mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-07-25 01:52:31 +00:00
Use JSFastNative API in more places, for improved compatibility with future SpiderMonkey versions.
Remove some unnecessary script-exposed functions, and move some more into the Engine namespace. This was SVN commit r8428.
This commit is contained in:
@@ -100,18 +100,6 @@ void ScriptingHost::RunScript(const VfsPath& pathname, JSObject* globalObject)
|
||||
throw PSERROR_Scripting_LoadFile_EvalErrors();
|
||||
}
|
||||
|
||||
jsval ScriptingHost::CallFunction(const std::string & functionName, jsval * params, int numParams)
|
||||
{
|
||||
jsval result;
|
||||
|
||||
JSBool ok = JS_CallFunctionName(m_Context, m_GlobalObject, functionName.c_str(), numParams, params, &result);
|
||||
|
||||
if (ok == JS_FALSE)
|
||||
throw PSERROR_Scripting_CallFunctionFailed();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
jsval ScriptingHost::ExecuteScript(const CStrW& script, const CStrW& calledFrom, JSObject* contextObject )
|
||||
{
|
||||
jsval rval;
|
||||
@@ -124,18 +112,6 @@ jsval ScriptingHost::ExecuteScript(const CStrW& script, const CStrW& calledFrom,
|
||||
return rval;
|
||||
}
|
||||
|
||||
void ScriptingHost::DefineConstant(const std::string & name, int value)
|
||||
{
|
||||
// First remove this constant if it already exists
|
||||
JS_DeleteProperty(m_Context, m_GlobalObject, name.c_str());
|
||||
|
||||
JSBool ok = JS_DefineProperty( m_Context, m_GlobalObject, name.c_str(), INT_TO_JSVAL(value),
|
||||
NULL, NULL, JSPROP_READONLY);
|
||||
|
||||
if (ok == JS_FALSE)
|
||||
throw PSERROR_Scripting_DefineConstantFailed();
|
||||
}
|
||||
|
||||
void ScriptingHost::DefineCustomObjectType(JSClass *clasp, JSNative constructor, uintN minArgs, JSPropertySpec *ps, JSFunctionSpec *fs, JSPropertySpec *static_ps, JSFunctionSpec *static_fs)
|
||||
{
|
||||
std::string typeName = clasp->name;
|
||||
@@ -246,8 +222,3 @@ CStrW ScriptingHost::ValueToUCString( const jsval value )
|
||||
size_t length=JS_GetStringLength(string);
|
||||
return std::wstring(strptr, strptr+length);
|
||||
}
|
||||
|
||||
jsval ScriptingHost::UCStringToValue( const CStrW& str )
|
||||
{
|
||||
return STRING_TO_JSVAL(JS_NewUCStringCopyZ(m_Context, str.utf16().c_str()));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user