Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- init :
- js_State *ctx = js_newstate(NULL,NULL,JS_STRICT);
- if (!ctx)
- {
- printf("js_State init error.\n");
- exit(-1);
- }
- js_getglobal(ctx,"Object");
- js_getproperty(ctx, -1, "prototype");
- js_newuserdata(ctx,"jsState",new jsState(),0);
- js_newcfunction(ctx,native_print,"print", 1 /*nargs*/);
- js_setglobal(ctx,"print");
- js_dostring(ctx,job_text.c_str());
- void jsProcessor::native_print(js_State *ctx)
- {
- jsState *j = (jsState *)js_touserdata(ctx,0,"jsState");
- printf("%s\n",js_tostring(ctx, 1));
- js_pushundefined(ctx);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement