Advertisement
Guest User

Untitled

a guest
Dec 15th, 2019
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.03 KB | None | 0 0
  1. typedef struct {
  2.     JSContext *ctx;
  3.     jsProcessor2 *jsp2;
  4.     JSValue obj;
  5.     JSValue func;
  6.     int argc;
  7.     JSValue argv[];
  8. } qjsContainer;
  9.  
  10. static JSClassID qjs_class_id;
  11.  
  12. static const JSClassDef qjs_class = {
  13.         "testclass",
  14. };
  15.  
  16. static const JSCFunctionListEntry jsProcessor2_proto_funcs[] =
  17. {
  18.     JS_CFUNC_DEF("error_report",1,jsProcessor2::error_report),
  19.     JS_CFUNC_DEF("local_log",1,jsProcessor2::local_log),
  20.     JS_CFUNC_DEF("log",1,jsProcessor2::log),
  21. }
  22.  
  23. class init :
  24.  
  25. qjsContainer *qjs_c = (qjsContainer *) malloc(sizeof(qjsContainer));
  26. qjs_c->ctx = ctx;
  27. qjs_c->jsp2 = this;
  28. JS_NewClassID(&qjs_class_id);
  29. JS_NewClass(rt, qjs_class_id, &qjs_class);
  30. JSValue proto = JS_NewObject(ctx);
  31. JS_SetPropertyFunctionList(ctx, proto, jsProcessor2_proto_funcs, countof(jsProcessor2_proto_funcs));
  32. JS_SetClassProto(ctx,qjs_class_id, proto);
  33. obj = JS_NewObjectClass(ctx,qjs_class_id);
  34. JS_SetOpaque(obj,qjs_c);
  35. 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