Expand description
The C structs whose bytes C fills in and we read.
JSClassDef and JSCFunctionListEntry are built by the caller’s compiler as static
data, then handed to us by pointer. Nothing about them is negotiated at runtime: a field
at the wrong offset is a silent misread, so every one of these is asserted against the
number gcc printed for offsetof on this platform (tests/abi.rs).
Measured on x86-64 Linux with the reference quickjs.h:
JSCFunctionListEntry 32 bytes: name 0, prop_flags 8, def_type 9, magic 10, u 16
u.func.length 16, u.func.cproto 17, u.func.cfunc 24
u.getset.get 16, u.getset.set 24, u.str/i32/i64/f64 16
JSClassDef 40 bytes: class_name 0, finalizer 8, gc_mark 16, call 24, exotic 32§Why JSCFunctionType is a union of function pointers
The reference spells one union for fourteen calling conventions and casts through it. We
only ever read the pointer out and call it with the convention the surrounding
cproto/def_type names, which is what the reference’s own JS_SetPropertyFunctionList
does too — so the union stays opaque here and JSCFunctionType::as_ptr is the one
accessor.
Modules§
- prop
JS_PROP_*: the attribute bits aJSCFunctionListEntry::prop_flagscarries.
Structs§
- Function
Entry - The
u.funchalf ofJSCFunctionListEntry: a function plus its arity and convention. - GetSet
Entry - The
u.getsethalf: a getter and a setter, either of which may be null. - JSCFunction
List Entry JSCFunctionListEntry: one row of a static table a C module hands us.- JSCFunction
Type JSCFunctionType: the union of everyJSCFunction*pointer type.- JSClass
Def JSClassDef: whatJS_NewClassis handed.- JSClass
Exotic Methods JSClassExoticMethods: the traps a class may override.- JSMalloc
Functions JSMallocFunctions: a custom allocator forJS_NewRuntime2.- JSMemory
Usage JSMemoryUsage: the shapeJS_ComputeMemoryUsagefills in.- JSPrint
Value Options JSPrintValueOptions: howJS_PrintValuerenders a value.- JSProperty
Descriptor JSPropertyDescriptor: one complete property, asJS_GetOwnPropertyreports it.- JSProperty
Enum JSPropertyEnum: one entry ofJS_GetOwnPropertyNames’ answer.- JsModule
Def JSModuleDef: a C module’s definition, asJS_NewCModuleanswers it.
Enums§
- CFunction
Enum JSCFunctionEnum: which calling convention aJSCFunctionTypeholds.
Constants§
- JS_
CALL_ FLAG_ CONSTRUCTOR JS_CALL_FLAG_CONSTRUCTOR: the flagJSClassCallreceives on anewcall.- JS_
DEF_ ALIAS JS_DEF_ALIAS.- JS_
DEF_ CFUNC JS_DEF_CFUNC: a function, withu.funcfilled in.- JS_
DEF_ CGETSET JS_DEF_CGETSET: a getter/setter pair with nomagic.- JS_
DEF_ CGETSET_ MAGIC JS_DEF_CGETSET_MAGIC: a getter/setter pair that also receivesmagic.- JS_
DEF_ OBJECT JS_DEF_OBJECT: a nested function-list table.- JS_
DEF_ PROP_ ATOM JS_DEF_PROP_ATOM.- JS_
DEF_ PROP_ BOOL JS_DEF_PROP_BOOL.- JS_
DEF_ PROP_ DOUBLE JS_DEF_PROP_DOUBLE.- JS_
DEF_ PROP_ INT32 JS_DEF_PROP_INT32.- JS_
DEF_ PROP_ INT64 JS_DEF_PROP_INT64.- JS_
DEF_ PROP_ STRING JS_DEF_PROP_STRING.- JS_
DEF_ PROP_ UNDEFINED JS_DEF_PROP_UNDEFINED.
Type Aliases§
- Bool
JS_BOOL.- CFunction
Data JSCFunctionData:(ctx, this_val, argc, argv, magic, func_data).- Class
Call JSClassCall:(ctx, func_obj, this_val, argc, argv, flags).- Class
Finalizer JSClassFinalizer:void (*)(JSRuntime *rt, JSValue val).- ClassGC
Mark JSClassGCMark:void (*)(JSRuntime *rt, JSValueConst val, JS_MarkFunc *mark_func).- ClassId
JSClassID: auint32_t.0isJS_INVALID_CLASS_ID.- Interrupt
Handler JSInterruptHandler: return non-zero to abort the running script.- JobFunc
JSJobFunc: a job the host enqueued withJS_EnqueueJob.- Module
Check Attrs JSModuleCheckSupportedImportAttributes: refuse an attribute set the host cannot honour.- Module
Init Func JSModuleInitFunc: fills a module’s exports in.- Module
Loader Func JSModuleLoaderFunc: load the module a normalised key names.- Module
Loader Func2 JSModuleLoaderFunc2: the same, plus the import attributes.- Module
Normalize Func JSModuleNormalizeFunc: turn(base_name, name)into the module’s key.- Print
Value Write JSPrintValueWrite: receives the rendered text in chunks.- Promise
Rejection Tracker JSHostPromiseRejectionTracker.- RawFunction
JSCFunction: the plain(ctx, this_val, argc, argv)shape.
Unions§
- Function
List Union - The
uunion ofJSCFunctionListEntry.