mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-07-04 05:55:47 -07:00
Use ToJSVal for JS_NewStringCopyZ to improve encapsulation and consistency and remove a snprintf call.
This was SVN commit r22536.
This commit is contained in:
parent
cbcd1bbde0
commit
62f83eb673
2 changed files with 3 additions and 7 deletions
|
|
@ -118,11 +118,10 @@ bool JSI_GUISize::toString(JSContext* cx, uint argc, JS::Value* vp)
|
|||
}
|
||||
catch (PSERROR_Scripting_ConversionFailed&)
|
||||
{
|
||||
rec.rval().setString(JS_NewStringCopyZ(cx, "<Error converting value to numbers>"));
|
||||
ScriptInterface::ToJSVal(cx, rec.rval(), std::string("<Error converting value to numbers>"));
|
||||
return true;
|
||||
}
|
||||
|
||||
rec.rval().setString(JS_NewStringCopyZ(cx, buffer.c_str()));
|
||||
ScriptInterface::ToJSVal(cx, rec.rval(), buffer);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -591,10 +591,7 @@ bool JSI_IGUIObject::toString(JSContext* cx, uint UNUSED(argc), JS::Value* vp)
|
|||
if (!e)
|
||||
return false;
|
||||
|
||||
char buffer[256];
|
||||
snprintf(buffer, 256, "[GUIObject: %s]", e->GetName().c_str());
|
||||
buffer[255] = 0;
|
||||
rec.rval().setString(JS_NewStringCopyZ(cx, buffer));
|
||||
ScriptInterface::ToJSVal(cx, rec.rval(), "[GUIObject: " + e->GetName() + "]");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue