bindings: Initial commit of C & C++ bindings prototype
authorJerome St-Louis <jerome@ecere.com>
Mon, 30 May 2016 04:46:51 +0000 (00:46 -0400)
committerJerome St-Louis <jerome@ecere.com>
Mon, 21 Nov 2016 14:18:55 +0000 (09:18 -0500)
17 files changed:
bindings/c/eC.c [new file with mode: 0644]
bindings/c/eC.h [new file with mode: 0644]
bindings/c/ecere.c [new file with mode: 0644]
bindings/c/ecere.h [new file with mode: 0644]
bindings/c/samples/form.c [new file with mode: 0644]
bindings/c/samples/helloGUI.c [new file with mode: 0644]
bindings/c/samples/test.epj [new file with mode: 0644]
bindings/cpp/eC.cpp [new file with mode: 0644]
bindings/cpp/eC.hpp [new file with mode: 0644]
bindings/cpp/ecere.cpp [new file with mode: 0644]
bindings/cpp/ecere.hpp [new file with mode: 0644]
bindings/cpp/samples/helloGUI.cpp [new file with mode: 0644]
bindings/cpp/samples/sample1.cpp [new file with mode: 0644]
bindings/cpp/samples/sample2.cpp [new file with mode: 0644]
bindings/cpp/samples/sample3.cpp [new file with mode: 0644]
bindings/cpp/samples/sample4.cpp [new file with mode: 0644]
bindings/cpp/samples/test.epj [new file with mode: 0644]

