本文整理汇总了C++中JS_SetProperty函数的典型用法代码示例。如果您正苦于以下问题:C++ JS_SetProperty函数的具体用法?C++ JS_SetProperty怎么用?C++ JS_SetProperty使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了JS_SetProperty函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: register_all_fygui
void register_all_fygui(JSContext* cx, JSObject* obj) {
// first, try to get the ns
jsval nsval;
JSObject *ns;
JS_GetProperty(cx, obj, "fygui", &nsval);
if (nsval == JSVAL_VOID) {
ns = JS_NewObject(cx, NULL, NULL, NULL);
nsval = OBJECT_TO_JSVAL(ns);
JS_SetProperty(cx, obj, "fygui", &nsval);
} else {
JS_ValueToObject(cx, nsval, &ns);
}
obj = ns;
js_register_fygui_FYPropCell(cx, obj);
}
示例2: jsg_resolve_prop
static JSBool
jsg_resolve_prop(JSContext *cx, JSObject *obj, jsval id)
{
js_setting_group_t *jsg = JS_GetPrivate(cx, obj);
const char *name;
name = JSVAL_IS_STRING(id) ? JS_GetStringBytes(JSVAL_TO_STRING(id)) : NULL;
if(name != NULL) {
htsmsg_field_t *f;
if((f = htsmsg_field_find(jsg->jsg_store, name)) != NULL) {
jsval vp = jsval_from_htsmsgfield(cx, f);
JS_SetProperty(cx, obj, name, &vp);
}
}
return JS_TRUE;
}
示例3: register_all_PluginIAPJS
void register_all_PluginIAPJS(JSContext* cx, JSObject* obj) {
// first, try to get the ns
jsval nsval;
JSObject *ns;
JS_GetProperty(cx, obj, "sdkbox", &nsval);
if (nsval == JSVAL_VOID) {
ns = JS_NewObject(cx, NULL, NULL, NULL);
nsval = OBJECT_TO_JSVAL(ns);
JS_SetProperty(cx, obj, "sdkbox", &nsval);
} else {
JS_ValueToObject(cx, nsval, &ns);
}
obj = ns;
js_register_PluginIAPJS_IAP(cx, obj);
}
示例4: smjs_init_globhist_interface
void
smjs_init_globhist_interface(void)
{
jsval val;
struct JSObject *globhist;
if (!smjs_ctx || !smjs_elinks_object)
return;
globhist = smjs_get_globhist_object();
if (!globhist) return;
val = OBJECT_TO_JSVAL(globhist);
JS_SetProperty(smjs_ctx, smjs_elinks_object, "globhist", &val);
}
示例5: register_CocosPlayer
void register_CocosPlayer(JSContext* cx, JSObject* obj) {
// first, try to get the ns
jsval nsval;
JSObject *ns;
JS_GetProperty(cx, obj, "cc", &nsval);
if (nsval == JSVAL_VOID) {
ns = JS_NewObject(cx, NULL, NULL, NULL);
nsval = OBJECT_TO_JSVAL(ns);
JS_SetProperty(cx, obj, "cc", &nsval);
} else {
JS_ValueToObject(cx, nsval, &ns);
}
obj = ns;
JS_DefineFunction(cx, obj, "_cocosplayerLog", JS_cocosPlayerLog, 2, JSPROP_READONLY | JSPROP_PERMANENT);
}
示例6: XMLGraph_Init
JSBool
XMLGraph_Init(JSContext *cx, JSObject *obj, JSObject *parent_proto)
{
jsval v = JSVAL_NULL;
JSObject *proto = JS_InitClass(cx, obj, parent_proto, &XMLGraph_class,
XMLGraph, 1,
xmlgraph_props, xmlgraph_funcs,
NULL, NULL);
if (!proto)
return JS_FALSE;
if (!JS_SetProperty(cx, proto, "nameBy", &v)) {
JS_ReportError(cx, "failed to set XMLGraph.prototype.nameBy = null");
return JS_FALSE;
}
return JS_TRUE;
}
示例7: register_all_cocos2dx_spine
void register_all_cocos2dx_spine(JSContext* cx, JSObject* obj) {
// first, try to get the ns
JS::RootedValue nsval(cx);
JSObject *ns;
JS_GetProperty(cx, obj, "sp", &nsval);
if (nsval == JSVAL_VOID) {
ns = JS_NewObject(cx, NULL, NULL, NULL);
nsval = OBJECT_TO_JSVAL(ns);
JS_SetProperty(cx, obj, "sp", nsval);
} else {
JS_ValueToObject(cx, nsval, &ns);
}
obj = ns;
js_register_cocos2dx_spine_Skeleton(cx, obj);
js_register_cocos2dx_spine_SkeletonAnimation(cx, obj);
}
示例8: register_facebook_js
void register_facebook_js(JSContext* cx, JSObject* global){
jsval nsval;
JSObject *facebookJsbObject;
JS_GetProperty(cx, global, "FacebookJsb", &nsval);
if (nsval == JSVAL_VOID) {
facebookJsbObject = JS_NewObject(cx, NULL, NULL, NULL);
nsval = OBJECT_TO_JSVAL(facebookJsbObject);
JS_SetProperty(cx, global, "FacebookJsb", &nsval);
} else
JS_ValueToObject(cx, nsval, &facebookJsbObject);
JS_DefineFunction(cx, facebookJsbObject, "login", JSB_Facebook_login, 2, JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineFunction(cx, facebookJsbObject, "logout", JSB_Facebook_logout, 1, JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineFunction(cx, facebookJsbObject, "getLoginStatus", JSB_Facebook_getLoginStatus, 2, JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineFunction(cx, facebookJsbObject, "api", JSB_Facebook_api, 4, JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineFunction(cx, facebookJsbObject, "ui", JSB_Facebook_ui, 2, JSPROP_READONLY | JSPROP_PERMANENT);
}
示例9: FillMyHashMap
static bool
FillMyHashMap(JSContext* cx, MutableHandle<MyHashMap> map)
{
for (size_t i = 0; i < 10; ++i) {
RootedObject obj(cx, JS_NewObject(cx, nullptr));
RootedValue val(cx, UndefinedValue());
// Construct a unique property name to ensure that the object creates a
// new shape.
char buffer[2];
buffer[0] = 'a' + i;
buffer[1] = '\0';
if (!JS_SetProperty(cx, obj, buffer, val))
return false;
if (!map.putNew(obj->as<NativeObject>().lastProperty(), obj))
return false;
}
return true;
}
示例10: onClose
virtual void onClose(WebSocket* ws)
{
js_proxy_t * p = jsb_get_native_proxy(ws);
if (!p) return;
JSContext* cx = ScriptingCore::getInstance()->getGlobalContext();
JSObject* jsobj = JS_NewObject(cx, NULL, NULL, NULL);
jsval vp = c_string_to_jsval(cx, "close");
JS_SetProperty(cx, jsobj, "type", &vp);
jsval args = OBJECT_TO_JSVAL(jsobj);
ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), "onclose", 1, &args);
js_proxy_t* jsproxy = jsb_get_js_proxy(p->obj);
JS_RemoveObjectRoot(cx, &jsproxy->obj);
jsb_remove_proxy(p, jsproxy);
CC_SAFE_DELETE(ws);
}
示例11: register_all_PluginIAPJS
void register_all_PluginIAPJS(JSContext* cx, JSObject* obj) {
// first, try to get the ns
JS::RootedValue nsval(cx);
JS::RootedObject ns(cx);
JS_GetProperty(cx, obj, "sdkbox", &nsval);
if (nsval == JSVAL_VOID) {
ns = JS_NewObject(cx, NULL, NULL, NULL);
nsval = OBJECT_TO_JSVAL(ns);
JS_SetProperty(cx, obj, "sdkbox", nsval);
} else {
JS_ValueToObject(cx, nsval, &ns);
}
obj = ns;
js_register_PluginIAPJS_IAP(cx, obj);
sdkbox::setProjectType("js");
}
示例12: js_CreateInternalJsObject
JSObject* DLLCALL js_CreateInternalJsObject(JSContext* cx, JSObject* parent, js_callback_t* cb, js_startup_t* startup)
{
JSObject* obj;
if((obj = JS_DefineObject(cx, parent, "js", &js_internal_class, NULL
,JSPROP_ENUMERATE|JSPROP_READONLY))==NULL)
return(NULL);
if(!JS_SetPrivate(cx, obj, cb)) /* Store a pointer to js_callback_t */
return(NULL);
if(startup!=NULL) {
JSObject* load_path_list;
jsval val;
str_list_t load_path;
if((load_path_list=JS_NewArrayObject(cx, 0, NULL))==NULL)
return(NULL);
val=OBJECT_TO_JSVAL(load_path_list);
if(!JS_SetProperty(cx, obj, JAVASCRIPT_LOAD_PATH_LIST, &val))
return(NULL);
if((load_path=strListSplitCopy(NULL, startup->load_path, ",")) != NULL) {
JSString* js_str;
unsigned i;
for(i=0; load_path[i]!=NULL; i++) {
if((js_str=JS_NewStringCopyZ(cx, load_path[i]))==NULL)
break;
val=STRING_TO_JSVAL(js_str);
if(!JS_SetElement(cx, load_path_list, i, &val))
break;
}
strListFree(&load_path);
}
}
#ifdef BUILD_JSDOCS
js_DescribeSyncObject(cx,obj,"JavaScript engine internal control object",311);
js_CreateArrayOfStrings(cx, obj, "_property_desc_list", prop_desc, JSPROP_READONLY);
#endif
return(obj);
}
示例13: register_pluginx_js_extensions
void register_pluginx_js_extensions(JSContext* cx, JSObject* global)
{
// first, try to get the ns
JS::RootedValue nsval(cx);
JS::RootedObject ns(cx);
JS_GetProperty(cx, global, "plugin", &nsval);
if (nsval == JSVAL_VOID) {
ns = JS_NewObject(cx, NULL, NULL, NULL);
nsval = OBJECT_TO_JSVAL(ns);
JS_SetProperty(cx, global, "plugin", nsval);
} else {
JS_ValueToObject(cx, nsval, &ns);
}
JS_DefineFunction(cx, jsb_cocos2d_plugin_ProtocolIAP_prototype, "setListener", js_pluginx_ProtocolIAP_setResultListener, 1, JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineFunction(cx, jsb_cocos2d_plugin_ProtocolIAP_prototype, "getListener", js_pluginx_ProtocolIAP_getResultListener, 0, JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineFunction(cx, jsb_cocos2d_plugin_ProtocolIAP_prototype, "payForProduct", js_pluginx_ProtocolIAP_payForProduct, 0, JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineFunction(cx, jsb_cocos2d_plugin_ProtocolAds_prototype, "setListener", js_pluginx_ProtocolAds_setAdsListener, 1, JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineFunction(cx, jsb_cocos2d_plugin_ProtocolAds_prototype, "getListener", js_pluginx_ProtocolAds_getAdsListener, 0, JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineFunction(cx, jsb_cocos2d_plugin_ProtocolShare_prototype, "setListener", js_pluginx_ProtocolShare_setResultListener, 1, JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineFunction(cx, jsb_cocos2d_plugin_ProtocolShare_prototype, "getListener", js_pluginx_ProtocolShare_getResultListener, 0, JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineFunction(cx, jsb_cocos2d_plugin_ProtocolShare_prototype, "share", js_pluginx_ProtocolShare_share, 0, JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineFunction(cx, jsb_cocos2d_plugin_ProtocolSocial_prototype, "setListener", js_pluginx_ProtocolSocial_setListener, 1, JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineFunction(cx, jsb_cocos2d_plugin_ProtocolSocial_prototype, "getListener", js_pluginx_ProtocolSocial_getListener, 0, JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineFunction(cx, jsb_cocos2d_plugin_ProtocolSocial_prototype, "submitScore", js_pluginx_ProtocolSocial_submitScore, 0, JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineFunction(cx, jsb_cocos2d_plugin_ProtocolSocial_prototype, "unlockAchievement", js_pluginx_ProtocolSocial_unlockAchievement, 0, JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineFunction(cx, jsb_cocos2d_plugin_ProtocolUser_prototype, "setActionListener", js_pluginx_ProtocolUser_setActionListener, 1, JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineFunction(cx, jsb_cocos2d_plugin_ProtocolUser_prototype, "getActionListener", js_pluginx_ProtocolUser_getActionListener, 0, JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineFunction(cx, jsb_cocos2d_plugin_ProtocolUser_prototype, "login", js_pluginx_ProtocolUser_login, 0, JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineFunction(cx, jsb_cocos2d_plugin_ProtocolUser_prototype, "logout", js_pluginx_ProtocolUser_logout, 0, JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineFunction(cx, jsb_cocos2d_plugin_PluginProtocol_prototype, "callFuncWithParam", js_pluginx_PluginProtocol_callFuncWithParam, 1, JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineFunction(cx, jsb_cocos2d_plugin_PluginProtocol_prototype, "callStringFuncWithParam", js_pluginx_PluginProtocol_callStringFuncWithParam, 1, JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineFunction(cx, jsb_cocos2d_plugin_PluginProtocol_prototype, "callIntFuncWithParam", js_pluginx_PluginProtocol_callIntFuncWithParam, 1, JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineFunction(cx, jsb_cocos2d_plugin_PluginProtocol_prototype, "callFloatFuncWithParam", js_pluginx_PluginProtocol_callFloatFuncWithParam, 1, JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineFunction(cx, jsb_cocos2d_plugin_PluginProtocol_prototype, "callBoolFuncWithParam", js_pluginx_PluginProtocol_callBoolFuncWithParam, 1, JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineFunction(cx, jsb_cocos2d_plugin_FacebookAgent_prototype, "login", js_pluginx_FacebookAgent_login, 0, JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineFunction(cx, jsb_cocos2d_plugin_FacebookAgent_prototype, "_api", js_pluginx_FacebookAgent_api, 0, JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineFunction(cx, jsb_cocos2d_plugin_FacebookAgent_prototype, "appRequest", js_pluginx_FacebookAgent_appRequest, 0, JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineFunction(cx, jsb_cocos2d_plugin_FacebookAgent_prototype, "dialog", js_pluginx_FacebookAgent_dialog, 0, JSPROP_READONLY | JSPROP_PERMANENT);
global = ns;
js_register_pluginx_protocols_PluginParam(cx, global);
}
示例14: try_to_chain_stack_trace
static void
try_to_chain_stack_trace(JSContext *src_context, JSContext *dst_context,
jsval src_exc) {
/* append current stack of dst_context to stack trace for src_exc.
* we bail if anything goes wrong, just using the src_exc unmodified
* in that case. */
jsval chained, src_stack, dst_stack, new_stack;
JSString *new_stack_str;
JS_BeginRequest(src_context);
JS_BeginRequest(dst_context);
if (!JSVAL_IS_OBJECT(src_exc))
goto out; // src_exc doesn't have a stack trace
/* create a new exception in dst_context to get a stack trace */
gjs_throw_literal(dst_context, "Chained exception");
if (!(JS_GetPendingException(dst_context, &chained) &&
JSVAL_IS_OBJECT(chained)))
goto out; // gjs_throw_literal didn't work?!
JS_ClearPendingException(dst_context);
/* get stack trace for src_exc and chained */
if (!(gjs_object_get_property(dst_context, JSVAL_TO_OBJECT(chained),
"stack", &dst_stack) &&
JSVAL_IS_STRING(dst_stack)))
goto out; // couldn't get chained stack
if (!(gjs_object_get_property(src_context, JSVAL_TO_OBJECT(src_exc),
"stack", &src_stack) &&
JSVAL_IS_STRING(src_stack)))
goto out; // couldn't get source stack
/* add chained exception's stack trace to src_exc */
new_stack_str = JS_ConcatStrings
(dst_context, JSVAL_TO_STRING(src_stack), JSVAL_TO_STRING(dst_stack));
if (new_stack_str==NULL)
goto out; // couldn't concatenate src and dst stacks?!
new_stack = STRING_TO_JSVAL(new_stack_str);
JS_SetProperty(dst_context, JSVAL_TO_OBJECT(src_exc), "stack", &new_stack);
out:
JS_EndRequest(dst_context);
JS_EndRequest(src_context);
}
示例15: register_LoadUrlImage_js
void register_LoadUrlImage_js(JSContext* cx, JSObject* global)
{
JS::RootedValue nsval(cx);
JS::RootedValue tmpval(cx);
JS::RootedObject pJsbObject(cx);
JS_GetProperty(cx, global, "LoadUrlImage", &nsval);
if (nsval == JSVAL_VOID) {
pJsbObject = JS_NewObject(cx, NULL, NULL, NULL);
nsval = OBJECT_TO_JSVAL(global);
JS_SetProperty(cx, global, "LoadUrlImage", nsval);
}
else
{
JS_ValueToObject(cx, nsval, &pJsbObject);
}
JS_DefineFunction(cx, global, "loadUrlImage", JSB_LoadUrlImage_loadUrlImage, 2, JSPROP_READONLY | JSPROP_PERMANENT);
}