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

C++ JSVAL_IS_OBJECT函数代码示例

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

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



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

示例1: NS_ENSURE_TRUE

NS_IMETHODIMP
nsDOMWorkerMessageEvent::GetData(nsAString& aData)
{
  nsIXPConnect* xpc = nsContentUtils::XPConnect();
  NS_ENSURE_TRUE(xpc, NS_ERROR_UNEXPECTED);

  nsAXPCNativeCallContext* cc;
  nsresult rv = xpc->GetCurrentNativeCallContext(&cc);
  NS_ENSURE_SUCCESS(rv, rv);
  NS_ENSURE_TRUE(cc, NS_ERROR_UNEXPECTED);

  if (!mDataValWasReparented) {
    if (JSVAL_IS_OBJECT(mDataVal) && !JSVAL_IS_NULL(mDataVal)) {
      JSContext* cx;
      rv = cc->GetJSContext(&cx);
      NS_ENSURE_SUCCESS(rv, rv);

      rv =
        nsContentUtils::ReparentClonedObjectToScope(cx,
                                                    JSVAL_TO_OBJECT(mDataVal),
                                                    JS_GetGlobalObject(cx));
      NS_ENSURE_SUCCESS(rv, rv);
    }
    mDataValWasReparented = PR_TRUE;
  }

  jsval* retval;
  rv = cc->GetRetValPtr(&retval);
  NS_ENSURE_SUCCESS(rv, rv);

  cc->SetReturnValueWasSet(PR_TRUE);
  *retval = mDataVal;
  return NS_OK;
}
开发者ID:lofter2011,项目名称:Icefox,代码行数:34,代码来源:nsDOMWorkerEvents.cpp


示例2: GetScopeFunction

static JSObject *
GetScopeFunction(JSContext *cx, JSObject *outerObj)
{
  jsval v;
  if (!JS_GetReservedSlot(cx, outerObj, sScopeFunSlot, &v)) {
    return nsnull;
  }

  JSObject *unsafeObj = GetUnsafeObject(outerObj);
  JSObject *scopeobj = JS_GetGlobalForObject(cx, unsafeObj);
  OBJ_TO_INNER_OBJECT(cx, scopeobj);
  if (!scopeobj) {
    return nsnull;
  }

  if (JSVAL_IS_OBJECT(v)) {
    JSObject *funobj = JSVAL_TO_OBJECT(v);
    if (JS_GetGlobalForObject(cx, funobj) == scopeobj) {
      return funobj;
    }
  }

  JSFunction *fun = JS_NewFunction(cx, DummyNative, 0, 0, scopeobj,
                                   "SJOWContentBoundary");
  if (!fun) {
    return nsnull;
  }

  JSObject *funobj = JS_GetFunctionObject(fun);
  if (!JS_SetReservedSlot(cx, outerObj, sScopeFunSlot, OBJECT_TO_JSVAL(funobj))) {
    return nsnull;
  }

  return funobj;
}
开发者ID:amyvmiwei,项目名称:firefox,代码行数:35,代码来源:XPCSafeJSObjectWrapper.cpp


