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

C++ JS_GetContextPrivate函数代码示例

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

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



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

示例1: nidium_sm_timer

bool JSGlobal::JS_setInterval(JSContext *cx, JS::CallArgs &args)
{
    struct nidium_sm_timer *params;
    int ms = 0, i;
    int argc = args.length();

    params = new nidium_sm_timer(cx);

    if (!params) {
        JS_ReportOutOfMemory(cx);
        return false;
    }

    params->cx     = cx;
    params->global = m_Instance;
    params->argc   = nidium_max(0, argc - 2);

    params->argv = new JS::PersistentRootedValue *[params->argc];

    for (i = 0; i < argc - 2; i++) {
        params->argv[i] = new JS::PersistentRootedValue(cx);
    }

    if (!JSUtils::ReportIfNotFunction(cx, args[0])) {
        delete[] params->argv;
        delete params;
        return false;
    }

    params->func = args[0];

    if (argc > 1 && !JS::ToInt32(cx, args[1], &ms)) {
        ms = 0;
    }

    params->ms = nidium_max(8, ms);

    for (i = 0; i < static_cast<int>(argc) - 2; i++) {
        *params->argv[i] = args.array()[i + 2];
    }

    ape_timer_t *timer = APE_timer_create(
        static_cast<ape_global *>(JS_GetContextPrivate(cx)), params->ms,
        nidium_timerng_wrapper, static_cast<void *>(params));

    APE_timer_unprotect(timer);
    APE_timer_setclearfunc(timer, nidium_timer_deleted);

    args.rval().setNumber(static_cast<double>(APE_timer_getid(timer)));

    return true;
}
开发者ID:nidium,项目名称:Nidium,代码行数:52,代码来源:JSGlobal.cpp


示例2: APE_timer_clearbyid

bool JSGlobal::JS_clearTimeout(JSContext *cx, JS::CallArgs &args)
{
    double identifier;

    if (!JS_ConvertArguments(cx, args, "d", &identifier)) {
        return false;
    }

    APE_timer_clearbyid(static_cast<ape_global *>(JS_GetContextPrivate(cx)),
                        static_cast<uint64_t>(identifier), 0);

    return true;
}
开发者ID:nidium,项目名称:Nidium,代码行数:13,代码来源:JSGlobal.cpp


示例3: setContentType

JSBool JsHttpServerResponse::setContentType(JSContext *cx,JSObject *obj,uintN argc,jsval *argv,jsval *rval)
{
	char *contentType = {0};

	if ( !JS_ConvertArguments(cx,argc,argv,"s",&contentType) ) {
		return Engine::throwUsageError(cx,argv);
	}

	ContextPrivate *cxPrivate = (ContextPrivate*)JS_GetContextPrivate(cx);
	cxPrivate->getHttpResponse().setContentType(contentType);

	return JS_TRUE;
}
开发者ID:CIHANGIRCAN,项目名称:vibestreamer,代码行数:13,代码来源:JsHttpServerResponse.cpp


示例4: write

JSBool JsHttpServerResponse::write(JSContext *cx,JSObject *obj,uintN argc,jsval *argv,jsval *rval)
{
	char *output = {0};

	if ( !JS_ConvertArguments(cx,argc,argv,"s",&output) ) {
		return Engine::throwUsageError(cx,argv);
	}

	ContextPrivate *cxPrivate = (ContextPrivate*)JS_GetContextPrivate(cx);
	cxPrivate->getHttpResponse().write(output,strlen(output));

	return JS_TRUE;
}
开发者ID:CIHANGIRCAN,项目名称:vibestreamer,代码行数:13,代码来源:JsHttpServerResponse.cpp


示例5: gjs_on_context_gc

static JSBool
gjs_on_context_gc (JSContext *cx,
                   JSGCStatus status)
{
    GjsContext *gjs_context = JS_GetContextPrivate(cx);

    if (status == JSGC_END) {
        if (gjs_context->idle_emit_gc_id == 0)
            gjs_context->idle_emit_gc_id = g_idle_add (gjs_context_idle_emit_gc, gjs_context);
    }
    
    return TRUE;
}
开发者ID:RavetcoFX,项目名称:cjs,代码行数:13,代码来源:context.c


示例6: error_reporter

static void
error_reporter(JSContext *ctx, const char *message, JSErrorReport *report)
{
	struct ecmascript_interpreter *interpreter = JS_GetContextPrivate(ctx);
	struct session *ses = interpreter->vs->doc_view->session;
	struct terminal *term;
	unsigned char *strict, *exception, *warning, *error;
	struct string msg;

	assert(interpreter && interpreter->vs && interpreter->vs->doc_view
	       && ses && ses->tab);
	if_assert_failed goto reported;

	term = ses->tab->term;

#ifdef CONFIG_LEDS
	set_led_value(ses->status.ecmascript_led, 'J');
#endif

	if (!get_opt_bool("ecmascript.error_reporting", ses)
	    || !init_string(&msg))
		goto reported;

	strict	  = JSREPORT_IS_STRICT(report->flags) ? " strict" : "";
	exception = JSREPORT_IS_EXCEPTION(report->flags) ? " exception" : "";
	warning   = JSREPORT_IS_WARNING(report->flags) ? " warning" : "";
	error	  = !report->flags ? " error" : "";

	add_format_to_string(&msg, _("A script embedded in the current "
			"document raised the following%s%s%s%s", term),
			strict, exception, warning, error);

	add_to_string(&msg, ":\n\n");
	add_to_string(&msg, message);

	if (report->linebuf && report->tokenptr) {
		int pos = report->tokenptr - report->linebuf;

		add_format_to_string(&msg, "\n\n%s\n.%*s^%*s.",
			       report->linebuf,
			       pos - 2, " ",
			       strlen(report->linebuf) - pos - 1, " ");
	}

	info_box(term, MSGBOX_FREE_TEXT, N_("JavaScript Error"), ALIGN_CENTER,
		 msg.source);

reported:
	/* Im clu'les. --pasky */
	JS_ClearPendingException(ctx);
}
开发者ID:Efreak,项目名称:elinks,代码行数:51,代码来源:spidermonkey.c


示例7: js_saveline

static JSBool
js_saveline(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
	sbbs_t*		sbbs;

	if((sbbs=(sbbs_t*)JS_GetContextPrivate(cx))==NULL)
		return(JS_FALSE);

	sbbs->slatr[sbbs->slcnt]=sbbs->latr; 
	sprintf(sbbs->slbuf[sbbs->slcnt<SAVE_LINES ? sbbs->slcnt++ : sbbs->slcnt] 
			,"%.*s",sbbs->lbuflen,sbbs->lbuf); 
	sbbs->lbuflen=0; 
    return(JS_TRUE);
}
开发者ID:ftnapps,项目名称:pkg-sbbs,代码行数:14,代码来源:js_console.cpp


示例8: js_restoreline

static JSBool
js_restoreline(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
	sbbs_t*		sbbs;

	if((sbbs=(sbbs_t*)JS_GetContextPrivate(cx))==NULL)
		return(JS_FALSE);

	sbbs->lbuflen=0; 
	sbbs->attr(sbbs->slatr[--sbbs->slcnt]);
	sbbs->rputs(sbbs->slbuf[sbbs->slcnt]); 
	sbbs->curatr=LIGHTGRAY;
    return(JS_TRUE);
}
开发者ID:ftnapps,项目名称:pkg-sbbs,代码行数:14,代码来源:js_console.cpp


示例9: js_cursor_left

static JSBool
js_cursor_left(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
	int32		val=1;
	sbbs_t*		sbbs;

	if((sbbs=(sbbs_t*)JS_GetContextPrivate(cx))==NULL)
		return(JS_FALSE);

	if(argc)
		JS_ValueToInt32(cx,argv[0],&val);
	sbbs->cursor_left(val);
    return(JS_TRUE);
}
开发者ID:ftnapps,项目名称:pkg-sbbs,代码行数:14,代码来源:js_console.cpp


示例10: go_func_callback

/* The function callback. */
JSBool go_func_callback(JSContext *cx, uintN argc, jsval *vp) {
	JSObject *callee = JSVAL_TO_OBJECT(JS_CALLEE(cx, vp));

	jsval name;
	JS_GetProperty(cx, callee, "name", &name);

	char* cname = JS_EncodeString(cx, JS_ValueToString(cx, name));

	JSBool result = call_go_func(JS_GetContextPrivate(cx), cname, argc, vp);

	JS_free(cx, (void*)cname);

	return result;
}
开发者ID:MrXiaoZ,项目名称:monkey,代码行数:15,代码来源:monkey.c


示例11: xgg_pbar_propop_xn_set

/** set numeric property (xn).
 */
JSBool xgg_pbar_propop_xn_set(JSContext *pcxa, JSObject *pobja, jsval id, jsval *vp)
{
	XGGPRIVHDR*		phdr = JS_GetPrivate(pcxa, pobja);
	XGG_PBAR_PRIV*	pv0 = JS_GetPrivate(pcxa, pobja);
	XJSEXADGELEM*	pelem0 = phdr->pxadgelem;
	XJSECTX*		pjsectx = (XJSECTX*)JS_GetContextPrivate(pcxa);
	XJSE_ASSERT(pelem0 != 0);	// basicelement inheritances must have this

	xjse_result_t	xr1;
	xjse_int_t		nid = 0;//, nvalue = 0;//, n1;
	char*			psz0;
	JS_ValueToInt32(pcxa, id, &nid);
	//JS_ValueToInt32(pcxa, vp[0], &nvalue);
	//XJSE_TRACE("xgg_pbar_propop_xn_set. [%d](%d)", nid, nvalue);

	switch(nid) {
	case PBAR_TID_EMPTYIMAGE:
		psz0 = JS_GetStringBytes(JS_ValueToString(pcxa, vp[0]));
		xr1 = xgg_xadget_reload_img(pjsectx, &(pv0->ppbempty), psz0, 0, 0);
		if(xr1 != XJSE_SUCCESS)
			goto	failed;
		if(pelem0->fcx == 0.0f)
			pelem0->fcx = (xjse_float_t)(pv0->ppbempty->nimgwidth);
		if(pelem0->fcy == 0.0f)
			pelem0->fcy = (xjse_float_t)(pv0->ppbempty->nimgheight);
		break;
	case PBAR_TID_FULLIMAGE:
		psz0 = JS_GetStringBytes(JS_ValueToString(pcxa, vp[0]));
		xr1 = xgg_xadget_reload_img(pjsectx, &(pv0->ppbfull), psz0, 0, 0);
		if(xr1 != XJSE_SUCCESS)
			goto	failed;
		break;
	case PBAR_TID_MAX:
		JS_ValueToInt32(pcxa, vp[0], &(pv0->nmax));
		break;
	case PBAR_TID_MIN:
		JS_ValueToInt32(pcxa, vp[0], &(pv0->nmin));
		break;
	case PBAR_TID_VALUE:
		JS_ValueToInt32(pcxa, vp[0], &(pv0->nvalue));
		break;
	default:
		XJSE_TRACE("(E) unknown xn prop [property id: %d]", nid);
	}

	return	JS_TRUE;

failed:
	return	JS_FALSE;
}
开发者ID:odistagon,项目名称:cyeonna,代码行数:52,代码来源:xgg_progressbar.c


示例12: js_cleartoeol

static JSBool
js_cleartoeol(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
	sbbs_t*		sbbs;

	if((sbbs=(sbbs_t*)JS_GetContextPrivate(cx))==NULL)
		return(JS_FALSE);

	if(argc)
		js_set_attr(cx, sbbs, argv[0]);

	sbbs->cleartoeol();
    return(JS_TRUE);
}
开发者ID:ftnapps,项目名称:pkg-sbbs,代码行数:14,代码来源:js_console.cpp


示例13: branch_cb

JSBool
branch_cb(JSContext* jscx, JSScript* script)
{
    Context* pycx = (Context*) JS_GetContextPrivate(jscx);
    time_t now = time(NULL);

    if(pycx == NULL)
    {
        JS_ReportError(jscx, "Failed to find Python context.");
        return JS_FALSE;
    }

    // Get out quick if we don't have any quotas.
    if(pycx->max_time == 0 && pycx->max_heap == 0)
    {
        return JS_TRUE;
    }

    // Only check occasionally for resource usage.
    pycx->branch_count++;
    if((pycx->branch_count > 0x3FFF) != 1)
    {
        return JS_TRUE;
    }

    pycx->branch_count = 0;

    if(pycx->max_heap > 0 && jscx->runtime->gcBytes > pycx->max_heap)
    {
        // First see if garbage collection gets under the threshold.
        JS_GC(jscx);
        if(jscx->runtime->gcBytes > pycx->max_heap)
        {
            PyErr_NoMemory();
            return JS_FALSE;
        }
    }

    if(
        pycx->max_time > 0
        && pycx->start_time > 0
        && pycx->max_time < now - pycx->start_time
    )
    {
        PyErr_SetNone(PyExc_SystemError);
        return JS_FALSE;
    }

    return JS_TRUE;
}
开发者ID:Jonnyliu,项目名称:phoneyc,代码行数:50,代码来源:context.c


示例14: MOZ_ASSERT

  ~WorkletJSContext() override
  {
    MOZ_ASSERT(!NS_IsMainThread());

    JSContext* cx = MaybeContext();
    if (!cx) {
      return;   // Initialize() must have failed
    }

    delete static_cast<WorkletThreadContextPrivate*>(JS_GetContextPrivate(cx));
    JS_SetContextPrivate(cx, nullptr);

    nsCycleCollector_shutdown();
  }
开发者ID:heiher,项目名称:gecko-dev,代码行数:14,代码来源:WorkletThread.cpp


示例15: resolve

JSBool
resolve(JSContext* jscx, JSObject* jsobj, jsval key)
{
    Context* pycx = NULL;
    PyObject* pykey = NULL;
    jsid pid;
    JSBool ret = JS_FALSE;

    pycx = (Context*) JS_GetContextPrivate(jscx);
    if(pycx == NULL)
    {
        JS_ReportError(jscx, "Failed to get Python context.");
        goto done;
    }

    // Bail if there's no registered global handler.
    if(pycx->global == NULL)
    {
        ret = JS_TRUE;
        goto done;
    }

    pykey = js2py(pycx, key);
    if(pykey == NULL) goto done;

    if(!PyMapping_HasKey(pycx->global, pykey))
    {
        ret = JS_TRUE;
        goto done;
    }

    if(!JS_ValueToId(jscx, key, &pid))
    {
        JS_ReportError(jscx, "Failed to convert property id.");
        goto done;
    }

    if(!js_DefineProperty(jscx, pycx->root, pid, JSVAL_VOID, NULL, NULL,
                            JSPROP_SHARED, NULL))
    {
        JS_ReportError(jscx, "Failed to define property.");
        goto done;
    }

    ret = JS_TRUE;

done:
    Py_XDECREF(pykey);
    return ret;
}
开发者ID:yooyoo,项目名称:python-spidermonkey,代码行数:50,代码来源:context.c


示例16: AssertIsOnWorkletThread

/* static */ WorkletThread*
WorkletThread::Get()
{
  AssertIsOnWorkletThread();

  CycleCollectedJSContext* ccjscx = CycleCollectedJSContext::Get();
  MOZ_ASSERT(ccjscx);

  void* cxPrivate = JS_GetContextPrivate(ccjscx->Context());
  MOZ_ASSERT(cxPrivate);

  return
    static_cast<WorkletThreadContextPrivate*>(cxPrivate)->GetWorkletThread();
}
开发者ID:heiher,项目名称:gecko-dev,代码行数:14,代码来源:WorkletThread.cpp


示例17: js_mnemonics

static JSBool
js_mnemonics(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
	sbbs_t*		sbbs;
    JSString*	js_str;

	if((sbbs=(sbbs_t*)JS_GetContextPrivate(cx))==NULL)
		return(JS_FALSE);

	if((js_str=JS_ValueToString(cx, argv[0]))==NULL)
		return(JS_FALSE);
	
	sbbs->mnemonics(JS_GetStringBytes(js_str));
    return(JS_TRUE);
}
开发者ID:ftnapps,项目名称:pkg-sbbs,代码行数:15,代码来源:js_console.cpp


示例18: js_getnum

static JSBool
js_getnum(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
	ulong		maxnum=~0;
	sbbs_t*		sbbs;

	if((sbbs=(sbbs_t*)JS_GetContextPrivate(cx))==NULL)
		return(JS_FALSE);

	if(argc && JSVAL_IS_NUMBER(argv[0]))
		JS_ValueToInt32(cx,argv[0],(int32*)&maxnum);

	*rval = INT_TO_JSVAL(sbbs->getnum(maxnum));
    return(JS_TRUE);
}
开发者ID:ftnapps,项目名称:pkg-sbbs,代码行数:15,代码来源:js_console.cpp


示例19: xgg_domdocument_ctor

static JSBool xgg_domdocument_ctor(JSContext *pcxa, JSObject *pobja, uintN argc, jsval *pva1, jsval *rval)
{
	XJSE_XDOMPRIV	*p0;
	p0 = (XJSE_XDOMPRIV*)xjse_malloc(0, sizeof(XJSE_XDOMPRIV));
	xjse_memset(0, p0, 0, sizeof(XJSE_XDOMPRIV));
	p0->pjsectx = (XJSECTX*)JS_GetContextPrivate(pcxa);
	p0->pothis = pobja;
	JSBool	b0 = JS_SetPrivate(pcxa, pobja, p0);
	if(b0 != JS_TRUE) {
		XJSE_TRACE("JS_SetPrivate failed!");
		return	JS_FALSE;
	}

	return  JS_TRUE;
}
开发者ID:odistagon,项目名称:cyeonna,代码行数:15,代码来源:xgg_dom.c


示例20: js_editfile

static JSBool
js_editfile(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
    JSString*	str;
	sbbs_t*		sbbs;

	if((sbbs=(sbbs_t*)JS_GetContextPrivate(cx))==NULL)
		return(JS_FALSE);

	if((str=JS_ValueToString(cx, argv[0]))==NULL)
		return(JS_FALSE);

	sbbs->editfile(JS_GetStringBytes(str));
    return(JS_TRUE);
}
开发者ID:ftnapps,项目名称:pkg-sbbs,代码行数:15,代码来源:js_console.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ JS_GetGlobalObject函数代码示例发布时间:2022-05-30
下一篇:
C++ JS_GC函数代码示例发布时间: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