• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ JS_NewRuntime函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中JS_NewRuntime函数的典型用法代码示例。如果您正苦于以下问题:C++ JS_NewRuntime函数的具体用法?C++ JS_NewRuntime怎么用?C++ JS_NewRuntime使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了JS_NewRuntime函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: createRuntime

virtual JSRuntime * createRuntime() {
    JSRuntime *rt = JS_NewRuntime(768 * 1024, JS_USE_HELPER_THREADS);
    if (!rt)
        return nullptr;
    setNativeStackQuota(rt);
    return rt;
}
开发者ID:JasonGross,项目名称:mozjs,代码行数:7,代码来源:testGCOutOfMemory.cpp


示例2: INDENT_LOG

void TraceMonkeyEngine::init()
{
    Logging::log(Logging::DEBUG, "TraceMonkeyEngine::init\r\n");
    INDENT_LOG(Logging::DEBUG);

    assert(runtime == NULL);

    runtime = JS_NewRuntime(8L * 1024L * 1024L); // Force GC after X MB.
    if (runtime == NULL)
    {
        Logging::log(Logging::ERROR, "Cannot create TraceMonkey runtime\r\n");
        assert(0);
    }

    /* Create a context. */
    context = JS_NewContext(runtime, 8192);
    if (context == NULL)
    {
        Logging::log(Logging::ERROR, "Cannot create TraceMonkey runtime\r\n");
        assert(0);
    }

    JS_SetOptions(context, JSOPTION_VAROBJFIX);
    JS_SetVersion(context, JSVERSION_ECMA_3);
    JS_SetErrorReporter(context, reportError);

    // Create the global object. Store it locally for a while until it is usable by others
    JSObject* _global = JS_NewObject(context, &global_class, NULL, NULL);
    if (_global == NULL)
    {
        Logging::log(Logging::ERROR, "Cannot create TraceMonkey runtime\r\n");
        assert(0);
    }

    /* Populate the global object with the standard globals,
       like Object and Array. */
    if (!JS_InitStandardClasses(context, _global))
    {
        Logging::log(Logging::ERROR, "Cannot create TraceMonkey runtime\r\n");
        assert(0);
    }

    // Create our internal wrappers

    globalValue = ScriptValuePtr(new TraceMonkeyValue( this, true, OBJECT_TO_JSVAL(_global) ));
    global = _global; // Now that globalValue is set, it is usable by others, so reveal it

    // JITting
//    JS_ToggleOptions(context, JSOPTION_JIT); // Might be buggy, wait for 1.8 to release

// JS_MaybeGC - call during idle time in the main loop? Or other method?

// Use JS_SetContextPrivate and JS_GetContextPrivate to associate application-specific data with a context.
//  - Useful for security checks, once we have a context for the system and sandboxed contexts
//    for user scripts

    // Debugging features

    JS_SetGCZeal(context, 2); // XXX This is 'extremely high' - make a parameter, see MDC docs
}
开发者ID:Amplifying,项目名称:intensityengine,代码行数:60,代码来源:script_engine_tracemonkey.cpp


示例3: JS_NewRuntime

JSInterpreter::JSInterpreter() {
        /* Create a JS runtime. You always need at least one runtime per process. */
        rt = JS_NewRuntime(8 * 1024 * 1024);
        if (rt == NULL)
            throw * new std::runtime_error("Can't create JS runtime.");

        /*
         * Create a context. You always need a context per thread.
         * Note that this program is not multi-threaded.
         */
        cx = JS_NewContext(rt, 8192);
        if (cx == NULL)
            throw * new std::runtime_error("Can't create js context.");

        JS_SetOptions(cx, JSOPTION_VAROBJFIX | JSOPTION_JIT | JSOPTION_METHODJIT);
        JS_SetVersion(cx, JSVERSION_LATEST);
        JS_SetErrorReporter(cx, reportError);

        /*
         * Create the global object in a new compartment.
         * You always need a global object per context.
         */
        global = JS_NewCompartmentAndGlobalObject(cx, &global_class, NULL);
        if (global == NULL)
            throw * new std::runtime_error("Can't create global object.");

        /*
         * Populate the global object with the standard JavaScript
         * function and object classes, such as Object, Array, Date.
         */
        if (!JS_InitStandardClasses(cx, global))
            throw * new std::runtime_error("Can't initialise standard classes.");

    }
