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