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

C++ JSVAL_IS_VOID函数代码示例

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

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



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

示例1: JSVAL_IS_VOID

void JSArmatureWrapper::addArmatureFileInfoAsyncCallbackFunc(float percent)
{
    JSContext *cx = ScriptingCore::getInstance()->getGlobalContext();
    JSObject *thisObj = JSVAL_IS_VOID(_jsThisObj) ? NULL : JSVAL_TO_OBJECT(_jsThisObj);
    jsval retval;
    if (_jsCallback != JSVAL_VOID)
    {
        jsval percentVal = DOUBLE_TO_JSVAL(percent);

        JS_AddValueRoot(cx, &percentVal);
        
        JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET
        
        JS_CallFunctionValue(cx, thisObj, _jsCallback, 1, &percentVal, &retval);
        JS_RemoveValueRoot(cx, &percentVal);
    }
}
开发者ID:6520874,项目名称:pipiGame,代码行数:17,代码来源:jsb_cocos2dx_studio_manual.cpp


示例2: JSVAL_TO_OBJECT

/**
 * 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, JSObject *aObject,
                                    const char *aProperty)
{
  jsval val;
  if (JS_GetProperty(cx, aObject, aProperty, &val)
      && !JSVAL_IS_VOID(val)) {
    if (JSVAL_IS_OBJECT(val)) {
      return JSVAL_TO_OBJECT(val);
    }
    else {
      JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
         JSMSG_UNEXPECTED_TYPE, aProperty, "not an object");
      return NULL;
    }
  }
  return JS_DefineObject(cx, aObject, aProperty, NULL, NULL, JSPROP_ENUMERATE);
}
开发者ID:michaelwu,项目名称:mozilla-central-pa,代码行数:23,代码来源:OSFileConstants.cpp


示例3: PJS_GetPassport

SV* PJS_GetPassport(
    pTHX_
    JSContext *cx,
    JSObject *thing
) {
    jsval temp;
    SV *box;
    SV *tref;
    JSObject *inboxed;
    if(!JS_LookupPropertyWithFlags(cx, thing, PJS_PASSPORT_PROP, 0, &temp)
       || JSVAL_IS_VOID(temp) || JSVAL_IS_NULL(temp))
	croak("Can't get passport");
    box = (SV *)JS_GetPrivate(cx, JSVAL_TO_OBJECT(temp));
    tref = *av_fetch((AV *)SvRV(box), 0, 0);
    inboxed = INT2PTR(JSObject *, SvIV((SV *)SvRV(tref)));
    assert(inboxed == thing);
    return box;
}
开发者ID:gitpan,项目名称:JSP,代码行数:18,代码来源:PJS_Reflection.c


示例4: propertyOp

static JSBool
propertyOp(const char *name, JSContext *cx, JSObject *obj, jsval id,
           jsval *vp)
{
  if (resolverHasMethod(cx, obj, name)) {
    jsval rval;
    jsval args[2];
    args[0] = id;
    args[1] = *vp;
    if (!delegateToResolver(cx, obj, name, 2, args, &rval))
      return JS_FALSE;

    if (!JSVAL_IS_VOID(rval))
      *vp = rval;
    return JS_TRUE;
  }
  return JS_PropertyStub(cx, obj, id, vp);
}
开发者ID:8planes,项目名称:mirosubs-jetpack,代码行数:18,代码来源:wrapper.cpp


示例5: if

// static
nsresult
IDBKeyRange::FromJSVal(JSContext* aCx,
                       const jsval& aVal,
                       IDBKeyRange** aKeyRange)
{
  nsresult rv;
  nsRefPtr<IDBKeyRange> keyRange;

  if (JSVAL_IS_VOID(aVal) || JSVAL_IS_NULL(aVal)) {
    // undefined and null returns no IDBKeyRange.
  }
  else if (JSVAL_IS_PRIMITIVE(aVal) ||
           JS_IsArrayObject(aCx, JSVAL_TO_OBJECT(aVal)) ||
           JS_ObjectIsDate(aCx, JSVAL_TO_OBJECT(aVal))) {
    // A valid key returns an 'only' IDBKeyRange.
    keyRange = new IDBKeyRange(false, false, true);

    rv = GetKeyFromJSVal(aCx, aVal, keyRange->Lower());
    if (NS_FAILED(rv)) {
      return rv;
    }
  }
  else {
    // An object is not permitted unless it's another IDBKeyRange.
    nsIXPConnect* xpc = nsContentUtils::XPConnect();
    NS_ASSERTION(xpc, "This should never be null!");

    nsCOMPtr<nsIXPConnectWrappedNative> wrapper;
    rv = xpc->GetWrappedNativeOfJSObject(aCx, JSVAL_TO_OBJECT(aVal),
                                         getter_AddRefs(wrapper));
    NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);

    nsCOMPtr<nsIIDBKeyRange> iface;
    if (!wrapper || !(iface = do_QueryInterface(wrapper->Native()))) {
      // Some random JS object?
      return NS_ERROR_DOM_INDEXEDDB_DATA_ERR;
    }

    keyRange = static_cast<IDBKeyRange*>(iface.get());
  }

  keyRange.forget(aKeyRange);
  return NS_OK;
}
开发者ID:almet,项目名称:mozilla-central,代码行数:45,代码来源:IDBKeyRange.cpp


示例6: NS_ASSERTION

NS_IMETHODIMP
LockedFile::GetMetadata(const jsval& aParameters,
                        JSContext* aCx,
                        nsIDOMFileRequest** _retval)
{
  NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");

  if (!IsOpen()) {
    return NS_ERROR_DOM_FILEHANDLE_LOCKEDFILE_INACTIVE_ERR;
  }

  // Do nothing if the window is closed
  if (!GetOwner()) {
    return NS_OK;
  }

  nsRefPtr<MetadataParameters> params = new MetadataParameters();

  // Get optional arguments.
  if (!JSVAL_IS_VOID(aParameters) && !JSVAL_IS_NULL(aParameters)) {
    nsresult rv = params->Init(aCx, &aParameters);
    NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR);

    if (!params->IsConfigured()) {
      return NS_ERROR_TYPE_ERR;
    }
  }
  else {
    params->Init(true, true);
  }

  nsRefPtr<FileRequest> fileRequest = GenerateFileRequest();
  NS_ENSURE_TRUE(fileRequest, NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR);

  nsRefPtr<MetadataHelper> helper =
    new MetadataHelper(this, fileRequest, params);

  nsresult rv = helper->Enqueue();
  NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR);

  fileRequest.forget(_retval);
  return NS_OK;
}
开发者ID:Ajunboys,项目名称:mozilla-os2,代码行数:43,代码来源:LockedFile.cpp


示例7: NS_ASSERTION

void
IDBRequest::NotifyHelperSentResultsToChildProcess(nsresult aRv)
{
  NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
  NS_ASSERTION(!mHaveResultOrErrorCode, "Already called!");
  NS_ASSERTION(JSVAL_IS_VOID(mResultVal), "Should be undefined!");

  // See if our window is still valid. If not then we're going to pretend that
  // we never completed.
  if (NS_FAILED(CheckInnerWindowCorrectness())) {
    return;
  }

  mHaveResultOrErrorCode = true;

  if (NS_FAILED(aRv)) {
    SetError(aRv);
  }
}
开发者ID:vlajos,项目名称:mozilla-central,代码行数:19,代码来源:IDBRequest.cpp


示例8: 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:stallman,项目名称:showtime,代码行数:43,代码来源:js.c


示例9: gf_webvtt_js_addCue

GF_EXPORT
GF_Err gf_webvtt_js_addCue(GF_Node *node, const char *id,
                           const char *start, const char *end,
                           const char *settings,
                           const char *payload)
{
	GF_Err e;
	JSBool found;
	JSContext *c = node->sgprivate->scenegraph->svg_js->js_ctx;
	JSObject *global = node->sgprivate->scenegraph->svg_js->global;
	jsval fun_val;

	gf_sg_lock_javascript(c, GF_TRUE);
	found = JS_LookupProperty(c, global, "addCue", &fun_val);
	if (!found || JSVAL_IS_VOID(fun_val) || !JSVAL_IS_OBJECT(fun_val) ) {
		e = GF_BAD_PARAM;
	} else {
		JSBool ret;
		uintN attr;
		ret = JS_GetPropertyAttributes(c, global, "addCue", &attr, &found);
		if (ret == JS_TRUE && found == JS_TRUE) {
			jsval rval;
			jsval argv[5];
			argv[0] = STRING_TO_JSVAL( JS_NewStringCopyZ(c, (id ? id : "")) );
			argv[1] = STRING_TO_JSVAL( JS_NewStringCopyZ(c, (start ? start : "")) );
			argv[2] = STRING_TO_JSVAL( JS_NewStringCopyZ(c, (end ? end : "")) );
			argv[3] = STRING_TO_JSVAL( JS_NewStringCopyZ(c, (settings ? settings : "")) );
			argv[4] = STRING_TO_JSVAL( JS_NewStringCopyZ(c, (payload ? payload : "")) );

			ret = JS_CallFunctionValue(c, global, fun_val, 5, argv, &rval);
			//ret = JS_CallFunctionName(c, global, "addCue", 5, argv, &rval);
			if (ret == JS_TRUE) {
				e = GF_OK;
			} else {
				e = GF_BAD_PARAM;
			}
		} else {
			e = GF_BAD_PARAM;
		}
	}
	gf_sg_lock_javascript(c, GF_FALSE);
	return e;
}
开发者ID:Bevara,项目名称:GPAC,代码行数:43,代码来源:webvtt_smjs.c


示例10: 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


示例11: ValueToString

static void
ValueToString(JSContext *cx, jsval aJSValue, nsString& aString)
{
	if (JSVAL_IS_VOID(aJSValue)) {
		aString.Assign(kUndefined, STRLEN_ARRAY(kUndefined));
	} else if (JSVAL_IS_NULL(aJSValue)) {
		aString.Assign(kNull, STRLEN_ARRAY(kNull));
	} else if (JSVAL_IS_INT(aJSValue)) {
		jsint i = JSVAL_TO_INT(aJSValue);
		char buf[20];
		PR_snprintf(buf, sizeof(buf), "%d", i);
		aString.Assign(NS_ConvertASCIItoUTF16(buf));
	} else if (JSVAL_IS_DOUBLE(aJSValue)) {
		jsdouble d = JSVAL_TO_DOUBLE(aJSValue);
		char buf[50];
		PR_snprintf(buf, sizeof(buf), "%f", d);
		aString.Assign(NS_ConvertASCIItoUTF16(buf));
	} else if (JSVAL_IS_BOOLEAN(aJSValue)) {
		JSBool b = JSVAL_TO_BOOLEAN(aJSValue);
		if (b)
			aString.Assign(kTrue, STRLEN_ARRAY(kTrue));
		else
			aString.Assign(kFalse, STRLEN_ARRAY(kFalse));
	} else if (JSVAL_IS_STRING(aJSValue)) {
		JSString *str = JSVAL_TO_STRING(aJSValue);
		size_t len;
		const jschar *chars = JS_GetStringCharsAndLength(cx, str, &len);
		NS_ASSERTION(chars, "out of memory");
		if (chars) {
			NS_ASSERTION(sizeof(jschar) == sizeof(PRUnichar),
						 "char size mismatch");
			aString.Assign(reinterpret_cast<const PRUnichar*>(chars), len);
		}
	} else {
		JSObject *obj = JSVAL_TO_OBJECT(aJSValue);
		JSClass *clazz = JS_GetClass(cx, obj);
		aString.Assign(PRUnichar('['));
		aString.Append(NS_ConvertASCIItoUTF16(clazz->name));
		aString.Append(PRUnichar(']'));
	}
}
开发者ID:dbaron,项目名称:leak-monitor,代码行数:41,代码来源:leakmonJSObjectInfo.cpp


示例12: js_AtomizePrimitiveValue

JSBool
js_AtomizePrimitiveValue(JSContext *cx, jsval v, JSAtom **atomp)
{
    JSAtom *atom;

    if (JSVAL_IS_STRING(v)) {
        atom = js_AtomizeString(cx, JSVAL_TO_STRING(v), 0);
        if (!atom)
            return JS_FALSE;
    } else if (JSVAL_IS_DOUBLE(v)) {
        atom = js_AtomizeDouble(cx, *JSVAL_TO_DOUBLE(v));
        if (!atom)
            return JS_FALSE;
    } else {
        JS_ASSERT(JSVAL_IS_INT(v) || JSVAL_IS_BOOLEAN(v) ||
                  JSVAL_IS_NULL(v) || JSVAL_IS_VOID(v));
        atom = (JSAtom *)v;
    }
    *atomp = atom;
    return JS_TRUE;
}
开发者ID:Web5design,项目名称:meguro,代码行数:21,代码来源:jsatom.cpp


示例13: JS_THIS_OBJECT

JSBool
Library::Open(JSContext* cx, uintN argc, jsval *vp)
{
  JSObject* ctypesObj = JS_THIS_OBJECT(cx, vp);
  if (!ctypesObj || !IsCTypesGlobal(cx, ctypesObj)) {
    JS_ReportError(cx, "not a ctypes object");
    return JS_FALSE;
  }

  if (argc != 1 || JSVAL_IS_VOID(JS_ARGV(cx, vp)[0])) {
    JS_ReportError(cx, "open requires a single argument");
    return JS_FALSE;
  }

  JSObject* library = Create(cx, JS_ARGV(cx, vp)[0], GetCallbacks(cx, ctypesObj));
  if (!library)
    return JS_FALSE;

  JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(library));
  return JS_TRUE;
}
开发者ID:GCRC,项目名称:build-couchdb,代码行数:21,代码来源:Library.cpp


示例14: spidermonkey_eval_boolback

int
spidermonkey_eval_boolback(struct ecmascript_interpreter *interpreter,
			   struct string *code)
{
	JSContext *ctx;
	JSFunction *fun;
	jsval rval;
	int ret;

	assert(interpreter);
	if (!js_module_init_ok) return 0;
	ctx = interpreter->backend_data;
	interpreter->ret = NULL;
	fun = JS_CompileFunction(ctx, NULL, "", 0, NULL, code->source,
				 code->length, "", 0);
	if (!fun)
		return -1;

#if defined(CONFIG_ECMASCRIPT_SMJS_HEARTBEAT)
	interpreter->heartbeat = add_heartbeat(interpreter);
#elif defined(HAVE_JS_SETBRANCHCALLBACK)
	setup_safeguard(interpreter, ctx);
#endif
	ret = JS_CallFunction(ctx, NULL, fun, 0, NULL, &rval);
#if defined(CONFIG_ECMASCRIPT_SMJS_HEARTBEAT)
	done_heartbeat(interpreter->heartbeat);
#endif
	if (ret == 2) { /* onClick="history.back()" */
		return 0;
	}
	if (ret == JS_FALSE) {
		return -1;
	}
	if (JSVAL_IS_VOID(rval)) {
		/* Undefined value. */
		return -1;
	}

	return jsval_to_boolean(ctx, &rval);
}
开发者ID:Efreak,项目名称:elinks,代码行数:40,代码来源:spidermonkey.c


示例15: wrap

js::ValueRef wrap(JSContext *cx, jsval val) {

    if ( JSVAL_IS_BOOLEAN(val)) {
        return JSVAL_TO_BOOLEAN(val) ? true : false;
    }
    if ( JSVAL_IS_NULL(val)){
     fprintf(stderr, "is null\n");
     }
    if ( JSVAL_IS_VOID(val)){
     fprintf(stderr, "is void\n");
     }
    if ( JSVAL_IS_INT (val)){
     fprintf(stderr, "is int\n");
     }
    if ( JSVAL_IS_STRING(val)) {
        JSString *str = JSVAL_TO_STRING(val);
        //todo: memory leak is my middle name
        js::String *jsstr = new js::String((std::string)JS_EncodeString(cx, str));

        return *jsstr;
    }
    if ( !JSVAL_IS_PRIMITIVE(val)) {
        JSObject* obj=JSVAL_TO_OBJECT(val);
        if (JS_IsArrayObject(cx, obj)){
            std::vector<js::ValueRef> els;
            jsuint length;
            JS_GetArrayLength(cx, obj, &length);
            for (int i = 0; i < length; i++){
                jsval ret;
                JS_GetElement(cx, obj, i, &ret);
                els.push_back(wrap(cx, ret));
            }
            // leaking memory
            js::Array *array=new js::Array(els);
            return (*array);
        }
    }
    return (std::string)"<unknown type>";
}
开发者ID:programmiersportgruppe,项目名称:structured-text-utils,代码行数:39,代码来源:js.cpp


