Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- typedef struct {
- JSContext *ctx;
- jsProcessor2 *jsp2;
- JSValue obj;
- JSValue func;
- int argc;
- JSValue argv[];
- } qjsContainer;
- static JSClassID qjs_class_id;
- static const JSClassDef qjs_class = {
- "testclass",
- };
- static const JSCFunctionListEntry jsProcessor2_proto_funcs[] =
- {
- JS_CFUNC_DEF("error_report",1,jsProcessor2::error_report),
- JS_CFUNC_DEF("local_log",1,jsProcessor2::local_log),
- JS_CFUNC_DEF("log",1,jsProcessor2::log),
- }
- class init :
- qjsContainer *qjs_c = (qjsContainer *) malloc(sizeof(qjsContainer));
- qjs_c->ctx = ctx;
- qjs_c->jsp2 = this;
- JS_NewClassID(&qjs_class_id);
- JS_NewClass(rt, qjs_class_id, &qjs_class);
- JSValue proto = JS_NewObject(ctx);
- JS_SetPropertyFunctionList(ctx, proto, jsProcessor2_proto_funcs, countof(jsProcessor2_proto_funcs));
- JS_SetClassProto(ctx,qjs_class_id, proto);
- obj = JS_NewObjectClass(ctx,qjs_class_id);
- JS_SetOpaque(obj,qjs_c);
- JSValue ret = JS_Eval(ctx,record_text,strlen(record_text),"<evalScript>", JS_EVAL_TYPE_GLOBAL);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement