mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-03 07:54:40 +08:00
scr_runtime.h now includes 48 module headers (scr_core.h, scr_rc.h, scr_string.h, scr_dyn.h, scr_http.h, ...) in dependency order and holds no declarations. Each module header holds whole sections of the former file, includes the headers whose names it uses, and compiles on its own. Declarations, macros, struct layouts and inline bodies are unchanged. Five blocks move to join their module: the class-hierarchy vtable header (into scr_error.h, after the string core), the node:timers/promises pair (into scr_async.h), the JSON.parse entry points and the JSON output buffer (into scr_json.h, after the dyn declarations) and the EventTarget block (after scr_json.h). No moved block uses or declares a name that a block it moves past uses or declares. The string methods keep their position after the class objects in scr_string_methods.h, because their struct ScrDyn parameters rely on the file-scope struct ScrDyn declaration there. The runtime ABI scan reads scr_runtime.h with its module headers expanded in include order. A runtime test compiles every module header on its own. scripts/runtime-header-hunks.mjs retargets a diff of the single-file header onto the module headers.
35 lines
1.4 KiB
C
35 lines
1.4 KiB
C
/* scriptc runtime — class instance accounting (scr_object.c). Included by
|
|
* scr_runtime.h, which says where new declarations go. */
|
|
#ifndef SCR_OBJECT_H
|
|
#define SCR_OBJECT_H
|
|
|
|
#include "scr_core.h"
|
|
|
|
/* ── class instances ─────────────────────────────────────────────────
|
|
* Objects are per-class C structs emitted by the compiler (shared header:
|
|
* `size_t rc` first), with per-class new/retain/release helpers also
|
|
* emitted. The runtime provides only the RC-audit hooks those helpers call.
|
|
*/
|
|
void scr_obj_alloc_note(void);
|
|
void scr_obj_free_note(void);
|
|
/* Emitted by the RC-audit lane's ProgramLifetime constructors, after the
|
|
* allocation note: such instances are never freed (the exit audit skips its
|
|
* leak report, and LeakSanitizer scans them as roots). */
|
|
void scr_obj_lifetime_note(const void *obj);
|
|
#ifdef SCR_RC_AUDIT
|
|
long scr_obj_live_count(void);
|
|
long scr_obj_lifetime_count(void);
|
|
#else
|
|
/* Only the RC audit lane counts live objects. Other runtimes keep the
|
|
* out-of-line no-op symbols for direct-emission objects that still call
|
|
* them (scr_object.c), while runtime-internal call sites compile away. */
|
|
#define scr_obj_alloc_note() ((void)0)
|
|
#define scr_obj_free_note() ((void)0)
|
|
#endif
|
|
#ifdef SCR_RC_AUDIT
|
|
/* A released lifetime region freed `n` program-lifetime instances. */
|
|
void scr_obj_lifetime_forget(long n);
|
|
#endif
|
|
|
|
#endif /* SCR_OBJECT_H */
|