Skip to content
This repository was archived by the owner on Apr 25, 2019. It is now read-only.

Commit 3ed1515

Browse files
committed
[WIP] Still converting the bindings to WebIDL
1 parent e654ec3 commit 3ed1515

22 files changed

+25623
-425
lines changed

Bindings/Bindings.idl

+823-34
Large diffs are not rendered by default.

Bindings/Wrapper.cpp

+104-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,46 @@
11
#include <string>
2+
#include <set>
3+
#include <map>
24
#include <GDCore/PlatformDefinition/Project.h>
35
#include <GDCore/PlatformDefinition/Layout.h>
6+
#include <GDCore/PlatformDefinition/Object.h>
7+
#include <GDCore/PlatformDefinition/Variable.h>
8+
#include <GDCore/PlatformDefinition/Automatism.h>
9+
#include <GDCore/PlatformDefinition/VariablesContainer.h>
10+
#include <GDCore/PlatformDefinition/Platform.h>
411
#include <GDCore/PlatformDefinition/InitialInstance.h>
512
#include <GDCore/PlatformDefinition/InitialInstancesContainer.h>
13+
#include <GDCore/Serialization/SerializerElement.h>
14+
#include <GDCore/Serialization/Serializer.h>
15+
16+
#include <GDCore/IDE/Dialogs/PropertyDescriptor.h>
17+
#include <GDCore/IDE/Dialogs/ObjectListDialogsHelper.h>
18+
#include <GDCore/IDE/TextFormatting.h>
19+
#include <GDCore/IDE/InstructionSentenceFormatter.h>
20+
#include <GDCore/IDE/EventsRefactorer.h>
21+
#include <GDCore/IDE/ProjectResourcesAdder.h>
22+
#include <GDCore/IDE/AbstractFileSystem.h>
23+
#include <GDCore/IDE/ArbitraryResourceWorker.h>
24+
#include <GDCore/IDE/MetadataProvider.h>
25+
#include <GDCore/IDE/EventsParametersLister.h>
26+
#include <GDCore/IDE/ArbitraryEventsWorker.h>
27+
28+
#include <GDJS/EventsCodeGenerator.h>
29+
#include <GDCore/Events/Builtin/StandardEvent.h>
30+
#include <GDCore/Events/Builtin/CommentEvent.h>
31+
#include <GDCore/Events/Builtin/ForEachEvent.h>
32+
#include <GDCore/Events/Builtin/WhileEvent.h>
33+
#include <GDCore/Events/Builtin/RepeatEvent.h>
34+
#include <GDCore/Events/Builtin/GroupEvent.h>
35+
36+
#include <GDCore/BuiltinExtensions/SpriteExtension/SpriteObject.h>
37+
#include <GDCore/BuiltinExtensions/SpriteExtension/Animation.h>
38+
#include <GDCore/BuiltinExtensions/SpriteExtension/Direction.h>
39+
#include <GDCore/BuiltinExtensions/SpriteExtension/Sprite.h>
40+
41+
#include "../../Extensions/TiledSpriteObject/TiledSpriteObject.h"
42+
#include "../../Extensions/TextObject/TextObject.h"
43+
644
#include "ProjectHelper.h"
745

846
class InitialInstanceJSFunctorWrapper : public gd::InitialInstanceFunctor {
@@ -17,17 +55,80 @@ class InitialInstanceJSFunctorWrapper : public gd::InitialInstanceFunctor {
1755
};
1856
};
1957

20-
//Declares typedef for std::vector
58+
//Declares typedef for std::vector and templatized types
2159
typedef std::vector<std::string> VectorString;
60+
typedef std::pair<std::string, gd::Variable> PairStringVariable;
61+
typedef std::pair<std::string, TextFormatting> PairStringTextFormatting;
62+
typedef std::vector<std::pair<std::string, TextFormatting>> VectorPairStringTextFormatting;
63+
typedef std::map<std::string, std::string> MapStringString;
64+
typedef std::map<std::string, gd::ExpressionMetadata> MapStringExpressionMetadata;
65+
typedef std::map<std::string, gd::InstructionMetadata> MapStringInstructionMetadata;
66+
typedef std::map<std::string, gd::EventMetadata> MapStringEventMetadata;
67+
typedef std::map<std::string, gd::PropertyDescriptor> MapStringPropertyDescriptor;
68+
typedef std::set<std::string> SetString;
69+
typedef gd::Object gdObject; //To avoid clashing javascript Object in glue.js
2270

