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

C++ JSValueToBoolean函数代码示例

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

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



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

示例1: setCustomPolicyDelegateCallback

static JSValueRef setCustomPolicyDelegateCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
{
    // Has mac implementation
    if (argumentCount < 1)
        return JSValueMakeUndefined(context);

    bool permissive = false;
    if (argumentCount >= 2)
        permissive = JSValueToBoolean(context, arguments[1]);

    LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
    controller->setCustomPolicyDelegate(JSValueToBoolean(context, arguments[0]), permissive);

    return JSValueMakeUndefined(context);
}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:15,代码来源:LayoutTestController.cpp


示例2: HyperloopJSValueIsArray

/*
 * Tests whether a JavaScript value is an array object
 * 
 * This invokes Array.isArray(value) and returns its result
 */
EXPORTAPI bool HyperloopJSValueIsArray(JSContextRef ctx, JSValueRef value) 
{
    if (JSValueIsObject(ctx, value)) 
    {
        JSObjectRef global = JSContextGetGlobalObject(ctx);
        JSValueRef exception = JSValueMakeNull(ctx);
        JSStringRef string = JSStringCreateWithUTF8CString("Array");
        JSObjectRef array = JSValueToObject(ctx, JSObjectGetProperty(ctx, global, string, &exception), &exception);
        JSStringRelease(string);
        if (!JSValueIsNull(ctx, exception)) 
        {
            return false;
        }

        string = JSStringCreateWithUTF8CString("isArray");
        JSObjectRef isArray = JSValueToObject(ctx, JSObjectGetProperty(ctx, array, string, &exception), &exception);
        JSStringRelease(string);
        if (!JSValueIsNull(ctx, exception))
        {
            return false;
        }

        JSValueRef result = JSObjectCallAsFunction(ctx, isArray, global, 1, &value, &exception);

        if (JSValueIsNull(ctx, exception) && JSValueIsBoolean(ctx, result)) 
        {
            return JSValueToBoolean(ctx, result);
        }
    }
    return false;
}
开发者ID:Sophrinix,项目名称:hyperloop-common,代码行数:36,代码来源:hyperloop.cpp


示例3: assertEqualsAsBoolean

static void assertEqualsAsBoolean(JSValueRef value, bool expectedValue)
{
    if (JSValueToBoolean(context, value) != expectedValue) {
        fprintf(stderr, "assertEqualsAsBoolean failed: %p, %d\n", value, expectedValue);
        failed = 1;
    }
}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:7,代码来源:testapi.c


示例4: enableEnhancedAccessibilityCallback

static JSValueRef enableEnhancedAccessibilityCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
{
    AccessibilityController* controller = static_cast<AccessibilityController*>(JSObjectGetPrivate(thisObject));
    if (argumentCount == 1)
        controller->enableEnhancedAccessibility(JSValueToBoolean(context, arguments[0]));
    return JSValueMakeUndefined(context);
}
开发者ID:Wrichik1999,项目名称:webkit,代码行数:7,代码来源:AccessibilityController.cpp


示例5: MakeObjectForJava_android_view_View

JNIEXPORT jboolean JNICALL
Java_com_appcelerator_hyperloop_ViewOnTouchListener_NativeOnTouch
(JNIEnv *env, jobject thiz, jlong jsContextRef, jlong thisObjectRef, jlong onTouchFuncRef, jobject view, jobject event)
{
    JSContextRef ctx = (JSContextRef)jsContextRef;
    JSObjectRef onTouchFunc = (JSObjectRef)onTouchFuncRef;
    JSObjectRef thisObject = (JSObjectRef)thisObjectRef;
    
    JSValueRef argv[2];
    argv[0] = MakeObjectForJava_android_view_View(ctx, view);
    argv[1] = MakeObjectForJava_android_view_MotionEvent(ctx, event);

    if (JSObjectIsFunction(ctx, onTouchFunc)) {
        JSValueRef exception = JSValueMakeNull(ctx);
        JSValueRef result = JSObjectCallAsFunction(ctx, onTouchFunc, thisObject, 2, argv, &exception);
        if (!JSValueIsNull(ctx, exception)) {
            JSStringRef string = JSValueToStringCopy(ctx, exception, NULL);
            CCHAR_FROM_JSSTRINGREF(string, cstring);
            LOGD("Java_com_appcelerator_hyperloop_ViewOnTouchListener_NativeOnTouch '%s'", cstring);
            free(cstring);
            JSStringRelease(string);
        }
        return JSValueToBoolean(ctx, result) ? JNI_TRUE : JNI_FALSE;
    }
    return JNI_FALSE;
}
开发者ID:appcelerator-forks,项目名称:appcelerator.hyperloop,代码行数:26,代码来源:HyperloopJNIExport.c


示例6: setSelectTrailingWhitespaceEnabledCallback

static JSValueRef setSelectTrailingWhitespaceEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
{
    if (argumentCount < 1)
        return JSValueMakeUndefined(context);

    LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
    controller->setSelectTrailingWhitespaceEnabled(JSValueToBoolean(context, arguments[0]));
    return JSValueMakeUndefined(context);
}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:9,代码来源:LayoutTestController.cpp


示例7: setCloseRemainingWindowsWhenCompleteCallback

static JSValueRef setCloseRemainingWindowsWhenCompleteCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
{
    if (argumentCount < 1)
        return JSValueMakeUndefined(context);

    LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
    controller->setCloseRemainingWindowsWhenComplete(JSValueToBoolean(context, arguments[0]));
    return JSValueMakeUndefined(context);
}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:9,代码来源:LayoutTestController.cpp


示例8: showChildApplicationsCallback

static JSValueRef showChildApplicationsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
{
    if (argumentCount < 1)
        return JSValueMakeUndefined(context);

    ApplicationTestController* controller = static_cast<ApplicationTestController*>(JSObjectGetPrivate(thisObject));
    controller->setShowChildApplications(JSValueToBoolean(context, arguments[0]));

    return JSValueMakeUndefined(context);
}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:10,代码来源:ApplicationTestController.cpp


示例9: webkit_javascript_result_get_global_context

bool WebViewTest::javascriptResultToBoolean(WebKitJavascriptResult* javascriptResult)
{
    JSGlobalContextRef context = webkit_javascript_result_get_global_context(javascriptResult);
    g_assert(context);
    JSValueRef value = webkit_javascript_result_get_value(javascriptResult);
    g_assert(value);
    g_assert(JSValueIsBoolean(context, value));

    return JSValueToBoolean(context, value);
}
开发者ID:Happy-Ferret,项目名称:webkit.js,代码行数:10,代码来源:WebViewTest.cpp


示例10: collectOnAlternateThreadCallback

static JSValueRef collectOnAlternateThreadCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
{
    bool waitUntilDone = false;
    if (argumentCount > 0)
        waitUntilDone = JSValueToBoolean(context, arguments[0]);

    GCController* controller = static_cast<GCController*>(JSObjectGetPrivate(thisObject));
    controller->collectOnAlternateThread(waitUntilDone);

    return JSValueMakeUndefined(context);
}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:11,代码来源:GCController.cpp


示例11: setUseDashboardCompatibilityModeCallback

static JSValueRef setUseDashboardCompatibilityModeCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
{
    // Has mac implementation
    if (argumentCount < 1)
        return JSValueMakeUndefined(context);

    LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
    controller->setUseDashboardCompatibilityMode(JSValueToBoolean(context, arguments[0]));

    return JSValueMakeUndefined(context);
}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:11,代码来源:LayoutTestController.cpp


示例12: setPopupBlockingEnabledCallback

static JSValueRef setPopupBlockingEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
{
    // Has mac & windows implementation
    if (argumentCount < 1)
        return JSValueMakeUndefined(context);

    LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
    controller->setPopupBlockingEnabled(JSValueToBoolean(context, arguments[0]));

    return JSValueMakeUndefined(context);
}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:11,代码来源:LayoutTestController.cpp


示例13: NATIVE

NATIVE(JSValue,jboolean,toBoolean) (PARAMS, jlong ctx, jlong valueRef)
{
	JSContextWrapper *wrapper = (JSContextWrapper *)ctx;
	struct msg_t { JSContextRef ctx; JSValueRef valueRef; bool ret; };
	msg_t msg = { wrapper->context, (JSValueRef)valueRef, false };
	wrapper->worker_q->sync([](void *msg) {
		msg_t *m = (msg_t *)msg;
		m->ret = JSValueToBoolean(m->ctx, m->valueRef);
	},&msg);
	return msg.ret;
}
开发者ID:ericwlange,项目名称:webkit,代码行数:11,代码来源:JSValue.cpp


示例14: IsArray