diff --git a/bindings/c/eC.c b/bindings/c/eC.c
new file mode 100644 (file)
index 0000000..a6c2e1c
--- /dev/null
@@ -0,0 +1,177 @@
+#include "eC.h"
+
+void (*CheckConsistency)(void);
+void (*CheckMemory)(void);
+DesignerBase (*GetActiveDesigner)(void);
+Platform (*GetRuntimePlatform)(void);
+void (*InitializeDataTypes)(Module module);
+void (*InitializeDataTypes1)(Module module);
+bool (*LocateModule)(const char *name, const char *fileName);
+void (*Print)(Class * class_object, void * object, ...);
+int (*PrintBuf)(char *buffer, int maxLen, Class * class_object, void * object, ...);
+void (*PrintLn)(Class * class_object, void * object, ...);
+int (*PrintLnBuf)(char *buffer, int maxLen, Class * class_object, void * object, ...);
+char *(*PrintLnString)(Class * class_object, void * object, ...);
+int (*PrintStdArgsToBuffer)(char *buffer, int maxLen, Class * class_object, void * object, va_list args);
+char *(*PrintString)(Class * class_object, void * object, ...);
+void (*SetActiveDesigner)(DesignerBase designer);
+int64 (*_strtoi64)(const char *string, const char **endString, int base);
+uint64 (*_strtoui64)(const char *string, const char **endString, int base);
+uint (*log2i)(uint number);
+void (*memswap)(byte *a, byte *b, uint size);
+uint (*pow2i)(uint number);
+void (*queryMemInfo)(char *string);
+void (*ChangeCh)(char *string, char ch1, char ch2);
+void (*ChangeChars)(char *string, const char *chars, char alt);
+char *(*ChangeExtension)(const char *string, const char *ext, char *output);
+char *(*CopyString)(const char *string);
+double (*FloatFromString)(const char *string);
+int64 (*GetCurrentThreadID)(void);
+char *(*GetExtension)(const char *string, char *output);
+uint (*GetHexValue)(char **buffer);
+char *(*GetLastDirectory)(const char *string, char *output);
+bool (*GetString)(char **buffer, char *string, int max);
+int (*GetValue)(char **buffer);
+int (*ISO8859_1toUTF8)(const char *source, char *dest, int max);
+bool (*IsPathInsideOf)(const char *path, const char *of);
+char *(*MakePathRelative)(const char *path, const char *to, char *destination);
+char *(*PathCat)(char *string, const char *addedPath);
+char *(*PathCatSlash)(char *string, const char *addedPath);
+void (*PrintBigSize)(char *string, double size, int prec);
+void (*PrintSize)(char *string, uint size, int prec);
+char *(*RSearchString)(const char *buffer, const char *subStr, int maxLen, bool matchCase, bool matchWord);
+void (*RepeatCh)(char *string, int count, char ch);
+char *(*SearchString)(const char *buffer, int start, const char *subStr, bool matchCase, bool matchWord);
+bool (*SplitArchivePath)(const char *fileName, char *archiveName, const char **archiveFile);
+char *(*SplitDirectory)(const char *string, char *part, char *rest);
+bool (*StripExtension)(char *string);
+char *(*StripLastDirectory)(const char *string, char *output);
+char *(*StripQuotes)(const char *string, char *output);
+int (*Tokenize)(char *string, int maxTokens, char *tokens[], BackSlashEscaping esc);
+int (*TokenizeWith)(char *string, int maxTokens, char *tokens[], const char *tokenizers, bool escapeBackSlashes);
+char *(*TrimLSpaces)(const char *string, char *output);
+char *(*TrimRSpaces)(const char *string, char *output);
+char *(*UTF16toUTF8)(const uint16 *source);
+int (*UTF16toUTF8Buffer)(const uint16 *source, char *dest, int max);
+int (*UTF32toUTF8Len)(const unichar *source, int count, char *dest, int max);
+unichar (*UTF8GetChar)(const char *string, int *numBytes);
+bool (*UTF8Validate)(const char *source);
+uint16 *(*UTF8toUTF16)(const char *source, int *wordCount);
+int (*UTF8toUTF16Buffer)(const char *source, uint16 *dest, int max);
+void (*strcatf)(char *string, const char *format, ...);
+
+Class * class_Application;
+Class * class_String;
+Class * class_int;
+Class * class_double;
+Class * class_float;
+Class * class_char;
+Class * class_int64;
+Class * class_short;
+Class * class_uint16;
+Class * class_uint;
+Class * class_uint64;
+Class * class_byte;
+
+Class * class_class;
+
+Method * method_class_onDisplay;
+Method * method_class_onCompare;
+Method * method_class_onCopy;
+Method * method_class_onFree;
+Method * method_class_onGetString;
+Method * method_class_onGetDataFromString;
+Method * method_class_onEdit;
+Method * method_class_onSerialize;
+Method * method_class_onUnserialize;
+Method * method_class_onSaveEdit;
+
+int onDisplay_vTblID;
+int onCompare_vTblID;
+int onCopy_vTblID;
+int onFree_vTblID;
+int onGetString_vTblID;
+int onGetDataFromString_vTblID;
+int onEdit_vTblID;
+int onSerialize_vTblID;
+int onUnserialize_vTblID;
+int onSaveEdit_vTblID;
+
+int Application_main_vTblID;
+
+Method * method_Application_main;
+
+GlobalFunction * function_PrintLn;
+
+Application eC_init(bool guiApp, int argc, char * argv[])
+{
+   Application app = eC_initApp(guiApp, argc, argv);
+   if(app)
+   {
+      Module module = Module_load(app, "ecereCOM", publicAccess);
+      app->_refCount++;
+      if(module)
+      {
+         // Set up all the class_*, property, method, function pointers ...
+         class_class = eC_findClass(app, "class");
+         if(class_class)
+         {
+            method_class_onDisplay = Class_findMethod(class_class, "OnDisplay", app);
+            if(method_class_onDisplay)
+               onDisplay_vTblID = method_class_onDisplay->vid;
+            method_class_onCompare = Class_findMethod(class_class, "OnCompare", app);
+            if(method_class_onCompare)
+               onCompare_vTblID = method_class_onCompare->vid;
+            method_class_onCopy = Class_findMethod(class_class, "OnCopy", app);
+            if(method_class_onCopy)
+               onCopy_vTblID = method_class_onCopy->vid;
+            method_class_onFree = Class_findMethod(class_class, "OnFree", app);
+            if(method_class_onFree)
+               onFree_vTblID = method_class_onFree->vid;
+            method_class_onGetString = Class_findMethod(class_class, "OnGetString", app);
+            if(method_class_onGetString)
+               onGetString_vTblID = method_class_onGetString->vid;
+            method_class_onGetDataFromString = Class_findMethod(class_class, "OnGetDataFromString", app);
+            if(method_class_onGetDataFromString)
+               onGetDataFromString_vTblID = method_class_onGetDataFromString->vid;
+            method_class_onEdit = Class_findMethod(class_class, "OnEdit", app);
+            if(method_class_onEdit)
+               onEdit_vTblID = method_class_onEdit->vid;
+            method_class_onSerialize = Class_findMethod(class_class, "OnSerialize", app);
+            if(method_class_onSerialize)
+               onSerialize_vTblID = method_class_onSerialize->vid;
+            method_class_onUnserialize = Class_findMethod(class_class, "OnUnserialize", app);
+            if(method_class_onUnserialize)
+               onUnserialize_vTblID = method_class_onUnserialize->vid;
+            method_class_onSaveEdit = Class_findMethod(class_class, "OnSaveEdit", app);
+            if(method_class_onSaveEdit)
+               onSaveEdit_vTblID = method_class_onSaveEdit->vid;
+         }
+
+         class_String = eC_findClass(app, "String");
+         class_int = eC_findClass(app, "int");
+         class_double = eC_findClass(app, "double");
+         class_float = eC_findClass(app, "float");
+         class_char = eC_findClass(app, "char");
+         class_int64 = eC_findClass(app, "int64");
+         class_short = eC_findClass(app, "short");
+         class_uint16 = eC_findClass(app, "uint16");
+         class_uint = eC_findClass(app, "uint");
+         class_uint64 = eC_findClass(app, "uint64");
+         class_byte = eC_findClass(app, "byte");
+
+         class_Application = eC_findClass(app, "Application");
+         if(class_Application)
+         {
+            method_Application_main = Class_findMethod(class_Application, "Main", app);
+            if(method_Application_main)
+               Application_main_vTblID = method_Application_main->vid;
+         }
+
+         function_PrintLn = eC_findFunction(app, "PrintLn");
+         if(function_PrintLn)
+            PrintLn = (void *)function_PrintLn->function;
+      }
+   }
+   return app;
+}
diff --git a/bindings/c/eC.h b/bindings/c/eC.h
new file mode 100644 (file)
index 0000000..84978ed
--- /dev/null
@@ -0,0 +1,1140 @@
+// Preprocessor directives can be added at the beginning (Can't store them in AST)
+
+/****************************************************************************
+===========================================================================
+   Core eC Library
+===========================================================================
+****************************************************************************/
+#if !defined(__EC_H__)
+#define __EC_H__
+
+#define CPP11 (defined(__cplusplus) && __cplusplus >= 201103L)
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#define Instance           eC_Instance
+#define Module             eC_Module
+#define Application        eC_Application
+#define Container          eC_Container
+#define Array              eC_Array
+#define CustomAVLTree      eC_CustomAVLTree
+#define AVLTree            eC_AVLTree
+#define Map                eC_Map
+#define LinkList           eC_LinkList
+#define List               eC_List
+#define IOChannel          eC_IOChannel
+#define SerialBuffer       eC_SerialBuffer
+#define OldArray           eC_OldArray
+
+#define Window             eC_Window
+#define ClassDesignerBase  eC_ClassDesignerBase
+#define DesignerBase       eC_DesignerBase
+
+// Structs / Unions (with methods or properties)
+#define Iterator           eC_Iterator
+#define MapIterator        eC_MapIterator
+#define BuiltInContainer   eC_BuiltInContainer
+#define BinaryTree         eC_BinaryTree
+#define StringBinaryTree   eC_StringBinaryTree
+#define OldList            eC_OldList
+
+// class : struct (with methods or properties)
+#define Class              eC_Class
+#define BTNode             eC_BTNode
+#define Item               eC_Item
+#define OldLink            eC_OldLink
+#define AVLNode            eC_AVLNode
+#define MapNode            eC_MapNode
+#define StringBTNode       eC_StringBTNode
+
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+
+// Syntactic Sugar (NOT GENERATED)
+#define $(x)      (constString)getTranslatedString(MODULE_NAME, x, null)
+#define $$(x, c)  (constString)getTranslatedString(MODULE_NAME, x, c)
+
+#define _IPTR(x, c, s) ((struct s *)((x) ? (((char *)(x)) + c->offset) : 0))
+#define IPTR(x, c) _IPTR(x, class_ ## c, c)
+
+#define incref(x) (x)->_refCount++;
+
+#define newi(c) ({ Instance i = Instance_new(c); incref(i); i; })
+#ifndef __cplusplus
+   #define new(t, c) eC_new(class_ ## t->structSize * c)
+#endif
+#define newb(c) eC_new(c)
+
+#define deletei(v) Instance_decref(v), v = null
+#ifndef __cplusplus
+   #define delete(v) eC_delete(v), v = null
+#endif
+
+#ifndef __cplusplus
+   #define registerClass(a, n, b)  \
+      eC_registerClass(normalClass, #n, #b, sizeof(struct n), 0, \
+         (void *)n ## _constructor, (void *)n ## _destructor, a, privateAccess, publicAccess)
+#endif
+
+#define addMethod(c, n, m) \
+   Class_addMethod(c, n, null, (void *)m, publicAccess)
+
+#if defined(__WIN32__) && !defined(__CONSOLE_APP__)
+   typedef void * HINSTANCE;
+   #define WINAPI __stdcall
+   #define MAIN_DECLARATION int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst, char * cmdLine, int show)
+   #define eC_init_CALL eC_init(true, 0, null)
+#else
+   #define MAIN_DECLARATION int main(int argc, char * argv[])
+   #ifdef __cplusplus
+      #if defined(__CONSOLE_APP__)
+         #define eC_init_CALL eC_init(false, null, null);
+      #else
+         #define eC_init_CALL eC_init(true, null, null);
+      #endif
+   #else
+      #if defined(__CONSOLE_APP__)
+         #define eC_init_CALL eC_init(false, argc, argv);
+      #else
+         #define eC_init_CALL eC_init(true, argc, argv);
+      #endif
+   #endif
+#endif
+
+#define APP_INTRO \
+   MAIN_DECLARATION \
+   { \
+      eC_Application app = eC_init_CALL;
+
+#define APP_OUTRO \
+      int exitCode = _IPTR(app, class_Application, class_members_Application)->exitCode; \
+      deletei(app); \
+      return exitCode; \
+   }
+
+// GENERATED:
+
+#ifdef __cplusplus
+   // class : struct (with methods or properties)
+   #define Class eC_Class
+   #define BTNode eC_BTNode
+   #define Item eC_Item
+   #define OldLink eC_OldLink
+   #define AVLNode eC_AVLNode
+   #define MapNode eC_MapNode
+   #define StringBTNode eC_StringBTNode
+#endif
+
+#ifdef __cplusplus
+   // Structs / Unions (with methods or properties)
+   #define Iterator eC_Iterator
+   #define MapIterator eC_MapIterator
+   #define BuiltInContainer eC_BuiltInContainer
+   #define BinaryTree eC_BinaryTree
+   #define StringBinaryTree eC_StringBinaryTree
+   #define OldList eC_OldList
+#endif
+
+// Defines
+#if defined(__cplusplus)
+#define null 0
+#else
+#define null (void *)0
+#endif
+
+// dllimport Functions
+#define eC_initApp               __ecereNameSpace__ecere__com____ecere_COM_Initialize
+#define eC_findClass             __ecereNameSpace__ecere__com__eSystem_FindClass
+#define eC_registerClass         __ecereNameSpace__ecere__com__eSystem_RegisterClass
+#define eC_new                   __ecereNameSpace__ecere__com__eSystem_New
+#define eC_new0                  __ecereNameSpace__ecere__com__eSystem_New0
+#define eC_delete                __ecereNameSpace__ecere__com__eSystem_Delete
+#define eC_findFunction          __ecereNameSpace__ecere__com__eSystem_FindFunction
+
+#define Class_addMethod          __ecereNameSpace__ecere__com__eClass_AddMethod
+#define Class_findMethod         __ecereNameSpace__ecere__com__eClass_FindMethod
+#define Class_findProperty       __ecereNameSpace__ecere__com__eClass_FindProperty
+#define Class_isDerived          __ecereNameSpace__ecere__com__eClass_IsDerived
+
+#define Module_load              __ecereNameSpace__ecere__com__eModule_Load
+
+#define Instance_new             __ecereNameSpace__ecere__com__eInstance_New
+#define Instance_delete          __ecereNameSpace__ecere__com__eInstance_Delete
+#define Instance_decref          __ecereNameSpace__ecere__com__eInstance_DecRef
+#define Instance_evolve          __ecereNameSpace__ecere__com__eInstance_Evolve
+#define Instance_setMethod       __ecereNameSpace__ecere__com__eInstance_SetMethod
+
+#define getTranslatedString      __ecereNameSpace__ecere__GetTranslatedString
+#define loadTranslatedStrings    __ecereNameSpace__ecere__LoadTranslatedStrings
+#define unloadTranslatedStrings  __ecereNameSpace__ecere__UnloadTranslatedStrings
+
+// Virtual Method Calls
+
+// Base Class
+#define onDisplay(c, i, s, x, y, w, d, a, f) ({ void (* method)(Class *, void *, Surface, int, int, int, void *, Alignment, DataDisplayFlags) = ((c) ? (c)->_vTbl : class_class->_vTbl)[onDisplay_vTblID]; \
+                                                method ? method((c), i, s, x, y, w, d, a, f) : 1; })
+#define onCompare(c, i, co, o)               ({ int (* method)(Class *, void *, Class *, void *) = ((c) ? (c)->_vTbl : class_class->_vTbl)[onCompare_vTblID]; \
+                                                method ? method((c), i, co, o) : 1; })
+#define onCopy(c, i, co, o)                  ({ void (* method)(Class *, void *, Class *, void *) = ((c) ? (c)->_vTbl : class_class->_vTbl)[onCopy_vTblID]; \
+                                                method ? method((c), i, co, o) : 1; })
+#define onFree(c, i)                         ({ void (* method)(Class *, void *) = ((c) ? (c)->_vTbl : class_class->_vTbl)[onFree_vTblID]; \
+                                                method ? method((c), i) : 1; })
+#define onGetString(c, i, t, d, n)           ({ constString (* method)(Class *, void *, char *, void *, bool *) = ((c) ? (c)->_vTbl : class_class->_vTbl)[onGetString_vTblID]; \
+                                                method ? method((c), i, t, d, n) : null; })
+#define onGetDataFromString(c, i, s)         ({ bool (* method)(Class *, void *, constString) = ((c) ? (c)->_vTbl : class_class->_vTbl)[onGetDataFromString_vTblID]; \
+                                                method ? method((c), i, s) : 1; })
+#define onEdit(c, i, b, o, x, y, w, h, u)    ({ Window (* method)(Class *, void *, DataBox, DataBox, int, int, int, int, void *) = ((c) ? (c)->_vTbl : class_class->_vTbl)[onEdit_vTblID]; \
+                                                method ? method((c), i, b, i, x, y, w, h, u) : 1; })
+#define onSerialize(c, i, s)                 ({ void (* method)(Class *, void *, IOChannel) = ((c) ? (c)->_vTbl : class_class->_vTbl)[onSerialize_vTblID]; \
+                                                method ? method((c), i, s) : 1; })
+#define onUnserialize(c, i, s)               ({ void (* method)(Class *, void *, IOChannel) = ((c) ? (c)->_vTbl : class_class->_vTbl)[onUnserialize_vTblID]; \
+                                                method ? method((c), i, s) : 1; })
+#define onSaveEdit(c, i, w, o)               ({ bool (* method)(Class *, void *, Window, void *) = ((c) ? (c)->_vTbl : class_class->_vTbl)[onSaveEdit_vTblID]; \
+                                                method ? method((c), i, w, o) : 1; })
+
+// Base Virtual Methods for Normal Classes
+#define Instance_onDisplay(c, i, s, x, y, w, d, a, f)  onDisplay(i ? i->_class : c, i, s, x, y, w, d, a, f)
+#define Instance_onCompare(c, i, co, o)                onCompare(i ? i->_class : c, i, co, o)
+#define Instance_onCopy(c, i, co, o)                   onCopy(c, &i, co, o)
+#define Instance_onFree(c, i)                          onFree(i ? i->_class : c, i)
+#define Instance_onGetString(c, i, t, d, n)            onGetString(i ? i->_class : c, i, t, d, n)
+#define Instance_onGetDataFromString(c, i, s)          onGetDataFromString(c, &i, s)
+#define Instance_onEdit(c, i, b, o, x, y, w, h, u)     onEdit(i ? i->_class : c, i, b, o, x, y, w, h, u)
+#define Instance_onSerialize(c, i, s)                  onSerialize(i ? i->_class : c, i, s)
+#define Instance_onUnserialize(c, i, s)                onUnserialize(c, &i, s)
+#define Instance_onSaveEdit(c, i, w, o)                onSaveEdit(c, &i, w, o)
+
+// Application Class
+#define Application_main(x)   ({ eC_Application i = x; \
+                                 void (* method)(eC_Application) = (void (*)(eC_Application))(i ? i->_vTbl : class_Application->_vTbl)[Application_main_vTblID]; \
+                                 if(method) method(i); })
+
+// Container Class
+#define Container_getFirst(i)                ({ void (* method)(Container) = ((i) ? (i)->_vTbl : class_Container->_vTbl)[Container_getFirst_vTblID]; \
+                                                return method ? method((i)) : null; })
+#define Container_getLast(i)
+#define Container_getPrev(i, p)
+#define Container_getNext(i, p)
+#define Container_getData(i, p)
+#define Container_setData(i, p, d)
+#define Container_getAtPosition(i, p, c, j)
+#define Container_insert(i, a, v)
+#define Container_add(i, v)
+#define Container_remove(i, t)
+#define Container_move(i, t, a)
+#define Container_removeAll(i)
+#define Container_copy(i, s)
+#define Container_find(i, v)
+#define Container_freeIterator(i, t)
+#define Container_getCount(i)
+#define Container_free(i)
+#define Container_deleteItem(i, t)
+#define Container_takeOut(i, d)
+
+
+// class : struct forward declarations
+struct BTNamedLink;
+struct BitMember;
+struct Class;
+struct ClassProperty;
+struct ClassTemplateParameter;
+struct DataMember;
+struct DefinedExpression;
+struct EnumClassData;
+struct GlobalFunction;
+union ListItem;
+struct Link;
+struct NamedLink;
+struct NamedLink64;
+struct Method;
+struct AVLNode;
+struct MapNode;
+struct Property;
+struct ObjectInfo;
+struct SubModule;
+struct BTNode;
+struct Item;
+struct NamedItem;
+struct OldLink;
+struct StringBTNode;
+
+typedef void IteratorPointer;
+typedef void Mutex;
+
+#ifndef __cplusplus
+// class : struct typedefs
+typedef struct BTNamedLink BTNamedLink;
+typedef struct BitMember BitMember;
+typedef struct Class Class;
+typedef struct ClassProperty ClassProperty;
+typedef struct ClassTemplateParameter ClassTemplateParameter;
+typedef struct DataMember DataMember;
+typedef struct DefinedExpression DefinedExpression;
+typedef struct EnumClassData EnumClassData;
+typedef struct GlobalFunction GlobalFunction;
+typedef union ListItem ListItem;
+typedef struct Link Link;
+typedef struct NamedLink NamedLink;
+typedef struct NamedLink64 NamedLink64;
+typedef struct Method Method;
+typedef struct AVLNode AVLNode;
+typedef struct MapNode MapNode;
+typedef struct Property Property;
+typedef struct ObjectInfo ObjectInfo;
+typedef struct SubModule SubModule;
+typedef struct BTNode BTNode;
+typedef struct Item Item;
+typedef struct NamedItem NamedItem;
+typedef struct OldLink OldLink;
+typedef struct StringBTNode StringBTNode;
+#endif
+
+// Unit Class Typedefs
+typedef uint8_t byte;
+typedef int64_t int64;
+typedef intptr_t intptr;
+typedef ssize_t intsize;
+typedef uint32_t uint;
+typedef uint16_t uint16;
+typedef uint32_t uint32;
+typedef uint64_t uint64;
+typedef uintptr_t uintptr;
+typedef size_t uintsize;
+typedef uint32_t unichar;
+typedef double Angle;
+
+// Normal Class Typedefs
+struct class_members_Instance;
+
+typedef struct class_members_Instance * Instance;
+typedef Instance Module;
+typedef Module Application;
+typedef Instance Container;
+typedef Container Array;
+typedef Container CustomAVLTree;
+typedef CustomAVLTree AVLTree;
+typedef CustomAVLTree Map;
+typedef Container LinkList;
+typedef LinkList List;
+typedef Instance IOChannel;
+typedef IOChannel SerialBuffer;
+typedef Instance OldArray;
+
+typedef Instance Window;
+typedef Window ClassDesignerBase;
+typedef Window DesignerBase;
+
+// String Type
+typedef char * String;
+typedef const char * constString;
+
+// Undefined classes
+typedef void * Type;
+typedef void * Instantiation;
+typedef void * ClassDefinition;
+
+// Bit Class Typedefs
+typedef uint32 Color;
+typedef uint32 Modifiers;
+
+// Enum Typedefs
+#if defined(__cplusplus)
+   #define bool eC_bool
+#elif defined(bool)
+   #undef bool
+   #define REDEFINE_STDBOOL
+   #define bool eC_bool
+#endif
+typedef uint32 bool;
+
+#if !defined(__cplusplus)
+typedef enum ClassType ClassType;
+typedef enum ImportType ImportType;
+typedef enum AccessMode AccessMode;
+typedef enum DataMemberType DataMemberType;
+typedef enum MethodType MethodType;
+typedef enum Platform Platform;
+typedef enum TemplateMemberType TemplateMemberType;
+typedef enum TemplateParameterType TemplateParameterType;
+typedef enum TreePrintStyle TreePrintStyle;
+#endif
+
+#if !CPP11
+typedef uint32 BackSlashEscaping;
+#endif
+
+// Template Types Typedefs
+typedef uint64 Container_D;
+typedef uint64 Container_I;
+typedef uint64 Container_T;
+
+typedef AVLNode * CustomAVLTree_BT;
+typedef uint64 CustomAVLTree_KT;
+
+typedef uint64 AVLNode_T;
+typedef uint64 Array_T;
+
+typedef void * LinkElement_T;
+typedef void * LinkList_LT;
+
+typedef uint64 MapNode_V;
+
+// Enumerations
+#if !defined(__bool_true_false_are_defined) && !defined(__cplusplus)
+enum boolean
+{
+   false = 0,
+   true = 1
+};
+#endif
+
+enum BackSlashEscaping
+#if CPP11
+   : uint32
+#endif
+{ forArgsPassing = 2 };
+
+enum Platform { unknown, win32, tux, apple };
+
+enum TemplateMemberType { dataMember, method, prop };
+enum TemplateParameterType { type, identifier, expression };
+enum TreePrintStyle { inOrder, postOrder, preOrder, depthOrder };
+
+enum ClassType
+{
+   normalClass,
+   structClass,
+   bitClass,
+   unitClass,
+   enumClass,
+   noHeadClass
+};
+
+enum MethodType { normalMethod, virtualMethod };
+
+enum ImportType
+{
+   normalImport,
+   staticImport,
+   remoteImport
+};
+
+enum AccessMode
+{
+   defaultAccess,
+   publicAccess,
+   privateAccess,
+   staticAccess,
+   baseSystemAccess
+};
+
+enum DataMemberType
+{
+   normalMember,
+   unionMember,
+   structMember
+};
+
+// Struct Typedefs
+#ifndef __cplusplus
+   typedef union DataValue DataValue;
+   typedef struct Size Size;
+   typedef struct Point Point;
+   typedef struct Iterator Iterator;
+   typedef struct MapIterator MapIterator;
+   typedef struct BuiltInContainer BuiltInContainer;
+   typedef union ClassTemplateArgument ClassTemplateArgument;
+   typedef struct LinkElement LinkElement;
+   typedef struct NameSpace NameSpace;
+   typedef struct StaticString StaticString;
+   typedef struct BinaryTree BinaryTree;
+   typedef struct StringBinaryTree StringBinaryTree;
+   typedef struct OldList OldList;
+#endif
+
+// Structs / Unions
+struct StaticString
+{
+   char string[1];
+};
+
+union DataValue
+{
+   char c;
+   byte uc;
+   short s;
+   uint16 us;
+   int i;
+   uint32 ui;
+   void * p;
+   float f;
+   double d;
+   int64 i64;
+   uint64 ui64;
+};
+
+struct BuiltInContainer
+{
+   void *_vTbl;
+   Class * _class;
+   int _refCount;
+   void *data;
+   int count;
+   Class * type;
+};
+
+struct BinaryTree
+{
+   BTNode * root;
+   int count;
+};
+
+struct OldList
+{
+   void *first;
+   void *last;
+   int count;
+   uint offset;
+   bool circ;
+};
+
+struct NameSpace
+{
+   const char *name;
+   NameSpace * btParent;
+   NameSpace * left;
+   NameSpace * right;
+   int depth;
+   NameSpace * parent;
+   BinaryTree nameSpaces;
+   BinaryTree classes;
+   BinaryTree defines;
+   BinaryTree functions;
+};
+
+struct Iterator
+{
+   Container container;
+   IteratorPointer * pointer;
+};
+
+struct MapIterator
+{
+   Map map;
+   IteratorPointer * pointer;
+};
+struct LinkElement
+{
+   LinkElement_T prev;
+   LinkElement_T next;
+};
+
+union ClassTemplateArgument
+{
+   // For type
+   struct
+   {
+      constString dataTypeString;
+      Class * dataTypeClass;
+   };
+   DataValue expression;
+   // For identifier
+   struct
+   {
+      constString memberString;
+      union
+      {
+         DataMember * member;
+         Property * prop;
+         Method * method;
+      };
+   };
+};
+
+// class : struct
+struct BTNamedLink
+{
+   const char *name;
+   BTNamedLink * parent;
+   BTNamedLink * left;
+   BTNamedLink * right;
+   int depth;
+   void *data;
+};
+struct BitMember
+{
+   BitMember * prev;
+   BitMember * next;
+   const char *name;
+   bool isProperty;
+   AccessMode memberAccess;
+   int id;
+   Class * _class;
+   const char *dataTypeString;
+   Class * dataTypeClass;
+   Type dataType;
+   DataMemberType type;
+   int size;
+   int pos;
+   uint64 mask;
+};
+
+struct Class
+{
+   Class * prev;
+   Class * next;
+   const char *name;
+   int offset;
+   int structSize;
+   void **_vTbl;
+   int vTblSize;
+   bool (*Constructor)(void *);
+   void (*Destructor)(void *);
+
+   int offsetClass;
+   int sizeClass;
+   Class * base;
+   BinaryTree methods;
+   BinaryTree members;
+   BinaryTree prop;
+   OldList membersAndProperties;
+   BinaryTree classProperties;
+   OldList derivatives;
+   int memberID;
+   int startMemberID;
+   ClassType type;
+   Module module;
+   NameSpace * nameSpace;
+   const char *dataTypeString;
+   Type dataType;
+   void (*Initialize)();
+   int typeSize;
+   int defaultAlignment;
+   int memberOffset;
+   OldList selfWatchers;
+   const char *designerClass;
+   bool noExpansion;
+   const char *defaultProperty;
+   bool comRedefinition;
+   int count;
+   int isRemote;
+   bool internalDecl;
+   void *data;
+   bool computeSize;
+   short structAlignment;
+   short pointerAlignment;
+   int destructionWatchOffset;
+   bool fixed;
+   OldList delayedCPValues;
+   AccessMode inheritanceAccess;
+   const char *fullName;
+   void *symbol;
+   OldList conversions;
+   OldList templateParams;
+   ClassTemplateArgument * templateArgs;
+   Class * templateClass;
+   OldList templatized;
+   int numParams;
+   bool isInstanceClass;
+   bool byValueSystemClass;
+};
+struct ClassProperty
+{
+   const char *name;
+   ClassProperty * parent;
+   ClassProperty * left;
+   ClassProperty * right;
+   int depth;
+   const char *dataTypeString;
+   Type dataType;
+   bool constant;
+};
+struct ClassTemplateParameter
+{
+   ClassTemplateParameter * prev;
+   ClassTemplateParameter * next;
+   const char *name;
+   TemplateParameterType type;
+   ClassTemplateArgument defaultArg;
+   void *param;
+};
+struct EnumClassData
+{
+   OldList values;
+   int64 largest;
+};
+struct DataMember
+{
+   DataMember * prev;
+   DataMember * next;
+   const char *name;
+   bool isProperty;
+   AccessMode memberAccess;
+   int id;
+   Class * _class;
+   const char *dataTypeString;
+   Class * dataTypeClass;
+   Type dataType;
+   DataMemberType type;
+   int offset;
+   int memberID;
+   OldList members;
+   BinaryTree membersAlpha;
+   int memberOffset;
+   short structAlignment;
+   short pointerAlignment;
+};
+struct DefinedExpression
+{
+   DefinedExpression * prev;
+   DefinedExpression * next;
+   const char * name;
+   const char * value;
+   NameSpace * nameSpace;
+};
+struct GlobalFunction
+{
+   GlobalFunction * prev;
+   GlobalFunction * next;
+   const char *name;
+   int (*function)();
+   Module module;
+   NameSpace * nameSpace;
+   const char *dataTypeString;
+   Type dataType;
+   void *symbol;
+};
+union ListItem
+{
+   LinkElement link;
+   struct { ListItem * prev, * next; };
+};
+
+struct Link
+{
+   LinkElement link;
+   struct { Link * prev, * next; };
+   uint64 data;
+};
+struct Method
+{
+   const char *name;
+   Method * parent;
+   Method * left;
+   Method * right;
+   int depth;
+   int (*function)();
+   int vid;
+   MethodType type;
+   Class * _class;
+   void *symbol;
+   const char *dataTypeString;
+   Type dataType;
+   AccessMode memberAccess;
+};
+struct ObjectInfo
+{
+   ObjectInfo * prev;
+   ObjectInfo * next;
+   Instance instance;
+   char *name;
+   Instantiation instCode;
+   bool deleted;
+   ObjectInfo * oClass;
+   OldList instances;
+   ClassDefinition classDefinition;
+   bool modified;
+   void *i18nStrings;
+};
+struct Property
+{
+   Property * prev;
+   Property * next;
+   const char *name;
+   bool isProperty;
+   AccessMode memberAccess;
+   int id;
+   Class * _class;
+   const char *dataTypeString;
+   Class * dataTypeClass;
+   Type dataType;
+
+   void (*Set)(void *, int);
+   int (*Get)(void *);
+   bool (*IsSet)(void *);
+
+   void *data;
+   void *symbol;
+   int vid;
+   bool conversion;
+   uint watcherOffset;
+   const char *category;
+   bool compiled;
+   bool selfWatchable;
+   bool isWatchable;
+};
+struct SubModule
+{
+   SubModule * prev;
+   SubModule * next;
+   Module module;
+   AccessMode importMode;
+};
+struct BTNode
+{
+   uintptr key;
+   BTNode * parent;
+   BTNode * left;
+   BTNode * right;
+   int depth;
+};
+struct Item
+{
+   Item * prev;
+   Item * next;
+};
+struct NamedItem
+{
+   NamedItem * prev;
+   NamedItem * next;
+   char *name;
+};
+struct NamedLink
+{
+   NamedLink * prev;
+   NamedLink * next;
+   char *name;
+   void *data;
+};
+struct NamedLink64
+{
+   NamedLink64 * prev;
+   NamedLink64 * next;
+   char *name;
+   int64 data;
+};
+struct OldLink
+{
+   OldLink * prev;
+   OldLink * next;
+   void *data;
+};
+struct AVLNode
+{
+   AVLNode_T key;
+};
+struct MapNode
+{
+   AVLNode_T key;
+   MapNode_V value;
+};
+struct StringBTNode
+{
+   String key;
+   StringBTNode * parent;
+   StringBTNode * left;
+   StringBTNode * right;
+   int depth;
+};
+
+// Normal Classes Visible Data Structures
+struct class_members_Instance
+{
+   void **_vTbl;
+   Class * _class;
+   int _refCount;
+};
+struct layout_Module
+{
+   Application application;
+   OldList classes;
+   OldList defines;
+   OldList functions;
+   OldList modules;
+   Module prev;
+   Module next;
+   const char *name;
+   void *library;
+   void *Unload;
+   ImportType importType;
+   ImportType origImportType;
+   NameSpace privateNameSpace;
+   NameSpace publicNameSpace;
+};
+struct class_members_Application
+{
+   int argc;
+   const char **argv;
+   int exitCode;
+   bool isGUIApp;
+   OldList allModules;
+   char *parsedCommand;
+   NameSpace systemNameSpace;
+};
+struct class_members_Array
+{
+   Array_T *array;
+   uint count;
+   uint minAllocSize;
+};
+
+struct class_members_CustomAVLTree
+{
+   CustomAVLTree_BT root;
+   int count;
+};
+struct class_members_DesignerBase
+{
+   ClassDesignerBase classDesigner;
+   const char *objectClass;
+   bool isDragging;
+};
+
+struct class_members_LinkList
+{
+   LinkList_LT first;
+   LinkList_LT last;
+   int count;
+};
+
+struct class_members_SerialBuffer
+{
+   byte *_buffer;
+   uint count;
+   uint _size;
+   uint pos;
+};
+
+// C Exported functions
+extern __attribute__((dllimport)) Application __ecereNameSpace__ecere__com____ecere_COM_Initialize(bool guiApp, int argc, char *argv[]);
+
+extern __attribute__((dllimport)) Class * __ecereNameSpace__ecere__com__eSystem_FindClass(Module module, const char *name);
+extern __attribute__((dllimport)) Class * __ecereNameSpace__ecere__com__eSystem_RegisterClass(ClassType type, const char *name, const char *baseName, int size, int sizeClass, bool (*Constructor)(void *), void (*Destructor)(void *), Module module, AccessMode declMode, AccessMode inheritanceAccess);
+extern __attribute__((dllimport)) void * __ecereNameSpace__ecere__com__eSystem_new(uint size);
+extern __attribute__((dllimport)) void * __ecereNameSpace__ecere__com__eSystem_new0(uint size);
+extern __attribute__((dllimport)) void *__ecereNameSpace__ecere__com__eSystem_Renew(void *memory, uint size);
+extern __attribute__((dllimport)) void *__ecereNameSpace__ecere__com__eSystem_Renew0(void *memory, uint size);
+extern __attribute__((dllimport)) void __ecereNameSpace__ecere__com__eSystem_Delete(void *memory);
+extern __attribute__((dllimport)) DefinedExpression * __ecereNameSpace__ecere__com__eSystem_FindDefine(Module module, const char *name);
+extern __attribute__((dllimport)) GlobalFunction * __ecereNameSpace__ecere__com__eSystem_FindFunction(Module module, const char *name);
+extern __attribute__((dllimport)) DefinedExpression * __ecereNameSpace__ecere__com__eSystem_RegisterDefine(const char *name, const char *value, Module module, AccessMode declMode);
+extern __attribute__((dllimport)) GlobalFunction * __ecereNameSpace__ecere__com__eSystem_RegisterFunction(const char *name, const char *type, void *func, Module module, AccessMode declMode);
+extern __attribute__((dllimport)) void __ecereNameSpace__ecere__com__eSystem_SetPoolingDisabled(bool disabled);
+
+extern __attribute__((dllimport)) Module __ecereNameSpace__ecere__com__eModule_Load(Module fromModule, const char *name, AccessMode importAccess);
+extern __attribute__((dllimport)) Module __ecereNameSpace__ecere__com__eModule_LoadStatic(Module fromModule, const char *name, AccessMode importAccess, bool __ecereNameSpace__ecere__com__Load(Module module), bool __ecereNameSpace__ecere__com__Unload(Module module));
+extern __attribute__((dllimport)) Module __ecereNameSpace__ecere__com__eModule_LoadStrict(Module fromModule, const char *name, AccessMode importAccess);
+extern __attribute__((dllimport)) void __ecereNameSpace__ecere__com__eModule_Unload(Module fromModule, Module module);
+
+extern __attribute__((dllimport)) Method * __ecereNameSpace__ecere__com__eClass_AddMethod(Class * _class, constString name, constString type, void *function, AccessMode declMode);
+extern __attribute__((dllimport)) Method * __ecereNameSpace__ecere__com__eClass_FindMethod(Class * _class, const char *name, Module module);
+extern __attribute__((dllimport)) Property * __ecereNameSpace__ecere__com__eClass_FindProperty(Class * _class, const char *name, Module module);
+extern __attribute__((dllimport)) BitMember * __ecereNameSpace__ecere__com__eClass_AddBitMember(Class * _class, const char *name, const char *type, int bitSize, int bitPos, AccessMode declMode);
+extern __attribute__((dllimport)) ClassProperty * __ecereNameSpace__ecere__com__eClass_AddClassProperty(Class * _class, const char *name, const char *dataType, void *setStmt, void *getStmt);
+extern __attribute__((dllimport)) DataMember * __ecereNameSpace__ecere__com__eClass_AddDataMember(Class * _class, const char *name, const char *type, uint size, uint alignment, AccessMode declMode);
+extern __attribute__((dllimport)) bool __ecereNameSpace__ecere__com__eClass_AddMember(Class * _class, DataMember * dataMember);
+extern __attribute__((dllimport)) Property * __ecereNameSpace__ecere__com__eClass_AddProperty(Class * _class, const char *name, const char *dataType, void *setStmt, void *getStmt, AccessMode declMode);
+extern __attribute__((dllimport)) ClassTemplateParameter * __ecereNameSpace__ecere__com__eClass_AddTemplateParameter(Class * _class, const char *name, TemplateParameterType type, const void *info, ClassTemplateArgument defaultArg);
+extern __attribute__((dllimport)) Method * __ecereNameSpace__ecere__com__eClass_AddVirtualMethod(Class * _class, const char *name, const char *type, void *function, AccessMode declMode);
+extern __attribute__((dllimport)) void __ecereNameSpace__ecere__com__eClass_DestructionWatchable(Class * _class);
+extern __attribute__((dllimport)) void __ecereNameSpace__ecere__com__eClass_DoneAddingTemplateParameters(Class * base);
+extern __attribute__((dllimport)) ClassProperty * __ecereNameSpace__ecere__com__eClass_FindClassProperty(Class * _class, const char *name);
+extern __attribute__((dllimport)) DataMember * __ecereNameSpace__ecere__com__eClass_FindDataMember(Class * _class, const char *name, Module module, DataMember * *subMemberStack, int *subMemberStackPos);
+extern __attribute__((dllimport)) DataMember * __ecereNameSpace__ecere__com__eClass_FindDataMemberAndId(Class * _class, const char *name, int *id, Module module, DataMember * *subMemberStack, int *subMemberStackPos);
+extern __attribute__((dllimport)) DataMember * __ecereNameSpace__ecere__com__eClass_FindDataMemberAndOffset(Class * _class, const char *name, uint *offset, Module module, DataMember * *subMemberStack, int *subMemberStackPos);
+extern __attribute__((dllimport)) void __ecereNameSpace__ecere__com__eClass_FindNextMember(Class * _class, Class * curClass, DataMember * *curMember, DataMember * *subMemberStack, int *subMemberStackPos);
+extern __attribute__((dllimport)) int64 __ecereNameSpace__ecere__com__eClass_GetProperty(Class * _class, const char *name);
+extern __attribute__((dllimport)) bool __ecereNameSpace__ecere__com__eClass_IsDerived(Class * _class, Class * from);
+extern __attribute__((dllimport)) void __ecereNameSpace__ecere__com__eClass_Resize(Class * _class, int newSize);
+extern __attribute__((dllimport)) void __ecereNameSpace__ecere__com__eClass_SetProperty(Class * _class, const char *name, int64 value);
+extern __attribute__((dllimport)) void __ecereNameSpace__ecere__com__eClass_Unregister(Class * _class);
+
+extern __attribute__((dllimport)) Instance __ecereNameSpace__ecere__com__eInstance_New(Class * _class);
+extern __attribute__((dllimport)) void __ecereNameSpace__ecere__com__eInstance_Delete(Instance instance);
+extern __attribute__((dllimport)) void __ecereNameSpace__ecere__com__eInstance_Evolve(Instance *instancePtr, Class * _class);
+extern __attribute__((dllimport)) void __ecereNameSpace__ecere__com__eInstance_SetMethod(Instance instance, constString name, void *function);
+extern __attribute__((dllimport)) void __ecereNameSpace__ecere__com__eInstance_DecRef(Instance instance);
+extern __attribute__((dllimport)) void __ecereNameSpace__ecere__com__eInstance_FireSelfWatchers(Instance instance, Property * _property);
+extern __attribute__((dllimport)) void __ecereNameSpace__ecere__com__eInstance_FireWatchers(Instance instance, Property * _property);
+extern __attribute__((dllimport)) void __ecereNameSpace__ecere__com__eInstance_IncRef(Instance instance);
+extern __attribute__((dllimport)) bool __ecereNameSpace__ecere__com__eInstance_IsDerived(Instance instance, Class * from);
+extern __attribute__((dllimport)) void __ecereNameSpace__ecere__com__eInstance_StopWatching(Instance instance, Property * _property, Instance object);
+extern __attribute__((dllimport)) void __ecereNameSpace__ecere__com__eInstance_Watch(Instance instance, Property * _property, void *object, void __ecereNameSpace__ecere__com__callback(void *, void *));
+extern __attribute__((dllimport)) void __ecereNameSpace__ecere__com__eInstance_WatchDestruction(Instance instance, Instance object, void __ecereNameSpace__ecere__com__callback(void *, void *));
+
+extern __attribute__((dllimport)) void __ecereNameSpace__ecere__com__eEnum_AddFixedValue(Class * _class, const char *string, int64 value);
+extern __attribute__((dllimport)) int64 __ecereNameSpace__ecere__com__eEnum_AddValue(Class * _class, const char *string);
+
+extern __attribute__((dllimport)) DataMember * __ecereNameSpace__ecere__com__eMember_AddDataMember(DataMember * member, const char *name, const char *type, uint size, uint alignment, AccessMode declMode);
+extern __attribute__((dllimport)) bool __ecereNameSpace__ecere__com__eMember_AddMember(DataMember * addTo, DataMember * dataMember);
+extern __attribute__((dllimport)) DataMember * __ecereNameSpace__ecere__com__eMember_New(DataMemberType type, AccessMode declMode);
+
+extern __attribute__((dllimport)) void __ecereNameSpace__ecere__com__eProperty_SelfWatch(Class * _class, const char *name, void (*__ecereNameSpace__ecere__com__callback)(void *));
+extern __attribute__((dllimport)) void __ecereNameSpace__ecere__com__eProperty_Watchable(Property * _property);
+
+extern __attribute__((dllimport)) void __ecereNameSpace__ecere__com__MemoryGuard_PopLoc(void);
+extern __attribute__((dllimport)) void __ecereNameSpace__ecere__com__MemoryGuard_PushLoc(const char *loc);
+
+extern __attribute__((dllimport)) constString __ecereNameSpace__ecere__GetTranslatedString(constString name, constString string, constString stringAndContext);
+extern __attribute__((dllimport)) void __ecereNameSpace__ecere__LoadTranslatedStrings(constString moduleName, constString name);
+extern __attribute__((dllimport)) void __ecereNameSpace__ecere__UnloadTranslatedStrings(constString name);
+
+// Global Functions
+extern void (*CheckConsistency)(void);
+extern void (*CheckMemory)(void);
+extern DesignerBase (*GetActiveDesigner)(void);
+extern Platform (*GetRuntimePlatform)(void);
+extern bool (*LocateModule)(const char *name, const char *fileName);
+extern void (*Print)(Class * class_object, void * object, ...);
+extern int (*PrintBuf)(char *buffer, int maxLen, Class * class_object, void * object, ...);
+extern void (*PrintLn)(Class * class_object, void * object, ...);
+extern int (*PrintLnBuf)(char *buffer, int maxLen, Class * class_object, void * object, ...);
+extern char *(*PrintLnString)(Class * class_object, void * object, ...);
+extern int (*PrintStdArgsToBuffer)(char *buffer, int maxLen, Class * class_object, void * object, va_list args);
+extern char *(*PrintString)(Class * class_object, void * object, ...);
+extern void (*SetActiveDesigner)(DesignerBase designer);
+extern int64 (*_strtoi64)(const char *string, const char **endString, int base);
+extern uint64 (*_strtoui64)(const char *string, const char **endString, int base);
+extern uint (*log2i)(uint number);
+extern void (*memswap)(byte *a, byte *b, uint size);
+extern uint (*pow2i)(uint number);
+extern void (*queryMemInfo)(char *string);
+extern void (*ChangeCh)(char *string, char ch1, char ch2);
+extern void (*ChangeChars)(char *string, const char *chars, char alt);
+extern char *(*ChangeExtension)(const char *string, const char *ext, char *output);
+extern char *(*CopyString)(const char *string);
+extern double (*FloatFromString)(const char *string);
+extern int64 (*GetCurrentThreadID)(void);
+extern char *(*GetExtension)(const char *string, char *output);
+extern uint (*GetHexValue)(char **buffer);
+extern char *(*GetLastDirectory)(const char *string, char *output);
+extern bool (*GetString)(char **buffer, char *string, int max);
+extern int (*GetValue)(char **buffer);
+extern int (*ISO8859_1toUTF8)(const char *source, char *dest, int max);
+extern bool (*IsPathInsideOf)(const char *path, const char *of);
+extern char *(*MakePathRelative)(const char *path, const char *to, char *destination);
+extern char *(*PathCat)(char *string, const char *addedPath);
+extern char *(*PathCatSlash)(char *string, const char *addedPath);
+extern void (*PrintBigSize)(char *string, double size, int prec);
+extern void (*PrintSize)(char *string, uint size, int prec);
+extern char *(*RSearchString)(const char *buffer, const char *subStr, int maxLen, bool matchCase, bool matchWord);
+extern void (*RepeatCh)(char *string, int count, char ch);
+extern char *(*SearchString)(const char *buffer, int start, const char *subStr, bool matchCase, bool matchWord);
+extern bool (*SplitArchivePath)(const char *fileName, char *archiveName, const char **archiveFile);
+extern char *(*SplitDirectory)(const char *string, char *part, char *rest);
+extern bool (*StripExtension)(char *string);
+extern char *(*StripLastDirectory)(const char *string, char *output);
+extern char *(*StripQuotes)(const char *string, char *output);
+extern int (*Tokenize)(char *string, int maxTokens, char *tokens[], BackSlashEscaping esc);
+extern int (*TokenizeWith)(char *string, int maxTokens, char *tokens[], const char *tokenizers, bool escapeBackSlashes);
+extern char *(*TrimLSpaces)(const char *string, char *output);
+extern char *(*TrimRSpaces)(const char *string, char *output);
+extern char *(*UTF16toUTF8)(const uint16 *source);
+extern int (*UTF16toUTF8Buffer)(const uint16 *source, char *dest, int max);
+extern int (*UTF32toUTF8Len)(const unichar *source, int count, char *dest, int max);
+extern unichar (*UTF8GetChar)(const char *string, int *numBytes);
+extern bool (*UTF8Validate)(const char *source);
+extern uint16 *(*UTF8toUTF16)(const char *source, int *wordCount);
+extern int (*UTF8toUTF16Buffer)(const char *source, uint16 *dest, int max);
+extern void (*strcatf)(char *string, const char *format, ...);
+
+// Base Class
+extern Class * class_class;
+
+extern Method * method_class_onDisplay;
+extern Method * method_class_onCompare;
+extern Method * method_class_onCopy;
+extern Method * method_class_onFree;
+extern Method * method_class_onGetString;
+extern Method * method_class_onGetDataFromString;
+extern Method * method_class_onEdit;
+extern Method * method_class_onSerialize;
+extern Method * method_class_onUnserialize;
+extern Method * method_class_onSaveEdit;
+
+extern int onDisplay_vTblID;
+extern int onCompare_vTblID;
+extern int onCopy_vTblID;
+extern int onFree_vTblID;
+extern int onGetString_vTblID;
+extern int onGetDataFromString_vTblID;
+extern int onEdit_vTblID;
+extern int onSerialize_vTblID;
+extern int onUnserialize_vTblID;
+extern int onSaveEdit_vTblID;
+
+extern Class * class_String;
+extern Class * class_int;
+extern Class * class_double;
+extern Class * class_float;
+extern Class * class_char;
+extern Class * class_int64;
+extern Class * class_short;
+extern Class * class_uint16;
+extern Class * class_uint;
+extern Class * class_uint64;
+extern Class * class_byte;
+
+// Application Class
+extern Class * class_Application;
+
+// Methods
+extern Method * method_Application_main;
+
+extern int Application_main_vTblID;
+
+Module eC_init(bool guiApp, int argc, char * argv[]);
+
+#if defined(__cplusplus)
+   #undef bool
+#elif defined(REDEFINE_STDBOOL)
+   #undef bool
+   #define bool _Bool
+#endif
+
+#ifdef __cplusplus
+
+   #undef Instance
+   #undef Module
+   #undef Application
+   #undef Container
+   #undef Array
+   #undef CustomAVLTree
+   #undef AVLTree
+   #undef Map
+   #undef LinkList
+   #undef List
+   #undef IOChannel
+   #undef SerialBuffer
+   #undef OldArray
+
+   #undef Window
+   #undef ClassDesignerBase
+   #undef DesignerBase
+
+   // Structs / Unions (with methods or properties)
+   #undef Iterator
+   #undef MapIterator
+   #undef BuiltInContainer
+   #undef BinaryTree
+   #undef StringBinaryTree
+   #undef OldList
+
+   // class : struct (with methods or properties)
+   #undef Class
+   #undef BTNode
+   #undef Item
+   #undef OldLink
+   #undef AVLNode
+   #undef MapNode
+   #undef StringBTNode
+
+};
+
+#endif
+
+#endif
diff --git a/bindings/c/ecere.c b/bindings/c/ecere.c
new file mode 100644 (file)
index 0000000..fe66892
--- /dev/null
@@ -0,0 +1,264 @@
+#include "ecere.h"
+
+Class * class_Surface;
+
+Method * method_Surface_writeTextf;
+
+void (* Surface_writeTextf)(Surface s, int x, int y, const char * format, ...);
+
+Class * class_FontResource;
+
+Property * property_FontResource_faceName;
+Property * property_FontResource_size;
+Property * property_FontResource_bold;
+Property * property_FontResource_italic;
+
+void (* FontResource_set_faceName)(FontResource f, constString v);
+constString (* FontResource_get_faceName)(FontResource f);
+
+void (* FontResource_set_size)(FontResource f, float v);
+float (* FontResource_get_size)(FontResource f);
+
+void (* FontResource_set_bold)(FontResource f, bool v);
+bool (* FontResource_get_bold)(FontResource f);
+
+void (* FontResource_set_italic)(FontResource f, bool v);
+bool (* FontResource_get_italic)(FontResource f);
+
+Class * class_Window;
+
+int Window_onCreate_vTblID;
+int Window_onRedraw_vTblID;
+
+Property * property_Window_caption;
+Property * property_Window_size;
+Property * property_Window_clientSize;
+Property * property_Window_hasClose;
+Property * property_Window_hasMinimize;
+Property * property_Window_hasMaximize;
+Property * property_Window_borderStyle;
+Property * property_Window_background;
+Property * property_Window_parent;
+Property * property_Window_position;
+Property * property_Window_font;
+
+Method * method_Window_modal;
+Method * method_Window_onCreate;
+Method * method_Window_onRedraw;
+
+void (* Window_set_borderStyle)(Window w, BorderStyle v);
+BorderStyle (* Window_get_borderStyle)(Window w);
+
+void (* Window_set_size)(Window w, const Size * v);
+void (* Window_get_size)(Window w, Size * v);
+
+void (* Window_set_clientSize)(Window w, const Size * v);
+void (* Window_get_clientSize)(Window w, Size * v);
+
+void (* Window_set_hasClose)(Window w, bool v);
+bool (* Window_get_hasClose)(Window w);
+
+void (* Window_set_hasMaximize)(Window w, bool v);
+bool (* Window_get_hasMaximize)(Window w);
+
+void (* Window_set_hasMinimize)(Window w, bool v);
+bool (* Window_get_hasMinimize)(Window w);
+
+void (* Window_set_parent)(Window w, Window v);
+Window (* Window_get_parent)(Window w);
+
+void (* Window_set_background)(Window w, Color v);
+Color (* Window_get_background)(Window w);
+
+void (* Window_set_position)(Window w, const Point * v);
+void (* Window_get_position)(Window w, Point * v);
+
+void (* Window_set_font)(Window w, Instance v);
+FontResource (* Window_get_font)(Window w);
+
+void (* Window_set_caption)(Window w, constString v);
+constString (* Window_get_caption)(Window w);
+
+DialogResult (* Window_modal)(Window);
+
+Class * class_Button;
+
+Method * method_Button_notifyClicked;
+
+int Button_notifyClicked_vTblID;
+
+Class * class_ToolButton;
+
+Class * class_Label;
+
+Class * class_GuiApplication;
+
+Class * class_MessageBox;
+
+Property * property_MessageBox_contents;
+
+void (* MessageBox_set_contents)(MessageBox m, constString v);
+constString (* MessageBox_get_contents)(MessageBox m);
+
+Module ecere_init(Module fromModule)
+{
+   Module module = Module_load(fromModule, "ecere", publicAccess);
+   if(module)
+   {
+      // Set up all the class_*, property, method, function pointers ...
+      class_Surface = eC_findClass(module, "Surface");
+      if(class_Surface)
+      {
+         method_Surface_writeTextf = Class_findMethod(class_Surface, "WriteTextf", module);
+         if(method_Surface_writeTextf)
+            Surface_writeTextf = (void *)method_Surface_writeTextf->function;
+      }
+
+      class_FontResource = eC_findClass(module, "FontResource");
+      if(class_FontResource)
+      {
+         property_FontResource_faceName = Class_findProperty(class_FontResource, "faceName", module);
+         if(property_FontResource_faceName)
+         {
+            FontResource_set_faceName = (void *)property_FontResource_faceName->Set;
+            FontResource_get_faceName = (void *)property_FontResource_faceName->Get;
+         }
+
+         property_FontResource_size = Class_findProperty(class_FontResource, "size", module);
+         if(property_FontResource_size)
+         {
+            FontResource_set_size = (void *)property_FontResource_size->Set;
+            FontResource_get_size = (void *)property_FontResource_size->Get;
+         }
+
+         property_FontResource_bold = Class_findProperty(class_FontResource, "bold", module);
+         if(property_FontResource_bold)
+         {
+            FontResource_set_bold = (void *)property_FontResource_bold->Set;
+            FontResource_get_bold = (void *)property_FontResource_bold->Get;
+         }
+
+         property_FontResource_italic = Class_findProperty(class_FontResource, "italic", module);
+         if(property_FontResource_italic)
+         {
+            FontResource_set_italic = (void *)property_FontResource_italic->Set;
+            FontResource_get_italic = (void *)property_FontResource_italic->Get;
+         }
+      }
+
+      class_Window = eC_findClass(module, "Window");
+      if(class_Window)
+      {
+         method_Window_modal = Class_findMethod(class_Window, "Modal", module);
+         if(method_Window_modal)
+            Window_modal = (void *)method_Window_modal->function;
+         method_Window_onCreate = Class_findMethod(class_Window, "OnCreate", module);
+         if(method_Window_onCreate)
+            Window_onCreate_vTblID = method_Window_onCreate->vid;
+         method_Window_onRedraw = Class_findMethod(class_Window, "OnRedraw", module);
+         if(method_Window_onRedraw)
+            Window_onRedraw_vTblID = method_Window_onRedraw->vid;
+
+         property_Window_caption = Class_findProperty(class_Window, "caption", module);
+         if(property_Window_caption)
+         {
+            Window_set_caption = (void *)property_Window_caption->Set;
+            Window_get_caption = (void *)property_Window_caption->Get;
+         }
+
+         property_Window_size = Class_findProperty(class_Window, "size", module);
+         if(property_Window_size)
+         {
+            Window_set_size = (void *)property_Window_size->Set;
+            Window_get_size = (void *)property_Window_size->Get;
+         }
+
+         property_Window_clientSize = Class_findProperty(class_Window, "clientSize", module);
+         if(property_Window_clientSize)
+         {
+            Window_set_clientSize = (void *)property_Window_clientSize->Set;
+            Window_get_clientSize = (void *)property_Window_clientSize->Get;
+         }
+
+         property_Window_borderStyle = Class_findProperty(class_Window, "borderStyle", module);
+         if(property_Window_borderStyle)
+         {
+            Window_set_borderStyle = (void *)property_Window_borderStyle->Set;
+            Window_get_borderStyle = (void *)property_Window_borderStyle->Get;
+         }
+
+         property_Window_background = Class_findProperty(class_Window, "background", module);
+         if(property_Window_background)
+         {
+            Window_set_background = (void *)property_Window_background->Set;
+            Window_get_background = (void *)property_Window_background->Get;
+         }
+
+         property_Window_hasClose = Class_findProperty(class_Window, "hasClose", module);
+         if(property_Window_hasClose)
+         {
+            Window_set_hasClose = (void *)property_Window_hasClose->Set;
+            Window_get_hasClose = (void *)property_Window_hasClose->Get;
+         }
+
+         property_Window_hasMinimize = Class_findProperty(class_Window, "hasMinimize", module);
+         if(property_Window_hasMinimize)
+         {
+            Window_set_hasMinimize = (void *)property_Window_hasMinimize->Set;
+            Window_get_hasMinimize = (void *)property_Window_hasMinimize->Get;
+         }
+
+         property_Window_hasMaximize = Class_findProperty(class_Window, "hasMaximize", module);
+         if(property_Window_hasMaximize)
+         {
+            Window_set_hasMaximize = (void *)property_Window_hasMaximize->Set;
+            Window_get_hasMaximize = (void *)property_Window_hasMaximize->Get;
+         }
+
+         property_Window_parent = Class_findProperty(class_Window, "parent", module);
+         if(property_Window_parent)
+         {
+            Window_set_parent = (void *)property_Window_parent->Set;
+            Window_get_parent = (void *)property_Window_parent->Get;
+         }
+
+         property_Window_position = Class_findProperty(class_Window, "position", module);
+         if(property_Window_position)
+         {
+            Window_set_position = (void *)property_Window_position->Set;
+            Window_get_position = (void *)property_Window_position->Get;
+         }
+
+         property_Window_font = Class_findProperty(class_Window, "font", module);
+         if(property_Window_font)
+         {
+            Window_set_font = (void *)property_Window_font->Set;
+            Window_get_font = (void *)property_Window_font->Get;
+         }
+      }
+
+      class_Label = eC_findClass(module, "Label");
+
+      class_Button = eC_findClass(module, "Button");
+      if(class_Button)
+      {
+         method_Button_notifyClicked = Class_findMethod(class_Button, "NotifyClicked", module);
+         if(method_Button_notifyClicked)
+            Button_notifyClicked_vTblID = method_Button_notifyClicked->vid;
+      }
+
+      class_MessageBox = eC_findClass(module, "MessageBox");
+      if(class_MessageBox)
+      {
+         property_MessageBox_contents = Class_findProperty(class_MessageBox, "contents", module);
+         if(property_MessageBox_contents)
+         {
+            MessageBox_set_contents = (void *)property_MessageBox_contents->Set;
+            MessageBox_get_contents = (void *)property_MessageBox_contents->Get;
+         }
+      }
+
+      class_GuiApplication = eC_findClass(module, "GuiApplication");
+   }
+   return module;
+}
diff --git a/bindings/c/ecere.h b/bindings/c/ecere.h
new file mode 100644 (file)
index 0000000..b6399a2
--- /dev/null
@@ -0,0 +1,314 @@
+// Preprocessor directives can be added at the beginning (Can't store them in AST)
+
+/****************************************************************************
+===========================================================================
+   Ecere Module
+===========================================================================
+****************************************************************************/
+#if !defined(__ECERE_H__)
+#define __ECERE_H__
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#include "eC.h"
+
+#define ECERE_APP_INTRO(c) \
+      APP_INTRO \
+      ecere_init(app); \
+      loadTranslatedStrings(null, MODULE_NAME); \
+      Instance_evolve(&app, class_ ## c);
+
+#define ECERE_APP_OUTRO \
+      unloadTranslatedStrings(MODULE_NAME); \
+      APP_OUTRO
+
+#define GUIAPP_INTRO ECERE_APP_INTRO(GuiApplication)
+
+// GENERATED:
+
+#define Class           eC_Class
+#define Instance        eC_Instance
+#define Module          eC_Module
+
+#define Surface         eC_Surface
+#define FontResource    eC_FontResource
+
+#define Window          eC_Window
+#define Button          eC_Button
+#define Label           eC_Label
+#define MessageBox      eC_MessageBox
+#define GuiApplication  eC_GuiApplication
+
+// Virtual Method Calls
+#define Window_onCreate(x)    ({  eC_Window i = x; \
+                                  bool (* method)(eC_Window) = (bool (*)(eC_Instance))(i ? i->_vTbl : class_Window->_vTbl)[Window_onCreate_vTblID]; \
+                                  method ? method(i) : true; })
+
+#define Window_onRedraw(x, s) ({  eC_Window i = x; \
+                                  void (* method)(eC_Window, eC_Surface) = (void (*)(eC_Window, eC_Surface))(i ? i->_vTbl : class_Window->_vTbl)[Window_onRedraw_vTblID]; \
+                                  if(method) method(i, s); })
+
+#define Button_notifyClicked(t, m, b, x, y, mods)    ({ eC_Button i = t; \
+                                                      bool (* method)(eC_Window, eC_Button, int, int, Modifiers) = (bool (*)(eC_Window, eC_Button, int, int, Modifiers))(i ? i->_vTbl : class_Button->_vTbl)[Button_notifyClicked_vTblID]; \
+                                                      method ? method(m, b, x, y, mods) : true; })
+
+// Bit Class Member Access
+#define COLOR_r_MASK       0x00FF0000
+#define COLOR_r_SHIFT      16
+#define COLOR_g_MASK       0x0000FF00
+#define COLOR_g_SHIFT      8
+#define COLOR_b_MASK       0x000000FF
+#define COLOR_b_SHIFT      0
+
+#define COLOR(r, g, b)     ((((Color)(r)) << COLOR_r_SHIFT) | ((Color)(g) << COLOR_g_SHIFT) | ((Color)(b)) << COLOR_b_SHIFT)
+#define COLOR_r(x)         ((((Color)(x)) & COLOR_r_MASK) >> COLOR_r_SHIFT)
+#define COLOR_g(x)         ((((Color)(x)) & COLOR_g_MASK) >> COLOR_g_SHIFT)
+#define COLOR_b(x)         ((((Color)(x)) & COLOR_b_MASK) >> COLOR_b_SHIFT)
+#define COLOR_SET_r(x, r)  (x) = ((Color)(x) & ~((Color)COLOR_r_MASK)) | (((Color)(r)) << COLOR_r_SHIFT)
+#define COLOR_SET_g(x, g)  (x) = ((Color)(x) & ~((Color)COLOR_g_MASK)) | (((Color)(g)) << COLOR_g_SHIFT)
+#define COLOR_SET_b(x, b)  (x) = ((Color)(x) & ~((Color)COLOR_b_MASK)) | (((Color)(b)) << COLOR_b_SHIFT)
+
+#define BORDERBITS_contour_mask  0x00000001
+#define BORDERBITS_contour_shift 0
+#define BORDERBITS_fixed_mask    0x00000002
+#define BORDERBITS_fixed_shift   1
+#define BORDERBITS_sizable_mask  0x00000004
+#define BORDERBITS_sizable_shift 2
+#define BORDERBITS_deep_mask     0x00000008
+#define BORDERBITS_deep__shift   3
+#define BORDERBITS_bevel_mask    0x00000010
+#define BORDERBITS_bevel_shift   4
+#define BORDERBITS_thin_mask     0x00000020
+#define BORDERBITS_thin_shift    5
+
+#define BORDERBITS_contour(x)    ((((BorderBits)(x)) & BORDERBITS_contour_MASK) >> BORDERBITS_contours_SHIFT)
+#define BORDERBITS_fixed(x)      ((((BorderBits)(x)) & BORDERBITS_fixed_MASK) >> BORDERBITS_fixed_SHIFT)
+#define BORDERBITS_sizable(x)    ((((BorderBits)(x)) & BORDERBITS_sizable_MASK) >> BORDERBITS_sizable_SHIFT)
+#define BORDERBITS_deep(x)       ((((BorderBits)(x)) & BORDERBITS_deep_MASK) >> BORDERBITS_deep_SHIFT)
+#define BORDERBITS_bevel(x)      ((((BorderBits)(x)) & BORDERBITS_bevel_MASK) >> BORDERBITS_bevel_SHIFT)
+#define BORDERBITS_thin(x)       ((((BorderBits)(x)) & BORDERBITS_thin_MASK) >> BORDERBITS_thin_SHIFT)
+
+// Structs
+struct Size { int w, h; };
+struct Point { int x, y; };
+
+// Struct Typedefs
+typedef struct Size Size;
+typedef struct Point Point;
+
+/****************************************************************************
+   ecere::gfx Namespace
+****************************************************************************/
+// Color Bit Class
+typedef uint32 Color;
+
+// System Color Enum
+#if !CPP11
+typedef Color SystemColor;
+#endif
+
+enum SystemColor
+#if CPP11
+   : Color
+#endif
+{
+   formColor = COLOR(229, 234, 245)
+};
+
+///////////// Surface Class /////////////////////////////////////////////////
+
+typedef Instance Surface;
+
+extern Class * class_Surface;
+
+// Methods
+extern Method * method_Surface_writeTextf;
+
+extern void (* Surface_writeTextf)(Surface s, int x, int y, const char * format, ...);
+
+
+///////////// FontResource Class /////////////////////////////////////////////////
+extern Class * class_FontResource;
+
+typedef Instance FontResource;
+
+// Properties
+extern Property * property_FontResource_faceName;
+extern Property * property_FontResource_size;
+
+extern void (* FontResource_set_faceName)(FontResource f, constString v);
+extern constString (* FontResource_get_faceName)(FontResource f);
+
+extern void (* FontResource_set_size)(FontResource f, float v);
+extern float (* FontResource_get_size)(FontResource f);
+
+extern void (* FontResource_set_bold)(FontResource f, bool v);
+extern bool (* FontResource_get_bold)(FontResource f);
+
+extern void (* FontResource_set_italic)(FontResource f, bool v);
+extern bool (* FontResource_get_italic)(FontResource f);
+
+/****************************************************************************
+   ecere::gui Namespace
+****************************************************************************/
+
+// Bit Class Typedefs
+typedef uint32 Modifiers;
+typedef uint32 BorderBits;
+
+// Enum Typedefs
+#if !CPP11
+typedef BorderBits BorderStyle;
+#endif
+
+#if !CPP11
+typedef int64 DialogResult;
+#endif
+
+// Enumerations
+enum DialogResult
+#if CPP11
+   : int64
+#endif
+{
+   cancel = 0,
+   yes = 1,
+   no = 2,
+   ok = 3
+};
+
+enum BorderStyle
+#if CPP11
+   : BorderBits
+#endif
+{
+   none,
+   contour      = BORDERBITS_contour_mask,
+   fixed        = BORDERBITS_fixed_mask | contour,
+   sizable      = BORDERBITS_sizable_mask | fixed,
+   thin         = BORDERBITS_thin_mask | fixed,
+   sizableThin  = BORDERBITS_sizable_mask | thin,
+   deep         = BORDERBITS_deep_mask,
+   bevel        = BORDERBITS_bevel_mask,
+   sizableDeep  = sizable|deep,
+   sizableBevel = sizable|bevel,
+   fixedDeep    = fixed|deep,
+   fixedBevel   = fixed|bevel,
+   deepContour  = deep|contour
+};
+
+///////////// Window Class /////////////////////////////////////////////////
+typedef Instance Window;
+
+extern Class * class_Window;
+
+// Properties
+extern Property * property_Window_caption;
+extern Property * property_Window_caption;
+extern Property * property_Window_size;
+extern Property * property_Window_clientSize;
+extern Property * property_Window_hasClose;
+extern Property * property_Window_hasMinimize;
+extern Property * property_Window_hasMaximize;
+extern Property * property_Window_borderStyle;
+extern Property * property_Window_background;
+extern Property * property_Window_parent;
+extern Property * property_Window_position;
+extern Property * property_Window_font;
+
+extern void (* Window_set_borderStyle)(Window w, BorderStyle v);
+extern BorderStyle (* Window_get_borderStyle)(Window w);
+
+extern void (* Window_set_size)(Window w, const Size * v);
+extern void (* Window_get_size)(Window w, Size * v);
+
+extern void (* Window_set_clientSize)(Window w, const Size * v);
+extern void (* Window_get_clientSize)(Window w, Size * v);
+
+extern void (* Window_set_hasClose)(Window w, bool v);
+extern bool (* Window_get_hasClose)(Window w);
+
+extern void (* Window_set_hasMaximize)(Window w, bool v);
+extern bool (* Window_get_hasMaximize)(Window w);
+
+extern void (* Window_set_hasMinimize)(Window w, bool v);
+extern bool (* Window_get_hasMinimize)(Window w);
+
+extern void (* Window_set_parent)(Window w, Window v);
+extern Window (* Window_get_parent)(Window w);
+
+extern void (* Window_set_background)(Window w, Color v);
+extern Color (* Window_get_background)(Window w);
+
+extern void (* Window_set_position)(Window w, const Point * v);
+extern void (* Window_get_position)(Window w, Point * v);
+
+extern void (* Window_set_font)(Window w, FontResource v);
+extern FontResource (* Window_get_font)(Window w);
+
+extern void (* Window_set_caption)(Window w, constString v);
+extern constString (* Window_get_caption)(Window w);
+
+// Methods
+extern DialogResult (* Window_modal)(Window);
+
+extern Method * method_Window_modal;
+extern Method * method_Window_onCreate;
+
+extern int Window_onCreate_vTblID;
+extern int Window_onRedraw_vTblID;
+
+///////////// Label Class /////////////////////////////////////////////////
+extern Class * class_Label;
+
+typedef Instance Label;
+
+///////////// MessageBox Class /////////////////////////////////////////////////
+typedef Window MessageBox;
+
+extern Class * class_MessageBox;
+
+// Properties
+extern Property * property_MessageBox_contents;
+
+extern void (* MessageBox_set_contents)(MessageBox m, constString v);
+extern constString (* MessageBox_get_contents)(MessageBox m);
+
+///////////// Button Class /////////////////////////////////////////////////
+typedef Window Button;
+
+extern Class * class_Button;
+
+// Method IDs
+extern int Button_notifyClicked_vTblID;
+
+
+extern Class * class_ToolButton;
+
+///////////// GuiApplication Class /////////////////////////////////////////////////
+extern Class * class_GuiApplication;
+
+typedef Instance GuiApplication;
+
+Module ecere_init(Module fromModule);
+
+#ifdef __cplusplus
+   #undef Button
+   #undef MessageBox
+   #undef Label
+   #undef Window
+   #undef GuiApplication
+
+   #undef FontResource
+   #undef Surface
+
+   #undef Module
+   #undef Class
+   #undef Instance
+};
+#endif
+
+#endif
diff --git a/bindings/c/samples/form.c b/bindings/c/samples/form.c
new file mode 100644 (file)
index 0000000..849246f
--- /dev/null
@@ -0,0 +1,68 @@
+#define MODULE_NAME  "HelloForm"
+// #define __CONSOLE_APP__
+
+#include "ecere.h"
+
+static Class * class_HelloForm2;
+
+struct HelloForm2 { Button button; };
+
+typedef Instance HelloForm2;
+
+static void HelloForm2_onRedraw(HelloForm2 this, Surface surface)
+{
+   // Surface_writeTextf(surface, 100, 100, I18N("Testing stuff!"));
+   Surface_writeTextf(surface, 100, 100, "%d + %d = %d", 2, 3, 2+3);
+}
+
+static bool HelloForm2_button_notifyClicked(HelloForm2 this, Button button, int x, int y, Modifiers mods)
+{
+   MessageBox msgBox = newi(class_MessageBox);
+   double i = 3.14159265;
+   char tmp[256];
+   constString s = onGetString(class_double, &i, tmp, null, null);
+
+   PrintLn(class_String, "Hello! -- ", class_String, s, null); // Need to terminate with a null!
+   Window_set_caption(msgBox, $("Hello!"));
+   MessageBox_set_contents(msgBox, $("C Bindings!"));
+   Window_modal(msgBox);
+   return true;
+}
+
+static bool HelloForm2_constructor(HelloForm2 this)
+{
+   struct HelloForm2 * self = IPTR(this, HelloForm2);
+   Window_set_caption(this, $("My Second Ecere/C Bindings App"));
+   Window_set_borderStyle(this, sizable);
+   Window_set_clientSize(this, &(Size){ 640, 480 });
+   Window_set_hasClose(this, true);
+   Window_set_hasMaximize(this, true);
+   Window_set_hasMinimize(this, true);
+   Window_set_background(this, formColor);
+
+   self->button = newi(class_Button);
+   Window_set_parent(self->button, this);
+   Window_set_position(self->button, &(Point){ 200, 200 });
+   Window_set_caption(self->button, $("Yay!!"));
+   Instance_setMethod(self->button, "NotifyClicked", HelloForm2_button_notifyClicked);
+   return true;
+}
+
+static void HelloForm2_destructor(HelloForm2 this)
+{
+   struct HelloForm2 * self = IPTR(this, HelloForm2);
+   deletei(self->button);
+}
+
+GUIAPP_INTRO
+{
+   class_HelloForm2 = registerClass(app, HelloForm2, Window);
+   addMethod(class_HelloForm2, "OnRedraw", HelloForm2_onRedraw);
+
+   HelloForm2 hello = newi(class_HelloForm2);
+
+   Application_main(app);
+
+   deletei(hello);
+}
+ECERE_APP_OUTRO
diff --git a/bindings/c/samples/helloGUI.c b/bindings/c/samples/helloGUI.c
new file mode 100644 (file)
index 0000000..998104d
--- /dev/null
@@ -0,0 +1,51 @@
+#define MODULE_NAME  "HelloForm"
+// #define __CONSOLE_APP__
+
+#include "ecere.h"
+
+static Class * class_HelloForm;
+
+struct HelloForm { Label label; };
+
+typedef Instance HelloForm;
+
+static bool HelloForm_constructor(HelloForm this)
+{
+   struct HelloForm * self = IPTR(this, HelloForm);
+   Window_set_caption(this, $("My First Ecere/C Bindings App"));
+   Window_set_borderStyle(this, sizable);
+   Window_set_size(this, &(Size){ 380, 190 });
+   Window_set_hasClose(this, true);
+
+   FontResource font = newi(class_FontResource);
+   FontResource_set_faceName(font, "Arial");
+   FontResource_set_size(font, 30);
+
+   /*char tmp[256];
+   String s = Instance_onGetString(0, font, tmp, null, null);
+   PrintLn(class_String, s, null);  // Need to terminate with a null!*/
+
+   self->label = newi(class_Label);
+   Window_set_parent(self->label, this);
+   Window_set_position(self->label, &(Point){ 10, 10 });
+   Window_set_font(self->label, font);
+   Window_set_caption(self->label, $("Hello, Bindings!!"));
+   return true;
+}
+
+static void HelloForm_destructor(HelloForm this)
+{
+   struct HelloForm * self = IPTR(this, HelloForm);
+   deletei(self->label);
+}
+
+GUIAPP_INTRO
+{
+   class_HelloForm = registerClass(app, HelloForm, Window);
+   HelloForm hello = newi(class_HelloForm);
+
+   Application_main(app);
+
+   deletei(hello);
+}
+ECERE_APP_OUTRO
diff --git a/bindings/c/samples/test.epj b/bindings/c/samples/test.epj
new file mode 100644 (file)
index 0000000..6e6680d
--- /dev/null
@@ -0,0 +1,53 @@
+{
+   "Version" : 0.2,
+   "ModuleName" : "EcereCAPI",
+   "Options" : {
+      "Warnings" : "All",
+      "IncludeDirs" : [
+         ".."
+      ],
+      "TargetType" : "Executable",
+      "TargetFileName" : "EcereCAPI",
+      "Libraries" : [
+         "ecere"
+      ]
+   },
+   "Configurations" : [
+      {
+         "Name" : "Debug",
+         "Options" : {
+            "Debug" : true,
+            "Optimization" : "None",
+            "PreprocessorDefinitions" : [
+               "_DEBUG"
+            ],
+            "Console" : true,
+            "FastMath" : false
+         }
+      },
+      {
+         "Name" : "Release",
+         "Options" : {
+            "Debug" : false,
+            "Optimization" : "Speed",
+            "FastMath" : true
+         }
+      }
+   ],
+   "Files" : [
+      {
+         "Folder" : "c",
+         "Files" : [
+            "../eC.c",
+            "../eC.h",
+            "../ecere.c",
+            "../ecere.h"
+         ]
+      },
+      "form.c"
+   ],
+   "ResourcesPath" : "",
+   "Resources" : [
+
+   ]
+}
diff --git a/bindings/cpp/eC.cpp b/bindings/cpp/eC.cpp
new file mode 100644 (file)
index 0000000..6ac6bef
--- /dev/null
@@ -0,0 +1,15 @@
+#include "eC.hpp"
+
+CPPClass<Instance> Instance::_class;
+CPPClass<Module> Module::_class;
+CPPClass<Application> Application::_class;
+
+void eC_cpp_init(Module & module)
+{
+   if(!Instance::_class.impl)
+   {
+      REGISTER_CPP_CLASS(Instance, module);
+      REGISTER_CPP_CLASS(Module, module);
+      REGISTER_CPP_CLASS(Application, module);
+   }
+}
diff --git a/bindings/cpp/eC.hpp b/bindings/cpp/eC.hpp
new file mode 100644 (file)
index 0000000..cffafcc
--- /dev/null
@@ -0,0 +1,360 @@
+// Preprocessor directives can be added at the beginning (Can't store them in AST)
+
+/****************************************************************************
+===========================================================================
+   Core eC Library
+===========================================================================
+****************************************************************************/
+#if !defined(__EC_HPP__)
+#define __EC_HPP__
+
+#include "eC.h"
+
+// Syntactic Sugar (NOT GENERATED)
+#define INSTANCEL(x, c) (*(void **)((char *)(x) + (c)->offset))
+#define _INSTANCE(x, c) INSTANCEL((x) ? (x) : 0, c)
+
+#define INSTANCE(x, c) ({c * _i = (c *)_INSTANCE(x, x->_class); _i ? *_i : c { x }; })
+
+#define newt(t, c) eC_new(class_ ## t->structSize * c)
+
+#define class_vtbl_setup(c) \
+   { typedef void (* Function)(void *); delete [] (Function *)_class->data; _class->data = new Function [_class->vTblSize]; \
+   memset(_class->data, 0, sizeof(Function) * _class->vTblSize); } \
+
+#define _REGISTER_CLASS(n, ns, bs, a) \
+   n::class_registration((Class *)eC_registerClass(normalClass, ns, bs, sizeof(Instance *), 0, \
+      (eC_bool (*)(void *)) n::constructor, (void(*)(void *)) n::destructor, (a).impl, privateAccess, publicAccess))
+
+// For defining _class and registereing together (single translation unit)
+#define REGISTER_CLASS_DEF(n, b, a)    CPPClass<n> n::_class(_REGISTER_CLASS(n,     #n, b::_class.impl->name, a));
+
+// For defining _class and registering separately (multiple translation units)
+#define CLASS_DEF(n)                   CPPClass<n> n::_class;
+#define REGISTER_CLASS(n, b, a)        n::_class.impl = _REGISTER_CLASS(n,       #n, b::_class.impl->name, a);
+
+// For C++ classes proxying eC classes:
+#define REGISTER_CPP_CLASS(n, a)       n::_class.impl = _REGISTER_CLASS(n, "CPP" #n, #n, a);
+
+#define _CONSTRUCT(c, b) \
+   static CPPClass<c> _class; \
+   static eC_bool constructor(eC_Instance i) { if(!Class_isDerived(i->_class, _class.impl)) return new c(i) != null; return true;} \
+   static void destructor(eC_Instance i) { c * inst = (c *)_INSTANCE(i, _class.impl); if(_class.destructor) ((void (*)(c & self))_class.destructor)(*inst); delete inst; } \
+   explicit inline c(eC_Instance _impl, Class * cl = _class.impl) : b(_impl, cl)
+
+#define CONSTRUCT(c, b) \
+   c() : c(Instance_new(_class.impl), _class.impl) { } \
+   _CONSTRUCT(c, b)
+
+#define APP_CONSTRUCT(c, b) \
+   inline c() : c(eC_init_CALL) { } \
+   _CONSTRUCT(c, b)
+
+#if !defined(__WIN32__) || defined(__CONSOLE_APP__)
+   #define APP_SET_ARGS(a) eC_setArgs(app, argc, argv)
+#else
+   #define APP_SET_ARGS(a)
+#endif
+
+#define MAIN_DEFINITION \
+   MAIN_DECLARATION \
+   { \
+      APP_SET_ARGS(app); \
+      app.main(); \
+      unloadTranslatedStrings(MODULE_NAME); \
+      return app.exitCode; \
+   }
+
+#define SELF(c, n)  c * self = ((c *)(((char *)this) - (char *)&((c *)0)->n))
+
+#define VIRTUAL_METHOD(n, c, b, r, p, sp, d) \
+   struct c ## _ ## n ## _Functor \
+   { \
+      int _[0]; \
+      typedef r (* FunctionType)p; \
+      FunctionType operator= (FunctionType func) \
+      { \
+         SELF(c, n); \
+         if(self->vTbl == c::_class.impl->data) \
+         { \
+            uint size = c :: _class.impl->vTblSize; \
+            self->vTbl = (void (**)())new FunctionType[size]; \
+            memcpy(self->vTbl, c::_class.impl->data, sizeof(FunctionType) * size); \
+         } \
+         ((FunctionType *)self->vTbl)[b ## _ ## n ## _vTblID] = func; \
+         return func; \
+      } \
+      r operator()sp \
+      { \
+         SELF(c, n); \
+         d; \
+      } \
+   } n; \
+   static void register_ ## n(Class * cl, c ## _ ## n ## _Functor::FunctionType func) \
+   { \
+      ((c ## _ ## n ## _Functor::FunctionType *)cl->data)[b ## _ ## n ## _vTblID] = func; \
+   }
+
+#define REGISTER_METHOD(ns, n, bc, c, r, p, o, a, ea, rv) \
+   addMethod(_class, ns, (void *) +[]p \
+   { \
+      Class * cl = (Class *)o->_class; \
+      c * i = (c *)_INSTANCE(o, cl); \
+      if(i) \
+      { \
+         int vid = bc ## _ ## n ## _vTblID; \
+         if(i->vTbl && i->vTbl[vid]) \
+         { \
+            return ((bc ## _ ## n ## _Functor::FunctionType)i->vTbl[vid]) a; \
+         } \
+         else \
+         { \
+            auto method = ((r (*) p)(class_ ## c->_vTbl)[bc ## _ ## n ## _vTblID]); \
+            if(method) return method ea; \
+         } \
+      } \
+      return rv; \
+   })
+
+#define property(n, sg) struct n ## Prop { n ## Prop() { }; int _[0]; sg } n;
+
+#define _set(t, n, d) \
+   inline t operator= (t v) \
+   { \
+      PSELF; \
+      d; \
+      return v; \
+   } \
+
+#define set(t, n, d) \
+   _set(t, n, d) \
+   inline n ## Prop & operator= (n ## Prop & prop) \
+   { \
+      PSELF; \
+      t v = prop; \
+      d; \
+      return prop; \
+   }
+
+#define get(t, n, d) inline operator t () const { PSELF; d; }
+
+extern "C" eC_Module ecere_init(eC_Module fromModule);
+
+class Class : public eC_Class { };
+
+template <class T>
+class CPPClass
+{
+public:
+   Class * impl;
+   void (*destructor)(T &);
+
+   CPPClass() { };
+   CPPClass(Class * _impl) : impl(_impl) { }
+   ~CPPClass()
+   {
+      if(impl)
+         delete [] (void (**)(void))impl->data;
+   }
+};
+
+// GENERATED: (Instance, Module and Application might require some custom tweaks...)
+
+// Normal Class Definitions
+class Instance
+{
+public:
+   static CPPClass<Instance> _class;
+   eC_Instance impl;
+   void (**vTbl)(void);
+
+   static eC_bool constructor(eC_Instance i) { if(!Class_isDerived(i->_class, _class.impl)) return new Instance(i) != null; return true; }
+   static void destructor(eC_Instance i) { Instance * inst = (Instance *)_INSTANCE(i, _class.impl); delete inst; }
+
+   inline explicit Instance(eC_Instance _impl, Class * c = _class.impl)
+   {
+      impl = _impl;
+      vTbl = c ? (void (**)(void))c->data : null;
+      if(impl)
+      {
+         if(c && !_INSTANCE(impl, c))
+            _INSTANCE(impl, c) = this;
+         impl->_refCount++;
+      }
+   }
+
+   inline Instance()
+   {
+      impl = null;
+      vTbl = null;
+   }
+
+   inline ~Instance()
+   {
+      if(impl && impl->_class)
+      {
+         Instance ** i = (Instance **)&INSTANCEL(impl, impl->_class);
+         if(i && *i == this)
+            *i = null;
+         if(vTbl && vTbl != impl->_class->data)
+            delete [] vTbl;
+         Instance_decref(impl);
+      }
+   }
+
+   inline Instance(const Instance & i)
+   {
+      impl = i.impl;
+      vTbl = null;
+      if(impl)
+      {
+         impl->_refCount++;
+         if(i.vTbl)
+            vTbl = i.vTbl;
+      }
+   }
+
+   static Class * class_registration(Class * _class) { return _class; }
+};
+
+class Module : public Instance
+{
+public:
+   static CPPClass<Module> _class;
+   inline explicit Module(eC_Instance _impl, Class * c = _class.impl) : Instance(_impl, c) { }
+};
+
+void eC_cpp_init(Module & module);
+void ecere_cpp_init(Module & module);
+
+#define Application_class_registration(c, d) \
+   REGISTER_METHOD("Main", main, Application, d, void, (eC_Instance o), o, (*i), (o), );
+
+class Application : public Module
+{
+public:
+   APP_CONSTRUCT(Application, Module)
+   {
+      eC_cpp_init(*this);
+      _INSTANCE(impl, impl->_class) = this;
+      vTbl = (void (**)(void))_class.impl->data;
+
+      // TODO: Omit this if we're linking against eC rt only
+      ecere_init(impl);
+      ecere_cpp_init(*this);
+#ifdef MODULE_NAME
+      loadTranslatedStrings(null, MODULE_NAME);
+#endif
+   }
+
+   static Class * class_registration(Class * _class) { Application_class_registration(_class, Application); class_vtbl_setup(_class); return _class; }
+
+   #undef   PSELF
+   #define  PSELF SELF(Application, exitCode)
+   property(exitCode, get(int, exitCode, return self ? _IPTR(self->impl, class_Application, class_members_Application)->exitCode : 0) );
+
+   VIRTUAL_METHOD(main, Application, Application, void, (Application &), (),
+      return Application_main(self->impl));
+};
+
+class Container : public Instance
+{
+public:
+   CONSTRUCT(Container, Instance) { }
+/*
+   inline IteratorPointer getFirst(void) { return Container_getFirst(impl); }
+   inline IteratorPointer getLast(void)  { return Container_getLast(impl); }
+   inline IteratorPointer getPrev(IteratorPointer * pointer) { return Container_getPrev(impl, pointer); }
+   inline IteratorPointer getNext(IteratorPointer * pointer) { return Container_getNext(impl, pointer); }
+   inline Container_D getData(IteratorPointer * pointer) { return (return Container_getData(impl, pointer); }
+   inline bool setData(IteratorPointer * pointer, Container_D data) { return Container_setData(impl, pointer, data); }
+   inline IteratorPointer getAtPosition(const Container_I pos, bool create, bool * justAdded) { return Container_getAtPosition(impl, pos, create, justAdded); }
+   inline IteratorPointer insert(IteratorPointer * after, Container_T value) { return Container_insert(impl, after, value); }
+   inline IteratorPointer add(Container_T value) { return Container_add(impl, value) }
+   inline void remove(IteratorPointer * it) { Container_remove(impl, it); }
+   inline void move(IteratorPointer * it, IteratorPointer * after) { Container_move(impl, it, after); }
+   inline void removeAll() { Container_removeAll(impl); }
+   inline void copy(Container <T> source) { Container_copy(impl, source); }  // Container <T> source
+   inline IteratorPointer find(const Container_D value) { return Container_find(impl, value); }
+   inline void freeIterator(IteratorPointer * it) { Container_freeIterator(impl, it); }
+   inline int getCount() { return Container_getCount(impl); }
+   inline void free() { Container_free(impl); }
+   inline void deleteItem(IteratorPointer * i) { Container_deleteItem(impl, i); }
+   inline void takeOut(const Container_D d) { Container_takeOut(impl, d); }
+*/
+};
+
+// Non-Events like methods
+//    1. The methods will call the eC methods through the C bindings
+//    2. This shound end up calling static class virtual table if overriden
+//    3. Registering a method (e.g. onRedraw) needs to call addMethod to update the virtual table, with C callback
+
+class Array : Container
+{
+public:
+   CONSTRUCT(Array, Container) { }
+};
+
+class CustomAVLTree : Container
+{
+public:
+   CONSTRUCT(CustomAVLTree, Container) { }
+};
+
+class AVLTree : CustomAVLTree
+{
+public:
+   CONSTRUCT(AVLTree, CustomAVLTree) { }
+};
+
+class Map : CustomAVLTree
+{
+public:
+   CONSTRUCT(Map, CustomAVLTree) { }
+};
+
+class LinkList : Container
+{
+public:
+   CONSTRUCT(LinkList, Container) { }
+};
+
+class List : LinkList
+{
+public:
+   CONSTRUCT(List, LinkList) { }
+};
+
+class IOChannel : Instance
+{
+public:
+   CONSTRUCT(IOChannel, Instance) { }
+};
+
+class SerialBuffer : IOChannel
+{
+public:
+   CONSTRUCT(SerialBuffer, IOChannel) { }
+};
+
+class OldArray : Instance
+{
+public:
+   CONSTRUCT(OldArray, Instance) { }
+};
+
+// How to handle inheritance from classes not loaded yet?
+/*
+class ClassDesignerBase : Window
+{
+public:
+   CONSTRUCT(ClassDesignerBase, Window) { }
+};
+class DesignerBase : Window
+{
+public:
+   CONSTRUCT(DesignerBase, Window) { }
+};
+*/
+
+#endif
diff --git a/bindings/cpp/ecere.cpp b/bindings/cpp/ecere.cpp
new file mode 100644 (file)
index 0000000..b1bd4bf
--- /dev/null
@@ -0,0 +1,23 @@
+#include "ecere.hpp"
+
+CPPClass<GuiApplication> GuiApplication::_class;
+CPPClass<Surface> Surface::_class;
+CPPClass<FontResource> FontResource::_class;
+CPPClass<Window> Window::_class;
+CPPClass<Button> Button::_class;
+CPPClass<Label> Label::_class;
+CPPClass<MessageBox> MessageBox::_class;
+
+void ecere_cpp_init(Module & module)
+{
+   if(!GuiApplication::_class.impl)
+   {
+      REGISTER_CPP_CLASS(Surface, module);
+      REGISTER_CPP_CLASS(FontResource, module);
+      REGISTER_CPP_CLASS(GuiApplication, module);
+      REGISTER_CPP_CLASS(Window, module);
+      REGISTER_CPP_CLASS(Button, module);
+      REGISTER_CPP_CLASS(Label, module);
+      REGISTER_CPP_CLASS(MessageBox, module);
+   }
+}
diff --git a/bindings/cpp/ecere.hpp b/bindings/cpp/ecere.hpp
new file mode 100644 (file)
index 0000000..6458b89
--- /dev/null
@@ -0,0 +1,232 @@
+/****************************************************************************
+===========================================================================
+   Ecere Module
+===========================================================================
+****************************************************************************/
+#if !defined(__ECERE_HPP__)
+#define __ECERE_HPP__
+
+#include "eC.hpp"
+#include "ecere.h"
+
+/****************************************************************************
+   ecere::gfx Namespace
+****************************************************************************/
+///////////// Surface Class /////////////////////////////////////////////////
+class Surface : public Instance
+{
+public:
+   CONSTRUCT(Surface, Instance) { }
+
+   inline void writeTextf(int x, int y, const char * format, ...)
+   {
+      Surface_writeTextf(impl, x, y, format);   // var args are a pain to pass...
+   }
+};
+
+///////////// FontResource Class /////////////////////////////////////////////////
+class FontResource : public Instance
+{
+public:
+   CONSTRUCT(FontResource, Instance) { }
+
+   inline FontResource(constString faceName, float size = 10, eC_bool bold = false, eC_bool italic = false) : FontResource()
+   {
+      this->faceName = faceName;
+      this->size = size;
+      this->bold = bold;
+      this->italic = italic;
+   }
+
+   #undef PSELF
+   #define PSELF SELF(FontResource, bold)
+
+   property(bold,
+      set(eC_bool, bold, FontResource_set_bold(self ? self->impl : null, v))
+      get(eC_bool, bold, return FontResource_get_bold(self ? self->impl : null))
+   );
+   property(italic,
+      set(eC_bool, italic, FontResource_set_italic(self ? self->impl : null, v))
+      get(eC_bool, italic, return FontResource_get_italic(self ? self->impl : null))
+   );
+   property(faceName,
+      set(constString, faceName, FontResource_set_faceName(self ? self->impl : null, v))
+      get(constString, faceName, return FontResource_get_faceName(self ? self->impl : null))
+   );
+   property(size,
+      set(float, size, FontResource_set_size(self ? self->impl : null, v))
+      get(float, size, return FontResource_get_size(self ? self->impl : null))
+   );
+};
+
+/****************************************************************************
+   ecere::gui Namespace
+****************************************************************************/
+///////////// Window Class /////////////////////////////////////////////////
+#define Window_class_registration(c, d) \
+   REGISTER_METHOD("OnRedraw", onRedraw, Window, d, void, (eC_Instance o, eC_Instance s),    o, (*i, Surface { s }), (o, s), ); \
+   REGISTER_METHOD("OnCreate", onCreate, Window, d, bool, (eC_Instance o),                     o, (*i),                (o),    true);
+
+bool foo(eC_Instance o);
+
+class Window : public Instance
+{
+public:
+   CONSTRUCT(Window, Instance) { }
+
+   static Class * class_registration(Class * _class) { Window_class_registration(_class, Window); class_vtbl_setup(_class); return _class; }
+
+   VIRTUAL_METHOD(onCreate, Window, Window, bool, (Window &), (),
+      return Window_onCreate(self->impl));
+   VIRTUAL_METHOD(onRedraw, Window, Window, void, (Window &, Surface), (Surface surface),
+      return Window_onRedraw(self->impl, surface.impl));
+
+   DialogResult modal() { return Window_modal(impl); }
+
+   // TOCHECK: See if we'll need set/get methods in addition to 'properties' for SWIG
+   //void set_size(const Size & v) { Window_set_size(impl, &v); }
+   //void set_hasClose(eC_bool v)  { Window_set_hasClose(impl, v); }
+
+   #undef   PSELF
+   #define  PSELF SELF(Window, parent)
+
+   property(parent,
+      set(const Window &, parent, Window_set_parent(self ? self->impl : null, v.impl))
+      get(Window &, parent,
+         eC_Instance i = Window_get_parent(self ? self->impl : null);
+         return *(Window *)_INSTANCE(i, Window::_class.impl))
+
+      _set(const Window *, parent, Window_set_parent(self ? self->impl : null, v ? v->impl : null))
+      get(Window *, parent,
+         eC_Instance i = Window_get_parent(self ? self->impl : null);
+         return i ? (Window *)_INSTANCE(i, Window::_class.impl) : null)
+
+      get(Window, parent, return Window(Window_get_parent(self ? self->impl : null)));
+   );
+   property(size,
+      set(const Size &, size, Window_set_size(self ? self->impl : null, &v))
+      get(Size, size, { Size v; Window_get_size(self ? self->impl : null, &v); return v; })
+   );
+   property(clientSize,
+      set(const Size &, clientSize, Window_set_clientSize(self ? self->impl : null, &v))
+      get(Size,         clientSize, { Size v; Window_get_clientSize(self ? self->impl : null, &v); return v; })
+   );
+   property(position,
+      set(const Point &, position, Window_set_position(self ? self->impl : null, &v))
+      get(Point,         position, { Point v; Window_get_position(self ? self->impl : null, &v); return v; })
+   );
+   property(hasClose,
+      set(eC_bool, hasClose, Window_set_hasClose(self ? self->impl : null, v))
+      get(eC_bool, hasClose, return Window_get_hasClose(self ? self->impl : null))
+   );
+   property(hasMinimize,
+      set(eC_bool, hasMinimize, Window_set_hasMinimize(self ? self->impl : null, v))
+      get(eC_bool, hasMinimize, return Window_get_hasMinimize(self ? self->impl : null))
+   );
+   property(hasMaximize,
+      set(eC_bool, hasMaximize, Window_set_hasMaximize(self ? self->impl : null, v))
+      get(eC_bool, hasMaximize, return Window_get_hasMaximize(self ? self->impl : null))
+   );
+   property(caption,
+      set(constString, caption, Window_set_caption(self ? self->impl : null, v))
+      get(constString, caption, return Window_get_caption(self ? self->impl : null))
+   );
+   property(font,
+      set(const FontResource &, font, Window_set_font(self ? self->impl : null, v.impl))
+      get(FontResource &, font,
+            eC_Instance i = Window_get_font(self ? self->impl : null);
+            return *(FontResource *)_INSTANCE(i, FontResource::_class.impl))
+
+      _set(const FontResource *, font, Window_set_font(self ? self->impl : null, v->impl))
+      get(FontResource *, font,
+            eC_Instance i = Window_get_font(self ? self->impl : null);
+            return i ? (FontResource *)_INSTANCE(i, FontResource::_class.impl) : null)
+
+      get(FontResource, font, return FontResource(Window_get_font(self ? self->impl : null)))
+   );
+   property(borderStyle,
+      set(BorderStyle, borderStyle, Window_set_borderStyle(self ? self->impl : null, v))
+      get(BorderStyle, borderStyle, return Window_get_borderStyle(self ? self->impl : null))
+   );
+   property(background,
+      set(Color, background, Window_set_background(self ? self->impl : null, v))
+      get(Color, background, return Window_get_background(self ? self->impl : null))
+   );
+};
+
+///////////// Label Class /////////////////////////////////////////////////
+class Label : public Window
+{
+public:
+   CONSTRUCT(Label, Window) { }
+
+   static Class * class_registration(Class * _class) { Window_class_registration(_class, Label); class_vtbl_setup(_class); return _class; }
+};
+
+///////////// MessageBox Class /////////////////////////////////////////////////
+class MessageBox : public Window
+{
+public:
+   CONSTRUCT(MessageBox, Window) { }
+
+   MessageBox(constString contents, constString caption = ""/*,  MessageBoxType type = ok*/) : MessageBox()
+   {
+      this->contents = contents;
+      this->caption = caption;
+   }
+   static Class * class_registration(Class * _class) { Window_class_registration(_class, MessageBox); class_vtbl_setup(_class); return _class; }
+
+   #undef PSELF
+   #define PSELF SELF(MessageBox, contents)
+
+   property(contents,
+      set(constString, contents, MessageBox_set_contents(self ? self->impl : null, v))
+      get(constString, contents, return MessageBox_get_contents(self ? self->impl : null))
+   );
+};
+
+///////////// Button Class /////////////////////////////////////////////////
+#define Button_class_registration(c, d) \
+   Window_class_registration(_class, d); \
+   REGISTER_METHOD("NotifyClicked", notifyClicked, Button, d, \
+      bool, (eC_Instance m, eC_Instance b, int x, int y, Modifiers mods), \
+      b, (*(Window *)INSTANCEL(m, m->_class), *(Button *)INSTANCEL(b, b->_class), x, y, mods), \
+      (m, b, x, y, mods), true);
+
+class Button : public Window
+{
+public:
+   CONSTRUCT(Button, Window) { }
+
+   static Class * class_registration(Class * _class) { Button_class_registration(_class, Button); class_vtbl_setup(_class); return _class; }
+
+   VIRTUAL_METHOD(notifyClicked, Button, Button, bool, (Window &, Button &, int, int, Modifiers), (Window & window, Button & button, int x, int y, Modifiers mods),
+      return Button_notifyClicked(self->impl, window.impl, button.impl, x, y, mods));
+};
+
+///////////// ToolButton Class /////////////////////////////////////////////////////
+class ToolButton : public Button
+{
+public:
+   CONSTRUCT(ToolButton, Button) { }
+   static Class * class_registration(Class * _class) { Button_class_registration(_class, ToolButton); class_vtbl_setup(_class); return _class; }
+
+   #undef PSELF
+   #define PSELF SELF(ToolButton, Foo)
+};
+
+///////////// GuiApplication Class /////////////////////////////////////////////////
+class GuiApplication : public Application
+{
+public:
+   APP_CONSTRUCT(GuiApplication, Application)
+   {
+      Instance_evolve(&impl, GuiApplication::_class.impl);
+      _INSTANCE(impl, impl->_class) = this;
+      vTbl = (void (**)(void))_class.impl->data;
+   }
+
+   static Class * class_registration(Class * _class) { Application_class_registration(_class, GuiApplication); class_vtbl_setup(_class); return _class; }
+};
+
+#endif
diff --git a/bindings/cpp/samples/helloGUI.cpp b/bindings/cpp/samples/helloGUI.cpp
new file mode 100644 (file)
index 0000000..ee8e5be
--- /dev/null
@@ -0,0 +1,35 @@
+#define MODULE_NAME  "HelloForm"
+// #define __CONSOLE_APP__
+
+#include "ecere.hpp"
+
+class HelloForm : public Window
+{
+public:
+   Label label;
+
+   CONSTRUCT(HelloForm, Window)
+   {
+      caption = $("My First Ecere/C++ Bindings App");
+      borderStyle = sizable;
+      size = { 380, 190 };
+      hasClose = true;
+
+      label.parent = this;
+      label.caption = $("Hello, Bindings!!");
+      label.position = { 10, 10 };
+      label.font = { "Arial", 30 };
+
+      //char tmp[256];
+      //String s = Instance_onGetString(0, font, tmp, null, null);
+      //PrintLn(class_String, s, null);  // Need to terminate with a null!
+   }
+};
+
+GuiApplication app;
+
+REGISTER_CLASS_DEF(HelloForm, Window, app);
+
+HelloForm hello;
+
+MAIN_DEFINITION;
diff --git a/bindings/cpp/samples/sample1.cpp b/bindings/cpp/samples/sample1.cpp
new file mode 100644 (file)
index 0000000..ac81a11
--- /dev/null
@@ -0,0 +1,50 @@
+#define MODULE_NAME  "HelloForm"
+
+#include "ecere.hpp"
+
+class HelloForm : public Window
+{
+public:
+   Button button;
+
+   CONSTRUCT(HelloForm, Window)
+   {
+      caption = $("Sample App using Ecere Toolkit/C++ Bindings");
+      borderStyle = sizable;
+      clientSize = { 640, 480 };
+      hasClose = true;
+      hasMaximize = true;
+      hasMinimize = true;
+      background = formColor;
+      font = { "Arial", 30 };
+
+      button.parent = this;
+      button.position = { 200, 200 };
+      button.caption = $("Yay!!");
+      button.notifyClicked = [](Window & owner, Button & btn, int x, int y, Modifiers mods)
+      {
+         HelloForm & self = (HelloForm &)owner;
+         MessageBox msgBox;
+         msgBox.caption = self.button.caption;
+         msgBox.contents = $("C++ Bindings!");
+         msgBox.modal();
+         return true;
+      };
+   }
+
+   static Class * class_registration(Class * _class)
+   {
+      Window::class_registration(_class);
+      register_onRedraw(_class, [](Window & w, Surface surface) { surface.writeTextf(100, 100, $("Class Method!")); });
+      HelloForm::_class.destructor = [](HelloForm & self) { printf("It's the end my friend!\n"); };
+      return _class;
+   }
+};
+
+GuiApplication app;
+
+REGISTER_CLASS_DEF(HelloForm, Window, app);
+
+HelloForm hello;
+
+MAIN_DEFINITION;
diff --git a/bindings/cpp/samples/sample2.cpp b/bindings/cpp/samples/sample2.cpp
new file mode 100644 (file)
index 0000000..256bef7
--- /dev/null
@@ -0,0 +1,55 @@
+#define MODULE_NAME  "HelloForm"
+
+#include "ecere.hpp"
+
+class HelloForm : public Window
+{
+public:
+   Button button;
+
+   CONSTRUCT(HelloForm, Window)
+   {
+      caption = $("Sample App using Ecere Toolkit/C++ Bindings");
+      borderStyle = sizable;
+      clientSize = { 640, 480 };
+      hasClose = true;
+      hasMaximize = true;
+      hasMinimize = true;
+      background = formColor;
+      font = { "Arial", 30 };
+
+      button.parent = this;
+      button.position = { 200, 200 };
+      button.caption = $("Yay!!");
+      button.notifyClicked = [](Window & owner, Button & btn, int x, int y, Modifiers mods)
+      {
+         HelloForm & self = (HelloForm &)owner;
+         MessageBox msgBox;
+         msgBox.caption = self.button.caption;
+         msgBox.contents = $("C++ Bindings!");
+         msgBox.modal();
+         return true;
+      };
+   }
+
+   static Class * class_registration(Class * _class)
+   {
+      Window::class_registration(_class);
+      register_onRedraw(_class, [](Window & w, Surface surface) { surface.writeTextf(100, 100, $("Class Method!")); });
+      return _class;
+   }
+};
+
+GuiApplication app;
+
+CLASS_DEF(HelloForm);
+
+MAIN_DECLARATION
+{
+   REGISTER_CLASS(HelloForm, Window, app);
+   APP_SET_ARGS(app);
+   HelloForm hello;
+   app.main();
+   unloadTranslatedStrings(MODULE_NAME);
+   return app.exitCode;
+}
diff --git a/bindings/cpp/samples/sample3.cpp b/bindings/cpp/samples/sample3.cpp
new file mode 100644 (file)
index 0000000..161a335
--- /dev/null
@@ -0,0 +1,62 @@
+#define MODULE_NAME  "HelloForm"
+
+#include "ecere.hpp"
+
+class HelloForm : public Window
+{
+public:
+   Button button;
+
+   CONSTRUCT(HelloForm, Window)
+   {
+      caption = $("Sample App using Ecere Toolkit/C++ Bindings");
+      borderStyle = sizable;
+      clientSize = { 640, 480 };
+      hasClose = true;
+      hasMaximize = true;
+      hasMinimize = true;
+      background = formColor;
+      font = { "Arial", 30 };
+
+      button.parent = this;
+      button.position = { 200, 200 };
+      button.caption = $("Yay!!");
+      button.notifyClicked = [](Window & owner, Button & btn, int x, int y, Modifiers mods)
+      {
+         HelloForm & self = (HelloForm &)owner;
+         MessageBox msgBox;
+         msgBox.caption = self.button.caption;
+         msgBox.contents = $("C++ Bindings!");
+         msgBox.modal();
+         return true;
+      };
+   }
+
+   static Class * class_registration(Class * _class)
+   {
+      Window::class_registration(_class);
+      register_onRedraw(_class, [](Window & w, Surface surface) { surface.writeTextf(100, 100, $("Class Method!")); });
+      return _class;
+   }
+};
+
+class MyApplication : public GuiApplication
+{
+public:
+   APP_CONSTRUCT(MyApplication, GuiApplication) { }
+
+   void main()
+   {
+      HelloForm hello;
+
+      GuiApplication::main();
+   }
+};
+
+MyApplication app;
+
+REGISTER_CLASS_DEF(MyApplication, GuiApplication, app);
+
+REGISTER_CLASS_DEF(HelloForm, Window, app);
+
+MAIN_DEFINITION;
diff --git a/bindings/cpp/samples/sample4.cpp b/bindings/cpp/samples/sample4.cpp
new file mode 100644 (file)
index 0000000..08f8f75
--- /dev/null
@@ -0,0 +1,43 @@
+#define MODULE_NAME  "HelloForm"
+
+#include "ecere.hpp"
+
+class HelloForm : public Window
+{
+public:
+   Button button;
+
+   CONSTRUCT(HelloForm, Window)
+   {
+      caption = $("Sample App using Ecere Toolkit/C++ Bindings");
+      borderStyle = sizable;
+      clientSize = { 640, 480 };
+      hasClose = true;
+      hasMaximize = true;
+      hasMinimize = true;
+      background = formColor;
+      font = { "Arial", 30 };
+
+      button.parent = this;
+      button.position = { 200, 200 };
+      button.caption = $("Yay!!");
+      button.notifyClicked = [](Window & owner, Button & btn, int x, int y, Modifiers mods)
+      {
+         HelloForm & self = (HelloForm &)owner;
+         MessageBox msgBox;
+         msgBox.caption = self.button.caption;
+         msgBox.contents = $("C++ Bindings!");
+         msgBox.modal();
+         return true;
+      };
+
+      onRedraw = [](Window & w, Surface surface) { surface.writeTextf(100, 100, $("Instance Method!")); };
+   }
+};
+GuiApplication app;
+
+REGISTER_CLASS_DEF(HelloForm, Window, app);
+
+HelloForm hello;
+
+MAIN_DEFINITION;
diff --git a/bindings/cpp/samples/test.epj b/bindings/cpp/samples/test.epj
new file mode 100644 (file)
index 0000000..6113303
--- /dev/null
@@ -0,0 +1,63 @@
+{
+   "Version" : 0.2,
+   "ModuleName" : "test",
+   "Options" : {
+      "Warnings" : "All",
+      "IncludeDirs" : [
+         "..",
+         "../../c"
+      ],
+      "TargetType" : "Executable",
+      "TargetFileName" : "test",
+      "Libraries" : [
+         "ecere"
+      ]
+   },
+   "Configurations" : [
+      {
+         "Name" : "Debug",
+         "Options" : {
+            "Debug" : true,
+            "Optimization" : "None",
+            "PreprocessorDefinitions" : [
+               "_DEBUG"
+            ],
+            "Console" : true,
+            "FastMath" : false
+         }
+      },
+      {
+         "Name" : "Release",
+         "Options" : {
+            "Debug" : false,
+            "Optimization" : "Speed",
+            "FastMath" : true
+         }
+      }
+   ],
+   "Files" : [
+      {
+         "Folder" : "c",
+         "Files" : [
+            "../../c/eC.c",
+            "../../c/eC.h",
+            "../../c/ecere.c",
+            "../../c/ecere.h"
+         ]
+      },
+      {
+         "Folder" : "cpp",
+         "Files" : [
+            "../eC.cpp",
+            "../eC.hpp",
+            "../ecere.cpp",
+            "../ecere.hpp"
+         ]
+      },
+      "sample1.cpp"
+   ],
+   "ResourcesPath" : "",
+   "Resources" : [
+
+   ]
+}