2371
//Customize some functions implementation thanks to WRAPPED_* macros
2472
//The original names will be reconstructed in the js file (see postjs.js)
2573
#define WRAPPED_set(a, b) at(a) = b
74+
#define WRAPPED_GetString(i) at(i).first
75+
#define WRAPPED_GetComment() com1
76+
#define WRAPPED_SetComment(str) com1 = str
77+
#define WRAPPED_GetTextFormatting(i) at(i).second
78+
#define WRAPPED_GetName() first
79+
#define WRAPPED_GetVariable() second
80+
81+
#define MAP_get(a) find(a)->second;
82+
#define MAP_set(key, value) [key] = value
83+
#define MAP_has(key) find(key) != self->end()
84+
2685
#define STATIC_CreateNewGDJSProject CreateNewGDJSProject
2786
#define STATIC_InitializePlatforms InitializePlatforms
87+
#define STATIC_ValidateObjectName ValidateObjectName
88+
#define STATIC_ToJSON ToJSON
89+
#define STATIC_FromJSON FromJSON
90+
#define STATIC_IsObject IsObject
91+
#define STATIC_Get Get
92+
#define STATIC_AddAllMissingImages AddAllMissingImages
93+
#define STATIC_GetAllUselessResources GetAllUselessResources
94+
#define STATIC_RemoveAllUselessResources RemoveAllUselessResources
95+
#define STATIC_HasCondition HasCondition
96+
#define STATIC_HasAction HasAction
97+
#define STATIC_HasObjectAction HasObjectAction
98+
#define STATIC_HasObjectCondition HasObjectCondition
99+
#define STATIC_HasAutomatismAction HasAutomatismAction
100+
#define STATIC_HasAutomatismCondition HasAutomatismCondition
101+
#define STATIC_HasExpression HasExpression
102+
#define STATIC_HasObjectExpression HasObjectExpression
103+
#define STATIC_HasAutomatismExpression HasAutomatismExpression
104+
#define STATIC_HasStrExpression HasStrExpression
105+
#define STATIC_HasObjectStrExpression HasObjectStrExpression
106+
#define STATIC_HasAutomatismStrExpression HasAutomatismStrExpression
107+
#define STATIC_RenameObjectInEvents RenameObjectInEvents
108+
#define STATIC_RemoveObjectInEvents RemoveObjectInEvents
109+
#define STATIC_ReplaceStringInEvents ReplaceStringInEvents
110+
#define STATIC_GetAutomatismMetadata GetAutomatismMetadata
111+
#define STATIC_GetObjectMetadata GetObjectMetadata
112+
#define STATIC_GetActionMetadata GetActionMetadata
113+
#define STATIC_GetConditionMetadata GetConditionMetadata
114+
#define STATIC_GetExpressionMetadata GetExpressionMetadata
115+
#define STATIC_GetObjectExpressionMetadata GetObjectExpressionMetadata
116+
#define STATIC_GetAutomatismExpressionMetadata GetAutomatismExpressionMetadata
117+
#define STATIC_GetStrExpressionMetadata GetStrExpressionMetadata
118+
#define STATIC_GetObjectStrExpressionMetadata GetObjectStrExpressionMetadata
119+
#define STATIC_GetAutomatismStrExpressionMetadata GetAutomatismStrExpressionMetadata
120+
#define STATIC_GenerateSceneEventsCompleteCode GenerateSceneEventsCompleteCode
121+
122+
//We postfix some methods with "At" as Javacsript does not support overloading
123+
#define GetLayoutAt GetLayout
124+
#define GetLayerAt GetLayer
125+
#define GetObjectAt GetObject
126+
#define GetAt Get
127+
#define GetEventAt GetEvent
128+
#define RemoveEventAt RemoveEvent
28129

29-
// We don't use prefix in .idl file to workaround a webidl_binder.py bug
30-
// that can't find in its list of interfaces a class which has a prefix.
130+
//We don't use prefix in .idl file to workaround a webidl_binder.py bug
131+
//that can't find in its list of interfaces a class which has a prefix.
31132
using namespace gd;
32133
using namespace std;
33134
#include "glue.cpp"

0 commit comments

Comments
 (0)