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

C++ JS_GetProperty函数代码示例

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

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



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

示例1: js_prop_set_from_jsval

void
js_prop_set_from_jsval(JSContext *cx, prop_t *p, jsval value)
{
  JSBool b;
  if(JSVAL_IS_INT(value)) {
    prop_set_int(p, JSVAL_TO_INT(value));
  } else if(JSVAL_IS_BOOLEAN(value)) {
    prop_set_int(p, JSVAL_TO_BOOLEAN(value));
  } else if(JSVAL_IS_NULL(value) || JSVAL_IS_VOID(value)) {
    prop_set_void(p);
  } else if(JSVAL_IS_DOUBLE(value)) {
    double d;
    if(JS_ValueToNumber(cx, value, &d))
      prop_set_float(p, d);
  } else if(JS_HasInstance(cx, RichText, value, &b) && b) {
    JSObject *o = JSVAL_TO_OBJECT(value);
    jsval v2;

    if(!JS_EnterLocalRootScope(cx))
      return;

    if(!JS_GetProperty(cx, o, "text", &v2)) {
      JS_LeaveLocalRootScope(cx);
      return;
    }

    prop_set_string_ex(p, NULL, JS_GetStringBytes(JS_ValueToString(cx, v2)),
		       PROP_STR_RICH);
    JS_LeaveLocalRootScope(cx);
  } else if(JSVAL_IS_STRING(value)) {
    js_prop_from_str(cx, p, value);
  } else if(JSVAL_IS_OBJECT(value)) {
    JSObject *obj = JSVAL_TO_OBJECT(value);
    JSClass *c = JS_GetClass(cx, obj);

    if(!strcmp(c->name, "XML"))   // Treat some classes special
      js_prop_from_str(cx, p, value);
    else
      js_prop_from_object(cx, obj, p);
  } else {
    prop_set_void(p);
  }
}
开发者ID:Hr-,项目名称:showtime,代码行数:43,代码来源:js.c


示例2: register_LoadUrlImage_js

void register_LoadUrlImage_js(JSContext* cx, JSObject* global)
{
    JS::RootedValue nsval(cx);
    JS::RootedValue tmpval(cx);
    JS::RootedObject pJsbObject(cx);

    JS_GetProperty(cx, global, "LoadUrlImage", &nsval);
    if (nsval == JSVAL_VOID) {
        pJsbObject = JS_NewObject(cx, NULL, NULL, NULL);
        nsval = OBJECT_TO_JSVAL(global);
        JS_SetProperty(cx, global, "LoadUrlImage", nsval);
    }
    else
    {
        JS_ValueToObject(cx, nsval, &pJsbObject);
    }

    JS_DefineFunction(cx, global, "loadUrlImage", JSB_LoadUrlImage_loadUrlImage, 2, JSPROP_READONLY | JSPROP_PERMANENT);
}
开发者ID:Ryeeeeee,项目名称:cocos2d-JS-3.0Alpha-FacebookDemo,代码行数:19,代码来源:js_bindings_loadUrlImage.cpp


示例3: getJSContext

void FFSessionHandler::disconnectDetectedImpl() {
  JSContext* ctx = getJSContext();
  if (!ctx) {
    return;
  }

  Debug::log(Debug::Debugging) << "Getting function \"__gwt_disconnected\""
        << Debug::flush;

  jsval funcVal;
  if (!JS_GetProperty(ctx, global, "__gwt_disconnected", &funcVal)
      || funcVal == JSVAL_VOID) {
    Debug::log(Debug::Error) << "Could not get function \"__gwt_disconnected\""
        << Debug::flush;
    return;
  }
  jsval rval;
  JS_CallFunctionValue(ctx, global, funcVal, 0, 0, &rval);
}
开发者ID:jnorthrup,项目名称:gwt-sandbox,代码行数:19,代码来源:FFSessionHandler.cpp


示例4: ScriptEvent_OnSwapBuffers

bool ScriptEvent_OnSwapBuffers(HDC hDC, BOOL & bSwapRes)
{
	JSAutoCompartment ac(g_JsCx, g_JsGlobal);

	jsval f;

	if(!JS_GetProperty(g_JsCx, g_JsGlobal, "onSwapBuffers", &f) || JSVAL_IS_PRIMITIVE(f))
		return false;

	jsval y;
	jsval x[1] = { JS_NumberValue((unsigned int)hDC) };

	if(!JS_CallFunctionValue(g_JsCx, g_JsGlobal, f, 1, x, &y))
		return false;

	bSwapRes = JS::ToBoolean(y);

	return true;
}
开发者ID:YaLTeR,项目名称:advancedfx,代码行数:19,代码来源:scripting.cpp


示例5: val

/**
 * Get a field of an object as an object.
 *
 * If the field does not exist, create it. If it exists but is not an
 * object, throw a JS error.
 */
JSObject *GetOrCreateObjectProperty(JSContext *cx, JS::Handle<JSObject*> aObject,
                                    const char *aProperty)
{
  JS::Rooted<JS::Value> val(cx);
  if (!JS_GetProperty(cx, aObject, aProperty, &val)) {
    return nullptr;
  }
  if (!val.isUndefined()) {
    if (val.isObject()) {
      return &val.toObject();
    }

    JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr,
      JSMSG_UNEXPECTED_TYPE, aProperty, "not an object");
    return nullptr;
  }
  return JS_DefineObject(cx, aObject, aProperty, nullptr, nullptr,
                         JSPROP_ENUMERATE);
}
开发者ID:cctuan,项目名称:mozilla-central,代码行数:25,代码来源:OSFileConstants.cpp


示例6: TaskEndWait

bool TaskEndWait( volatile ProcessEvent *pe, bool *hasEvent, JSContext *cx, JSObject * ) {

	TaskEvent *upe = (TaskEvent*)pe;

	*hasEvent = (upe->pv->pendingResponseCount > 0);

	if ( !*hasEvent )
		return true;

	jsval fct, argv[2];
	argv[1] = OBJECT_TO_JSVAL(upe->obj); // already rooted

	JL_CHK( JS_GetProperty(cx, upe->obj, "onResponse", &fct) );
	if ( JL_ValueIsCallable(cx, fct) )
		JL_CHK( JS_CallFunctionValue(cx, upe->obj, fct, COUNTOF(argv)-1, argv+1, argv) );

	return true;
	JL_BAD;
}
开发者ID:BenitoJedai,项目名称:jslibs,代码行数:19,代码来源:task.cpp


示例7: js_prop_from_object

int
js_prop_from_object(JSContext *cx, JSObject *obj, prop_t *p)
{
  JSIdArray *ida;
  int i, r = 0;
  const char *n;
  int array_zapped = 0;

  if((ida = JS_Enumerate(cx, obj)) == NULL)
    return -1;
  
  for(i = 0; i < ida->length; i++) {
    jsval name, value;

    if(!JS_IdToValue(cx, ida->vector[i], &name))
      continue;

    if(JSVAL_IS_STRING(name)) {
      n = JS_GetStringBytes(JSVAL_TO_STRING(name));
      if(!JS_GetProperty(cx, obj, n, &value))
	continue;
    } else if(JSVAL_IS_INT(name)) {
      if(!JS_GetElement(cx, obj, JSVAL_TO_INT(name), &value) ||
	 JSVAL_IS_VOID(value))
	continue;
      if(!array_zapped) {
	array_zapped = 1;
	prop_destroy_by_name(p, NULL);
      }
      n = NULL;
    } else {
      continue;
    }

    if(JSVAL_TO_OBJECT(value) == obj)
      continue;

    js_prop_set_from_jsval(cx, prop_create(p, n), value);
  }
  JS_DestroyIdArray(cx, ida);
  return r;
}
开发者ID:dev-life,项目名称:showtime,代码行数:42,代码来源:js.c


示例8: _scriptFileName

ComponentJS::ComponentJS(const std::string& scriptFileName)
: _scriptFileName(scriptFileName)
, _jsObj(nullptr)
{
    ScriptingCore* engine = ScriptingCore::getInstance();
    JSContext* cx = engine->getGlobalContext();
    // Require script
    JS::RootedValue classValue(cx);
    _succeedLoadingScript = engine->requireScript(_scriptFileName.c_str(), &classValue);

    if (_succeedLoadingScript)
    {
        JS::RootedObject classObj(cx, classValue.toObjectOrNull());
        const JSClass* theClass = JS_GetClass(classObj);
        JS::RootedValue protoValue(cx);
        JS_GetProperty(cx, classObj, "prototype", &protoValue);

        TypeTest<ComponentJS> 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;

        mozilla::Maybe<JS::PersistentRootedObject> *jsObj = new (std::nothrow) mozilla::Maybe<JS::PersistentRootedObject>();

        JS::RootedObject proto(cx, protoValue.toObjectOrNull());
        JS::RootedObject parent(cx, typeClass->proto.ref());
        jsObj->construct(cx);
        JS::RootedObject obj(cx, JS_NewObject(cx, theClass, proto, parent));
        jsObj->ref() = obj;

        // Unbind current proxy binding
        js_proxy_t* jsproxy = js_get_or_create_proxy<ComponentJS>(cx, this);
        JS::RemoveObjectRoot(cx, &jsproxy->obj);
        jsb_remove_proxy(jsproxy);
        // link the native object with the javascript object
        jsb_new_proxy(this, jsObj->ref());

        _jsObj = jsObj;
    }
}
开发者ID:253056965,项目名称:cocos2d-x-lite,代码行数:42,代码来源:CCComponentJS.cpp


示例9: onFailure

    void onFailure(const sdkbox::Product& info, const std::string& msg)
    {
        if (!s_cx)
        {
            return;
        }
        JSContext* cx = s_cx;
        const char* func_name = "onFailure";
        
        JS::RootedObject obj(cx, _JSDelegate);
        JSAutoCompartment ac(cx, obj);
        
#if MOZJS_MAJOR_VERSION >= 31
        bool hasAction;
        JS::RootedValue retval(cx);
        JS::RootedValue func_handle(cx);
#else
        JSBool hasAction;
        jsval retval;
        jsval func_handle;
#endif
        jsval dataVal[2];
        jsval value = OBJECT_TO_JSVAL(product_to_obj(s_cx, info));

        dataVal[0] = value;
        dataVal[1] = std_string_to_jsval(cx, msg);
        
        if (JS_HasProperty(cx, obj, func_name, &hasAction) && hasAction) {
            if(!JS_GetProperty(cx, obj, func_name, &func_handle)) {
                return;
            }
            if(func_handle == JSVAL_VOID) {
                return;
            }
            
#if MOZJS_MAJOR_VERSION >= 31
            JS_CallFunctionName(cx, obj, func_name, JS::HandleValueArray::fromMarkedLocation(sizeof(dataVal)/sizeof(*dataVal), dataVal), &retval);
#else
            JS_CallFunctionName(cx, obj, func_name, sizeof(dataVal)/sizeof(*dataVal), dataVal, &retval);
#endif
        }
    }
开发者ID:yinjimmy,项目名称:sdkbox-samples,代码行数:42,代码来源:PluginIAPJSHelper.cpp


示例10: register_CCBuilderReader

void register_CCBuilderReader(JSContext *cx, JSObject *obj) {
    jsval nsval;
	JSObject *ns;
	JS_GetProperty(cx, obj, "cc", &nsval);
	if (nsval == JSVAL_VOID) {
		ns = JS_NewObject(cx, NULL, NULL, NULL);
		nsval = OBJECT_TO_JSVAL(ns);
		JS_SetProperty(cx, obj, "cc", &nsval);
	} else {
		JS_ValueToObject(cx, nsval, &ns);
	}
	obj = ns;

    JSObject  *tmpObj = JSVAL_TO_OBJECT(anonEvaluate(cx, obj, "(function () { return cc._Reader; })()"));
    JS_DefineFunction(cx, tmpObj, "create", js_CocosBuilder_create, 2, JSPROP_READONLY | JSPROP_PERMANENT);
    JS_DefineFunction(cx, tmpObj, "loadScene", js_cocos2dx_CCBReader_createSceneWithNodeGraphFromFile, 2, JSPROP_READONLY | JSPROP_PERMANENT);
    
    JS_DefineFunction(cx, jsb_CCBReader_prototype, "load", js_cocos2dx_CCBReader_readNodeGraphFromFile, 2, JSPROP_READONLY | JSPROP_PERMANENT);
    JS_DefineFunction(cx, jsb_CCBAnimationManager_prototype, "setCompletedAnimationCallback", js_cocos2dx_CCBAnimationManager_animationCompleteCallback, 2, JSPROP_READONLY | JSPROP_PERMANENT);
}
开发者ID:CodeSnooker,项目名称:cocos2d-x,代码行数:20,代码来源:js_bindings_ccbreader.cpp


示例11: rq

bool ScriptInterface::ReplaceNondeterministicRNG(boost::rand48& rng)
{
	JSAutoRequest rq(m->m_cx);
	JS::RootedValue math(m->m_cx);
	JS::RootedObject global(m->m_cx, m->m_glob);
	if (JS_GetProperty(m->m_cx, global, "Math", &math) && math.isObject())
	{
		JS::RootedObject mathObj(m->m_cx, &math.toObject());
		JS::RootedFunction random(m->m_cx, JS_DefineFunction(m->m_cx, mathObj, "random", Math_random, 0,
			JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_PERMANENT));
		if (random)
		{
			m->m_rng = &rng;
			return true;
		}
	}

	LOGERROR("ReplaceNondeterministicRNG: failed to replace Math.random");
	return false;
}
开发者ID:Rektosauros,项目名称:0ad,代码行数:20,代码来源:ScriptInterface.cpp


示例12: convert_symbol_to_js

static JSBool convert_symbol_to_js(JohnsonRuntime* runtime, VALUE symbol, jsval* retval)
{
  JSContext * context = johnson_get_current_context(runtime);
  PREPARE_JROOTS(context, 2);

  VALUE to_s = CALL_RUBY_WRAPPER(rb_funcall_0, symbol, rb_intern("to_s"), 0);
  jsval name = STRING_TO_JSVAL(JS_NewStringCopyN(context, StringValuePtr(to_s), (size_t) StringValueLen(to_s)));

  JROOT(name);

  // calls Johnson.symbolize(name) in JS-land. See lib/prelude.js

  jsval nsJohnson;    
  JCHECK(JS_GetProperty(context, runtime->global, "Johnson", &nsJohnson));
  JROOT(nsJohnson);

  JCHECK(JS_CallFunctionName(context, JSVAL_TO_OBJECT(nsJohnson), "symbolize", 1, &name, retval));

  JRETURN;
}
开发者ID:JackDanger,项目名称:johnson,代码行数:20,代码来源:conversions.c


示例13: JS_GetProperty

LogicEntityPtr TraceMonkeyEngine::getCLogicEntity(JSObject* scriptingEntity)
{
    // We do this in a slow but sure manner: read the uniqueId from JS,
    // and look up the entity using that. In the future, speed this up
    // using private data or some other method

    jsval temp;
    bool success = JS_GetProperty(context, scriptingEntity, "uniqueId", &temp);
    assert(success);
    assert(JSVAL_IS_INT(temp));

    int uniqueId = JSVAL_TO_INT(temp);
    LogicEntityPtr ret = LogicSystem::getLogicEntity(uniqueId);

    Logging::log(Logging::DEBUG, "TraceMonkey getting the CLE for UID %d\r\n", uniqueId);

    assert(ret.get());

    return ret;
}
开发者ID:Amplifying,项目名称:intensityengine,代码行数:20,代码来源:script_engine_tracemonkey.cpp


示例14: _scriptFileName

ComponentJS::ComponentJS(const std::string& scriptFileName)
: _scriptFileName(scriptFileName)
, _jsObj(nullptr)
{
    ScriptingCore* engine = ScriptingCore::getInstance();
    JSContext* cx = engine->getGlobalContext();
    // Require script
    JS::RootedValue classValue(cx);
    _succeedLoadingScript = engine->requireScript(_scriptFileName.c_str(), &classValue);
    
    if (_succeedLoadingScript)
    {
        JS::RootedObject classObj(cx, classValue.toObjectOrNull());
        const JSClass* theClass = JS_GetClass(classObj);
        JS::RootedValue protoValue(cx);
        JS_GetProperty(cx, classObj, "prototype", &protoValue);
        
        mozilla::Maybe<JS::PersistentRootedObject> *jsObj = new (std::nothrow) mozilla::Maybe<JS::PersistentRootedObject>();
        
        js_type_class_t *typeClass = js_get_type_from_native<cocos2d::ComponentJS>(this);
        JS::RootedObject proto(cx, protoValue.toObjectOrNull());
        JS::RootedObject parent(cx, typeClass->proto.ref());
        jsObj->construct(cx);
        JS::RootedObject obj(cx, JS_NewObject(cx, theClass, proto, parent));
        jsObj->ref() = obj;
        
        // Unbind current proxy binding
        js_proxy_t* nproxy = jsb_get_native_proxy(this);
        if (nproxy)
        {
#if CC_ENABLE_GC_FOR_NATIVE_OBJECTS
            JS::RemoveObjectRoot(cx, &nproxy->obj);
#endif // CC_ENABLE_GC_FOR_NATIVE_OBJECTS
            jsb_remove_proxy(nproxy, jsb_get_js_proxy(nproxy->obj));
        }
        // link the native object with the javascript object
        jsb_new_proxy(this, jsObj->ref());
        
        _jsObj = jsObj;
    }
}
开发者ID:DmitryDronov,项目名称:Test1,代码行数:41,代码来源:CCComponentJS.cpp


示例15: _egueb_script_js_sm_scripter_load

static Eina_Bool _egueb_script_js_sm_scripter_load(void *prv, Egueb_Dom_String *s, void **obj)
{
	Egueb_Script_Js_Sm_Scripter *thiz = prv;
	Egueb_Dom_String *uri = NULL;
	jsval val;
	JSObject *so;
	Eina_Bool ret = EINA_FALSE;
	const char *data;

	*obj = NULL;
	data = egueb_dom_string_chars_get(s);
	/* get the document, get the uri of the document, pass it as the filename */
	if (JS_GetProperty(thiz->cx, thiz->global, "document", &val))
	{
		JSObject *doc;

		doc = JSVAL_TO_OBJECT(val);
		if (ender_js_sm_is_instance(thiz->cx, doc))
		{
			Egueb_Dom_Node *n;
			n = ender_js_sm_instance_ptr_get(thiz->cx, doc);
			uri = egueb_dom_document_uri_get(n);
		}
	}
	so = JS_CompileScript(thiz->cx, NULL, data, strlen(data),
			uri ? egueb_dom_string_chars_get(uri) : NULL, 1);
	if (so)
	{
		Egueb_Script_Js_Sm_Scripter_Script *script;
		script = calloc(1, sizeof(Egueb_Script_Js_Sm_Scripter_Script));
		script->obj = so;
		*obj = script;
		ret = EINA_TRUE;
	}
	if (uri)
	{
		egueb_dom_string_unref(uri);
	}

	return ret;
}
开发者ID:turran,项目名称:egueb-script,代码行数:41,代码来源:egueb_script_js_sm.c


示例16: onProductRequestSuccess

    void onProductRequestSuccess(const std::vector<sdkbox::Product>& products)
    {
        if (!s_cx)
        {
            return;
        }
        JSContext* cx = s_cx;
        const char* func_name = "onProductRequestSuccess";
        
        JS::RootedObject obj(cx, _JSDelegate);
        JSAutoCompartment ac(cx, obj);
        
#if MOZJS_MAJOR_VERSION >= 31
        bool hasAction;
        JS::RootedValue retval(cx);
        JS::RootedValue func_handle(cx);
#else
        JSBool hasAction;
        jsval retval;
        jsval func_handle;
#endif
        jsval dataVal[1];
        jsval value = std_vector_product_to_jsval(s_cx, products);

        dataVal[0] = value;
        
        if (JS_HasProperty(cx, obj, func_name, &hasAction) && hasAction) {
            if(!JS_GetProperty(cx, obj, func_name, &func_handle)) {
                return;
            }
            if(func_handle == JSVAL_VOID) {
                return;
            }
            
#if MOZJS_MAJOR_VERSION >= 31
            JS_CallFunctionName(cx, obj, func_name, JS::HandleValueArray::fromMarkedLocation(sizeof(dataVal)/sizeof(*dataVal), dataVal), &retval);
#else
            JS_CallFunctionName(cx, obj, func_name, sizeof(dataVal)/sizeof(*dataVal), dataVal, &retval);
#endif
        }
    }
开发者ID:yinjimmy,项目名称:sdkbox-samples,代码行数:41,代码来源:PluginIAPJSHelper.cpp


示例17: assert

ScriptValuePtr TraceMonkeyValue::getProperty(std::string propertyName)
{
    assert(isValid());

    Logging::log(Logging::DEBUG, "TraceMonkeyValue::getProperty(%s): \r\n", propertyName.c_str()); printJSVAL(value);

    assert(JSVAL_IS_OBJECT(value));
    jsval ret;
    assert(JS_GetProperty(TraceMonkeyEngine::context, JSVAL_TO_OBJECT(value), propertyName.c_str(), &ret));
    bool success = JS_AddNamedRoot(TraceMonkeyEngine::context, &ret, "TraceMonkeyValue::getProperty temp val"); // Ensure our value won't be GCed
    assert(success);

    Logging::log(Logging::DEBUG, "returning: \r\n"); printJSVAL(ret);

    ScriptValuePtr retValue(new TraceMonkeyValue(engine, true, ret));

    success = JS_RemoveRoot(TraceMonkeyEngine::context, &ret); // Allow GCing, it is already marked in the retValue
    assert(success);

    return retValue;
}
开发者ID:Amplifying,项目名称:intensityengine,代码行数:21,代码来源:script_engine_tracemonkey.cpp


