ecere/com: Corrected cross-bitness fix 0.44.05
authorJerome St-Louis <jerome@ecere.com>
Mon, 18 Mar 2013 07:06:41 +0000 (03:06 -0400)
committerJerome St-Louis <jerome@ecere.com>
Mon, 18 Mar 2013 07:06:41 +0000 (03:06 -0400)
- The global variable wasn't working in basic ecp test (It's different across ecere/ecereCOM)

compiler/bootstrap/ecere/bootstrap/instance.c
ecere/src/com/instance.ec

index 715aa69..8607ffd 100644 (file)
@@ -1143,8 +1143,6 @@ void __ecereNameSpace__ecere__com__CheckMemory()
 {
 }
 
-static int __ecereNameSpace__ecere__com__insideCrossBuild32;
-
 static void __ecereNameSpace__ecere__com__ComputeClassParameters(struct __ecereNameSpace__ecere__com__Class * templatedClass, char *  templateParams, struct __ecereNameSpace__ecere__com__Instance * findModule);
 
 extern char *  strchr(const char * , int);
@@ -3510,8 +3508,11 @@ if(_class)
 {
 {
 int size = _class->structSize;
+int flags = (unsigned int)((struct __ecereNameSpace__ecere__com__Application *)(((char *)((struct __ecereNameSpace__ecere__com__Module *)(((char *)_class->module + structSize_Instance)))->application + structSize_Module)))->isGUIApp;
+unsigned int inCompiler = (flags & 8) ? 0x1 : 0x0;
+unsigned int force32Bits = (flags & 4) ? 0x1 : 0x0;
 
-if(__ecereNameSpace__ecere__com__insideCrossBuild32)
+if(force32Bits && inCompiler)
 {
 if(!strcmp(_class->name, "Module"))
 size = 560;
@@ -4247,10 +4248,6 @@ void * __ecereTemp1;
 unsigned int (stdcall * Load)(struct __ecereNameSpace__ecere__com__Instance * module) = (((void *)0));
 unsigned int (stdcall * Unload)(struct __ecereNameSpace__ecere__com__Instance * module) = (((void *)0));
 struct __ecereNameSpace__ecere__com__Instance * module;
-int flags = (unsigned int)((struct __ecereNameSpace__ecere__com__Application *)(((char *)((struct __ecereNameSpace__ecere__com__Module *)(((char *)fromModule + structSize_Instance)))->application + structSize_Module)))->isGUIApp;
-unsigned int inCompiler = (flags & 8) ? 0x1 : 0x0;
-unsigned int force32Bits = (flags & 4) ? 0x1 : 0x0;
-unsigned int setInsideCrossBuild32 = force32Bits && inCompiler;
 
 for(module = ((struct __ecereNameSpace__ecere__com__Application *)(((char *)((struct __ecereNameSpace__ecere__com__Module *)(((char *)fromModule + structSize_Instance)))->application + structSize_Module)))->allModules.first; module; module = ((struct __ecereNameSpace__ecere__com__Module *)(((char *)module + structSize_Instance)))->next)
 {
@@ -4282,8 +4279,6 @@ library = Instance_Module_Load(libLocation, name, &Load, &Unload);
 }
 if(Load)
 {
-if(setInsideCrossBuild32)
-__ecereNameSpace__ecere__com__insideCrossBuild32++;
 module = (struct __ecereNameSpace__ecere__com__Instance *)__ecereNameSpace__ecere__com__eInstance_New(__ecereNameSpace__ecere__com__eSystem_FindClass(fromModule, "Module"));
 ((struct __ecereNameSpace__ecere__com__Module *)(((char *)module + structSize_Instance)))->application = ((struct __ecereNameSpace__ecere__com__Module *)(((char *)fromModule + structSize_Instance)))->application;
 ((struct __ecereNameSpace__ecere__com__Module *)(((char *)module + structSize_Instance)))->library = library;
@@ -4295,8 +4290,6 @@ if(!Load(module))
 __ecereNameSpace__ecere__com__eInstance_Delete((struct __ecereNameSpace__ecere__com__Instance *)module);
 module = (((void *)0));
 }
-if(setInsideCrossBuild32)
-__ecereNameSpace__ecere__com__insideCrossBuild32--;
 }
 __ecereMethod___ecereNameSpace__ecere__sys__OldList_Add(&((struct __ecereNameSpace__ecere__com__Application *)(((char *)((struct __ecereNameSpace__ecere__com__Module *)(((char *)fromModule + structSize_Instance)))->application + structSize_Module)))->allModules, module);
 }
@@ -4316,8 +4309,6 @@ if(!module)
 {
 Load = __ecereDll_Load_ecere;
 Unload = __ecereDll_Unload_ecere;
-if(setInsideCrossBuild32)
-__ecereNameSpace__ecere__com__insideCrossBuild32++;
 module = (struct __ecereNameSpace__ecere__com__Instance *)__ecereNameSpace__ecere__com__eInstance_New(__ecereNameSpace__ecere__com__eSystem_FindClass(fromModule, "Module"));
 ((struct __ecereNameSpace__ecere__com__Module *)(((char *)module + structSize_Instance)))->application = ((struct __ecereNameSpace__ecere__com__Module *)(((char *)fromModule + structSize_Instance)))->application;
 ((struct __ecereNameSpace__ecere__com__Module *)(((char *)module + structSize_Instance)))->library = (((void *)0));
@@ -4328,8 +4319,6 @@ if(!Load(module))
 __ecereNameSpace__ecere__com__eInstance_Delete((struct __ecereNameSpace__ecere__com__Instance *)module);
 module = (((void *)0));
 }
-if(setInsideCrossBuild32)
-__ecereNameSpace__ecere__com__insideCrossBuild32--;
 __ecereMethod___ecereNameSpace__ecere__sys__OldList_Add(&((struct __ecereNameSpace__ecere__com__Application *)(((char *)((struct __ecereNameSpace__ecere__com__Module *)(((char *)fromModule + structSize_Instance)))->application + structSize_Module)))->allModules, module);
 }
 if(module)
