fluffos/docs/lpc/source-files.md
Yucong Sun c914f03d66
Add local search and documentation guide for docs site (#1221)
* docs: add local full-text search and a contributor README

Add @easyops-cn/docusaurus-search-local to the Docusaurus site so the
docs get an offline search bar (index built at build time, no external
service). English and zh-CN pages are both indexed, and matched terms
are highlighted on the target page.

Add docs/README.md describing the Docusaurus setup, local dev/build
commands, search behavior, directory layout, and gotchas; exclude it
from the published site alongside CLAUDE.md. Point the root README's
docs/ entry at it.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TSzcESzU9947zkGzQ6SMmE

* docs: remove dead framework leftovers, fix index generation, complete the nav

Delete the VitePress (.vitepress/) and Jekyll (_layouts/, css/) leftovers,
the one-shot migration scripts (fix_md_header.py, fix_seealso.py), and the
stale keywords.json snapshot; prune the matching .gitignore entries and
docusaurus exclude patterns.

Rewrite gen_index.py for Docusaurus: it emitted dead .html links and
legacy 'layout: doc' frontmatter, choked on non-markdown entries, and
dropped nested categories — regenerating an index would have broken it.
It now emits the extension-less links the site actually uses, links
nested category indexes (restoring apply/* on the zh-CN index), and
refuses to run on the docs root. Fix update_index.sh's copy-paste titles
(zh-CN efun/build were titled 'APPLY'), stop it clobbering the
hand-written lpc/index.md, and cover cli/. Regenerated indexes pick up
the missing driver/ffi-plan entry. add_missing_efuns.py now takes the
keywords.json path as an argument instead of requiring a stale copy.

Move CNAME and the Google site-verification file into static/ so they
actually reach the published build output.

Complete the sidebar: link the CLI category to cli/index and add the
missing portbind/symbol/generate_keywords pages, and expose the
previously orphaned stdlib section under Reference.

Promote onBrokenLinks to 'throw' now the build is warning-free, and drop
the empty Demo section from the landing page.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TSzcESzU9947zkGzQ6SMmE

* docs: strip legacy 'layout: doc' frontmatter from all pages

Mechanical sweep removing the Jekyll-era 'layout: doc' line from every
doc page's frontmatter (Docusaurus ignores it), and the matching line
from the templates in docs/CLAUDE.md so new pages don't reintroduce it.
No content changes.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TSzcESzU9947zkGzQ6SMmE

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-07-09 22:09:55 -04:00

2.7 KiB

title
source files & object names

Source files and object names

LPC source files use the .lpc extension; the legacy .c extension is fully supported. This page describes how a name like "/std/room" (or "/std/room.c", or "/std/room.lpc") is resolved to a source file and to a loaded object.

Resolution rules

When the driver needs to load a file — load_object(), an inherit statement, clone_object() of an unloaded name, the master or simul_efun file from the config — it resolves the source like this:

  • An explicit extension is exact. load_object("/foo.c") probes only foo.c; load_object("/foo.lpc") probes only foo.lpc. The other spelling is never looked up.
  • Extension-less names prefer .lpc, then fall back to .c. load_object("/foo") loads foo.lpc if it exists, otherwise foo.c.
  • If no source file matches, the master's compile_object() apply is consulted with the extension-less name (the virtual object hook). If it declines, the load fails and load_object() returns 0.

Object names never carry an extension

A loaded object's name (what file_name() / base_name() return, and what the object registry is keyed by) is always the extension-less path: loading /std/room.lpc produces the object /std/room.

Consequently object identity is extension-blind:

  • find_object("/foo"), find_object("/foo.c") and find_object("/foo.lpc") all find the same loaded object.
  • load_object() consults the registry before the filesystem: any spelling of an already-loaded object's name returns that object; the exactness rule above only applies when the load actually reaches the disk.

The program name (prog->filename) is different: it records the real file that was compiled, extension included. That is the name reported by inherit_list(), deep_inherit_list(), error tracebacks, and compiler diagnostics.

object ob = load_object("/std/room");      // loads /std/room.lpc
file_name(ob);                             // "/std/room"
inherit_list(ob);                          // ({ "/std/container.lpc" })

Writing portable mudlib code

  • Refer to objects by their extension-less name in normal code ("/std/room"); use an explicit extension only when you really mean a specific file.
  • Do not append ".c" to names before calling load_object() / call_other() — pass the name through and let the driver resolve it.
  • When comparing against program names (e.g. results of function_exists() on file paths, inherit_list() entries), expect either extension.

The full behavior is pinned by the driver test testsuite/single/tests/efuns/dual_extension.lpc.