本文整理汇总了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);
}
示例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;
}
示例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;
}
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}