forked from mirrors/0ad
Rename JSInterface_GUITypes to JSInterface_GUISize, refs 8734efca94, 9be8a560a9.
Rename init to RegisterScriptClass. Differential Revision: https://code.wildfiregames.com/D2339 Tested on: clang 8.0.1., Jenkins/vs2015 This was SVN commit r23018.
This commit is contained in:
@@ -19,7 +19,7 @@
|
||||
|
||||
#include "GUIbase.h"
|
||||
|
||||
#include "gui/scripting/JSInterface_GUITypes.h"
|
||||
#include "gui/scripting/JSInterface_GUISize.h"
|
||||
#include "ps/CLogger.h"
|
||||
|
||||
CClientArea::CClientArea() : pixel(0.f,0.f,0.f,0.f), percent(0.f,0.f,0.f,0.f)
|
||||
|
||||
@@ -17,12 +17,10 @@
|
||||
|
||||
#include "precompiled.h"
|
||||
|
||||
#include "gui/IGUIObject.h"
|
||||
#include "IGUIObject.h"
|
||||
|
||||
#include "gui/CGUI.h"
|
||||
#include "gui/CGUISetting.h"
|
||||
#include "gui/scripting/JSInterface_GUITypes.h"
|
||||
#include "gui/scripting/JSInterface_IGUIObject.h"
|
||||
#include "ps/CLogger.h"
|
||||
#include "ps/GameSetup/Config.h"
|
||||
#include "ps/Profile.h"
|
||||
|
||||
+7
-7
@@ -17,7 +17,7 @@
|
||||
|
||||
#include "precompiled.h"
|
||||
|
||||
#include "JSInterface_GUITypes.h"
|
||||
#include "JSInterface_GUISize.h"
|
||||
|
||||
#include "ps/CStr.h"
|
||||
#include "scriptinterface/ScriptInterface.h"
|
||||
@@ -36,6 +36,11 @@ JSFunctionSpec JSI_GUISize::JSI_methods[] =
|
||||
JS_FS_END
|
||||
};
|
||||
|
||||
void JSI_GUISize::RegisterScriptClass(ScriptInterface& scriptInterface)
|
||||
{
|
||||
scriptInterface.DefineCustomObjectType(&JSI_GUISize::JSI_class, JSI_GUISize::construct, 0, nullptr, JSI_GUISize::JSI_methods, nullptr, nullptr);
|
||||
}
|
||||
|
||||
bool JSI_GUISize::construct(JSContext* cx, uint argc, JS::Value* vp)
|
||||
{
|
||||
JSAutoRequest rq(cx);
|
||||
@@ -84,7 +89,7 @@ bool JSI_GUISize::construct(JSContext* cx, uint argc, JS::Value* vp)
|
||||
}
|
||||
|
||||
// Produces "10", "-10", "50%", "50%-10", "50%+10", etc
|
||||
CStr ToPercentString(double pix, double per)
|
||||
CStr JSI_GUISize::ToPercentString(double pix, double per)
|
||||
{
|
||||
if (per == 0)
|
||||
return CStr::FromDouble(pix);
|
||||
@@ -118,8 +123,3 @@ bool JSI_GUISize::toString(JSContext* cx, uint argc, JS::Value* vp)
|
||||
ScriptInterface::ToJSVal(cx, args.rval(), buffer);
|
||||
return true;
|
||||
}
|
||||
|
||||
void JSI_GUITypes::init(ScriptInterface& scriptInterface)
|
||||
{
|
||||
scriptInterface.DefineCustomObjectType(&JSI_GUISize::JSI_class, JSI_GUISize::construct, 1, nullptr, JSI_GUISize::JSI_methods, nullptr, nullptr);
|
||||
}
|
||||
+15
-19
@@ -15,28 +15,24 @@
|
||||
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef INCLUDED_JSI_GUITYPES
|
||||
#define INCLUDED_JSI_GUITYPES
|
||||
#ifndef INCLUDED_JSI_GUISIZE
|
||||
#define INCLUDED_JSI_GUISIZE
|
||||
|
||||
#include "scriptinterface/ScriptInterface.h"
|
||||
#include "ps/CStr.h"
|
||||
|
||||
#define GUISTDTYPE(x) \
|
||||
namespace JSI_GUI##x \
|
||||
{ \
|
||||
extern JSClass JSI_class; \
|
||||
extern JSPropertySpec JSI_props[]; \
|
||||
extern JSFunctionSpec JSI_methods[]; \
|
||||
bool construct(JSContext* cx, uint argc, JS::Value* vp); \
|
||||
bool toString(JSContext* cx, uint argc, JS::Value* vp); \
|
||||
}
|
||||
|
||||
GUISTDTYPE(Size)
|
||||
|
||||
#undef GUISTDTYPE // avoid unnecessary pollution
|
||||
|
||||
namespace JSI_GUITypes
|
||||
namespace JSI_GUISize
|
||||
{
|
||||
void init(ScriptInterface& scriptInterface);
|
||||
extern JSClass JSI_class;
|
||||
extern JSPropertySpec JSI_props[];
|
||||
extern JSFunctionSpec JSI_methods[];
|
||||
|
||||
void RegisterScriptClass(ScriptInterface& scriptInterface);
|
||||
|
||||
bool construct(JSContext* cx, uint argc, JS::Value* vp);
|
||||
bool toString(JSContext* cx, uint argc, JS::Value* vp);
|
||||
|
||||
CStr ToPercentString(double pix, double per);
|
||||
}
|
||||
|
||||
#endif // INCLUDED_JSI_GUITYPES
|
||||
#endif // INCLUDED_JSI_GUISIZE
|
||||
@@ -20,13 +20,8 @@
|
||||
#include "JSInterface_IGUIObject.h"
|
||||
|
||||
#include "gui/CGUI.h"
|
||||
#include "gui/CGUIColor.h"
|
||||
#include "gui/CGUISetting.h"
|
||||
#include "gui/CList.h"
|
||||
#include "gui/GUIManager.h"
|
||||
#include "gui/IGUIObject.h"
|
||||
#include "gui/IGUIScrollBar.h"
|
||||
#include "gui/scripting/JSInterface_GUITypes.h"
|
||||
#include "scriptinterface/ScriptExtraHeaders.h"
|
||||
#include "scriptinterface/ScriptInterface.h"
|
||||
|
||||
@@ -47,6 +42,11 @@ JSFunctionSpec JSI_IGUIObject::JSI_methods[] =
|
||||
JS_FS_END
|
||||
};
|
||||
|
||||
void JSI_IGUIObject::RegisterScriptClass(ScriptInterface& scriptInterface)
|
||||
{
|
||||
scriptInterface.DefineCustomObjectType(&JSI_class, nullptr, 0, nullptr, JSI_methods, nullptr, nullptr);
|
||||
}
|
||||
|
||||
bool JSI_IGUIObject::getProperty(JSContext* cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp)
|
||||
{
|
||||
JSAutoRequest rq(cx);
|
||||
@@ -174,11 +174,6 @@ bool JSI_IGUIObject::setProperty(JSContext* cx, JS::HandleObject obj, JS::Handle
|
||||
return result.fail(JSMSG_UNDEFINED_PROP);
|
||||
}
|
||||
|
||||
void JSI_IGUIObject::init(ScriptInterface& scriptInterface)
|
||||
{
|
||||
scriptInterface.DefineCustomObjectType(&JSI_class, nullptr, 1, nullptr, JSI_methods, nullptr, nullptr);
|
||||
}
|
||||
|
||||
bool JSI_IGUIObject::toString(JSContext* cx, uint argc, JS::Value* vp)
|
||||
{
|
||||
// No JSAutoRequest needed for these calls
|
||||
|
||||
@@ -24,6 +24,9 @@ namespace JSI_IGUIObject
|
||||
{
|
||||
extern JSClass JSI_class;
|
||||
extern JSFunctionSpec JSI_methods[];
|
||||
|
||||
void RegisterScriptClass(ScriptInterface& scriptInterface);
|
||||
|
||||
bool getProperty(JSContext* cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp);
|
||||
bool setProperty(JSContext* cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp, JS::ObjectOpResult& result);
|
||||
bool toString(JSContext* cx, uint argc, JS::Value* vp);
|
||||
@@ -31,7 +34,6 @@ namespace JSI_IGUIObject
|
||||
bool blur(JSContext* cx, uint argc, JS::Value* vp);
|
||||
bool getComputedSize(JSContext* cx, uint argc, JS::Value* vp);
|
||||
bool getTextSize(JSContext* cx, uint argc, JS::Value* vp);
|
||||
void init(ScriptInterface& scriptInterface);
|
||||
}
|
||||
|
||||
#endif // INCLUDED_JSI_IGUIOBJECT
|
||||
|
||||
@@ -20,9 +20,9 @@
|
||||
#include "ScriptFunctions.h"
|
||||
|
||||
#include "graphics/scripting/JSInterface_GameView.h"
|
||||
#include "gui/IGUIObject.h"
|
||||
#include "gui/scripting/JSInterface_GUIManager.h"
|
||||
#include "gui/scripting/JSInterface_GUITypes.h"
|
||||
#include "gui/scripting/JSInterface_GUISize.h"
|
||||
#include "gui/scripting/JSInterface_IGUIObject.h"
|
||||
#include "i18n/scripting/JSInterface_L10n.h"
|
||||
#include "lobby/scripting/JSInterface_Lobby.h"
|
||||
#include "network/scripting/JSInterface_Network.h"
|
||||
@@ -50,8 +50,8 @@
|
||||
*/
|
||||
void GuiScriptingInit(ScriptInterface& scriptInterface)
|
||||
{
|
||||
JSI_IGUIObject::init(scriptInterface);
|
||||
JSI_GUITypes::init(scriptInterface);
|
||||
JSI_GUISize::RegisterScriptClass(scriptInterface);
|
||||
JSI_IGUIObject::RegisterScriptClass(scriptInterface);
|
||||
|
||||
JSI_ConfigDB::RegisterScriptFunctions(scriptInterface);
|
||||
JSI_Console::RegisterScriptFunctions(scriptInterface);
|
||||
|
||||
Reference in New Issue
Block a user