示例16: js_ErrorFromException

JSErrorReport *
js_ErrorFromException(JSContext *cx, jsval exn)
{
    JSObject *obj;
    JSExnPrivate *privateData;
    jsval privateValue;

    if (JSVAL_IS_PRIMITIVE(exn))
        return NULL;
    obj = JSVAL_TO_OBJECT(exn);
    if (OBJ_GET_CLASS(cx, obj) != &ExceptionClass)
        return NULL;
    privateValue = OBJ_GET_SLOT(cx, obj, JSSLOT_PRIVATE);
    if (JSVAL_IS_VOID(privateValue))
        return NULL;
    privateData = (JSExnPrivate*) JSVAL_TO_PRIVATE(privateValue);
    if (!privateData)
        return NULL;

    JS_ASSERT(privateData->errorReport);
    return privateData->errorReport;
}
开发者ID:DmitrySigaev,项目名称:DSMedia,代码行数:22,代码来源:jsexn.c


示例17: vfw_setval

static void
vfw_setval(void *opaque, prop_event_t event, ...)
{
  wfv_t *wfv = opaque;
  va_list ap;
  rstr_t *r;
  const char *s;
  va_start(ap, event);

  switch(event) {
  case PROP_SET_VOID:
    if(JSVAL_IS_NULL(wfv->value) || JSVAL_IS_VOID(wfv->value))
      break;
    return;

  case PROP_SET_RSTRING:
    if(!JSVAL_IS_STRING(wfv->value))
      return;

    r = va_arg(ap, rstr_t *);
    if(strcmp(JS_GetStringBytes(JSVAL_TO_STRING(wfv->value)), rstr_get(r)))
      return;
    break;

  case PROP_SET_CSTRING:
    if(!JSVAL_IS_STRING(wfv->value))
      return;

    s = va_arg(ap, const char *);
    if(strcmp(JS_GetStringBytes(JSVAL_TO_STRING(wfv->value)), s))
      return;
    break;

  default:
    return;
  }
  wfv->done = 1;
}
开发者ID:CrashSerious,项目名称:showtime,代码行数:38,代码来源:js_prop.c


示例18: JSTypeToCOMType

VARTYPE XPCDispConvert::JSTypeToCOMType(XPCCallContext& ccx, jsval val)
{
    if(JSVAL_IS_PRIMITIVE(val))
    {
        if(JSVAL_IS_STRING(val))
        {
            return VT_BSTR;
        }
        if(JSVAL_IS_INT(val))
        {
            return VT_I4;
        }
        if(JSVAL_IS_DOUBLE(val))
        {
            return VT_R8;
        }
        if(JSVAL_IS_BOOLEAN(val))
        {
            return VT_BOOL;
        }
        if(JSVAL_IS_VOID(val))
        {
            return VT_EMPTY;
        }
        if(JSVAL_IS_NULL(val))
        {
            return VT_NULL;
        }
    }
    else
    {
        if(JS_IsArrayObject(ccx, JSVAL_TO_OBJECT(val)))
            return VT_ARRAY | VT_VARIANT;
        return VT_DISPATCH;
    }
    NS_ERROR("XPCDispConvert::JSTypeToCOMType was unable to identify the type of the jsval");
    return VT_EMPTY;
}
开发者ID:LittleForker,项目名称:mozilla-central,代码行数:38,代码来源:XPCDispConvert.cpp


示例19: gjs_object_require_property

/* Returns whether the object had the property; if the object did
 * not have the property, always sets an exception. Treats
 * "the property's value is JSVAL_VOID" the same as "no such property,"
 * while JS_GetProperty() treats only "no such property" as an error.
 * Guarantees that *value_p is set to something, if only JSVAL_VOID,
 * even if an exception is set and false is returned.
 */
gboolean
gjs_object_require_property(JSContext       *context,
                            JSObject        *obj,
                            const char      *obj_description,
                            const char      *property_name,
                            jsval           *value_p)
{
    jsval value;

    JS_BeginRequest(context);

    value = JSVAL_VOID;
    JS_GetProperty(context, obj, property_name, &value);

    if (value_p)
        *value_p = value;

    if (!JSVAL_IS_VOID(value)) {
        JS_ClearPendingException(context); /* in case JS_GetProperty() was on crack */
        JS_EndRequest(context);
        return TRUE;
    } else {
        /* remember gjs_throw() is a no-op if JS_GetProperty()
         * already set an exception
         */
        if (obj_description)
            gjs_throw(context,
                      "No property '%s' in %s (or its value was undefined)",
                      property_name, obj_description);
        else
            gjs_throw(context,
                      "No property '%s' in object %p (or its value was undefined)",
                      property_name, obj);

        JS_EndRequest(context);
        return FALSE;
    }
}
开发者ID:BabeNovelty,项目名称:glib-win32,代码行数:45,代码来源:jsapi-util-vs10.c


示例20: JSVAL_TO_STRING

xpc_qsAString::xpc_qsAString(JSContext *cx, jsval *pval)
{
    // From the T_ASTRING case in XPCConvert::JSData2Native.
    typedef implementation_type::char_traits traits;
    jsval v;
    JSString *s;
    const PRUnichar *chars;
    size_t len;

    v = *pval;
    if(JSVAL_IS_STRING(v))
    {
        s = JSVAL_TO_STRING(v);
    }
    else
    {
        if(JSVAL_IS_NULL(v) || JSVAL_IS_VOID(v))
        {
            (new(mBuf) implementation_type(
                traits::sEmptyBuffer, PRUint32(0)))->SetIsVoid(PR_TRUE);
            mValid = JS_TRUE;
            return;
        }

        s = JS_ValueToString(cx, v);
        if(!s)
        {
            mValid = JS_FALSE;
            return;
        }
        *pval = STRING_TO_JSVAL(s);  // Root the new string.
    }

    len = JS_GetStringLength(s);
    chars = (len == 0 ? traits::sEmptyBuffer : (const PRUnichar*)JS_GetStringChars(s));
    new(mBuf) implementation_type(chars, len);
    mValid = JS_TRUE;
}
开发者ID:amyvmiwei,项目名称:firefox,代码行数:38,代码来源:xpcquickstubs.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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