Changeset View
Changeset View
Standalone View
Standalone View
source/scriptinterface/ScriptInterface.cpp
Show First 20 Lines • Show All 638 Lines • ▼ Show 20 Lines | bool ScriptInterface::SetPropertyInt_(JS::HandleValue obj, int name, JS::HandleValue value, bool constant, bool enumerate) const | ||||
if (!obj.isObject()) | if (!obj.isObject()) | ||||
return false; | return false; | ||||
JS::RootedObject object(rq.cx, &obj.toObject()); | JS::RootedObject object(rq.cx, &obj.toObject()); | ||||
JS::RootedId id(rq.cx, INT_TO_JSID(name)); | JS::RootedId id(rq.cx, INT_TO_JSID(name)); | ||||
return JS_DefinePropertyById(rq.cx, object, id, value, attrs); | return JS_DefinePropertyById(rq.cx, object, id, value, attrs); | ||||
} | } | ||||
bool ScriptInterface::GetProperty(JS::HandleValue obj, const char* name, JS::MutableHandleValue out) const | bool ScriptInterface::GetProperty(JS::HandleValue obj, const char* name, JS::MutableHandleObject out) const | ||||
{ | { | ||||
return GetProperty_(obj, name, out); | ScriptRequest rq(this); | ||||
return GetProperty(rq, obj, name, out); | |||||
} | } | ||||
bool ScriptInterface::GetProperty(JS::HandleValue obj, const char* name, JS::MutableHandleObject out) const | bool ScriptInterface::GetProperty(const ScriptRequest& rq, JS::HandleValue obj, const char* name, JS::MutableHandleObject out) | ||||
{ | { | ||||
ScriptRequest rq(this); | |||||
JS::RootedValue val(rq.cx); | JS::RootedValue val(rq.cx); | ||||
if (!GetProperty_(obj, name, &val)) | if (!GetProperty(rq, obj, name, &val)) | ||||
return false; | return false; | ||||
if (!val.isObject()) | if (!val.isObject()) | ||||
{ | { | ||||
LOGERROR("GetProperty failed: trying to get an object, but the property is not an object!"); | LOGERROR("GetProperty failed: trying to get an object, but the property is not an object!"); | ||||
return false; | return false; | ||||
} | } | ||||
out.set(&val.toObject()); | out.set(&val.toObject()); | ||||
return true; | return true; | ||||
} | } | ||||
bool ScriptInterface::GetPropertyInt(JS::HandleValue obj, int name, JS::MutableHandleValue out) const | bool ScriptInterface::GetProperty(JS::HandleValue obj, const char* name, JS::MutableHandleValue out) const | ||||
{ | { | ||||
return GetPropertyInt_(obj, name, out); | ScriptRequest rq(this); | ||||
return GetProperty(rq, obj, name, out); | |||||
} | } | ||||
bool ScriptInterface::GetProperty_(JS::HandleValue obj, const char* name, JS::MutableHandleValue out) const | bool ScriptInterface::GetProperty(const ScriptRequest& rq, JS::HandleValue obj, const char* name, JS::MutableHandleValue out) | ||||
{ | { | ||||
ScriptRequest rq(this); | |||||
if (!obj.isObject()) | if (!obj.isObject()) | ||||
return false; | return false; | ||||
JS::RootedObject object(rq.cx, &obj.toObject()); | JS::RootedObject object(rq.cx, &obj.toObject()); | ||||
return JS_GetProperty(rq.cx, object, name, out); | return JS_GetProperty(rq.cx, object, name, out); | ||||
} | } | ||||
bool ScriptInterface::GetPropertyInt_(JS::HandleValue obj, int name, JS::MutableHandleValue out) const | bool ScriptInterface::GetPropertyInt(JS::HandleValue obj, int name, JS::MutableHandleValue out) const | ||||
{ | { | ||||
ScriptRequest rq(this); | ScriptRequest rq(this); | ||||
return GetPropertyInt(rq,obj, name, out); | |||||
} | |||||
bool ScriptInterface::GetPropertyInt(const ScriptRequest& rq, JS::HandleValue obj, int name, JS::MutableHandleValue out) | |||||
{ | |||||
JS::RootedId nameId(rq.cx, INT_TO_JSID(name)); | JS::RootedId nameId(rq.cx, INT_TO_JSID(name)); | ||||
if (!obj.isObject()) | if (!obj.isObject()) | ||||
return false; | return false; | ||||
JS::RootedObject object(rq.cx, &obj.toObject()); | JS::RootedObject object(rq.cx, &obj.toObject()); | ||||
return JS_GetPropertyById(rq.cx, object, nameId, out); | return JS_GetPropertyById(rq.cx, object, nameId, out); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 358 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator