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


C++ JSValueMakeBoolean函数代码示例

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


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

示例1: Hyperloop_Binary_IsEqual

EXPORTAPI JSValueRef Hyperloop_Binary_IsEqual(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) {
    if (argumentCount < 2)
    {
        *exception = HyperloopMakeException(ctx, "Wrong arguments passed to IsEqual");
        return JSValueMakeUndefined(ctx);
    }

    auto isObject_a = JSValueIsObject(ctx, arguments[0]);
    auto isObject_b = JSValueIsObject(ctx, arguments[1]);

    if (isObject_a && isObject_b)
    {
        auto obj_a = HyperloopJSValueToVoidPointer(ctx, arguments[0], exception);
        auto obj_b = HyperloopJSValueToVoidPointer(ctx, arguments[1], exception);

        // nullptr means both objects are not a native object
        if (obj_a == nullptr && obj_b == nullptr) {
            return JSValueMakeBoolean(ctx, JSValueIsStrictEqual(ctx, arguments[0], arguments[1]));
        }

        return JSValueMakeBoolean(ctx, (obj_a == obj_b));
    }
    else if (!isObject_a && !isObject_b) {
        return JSValueMakeBoolean(ctx, JSValueIsStrictEqual(ctx, arguments[0], arguments[1]));
    }

    return JSValueMakeBoolean(ctx, false);
}
开发者ID:Sophrinix,项目名称:hyperloop-common,代码行数:28,代码来源:hyperloop.cpp

示例2: isMarkerRangeEqualCallback

static JSValueRef isMarkerRangeEqualCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
{
    if (argumentCount != 1)
        return JSValueMakeBoolean(context, false);
    
    JSObjectRef otherMarker = JSValueToObject(context, arguments[0], exception);
    return JSValueMakeBoolean(context, toTextMarkerRange(thisObject)->isEqual(toTextMarkerRange(otherMarker)));
}
开发者ID:SchleunigerAG,项目名称:WinEC7_Qt5.3.1_Fixes,代码行数:8,代码来源:AccessibilityTextMarker.cpp

示例3: addNotificationListenerCallback

static JSValueRef addNotificationListenerCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
{
    if (argumentCount != 1)
        return JSValueMakeBoolean(context, false);
    
    JSObjectRef callback = JSValueToObject(context, arguments[0], exception);
    bool succeeded = toAXElement(thisObject)->addNotificationListener(callback);
    return JSValueMakeBoolean(context, succeeded);
}
开发者ID:mikezit,项目名称:Webkit_Code,代码行数:9,代码来源:AccessibilityUIElement.cpp

示例4: ASSERT_ARG

JSObjectRef InspectorController::addScriptResource(InspectorResource* resource)
{
    ASSERT_ARG(resource, resource);

    // This happens for pages loaded from the back/forward cache.
    if (resource->scriptObject)
        return resource->scriptObject;

    ASSERT(m_scriptContext);
    ASSERT(m_scriptObject);
    if (!m_scriptContext || !m_scriptObject)
        return 0;

    JSStringRef resourceString = JSStringCreateWithUTF8CString("Resource");
    JSObjectRef resourceConstructor = JSValueToObject(m_scriptContext, JSObjectGetProperty(m_scriptContext, m_scriptObject, resourceString, 0), 0);
    JSStringRelease(resourceString);

    String urlString = resource->requestURL.url();
    JSStringRef url = JSStringCreateWithCharacters(urlString.characters(), urlString.length());
    JSValueRef urlValue = JSValueMakeString(m_scriptContext, url);
    JSStringRelease(url);

    urlString = resource->requestURL.host();
    JSStringRef domain = JSStringCreateWithCharacters(urlString.characters(), urlString.length());
    JSValueRef domainValue = JSValueMakeString(m_scriptContext, domain);
    JSStringRelease(domain);

    urlString = resource->requestURL.path();
    JSStringRef path = JSStringCreateWithCharacters(urlString.characters(), urlString.length());
    JSValueRef pathValue = JSValueMakeString(m_scriptContext, path);
    JSStringRelease(path);

    urlString = resource->requestURL.lastPathComponent();
    JSStringRef lastPathComponent = JSStringCreateWithCharacters(urlString.characters(), urlString.length());
    JSValueRef lastPathComponentValue = JSValueMakeString(m_scriptContext, lastPathComponent);
    JSStringRelease(lastPathComponent);

    JSValueRef identifier = JSValueMakeNumber(m_scriptContext, resource->identifier);
    JSValueRef mainResource = JSValueMakeBoolean(m_scriptContext, m_mainResource == resource);
    JSValueRef cached = JSValueMakeBoolean(m_scriptContext, resource->cached);

    JSValueRef arguments[] = { scriptObjectForRequest(m_scriptContext, resource), urlValue, domainValue, pathValue, lastPathComponentValue, identifier, mainResource, cached };
    JSObjectRef result = JSObjectCallAsConstructor(m_scriptContext, resourceConstructor, 8, arguments, 0);

    resource->setScriptObject(m_scriptContext, result);

    ASSERT(result);

    JSStringRef addResourceString = JSStringCreateWithUTF8CString("addResource");
    JSObjectRef addResourceFunction = JSValueToObject(m_scriptContext, JSObjectGetProperty(m_scriptContext, m_scriptObject, addResourceString, 0), 0);
    JSStringRelease(addResourceString);

    JSValueRef addArguments[] = { result };
    JSObjectCallAsFunction(m_scriptContext, addResourceFunction, m_scriptObject, 1, addArguments, 0);

    return result;
}
开发者ID:FilipBE,项目名称:qtextended,代码行数:57,代码来源:InspectorController.cpp

