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


C++ JSVAL_IS_VOID函数代码示例

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


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


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