diff --git a/docs/docs/developer-guide/intro.md b/docs/docs/developer-guide/intro.md index 4d85efb08..551bb37b2 100644 --- a/docs/docs/developer-guide/intro.md +++ b/docs/docs/developer-guide/intro.md @@ -80,11 +80,9 @@ it. A `gc_mark` method can be provided so that the cycle removal algorithm can find the other objects referenced by this object. Other methods are available to define exotic object behaviors. -The Class ID are allocated per-runtime. The -`JSClass` are allocated per `JSRuntime`. `JS_SetClassProto()` -is used to define a prototype for a given class in a given -`JSContext`. `JS_NewObjectClass()` sets this prototype in the -created object. +The class and class ID are allocated per-runtime. `JS_SetClassProto()` +is used to define a prototype for a given class in a given `JSContext`. +`JS_NewObjectClass()` sets this prototype in the created object. Examples are available in `quickjs-libc.c`. diff --git a/quickjs.c b/quickjs.c index ab6c0b9e2..19d142d7f 100644 --- a/quickjs.c +++ b/quickjs.c @@ -324,6 +324,16 @@ typedef struct JSValueLink { JSValueConst value; } JSValueLink; +typedef struct JSClass { + uint32_t class_id; /* 0 means free entry */ + JSAtom class_name; + JSClassFinalizer *finalizer; + JSClassGCMark *gc_mark; + JSClassCall *call; + /* pointers for exotic behavior, can be NULL if none are present */ + const JSClassExoticMethods *exotic; +} JSClass; + struct JSRuntime { JSMallocFunctions mf; JSMallocState malloc_state; @@ -414,16 +424,6 @@ struct JSRuntime { JSRuntimeFinalizerState *finalizers; }; -struct JSClass { - uint32_t class_id; /* 0 means free entry */ - JSAtom class_name; - JSClassFinalizer *finalizer; - JSClassGCMark *gc_mark; - JSClassCall *call; - /* pointers for exotic behavior, can be NULL if none are present */ - const JSClassExoticMethods *exotic; -}; - typedef struct JSStackFrame { struct JSStackFrame *prev_frame; /* NULL if first stack frame */ JSValue cur_func; /* current function, JS_UNDEFINED if the frame is detached */ diff --git a/quickjs.h b/quickjs.h index a78077989..30269f27d 100644 --- a/quickjs.h +++ b/quickjs.h @@ -160,7 +160,6 @@ extern "C" { typedef struct JSRuntime JSRuntime; typedef struct JSContext JSContext; typedef struct JSObject JSObject; -typedef struct JSClass JSClass; typedef uint32_t JSClassID; typedef uint32_t JSAtom;