Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions docs/docs/developer-guide/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

Expand Down
20 changes: 10 additions & 10 deletions quickjs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 */
Expand Down
1 change: 0 additions & 1 deletion quickjs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Loading