Changeset View
Changeset View
Standalone View
Standalone View
source/scriptinterface/ScriptInterface.cpp
Show First 20 Lines • Show All 561 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::MutableHandleObject object) const | bool ScriptInterface::CreateObject_(JSContext* cx, JS::MutableHandleObject object) | ||||
{ | { | ||||
// JSAutoRequest is the responsibility of the caller | // JSAutoRequest is the responsibility of the caller | ||||
object.set(JS_NewPlainObject(GetContext())); | object.set(JS_NewPlainObject(cx)); | ||||
if (!object) | if (!object) | ||||
throw PSERROR_Scripting_CreateObjectFailed(); | throw PSERROR_Scripting_CreateObjectFailed(); | ||||
return true; | return true; | ||||
} | } | ||||
void ScriptInterface::CreateArray(JS::MutableHandleValue objectValue, size_t length) const | void ScriptInterface::CreateArray(JSContext* cx, JS::MutableHandleValue objectValue, size_t length) | ||||
{ | { | ||||
JSContext* cx = GetContext(); | |||||
JSAutoRequest rq(cx); | JSAutoRequest rq(cx); | ||||
objectValue.setObjectOrNull(JS_NewArrayObject(cx, length)); | objectValue.setObjectOrNull(JS_NewArrayObject(cx, length)); | ||||
if (!objectValue.isObject()) | if (!objectValue.isObject()) | ||||
throw PSERROR_Scripting_CreateObjectFailed(); | throw PSERROR_Scripting_CreateObjectFailed(); | ||||
} | } | ||||
JS::Value ScriptInterface::GetGlobalObject() const | JS::Value ScriptInterface::GetGlobalObject() const | ||||
▲ Show 20 Lines • Show All 557 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator