- Get/SetGlobal() added
- Made CreateCustomObject call the constructor (JS_NewObject => JS_ConstructObject) - Made the JS error reporter work even before the console has been constructed This was SVN commit r620.
This commit is contained in:
parent
b137e965f3
commit
3109d4361a
@ -231,7 +231,7 @@ JSObject * ScriptingHost::CreateCustomObject(const std::string & typeName)
|
||||
throw std::string("Tried to create a type that doesn't exist");
|
||||
}
|
||||
|
||||
return JS_NewObject(m_Context, (*it).second.m_Class, (*it).second.m_Object, NULL);
|
||||
return JS_ConstructObject(m_Context, (*it).second.m_Class, (*it).second.m_Object, NULL);
|
||||
|
||||
}
|
||||
|
||||
@ -247,6 +247,18 @@ jsval ScriptingHost::GetObjectProperty( JSObject* object, const std::string& pro
|
||||
return( vp );
|
||||
}
|
||||
|
||||
void ScriptingHost::SetGlobal(const std::string &globalName, jsval value)
|
||||
{
|
||||
JS_SetProperty(m_Context, m_GlobalObject, globalName.c_str(), &value);
|
||||
}
|
||||
|
||||
jsval ScriptingHost::GetGlobal(const std::string &globalName)
|
||||
{
|
||||
jsval vp;
|
||||
JS_GetProperty(m_Context, m_GlobalObject, globalName.c_str(), &vp);
|
||||
return vp;
|
||||
}
|
||||
|
||||
int ScriptingHost::ValueToInt(const jsval value)
|
||||
{
|
||||
int32 i = 0;
|
||||
@ -298,13 +310,16 @@ double ScriptingHost::ValueToDouble(const jsval value)
|
||||
|
||||
void ScriptingHost::ErrorReporter(JSContext * context, const char * message, JSErrorReport * report)
|
||||
{
|
||||
g_Console->InsertMessage( L"%S ( %d )", report->filename, report->lineno );
|
||||
if( message )
|
||||
if (g_Console)
|
||||
{
|
||||
g_Console->InsertMessage( L"%S", message );
|
||||
g_Console->InsertMessage( L"%S ( %d )", report->filename, report->lineno );
|
||||
if( message )
|
||||
{
|
||||
g_Console->InsertMessage( L"%S", message );
|
||||
}
|
||||
else
|
||||
g_Console->InsertMessage( L"No error message available" );
|
||||
}
|
||||
else
|
||||
g_Console->InsertMessage( L"No error message available" );
|
||||
|
||||
if (report->filename != NULL)
|
||||
{
|
||||
|
@ -72,6 +72,9 @@ public:
|
||||
void SetObjectProperty(JSObject * object, const std::string & propertyName, jsval value);
|
||||
jsval GetObjectProperty( JSObject* object, const std::string& propertyName );
|
||||
|
||||
void SetGlobal(const std::string& globalName, jsval value);
|
||||
jsval GetGlobal(const std::string& globalName);
|
||||
|
||||
int ValueToInt(const jsval value);
|
||||
bool ValueToBool(const jsval value);
|
||||
std::string ValueToString(const jsval value);
|
||||
|
Loading…
Reference in New Issue
Block a user