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:
Ykkrosh
2010-10-21 19:54:59 +00:00
parent 55741aed44
commit c0a7a36f7a
14 changed files with 124 additions and 394 deletions
-29
View File
@@ -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()));
}