示例18: func

/* JSCall function by name, cvalues will be converted
 *
 * deactivates controller if any script errors!
 *
 * format values:
 * case 'b': BOOLEAN_TO_JSVAL((JSBool) va_arg(ap, int));
 * case 'c': INT_TO_JSVAL((uint16) va_arg(ap, unsigned int));
 * case 'i':
 * case 'j': js_NewNumberValue(cx, (jsdouble) va_arg(ap, int32), sp)
 * case 'u': js_NewNumberValue(cx, (jsdouble) va_arg(ap, uint32), sp)
 * case 'd':
 * case 'I': js_NewDoubleValue(cx, va_arg(ap, jsdouble), sp)
 * case 's': JS_NewStringCopyZ(cx, va_arg(ap, char *))
 * case 'W': JS_NewUCStringCopyZ(cx, va_arg(ap, jschar *))
 * case 'S': va_arg(ap, JSString *)
 * case 'o': OBJECT_TO_JSVAL(va_arg(ap, JSObject *)
 * case 'f':
 * fun = va_arg(ap, JSFunction *);
 *       fun ? OBJECT_TO_JSVAL(fun->object) : JSVAL_NULL;
 * case 'v': va_arg(ap, jsval);
 */
bool ControllerListener::call(const char *funcname, int argc, const char *format, ...) {
    va_list ap;
    jsval fval = JSVAL_VOID;
    jsval ret = JSVAL_VOID;
    
    func("%s try calling method %s.%s(argc:%i)", __func__, name, funcname, argc);
    JS_SetContextThread(jsContext);
    JS_BeginRequest(jsContext);
    int res = JS_GetProperty(jsContext, jsObject, funcname, &fval);
    
    if(JSVAL_IS_VOID(fval)) {
        warning("method unresolved by JS_GetProperty");
    } else {
        jsval *argv;
        void *markp;
        
        va_start(ap, format);
        argv = JS_PushArgumentsVA(jsContext, &markp, format, ap);
        va_end(ap);
        
        res = JS_CallFunctionValue(jsContext, jsObject, fval, argc, argv, &ret);
        JS_PopArguments(jsContext, &markp);
        
        if (res) {
            if(!JSVAL_IS_VOID(ret)) {
                JSBool ok;
                JS_ValueToBoolean(jsContext, ret, &ok);
                if (ok) // JSfunc returned 'true', so event is done
                {
                    JS_EndRequest(jsContext);
                    JS_ClearContextThread(jsContext);
                    return true;
                }
            }
        }
    }
    JS_EndRequest(jsContext);
    JS_ClearContextThread(jsContext);
    return false; // no callback, redo on next controller
}
开发者ID:dewn49,项目名称:FreeJ,代码行数:61,代码来源:controller.cpp


示例19: JS_HasProperty

void GLNode::draw() {
    js_proxy_t* proxy = NULL;
    JSContext *cx = ScriptingCore::getInstance()->getGlobalContext();
    proxy = js_get_or_create_proxy<cocos2d::Node>(cx, this);

    if( proxy ) {
        JSObject *jsObj = proxy->obj;
        if (jsObj) {
            bool found;
            JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET
                    JS_HasProperty(cx, jsObj, "draw", &found);
            if (found == true) {
                JS::RootedValue rval(cx);
                JS::RootedValue fval(cx);
                jsval *argv = NULL; unsigned argc=0;

                JS_GetProperty(cx, jsObj, "draw", &fval);
                JS_CallFunctionValue(cx, jsObj, fval, argc, argv, rval.address());
            }
        }
    }
}
开发者ID:12white,项目名称:CocoStudioSamples,代码行数:22,代码来源:js_bindings_opengl.cpp


示例20: CreateAlias

bool
CreateAlias(JSContext* cx, const char* dstName, JS::HandleObject namespaceObj, const char* srcName)
{
    RootedObject global(cx, JS_GetGlobalForObject(cx, namespaceObj));
    if (!global)
        return false;

    RootedValue val(cx);
    if (!JS_GetProperty(cx, namespaceObj, srcName, &val))
        return false;

    if (!val.isObject()) {
        JS_ReportErrorASCII(cx, "attempted to alias nonexistent function");
        return false;
    }
    
    RootedObject function(cx, &val.toObject());
    if (!JS_DefineProperty(cx, global, dstName, function, 0))
        return false;

    return true;
}
开发者ID:luke-chang,项目名称:gecko-1,代码行数:22,代码来源:jsshell.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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