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


C++ JSValueToBoolean函数代码示例

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


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


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