开发者ID:programmiersportgruppe,项目名称:structured-text-utils,代码行数:34,代码来源:js.cpp


示例4: round_js_sm_engine_init

bool round_js_sm_engine_init(RoundJavaScriptEngine* engine)
{
  if (!engine)
    return NULL;

  JS_SetCStringsAreUTF8();

  engine->cx = NULL;
  engine->rt = NULL;
  engine->obj = NULL;

  engine->rt = JS_NewRuntime(8L * 1024L * 1024L);
  if (!engine->rt)
    return false;

  engine->cx = JS_NewContext(engine->rt, 8192);
  if (!engine->cx)
    return false;

  JS_SetErrorReporter(engine->cx, RoundJSReportError);

  // Obsolete since JSAPI 16
  engine->obj = JS_NewCompartmentAndGlobalObject(engine->cx, &RoundJSGlobalClass, NULL);
  if (!engine->obj)
    return false;

  JS_InitStandardClasses(engine->cx, engine->obj);
  JS_DefineFunctions(engine->cx, engine->obj, JS_SM_FUNCTIONS);

  return true;
}
开发者ID:cybergarage,项目名称:round,代码行数:31,代码来源:js_sm_engine.c


示例5: js_init

static int
js_init(void)
{
  JSContext *cx;

  JS_SetCStringsAreUTF8();

  runtime = JS_NewRuntime(0x1000000);

  cx = js_newctx(err_reporter);

  JS_BeginRequest(cx);

  showtimeobj = JS_NewObject(cx, &showtime_class, NULL, NULL);
  JS_DefineFunctions(cx, showtimeobj, showtime_functions);

  JSFunction *fn = JS_DefineFunction(cx, showtimeobj, "RichText",
				     js_RichText, 1, 0);
  RichText = JS_GetFunctionObject(fn);
	     
  JS_AddNamedRoot(cx, &showtimeobj, "showtime");

  JS_EndRequest(cx);
  JS_DestroyContext(cx);

  return 0;
}
开发者ID:stallman,项目名称:showtime,代码行数:27,代码来源:js.c


示例6: main

int main(int argc, const char *argv[]) {
    /* Initialize the JS engine -- new/required as of SpiderMonkey 31. */
    /*if (!JS_Init())
       return 1;*/

    /* Create a JS runtime. */
    JSRuntime *rt = JS_NewRuntime(8L * 1024L * 1024L, JS_NO_HELPER_THREADS);
    if (!rt)
       return 1;

    /* Create a context. */
    JSContext *cx = JS_NewContext(rt, 8192);
    if (!cx)
       return 1;
    JS_SetOptions(cx, JSOPTION_VAROBJFIX);
    JS_SetErrorReporter(cx, reportError);

    int status = run(cx);

    JS_DestroyContext(cx);
    JS_DestroyRuntime(rt);

    /* Shut down the JS engine. */
    JS_ShutDown();

    return status;
}
开发者ID:AdrianArroyoCalle,项目名称:test-embed-language,代码行数:27,代码来源:main.cpp


示例7: ejs_alloc

spidermonkey_vm *sm_initialize(long thread_stack, long heap_size) {
  spidermonkey_vm *vm = ejs_alloc(sizeof(spidermonkey_vm));
  spidermonkey_state *state = ejs_alloc(sizeof(spidermonkey_state));
  state->branch_count = 0;
  state->error = NULL;
  state->terminate = 0;
  int gc_size = (int) heap_size * 0.25;
  vm->runtime = JS_NewRuntime(MAX_GC_SIZE);
  JS_SetGCParameter(vm->runtime, JSGC_MAX_BYTES, heap_size);
  JS_SetGCParameter(vm->runtime, JSGC_MAX_MALLOC_BYTES, gc_size);
  vm->context = JS_NewContext(vm->runtime, 8192);
  JS_SetScriptStackQuota(vm->context, thread_stack);

  begin_request(vm);
  JS_SetOptions(vm->context, JSOPTION_VAROBJFIX);
  JS_SetOptions(vm->context, JSOPTION_STRICT);
  JS_SetOptions(vm->context, JSOPTION_COMPILE_N_GO);
  JS_SetOptions(vm->context, JSVERSION_LATEST);
  vm->global = JS_NewCompartmentAndGlobalObject(vm->context, &global_class, NULL);
  JS_InitStandardClasses(vm->context, vm->global);
  JS_SetErrorReporter(vm->context, on_error);
  JS_SetOperationCallback(vm->context, on_branch);
  JS_SetContextPrivate(vm->context, state);
  JSNative funptr = (JSNative) &js_log;
  JS_DefineFunction(vm->context, JS_GetGlobalObject(vm->context), "ejsLog", funptr,
                    0, 0);
  end_request(vm);

  return vm;
}
开发者ID:systra,项目名称:erlang_js,代码行数:30,代码来源:spidermonkey.c


示例8: Runtime_new

PyObject*
Runtime_new(PyTypeObject* type, PyObject* args, PyObject* kwargs)
{
    Runtime* self = NULL;
    unsigned int stacksize = 0x2000000; // 32 MiB heap size.

    if (!PyArg_ParseTuple(args, "|I", &stacksize)) goto error;

#ifdef SPIDERMONKEY_31
    if (!JS_Init())
    {
        PyErr_SetString(JSError, "Failed to initilaize JS engine");
        goto error;
    }
#endif

    self = (Runtime*) type->tp_alloc(type, 0);
    if(self == NULL) goto error;

    self->rt = JS_NewRuntime(stacksize, JS_NO_HELPER_THREADS);
    if(self->rt == NULL)
    {
        PyErr_SetString(JSError, "Failed to allocate new JSRuntime.");
        goto error;
    }

    goto success;

error:
    Py_XDECREF(self);
    self = NULL;

success:
    return (PyObject*) self;
}
开发者ID:smurfix,项目名称:python-spidermonkey,代码行数:35,代码来源:runtime.cpp


示例9: js_init

static int
js_init(void)
{
  JSContext *cx;
  jsval val;

  JS_SetCStringsAreUTF8();

  runtime = JS_NewRuntime(0x1000000);

  cx = js_newctx(err_reporter);

  JS_BeginRequest(cx);

  showtimeobj = JS_NewObject(cx, &showtime_class, NULL, NULL);
  JS_DefineFunctions(cx, showtimeobj, showtime_functions);

  val = INT_TO_JSVAL(showtime_get_version_int());
  JS_SetProperty(cx, showtimeobj, "currentVersionInt", &val);

  val = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, htsversion));
  JS_SetProperty(cx, showtimeobj, "currentVersionString", &val);


  JSFunction *fn = JS_DefineFunction(cx, showtimeobj, "RichText",
				     js_RichText, 1, 0);
  RichText = JS_GetFunctionObject(fn);
	     
  JS_AddNamedRoot(cx, &showtimeobj, "showtime");

  JS_EndRequest(cx);
  JS_DestroyContext(cx);

  return 0;
}
开发者ID:Hr-,项目名称:showtime,代码行数:35,代码来源:js.c


示例10: theMain