示例3: ejs_execv

  static JSBool
  ejs_execv(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
  {
    EJS_CHECK_TRUSTED(cx,obj);
    EJS_CHECK_NUM_ARGS(cx,obj,2,argc);

    JSString *strtype=JS_ValueToString(cx, argv[0]);
    // todo: we loose unicode information here
    const char* filename=JS_GetStringBytes(strtype);
    if (!filename) return JS_FALSE;

    if (!JSVAL_IS_OBJECT(argv[1])) EJS_THROW_ERROR(cx,obj,"array object required");
    JSObject *aobj=JSVAL_TO_OBJECT(argv[1]);
    jsuint l;
    if (!JS_GetArrayLength(cx, aobj, &l)) return JS_FALSE;
    char* eargv[l+1];
    for (jsuint i=0;i<l;++i) {
      jsval elem;
      if (!JS_GetElement(cx, aobj, i ,&elem)) return JS_FALSE;
      strtype=JS_ValueToString(cx, elem);
      // todo: we loose unicode information here
      eargv[i]=JS_GetStringBytes(strtype);
      if (!eargv[i]) return JS_FALSE;
    }
    eargv[l]=NULL;

    execv(filename, eargv);

    // some error occured
    EJS_THROW_ERROR(cx,obj,"execv failed");
  }
开发者ID:BackupTheBerlios,项目名称:egachine,代码行数:31,代码来源:ejsposix.cpp


示例4: jsd_GetValueClassName

const char*
jsd_GetValueClassName(JSDContext* jsdc, JSDValue* jsdval)
{
    jsval val = jsdval->val;
    JSCrossCompartmentCall *call = NULL;

    if(!jsdval->className && JSVAL_IS_OBJECT(val))
    {
        JSObject* obj;
        if(!(obj = JSVAL_TO_OBJECT(val)))
            return NULL;
        JS_BeginRequest(jsdc->dumbContext);
        call = JS_EnterCrossCompartmentCall(jsdc->dumbContext, obj);
        if(!call) {
            JS_EndRequest(jsdc->dumbContext);

            return NULL;
        }
        if(JS_GET_CLASS(jsdc->dumbContext, obj))
            jsdval->className = JS_GET_CLASS(jsdc->dumbContext, obj)->name;
        JS_LeaveCrossCompartmentCall(call);
        JS_EndRequest(jsdc->dumbContext);
    }
    return jsdval->className;
}
开发者ID:ThinkerYzu,项目名称:mozilla-central,代码行数:25,代码来源:jsd_val.c


示例5: call_js_function_value

static VALUE call_js_function_value(JohnsonRuntime* runtime, jsval target, jsval function, int argc, VALUE* argv)
{
  JSContext * context = johnson_get_current_context(runtime);
  PREPARE_RUBY_JROOTS(context, argc + 2);

  JROOT(target);
  JROOT(function);

  assert(JSVAL_IS_OBJECT(target));

  jsval args[argc];
  jsval result;

  int i;
  for(i = 0; i < argc; ++i)
  {
    JCHECK(convert_to_js(runtime, argv[i], &(args[i])));
    JROOT(args[i]);
  }

  JCHECK(JS_CallFunctionValue(context,
    JSVAL_TO_OBJECT(target), function, (unsigned) argc, args, &result));

  JRETURN_RUBY(CONVERT_TO_RUBY(runtime, result));
}
开发者ID:aasmith,项目名称:johnson,代码行数:25,代码来源:ruby_land_proxy.c


示例6: js_item_moveBefore

static JSBool 
js_item_moveBefore(JSContext *cx, JSObject *obj,
		   uintN argc, jsval *argv, jsval *rval)
{
  js_item_t *ji = JS_GetPrivate(cx, obj);
  js_item_t *before;

  if(argc >= 1 && JSVAL_IS_OBJECT(argv[0]) &&
     !JSVAL_IS_NULL(argv[0]) && 
     JS_GetClass(cx, JSVAL_TO_OBJECT(argv[0])) == &item_class) {
    before = JS_GetPrivate(cx, JSVAL_TO_OBJECT(argv[0]));
  } else {
    before = NULL;
  }

  TAILQ_REMOVE(&ji->ji_model->jm_items, ji, ji_link);
  if(before)
    TAILQ_INSERT_BEFORE(before, ji, ji_link);
  else
    TAILQ_INSERT_TAIL(&ji->ji_model->jm_items, ji, ji_link);

  prop_move(ji->ji_root, before ? before->ji_root : NULL);
  *rval = JSVAL_VOID;
  return JS_TRUE;
}
开发者ID:KptKloppsKopp,项目名称:showtime,代码行数:25,代码来源:js_page.c


示例7: get_version_for_ns

static JSBool
get_version_for_ns (JSContext *context,
                    JSObject  *repo_obj,
                    jsid       ns_id,
                    char     **version)
{
    jsid versions_name;
    jsval versions_val;
    JSObject *versions;
    jsval version_val;

    versions_name = gjs_context_get_const_string(context, GJS_STRING_GI_VERSIONS);
    if (!gjs_object_require_property(context, repo_obj, "GI repository object", versions_name, &versions_val) ||
        !JSVAL_IS_OBJECT(versions_val)) {
        gjs_throw(context, "No 'versions' property in GI repository object");
        return JS_FALSE;
    }

    versions = JSVAL_TO_OBJECT(versions_val);

    *version = NULL;
    if (JS_GetPropertyById(context, versions, ns_id, &version_val) &&
        JSVAL_IS_STRING(version_val)) {
        gjs_string_to_utf8(context, version_val, version);
    }

    return JS_TRUE;
}
开发者ID:fatman2021,项目名称:cjs,代码行数:28,代码来源:repo.cpp


示例8: newStreamObject

// todo: similar code is also in ejsnet.cpp
JSBool
newStreamObject(JSContext* cx, JSObject* obj, std::streambuf* stream, jsval* rval)
{
  // todo: this is quite ugly
  // create javascript Stream object and set stream pointer
  // the difficulty is that we do not have any native reference
  // => we must use the interpreter to indirectly create a native Stream
  // wrapper object and set the private data accordingly
  // this is only safe if we know that the created javascript object 
  // is of the correct class (stream_class) otherwise this would be dangerous

  jsval streamval;
  if (!ejs_evalExpression(cx,obj,"new (ejs.ModuleLoader.get(\"Stream\").Stream)()",&streamval))
    return JS_FALSE;

  // todo: is this enough to root this object?
  *rval=streamval;
  if (!JSVAL_IS_OBJECT(streamval))
    EJS_THROW_ERROR(cx,obj,"failed to create Stream object");
  JSObject* jsstream=JSVAL_TO_OBJECT(streamval);
  // make sure this object has a private slot and it is NULL
  JSClass* oclass;
  if ((!(oclass=JS_GET_CLASS(cx,jsstream)))
      || (!(oclass->flags & JSCLASS_HAS_PRIVATE))
      || (JS_GetPrivate(cx,jsstream))
      || (std::string("Stream")!=oclass->name))
    EJS_THROW_ERROR(cx,obj,"you have messed with the Stream object");
  
  if (!JS_SetPrivate(cx,jsstream,(void *)stream))
    return JS_FALSE;
  // tell the stream object wether to delete this streambuf
  JS_SetReservedSlot(cx,jsstream,0,JSVAL_TRUE);
  
  return JS_TRUE;
}
开发者ID:BackupTheBerlios,项目名称:egachine,代码行数:36,代码来源:ejsfile.cpp


示例9: SMJS_FUNCTION

static JSBool SMJS_FUNCTION(widget_message_handler_factory)
{
	char *msg_name;
	u32 i, count;
	SMJS_OBJ
	SMJS_ARGS
	GF_WidgetInterfaceInstance *bifce = (GF_WidgetInterfaceInstance *)SMJS_GET_PRIVATE(c, obj);
	if (!bifce) return JS_FALSE;

	if (!argc) return JS_FALSE;
	if (!JSVAL_IS_STRING(argv[0])) return JS_FALSE;

	msg_name = SMJS_CHARS(c, argv[0]);
	if (!msg_name ) return JS_FALSE;

	SMJS_SET_RVAL( JSVAL_NULL );
	count = gf_list_count(bifce->ifce->messages);
	for (i=0; i<count; i++) {
		GF_WidgetMessage *msg = gf_list_get(bifce->ifce->messages, i);
		if (!strcmp(msg->name, msg_name)) {
			JSObject *an_obj = JS_NewObject(c, &bifce->wid->widget->wm->widgetAnyClass._class, 0, 0);
			SMJS_SET_PRIVATE(c, an_obj, msg);
			JS_DefineProperty(c, an_obj, "msgName", STRING_TO_JSVAL( JS_NewStringCopyZ(c, msg->name) ), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT);
			JS_DefineProperty(c, an_obj, "interfaceHandler", OBJECT_TO_JSVAL( obj ), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT);
			JS_DefineFunction(c, an_obj, "onInvokeReply", widget_call_message_reply_callback, 1, 0);

			if ((argc==2) && JSVAL_IS_OBJECT(argv[1]) && !JSVAL_IS_NULL(argv[1]))
				JS_DefineProperty(c, an_obj, "replyCallback", argv[1], 0, 0, JSPROP_READONLY | JSPROP_PERMANENT);
			
			SMJS_SET_RVAL( OBJECT_TO_JSVAL(an_obj) );
		}
	}
	SMJS_FREE(c, msg_name);
	return JS_TRUE;
}
开发者ID:DmitrySigaev,项目名称:gpac_hbbtv,代码行数:35,代码来源:widget.c


示例10: gjs_define_root_importer

JSBool
gjs_define_root_importer(JSContext   *context,
                         JSObject    *in_object,
                         const char  *importer_name)
{
    JSObject *global;
    jsval value;
    JSBool success;

    success = JS_FALSE;
    global = gjs_get_import_global(context);
    JS_BeginRequest(context);

    if (!gjs_object_require_property(context,
                                     global, "global object",
                                     "imports", &value) ||
            !JSVAL_IS_OBJECT(value)) {
        gjs_debug(GJS_DEBUG_IMPORTER, "Root importer did not exist, couldn't get from load context; must create it");
        goto fail;
    }

    if (!JS_DefineProperty(context, in_object,
                           importer_name, value,
                           NULL, NULL,
                           GJS_MODULE_PROP_FLAGS)) {
        gjs_debug(GJS_DEBUG_IMPORTER, "DefineProperty %s on %p failed",
                  importer_name, in_object);
        goto fail;
    }

    success = JS_TRUE;
fail:
    JS_EndRequest(context);
    return success;
}
开发者ID:KNOPOChKA2,项目名称:gjs,代码行数:35,代码来源:importer.c


示例11: jsd_GetValuePrototype

JSDValue*
jsd_GetValuePrototype(JSDContext* jsdc, JSDValue* jsdval)
{
    JSCrossCompartmentCall *call = NULL;

    if(!(CHECK_BIT_FLAG(jsdval->flags, GOT_PROTO)))
    {
        JSObject* obj;
        JSObject* proto;
        JS_ASSERT(!jsdval->proto);
        SET_BIT_FLAG(jsdval->flags, GOT_PROTO);
        if(!JSVAL_IS_OBJECT(jsdval->val))
            return NULL;
        if(!(obj = JSVAL_TO_OBJECT(jsdval->val)))
            return NULL;
        JS_BeginRequest(jsdc->dumbContext);
        call = JS_EnterCrossCompartmentCall(jsdc->dumbContext, obj);
        if(!call) {
            JS_EndRequest(jsdc->dumbContext);

            return NULL;
        }
        proto = JS_GetPrototype(jsdc->dumbContext, obj);
        JS_LeaveCrossCompartmentCall(call);
        JS_EndRequest(jsdc->dumbContext);
        if(!proto)
            return NULL;
        jsdval->proto = jsd_NewValue(jsdc, OBJECT_TO_JSVAL(proto));
    }
    if(jsdval->proto)
        jsdval->proto->nref++;
    return jsdval->proto;
}
开发者ID:ThinkerYzu,项目名称:mozilla-central,代码行数:33,代码来源:jsd_val.c


示例12: JSD_ASSERT_VALID_VALUE

void JSD_ASSERT_VALID_VALUE(JSDValue* jsdval)
{
    JS_ASSERT(jsdval);
    JS_ASSERT(jsdval->nref > 0);
    if(!JS_CLIST_IS_EMPTY(&jsdval->props))
    {
        JS_ASSERT(CHECK_BIT_FLAG(jsdval->flags, GOT_PROPS));
        JS_ASSERT(JSVAL_IS_OBJECT(jsdval->val));
    }

    if(jsdval->proto)
    {
        JS_ASSERT(CHECK_BIT_FLAG(jsdval->flags, GOT_PROTO));
        JS_ASSERT(jsdval->proto->nref > 0);
    }
    if(jsdval->parent)
    {
        JS_ASSERT(CHECK_BIT_FLAG(jsdval->flags, GOT_PARENT));
        JS_ASSERT(jsdval->parent->nref > 0);
    }
    if(jsdval->ctor)
    {
        JS_ASSERT(CHECK_BIT_FLAG(jsdval->flags, GOT_CTOR));
        JS_ASSERT(jsdval->ctor->nref > 0);
    }
}
开发者ID:bjonreyes,项目名称:spidernode,代码行数:26,代码来源:jsd_val.c


示例13: jsd_GetValueParent

JSDValue*
jsd_GetValueParent(JSDContext* jsdc, JSDValue* jsdval)
{
    JSCrossCompartmentCall *call = NULL;

    if(!(CHECK_BIT_FLAG(jsdval->flags, GOT_PARENT)))
    {
        JSObject* obj;
        JSObject* parent;
        JS_ASSERT(!jsdval->parent);
        SET_BIT_FLAG(jsdval->flags, GOT_PARENT);
        if(!JSVAL_IS_OBJECT(jsdval->val))
            return NULL;
        if(!(obj = JSVAL_TO_OBJECT(jsdval->val)))
            return NULL;
        JS_BeginRequest(jsdc->dumbContext);
        call = JS_EnterCrossCompartmentCall(jsdc->dumbContext, obj);
        if(!call) {
            JS_EndRequest(jsdc->dumbContext);

            return NULL;
        }
        parent = JS_GetParentOrScopeChain(jsdc->dumbContext,obj);
        JS_LeaveCrossCompartmentCall(call);
        JS_EndRequest(jsdc->dumbContext);
        if(!parent)
            return NULL;
        jsdval->parent = jsd_NewValue(jsdc, OBJECT_TO_JSVAL(parent));
    }
    if(jsdval->parent)
        jsdval->parent->nref++;
    return jsdval->parent;
}
开发者ID:bjonreyes,项目名称:spidernode,代码行数:33,代码来源:jsd_val.c


示例14: gjs_lookup_fundamental_prototype

static JSObject *
gjs_lookup_fundamental_prototype(JSContext    *context,
                                 GIObjectInfo *info,
                                 GType         gtype)
{
    JSObject *in_object;
    JSObject *constructor;
    const char *constructor_name;
    jsval value;

    if (info) {
        in_object = gjs_lookup_namespace_object(context, (GIBaseInfo*) info);
        constructor_name = g_base_info_get_name((GIBaseInfo*) info);
    } else {
        in_object = gjs_lookup_private_namespace(context);
        constructor_name = g_type_name(gtype);
    }

    if (G_UNLIKELY (!in_object))
        return NULL;

    if (!JS_GetProperty(context, in_object, constructor_name, &value))
        return NULL;

    if (JSVAL_IS_VOID(value)) {
        /* In case we're looking for a private type, and we don't find it,
           we need to define it first.
        */
        gjs_define_fundamental_class(context, in_object, info, &constructor, NULL);
    } else {
        if (G_UNLIKELY (!JSVAL_IS_OBJECT(value) || JSVAL_IS_NULL(value)))
            return NULL;

        constructor = JSVAL_TO_OBJECT(value);
    }

    g_assert(constructor != NULL);

    if (!gjs_object_get_property_const(context, constructor,
                                       GJS_STRING_PROTOTYPE, &value))
        return NULL;

    if (G_UNLIKELY (!JSVAL_IS_OBJECT(value)))
        return NULL;

    return JSVAL_TO_OBJECT(value);
}
开发者ID:victoryang,项目名称:gjs,代码行数:47,代码来源:fundamental.cpp


示例15: SMJS_FUNCTION

static JSBool SMJS_FUNCTION(upnp_service_set_action_listener)
{
	PLT_ActionDesc *action;
	PLT_ArgumentDesc *desc;
	GPAC_ActionArgListener *argl  = NULL;
	char *name;
	Bool script_callback = GF_FALSE;
	u32 i;
	SMJS_OBJ
	SMJS_ARGS
	GPAC_ServiceItem *service = (GPAC_ServiceItem *)SMJS_GET_PRIVATE(c, obj);
	if (!service || (argc<2) || !JSVAL_IS_STRING(argv[0]) || !JSVAL_IS_OBJECT(argv[1])) return JS_FALSE;

	name = SMJS_CHARS(c, argv[0]);
	if (!name) return JS_FALSE;

	action = service->m_service->FindActionDesc(name);
	SMJS_FREE(c, name);

	if (!action) return JS_FALSE;

	desc = NULL;
	if (argc==3) {
		if (JSVAL_IS_BOOLEAN(argv[2])) {
			script_callback = GF_TRUE;
		} else {
			if (!JSVAL_IS_STRING(argv[2]) ) return JS_FALSE;
			name = SMJS_CHARS(c, argv[2]);
			if (!name) return JS_FALSE;
			desc = action->GetArgumentDesc(name);
			SMJS_FREE(c, name);
			if (!desc) return JS_FALSE;
		}
	}


	/*action listener*/
	i=0;
	while ((argl = (GPAC_ActionArgListener *)gf_list_enum(service->m_ArgListeners, &i))) {
		if (argl->arg == desc) break;
		argl = NULL;
	}
	if (!argl) {
		argl = new GPAC_ActionArgListener();
		argl->arg = desc;
		gf_list_add(service->m_ArgListeners, argl);
	}
	argl->action = action;
	if (!JSVAL_IS_NULL(argl->on_event))
		gf_js_remove_root(c, &argl->on_event, GF_JSGC_VAL);
	if (JSVAL_IS_NULL(argv[1])) {
		gf_list_del_item(service->m_ArgListeners, argl);
		delete argl;
	}
	argl->on_event = argv[1];
	argl->is_script = script_callback;
	gf_js_add_root(c, &argl->on_event, GF_JSGC_VAL);
	return JS_TRUE;
}
开发者ID:ARSekkat,项目名称:gpac,代码行数:59,代码来源:GenericDevice.cpp


示例16: InstallFileOpDirRename

//
// Native method DirRename
//
JSBool PR_CALLBACK
InstallFileOpDirRename(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
  nsInstall *nativeThis =
    GetNativeThis(cx, obj, argv);
  if (!nativeThis)
    return JS_FALSE;

  PRInt32 nativeRet;
  nsAutoString b1;
  JSObject *jsObj;
  nsInstallFolder *folder;

  *rval = INT_TO_JSVAL(nsInstall::UNEXPECTED_ERROR);

  if(argc >= 2)
  {
    //  public int DirRename (String aSourceFolder,
    //                        String aTargetFolder);

    ConvertJSValToStr(b1, cx, argv[1]);

// fix: nsFileSpec::Rename() does not accept new name as a
//      nsFileSpec type.  It only accepts a char* type for the new name
//      This is a bug with nsFileSpec.  A char* will be used until
//      nsFileSpec if fixed.
//    nsFileSpec fsB1(b1);
    
    if (argv[0] == JSVAL_NULL || !JSVAL_IS_OBJECT(argv[0])) //argv[0] MUST be a jsval
    {
      *rval = INT_TO_JSVAL(nsInstall::INVALID_ARGUMENTS);
      return JS_TRUE;
    }

    jsObj = JSVAL_TO_OBJECT(argv[0]);

    if (!JS_InstanceOf(cx, jsObj, &FileSpecObjectClass, nsnull))
    {
      *rval = INT_TO_JSVAL(nsInstall::INVALID_ARGUMENTS);
      return JS_TRUE;
    }

    folder = (nsInstallFolder*)JS_GetPrivate(cx, jsObj);

    if(!folder || NS_OK != nativeThis->FileOpDirRename(*folder, b1, &nativeRet))
    {
      return JS_TRUE;
    }

    *rval = INT_TO_JSVAL(nativeRet);
  }
  else
  {
    JS_ReportError(cx, "Function DirRename requires 2 parameters");
    return JS_TRUE;
  }

  return JS_TRUE;
}
开发者ID:rn10950,项目名称:RetroZilla,代码行数:62,代码来源:nsJSFile.cpp


示例17: toObject

    BSONObj toObject( jsval v ) {
        if ( JSVAL_IS_NULL( v ) ||
                JSVAL_IS_VOID( v ) )
            return BSONObj();

        uassert( 10215 ,  "not an object" , JSVAL_IS_OBJECT( v ) );
        return toObject( JSVAL_TO_OBJECT( v ) );
    }
开发者ID:xrogaan,项目名称:mongo,代码行数:8,代码来源:engine_spidermonkey.cpp


示例18: assert

void TraceMonkeyValue::setProperty(std::string propertyName, ScriptValuePtr propertyValue)
{
    assert(isValid());

    assert(JSVAL_IS_OBJECT(value));
    jsval ret = (dynamic_cast<TraceMonkeyValue*>(propertyValue.get())->value);
    JS_SetProperty(TraceMonkeyEngine::context, JSVAL_TO_OBJECT(value), propertyName.c_str(), &ret);
}
开发者ID:Amplifying,项目名称:intensityengine,代码行数:8,代码来源:script_engine_tracemonkey.cpp


示例19: takeArgsToWebRequest

void takeArgsToWebRequest(JSContext *cx, uintN argc, jsval *vp, char post){
	if(argc > 0){
		JSString *jsurl = NULL;
		jsurl = JS_ValueToString(cx,JS_ARGV(cx,vp)[0]);
		if(jsurl){
			char *url = NULL;
			url = JS_EncodeString(cx,jsurl);
			jsval success = JSVAL_NULL, failure = JSVAL_NULL;
			if(JSVAL_IS_OBJECT(JS_ARGV(cx,vp)[1])){
				success = JS_ARGV(cx,vp)[1];
			}

			if(JSVAL_IS_OBJECT(JS_ARGV(cx,vp)[2])){
				failure = JS_ARGV(cx,vp)[2];
			}

			if(url){
				int length = 1;
				char *str = url;
				while(*url != '\0'){
					if(*url++ == ' ') length += 3;
					else length++;
				}
				url = str;
				char *url2 = (char*)malloc(length),*url_enc = url2;
				
				while(*url != '\0'){
					if(*url == ' '){
						*url2++ = '%';
						*url2++ = '2';
						*url2++ = '0';
						url++;
					} else 
						*url2++ = *url++;
				}
				*url2 = '\0';
					
				launchRequest(url_enc,NULL,0,success,failure); //zero says use get
				if(url_enc) free(url_enc);
				JS_free(cx,str);
			}
			
		}
	}
}
开发者ID:joejoyce,项目名称:jsEngine,代码行数:45,代码来源:web.cpp


示例20: jsd_GetValueString

JSString*
jsd_GetValueString(JSDContext* jsdc, JSDValue* jsdval)
{
    JSContext* cx = jsdc->dumbContext;
    JSExceptionState* exceptionState;
    JSCrossCompartmentCall *call = NULL;
    jsval stringval;
    JSString *string;
    JSBool needWrap;
    JSObject *scopeObj;

    if(jsdval->string)
        return jsdval->string;

    /* Reuse the string without copying or re-rooting it */
    if(JSVAL_IS_STRING(jsdval->val)) {
        jsdval->string = JSVAL_TO_STRING(jsdval->val);
        return jsdval->string;
    }

    JS_BeginRequest(cx);

    /* Objects call JS_ValueToString in their own compartment. */
    scopeObj = JSVAL_IS_OBJECT(jsdval->val) ? JSVAL_TO_OBJECT(jsdval->val) : jsdc->glob;
    call = JS_EnterCrossCompartmentCall(cx, scopeObj);
    if(!call) {
        JS_EndRequest(cx);
        return NULL;
    }
    exceptionState = JS_SaveExceptionState(cx);

    string = JS_ValueToString(cx, jsdval->val);

    JS_RestoreExceptionState(cx, exceptionState);
    JS_LeaveCrossCompartmentCall(call);
    call = NULL;

    if(string) {
        stringval = STRING_TO_JSVAL(string);
        call = JS_EnterCrossCompartmentCall(cx, jsdc->glob);
    }
    if(!string || !call || !JS_WrapValue(cx, &stringval)) {
        if(call)
            JS_LeaveCrossCompartmentCall(call);
        JS_EndRequest(cx);
        return NULL;
    }

    jsdval->string = JSVAL_TO_STRING(stringval);
    if(!JS_AddNamedStringRoot(cx, &jsdval->string, "ValueString"))
        jsdval->string = NULL;

    JS_LeaveCrossCompartmentCall(call);
    JS_EndRequest(cx);

    return jsdval->string;
}
开发者ID:moussa1,项目名称:mozilla-central,代码行数:57,代码来源:jsd_val.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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