示例5: getIsValidCallback

static JSValueRef getIsValidCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
{
    AccessibilityUIElement* uiElement = toAXElement(thisObject);
    if (!uiElement->platformUIElement())
        return JSValueMakeBoolean(context, false);
    
    // There might be other platform logic that one could check here...
    
    return JSValueMakeBoolean(context, true);
}
开发者ID:mikezit,项目名称:Webkit_Code,代码行数:10,代码来源:AccessibilityUIElement.cpp

示例6: addNotificationListenerCallback

static JSValueRef addNotificationListenerCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
{
    if (argumentCount != 1)
        return JSValueMakeBoolean(context, false);

    AccessibilityController* controller = static_cast<AccessibilityController*>(JSObjectGetPrivate(thisObject));
    JSObjectRef callback = JSValueToObject(context, arguments[0], exception);
    bool succeeded = controller->addNotificationListener(callback);
    return JSValueMakeBoolean(context, succeeded);
}
开发者ID:Wrichik1999,项目名称:webkit,代码行数:10,代码来源:AccessibilityController.cpp

示例7: isEqualCallback

static JSValueRef isEqualCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
{
    JSObjectRef otherElement = 0;
    if (argumentCount == 1)
        otherElement = JSValueToObject(context, arguments[0], exception);
    else
        return JSValueMakeBoolean(context, false);
    
    return JSValueMakeBoolean(context, toAXElement(thisObject)->isEqual(toAXElement(otherElement)));
}
开发者ID:mikezit,项目名称:Webkit_Code,代码行数:10,代码来源:AccessibilityUIElement.cpp

示例8: main

int
main()
{
    JSContextRef ctx = JSGlobalContextCreate(NULL);
    JSValueRef jsvalue;
    JSObjectRef jsobject2;
    JSObjectRef jsobject3;
    JSValueRef jsvalue4;
    jsvalue = JSValueMakeNumber(ctx, 0.123456711111111111);
    print_js(ctx, jsvalue);
    jsvalue = JSValueMakeBoolean(ctx, 1);
    print_js(ctx, jsvalue);
    jsvalue = JSValueMakeBoolean(ctx, 0);
    print_js(ctx, jsvalue);
    jsvalue = JSValueMakeNull(ctx);
    print_js(ctx, jsvalue);
    jsvalue = JSValueMakeUndefined(ctx);
    /* JSObjectIsFunction(ctx, jsvalue); //segmentation fault */
    print_js(ctx, jsvalue);
    jsvalue = JSObjectMakeError(ctx, 0, NULL, NULL);
    printf("%lx\n", (unsigned long)jsvalue);
    printf("%lx\n", (unsigned long)(jsvalue =
                                    JSValueToObject(ctx, jsvalue, NULL)));
    printf("%lx\n", (unsigned long)(jsvalue =
                                    JSValueToObject(ctx, jsvalue, NULL)));
    print_js(ctx, jsvalue);
    jsvalue = JSObjectMake(ctx, NULL, NULL);
    print_js(ctx, jsvalue);
    jsobject2 = (JSObjectRef)get_property(ctx, jsvalue, "toString");
    print_js(ctx, jsobject2);
    jsobject3 = JSObjectMakeError(ctx, 0, NULL, NULL);
    /* jsobject3 = JSValueMakeBoolean(ctx, 0); */
    /* jsobject3 = JSValueMakeNull(ctx); */
    /* jsobject3 = JSValueMakeNumber(ctx, 0.123134123); */
    /* jsobject3 = JSValueMakeUndefined(ctx); */
    jsvalue4 = JSObjectCallAsFunction(ctx, jsobject2, jsobject3, 0, NULL, NULL);
    print_js(ctx, jsvalue4);
    printf("test_function\n");
    //test_function(ctx, jsobject3);

    JSStringRef jsstr;
    jsstr = JSStringCreateWithUTF8CString("abcdef");
    jsvalue = JSValueMakeString(ctx, jsstr);
    JSStringRelease(jsstr);
    printf("%lx\n", (unsigned long)jsvalue);
    print_js(ctx, jsvalue);
    printf("%lx\n", (unsigned long)JSValueToObject(ctx, jsvalue, NULL));
    print_js(ctx, JSValueToObject(ctx, jsvalue, NULL));
    JSObjectCopyPropertyNames(ctx, (JSObjectRef)jsvalue);
    return 0;
}
开发者ID:yuyichao,项目名称:explore,代码行数:51,代码来源:main.c

示例9: JSFeature_getProperty

static JSValueRef JSFeature_getProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception)
{
    osgEarth::Features::Feature *feature = static_cast<osgEarth::Features::Feature*>(JSObjectGetPrivate(object));

    char* attrBuf = JSUtils::JSStringRef_to_CharArray(propertyName);
    if (attrBuf)
    {
        std::string attr(attrBuf);
        delete [] attrBuf;
        
        if (attr == "attributes" || attr == "attrs")
        {
            return object;
        }
        
        osgEarth::Features::AttributeTable::const_iterator it = feature->getAttrs().find(attr);
        if (it != feature->getAttrs().end())
        {
            osgEarth::Features::AttributeType atype = (*it).second.first;
            switch (atype)
            {
                case osgEarth::Features::ATTRTYPE_BOOL:
                    return JSValueMakeBoolean(ctx, (*it).second.getBool());
                case osgEarth::Features::ATTRTYPE_DOUBLE:
                    return JSValueMakeNumber(ctx, (*it).second.getDouble());
                case osgEarth::Features::ATTRTYPE_INT:
                    return JSValueMakeNumber(ctx, (*it).second.getInt());
                default:
                    return JSValueMakeString(ctx, JSStringCreateWithUTF8CString((*it).second.getString().c_str()));
            }
        }
    }

    return JSValueMakeNull(ctx);
}
开发者ID:2php,项目名称:osgearth,代码行数:35,代码来源:JSWrappers.cpp

示例10: get_in_authentication_cb

static JSValueRef
get_in_authentication_cb(JSContextRef context,
						 JSObjectRef thisObject,
						 JSStringRef propertyName,
						 JSValueRef *exception) {
	return JSValueMakeBoolean(context, lightdm_greeter_get_in_authentication(GREETER));
}
开发者ID:sbalneav,项目名称:lightdm-webkit2-greeter,代码行数:7,代码来源:lightdm-webkit2-greeter-ext.c

示例11: get_user_logged_in_cb

static JSValueRef
get_user_logged_in_cb(JSContextRef context,
					  JSObjectRef thisObject,
					  JSStringRef propertyName,
					  JSValueRef *exception) {
	return JSValueMakeBoolean(context, lightdm_user_get_logged_in(USER));
}
开发者ID:sbalneav,项目名称:lightdm-webkit2-greeter,代码行数:7,代码来源:lightdm-webkit2-greeter-ext.c

示例12: get_select_guest_cb

static JSValueRef
get_select_guest_cb(JSContextRef context,
					JSObjectRef thisObject,
					JSStringRef propertyName,
					JSValueRef *exception) {
	return JSValueMakeBoolean(context, lightdm_greeter_get_select_guest_hint(GREETER));
}
开发者ID:sbalneav,项目名称:lightdm-webkit2-greeter,代码行数:7,代码来源:lightdm-webkit2-greeter-ext.c

示例13: start_session_sync_cb

static JSValueRef
start_session_sync_cb(JSContextRef context,
					  JSObjectRef function,
					  JSObjectRef thisObject,
					  size_t argumentCount,
					  const JSValueRef arguments[],
					  JSValueRef *exception) {

	gchar *session = NULL;
	gboolean result;
	GError *err = NULL;

	/* FIXME: old API required lightdm.login(username, session), but the username
	 * is never actually used.  At some point, deprecate the old usage.  For now,
	 * simply work around it.
	 */
	if (argumentCount == 1) {
		session = arg_to_string(context, arguments[0], exception);
	} else if (argumentCount == 2) {
		session = arg_to_string(context, arguments[1], exception);
	}

	result = lightdm_greeter_start_session_sync(GREETER, session, &err);
	g_free(session);

	if (err != NULL) {
		_mkexception(context, exception, err->message);
		g_error_free(err);
	}

	return JSValueMakeBoolean(context, result);
}
开发者ID:sbalneav,项目名称:lightdm-webkit2-greeter,代码行数:32,代码来源:lightdm-webkit2-greeter-ext.c

示例14: toBoolForJSBuffer

/**
 * toBool
 */
JSValueRef toBoolForJSBuffer (JSContextRef ctx, JSObjectRef function, JSObjectRef object, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
{
    BUFFER(buffer);
    PRIMITIVE_GET_ARRAY(bool);
    GET_NUMBER(0,index);
    bool v = value[(size_t)index];
    return JSValueMakeBoolean(ctx,v);
}
开发者ID:pec1985,项目名称:hyperloop,代码行数:11,代码来源:JSBuffer.cpp

示例15: get_can_shutdown_cb

static JSValueRef
get_can_shutdown_cb(JSContextRef context,
					JSObjectRef thisObject,
					JSStringRef propertyName,
					JSValueRef *exception) {

	return JSValueMakeBoolean(context, lightdm_get_can_shutdown());
}
开发者ID:sbalneav,项目名称:lightdm-webkit2-greeter,代码行数:8,代码来源:lightdm-webkit2-greeter-ext.c


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