int theMain(int argc, char **argv){
	obj.screenLog = TEMP_EN_LOG; //initially disable logging to screen.
		
	//Define the quit handler;
	signal(SIGTERM,exitHandle);
	initSDL();


	//JS_Init(); //SETUP SPIDERMONKEY -> NEW VERSION!!

	if(!(runtime = JS_NewRuntime(8L *1024*1024L * 8,JS_USE_HELPER_THREADS /*JS_NO_HELPER_THREADS*/ ))){
		fprint(stderr,"Could not setup runtime\n");
		exit(EXIT_FAILURE);
	}
	
	init_video_libraries(&argc,&argv);
	
	while(1){
		char *appPath = NULL;
		appPath = launchApp(MENU_SCRIPT,1);
		if(appPath == NULL)
			continue;
		loadApp(appPath);
	}
	return EXIT_SUCCESS;
}
开发者ID:joejoyce,项目名称:jsEngine,代码行数:26,代码来源:jsEngine.cpp


示例11: main

int
main (int argc, char *argv[])
{
    JSRuntime *rt;
    JSObject *glob;
    int number_failed;
    Suite *s;
    SRunner *sr;

    g_type_init ();
    
    rt = JS_NewRuntime(0x100000); 
    cx = JS_NewContext(rt, 0x1000); 

    /* create the global object here */
    glob = JS_NewObject(cx, NULL, NULL, NULL);
    JS_InitStandardClasses(cx, glob);

    s = gom_value_suite ();
    sr = srunner_create (s);

    srunner_run_all (sr, CK_NORMAL);
    number_failed = srunner_ntests_failed (sr);
    srunner_free (sr);

    return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}
开发者ID:jberkman,项目名称:gom,代码行数:27,代码来源:checkgom.c


示例12: main

int main(int argc, const char *argv[]) {
    /* JS variables. */
    JSRuntime *rt;
    JSContext *cx;
    JSObject *global;

    /* Create a JS runtime. */
    rt = JS_NewRuntime(8L * 1024L * 1024L,JS_NO_HELPER_THREADS);
    if (rt == NULL)
       return 1;

    /* Create a context. */
    cx = JS_NewContext(rt, 8192);
    if (cx == NULL)
       return 1;
    JS_SetOptions(cx, JSOPTION_VAROBJFIX | JSOPTION_METHODJIT);
    JS_SetVersion(cx, JSVERSION_LATEST);
    JS_SetErrorReporter(cx, reportError);

    /* Create the global object in a new compartment. */
    global = JS_NewGlobalObject(cx, &global_class, NULL);
    if (global == NULL)
       return 1;

    /* Populate the global object with the standard globals, like Object and Array. */
    if (!JS_InitStandardClasses(cx, global))
       return 1;

 
    /* Your application code here. This may include JSAPI calls
     * to create your own custom JavaScript objects and to run scripts.
     *
     * The following example code creates a literal JavaScript script,
     * evaluates it, and prints the result to stdout.
     *
     * Errors are conventionally saved in a JSBool variable named ok.
     */
	
	JS_DefineFunction(cx,global,"print",&js_print,0,0);
	
	// execJsFile(cx,"t.js");
	
	// testObj(cx);
	
	beforeTest(cx);
	execJsFile(cx,"t4.js");
	test(cx);
    
 
    /* End of your application code */
 
    /* Clean things up and shut down SpiderMonkey. */
    JS_DestroyContext(cx);
    JS_DestroyRuntime(rt);
    JS_ShutDown();
    return 0;
}
开发者ID:trarck,项目名称:learnspidermonkey,代码行数:57,代码来源:test_binding_object.cpp


示例13: createRuntime

virtual JSRuntime * createRuntime() override
{
    JSRuntime* rt = JS_NewRuntime(0);
    if (!rt)
        return nullptr;
    JS_SetGCParameter(rt, JSGC_MAX_BYTES, (uint32_t)-1);
    setNativeStackQuota(rt);
    return rt;
}
开发者ID:Nazi-Nigger,项目名称:gecko-dev,代码行数:9,代码来源:testOOM.cpp


示例14: JS_NewRuntime

