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

Commit

Permalink
Merge pull request #6 from 4ian/feature/events-function-extension
Browse files Browse the repository at this point in the history
Feature/events function extension
  • Loading branch information
4ian authored Oct 8, 2018
2 parents ca9dd8b + 1a42746 commit 5c87b37
Show file tree
Hide file tree
Showing 6 changed files with 960 additions and 62 deletions.
105 changes: 97 additions & 8 deletions Bindings/Bindings.idl
Original file line number Diff line number Diff line change
Expand Up @@ -111,22 +111,23 @@ interface Platform {
[Const, Value] DOMString GetSubtitle();
[Const, Value] DOMString GetDescription();
boolean IsExtensionLoaded([Const] DOMString name);
void RemoveExtension([Const] DOMString name);

[Const, Ref] VectorPlatformExtension GetAllPlatformExtensions();
//TODO:
//createObject
};

interface JsPlatform {
[Ref] JsPlatform STATIC_Get();
void AddNewExtension([Const, Ref] PlatformExtension extension);


// Inherited from Platform:
[Const, Value] DOMString GetName();
[Const, Value] DOMString GetFullName();
[Const, Value] DOMString GetSubtitle();
[Const, Value] DOMString GetDescription();
boolean IsExtensionLoaded([Const] DOMString name);
void RemoveExtension([Const] DOMString name);

[Const, Ref] VectorPlatformExtension GetAllPlatformExtensions();
};
Expand Down Expand Up @@ -322,6 +323,14 @@ interface Project {
[Ref] ExternalLayout InsertNewExternalLayout([Const] DOMString name, unsigned long position);
void RemoveExternalLayout([Const] DOMString name);

boolean HasEventsFunctionsExtensionNamed([Const] DOMString name);
[Ref] EventsFunctionsExtension GetEventsFunctionsExtension([Const] DOMString name);
[Ref] EventsFunctionsExtension GetEventsFunctionsExtensionAt(unsigned long index);
void SwapEventsFunctionsExtensions(unsigned long first, unsigned long second);
unsigned long GetEventsFunctionsExtensionsCount();
[Ref] EventsFunctionsExtension InsertNewEventsFunctionsExtension([Const] DOMString name, unsigned long position);
void RemoveEventsFunctionsExtension([Const] DOMString name);

[Ref] VariablesContainer GetVariables();
[Ref] ResourcesManager GetResourcesManager();
void ExposeResources([Ref] ArbitraryResourceWorker worker);
Expand Down Expand Up @@ -855,7 +864,7 @@ interface InstructionMetadata {
[Const, Ref] DOMString GetSmallIconFilename();
[Const, Ref] DOMString GetHelpPath();
boolean CanHaveSubInstructions();
[Const, Ref] ParameterMetadata GetParameter(unsigned long index);
[Ref] ParameterMetadata GetParameter(unsigned long index);
unsigned long GetParametersCount();
long GetUsageComplexity();
boolean IsHidden();
Expand Down Expand Up @@ -928,6 +937,7 @@ interface VectorParameterMetadata {
unsigned long size();
[Ref] ParameterMetadata at(unsigned long index);
void WRAPPED_set(unsigned long index, [Const, Ref] ParameterMetadata parameterMetadata);
void FREE_removeFromVectorParameterMetadata(unsigned long index);
void clear();
};

Expand Down Expand Up @@ -1101,6 +1111,8 @@ interface PlatformExtension {
[Ref] MapStringInstructionMetadata GetAllConditionsForBehavior([Const] DOMString autoType);
[Ref] MapStringExpressionMetadata GetAllExpressionsForBehavior([Const] DOMString autoType);
[Ref] MapStringExpressionMetadata GetAllStrExpressionsForBehavior([Const] DOMString autoType);

[Const, Value] DOMString STATIC_GetNamespaceSeparator();
};

interface EventsList {
Expand Down Expand Up @@ -1367,13 +1379,24 @@ interface VectorEventsSearchResult {
};

interface EventsRefactorer {
void STATIC_RenameObjectInEvents([Const, Ref] Platform platform, [Ref] Project project, [Ref] Layout layout, [Ref] EventsList events, [Const] DOMString oldName, [Const] DOMString newName);
void STATIC_RemoveObjectInEvents([Const, Ref] Platform platform, [Ref] Project project, [Ref] Layout layout, [Ref] EventsList events, [Const] DOMString name);
void STATIC_ReplaceStringInEvents([Ref] Project project, [Ref] Layout layout, [Ref] EventsList events, [Const] DOMString toReplace, [Const] DOMString newString, boolean matchCase, boolean inConditions, boolean inActions);
[Value] VectorEventsSearchResult STATIC_SearchInEvents([Ref] Project project, [Ref] Layout layout, [Ref] EventsList events, [Const] DOMString search, boolean matchCase, boolean inConditions, boolean inActions);
void STATIC_RenameObjectInEvents([Const, Ref] Platform platform, [Ref] ObjectsContainer project, [Ref] ObjectsContainer layout, [Ref] EventsList events, [Const] DOMString oldName, [Const] DOMString newName);
void STATIC_RemoveObjectInEvents([Const, Ref] Platform platform, [Ref] ObjectsContainer project, [Ref] ObjectsContainer layout, [Ref] EventsList events, [Const] DOMString name);
void STATIC_ReplaceStringInEvents([Ref] ObjectsContainer project, [Ref] ObjectsContainer layout, [Ref] EventsList events, [Const] DOMString toReplace, [Const] DOMString newString, boolean matchCase, boolean inConditions, boolean inActions);
[Value] VectorEventsSearchResult STATIC_SearchInEvents([Ref] ObjectsContainer project, [Ref] ObjectsContainer layout, [Ref] EventsList events, [Const] DOMString search, boolean matchCase, boolean inConditions, boolean inActions);
};

interface WholeProjectRefactorer {
void STATIC_ExposeProjectEvents([Ref] Project project, [Ref] ArbitraryEventsWorker worker);
void STATIC_RenameEventsFunctionsExtension(
[Ref] Project project,
[Const, Ref] EventsFunctionsExtension eventsFunctionsExtension,
[Const] DOMString oldName,
[Const] DOMString newName);
void STATIC_RenameEventsFunction(
[Ref] Project project,
[Const, Ref] EventsFunctionsExtension eventsFunctionsExtension,
[Const] DOMString oldName,
[Const] DOMString newName);
void STATIC_ObjectRenamedInLayout([Ref] Project project, [Ref] Layout layout, [Const] DOMString oldName, [Const] DOMString newName);
void STATIC_ObjectRemovedInLayout([Ref] Project project, [Ref] Layout layout, [Const] DOMString objectName, boolean removeEventsAndGroups);
void STATIC_GlobalObjectRenamed([Ref] Project project, [Const] DOMString oldName, [Const] DOMString newName);
Expand Down Expand Up @@ -1459,6 +1482,66 @@ interface CallbacksForExpressionCorrectnessTesting {
unsigned long GetFirstErrorPosition();
};

enum EventsFunction_FunctionType {
"EventsFunction::Action",
"EventsFunction::Condition",
"EventsFunction::Expression",
"EventsFunction::StringExpression"
};

interface EventsFunction {
void EventsFunction();

[Ref] EventsFunction SetDescription([Const] DOMString description);
[Const, Ref] DOMString GetDescription();
[Ref] EventsFunction SetName([Const] DOMString name);
[Const, Ref] DOMString GetName();
[Ref] EventsFunction SetFullName([Const] DOMString fullName);
[Const, Ref] DOMString GetFullName();
[Ref] EventsFunction SetSentence([Const] DOMString sentence);
[Const, Ref] DOMString GetSentence();
[Ref] EventsFunction SetFunctionType(EventsFunction_FunctionType type);
EventsFunction_FunctionType GetFunctionType();

[Ref] EventsList GetEvents();
[Ref] VectorParameterMetadata GetParameters();

void SerializeTo([Ref] SerializerElement element);
void UnserializeFrom([Ref] Project project, [Const, Ref] SerializerElement element);
};

interface VectorEventsFunction {
void VectorEventsFunction();

void push_back([Const, Ref] EventsFunction eventsFunction);
unsigned long size();
[Ref] EventsFunction at(unsigned long index);
void WRAPPED_set(unsigned long index, [Const, Ref] EventsFunction eventsFunction);
void clear();
};

interface EventsFunctionsExtension {
void EventsFunctionsExtension();

[Ref] EventsFunctionsExtension SetNamespace([Const] DOMString namespace);
[Const, Ref] DOMString GetNamespace();
[Ref] EventsFunctionsExtension SetVersion([Const] DOMString version);
[Const, Ref] DOMString GetVersion();
[Ref] EventsFunctionsExtension SetDescription([Const] DOMString description);
[Const, Ref] DOMString GetDescription();
[Ref] EventsFunctionsExtension SetName([Const] DOMString name);
[Const, Ref] DOMString GetName();
[Ref] EventsFunctionsExtension SetFullName([Const] DOMString fullName);
[Const, Ref] DOMString GetFullName();

boolean HasEventsFunctionNamed([Const] DOMString name);
[Ref] EventsFunction GetEventsFunction([Const] DOMString name);
[Ref] VectorEventsFunction GetEventsFunctions();

void SerializeTo([Ref] SerializerElement element);
void UnserializeFrom([Ref] Project project, [Const, Ref] SerializerElement element);
};

interface AbstractFileSystem {
};

Expand Down Expand Up @@ -1510,6 +1593,12 @@ interface EventsTypesLister {
void Launch([Ref] EventsList events);
};

interface InstructionsTypeRenamer {
void InstructionsTypeRenamer([Const, Ref] Project project, [Const] DOMString oldType, [Const] DOMString newType);

//Inherited from ArbitraryEventsWorker
void Launch([Ref] EventsList events);
};

interface EventsContext {
[Const, Ref] SetString GetObjectOrGroupNames();
Expand Down Expand Up @@ -2084,7 +2173,7 @@ interface ParticleEmitterObject {
[NoDelete, Prefix="gdjs::"]
interface EventsCodeGenerator {
[Const, Value] DOMString STATIC_GenerateSceneEventsCompleteCode([Ref] Project project, [Ref] Layout layout, [Ref] EventsList events, [Ref] SetString includes, boolean compilationForRuntime);
[Const, Value] DOMString STATIC_GenerateEventsFunctionCode([Ref] Project project, [Const, Ref] VectorParameterMetadata parameters, [Const, Ref] EventsList events, boolean compilationForRuntime);
[Const, Value] DOMString STATIC_GenerateEventsFunctionCode([Ref] Project project, [Const, Ref] EventsFunction eventsFunction, [Const] DOMString codeNamespace, [Ref] SetString includes, boolean compilationForRuntime);
};

[Prefix="gdjs::"]
Expand Down
15 changes: 15 additions & 0 deletions Bindings/Wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@
#include <GDCore/Events/Parsers/ExpressionParser.h>
#include <GDCore/Extensions/Metadata/MetadataProvider.h>
#include <GDCore/Extensions/Metadata/ParameterMetadataTools.h>
#include <GDCore/Project/EventsFunction.h>
#include <GDCore/Project/EventsFunctionsExtension.h>
#include <GDCore/IDE/AbstractFileSystem.h>
#include <GDCore/IDE/Dialogs/LayoutEditorCanvas/LayoutEditorCanvasOptions.h>
#include <GDCore/IDE/Dialogs/ObjectListDialogsHelper.h>
#include <GDCore/IDE/Dialogs/PropertyDescriptor.h>
#include <GDCore/IDE/Events/ArbitraryEventsWorker.h>
#include <GDCore/IDE/Events/InstructionsTypeRenamer.h>
#include <GDCore/IDE/Events/EventsContextAnalyzer.h>
#include <GDCore/IDE/Events/EventsParametersLister.h>
#include <GDCore/IDE/Events/EventsTypesLister.h>
Expand Down Expand Up @@ -340,6 +343,10 @@ void removeFromVectorVector2f(std::vector<sf::Vector2f> &vec, size_t pos) {
vec.erase(vec.begin() + pos);
}

void removeFromVectorParameterMetadata(std::vector<gd::ParameterMetadata> &vec, size_t pos) {
vec.erase(vec.begin() + pos);
}

// Implement a conversion from std::set<gd::String> to std::vector<gd::String>
// as there is no easy way to properly expose iterators :/
std::vector<gd::String> toNewVectorString(const std::set<gd::String> &set) {
Expand Down Expand Up @@ -372,8 +379,10 @@ typedef std::vector<Polygon2d> VectorPolygon2d;
typedef std::vector<sf::Vector2f> VectorVector2f;
typedef std::vector<EventsSearchResult> VectorEventsSearchResult;
typedef std::vector<gd::ParameterMetadata> VectorParameterMetadata;
typedef std::vector<gd::EventsFunction> VectorEventsFunction;
typedef gd::Object gdObject; // To avoid clashing javascript Object in glue.js
typedef ParticleEmitterObject::RendererType ParticleEmitterObject_RendererType;
typedef EventsFunction::FunctionType EventsFunction_FunctionType;

typedef ExtensionAndMetadata<BehaviorMetadata> ExtensionAndBehaviorMetadata;
typedef ExtensionAndMetadata<ObjectMetadata> ExtensionAndObjectMetadata;
Expand Down Expand Up @@ -473,6 +482,7 @@ typedef ExtensionAndMetadata<ExpressionMetadata> ExtensionAndExpressionMetadata;
#define STATIC_RenameObjectInEvents RenameObjectInEvents
#define STATIC_RemoveObjectInEvents RemoveObjectInEvents
#define STATIC_ReplaceStringInEvents ReplaceStringInEvents
#define STATIC_ExposeProjectEvents ExposeProjectEvents

#define STATIC_GetBehaviorMetadata GetBehaviorMetadata
#define STATIC_GetObjectMetadata GetObjectMetadata
Expand Down Expand Up @@ -512,10 +522,15 @@ typedef ExtensionAndMetadata<ExpressionMetadata> ExtensionAndExpressionMetadata;

#define STATIC_ParametersToObjectsContainer ParametersToObjectsContainer

#define STATIC_GetNamespaceSeparator GetNamespaceSeparator
#define STATIC_RenameEventsFunctionsExtension RenameEventsFunctionsExtension
#define STATIC_RenameEventsFunction RenameEventsFunction

// We postfix some methods with "At" as Javascript does not support overloading
#define GetLayoutAt GetLayout
#define GetExternalEventsAt GetExternalEvents
#define GetExternalLayoutAt GetExternalLayout
#define GetEventsFunctionsExtensionAt GetEventsFunctionsExtension
#define GetLayerAt GetLayer
#define GetObjectAt GetObject
#define GetAt Get
Expand Down
Loading

0 comments on commit 5c87b37

Please sign in to comment.