本文整理汇总了C++中js::HandleObject::get方法的典型用法代码示例。如果您正苦于以下问题:C++ HandleObject::get方法的具体用法?C++ HandleObject::get怎么用?C++ HandleObject::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类js::HandleObject
的用法示例。
在下文中一共展示了HandleObject::get方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: v
bool
document_resolve(JSContext *cx, JS::HandleObject obj, JS::HandleId id, unsigned flags,
JS::MutableHandleObject objp)
{
// If id is "all", resolve document.all=true.
JS::RootedValue v(cx);
if (!JS_IdToValue(cx, id, &v))
return false;
if (JSVAL_IS_STRING(v)) {
JSString *str = JSVAL_TO_STRING(v);
JSFlatString *flatStr = JS_FlattenString(cx, str);
if (!flatStr)
return false;
if (JS_FlatStringEqualsAscii(flatStr, "all")) {
JS::Rooted<JSObject*> docAll(cx,
JS_NewObject(cx, &DocumentAllClass, JS::NullPtr(), JS::NullPtr()));
if (!docAll)
return false;
JS::Rooted<JS::Value> allValue(cx, ObjectValue(*docAll));
bool ok = JS_DefinePropertyById(cx, obj, id, allValue, nullptr, nullptr, 0);
objp.set(ok ? obj.get() : nullptr);
return ok;
}
}
objp.set(nullptr);
return true;
}
示例2: def_timestep_image_map_set_width
CEXPORT bool def_timestep_image_map_set_width(JSContext *cx, JS::HandleObject obj, JS::HandleId id, bool strict, JS::MutableHandleValue vp) {
JS_BeginRequest(cx);
timestep_image_map *thiz = (timestep_image_map*)JS_GetPrivate(obj.get());
if (thiz) {
thiz->width = vp.toInt32();
}
JS_EndRequest(cx);
return true;
}
示例3: def_timestep_image_map_get_y
CEXPORT bool def_timestep_image_map_get_y(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) {
JS_BeginRequest(cx);
timestep_image_map *thiz = (timestep_image_map*)JS_GetPrivate(obj.get());
if (thiz) {
vp.setInt32(thiz->y);
}
JS_EndRequest(cx);
return true;
}
示例4:
static JSBool js_cocos2dx_extension_WebSocket_get_readyState(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp)
{
JSObject* jsobj = obj.get();
js_proxy_t *proxy = jsb_get_js_proxy(jsobj);
WebSocket* cobj = (WebSocket *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
if (cobj) {
vp.set(INT_TO_JSVAL((int)cobj->getReadyState()));
return JS_TRUE;
} else {
JS_ReportError(cx, "Error: WebSocket instance is invalid.");
return JS_FALSE;
}
}
示例5: _js_get_SIOClient_tag
static bool _js_get_SIOClient_tag(JSContext* cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp)
{
CCLOG("JSB SocketIO.getTag method called");
JSObject* jsobj = obj.get();
js_proxy_t *proxy = jsb_get_js_proxy(jsobj);
SIOClient* cobj = (SIOClient *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object");
if (cobj) {
vp.set(std_string_to_jsval(cx, cobj->getTag()));
return true;
} else {
JS_ReportError(cx, "Error: SocketIO instance is invalid.");
return false;
}
}
示例6: prototype
void
gjs_define_param_class(JSContext *context,
JS::HandleObject in_object)
{
const char *constructor_name;
JS::RootedObject prototype(context), constructor(context);
GIObjectInfo *info;
constructor_name = "ParamSpec";
if (!gjs_init_class_dynamic(context, in_object, nullptr, "GObject",
constructor_name,
&gjs_param_class,
gjs_param_constructor, 0,
/* props of prototype */
&gjs_param_proto_props[0],
/* funcs of prototype */
&gjs_param_proto_funcs[0],
/* props of constructor, MyConstructor.myprop */
NULL,
/* funcs of constructor, MyConstructor.myfunc() */
gjs_param_constructor_funcs,
&prototype,
&constructor)) {
g_error("Can't init class %s", constructor_name);
}
JS::RootedObject gtype_obj(context,
gjs_gtype_create_gtype_wrapper(context, G_TYPE_PARAM));
JS_DefineProperty(context, constructor, "$gtype", gtype_obj, JSPROP_PERMANENT);
info = (GIObjectInfo*)g_irepository_find_by_gtype(g_irepository_get_default(), G_TYPE_PARAM);
gjs_object_define_static_methods(context, constructor, G_TYPE_PARAM, info);
g_base_info_unref( (GIBaseInfo*) info);
gjs_debug(GJS_DEBUG_GPARAM, "Defined class %s prototype is %p class %p in object %p",
constructor_name, prototype.get(), JS_GetClass(prototype),
in_object.get());
}
示例7: def_timestep_image_map_set_url
CEXPORT bool def_timestep_image_map_set_url(JSContext *cx, JS::HandleObject obj, JS::HandleId id, bool strict, JS::MutableHandleValue vp) {
JS_BeginRequest(cx);
timestep_image_map *thiz = (timestep_image_map*)JS_GetPrivate(obj.get());
if (thiz) {
if (vp.isString()) {
JSString *jstr = vp.toString();
JSTR_TO_CSTR_PERSIST(cx, jstr, cstr);
if (thiz->url) {
free(thiz->url);
}
thiz->url = cstr;
}
}
JS_EndRequest(cx);
return true;
}