本文整理汇总了C++中JSVAL_IS_BOOLEAN函数的典型用法代码示例。如果您正苦于以下问题:C++ JSVAL_IS_BOOLEAN函数的具体用法?C++ JSVAL_IS_BOOLEAN怎么用?C++ JSVAL_IS_BOOLEAN使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了JSVAL_IS_BOOLEAN函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: js_json_emit_jsval
static void
js_json_emit_jsval(JSContext *cx, jsval value, htsbuf_queue_t *out)
{
char buf[100];
if(JSVAL_IS_BOOLEAN(value)) {
if(JSVAL_TO_BOOLEAN(value))
htsbuf_append(out, "true", 4);
else
htsbuf_append(out, "false", 5);
} else if(JSVAL_IS_INT(value)) {
snprintf(buf, sizeof(buf), "%d", JSVAL_TO_INT(value));
htsbuf_append(out, buf, strlen(buf));
} else if(JSVAL_IS_DOUBLE(value)) {
double dbl;
if(JS_ValueToNumber(cx, value, &dbl) &&
!my_double2str(buf, sizeof(buf), dbl))
htsbuf_append(out, buf, strlen(buf));
else
htsbuf_append(out, "null", 4);
} else if(JSVAL_IS_NULL(value)) {
htsbuf_append(out, "null", 4);
} else if(JSVAL_IS_STRING(value)) {
js_json_emit_str(cx, value, out);
} else if(JSVAL_IS_OBJECT(value)) {
JSObject *obj = JSVAL_TO_OBJECT(value);
JSClass *c = JS_GET_CLASS(cx, obj);
if(!strcmp(c->name, "XML")) // Treat some classes special
js_json_emit_str(cx, value, out);
else {
if(js_json_encode_from_object(cx, obj, out))
htsbuf_append(out, "null", 4);
}
}
}
开发者ID:Overx,项目名称:showtime,代码行数:35,代码来源:js_json.c
示例2: js_sprintf
char* DLLCALL
js_sprintf(JSContext *cx, uint argn, uintN argc, jsval *argv)
{
char* p;
JSString* str;
if((p=js_ValueToStringBytes(cx, argv[argn++], NULL))==NULL)
return(NULL);
p=xp_asprintf_start(p);
for(; argn<argc; argn++) {
if(JSVAL_IS_DOUBLE(argv[argn]))
p=xp_asprintf_next(p,XP_PRINTF_CONVERT|XP_PRINTF_TYPE_DOUBLE,*JSVAL_TO_DOUBLE(argv[argn]));
else if(JSVAL_IS_INT(argv[argn]))
p=xp_asprintf_next(p,XP_PRINTF_CONVERT|XP_PRINTF_TYPE_INT,JSVAL_TO_INT(argv[argn]));
else if(JSVAL_IS_BOOLEAN(argv[argn]) && xp_printf_get_type(p)!=XP_PRINTF_TYPE_CHARP)
p=xp_asprintf_next(p,XP_PRINTF_CONVERT|XP_PRINTF_TYPE_INT,JSVAL_TO_BOOLEAN(argv[argn]));
else {
if((str=JS_ValueToString(cx, argv[argn]))==NULL)
return(NULL);
p=xp_asprintf_next(p,XP_PRINTF_CONVERT|XP_PRINTF_TYPE_CHARP,JS_GetStringBytes(str));
}
}
return xp_asprintf_end(p, NULL);
}
开发者ID:ftnapps,项目名称:pkg-sbbs,代码行数:27,代码来源:js_sprintf.c
示例3: JSHistogram_Add
JSBool
JSHistogram_Add(JSContext *cx, unsigned argc, jsval *vp)
{
if (!argc) {
JS_ReportError(cx, "Expected one argument");
return JS_FALSE;
}
jsval v = JS_ARGV(cx, vp)[0];
if (!(JSVAL_IS_NUMBER(v) || JSVAL_IS_BOOLEAN(v))) {
JS_ReportError(cx, "Not a number");
return JS_FALSE;
}
int32_t value;
if (!JS_ValueToECMAInt32(cx, v, &value)) {
return JS_FALSE;
}
if (TelemetryImpl::CanRecord()) {
JSObject *obj = JS_THIS_OBJECT(cx, vp);
if (!obj) {
return JS_FALSE;
}
Histogram *h = static_cast<Histogram*>(JS_GetPrivate(obj));
if (h->histogram_type() == Histogram::BOOLEAN_HISTOGRAM)
h->Add(!!value);
else
h->Add(value);
}
return JS_TRUE;
}
开发者ID:TheTypoMaster,项目名称:fennec-777045,代码行数:34,代码来源:Telemetry.cpp
示例4: js_ValueToBoolean
JSBool
js_ValueToBoolean(JSContext *cx, jsval v, JSBool *bp)
{
JSBool b;
jsdouble d;
if (JSVAL_IS_NULL(v) || JSVAL_IS_VOID(v))
{
b = JS_FALSE;
}
else if (JSVAL_IS_OBJECT(v))
{
if (!JS_VERSION_IS_ECMA(cx))
{
if (!OBJ_DEFAULT_VALUE(cx, JSVAL_TO_OBJECT(v), JSTYPE_BOOLEAN, &v))
return JS_FALSE;
if (!JSVAL_IS_BOOLEAN(v))
v = JSVAL_TRUE; /* non-null object is true */
b = JSVAL_TO_BOOLEAN(v);
}
else
{
b = JS_TRUE;
}
}
else if (JSVAL_IS_STRING(v))
{
b = JSSTRING_LENGTH(JSVAL_TO_STRING(v)) ? JS_TRUE : JS_FALSE;
}
else if (JSVAL_IS_INT(v))
{
b = JSVAL_TO_INT(v) ? JS_TRUE : JS_FALSE;
}
else if (JSVAL_IS_DOUBLE(v))
{
d = *JSVAL_TO_DOUBLE(v);
b = (!JSDOUBLE_IS_NaN(d) && d != 0) ? JS_TRUE : JS_FALSE;
}
else
{
JS_ASSERT(JSVAL_IS_BOOLEAN(v));
b = JSVAL_TO_BOOLEAN(v);
}
*bp = b;
return JS_TRUE;
}
开发者ID:nixz,项目名称:covise,代码行数:47,代码来源:jsbool.c
示例5: 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
示例6: Handle
NS_IMETHOD Handle(const nsAString& aName, const JS::Value& aResult)
{
if (JSVAL_IS_BOOLEAN(aResult)) {
bool isSharingEnabled = JSVAL_TO_BOOLEAN(aResult);
SetAutoMounterSharingMode(mVolumeName, isSharingEnabled);
}
return NS_OK;
}
开发者ID:Incognito,项目名称:mozilla-central,代码行数:8,代码来源:AutoMounterSetting.cpp
示例7: jsd_GetValueBoolean
JSBool
jsd_GetValueBoolean(JSDContext* jsdc, JSDValue* jsdval)
{
jsval val = jsdval->val;
if(!JSVAL_IS_BOOLEAN(val))
return JS_FALSE;
return JSVAL_TO_BOOLEAN(val);
}
开发者ID:moussa1,项目名称:mozilla-central,代码行数:8,代码来源:jsd_val.c
示例8: jsval_to_FBInfo
bool jsval_to_FBInfo(JSContext *cx, jsval v, StringMap* ret)
{
JSObject* tmp = JSVAL_TO_OBJECT(v);
if (!tmp) {
LOGD("jsval_to_TProductInfo: the jsval is not an object.");
return false;
}
JSObject* it = JS_NewPropertyIterator(cx, tmp);
while (true)
{
jsid idp;
jsval key;
if (! JS_NextProperty(cx, it, &idp) || ! JS_IdToValue(cx, idp, &key))
return false; // error
if (key == JSVAL_VOID)
break; // end of iteration
if (! JSVAL_IS_STRING(key))
continue; // ignore integer properties
JS::RootedValue value(cx);
JS_GetPropertyById(cx, tmp, idp, &value);
// if (! JSVAL_IS_STRING(value))
// continue; // ignore integer properties
if(JSVAL_IS_STRING(value))
{
JSStringWrapper strWrapper(JSVAL_TO_STRING(key), cx);
JSStringWrapper strWrapper2(JSVAL_TO_STRING(value), cx);
ret->insert(std::map<std::string, std::string>::value_type(strWrapper.get(), strWrapper2.get()));
}
else if(JSVAL_IS_NUMBER(value))
{
double number = 0.0;
JS::ToNumber(cx, value, &number);
std::stringstream ss;
ss << number;
JSStringWrapper strWrapper(JSVAL_TO_STRING(key), cx);
//JSStringWrapper strWrapper2(JSVAL_TO_STRING(value), cx);
ret->insert(std::map<std::string, std::string>::value_type(strWrapper.get(), ss.str()));
}
else if(JSVAL_IS_BOOLEAN(value))
{
bool boolVal = JS::ToBoolean(value);
JSStringWrapper strWrapper(JSVAL_TO_STRING(key), cx);
//JSStringWrapper strWrapper2(JSVAL_TO_STRING(value), cx);
std::string boolstring = boolVal ? "true" : "false";
ret->insert(std::map<std::string, std::string>::value_type(strWrapper.get(), boolstring));
}
}
return true;
}
开发者ID:TheWindShan,项目名称:HYFish,代码行数:58,代码来源:jsb_pluginx_basic_conversions.cpp
示例9: js_db_query
static JSBool
js_db_query(JSContext *cx, JSObject *obj, uintN argc,
jsval *argv, jsval *rval)
{
const char *query;
js_db_t *jd = JS_GetPrivate(cx, obj);
int rc;
if(js_db_check(cx, jd))
return JS_FALSE;
if(!JS_ConvertArguments(cx, argc, argv, "s", &query))
return JS_FALSE;
if(jd->jd_stmt) {
sqlite3_finalize(jd->jd_stmt);
jd->jd_stmt = NULL;
}
rc = db_prepare(jd->jd_db, &jd->jd_stmt, query);
if(rc != SQLITE_OK) {
if(jd->jd_transaction && rc == SQLITE_LOCKED) {
js_txn_deadlock(cx, jd);
return JS_FALSE;
}
*rval = JSVAL_FALSE;
return JS_TRUE;
}
sqlite3_stmt *stmt = jd->jd_stmt;
for(int i = 1; i < argc; i++) {
jsval v = argv[i];
if(JSVAL_IS_NULL(v) || JSVAL_IS_VOID(v)) {
sqlite3_bind_null(stmt, i);
} else if(JSVAL_IS_INT(v)) {
sqlite3_bind_int(stmt, i, JSVAL_TO_INT(v));
} else if(JSVAL_IS_BOOLEAN(v)) {
sqlite3_bind_int(stmt, i, JSVAL_TO_BOOLEAN(v));
} else if(JSVAL_IS_DOUBLE(v)) {
double d;
if(JS_ValueToNumber(cx, v, &d))
sqlite3_bind_double(stmt, i, d);
} else if(JSVAL_IS_STRING(v)) {
JSString *s = JS_ValueToString(cx, v);
sqlite3_bind_text(stmt, i, JS_GetStringBytes(s), -1, SQLITE_STATIC);
} else {
JS_ReportError(cx, "Unable to bind argument %d, invalid type", i);
sqlite3_finalize(stmt);
return JS_FALSE;
}
}
*rval = JSVAL_TRUE;
return js_stmt_step(cx, jd, rval);
}
开发者ID:Bibamaru,项目名称:showtime,代码行数:57,代码来源:js_db.c
示例10: assert
bool TraceMonkeyValue::getBool()
{
assert(isValid());
Logging::log(Logging::DEBUG, "TraceMonkeyValue::getBool: \r\n"); printJSVAL(value);
assert(JSVAL_IS_BOOLEAN(value));
return JSVAL_TO_BOOLEAN(value);
}
开发者ID:Amplifying,项目名称:intensityengine,代码行数:9,代码来源:script_engine_tracemonkey.cpp
示例11: WARN_IF_NOT
template<> bool ScriptInterface::FromJSVal<bool>(JSContext* cx, jsval v, bool& out)
{
JSBool ret;
WARN_IF_NOT(JSVAL_IS_BOOLEAN(v), v);
if (!JS_ValueToBoolean(cx, v, &ret))
return false;
out = (ret ? true : false);
return true;
}
开发者ID:Valvador,项目名称:PyroSpaceFork,代码行数:9,代码来源:ScriptConversions.cpp
示例12: ccTouchBegan
bool ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent) {
CC_UNUSED_PARAM(pTouch);
CC_UNUSED_PARAM(pEvent);
jsval retval;
ScriptingCore::getInstance()->executeCustomTouchEvent(CCTOUCHBEGAN,
pTouch, _mObj, retval);
if(JSVAL_IS_BOOLEAN(retval)) {
return JSVAL_TO_BOOLEAN(retval);
} return false;
};
开发者ID:nicolasgramlich,项目名称:cxx-generator,代码行数:10,代码来源:cocos2d_specifics.hpp
示例13: jsval_to_boolean
SEXP
jsval_to_boolean(SEXP ptr)
{
jsval *p = R_ExternalPtrAddr(ptr);
if(!JSVAL_IS_BOOLEAN(*p)) {
PROBLEM "jsval is not a boolean!"
ERROR;
}
return(ScalarLogical(JSVAL_TO_BOOLEAN(*p)));
}
开发者ID:omegahat,项目名称:SpiderMonkey,代码行数:10,代码来源:jsval.c
示例14: printf
/* void printArgTypes (); */
NS_IMETHODIMP
xpctestEcho::PrintArgTypes(void)
{
GET_CALL_CONTEXT;
if(NS_FAILED(rv) || !cc)
return NS_ERROR_FAILURE;
nsCOMPtr<nsISupports> callee;
if(NS_FAILED(cc->GetCallee(getter_AddRefs(callee))) ||
callee != static_cast<nsIEcho*>(this))
return NS_ERROR_FAILURE;
PRUint32 argc;
if(NS_SUCCEEDED(cc->GetArgc(&argc)))
printf("argc = %d ", (int)argc);
else
return NS_ERROR_FAILURE;
jsval* argv;
if(NS_FAILED(cc->GetArgvPtr(&argv)))
return NS_ERROR_FAILURE;
printf("argv types = [");
for(PRUint32 i = 0; i < argc; i++)
{
const char* type = "<unknown>";
if(JSVAL_IS_OBJECT(argv[i]))
{
if(JSVAL_IS_NULL(argv[i]))
type = "null";
else
type = "object";
}
else if (JSVAL_IS_BOOLEAN(argv[i]))
type = "boolean";
else if (JSVAL_IS_STRING(argv[i]))
type = "string";
else if (JSVAL_IS_DOUBLE(argv[i]))
type = "double";
else if (JSVAL_IS_INT(argv[i]))
type = "int";
else if (JSVAL_IS_VOID(argv[i]))
type = "void";
fputs(type, stdout);
if(i < argc-1)
printf(", ");
}
printf("]\n");
return NS_OK;
}
开发者ID:LittleForker,项目名称:mozilla-central,代码行数:55,代码来源:xpctest_echo.cpp
示例15: _modulesInstalled
static void _modulesInstalled(SG_context *pCtx, JSContext *cx, JSObject *glob, SG_bool *installed)
{
jsval jv = JSVAL_VOID;
SG_UNUSED(pCtx);
*installed = SG_FALSE;
if (JS_GetProperty(cx, glob, "vvModulesInstalled", &jv) && JSVAL_IS_BOOLEAN(jv))
{
*installed = JSVAL_TO_BOOLEAN(jv);
}
}
开发者ID:refaqtor,项目名称:sourcegear_veracity_clone,代码行数:13,代码来源:sg_jscore.c
示例16: debug_protocol_hdlr
static JSBool debug_protocol_hdlr(JSContext *cx, JSObject *obj, jsval *vp)
{
/* Check if debugProtocol was assigned a boolean value */
if (!JSVAL_IS_BOOLEAN(*vp))
return JS_FALSE;
if (JSVAL_TO_BOOLEAN(*vp) == JS_TRUE)
config.smtp_debug = 1;
else
config.smtp_debug = 0;
return JS_TRUE;
}
开发者ID:mindbit,项目名称:mailfilter,代码行数:13,代码来源:js_sys.c
示例17: setSuccess
JSBool setSuccess(JSContext *cx, JSObject *obj, uintN argc,
jsval *argv, jsval *rval)
{// begin setSuccess
bool Jscript_succeed = false;
// default return value
if(argc != 1)
return JS_FALSE;
if(JSVAL_IS_BOOLEAN(argv[0]) == false)
return JS_FALSE;
Jscript_succeed = JSVAL_TO_BOOLEAN(argv[0]);
JS_setSuccess(Jscript_succeed);
return JS_TRUE;
}// end setSuccess
开发者ID:BackupTheBerlios,项目名称:avidemux-svn,代码行数:14,代码来源:ADM_JSFunctions.cpp
示例18: JSFUNC_setPaused
JSBool ofxJSSoundPlayer::JSFUNC_setPaused(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
ofxJSSoundPlayer *p = (ofxJSSoundPlayer*)JS_GetPrivate(cx, obj);
if (argc < 1) return JS_FALSE;
if (argc == 1) {
/* Function: void setPaused(bool bP) */
if (JSVAL_IS_BOOLEAN(argv[0])) {
p->setPaused(__JSVal_TO_bool(argv[0]));
return JS_TRUE;
}
}
return JS_FALSE;
}
开发者ID:naotokui,项目名称:ofxJavascript,代码行数:14,代码来源:ofxJSSoundPlayer.cpp
示例19: unit_setProperty
INT unit_setProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
{
CDebug cDbg("unit setProperty");
switch(JSVAL_TO_INT(id))
{
case ME_CHICKENHP:
if(JSVAL_IS_INT(*vp))
Vars.nChickenHP = JSVAL_TO_INT(*vp);
break;
case ME_CHICKENMP:
if(JSVAL_IS_INT(*vp))
Vars.nChickenMP = JSVAL_TO_INT(*vp);
break;
case ME_QUITONHOSTILE:
if(JSVAL_IS_BOOLEAN(*vp))
Vars.bQuitOnHostile = JSVAL_TO_BOOLEAN(*vp);
break;
case OOG_QUITONERROR:
if(JSVAL_IS_BOOLEAN(*vp))
Vars.bQuitOnError = JSVAL_TO_BOOLEAN(*vp);
break;
case OOG_MAXGAMETIME:
if(JSVAL_IS_INT(*vp))
Vars.dwMaxGameTime = JSVAL_TO_INT(*vp);
break;
case ME_BLOCKKEYS:
if(JSVAL_IS_BOOLEAN(*vp))
Vars.bBlockKeys = JSVAL_TO_BOOLEAN(*vp);
break;
case ME_BLOCKMOUSE:
if(JSVAL_IS_BOOLEAN(*vp))
Vars.bBlockMouse = JSVAL_TO_BOOLEAN(*vp);
break;
}
return JS_TRUE;
}
开发者ID:ds-hwang,项目名称:d2bs,代码行数:37,代码来源:JSUnit.cpp
示例20: js_to_R
SEXP
js_to_R(SEXP ptr)
{
jsval *p = R_ExternalPtrAddr(ptr);
if(JSVAL_IS_INT(*p))
return(ScalarInteger(JSVAL_TO_INT(*p)));
else if(JSVAL_IS_BOOLEAN(*p))
return(ScalarLogical(JSVAL_TO_BOOLEAN(*p)));
else if(JSVAL_IS_DOUBLE(*p))
return(ScalarReal( * JSVAL_TO_DOUBLE(*p)));
else if(JSVAL_IS_STRING(*p)) {
return(jsval_to_string(ptr));
} else
return(R_NilValue);
}
开发者ID:omegahat,项目名称:SpiderMonkey,代码行数:15,代码来源:jsval.c
注:本文中的JSVAL_IS_BOOLEAN函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论