bool IsArray(JSObjectRef obj)
{
    if (g_fnxIsArray == NULL)
    {
        JSStringRef fnScript = JSStringCreateWithUTF8CString("return arguments[0] instanceof Array");
        g_fnxIsArray = JSObjectMakeFunction(g_ctx, NULL, 0, NULL, fnScript, NULL, 0, NULL);
        JSValueProtect(g_ctx, g_fnxIsArray);
        JSStringRelease(fnScript);
    }

    JSValueRef isArray = JSObjectCallAsFunction(g_ctx, g_fnxIsArray, NULL, 1, (JSValueRef*) &obj, NULL);
    return JSValueToBoolean(g_ctx, isArray);
}
开发者ID:vnmc,项目名称:zephyros,代码行数:13,代码来源:jsbridge_webview.cpp


示例15: EJ_BIND_FUNCTION

 EJ_BIND_FUNCTION(EJBindingCanvas, arc, ctx, argc, argv ) {
 	if( argc < 5 ) { return NULL; }
	
 	float
 		x = JSValueToNumberFast(ctx, argv[0]),
 		y = JSValueToNumberFast(ctx, argv[1]),
 		radius = JSValueToNumberFast(ctx, argv[2]),
 		startAngle = JSValueToNumberFast(ctx, argv[3]),
 		endAngle = JSValueToNumberFast(ctx, argv[4]);
 	BOOL antiClockwise = argc < 6 ? false : JSValueToBoolean(ctx, argv[5]);
 	renderingContext->arc(x,y,radius,startAngle,endAngle ,antiClockwise);
 	return NULL;
 }
开发者ID:YaakovDavis,项目名称:Ejecta-X,代码行数:13,代码来源:EJBindingCanvas.cpp


示例16: JSStringCreateWithUTF8CString

template<> std::string RJSAccessor::to_binary(JSContextRef ctx, JSValueRef &val) {
    static JSStringRef arrayBufferString = JSStringCreateWithUTF8CString("ArrayBuffer");
    static JSStringRef bufferString = JSStringCreateWithUTF8CString("buffer");
    static JSStringRef byteLengthString = JSStringCreateWithUTF8CString("byteLength");
    static JSStringRef byteOffsetString = JSStringCreateWithUTF8CString("byteOffset");
    static JSStringRef isViewString = JSStringCreateWithUTF8CString("isView");
    static JSStringRef uint8ArrayString = JSStringCreateWithUTF8CString("Uint8Array");

    JSObjectRef arrayBufferConstructor = RJSValidatedObjectProperty(ctx, JSContextGetGlobalObject(ctx), arrayBufferString);
    JSObjectRef uint8ArrayContructor = RJSValidatedObjectProperty(ctx, JSContextGetGlobalObject(ctx), uint8ArrayString);
    JSValueRef uint8ArrayArguments[3];
    size_t uint8ArrayArgumentsCount = 0;

    // Value should either be an ArrayBuffer or ArrayBufferView (i.e. TypedArray or DataView).
    if (JSValueIsInstanceOfConstructor(ctx, val, arrayBufferConstructor, NULL)) {
        uint8ArrayArguments[0] = val;
        uint8ArrayArgumentsCount = 1;
    }
    else if (JSObjectRef object = JSValueToObject(ctx, val, NULL)) {
        // Check if value is an ArrayBufferView by calling ArrayBuffer.isView(val).
        JSObjectRef isViewMethod = RJSValidatedObjectProperty(ctx, arrayBufferConstructor, isViewString);
        JSValueRef isView = JSObjectCallAsFunction(ctx, isViewMethod, arrayBufferConstructor, 1, &val, NULL);

        if (isView && JSValueToBoolean(ctx, isView)) {
            uint8ArrayArguments[0] = RJSValidatedObjectProperty(ctx, object, bufferString);
            uint8ArrayArguments[1] = RJSValidatedPropertyValue(ctx, object, byteOffsetString);
            uint8ArrayArguments[2] = RJSValidatedPropertyValue(ctx, object, byteLengthString);
            uint8ArrayArgumentsCount = 3;
        }
    }

    if (!uint8ArrayArgumentsCount) {
        throw std::runtime_error("Can only convert ArrayBuffer and TypedArray objects to binary");
    }

    JSValueRef exception = NULL;
    JSObjectRef uint8Array = JSObjectCallAsConstructor(ctx, uint8ArrayContructor, uint8ArrayArgumentsCount, uint8ArrayArguments, &exception);
    if (exception) {
        throw RJSException(ctx, exception);
    }

    size_t byteCount = RJSValidatedListLength(ctx, uint8Array);
    std::string bytes(byteCount, 0);

    for (size_t i = 0; i < byteCount; i++) {
        JSValueRef byteValue = JSObjectGetPropertyAtIndex(ctx, uint8Array, (unsigned)i, NULL);
        bytes[i] = JSValueToNumber(ctx, byteValue, NULL);
    }

    return bytes;
}
开发者ID:Aneeskhan,项目名称:realm-js,代码行数:51,代码来源:js_object.cpp


示例17: EvilExceptionObject_hasInstance

static bool EvilExceptionObject_hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleValue, JSValueRef* exception)
{
    UNUSED_PARAM(context);
    UNUSED_PARAM(constructor);
    
    JSStringRef hasInstanceName = JSStringCreateWithUTF8CString("hasInstance");
    JSValueRef hasInstance = JSObjectGetProperty(context, constructor, hasInstanceName, exception);
    JSStringRelease(hasInstanceName);
    if (!hasInstance)
        return false;
    JSObjectRef function = JSValueToObject(context, hasInstance, exception);
    JSValueRef result = JSObjectCallAsFunction(context, function, constructor, 1, &possibleValue, exception);
    return result && JSValueToBoolean(context, result);
}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:14,代码来源:testapi.c


示例18: console_setSharedBool

static bool console_setSharedBool(JSContextRef ctx, JSObjectRef thisObject, JSStringRef /*propertyName*/, JSValueRef value, JSValueRef* /*exception*/)
{
    if (!JSValueIsBoolean(ctx, value))
        return false;

    CallJSDlg* dlg = static_cast<CallJSDlg*>(JSObjectGetPrivate(thisObject));
    if (!dlg)
        return false;

    bool temp = JSValueToBoolean (ctx, value);
    dlg->setSharedBool(temp);

    return true;
}
开发者ID:Omgan,项目名称:CallJS,代码行数:14,代码来源:JSBindings.cpp


示例19: HyperloopLogger

/**
 * internal
 * 
 * implementation of console.log 
 */
static JSValueRef HyperloopLogger (JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
{
    if (argumentCount>0) 
    {
        std::ostringstream stream;
        for (size_t c=0;c<argumentCount;c++)
        {
            if (JSValueIsObject(ctx,arguments[c]) || JSValueIsString(ctx,arguments[c])) 
            {
                std::string str(HyperloopJSValueToStringCopy(ctx,arguments[c],exception));
                stream << str;
            }
            else if (JSValueIsNumber(ctx,arguments[c]))
            {
                double num = JSValueToNumber(ctx,arguments[c],exception);
                double intpart;
                if (modf(num, &intpart) == 0.0)
                {
                    stream << intpart;
                }
                else 
                {
                    stream << num;
                }
            }
            else if (JSValueIsBoolean(ctx,arguments[c]))
            {
                bool b = JSValueToBoolean(ctx,arguments[c]);
                stream << (b ? "true":"false");
            }
            else if (JSValueIsNull(ctx,arguments[c]))
            {
                stream << "null";
            }
            else if (JSValueIsUndefined(ctx,arguments[c]))
            {
                stream << "undefined";
            }
            if (c+1 < argumentCount) 
            {
                stream << " ";
            }
        }
        // call the platform adapter
        HyperloopNativeLogger(stream.str().c_str());
    }
    return JSValueMakeUndefined(ctx);
}
开发者ID:Sophrinix,项目名称:hyperloop-common,代码行数:53,代码来源:hyperloop.cpp


示例20: gumjs_proxy_has_property

static bool
gumjs_proxy_has_property (JSContextRef ctx,
                          JSObjectRef object,
                          JSStringRef property_name)
{
  GumJscProxy * self;
  GumJscCore * core;

  self = GUMJS_PROXY (object);
  if (self->has == NULL)
    return false;

  core = JSObjectGetPrivate (JSContextGetGlobalObject (ctx));

  {
    GumJscScope scope = GUM_JSC_SCOPE_INIT (core);
    JSValueRef * ex = &scope.exception;
    JSValueRef property_name_value, value;
    bool result = false;

    property_name_value = JSValueMakeString (ctx, property_name);
    value = JSObjectCallAsFunction (ctx, self->has, self->receiver,
        1, &property_name_value, ex);
    if (value == NULL)
      goto beach;

    if (!JSValueIsBoolean (ctx, value))
      goto invalid_result_type;

    result = JSValueToBoolean (ctx, value);

    goto beach;

invalid_result_type:
    {
      _gumjs_throw (ctx, ex, "expected has() to return a boolean");
      goto beach;
    }
beach:
    {
      _gum_jsc_scope_flush (&scope);
      return result;
    }
  }
}
开发者ID:terry2012,项目名称:frida-gum,代码行数:45,代码来源:gumjscpolyfill.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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