Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/scriptinterface/ScriptInterface.cpp
Show First 20 Lines • Show All 573 Lines • ▼ Show 20 Lines | bool ScriptInterface::CallFunction_(JS::HandleValue val, const char* name, JS::HandleValueArray argv, JS::MutableHandleValue ret) const | ||||
if (!JS_HasProperty(m->m_cx, obj, name, &found) || !found) | if (!JS_HasProperty(m->m_cx, obj, name, &found) || !found) | ||||
return false; | return false; | ||||
bool ok = JS_CallFunctionName(m->m_cx, obj, name, argv, ret); | bool ok = JS_CallFunctionName(m->m_cx, obj, name, argv, ret); | ||||
return ok; | return ok; | ||||
} | } | ||||
bool ScriptInterface::CreateObject(JS::MutableHandleValue objectValue) const | |||||
{ | |||||
JSContext* cx = GetContext(); | |||||
JSAutoRequest rq(cx); | |||||
objectValue.setObjectOrNull(JS_NewPlainObject(cx)); | |||||
if (!objectValue.isObject()) | |||||
throw PSERROR_Scripting_CreateObjectFailed(); | |||||
return true; | |||||
} | |||||
void ScriptInterface::CreateArray(JS::MutableHandleValue objectValue, size_t length) const | |||||
{ | |||||
JSContext* cx = GetContext(); | |||||
JSAutoRequest rq(cx); | |||||
objectValue.setObjectOrNull(JS_NewArrayObject(cx, length)); | |||||
if (!objectValue.isObject()) | |||||
throw PSERROR_Scripting_CreateObjectFailed(); | |||||
} | |||||
JS::Value ScriptInterface::GetGlobalObject() const | JS::Value ScriptInterface::GetGlobalObject() const | ||||
{ | { | ||||
JSAutoRequest rq(m->m_cx); | JSAutoRequest rq(m->m_cx); | ||||
return JS::ObjectValue(*JS::CurrentGlobalOrNull(m->m_cx)); | return JS::ObjectValue(*JS::CurrentGlobalOrNull(m->m_cx)); | ||||
} | } | ||||
bool ScriptInterface::SetGlobal_(const char* name, JS::HandleValue value, bool replace, bool constant, bool enumerate) | bool ScriptInterface::SetGlobal_(const char* name, JS::HandleValue value, bool replace, bool constant, bool enumerate) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 565 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator