本文整理汇总了C++中JSObjectSetProperty函数的典型用法代码示例。如果您正苦于以下问题:C++ JSObjectSetProperty函数的具体用法?C++ JSObjectSetProperty怎么用?C++ JSObjectSetProperty使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了JSObjectSetProperty函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: main
int
main (int argc,
gchar* argv[])
{
GtkWidget* window;
GtkWidget* vbox;
GtkWidget* scrolled;
GtkWidget* web_view;
GtkWidget* button_box;
WebKitWebFrame* web_frame;
JSGlobalContextRef js_context;
JSObjectRef js_global;
JSStringRef js_function_name;
JSObjectRef js_set_can_register;
if (!g_thread_supported ())
g_thread_init (NULL);
gtk_init_check (&argc, &argv);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (window), "WebKitGTK+ API Demo");
gtk_window_set_default_size (GTK_WINDOW (window), 640, 240);
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
vbox = gtk_vbox_new (FALSE, 4);
gtk_container_add (GTK_CONTAINER (window), vbox);
scrolled = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtk_box_pack_start (GTK_BOX (vbox), scrolled, TRUE, TRUE, 0);
web_view = webkit_web_view_new ();
gtk_container_add (GTK_CONTAINER (scrolled), web_view);
webkit_web_view_load_string (WEBKIT_WEB_VIEW (web_view), form_markup, "text/html", "UTF-8", "");
g_signal_connect (web_view, "create-plugin-widget",
G_CALLBACK (web_view_create_plugin_widget_cb), NULL);
button_box = gtk_hbutton_box_new ();
gtk_box_pack_start (GTK_BOX (vbox), button_box, FALSE, FALSE, 0);
register_button = gtk_button_new_with_mnemonic ("Send _Registration");
gtk_widget_set_sensitive (register_button, FALSE);
gtk_box_pack_start (GTK_BOX (button_box), register_button, FALSE, FALSE, 0);
web_frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (web_view));
js_context = webkit_web_frame_get_global_context (web_frame);
js_global = JSContextGetGlobalObject (js_context);
js_function_name = JSStringCreateWithUTF8CString ("setCanRegister");
js_set_can_register = JSObjectMakeFunctionWithCallback (js_context,
js_function_name, (JSObjectCallAsFunctionCallback)set_can_register_cb);
JSObjectSetProperty (js_context, js_global, js_function_name, js_set_can_register, 0, NULL);
JSStringRelease (js_function_name);
gtk_widget_show_all (window);
gtk_main ();
return 0;
}
开发者ID:diegoe,项目名称:webkitgtk.org,代码行数:57,代码来源:gcds.c
示例17: MakeObjectForJSBuffer
/**
* called to make a native object for JSBuffer. this method must be called instead of
* normal JSObjectMake in JavaScriptCore so that the correct prototype chain and
* constructor will be setup.
*/
JSObjectRef MakeObjectForJSBuffer (JSContextRef ctx, JSBuffer *instance)
{
JSObjectRef object = JSObjectMake(ctx, CreateClassForJSBuffer(), HyperloopMakePrivateObjectForJSBuffer(instance));
JSObjectRef value = JSObjectMake(ctx, CreateClassForJSBufferConstructor(), 0);
JSStringRef cproperty = JSStringCreateWithUTF8CString("constructor");
JSObjectSetProperty(ctx, object, cproperty, value, kJSPropertyAttributeDontEnum, 0);
JSStringRelease(cproperty);
JSStringRef nameProperty = JSStringCreateWithUTF8CString("name");
JSStringRef valueProperty = JSStringCreateWithUTF8CString("JSBuffer");
JSValueRef valueRef = JSValueMakeString(ctx, valueProperty);
JSObjectSetProperty(ctx, value, nameProperty, valueRef, kJSPropertyAttributeDontEnum, 0);
JSStringRelease(nameProperty);
JSStringRelease(valueProperty);
return object;
}
开发者ID:pec1985,项目名称:hyperloop,代码行数:23,代码来源:JSBuffer.cpp
示例18: createWrappedMessage
static JSObjectRef createWrappedMessage(JSGlobalContextRef context, WKStringRef data)
{
static JSStringRef dataName = JSStringCreateWithUTF8CString("data");
JSRetainPtr<JSStringRef> jsData = WKStringCopyJSString(data);
JSObjectRef wrappedMessage = JSObjectMake(context, 0, 0);
JSObjectSetProperty(context, wrappedMessage, dataName, JSValueMakeString(context, jsData.get()), kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly, 0);
return wrappedMessage;
}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:9,代码来源:QtBuiltinBundlePage.cpp
示例19: JSObjectSetProperty
void JSObject::SetProperty(const JSString& property_name, const JSValue& property_value, const std::unordered_set<JSPropertyAttribute>& attributes) {
HAL_JSOBJECT_LOCK_GUARD;
JSValueRef exception { nullptr };
JSObjectSetProperty(static_cast<JSContextRef>(js_context__), js_object_ref__, static_cast<JSStringRef>(property_name), static_cast<JSValueRef>(property_value), detail::ToJSPropertyAttributes(attributes), &exception);
if (exception) {
detail::ThrowRuntimeError("JSObject", JSValue(js_context__, exception));
}
}
开发者ID:garymathews,项目名称:HAL,代码行数:9,代码来源:JSObject.cpp
示例20: script_state_load_single
bool script_state_load_single(int script_idx,bool checkpoint,char *err_str)
{
int prop_name_len,prop_value_len;
char prop_name[256];
char *prop_value;
script_type *script;
JSStringRef js_prop_name,js_prop_json;
JSValueRef js_prop_value;
if (script_idx==-1) return(TRUE);
// get the script
script=js.script_list.scripts[script_idx];
// run through the properties to replace
// a 0 property name length means the end
// of properties for this script
while (TRUE) {
// get the prop name and JSON value
game_file_get_chunk(&prop_name_len);
if (prop_name_len==0) break;
game_file_get_chunk(prop_name);
game_file_get_chunk(&prop_value_len);
prop_value=(char*)malloc(prop_value_len);
if (prop_value==NULL) {
strcpy(err_str,"Out of Memory");
return(FALSE);
}
game_file_get_chunk(prop_value);
// process the property
js_prop_name=JSStringCreateWithUTF8CString(prop_name);
js_prop_json=JSStringCreateWithUTF8CString(prop_value);
js_prop_value=JSValueMakeFromJSONString(script->cx,js_prop_json);
JSStringRelease(js_prop_json);
JSObjectSetProperty(script->cx,script->global_obj,js_prop_name,js_prop_value,0,NULL);
JSStringRelease(js_prop_name);
}
// send load event to script
scripts_post_event(script_idx,-1,sd_event_state,(checkpoint?sd_event_state_load_checkpoint:sd_event_state_load),0,err_str);
return(TRUE);
}
开发者ID:rzel,项目名称:dim3,代码行数:56,代码来源:scripts_state.c
注:本文中的JSObjectSetProperty函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论