bool Engine::init()
{
	m_runtime = JS_NewRuntime(8L*1024L*1024L);
	if ( m_runtime==NULL ) {
		return false;
	}

	return true;
}
开发者ID:CIHANGIRCAN,项目名称:vibestreamer,代码行数:9,代码来源:Engine.cpp


示例15: qq_js_init

qq_js_t* qq_js_init()
{
    qq_js_t* h =(qq_js_t*) s_malloc0(sizeof(*h));
    h->runtime = JS_NewRuntime(8L*1024L*1024L);
    h->context = JS_NewContext(h->runtime, 8*1024);
    JS_SetOptions(h->context, JSOPTION_VAROBJFIX);
    JS_SetErrorReporter(h->context, report_error);
    h->global = JS_NewCompartmentAndGlobalObject(h->context, &global_class, NULL);
    JS_InitStandardClasses(h->context, h->global);
    return h;
}
开发者ID:badcell,项目名称:kopete-lwqq,代码行数:11,代码来源:js.cpp


示例16: pacparser_init

// Initialize PAC parser.
//
// - Initializes JavaScript engine,
// - Exports dns_functions (defined above) to JavaScript context.
// - Sets error reporting function to print_jserror,
// - Evaluates JavaScript code in pacUtils variable defined in pac_utils.h.
int                                     // 0 (=Failure) or 1 (=Success)
pacparser_init()
{
  jsval rval;
  char *error_prefix = "pacparser.c: pacparser_init:";
  // Initialize JS engine
  if (!(rt = JS_NewRuntime(8L * 1024L * 1024L)) ||
      !(cx = JS_NewContext(rt, 8192)) ||
      !(global = JS_NewObject(cx, &global_class, NULL, NULL)) ||
      !JS_InitStandardClasses(cx, global)) {
    print_error("%s %s\n", error_prefix, "Could not initialize  JavaScript "
		  "runtime.");
    return 0;
  }
  JS_SetErrorReporter(cx, print_jserror);
  // Export our functions to Javascript engine
  if (!JS_DefineFunction(cx, global, "dnsResolve", dns_resolve, 1, 0)) {
    print_error("%s %s\n", error_prefix,
		  "Could not define dnsResolve in JS context.");
    return 0;
  }
  if (!JS_DefineFunction(cx, global, "myIpAddress", my_ip, 0, 0)) {
    print_error("%s %s\n", error_prefix,
		  "Could not define myIpAddress in JS context.");
    return 0;
  }
  if (!JS_DefineFunction(cx, global, "dnsResolveEx", dns_resolve_ex, 1, 0)) {
    print_error("%s %s\n", error_prefix,
      "Could not define dnsResolveEx in JS context.");
    return 0;
  }
  if (!JS_DefineFunction(cx, global, "myIpAddressEx", my_ip_ex, 0, 0)) {
    print_error("%s %s\n", error_prefix,
		  "Could not define myIpAddressEx in JS context.");
    return 0;
  }
  // Evaluate pacUtils. Utility functions required to parse pac files.
  if (!JS_EvaluateScript(cx,           // JS engine context
                         global,       // global object
                         pacUtils,     // this is defined in pac_utils.h
                         strlen(pacUtils),
                         NULL,         // filename (NULL in this case)
                         1,            // line number, used for reporting.
                         &rval)) {
    print_error("%s %s\n", error_prefix,
		  "Could not evaluate pacUtils defined in pac_utils.h.");
    return 0;
  }
  if (_debug()) print_error("DEBUG: Pacparser Initalized.\n");
  return 1;
}
开发者ID:betaY,项目名称:crawler,代码行数:57,代码来源:pacparser.c


示例17: CompileFile