@@ -4843,7 +4832,13 @@ void __ecereNameSpace__ecere__com__eInstance_FireWatchers(struct __ecereNameSpac
 {
 if(instance && _property && _property->isWatchable)
 {
-if(!__ecereNameSpace__ecere__com__insideCrossBuild32)
+struct __ecereNameSpace__ecere__com__Instance * module = ((struct __ecereNameSpace__ecere__com__Instance *)(char *)instance)->_class ? ((struct __ecereNameSpace__ecere__com__Instance *)(char *)instance)->_class->module : (((void *)0));
+struct __ecereNameSpace__ecere__com__Instance * application = module ? ((struct __ecereNameSpace__ecere__com__Module *)(((char *)module + structSize_Instance)))->application : (((void *)0));
+int flags = application ? (unsigned int)((struct __ecereNameSpace__ecere__com__Application *)(((char *)application + structSize_Module)))->isGUIApp : 0;
+unsigned int inCompiler = (flags & 8) ? 0x1 : 0x0;
+unsigned int force32Bits = (flags & 4) ? 0x1 : 0x0;
+
+if(!force32Bits || !inCompiler)
 {
 struct __ecereNameSpace__ecere__sys__OldList * watchers = (struct __ecereNameSpace__ecere__sys__OldList *)((unsigned char *)instance + _property->watcherOffset);
 struct __ecereNameSpace__ecere__com__Watcher * watcher, * next;
index 86ca1f1..5cce5f5 100644 (file)
@@ -1906,8 +1906,6 @@ public void CheckMemory()
 #endif
 }
 
-static int insideCrossBuild32;
-
 static void FixDerivativesBase(Class base, Class mod)
 {
    OldLink derivative;
@@ -4353,7 +4351,10 @@ public dllexport void * eInstance_New(Class _class)
 #endif
       {
          int size = _class.structSize;
-         if(insideCrossBuild32)
+         int flags = _class.module.application.isGUIApp;
+         bool inCompiler = (flags & 8) ? true : false;
+         bool force32Bits = (flags & 4) ? true : false;
+         if(force32Bits && inCompiler)
          {
             // Allocate 64 bit sizes for these when cross-compiling for 32 bit to allow loaded libraries to work properly
             if(!strcmp(_class.name, "Module"))
@@ -5147,10 +5148,6 @@ static Module Module_Load(Module fromModule, char * name, AccessMode importAcces
    bool (stdcall * Load)(Module module) = null;
    bool (stdcall * Unload)(Module module) = null;
    Module module;
-   int flags = fromModule.application.isGUIApp;
-   bool inCompiler = (flags & 8) ? true : false;
-   bool force32Bits = (flags & 4) ? true : false;
-   bool setInsideCrossBuild32 = force32Bits && inCompiler;
 
    for(module = fromModule.application.allModules.first; module; module = module.next)
    {
@@ -5184,9 +5181,6 @@ static Module Module_Load(Module fromModule, char * name, AccessMode importAcces
       }
       if(Load)
       {
-         if(setInsideCrossBuild32)
-            insideCrossBuild32++;
-
          module = (Module)eInstance_New(eSystem_FindClass(fromModule, "Module"));
          module.application = fromModule.application;
          module.library = library;
@@ -5199,9 +5193,6 @@ static Module Module_Load(Module fromModule, char * name, AccessMode importAcces
             eInstance_Delete((Instance)module);
             module = null;
          }
-
-         if(setInsideCrossBuild32)
-            insideCrossBuild32--;
       }
       fromModule.application.allModules.Add(module);
    }
@@ -5222,9 +5213,6 @@ static Module Module_Load(Module fromModule, char * name, AccessMode importAcces
             Load = COM_LOAD_FUNCTION;
             Unload = COM_UNLOAD_FUNCTION;
 
-            if(setInsideCrossBuild32)
-               insideCrossBuild32++;
-
             module = (Module)eInstance_New(eSystem_FindClass(fromModule, "Module"));
             module.application = fromModule.application;
             module.library = null;
@@ -5237,8 +5225,6 @@ static Module Module_Load(Module fromModule, char * name, AccessMode importAcces
                module = null;
             }
 
-            if(setInsideCrossBuild32)
-               insideCrossBuild32--;
             fromModule.application.allModules.Add(module);
          }
          if(module)
@@ -5780,7 +5766,12 @@ public dllexport void eInstance_FireWatchers(Instance instance, Property _proper
 {
    if(instance && _property && _property.isWatchable)
    {
-      if(!insideCrossBuild32)
+      Module module = instance._class ? instance._class.module : null;
+      Application application = module ? module.application : null;
+      int flags = application ? application.isGUIApp : 0;
+      bool inCompiler = (flags & 8) ? true : false;
+      bool force32Bits = (flags & 4) ? true : false;
+      if(!force32Bits || !inCompiler)
       {
          OldList * watchers = (OldList *)((byte *)instance + _property.watcherOffset);
          Watcher watcher, next;