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


C++ JSObjectSetProperty函数代码示例

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


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

示例1: mainThreadNormalWorld

int MDNativeBindingManager::registerNativeJSObjectsToContext(ScriptController *script, DOMWrapperWorld* world)
{
    DOMWrapperWorld* nativeWorld = (world)? world : mainThreadNormalWorld();
    JSDOMWindow*    window =  (script->globalObject(nativeWorld));
    //toJSDOMWindow
    JSContextRef context = reinterpret_cast<JSContextRef>(window->globalExec()); 
    JSObjectRef globalObject = JSContextGetGlobalObject(context);

    IMDNativeBindingObject *object = NULL;
    size_t size = m_jsTable.size();
    
    for (size_t i=0; i<size; i++) {
        object = m_jsTable.at(i);
        JSStringRef propertyName = object->propertyName(); //entry->m_propertyName;
        JSObjectSetProperty(
                context,
                globalObject,
                propertyName,
                object->propertyValue(context),
                kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete, NULL);

        JSStringRelease(propertyName);
    }

    return 0;
}
开发者ID:bytewang,项目名称:vitas,代码行数:26,代码来源:MDNativeBindingManager.cpp

示例2: layoutTestContollerStr

void LayoutTestController::makeWindowObject(JSContextRef context, JSObjectRef windowObject, JSValueRef* exception)
{
    JSRetainPtr<JSStringRef> layoutTestContollerStr(Adopt, JSStringCreateWithUTF8CString("layoutTestController"));
    ref();
    JSValueRef layoutTestContollerObject = JSObjectMake(context, getJSClass(), this);
    JSObjectSetProperty(context, windowObject, layoutTestContollerStr.get(), layoutTestContollerObject, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete, exception);
}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:7,代码来源:LayoutTestController.cpp

示例3: Java_com_vasco_digipass_sdk_smartfaceplugin_PluginImp_initNative

void Java_com_vasco_digipass_sdk_smartfaceplugin_PluginImp_initNative(JNIEnv *env, jobject thiz,jlong jsContext,jlong envMap)
{
	long jscontextlong = (long)jsContext;
	DPPlugin* instance = DPPlugin::getInstance();
	instance->jsContext = (JSContextRef)jsContext;
	instance->envMap = (std::map<long,JNIEnv*>*)envMap;
	instance->pluginImpObject = env->NewGlobalRef(thiz);
    jclass clazz = env->GetObjectClass(thiz);
    jmethodID initMethod = env->GetMethodID(clazz,"init","(Ljava/lang/String;)V");
    jstring fingerprint = env->NewStringUTF(DBFINGERPRINT);
    env->CallVoidMethod(thiz,initMethod,fingerprint);
    env->DeleteLocalRef(fingerprint);
    instance->getBytes = env->GetMethodID(clazz,"getBytes","(Ljava/lang/String;)[B");
    instance->putBytes = env->GetMethodID(clazz,"putBytes","(Ljava/lang/String;Ljava/lang/String;[B)Z");
    instance->initializeRegistrationDataV2JavaFunction = env->GetMethodID(clazz,"initializeRegistrationDataV2","(Ljava/lang/String;[Z)Ljava/lang/String;");
    instance->decryptActivationDataJavaFunction = env->GetMethodID(clazz,"decryptActivationData","(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;[Z)Ljava/lang/String;");
    instance->validateSharedDataChecksumJavaFunction = env->GetMethodID(clazz,"validateSharedDataChecksum","(Ljava/lang/String;[Z)Ljava/lang/String;");
    env->DeleteLocalRef(clazz);
    JSStringRef str = JSStringCreateWithUTF8CString("VASCO");
	JSClassRef classDef = JSClassCreate(&spjsdpplugin_def);
	JSObjectRef classObj = JSObjectMake(instance->jsContext, classDef, (void*)DPPlugin::getInstance());
	JSObjectSetProperty(instance->jsContext, JSContextGetGlobalObject(instance->jsContext), str, classObj, kJSPropertyAttributeNone, NULL);
    JSClassRelease(classDef);
	JSStringRelease(str);
}
开发者ID:memedum90,项目名称:demoforios,代码行数:25,代码来源:plugin-jni-Android.cpp

示例4: window_object_cleared_callback

//
//  Boilerplate code / signal callback for attaching methods when a
//  new javascript context is created.
//
static void 
window_object_cleared_callback (WebKitScriptWorld *world, 
                                WebKitWebPage *web_page, 
                                WebKitFrame *frame, 
                                gpointer user_data)
{
  std::cout << "attempting to set up custom c function bindings\n";
  JSGlobalContextRef js_ctx;
  js_ctx = webkit_frame_get_javascript_context_for_script_world (frame, world);
  
  JSStringRef function_name = JSStringCreateWithUTF8CString("whatever");
  JSObjectRef boiler_plate = JSObjectMakeFunctionWithCallback(js_ctx,
                                                              function_name,
                                                              some_method);
  JSValueRef exception = 0;
  JSObjectRef global = JSContextGetGlobalObject(js_ctx);
  JSObjectSetProperty(js_ctx,
                      global,
                      JSStringCreateWithUTF8CString("myCFunction"),
                      boiler_plate,
                      kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly,
                      &exception);
  if (exception) {
    std::cout << "Argh! an exception!!!!\n";
  }
}
开发者ID:Aeva,项目名称:webkit2gtk-experiment,代码行数:30,代码来源:module.cpp

示例5: window_object_cleared_callback

static void window_object_cleared_callback(WebKitWebView* web_view, WebKitWebFrame* web_frame, JSGlobalContextRef context, JSObjectRef window_object, gpointer data)
{
    JSStringRef name = JSStringCreateWithUTF8CString("runTest");
    JSObjectRef testComplete = JSObjectMakeFunctionWithCallback(context, name, runPasteTestCallback);
    JSObjectSetProperty(context, window_object, name, testComplete, kJSPropertyAttributeNone, 0);
    JSStringRelease(name);
}
开发者ID:CannedFish,项目名称:webkitgtk,代码行数:7,代码来源:testcopyandpaste.c

示例6: get_message_data

static JSValueRef
get_message_data(SoupMessage *msg)
{
    const char *name, *value;
    SoupMessageHeadersIter iter;
    JSObjectRef o = NULL, ho;
    JSValueRef ret;
    JSStringRef s;

    JSContextRef ctx = scripts_get_global_context();
    if (ctx == NULL) {
        return NIL;
    }

    o = JSObjectMake(ctx, NULL, NULL);
    js_set_object_property(ctx, o, "body", msg->response_body->data, NULL);

    ho = JSObjectMake(ctx, NULL, NULL);

    soup_message_headers_iter_init(&iter, msg->response_headers);
    while (soup_message_headers_iter_next(&iter, &name, &value))
        js_set_object_property(ctx, ho, name, value, NULL);

    s = JSStringCreateWithUTF8CString("headers");
    JSObjectSetProperty(ctx, o, s, ho, kJSDefaultProperty, NULL);
    JSStringRelease(s);
    ret = o;

    scripts_release_global_context();

    return ret;
}
开发者ID:vifino,项目名称:dwb,代码行数:32,代码来源:ns_net.c

示例7: code

	void JavascriptModuleInstance::Run()
	{
		std::string code(FileUtils::ReadFile(this->path));

		// Insert the global object into this script's context.
		KValueRef globalValue = Value::NewObject(host->GetGlobalObject());
		JSValueRef jsAPI = KJSUtil::ToJSValue(globalValue, context);
		JSStringRef propertyName = JSStringCreateWithUTF8CString(PRODUCT_NAME);
		JSObjectSetProperty(context, global, propertyName, jsAPI,
			kJSPropertyAttributeNone, NULL);
		JSStringRelease(propertyName);

		// Check the script's syntax.
		JSValueRef exception;
		JSStringRef jsCode = JSStringCreateWithUTF8CString(code.c_str());
		bool syntax = JSCheckScriptSyntax(context, jsCode, NULL, 0, &exception);
		if (!syntax)
		{
			KValueRef e = KJSUtil::ToKrollValue(exception, context, NULL);
			JSStringRelease(jsCode);
			throw ValueException(e);
		}

		// Run the script.
		JSValueRef ret = JSEvaluateScript(context, jsCode, NULL, NULL, 1, &exception);
		JSStringRelease(jsCode);

		if (ret == NULL)
		{
			KValueRef e = KJSUtil::ToKrollValue(exception, context, NULL);
			throw ValueException(e);
		}
	}
开发者ID:mital,项目名称:kroll,代码行数:33,代码来源:javascript_module_instance.cpp

示例8: window_object_cleared__

static void window_object_cleared__(
	WebKitWebView  *wv,
	WebKitWebFrame *wf,
	JSGlobalContextRef ctx,
	gpointer        window_object,
	gpointer        user_data)
{
	const char* name0 = "z$";
	JSStringRef name = JSStringCreateWithUTF8CString(name0);

	JSObjectRef func;
	//func = JSObjectMakeFunctionWithCallback(ctx, name, zs__);
	{
		JSClassDefinition cd = kJSClassDefinitionEmpty;
		cd.className = name0;
		cd.callAsFunction = zs__;
		JSClassRef cr = JSClassCreate (&cd);
		func = JSObjectMake (ctx, cr, NULL);
	}

	JSObjectRef o = JSContextGetGlobalObject(ctx);
	JSObjectSetProperty(ctx, o, name, func, kJSPropertyAttributeNone, NULL);
	JSStringRelease(name);
	/*bool b=*/JSObjectSetPrivate(func, (void*)webkit_view___::from__(wv));
}
开发者ID:zzzzzzzzzzz0,项目名称:zhscript,代码行数:25,代码来源:webkit_view___.cpp

示例9: JSObjectSetProperty

void Object::setProperty(const String& propName, const Value& value) const {
  JSValueRef exn = NULL;
  JSObjectSetProperty(m_context, m_obj, propName, value, kJSPropertyAttributeNone, &exn);
  if (exn) {
    std::string exceptionText = Value(m_context, exn).toString().str();
    throwJSExecutionException("Failed to set property: %s", exceptionText.c_str());
  }
}
开发者ID:0m15,项目名称:react-native-1,代码行数:8,代码来源:Value.cpp

示例10: create

	static void create(JSContextRef ctx, JSObjectRef global) {
		JSClassDefinition classDefinition = kJSClassDefinitionEmpty;
		classDefinition.callAsConstructor = classConstructor;
		JSClassRef clsRef = JSClassCreate(&classDefinition);
		JSObjectRef classDef = JSObjectMake(ctx, clsRef, NULL);
		JSStringRef className = JSStringCreateWithUTF8CString("ManipulationDeltaEventHandler");
		JSObjectSetProperty(ctx, global, className, classDef, kJSPropertyAttributeNone, NULL);
	}
开发者ID:FokkeZB,项目名称:hyperloop,代码行数:8,代码来源:Windows_UI_Xaml_Input_ManipulationDeltaEventHandler.hpp

示例11: JSObjectMake

JSPropertyValue& JSPropertyValue::operator=(const JSCallbackWithRetval& callback) {
  JSObjectRef nativeFunction = JSObjectMake(ctx_, NativeFunctionWithRetvalClass(), new JSCallbackWithRetval(callback));
  if (using_numeric_idx_)
    JSObjectSetPropertyAtIndex(ctx_, *proxyObj_, numeric_idx_, nativeFunction, nullptr);
  else
    JSObjectSetProperty(ctx_, *proxyObj_, string_idx_, nativeFunction, kJSPropertyAttributeNone, nullptr);
  return *this;
}
开发者ID:FinnProjects,项目名称:ultralight,代码行数:8,代码来源:JSHelpers.cpp

示例12: JSObjectSetPropertyAtIndex

JSPropertyValue& JSPropertyValue::operator=(const JSValue& value) {
  if (using_numeric_idx_)
    JSObjectSetPropertyAtIndex(ctx_, *proxyObj_, numeric_idx_, value, nullptr);
  else
    JSObjectSetProperty(ctx_, *proxyObj_, string_idx_, value, kJSPropertyAttributeNone, nullptr);

  return *this;
}
开发者ID:FinnProjects,项目名称:ultralight,代码行数:8,代码来源:JSHelpers.cpp

示例13: register_global_function

void register_global_function(JSContextRef ctx, char *name, JSObjectCallAsFunctionCallback handler) {
	JSObjectRef global_obj = JSContextGetGlobalObject(ctx);

	JSStringRef fn_name = JSStringCreateWithUTF8CString(name);
	JSObjectRef fn_obj = JSObjectMakeFunctionWithCallback(ctx, fn_name, handler);

	JSObjectSetProperty(ctx, global_obj, fn_name, fn_obj, kJSPropertyAttributeNone, NULL);
}
开发者ID:gsnewmark,项目名称:planck,代码行数:8,代码来源:main.c

示例14: JSStringCreateWithUTF8CString

bool ObjectWrapper::SetValue(const KeyType key, JSValueRef value)
{
    JSStringRef strKey = JSStringCreateWithUTF8CString(key.c_str());
    JSObjectSetProperty(g_ctx, m_obj, strKey, value, kJSPropertyAttributeNone, NULL);
    JSStringRelease(strKey);

    return true;
}
开发者ID:vnmc,项目名称:zephyros,代码行数:8,代码来源:jsbridge_webview.cpp

示例15: JSContextGetGlobalObject

void JSCExecutor::setGlobalVariable(const std::string& propName, const std::string& jsonValue) {
  auto globalObject = JSContextGetGlobalObject(m_context);
  String jsPropertyName(propName.c_str());

  String jsValueJSON(jsonValue.c_str());
  auto valueToInject = JSValueMakeFromJSONString(m_context, jsValueJSON);

  JSObjectSetProperty(m_context, globalObject, jsPropertyName, valueToInject, 0, NULL);
}
开发者ID:DYS1230,项目名称:react-native,代码行数:9,代码来源:JSCExecutor.cpp


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