bool CompileFile(const std::string &inputFilePath, const std::string &outputFilePath) {
    bool result = false;
    std::string ofp;
    if (!outputFilePath.empty()) {
        ofp = outputFilePath;
    }
    else {
        ofp = RemoveFileExt(inputFilePath) + BYTE_CODE_FILE_EXT;
    }
    std::cout << "Input file: " << inputFilePath << std::endl;
    JSRuntime * runtime = JS_NewRuntime(10 * 1024 * 1024, JS_NO_HELPER_THREADS);
    JSContext *context = JS_NewContext(runtime, 10240);
    JS_SetOptions(context, JSOPTION_TYPE_INFERENCE);
    JS_SetVersion(context, JSVERSION_LATEST);
    JS_SetOptions(context, JS_GetOptions(context) & ~JSOPTION_METHODJIT);
    JS_SetOptions(context, JS_GetOptions(context) & ~JSOPTION_METHODJIT_ALWAYS);
	JSObject* global = JS_NewGlobalObject(context, &GlobalClass, NULL);
    JS_SetErrorReporter(context, &ReportError);
	if (JS_InitStandardClasses(context, global)) {

        JS::CompileOptions options(context);
        options.setUTF8(true);
        options.setSourcePolicy(JS::CompileOptions::NO_SOURCE);
        js::RootedObject rootedObject(context, global);
        std::cout << "Compiling ..." << std::endl;
        JSScript *script = JS::Compile(context, rootedObject, options, inputFilePath.c_str());
        if (script) {
            void *data = NULL;
            uint32_t length = 0;
            std::cout << "Encoding ..." << std::endl;
            data = JS_EncodeScript(context, script, &length);
            if (data) {
                if (WriteFile(ofp, data, length)) {
                    std::cout << "Done! " << "Output file: " << ofp << std::endl;
                    result = true;
                }
            }
        }
        
    }
    if (context) {
        JS_DestroyContext(context);
        context = NULL;
    }
    if (runtime) {
        JS_DestroyRuntime(runtime);
        runtime = NULL;
    }
    return result;
}
开发者ID:csouls,项目名称:nyangame-v3,代码行数:50,代码来源:main.cpp


示例18: PR_GetCurrentThread

MozJSImplScope::MozRuntime::MozRuntime() {
    mongo::sm::reset(kMallocMemoryLimit);

    // If this runtime isn't running on an NSPR thread, then it is
    // running on a mongo thread. In that case, we need to insert a
    // fake NSPR thread so that the SM runtime can call PR functions
    // without falling over.
    auto thread = PR_GetCurrentThread();
    if (!thread) {
        PR_BindThread(_thread = PR_CreateFakeThread());
    }

    {
        stdx::unique_lock<stdx::mutex> lk(gRuntimeCreationMutex);

        if (gFirstRuntimeCreated) {
            // If we've already made a runtime, just proceed
            lk.unlock();
        } else {
            // If this is the first one, hold the lock until after the first
            // one's done
            gFirstRuntimeCreated = true;
        }

        _runtime = JS_NewRuntime(kMaxBytesBeforeGC);

        const StackLocator locator;
        const auto available = locator.available();
        if (available) {
            // We fudge by 64k for a two reasons. First, it appears
            // that the internal recursion checks that SM performs can
            // have stack usage between checks of more than 32k in
            // some builds. Second, some platforms report the guard
            // page (in the linux sense) as "part of the stack", even
            // though accessing that page will fault the process. We
            // don't have a good way of getting information about the
            // guard page on those platforms.
            //
            // TODO: What if we are running on a platform with very
            // large pages, like 4MB?
            JS_SetNativeStackQuota(_runtime, available.get() - (64 * 1024));
        }
    }

    uassert(ErrorCodes::JSInterpreterFailure, "Failed to initialize JSRuntime", _runtime);

    _context = JS_NewContext(_runtime, kStackChunkSize);
    uassert(ErrorCodes::JSInterpreterFailure, "Failed to initialize JSContext", _context);
}
开发者ID:Jaryli,项目名称:mongo,代码行数:49,代码来源:implscope.cpp


示例19: rpmjsNew

