Example #1
0
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);
}
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)));
}
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);
}
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;
}
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);
}
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);
}
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)));
}
Example #8
0
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;
}
Example #9
0
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);
}
static JSValueRef
get_in_authentication_cb(JSContextRef context,
						 JSObjectRef thisObject,
						 JSStringRef propertyName,
						 JSValueRef *exception) {
	return JSValueMakeBoolean(context, lightdm_greeter_get_in_authentication(GREETER));
}
static JSValueRef
get_user_logged_in_cb(JSContextRef context,
					  JSObjectRef thisObject,
					  JSStringRef propertyName,
					  JSValueRef *exception) {
	return JSValueMakeBoolean(context, lightdm_user_get_logged_in(USER));
}
static JSValueRef
get_select_guest_cb(JSContextRef context,
					JSObjectRef thisObject,
					JSStringRef propertyName,
					JSValueRef *exception) {
	return JSValueMakeBoolean(context, lightdm_greeter_get_select_guest_hint(GREETER));
}
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);
}
Example #14
0
/**
 * 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);
}
static JSValueRef
get_can_shutdown_cb(JSContextRef context,
					JSObjectRef thisObject,
					JSStringRef propertyName,
					JSValueRef *exception) {

	return JSValueMakeBoolean(context, lightdm_get_can_shutdown());
}
JNIEXPORT jintLong JNICALL WebKit_win32_NATIVE(JSValueMakeBoolean)
	(JNIEnv *env, jclass that, jintLong arg0, jintLong arg1)
{
	jintLong rc = 0;
	WebKit_win32_NATIVE_ENTER(env, that, JSValueMakeBoolean_FUNC);
	rc = (jintLong)JSValueMakeBoolean((JSContextRef)arg0, (bool)arg1);
	WebKit_win32_NATIVE_EXIT(env, that, JSValueMakeBoolean_FUNC);
	return rc;
}
JSValueRef equalsConstructorForJava_java_lang_String(JSContextRef ctx, JSObjectRef function, JSObjectRef object, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
{
    JSPrivateObject* p = (JSPrivateObject*)JSObjectGetPrivate(object);
    if (p && p->object && argumentCount > 0) {
        JSPrivateObject* arg0 = (JSPrivateObject*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], NULL));
        if (arg0 == NULL || arg0->object == NULL) return JSValueMakeBoolean(ctx, false);
        JNI_ENV_ENTER
        jclass  javaClass = (*env)->FindClass(env, "java/lang/String");
        if (javaClass == NULL) return HyperloopMakeException(ctx, "Class not found: java.lang.String", exception);

        jmethodID methodId = (*env)->GetMethodID(env, javaClass, "equals", "(Ljava/lang/Object;)Z");
        if (methodId == NULL) return HyperloopMakeException(ctx, "Method not found: java.lang.String#equals", exception);
        
        jboolean result = (*env)->CallBooleanMethod(env, p->object, methodId, arg0->object);
        CHECK_JAVAEXCEPTION
        JNI_ENV_EXIT
        return result == JNI_TRUE ? JSValueMakeBoolean(ctx, true) : JSValueMakeBoolean(ctx, false);
    }
static JSValueRef hasMarkedTextCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
{
    TextInputController* controller = static_cast<TextInputController*>(JSObjectGetPrivate(thisObject));
    
    if (controller)
        return JSValueMakeBoolean(context, controller->hasMarkedText());

    return JSValueMakeUndefined(context);
}
static JSValueRef isActionSupportedCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
{
    JSStringRef action = 0;
    if (argumentCount == 1)
        action = JSValueToStringCopy(context, arguments[0], exception);    
    JSValueRef result = JSValueMakeBoolean(context, toAXElement(thisObject)->isActionSupported(action));
    if (action)
        JSStringRelease(action);
    return result;
}
Example #20
0
static JSValueRef attributedStringRangeIsMisspelledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
{
    unsigned location = UINT_MAX, length = 0;
    if (argumentCount == 2) {
        location = JSValueToNumber(context, arguments[0], exception);
        length = JSValueToNumber(context, arguments[1], exception);
    }
    
    return JSValueMakeBoolean(context, toAXElement(thisObject)->attributedStringRangeIsMisspelled(location, length));
}
void InspectorController::updateScriptResource(InspectorResource* resource, bool finished, bool failed)
{
    ASSERT(resource->scriptObject);
    ASSERT(m_scriptContext);
    if (!resource->scriptObject || !m_scriptContext)
        return;

    JSValueRef failedValue = JSValueMakeBoolean(m_scriptContext, failed);
    JSValueRef finishedValue = JSValueMakeBoolean(m_scriptContext, finished);

    JSStringRef propertyName = JSStringCreateWithUTF8CString("failed");
    JSObjectSetProperty(m_scriptContext, resource->scriptObject, propertyName, failedValue, kJSPropertyAttributeNone, 0);
    JSStringRelease(propertyName);

    propertyName = JSStringCreateWithUTF8CString("finished");
    JSObjectSetProperty(m_scriptContext, resource->scriptObject, propertyName, finishedValue, kJSPropertyAttributeNone, 0);
    JSStringRelease(propertyName);

}
static JSValueRef elementDoesAutoCompleteForElementWithIdCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
{
    LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
    JSRetainPtr<JSStringRef> elementId(Adopt, JSValueToStringCopy(context, arguments[0], exception));
    ASSERT(!*exception);

    bool autoCompletes = controller->elementDoesAutoCompleteForElementWithId(elementId.get());

    return JSValueMakeBoolean(context, autoCompletes);
}
static JSValueRef isAttributeSettableCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
{
    JSStringRef attribute = 0;
    if (argumentCount == 1)
        attribute = JSValueToStringCopy(context, arguments[0], exception);    
    JSValueRef result = JSValueMakeBoolean(context, toAXElement(thisObject)->isAttributeSettable(attribute));
    if (attribute)
        JSStringRelease(attribute);
    return result;
}
Example #24
0
static JSValueRef getVisible(JSContextRef ctx, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
{
    KJS::JSLock lock(false);

    if (!JSValueIsObjectOfClass(ctx, thisObject, ProfileNodeClass()))
        return JSValueMakeUndefined(ctx);

    ProfileNode* profileNode = static_cast<ProfileNode*>(JSObjectGetPrivate(thisObject));
    return JSValueMakeBoolean(ctx, profileNode->visible());
}
Example #25
0
bool
web_view_callback (struct js_callback_data *data) {
	unsigned short i;

	JSValueRef js_args[data->args_len];
	for (i = 0; i < data->args_len; i++) {
		switch (data->args[i].type) {
		case kJSTypeBoolean:
			js_args[i] = JSValueMakeBoolean(data->widget->js_context, data->args[i].value.boolean);
			break;
		case kJSTypeNull:
			js_args[i] = JSValueMakeNull(data->widget->js_context);
			break;
		case kJSTypeNumber:
			js_args[i] = JSValueMakeNumber(data->widget->js_context, data->args[i].value.number);
			break;
		case kJSTypeObject:
			js_args[i] = data->args[i].value.object;
			break;
		case kJSTypeString: {
			JSStringRef str = JSStringCreateWithUTF8CString(data->args[i].value.string);
			js_args[i] = JSValueMakeString(data->widget->js_context, str);
			JSStringRelease(str);
			break;
		}
		case kJSTypeUndefined:
			js_args[i] = JSValueMakeUndefined(data->widget->js_context);
			break;
		}
	}

	if (!data->widget->js_context || !data->widget->js_object) {
		LOG_ERR("missing JS context or object!");

		return false;
	}

	JSStringRef str_ondatachanged = JSStringCreateWithUTF8CString("onDataChanged");
	JSValueRef func = JSObjectGetProperty(data->widget->js_context, data->widget->js_object, str_ondatachanged, NULL);
	JSObjectRef function = JSValueToObject(data->widget->js_context, func, NULL);
	JSStringRelease(str_ondatachanged);

	/* let the thread know we're done with the data so it can cleanup */
	pthread_cond_signal(&update_cond);

	if (!JSObjectIsFunction(data->widget->js_context, function)) {
		LOG_DEBUG("onDataChanged callback for 'widget_%s' with type '%s' is not a function or is not set", data->widget->name, data->widget->type);

		return false; /* only run once */
	}

	JSObjectCallAsFunction(data->widget->js_context, function, NULL, data->args_len, js_args, NULL);

	return false; /* only run once */
}
Example #26
0
static JSValueRef console_getSharedBool(JSContextRef ctx, JSObjectRef thisObject, JSStringRef /*propertyName*/, JSValueRef* /*exception*/)
{
    if (!JSValueIsObjectOfClass(ctx, thisObject, ConsoleClass()))
        return JSValueMakeUndefined(ctx);

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

    return JSValueMakeBoolean(ctx, dlg->sharedBool());
}
Example #27
0
NATIVE(JSValue,jlong,makeBoolean) (PARAMS, jlong ctx, jboolean boolean)
{
	JSContextWrapper *wrapper = (JSContextWrapper *)ctx;
	struct msg_t { JSContextRef ctx; bool boolean; JSValueRef ret; };
	msg_t msg = { wrapper->context, (bool)boolean, NULL };
	wrapper->worker_q->sync([](void *msg) {
		msg_t *m = (msg_t *)msg;
		m->ret = JSValueMakeBoolean(m->ctx, m->boolean);
	},&msg);
	return (long) msg.ret;
}
void InspectorController::updateScriptResourceRequest(InspectorResource* resource)
{
    ASSERT(resource->scriptObject);
    ASSERT(m_scriptContext);
    if (!resource->scriptObject || !m_scriptContext)
        return;

    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 mainResourceValue = JSValueMakeBoolean(m_scriptContext, m_mainResource == resource);

    JSStringRef propertyName = JSStringCreateWithUTF8CString("url");
    JSObjectSetProperty(m_scriptContext, resource->scriptObject, propertyName, urlValue, kJSPropertyAttributeNone, 0);
    JSStringRelease(propertyName);

    propertyName = JSStringCreateWithUTF8CString("domain");
    JSObjectSetProperty(m_scriptContext, resource->scriptObject, propertyName, domainValue, kJSPropertyAttributeNone, 0);
    JSStringRelease(propertyName);

    propertyName = JSStringCreateWithUTF8CString("path");
    JSObjectSetProperty(m_scriptContext, resource->scriptObject, propertyName, pathValue, kJSPropertyAttributeNone, 0);
    JSStringRelease(propertyName);

    propertyName = JSStringCreateWithUTF8CString("lastPathComponent");
    JSObjectSetProperty(m_scriptContext, resource->scriptObject, propertyName, lastPathComponentValue, kJSPropertyAttributeNone, 0);
    JSStringRelease(propertyName);

    propertyName = JSStringCreateWithUTF8CString("requestHeaders");
    JSObjectSetProperty(m_scriptContext, resource->scriptObject, propertyName, scriptObjectForRequest(m_scriptContext, resource), kJSPropertyAttributeNone, 0);
    JSStringRelease(propertyName);

    propertyName = JSStringCreateWithUTF8CString("mainResource");
    JSObjectSetProperty(m_scriptContext, resource->scriptObject, propertyName, mainResourceValue, kJSPropertyAttributeNone, 0);
    JSStringRelease(propertyName);
}
Example #29
0
static JSValueRef
zs__                (JSContextRef     js_context,
                     JSObjectRef      js_function,
                     JSObjectRef      js_this,
                     size_t           argument_count,
                     const JSValueRef js_arguments[],
                     JSValueRef*      js_exception)
{
	if(argument_count<=0){
		return JSValueMakeNull (js_context);
	}
	const char*ret;
	{
		window___* w=reinterpret_cast<window___*>(JSObjectGetPrivate(js_function));
		if(!w){
			return JSValueMakeNull (js_context);
		}
		char** argv=new char*[argument_count+1];
		JSStringRef* jsr=new JSStringRef[argument_count];
		for(size_t i=0;i<argument_count;i++){
			jsr[i]=JSValueToStringCopy(js_context, js_arguments[i], js_exception);
			size_t jsSize = JSStringGetMaximumUTF8CStringSize(jsr[i]);
			argv[i]=new char[jsSize];
			JSStringGetUTF8CString(jsr[i], argv[i], jsSize);
		}
		if(!argv[0][0]){
			ret=NULL;
			for(size_t i=1;i<argument_count;i++)
				cout<<argv[i];
			cout<<endl;
		}else
			ret=call4__(argv[0],NULL,argument_count,(const char**)argv,1);
		for(size_t i=0;i<argument_count;i++){
			delete argv[i];
			JSStringRelease(jsr[i]);
		}
		delete jsr;
		delete argv;
	}

	if(!ret)
		return JSValueMakeNull (js_context);
	JSValueRef ret2;
	if(true_==ret||false_==ret){
		ret2=JSValueMakeBoolean(js_context,true_==ret);
	}else{
		JSStringRef ret1=JSStringCreateWithUTF8CString(ret);
		ret2=JSValueMakeString(js_context,ret1);
		JSStringRelease (ret1);
	}
	return ret2;
}
static JSValueRef JSOSInstaller_getWorking(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception)
{
    JSInstaller* jsinst = JSObjectGetPrivate(object);
    if (jsinst) {
        JSValueRef value = JSValueMakeBoolean(context, jsinst->is_working);
        return value;
    }else{
        JSStringRef message = JSStringCreateWithUTF8CString("TypeError: Failed to get inside JSInstaller");
        *exception = JSValueMakeString(context, message);
        JSStringRelease(message);
    }
    return NULL;
}