int (*PrintStdArgsToBuffer)(char *buffer, int maxLen, Class * class_object, const void * object, va_list args);
char *(*PrintString)(Class * class_object, const 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);
+// 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);
int onUnserialize_vTblID;
int onSaveEdit_vTblID;
+Class * class_Module;
+
int Application_main_vTblID;
Method * method_Application_main;
class_Instance = eC_findClass(app, "Instance");
+ class_Module = eC_findClass(app, "Module");
+
class_Application = eC_findClass(app, "Application");
if(class_Application)
{
}
return app;
}
+
+Module __thisModule;
#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 newi(c) ({ eC_Instance i = Instance_new(c); incref(i); i; })
+#define newc(t, c) (t *)eC_new(class_ ## t->structSize * c)
+#define newt(t, c) (t *)eC_new(sizeof(t) * c)
#define deletei(v) Instance_decref(v), v = null
#ifndef __cplusplus
#define Module_load __ecereNameSpace__ecere__com__eModule_Load
#define Instance_new __ecereNameSpace__ecere__com__eInstance_New
+#define Instance_newEx __ecereNameSpace__ecere__com__eInstance_NewEx
#define Instance_delete __ecereNameSpace__ecere__com__eInstance_Delete
#define Instance_decref __ecereNameSpace__ecere__com__eInstance_DecRef
#define Instance_evolve __ecereNameSpace__ecere__com__eInstance_Evolve
};
#endif
-enum BackSlashEscaping
#if CPP11
- : uint32
+enum BackSlashEscaping : uint32
+#else
+enum enum_BackSlashEscaping
#endif
{ forArgsPassing = 2 };
{
BTNode * root;
int count;
+ int (*CompareKey)(BinaryTree * tree, uintptr a, uintptr b);
+ void (*FreeKey)(void * key);
};
struct OldList
NameSpace * nameSpace;
const char *dataTypeString;
Type dataType;
- void (*Initialize)();
int typeSize;
int defaultAlignment;
+ void (*Initialize)();
int memberOffset;
OldList selfWatchers;
const char *designerClass;
int numParams;
bool isInstanceClass;
bool byValueSystemClass;
+ void * bindingsClass;
};
struct ClassProperty
{
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_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)) void __ecereNameSpace__ecere__com__eClass_Unregister(Class * _class);
extern __attribute__((dllimport)) Instance __ecereNameSpace__ecere__com__eInstance_New(Class * _class);
+extern __attribute__((dllimport)) Instance __ecereNameSpace__ecere__com__eInstance_NewEx(Class * _class, bool bindingsAlloc);
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__LoadTranslatedStrings(constString moduleName, constString name);
extern __attribute__((dllimport)) void __ecereNameSpace__ecere__UnloadTranslatedStrings(constString name);
+extern Module __thisModule;
+
// Global Functions
extern void (*CheckConsistency)(void);
extern void (*CheckMemory)(void);
extern int (*PrintStdArgsToBuffer)(char *buffer, int maxLen, Class * class_object, const void * object, va_list args);
extern char *(*PrintString)(Class * class_object, const 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 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);
// Instance Class
extern Class * class_Instance;
+// Module Class
+extern Class * class_Module;
+
// Application Class
extern Class * class_Application;
typedef Color SystemColor;
#endif
-enum SystemColor
#if CPP11
- : Color
+enum SystemColor : Color
+#else
+enum enum_Color
#endif
{
formColor = COLOR(229, 234, 245)
#endif
// Enumerations
-enum DialogResult
+
#if CPP11
- : int64
+enum DialogResult : int64
+#else
+enum enum_DialogResult
#endif
{
cancel = 0,
ok = 3
};
-enum BorderStyle
#if CPP11
- : BorderBits
+enum BorderStyle : BorderBits
+#else
+enum enum_BorderStyle
#endif
{
none,
#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)
+#undef newi
+#define newi(c) Instance_newEx(c, true)
#define _REGISTER_CLASS(n, ns, bs, a) \
(Class *)eC_registerClass(normalClass, ns, bs, sizeof(Instance *), 0, \
#define _CONSTRUCT(c, b) \
INSTANCE_VIRTUAL_METHODS(c) \
static TCPPClass<c> _class; \
- static eC_bool constructor(eC_Instance i) { if(!Class_isDerived(i->_class, _class.impl)) return new c(i) != null; return true;} \
+ static eC_bool constructor(eC_Instance i, eC_bool alloc) { return (alloc && !_INSTANCE(i, _class.impl)) ? new c(i, _class) != null : 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, CPPClass & cl = _class) : b(_impl, cl)
#define CONSTRUCT(c, b) \
- c() : c(Instance_new(_class.impl), _class) { } \
+ c() : c(Instance_newEx(_class.impl, false), _class) { } \
_CONSTRUCT(c, b)
#define DESTRUCT(c) \
#endif
#define MAIN_DEFINITION \
- MAIN_DECLARATION \
+ extern "C" MAIN_DECLARATION \
{ \
APP_SET_ARGS(app); \
app.main(); \
return app.exitCode; \
}
-#define SELF(c, n) c * self = ((c *)(((char *)this) - (char *)&((c *)0)->n))
+#define SELF(c, n) c * self = ((c *)(((char *)this) + 0x10 - (char *)&((c *)0x10)->n))
#define _ARG ,
if(self->vTbl == c::_class.vTbl) \
{ \
uint size = c :: _class.impl->vTblSize; \
- self->vTbl = (void (**)())new FunctionType[size]; \
+ self->vTbl = (void (**)())newt(FunctionType, size); \
memcpy(self->vTbl, c::_class.vTbl, sizeof(FunctionType) * size); \
} \
((FunctionType *)self->vTbl)[b ## _ ## n ## _vTblID] = func; \
#define REGISTER_TYPED_METHOD(ns, n, bc, c, r, p, ocl, oi, code, ea, rv) \
_REGISTER_METHOD(\
- CPPClass * cppcl = _class ? (CPPClass *)_class->data : null;, \
+ CPPClass * cppcl = _class ? (CPPClass *)_class->bindingsClass : null;, \
else if(cppcl && cppcl->vTbl && cppcl->vTbl[vid]) \
{ \
fn = (bc ## _ ## n ## _Functor::FunctionType) cppcl->vTbl[vid]; \
#define property(n, sg) struct n ## Prop { n ## Prop() { }; int _[0]; sg } n;
-#define _set(t, n, d) \
+#define _set(t, n, c, d) \
inline t operator= (t v) \
{ \
- PSELF; \
+ SELF(c, n); \
d; \
return v; \
} \
-#define set(t, n, d) \
- _set(t, n, d) \
+#define set(t, n, c, d) \
+ _set(t, n, c, d) \
inline n ## Prop & operator= (n ## Prop & prop) \
{ \
- PSELF; \
+ SELF(c, n); \
t v = prop; \
d; \
return prop; \
}
-#define get(t, n, d) inline operator t () const { PSELF; d; }
+#define get(t, n, c, d) inline operator t () const { SELF(c, n); d; }
extern "C" eC_Module ecere_init(eC_Module fromModule);
impl = _impl;
if(impl)
{
- _impl->data = this;
- if(vTbl) delete [] vTbl;
- vTbl = new Function[impl->vTblSize];
+ _impl->bindingsClass = this;
+ if(vTbl) eC_delete(vTbl);
+ vTbl = newt(Function, impl->vTblSize);
memset(vTbl, 0, sizeof(Function) * impl->vTblSize);
T::class_registration(*this);
}
~TCPPClass()
{
if(impl)
- delete [] vTbl;
+ eC_delete(vTbl);
}
};
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; }
+ void * operator new (uintsize count) { return eC_new(count); }
+ void * operator new [](uintsize count) { return eC_new(count); }
+ void operator delete (void * ptr) { eC_delete(ptr); }
+ void operator delete [](void * ptr) { eC_delete(ptr); }
+
+ static eC_bool constructor(eC_Instance i, bool alloc)
+ {
+ if(alloc &&!_INSTANCE(i, _class.impl))
+ return new Instance(i, _class) != null;
+ return true;
+ }
static void destructor(eC_Instance i) { Instance * inst = (Instance *)_INSTANCE(i, _class.impl); delete inst; }
static void class_registration(CPPClass & _class);
- //static void class_registration(CPPClass & _class) { Instance_class_registration(Instance); }
INSTANCE_VIRTUAL_METHODS(Instance);
{
if(impl && impl->_class)
{
- if(impl->_class->data)
+ if(impl->_class->bindingsClass)
{
Instance ** i = (Instance **)&INSTANCEL(impl, impl->_class);
if(i && *i == this)
*i = null;
if(vTbl)
{
- CPPClass * cl = (CPPClass *)impl->_class->data;
+ CPPClass * cl = (CPPClass *)impl->_class->bindingsClass;
if(cl && vTbl != cl->vTbl)
- delete [] vTbl;
+ eC_delete(vTbl);
}
}
Instance_decref(impl);
eC_cpp_init(*this);
_INSTANCE(impl, impl->_class) = this;
vTbl = _class.vTbl;
+ __thisModule = impl;
// 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 void class_registration(CPPClass & _class) { Application_class_registration(Application); }
- #undef PSELF
- #define PSELF SELF(Application, exitCode)
- property(exitCode, get(int, exitCode, return self ? _IPTR(self->impl, class_Application, class_members_Application)->exitCode : 0) );
+ property(exitCode, get(int, exitCode, Application, return self ? _IPTR(self->impl, class_Application, class_members_Application)->exitCode : 0) );
VIRTUAL_METHOD(main, Application, Application, void, Application &, , ,
return Application_main(self->impl));
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))
+ set(eC_bool, bold, FontResource, FontResource_set_bold(self ? self->impl : null, v))
+ get(eC_bool, bold, FontResource, 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))
+ set(eC_bool, italic, FontResource, FontResource_set_italic(self ? self->impl : null, v))
+ get(eC_bool, italic, FontResource, 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))
+ set(constString, faceName, FontResource, FontResource_set_faceName(self ? self->impl : null, v))
+ get(constString, faceName, FontResource, 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))
+ set(float, size, FontResource, FontResource_set_size(self ? self->impl : null, v))
+ get(float, size, FontResource, return FontResource_get_size(self ? self->impl : null))
);
};
//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,
+ set(const Window &, parent, Window, Window_set_parent(self ? self->impl : null, v.impl))
+ get(Window &, parent, Window,
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,
+ _set(const Window *, parent, Window, Window_set_parent(self ? self->impl : null, v ? v->impl : null))
+ get(Window *, parent, Window,
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)));
+ get(Window, parent, Window, 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; })
+ set(const Size &, size, Window, Window_set_size(self ? self->impl : null, &v))
+ get(Size, size, Window, { 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; })
+ set(const Size &, clientSize, Window, Window_set_clientSize(self ? self->impl : null, &v))
+ get(Size, clientSize, Window, { 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; })
+ set(const Point &, position, Window, Window_set_position(self ? self->impl : null, &v))
+ get(Point, position, Window, { 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))
+ set(eC_bool, hasClose, Window, Window_set_hasClose(self ? self->impl : null, v))
+ get(eC_bool, hasClose, Window, 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))
+ set(eC_bool, hasMinimize, Window, Window_set_hasMinimize(self ? self->impl : null, v))
+ get(eC_bool, hasMinimize, Window, 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))
+ set(eC_bool, hasMaximize, Window, Window_set_hasMaximize(self ? self->impl : null, v))
+ get(eC_bool, hasMaximize, Window, 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))
+ set(constString, caption, Window, Window_set_caption(self ? self->impl : null, v))
+ get(constString, caption, Window, 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,
+ set(const FontResource &, font, Window, Window_set_font(self ? self->impl : null, v.impl))
+ get(FontResource &, font, Window,
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,
+ _set(const FontResource *, font,Window, Window_set_font(self ? self->impl : null, v->impl))
+ get(FontResource *, font, Window,
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)))
+ get(FontResource, font, Window, 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))
+ set(BorderStyle, borderStyle, Window, Window_set_borderStyle(self ? self->impl : null, v))
+ get(BorderStyle, borderStyle, Window, 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))
+ set(Color, background, Window, Window_set_background(self ? self->impl : null, v))
+ get(Color, background, Window, return Window_get_background(self ? self->impl : null))
);
};
}
REGISTER() { Window_class_registration(MessageBox); }
- #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))
+ set(constString, contents, MessageBox, MessageBox_set_contents(self ? self->impl : null, v))
+ get(constString, contents, MessageBox, return MessageBox_get_contents(self ? self->impl : null))
);
};
public:
CONSTRUCT(ToolButton, Button) { }
REGISTER() { Button_class_registration(ToolButton); }
-
- #undef PSELF
- #define PSELF SELF(ToolButton, Foo)
};
///////////// GuiApplication Class /////////////////////////////////////////////////
{
Instance_evolve(&impl, GuiApplication::_class.impl);
_INSTANCE(impl, impl->_class) = this;
+ __thisModule = impl;
vTbl = _class.vTbl;
}
--- /dev/null
+class HelloForm2;
+HelloForm2 form2 { };
};
REGISTER_CLASS_DEF(Foo, Instance, app);
+void testStuff();
+
class HelloForm2 : public Window
{
public:
printf("after");
*/
Surface s { };
- ((Foo *)null)->onDisplay(s, 0,0,0, null, 0, 0);
+ Foo * o = (Foo *)null; o->onDisplay(s, 0,0,0, null, 0, 0);
//((Foo *)&obj3)->onDisplay(Surface { }, 0,0,0, null, 0, 0);
int r;
//r = obj2.onCompare(obj1); printf("result: %d\n", r);
//r = obj1.onCompare(obj3); printf("result: %d\n", r);
//printf("result: a = %d, b = %d\n", obj4.a, obj4.b);
+
+ testStuff();
}
return true;
};
};
REGISTER_CLASS_DEF(HelloForm2, Window, app);
+void testStuff()
+{
+ //eC_Class * c = eC_findClass(app.impl, "HelloForm2");
+ eC_Class * c = HelloForm2::_class.impl;
+ ((HelloForm2 *)_INSTANCE(newi(c), c))->modal();
+}
+
class HelloForm3 : public HelloForm2
{
public:
};
REGISTER_CLASS_DEF(HelloForm3, HelloForm2, app);
-HelloForm2 hello2;
-//HelloForm3 hello3;
+//HelloForm2 hello2;
+HelloForm3 hello3;
"../ecere.hpp"
]
},
- "form.cpp"
+ "form.cpp",
+ "foo.ec"
],
"ResourcesPath" : "",
"Resources" : [
{
f.Puts(" int exitCode;\n");
f.Puts(" Module module;\n");
+ f.Puts(" bool setThingsUp = !__thisModule;\n");
}
//if(nonInst || thisAppClass) // We use it all the time to get "Application" for the exit code now...
f.Puts(" __thisModule = module;\n");
f.Puts(" }\n\n");
}
- else if(targetPlatform == win32 && !isConsole)
- f.Puts(" __thisModule = __currentModule = module = __ecere_COM_Initialize(1, 0, null);\n\n");
else
- f.Puts(" __thisModule = __currentModule = module = __ecere_COM_Initialize(1, _argc, (void *)_argv);\n\n");
+ {
+ f.Puts(" if(setThingsUp)\n");
+ if(targetPlatform == win32 && !isConsole)
+ f.Puts(" __thisModule = __ecere_COM_Initialize(1, 0, null);\n\n");
+ else
+ f.Puts(" __thisModule = __ecere_COM_Initialize(1, _argc, (void *)_argv);\n\n");
+ f.Puts(" __currentModule = module = __thisModule;\n");
+ }
// First load all modules
if(_imports.count)
if(!isDynamicLibrary && thisAppClass)
{
f.Printf(" _class = eSystem_FindClass(__currentModule, \"%s\");\n", thisAppClass.name);
- f.Printf(" eInstance_Evolve((Instance *)&__currentModule, _class);\n");
+ f.Printf(" if(setThingsUp) eInstance_Evolve((Instance *)&__currentModule, _class);\n");
f.Printf(" __thisModule = __currentModule;\n");
}
thisAppClass = FindAppClass(&privateModule.application.privateNameSpace, false);
*/
thisAppClass = SearchAppClass_Module(privateModule);
+ if(!thisAppClass)
+ thisAppClass = eSystem_FindClass(privateModule, "Application");
}
WriteMain(output);
}
else if(_class.type == normalClass || _class.type == noHeadClass || _class.type == structClass)
{
+ // TOCHECK: Serializing null instances?
//if(data)
{
Class lastClass = null;
RegisterClass_String(module);
}
-public int PrintStdArgsToBuffer(char * buffer, int maxLen, typed_object object, va_list args)
+public int PrintStdArgsToBuffer(char * buffer, int maxLen, const typed_object object, va_list args)
{
int len = 0;
// TOFIX: OnGetString will need a maxLen as well
return len;
}
-public int PrintBuf(char * buffer, int maxLen, typed_object object, ...)
+public int PrintBuf(char * buffer, int maxLen, const typed_object object, ...)
{
va_list args;
int len;
return len;
}
-public int PrintLnBuf(char * buffer, int maxLen, typed_object object, ...)
+public int PrintLnBuf(char * buffer, int maxLen, const typed_object object, ...)
{
va_list args;
int len;
return len;
}
-public char * PrintString(typed_object object, ...)
+public char * PrintString(const typed_object object, ...)
{
char buffer[4096];
va_list args;
return string;
}
-public char * PrintLnString(typed_object object, ...)
+public char * PrintLnString(const typed_object object, ...)
{
char buffer[4096];
va_list args;
#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "ecere-app", __VA_ARGS__))
#endif
-public void PrintLn(typed_object object, ...)
+public void PrintLn(const typed_object object, ...)
{
va_list args;
char buffer[4096];
#endif
}
-public void Print(typed_object object, ...)
+public void Print(const typed_object object, ...)
{
va_list args;
char buffer[4096];
int numParams; // TOTAL number of params including all base classes; use templateParams.count for this level
bool isInstanceClass;
bool byValueSystemClass;
+ void * bindingsClass;
property const char *
{
}
// Construct an instance
-static bool ConstructInstance(void * instance, Class _class, Class from)
+static bool ConstructInstance(void * instance, Class _class, Class from, bool bindingsAlloc)
{
if(_class.templateClass) _class = _class.templateClass;
if(_class.base && from != _class.base)
{
- if(!ConstructInstance(instance, _class.base, from))
+ if(!ConstructInstance(instance, _class.base, from, false))
return false;
}
if(_class.Initialize)
}
if(_class.Constructor)
{
- if(!_class.Constructor(instance))
+ bool result;
+ if(_class.bindingsClass)
+ result = ((bool (*)(void *, bool))(void *)_class.Constructor)(instance, bindingsAlloc);
+ else
+ result = _class.Constructor(instance);
+ if(!result)
{
for(; _class; _class = _class.base)
{
return true;
}
-public dllexport void * eInstance_New(Class _class)
+static void * Instance_New(Class _class, bool bindingsAlloc)
{
Instance instance = null;
if(_class)
// Copy the virtual table initially
instance._vTbl = _class._vTbl;
}
- if(instance && !ConstructInstance(instance, _class, null))
+ if(instance && !ConstructInstance(instance, _class, null, bindingsAlloc))
{
_free(instance);
instance = null;
return instance;
}
+public dllexport void * eInstance_New(Class _class)
+{
+ return Instance_New(_class, true);
+}
+
+public dllexport void * eInstance_NewEx(Class _class, bool bindingsAlloc)
+{
+ return Instance_New(_class, bindingsAlloc);
+}
+
public dllexport void eInstance_Evolve(Instance * instancePtr, Class _class)
{
if(_class && instancePtr && *instancePtr)
instance._vTbl = _class._vTbl;
// We don't want to reconstruct the portion already constructed...
- if(!ConstructInstance(instance, _class, fromClass))
+ if(!ConstructInstance(instance, _class, fromClass, false))
{
_free(instance);
*instancePtr = null;
}
}
-public dllexport void eInstance_Watch(void * instance, Property _property, void * object, void (*callback)(void *, void *))
+public dllexport void eInstance_Watch(Instance instance, Property _property, void * object, void (*callback)(void *, void *))
{
if(_property.isWatchable)
{