/* XXX FIXME: Iargv/Ienviron are now associated with running. */
rpmjs rpmjsNew(char ** av, uint32_t flags)
{
    rpmjs js =
#ifdef	NOTYET
	(flags & 0x80000000) ? rpmjsI() :
#endif
	rpmjsGetPool(_rpmjsPool);
    JSI_t I = NULL;

#if defined(WITH_GPSEE)

#if defined(XXX_GPSEE_DEBUGGER)	/* XXX js->jsdc? */
    JSDContext *jsdc;
#endif

    if (flags == 0)
	flags = _rpmjs_options;

    if (F_ISSET(flags, NOUTF8) || getenv("GPSEE_NO_UTF8_C_STRINGS")) {
	JS_DestroyRuntime(JS_NewRuntime(1024));
	putenv((char *) "GPSEE_NO_UTF8_C_STRINGS=1");
    }

    /* XXX FIXME: js->Iargv/js->Ienviron for use by rpmjsRunFile() */
    I = gpsee_createInterpreter();
#if defined(XXX_GPSEE_DEBUGGER)
    js->jsdc = gpsee_initDebugger(I->cx, I->realm, DEBUGGER_JS);
#endif

#ifdef	NOTYET	/* FIXME: dig out where NOCACHE has moved. */
    if (F_ISSET(flags, NOCACHE))
	I->useCompilerCache = 0;
#endif
    if (F_ISSET(flags, NOWARN)) {
	gpsee_runtime_t * grt = JS_GetRuntimePrivate(JS_GetRuntime(I->cx));
	grt->errorReport |= er_noWarnings;
    }

    JS_SetOptions(I->cx, (flags & 0xffff));
#if defined(JS_GC_ZEAL)
    JS_SetGCZeal(I->cx, _rpmjs_zeal);
#endif
#endif	/* WITH_GPSEE */

    js->flags = flags;
    js->I = I;

    return rpmjsLink(js);
}
开发者ID:cmjonze,项目名称:rpm5_tarballs,代码行数:50,代码来源:rpmjs.c


示例20: JS_NewRuntime

JsExecutionContext::JsExecutionContext(JsParser *jsParser)
{
  parser = jsParser;
  /* Create a new runtime environment. */
  rt = JS_NewRuntime(8L * 1024L * 1024L);
  if (!rt) {
    error("JsParser :: error creating runtime");
    return; /* XXX should return int or ptr! */
  }

  /* Create a new context. */
  cx = JS_NewContext(rt, STACK_CHUNK_SIZE);
  /* if global_context does not have a value, end the program here */
  if (cx == NULL) {
    error("JsParser :: error creating context");
    return;
  }

  JS_BeginRequest(cx);
  // Store a reference to ourselves in the context ...
  JS_SetContextPrivate(cx, parser);

  /* Set a more strict error checking */
  JS_SetOptions(cx, JSOPTION_VAROBJFIX); // | JSOPTION_STRICT);

  /* Set the branch callback */
#if defined JSOPTION_NATIVE_BRANCH_CALLBACK
  JS_SetBranchCallback(cx, js_static_branch_callback);
#else
  JS_SetOperationCallback(cx, js_static_branch_callback);
#endif

  /* Set the error reporter */
  JS_SetErrorReporter(cx, js_error_reporter);

  /* Create the global object here */
  //  JS_SetGlobalObject(global_context, global_object);
  //  this is done in init_class / JS_InitStandardClasses.
  obj = JS_NewObject(cx, &global_class, NULL, NULL);
  init_class();
  JS_EndRequest(cx);
  // deassociate this context from the creating thread
  // so that it can be used in other threads
  // https://developer.mozilla.org/en/SpiderMonkey/JSAPI_Reference/JS_NewContext
  JS_ClearContextThread(cx);
  /** register SIGINT signal */
  //   signal(SIGINT, js_sigint_handler);
}
开发者ID:dyne,项目名称:FreeJ,代码行数:48,代码来源:jsparser.cpp



注:本文中的JS_NewRuntime函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ JS_NewStringCopyN函数代码示例发布时间:2022-05-30
下一篇:
C++ JS_NewContext函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap