Unify script conversions and remove JSInterface_Vector3D.
Because it was historically grown, we have some duplicated code for converting script types to native types. This patch removes the file JSConversions.cpp and moves some code to ScriptConversions.cpp. The places using JSConversions.cpp are changed to use the ScriptInterface's conversion functions in ScriptConversions.cpp. I also removed JSInterface_Vector3D because it had additional requirements to the conversion code that no other code has and because it's currently not used. I think it doesn't make sense to maintain code just because it could possibly be used again later. Closes #2213 Refs #1886 This was SVN commit r14036.
This commit is contained in:
1 parent
a4cd90ddfc
commit
20ed5b118c
9 files changed
+104
-791
No files matched your search
@@ -24,7 +24,6 @@
|
||||
#include "precompiled.h"
|
||||
|
||||
#include "ScriptGlue.h"
|
||||
#include "JSConversions.h"
|
||||
|
||||
#include "graphics/GameView.h"
|
||||
#include "graphics/LightEnv.h"
|
||||
@@ -37,7 +36,6 @@
|
||||
#include "lib/svn_revision.h"
|
||||
#include "lib/timer.h"
|
||||
#include "lib/sysdep/sysdep.h" // sys_OpenFile
|
||||
#include "maths/scripting/JSInterface_Vector3D.h"
|
||||
#include "network/NetServer.h"
|
||||
#include "ps/CConsole.h"
|
||||
#include "ps/CLogger.h"
|
||||
@@ -111,7 +109,8 @@ JSBool StartJsTimer(JSContext* cx, uintN argc, jsval* vp)
|
||||
ONCE(InitJsTimers());
|
||||
|
||||
JSU_REQUIRE_PARAMS(1);
|
||||
size_t slot = ToPrimitive<size_t>(JS_ARGV(cx, vp)[0]);
|
||||
size_t slot;
|
||||
ScriptInterface::FromJSVal(cx, JS_ARGV(cx, vp)[0], slot);
|
||||
if (slot >= MAX_JS_TIMERS)
|
||||
return JS_FALSE;
|
||||
|
||||
@@ -125,7 +124,8 @@ JSBool StartJsTimer(JSContext* cx, uintN argc, jsval* vp)
|
||||
JSBool StopJsTimer(JSContext* cx, uintN argc, jsval* vp)
|
||||
{
|
||||
JSU_REQUIRE_PARAMS(1);
|
||||
size_t slot = ToPrimitive<size_t>(JS_ARGV(cx, vp)[0]);
|
||||
size_t slot;
|
||||
ScriptInterface::FromJSVal(cx, JS_ARGV(cx, vp)[0], slot);
|
||||
if (slot >= MAX_JS_TIMERS)
|
||||
return JS_FALSE;
|
||||
|
||||
@@ -215,7 +215,8 @@ JSBool GetGUIObjectByName(JSContext* cx, uintN argc, jsval* vp)
|
||||
|
||||
try
|
||||
{
|
||||
CStr name = ToPrimitive<CStr>(cx, JS_ARGV(cx, vp)[0]);
|
||||
CStr name;
|
||||
ScriptInterface::FromJSVal(cx, JS_ARGV(cx, vp)[0], name);
|
||||
IGUIObject* guiObj = g_GUI->FindObjectByName(name);
|
||||
if (guiObj)
|
||||
JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(guiObj->GetJSObject()));
|
||||
@@ -340,7 +341,7 @@ JSBool SetPaused(JSContext* cx, uintN argc, jsval* vp)
|
||||
|
||||
try
|
||||
{
|
||||
g_Game->m_Paused = ToPrimitive<bool> (JS_ARGV(cx, vp)[0]);
|
||||
ScriptInterface::FromJSVal(cx, JS_ARGV(cx, vp)[0], g_Game->m_Paused);
|
||||
|
||||
if ( g_SoundManager )
|
||||
g_SoundManager->Pause(g_Game->m_Paused);
|
||||
|
||||
Reference in new issue
Block a user