当前位置: 首页>>代码示例>>C++>>正文


C++ JS_SET_RVAL函数代码示例

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


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

示例1: executeFile

static JSBool executeFile(JSContext *cx, unsigned argc, jsval *vp) {

  JSString* str;
  JSObject* obj;
  if (!JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "So", &str, &obj)) {
    return JS_FALSE;
  }
  char *filename = JS_EncodeString(cx, str);

  JSScript* script = JS_CompileUTF8File(cx, JS_THIS_OBJECT(cx, vp), filename);
  JS_free(cx, filename);
  if (!script) {
    return JS_FALSE;
  }

  jsval result;
  if (!JS_ExecuteScript(cx, obj, script, &result)) {
    return JS_FALSE;
  }

  JS_SET_RVAL(cx, vp, result);
  return JS_TRUE;
}
开发者ID:bnoordhuis,项目名称:luvmonkey,代码行数:23,代码来源:main.c

示例2: body_applyDirectionalImpulse

static JSBool
body_applyDirectionalImpulse(JSContext* cx, uintN argc, jsval* vp)
{
  jsdouble amt;
  if (!JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "d", &amt)) {
      /* Throw a JavaScript exception. */
      JS_ReportError(cx, "body_applyDirectionalImpulse: couldn't parse out amt");
      return JS_FALSE;
  }

  JSObject* bodyObj = JS_THIS_OBJECT(cx, vp);

  cpBody* body = (cpBody*)JS_GetPrivate(cx, bodyObj);
  cpFloat angle = cpBodyGetAngle(body);
  double xAmt = -sin(angle) * amt;
  double yAmt = cos(angle) * amt;
  cpVect j = {xAmt, yAmt};
  cpBodyApplyImpulse(body, j, cpvzero);

  jsval rVal = JSVAL_VOID;
  JS_SET_RVAL(cx, vp, rVal);
  return JS_TRUE;
}
开发者ID:dumganhar,项目名称:sugs_spiderMonkey,代码行数:23,代码来源:body.cpp

示例3: JS_THIS_OBJECT

JSBool
Library::Close(JSContext* cx, unsigned argc, jsval* vp)
{
  JSObject* obj = JS_THIS_OBJECT(cx, vp);
  if (!obj)
    return JS_FALSE;
  if (!IsLibrary(obj)) {
    JS_ReportError(cx, "not a library");
    return JS_FALSE;
  }

  if (argc != 0) {
    JS_ReportError(cx, "close doesn't take any arguments");
    return JS_FALSE;
  }

  // delete our internal objects
  UnloadLibrary(obj);
  JS_SetReservedSlot(obj, SLOT_LIBRARY, PRIVATE_TO_JSVAL(NULL));

  JS_SET_RVAL(cx, vp, JSVAL_VOID);
  return JS_TRUE;
}
开发者ID:BrunoReX,项目名称:palemoon,代码行数:23,代码来源:Library.cpp

示例4: JS_ReportError

JSBool
JetpackChild::CreateSandbox(JSContext* cx, uintN argc, jsval* vp)
{
  if (argc > 0) {
    JS_ReportError(cx, "createSandbox takes zero arguments");
    return JS_FALSE;
  }

  JSObject* obj = JS_NewCompartmentAndGlobalObject(cx, const_cast<JSClass*>(&sGlobalClass), NULL);
  if (!obj)
    return JS_FALSE;

  jsval rval = OBJECT_TO_JSVAL(obj);
  if (!JS_WrapValue(cx, &rval))
    return JS_FALSE;

  JSAutoEnterCompartment ac;
  if (!ac.enter(cx, obj))
    return JS_FALSE;

  JS_SET_RVAL(cx, vp, rval);
  return JS_InitStandardClasses(cx, obj);
}
开发者ID:krad-radio,项目名称:mozilla-krad,代码行数:23,代码来源:JetpackChild.cpp

示例5: dummy_constructor

static bool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) {
    JS::RootedValue initializing(cx);
    bool isNewValid = true;
    JSObject* global = ScriptingCore::getInstance()->getGlobalObject();
	isNewValid = JS_GetProperty(cx, global, "initializing", &initializing) && JSVAL_TO_BOOLEAN(initializing);
	if (isNewValid)
	{
		TypeTest<T> t;
		js_type_class_t *typeClass = nullptr;
		std::string typeName = t.s_name();
		auto typeMapIter = _js_global_type_map.find(typeName);
		CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!");
		typeClass = typeMapIter->second;
		CCASSERT(typeClass, "The value is null.");

		JSObject *_tmp = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto);
		JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(_tmp));
		return true;
	}

    JS_ReportError(cx, "Don't use `new cc.XXX`, please use `cc.XXX.create` instead! ");
    return false;
}
开发者ID:redmobile,项目名称:auto-generated,代码行数:23,代码来源:jsb_soomla_auto.cpp

示例6: getType_func

static JSBool
getType_func(JSContext *context,
             uintN      argc,
             jsval     *vp)
{
    JSObject *obj = JS_THIS_OBJECT(context, vp);
    cairo_surface_t *surface;
    cairo_surface_type_t type;

    if (argc > 1) {
        gjs_throw(context, "Surface.getType() takes no arguments");
        return JS_FALSE;
    }

    surface = gjs_cairo_surface_get_surface(context, obj);
    type = cairo_surface_get_type(surface);
    if (!gjs_cairo_check_status(context, cairo_surface_status(surface),
                                "surface"))
        return JS_FALSE;

    JS_SET_RVAL(context, vp, INT_TO_JSVAL(type));
    return JS_TRUE;
}
开发者ID:BabeNovelty,项目名称:glib-win32,代码行数:23,代码来源:cairo-surface-vs10.c

示例7: rpmhdr_fi

static JSBool
rpmhdr_fi(JSContext *cx, uintN argc, jsval *vp)
{
    jsval *argv = JS_ARGV(cx , vp);
    JSObject *obj = JS_NewObjectForConstructor(cx , vp);
    if(!obj) {
	JS_ReportError(cx , "Failed to create 'this' object");
	return JS_FALSE;
    }
    void * ptr = JS_GetInstancePrivate(cx, obj, &rpmhdrClass, NULL);
    Header h = ptr;
    rpmTag tagN = RPMTAG_BASENAMES;
    JSBool ok = JS_FALSE;

_METHOD_DEBUG_ENTRY(_debug);

    if (!(ok = JS_ConvertArguments(cx, argc, argv, "/u", &tagN)))
        goto exit;
    JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(rpmjs_NewFiObject(cx, h, tagN)));
    ok = JS_TRUE;
exit:
    return ok;
}
开发者ID:avokhmin,项目名称:RPM5,代码行数:23,代码来源:rpmhdr-js.c

示例8: js_conio_getpass

static JSBool
js_conio_getpass(JSContext *cx, uintN argc, jsval *arglist)
{
	jsval *argv=JS_ARGV(cx, arglist);
	char *	str;
	char *	pwd;
	jsrefcount	rc;

	if(argc==1) {
		JSVALUE_TO_MSTRING(cx, argv[0], str, NULL);
		HANDLE_PENDING(cx);
		if(str != NULL) {
			rc=JS_SUSPENDREQUEST(cx);
			pwd=getpass(str);
			free(str);
			JS_RESUMEREQUEST(cx, rc);
			JS_SET_RVAL(cx, arglist,STRING_TO_JSVAL(JS_NewStringCopyZ(cx,pwd)));
			return(JS_TRUE);
		}
	}

	return(JS_FALSE);
}
开发者ID:kindy,项目名称:synchronet-bbs-1,代码行数:23,代码来源:js_conio.c

示例9: gjs_format_int_alternative_output

static JSBool
gjs_format_int_alternative_output(JSContext *context,
                                  uintN      argc,
                                  jsval     *vp)
{
    jsval *argv = JS_ARGV(cx, vp);
    char *str;
    jsval rval;
    int intval;
    JSBool ret;

    if (!gjs_parse_args(context, "format_int_alternative_output", "i", argc, argv,
                        "intval", &intval))
        return JS_FALSE;

    str = g_strdup_printf("%Id", intval);
    ret = gjs_string_from_utf8(context, str, -1, &rval);
    if (ret)
        JS_SET_RVAL(context, vp, rval);
    g_free (str);

    return ret;
}
开发者ID:goizueta,项目名称:gjs,代码行数:23,代码来源:format.c

示例10: Construct

	JSBool Construct(JSContext* cx, uintN argc, jsval* vp)
	{
		UNUSED2(argc);

		JSObject *newObj = JS_NewObject(cx, &Class, NULL, NULL);
		JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(newObj));

		int flags=JSPROP_ENUMERATE|JSPROP_READONLY|JSPROP_PERMANENT;
#define cfg_ns(_propname, _enum) STMT (\
	JSObject *nsobj=g_ScriptingHost.CreateCustomObject("ConfigNamespace"); \
	ENSURE(nsobj); \
	ConfigNamespace_JS::SetNamespace(cx, nsobj, _enum); \
	ENSURE(JS_DefineProperty(cx, newObj, _propname, OBJECT_TO_JSVAL(nsobj), NULL, NULL, flags)); )

		cfg_ns("default", CFG_DEFAULT);
		cfg_ns("system", CFG_SYSTEM);
		cfg_ns("user", CFG_USER);
		cfg_ns("mod", CFG_MOD);

#undef cfg_ns

		return JS_TRUE;
	}
开发者ID:Gallaecio,项目名称:0ad,代码行数:23,代码来源:ConfigDB.cpp

示例11: dummy_constructor

static JSBool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) {
	TypeTest<T> t;
	T* cobj = new T();
#if not $script_control_cpp
	cocos2d::CCObject *_ccobj = dynamic_cast<cocos2d::CCObject *>(cobj);
	if (_ccobj) {
		_ccobj->autorelease();
	}
#end if
	js_type_class_t *p;
	uint32_t typeId = t.s_id();
	HASH_FIND_INT(_js_global_type_ht, &typeId, p);
	assert(p);
	JSObject *_tmp = JS_NewObject(cx, p->jsclass, p->proto, p->parentProto);
	js_proxy_t *pp;
	JS_NEW_PROXY(pp, cobj, _tmp);
#if not $script_control_cpp
	JS_AddObjectRoot(cx, &pp->obj);
#end if
	JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(_tmp));

	return JS_TRUE;
}
开发者ID:AlexYanJianhua,项目名称:bindings-generator,代码行数:23,代码来源:layout_head.c

示例12: dummy_constructor

static bool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) {
    JS::RootedValue initializing(cx);
    bool isNewValid = true;
    if (isNewValid)
    {
        TypeTest<T> t;
        js_type_class_t *typeClass = nullptr;
        std::string typeName = t.s_name();
        auto typeMapIter = _js_global_type_map.find(typeName);
        CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!");
        typeClass = typeMapIter->second;
        CCASSERT(typeClass, "The value is null.");

        JSObject *_tmp = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto);
        T* cobj = new T();
        js_proxy_t *pp = jsb_new_proxy(cobj, _tmp);
        JS_AddObjectRoot(cx, &pp->obj);
        JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(_tmp));
        return true;
    }

    return false;
}
开发者ID:jianqiang-411,项目名称:sdkbox-facebook-sample,代码行数:23,代码来源:PluginFacebookJS.cpp

示例13: js_PluginAdColonyJS_PluginAdColony_notifyIAPComplete

JSBool js_PluginAdColonyJS_PluginAdColony_notifyIAPComplete(JSContext *cx, uint32_t argc, jsval *vp)
{
    jsval *argv = JS_ARGV(cx, vp);
    JSBool ok = JS_TRUE;
    if (argc == 5) {
        std::string arg0;
        std::string arg1;
        int arg2;
        double arg3;
        std::string arg4;
        ok &= jsval_to_std_string(cx, argv[0], &arg0);
        ok &= jsval_to_std_string(cx, argv[1], &arg1);
        ok &= jsval_to_int32(cx, argv[2], (int32_t *)&arg2);
        ok &= sdkbox::js_to_number(cx, argv[3], &arg3);
        ok &= jsval_to_std_string(cx, argv[4], &arg4);
        JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments");
        sdkbox::PluginAdColony::notifyIAPComplete(arg0, arg1, arg2, arg3, arg4);
        JS_SET_RVAL(cx, vp, JSVAL_VOID);
        return JS_TRUE;
    }
    JS_ReportError(cx, "wrong number of arguments");
    return JS_FALSE;
}
开发者ID:yinjimmy,项目名称:sdkbox-samples,代码行数:23,代码来源:PluginAdColonyJS.cpp

示例14: setExtend_func

static JSBool
setExtend_func(JSContext *context,
               unsigned   argc,
               jsval     *vp)
{
    jsval *argv = JS_ARGV(context, vp);
    JSObject *obj = JS_THIS_OBJECT(context, vp);
    cairo_extend_t extend;
    cairo_pattern_t *pattern;

    if (!gjs_parse_args(context, "setExtend", "i", argc, argv,
                        "extend", &extend))
        return JS_FALSE;

    pattern = gjs_cairo_pattern_get_pattern(context, obj);
    cairo_pattern_set_extend(pattern, extend);

    if (!gjs_cairo_check_status(context, cairo_pattern_status(pattern), "pattern"))
        return JS_FALSE;

    JS_SET_RVAL(context, vp, JSVAL_VOID);
    return JS_TRUE;
}
开发者ID:3dfxmadscientist,项目名称:cjs,代码行数:23,代码来源:cairo-surface-pattern.cpp

示例15: js_EventListenerTouchOneByOne_create

bool js_EventListenerTouchOneByOne_create(JSContext *cx, uint32_t argc, jsval *vp)
{
    if (argc == 0) {
        auto ret = EventListenerTouchOneByOne::create();
        
        ret->onTouchBegan = [ret](Touch* touch, Event* event) -> bool {
            jsval jsret = JSVAL_NULL;
            bool ok = ScriptingCore::getInstance()->handleTouchEvent(ret, EventTouch::EventCode::BEGAN, touch, event, &jsret);
            
            // Not found the method, just return false.
            if (!ok)
                return false;

            CCASSERT(JSVAL_IS_BOOLEAN(jsret), "the return value of onTouchBegan isn't boolean");
            return JSVAL_TO_BOOLEAN(jsret);
        };
        
        ret->onTouchMoved = [ret](Touch* touch, Event* event) {
            ScriptingCore::getInstance()->handleTouchEvent(ret, EventTouch::EventCode::MOVED, touch, event);
        };
        
        ret->onTouchEnded = [ret](Touch* touch, Event* event) {
            ScriptingCore::getInstance()->handleTouchEvent(ret, EventTouch::EventCode::ENDED, touch, event);
        };
        
        ret->onTouchCancelled = [ret](Touch* touch, Event* event) {
            ScriptingCore::getInstance()->handleTouchEvent(ret, EventTouch::EventCode::CANCELLED, touch, event);
        };
        
		jsval jsret = getJSObject(cx, ret);
		JS_SET_RVAL(cx, vp, jsret);
		return true;
	}
    
	JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0);
	return false;
}
开发者ID:071300726,项目名称:cocos2d-js,代码行数:37,代码来源:jsb_event_dispatcher_manual.cpp


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