documentor; compiler/libec; ecere/com/instance: Fixes for consistent module names...
authorJerome St-Louis <jerome@ecere.com>
Fri, 7 Feb 2014 19:17:16 +0000 (02:17 +0700)
committerJerome St-Louis <jerome@ecere.com>
Fri, 7 Feb 2014 19:31:57 +0000 (02:31 +0700)
compiler/bootstrap/ecere/bootstrap/instance.c
compiler/bootstrap/libec/bootstrap/loadSymbols.c
compiler/libec/src/loadSymbols.ec
documentor/src/Documentor.ec
ecere/src/com/instance.c
ecere/src/com/instance.ec

index 5735fca..a62fcef 100644 (file)
@@ -4358,6 +4358,14 @@ return bitMember;
 return (((void *)0));
 }
 
+extern char *  __ecereNameSpace__ecere__sys__GetLastDirectory(char *  string, char *  output);
+
+extern char *  __ecereNameSpace__ecere__sys__GetExtension(char *  string, char *  output);
+
+extern unsigned int __ecereNameSpace__ecere__sys__StripExtension(char *  string);
+
+extern int strcasecmp(const char * , const char * );
+
 static struct __ecereNameSpace__ecere__com__Instance * __ecereNameSpace__ecere__com__Module_Load(struct __ecereNameSpace__ecere__com__Instance * fromModule, char * name, int importAccess, unsigned int ensureCOM)
 {
 unsigned int (stdcall * Load)(struct __ecereNameSpace__ecere__com__Instance * module) = (((void *)0));
@@ -4397,7 +4405,22 @@ if(Load)
 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;
-((struct __ecereNameSpace__ecere__com__Module *)(((char *)module + structSize_Instance)))->name = __ecereNameSpace__ecere__sys__CopyString(name);
+{
+char moduleName[274];
+char ext[17];
+
+__ecereNameSpace__ecere__sys__GetLastDirectory(name, moduleName);
+__ecereNameSpace__ecere__sys__GetExtension(moduleName, ext);
+__ecereNameSpace__ecere__sys__StripExtension(moduleName);
+if((!(strcasecmp)(ext, "dylib") || !(strcasecmp)(ext, "so")) && strstr(moduleName, "lib") == moduleName)
+{
+int len = strlen(moduleName) - 3;
+
+memmove(moduleName, moduleName + 3, len);
+moduleName[len] = (char)0;
+}
+((struct __ecereNameSpace__ecere__com__Module *)(((char *)module + structSize_Instance)))->name = __ecereNameSpace__ecere__sys__CopyString(moduleName);
+}
 ((struct __ecereNameSpace__ecere__com__Module *)(((char *)module + structSize_Instance)))->Unload = Unload;
 ((struct __ecereNameSpace__ecere__com__Module *)(((char *)module + structSize_Instance)))->origImportType = 0;
 if(!Load(module))
index 3ed9e0e..8a87947 100644 (file)
@@ -1697,10 +1697,10 @@ unsigned int __ecereMethod___ecereNameSpace__ecere__com__Iterator_Next();
 void ImportModule(char * name, int importType, int importAccess, unsigned int loadDllOnly)
 {
 struct ImportedModule * module = (((void *)0));
-char moduleName[274];
+char moduleName[797];
 
-strncpy(moduleName, name, (274) - 1);
-moduleName[(274) - 1] = (char)0;
+strncpy(moduleName, name, (797) - 1);
+moduleName[(797) - 1] = (char)0;
 __ecereNameSpace__ecere__sys__StripExtension(moduleName);
 for(module = (*defines).first; module; module = module->next)
 {
@@ -1718,7 +1718,7 @@ __ecereNameSpace__ecere__sys__GetExtension(name, ext);
 strcpy(symFile, symbolsDir ? symbolsDir : "");
 __ecereNameSpace__ecere__sys__PathCat(symFile, name);
 __ecereNameSpace__ecere__sys__ChangeExtension(symFile, "sym", symFile);
-if(!strcmp(ext, "dll") || !strcmp(ext, "dll") || !ext[0])
+if(!strcmp(ext, "dll") || !strcmp(ext, "so") || !strcmp(ext, "dylib") || !ext[0])
 {
 if(importType != 4)
 {
@@ -1745,17 +1745,14 @@ if(ext[0] || !__ecereNameSpace__ecere__sys__FileExists(symFile))
 {
 unsigned int skipLoad = 0x0;
 struct __ecereNameSpace__ecere__com__Instance * list = (((void *)0));
-char file[274];
 
-strcpy(file, name);
-__ecereNameSpace__ecere__sys__StripExtension(file);
 if(!inCompiler && !inPreCompiler && !inSymbolGen)
 {
 struct __ecereNameSpace__ecere__com__MapIterator it = (it.container = (void *)0, it.pointer = (void *)0, __ecereProp___ecereNameSpace__ecere__com__MapIterator_Set_map(&it, loadedModules), it);
 
-if(!__ecereMethod___ecereNameSpace__ecere__com__Iterator_Index(&it, (uint64)(file), 0x0))
+if(!__ecereMethod___ecereNameSpace__ecere__com__Iterator_Index(&it, (uint64)(name), 0x0))
 {
-struct __ecereNameSpace__ecere__com__Instance * firstModule = __ecereNameSpace__ecere__com__eModule_LoadStrict(((struct __ecereNameSpace__ecere__com__Module *)(((char *)__thisModule + structSize_Instance)))->application, file, importAccess);
+struct __ecereNameSpace__ecere__com__Instance * firstModule = __ecereNameSpace__ecere__com__eModule_LoadStrict(((struct __ecereNameSpace__ecere__com__Module *)(((char *)__thisModule + structSize_Instance)))->application, name, importAccess);
 
 if(firstModule)
 {
@@ -1771,7 +1768,7 @@ struct __ecereNameSpace__ecere__com__Iterator __internalIterator =
 loadedModules, 0
 };
 
-__ecereMethod___ecereNameSpace__ecere__com__Iterator_Index(&__internalIterator, (uint64)(((uint64)(file))), 0x1);
+__ecereMethod___ecereNameSpace__ecere__com__Iterator_Index(&__internalIterator, (uint64)(((uint64)(name))), 0x1);
 __ecereProp___ecereNameSpace__ecere__com__Iterator_Set_data(&__internalIterator, list);
 });
 }
@@ -1783,7 +1780,7 @@ list = ((struct __ecereNameSpace__ecere__com__Instance *)__ecereProp___ecereName
 }
 if(!skipLoad)
 {
-loadedModule = __ecereNameSpace__ecere__com__eModule_LoadStrict(privateModule, file, importAccess);
+loadedModule = __ecereNameSpace__ecere__com__eModule_LoadStrict(privateModule, name, importAccess);
 if(loadedModule)
 {
 ((struct __ecereNameSpace__ecere__com__Module *)(((char *)loadedModule + structSize_Instance)))->importType = importType;
index 351649c..d031a68 100644 (file)
@@ -716,10 +716,10 @@ Map<String, List<Module> > loadedModules { };
 public void ImportModule(char * name, ImportType importType, AccessMode importAccess, bool loadDllOnly)
 {
    ImportedModule module = null;
-   char moduleName[MAX_FILENAME];
+   char moduleName[MAX_LOCATION];
 
-   strncpy(moduleName, name, MAX_FILENAME-1);
-   moduleName[MAX_FILENAME-1] = 0;
+   strncpy(moduleName, name, MAX_LOCATION-1);
+   moduleName[MAX_LOCATION-1] = 0;
    StripExtension(moduleName);
 
    for(module = defines->first; module; module = module.next)
@@ -740,7 +740,7 @@ public void ImportModule(char * name, ImportType importType, AccessMode importAc
       PathCat(symFile, name);
       ChangeExtension(symFile, "sym", symFile);
 
-      if(!strcmp(ext, "dll") || !strcmp(ext, "dll") || !ext[0])
+      if(!strcmp(ext, "dll") || !strcmp(ext, "so") || !strcmp(ext, "dylib") || !ext[0])
       {
          if(importType != comCheckImport)
          {
@@ -772,24 +772,25 @@ public void ImportModule(char * name, ImportType importType, AccessMode importAc
             {
                bool skipLoad = false;
                List<Module> list = null;
-
-               char file[MAX_FILENAME];
+               /*
+               char file[MAX_LOCATION];
                strcpy(file, name);
                StripExtension(file);
+               */
 
                // Load an extra instance of any shared module to ensure freeing up a
                // module loaded in another file will not invalidate our objects.
                if(!inCompiler && !inPreCompiler && !inSymbolGen)
                {
                   MapIterator<String, List<Module> > it { map = loadedModules };
-                  if(!it.Index(file, false))
+                  if(!it.Index(name /*file*/, false))
                   {
-                     Module firstModule = eModule_LoadStrict(__thisModule.application, file, importAccess);
+                     Module firstModule = eModule_LoadStrict(__thisModule.application, name /*file*/, importAccess);
                      if(firstModule)
                      {
                         list = { };
                         list.Add(firstModule);
-                        loadedModules[file] = list;
+                        loadedModules[name /*file*/] = list;
                      }
                      else
                         skipLoad = true;
@@ -800,7 +801,7 @@ public void ImportModule(char * name, ImportType importType, AccessMode importAc
 
                if(!skipLoad)
                {
-                  loadedModule = eModule_LoadStrict(privateModule, file, importAccess);
+                  loadedModule = eModule_LoadStrict(privateModule, name /*file*/, importAccess);
                   if(loadedModule)
                   {
                      loadedModule.importType = importType;
index 0b6bc70..cc942cc 100644 (file)
@@ -4,6 +4,8 @@ import "HTMLView"
 import "IDESettings"
 import "SettingsDialog"
 
+uint64 strtoull(const char * nptr, char ** endptr, int base);
+
 static Context globalContext { };
 static OldList defines { };
 static OldList imports { };
@@ -654,7 +656,7 @@ class APIPageNameSpace : APIPage
       char nsName[1024], temp[1024];
       NameSpace * ns;
       BTNamedLink link;
-      uint tag;
+      int64 tag;
 
       nsName[0] = 0;
       ns = nameSpace;
@@ -671,12 +673,12 @@ class APIPageNameSpace : APIPage
       if(nsName[0])
       {
          f.Printf("<FONT FACE=\"Arial\" SIZE=\"6\">%s</FONT><br><br>\n", nsName );
-         tag = (uint)nameSpace;
+         tag = (int64)nameSpace;
          f.Printf($"Module: <a href=\"api://%p\" style=\"text-decoration: none;\">%s</a><br>\n", (module && module.name) ? module : null, (!module || !module.name || !strcmp(nsName, "ecere::com")) ? "ecereCOM" : module.name);
       }
       else
       {
-         tag = (uint)((!module || !module.name || !strcmp(nsName, "ecere::com") ? null : module));
+         tag = (int64)(!module || !module.name || !strcmp(nsName, "ecere::com") ? null : module);
          f.Printf($"<FONT FACE=\"Arial\" SIZE=\"6\">Module %s</FONT><br>\n", (!module || !module.name || !strcmp(nsName, "ecere::com")) ? "ecereCOM" : module.name);
       }
 
@@ -2275,7 +2277,7 @@ class MainForm : Window
 
       ImportModule(filePath, normalImport, publicAccess, false);
 
-      if(extension[0] && strcmpi(extension, "so") && strcmpi(extension, "dll"))
+      if(extension[0] && strcmpi(extension, "so") && strcmpi(extension, "dll") && strcmpi(extension, "dylib"))
          componentsApp.name = CopyString(filePath);
 
       for(module = componentsApp.allModules.first; module; module = module.next)
@@ -2287,19 +2289,18 @@ class MainForm : Window
          eModule_LoadStrict(componentsApp, "ecereCOM", publicAccess /*privateAccess*/);
       AddComponents(componentsApp, false);
 
-      // lib prefix and extension get removed by ImportModule
+      GetLastDirectory(filePath, moduleName);
+      // Extension, path and lib prefix get removed in Module::name
       if(extension[0])
       {
-         char name[MAX_FILENAME];
-         GetLastDirectory(filePath, name);
-         StripLastDirectory(filePath, moduleName);
-         StripExtension(name);
-         if((!strcmpi(extension, "so") || !strcmpi(extension, "dylib")) && strstr(name, "lib") == name)
-            memmove(name, name + 3, strlen(name)-3);
-         PathCat(moduleName, name);
+         StripExtension(moduleName);
+         if((!strcmpi(extension, "so") || !strcmpi(extension, "dylib")) && strstr(moduleName, "lib") == moduleName)
+         {
+            int len = strlen(moduleName) - 3;
+            memmove(moduleName, moduleName + 3, len);
+            moduleName[len] = 0;
+         }
       }
-      else
-         strcpy(moduleName, filePath);
 
       for(module = componentsApp.allModules.first; module; module = module.next)
       {
@@ -2510,13 +2511,6 @@ class HelpView : HTMLView
             NameSpace * ns = page ? page.GetNameSpace() : null;
 
             sprintf(docFile, "%s/%s.eCdoc", settings.docDir, (!module || !module.name || (ns && ns->name && !strcmp(ns->name, "namespaces/ecere/namespaces/com"))) ? "ecereCOM" : module.name);
-            if(strchr(docFile, DIR_SEP))
-            {
-               char temp[MAX_LOCATION];
-               GetLastDirectory(docFile, temp);
-               strcpy(docFile, temp);
-            }
-
             if(FileExists(docFile))
             {
                archive = ArchiveOpen(docFile, { true } );
@@ -2735,7 +2729,7 @@ class HelpView : HTMLView
    {
       if(!strncmp(href, "api://", 6))
       {
-         int tag = (uint)strtoul(href + 6, null, 16);
+         int64 tag = (int64)strtoull(href + 6, null, 16);
          DataRow row = mainForm.browser.FindSubRow(tag);
          if(row)
          {
index 04d507c..38f7baa 100644 (file)
@@ -458,8 +458,8 @@ void * Instance_Module_Load(const char * libLocation, const char * name, void **
          FreeLibrary(library);
    }
 #elif defined(__unix__) || defined(__APPLE__)
-   if(libLocation)
-      strcpy(fileName, libLocation);
+   if(libLocation || strchr(name, '/'))
+      strcpy(fileName, libLocation ? libLocation : "");
    else
       strcpy(fileName, "lib");
    strcat(fileName, name);
@@ -505,7 +505,10 @@ void * Instance_Module_Load(const char * libLocation, const char * name, void **
          dlclose(library);
    }
 #elif defined(__APPLE__)
-   strcpy(fileName, "lib");
+   if(libLocation || strchr(name, '/'))
+      strcpy(fileName, libLocation ? libLocation : "");
+   else
+      strcpy(fileName, "lib");
    strcat(fileName, name);
    GetExtension(fileName, extension);
    if(!extension[0])
index b7df135..37f2f87 100644 (file)
@@ -5270,7 +5270,20 @@ static Module Module_Load(Module fromModule, char * name, AccessMode importAcces
          module = (Module)eInstance_New(eSystem_FindClass(fromModule, "Module"));
          module.application = fromModule.application;
          module.library = library;
-         module.name = CopyString(name);
+         {
+            char moduleName[MAX_FILENAME];
+            char ext[MAX_EXTENSION];
+            GetLastDirectory(name, moduleName);
+            GetExtension(moduleName, ext);
+            StripExtension(moduleName);
+            if((!strcmpi(ext, "dylib") || !strcmpi(ext, "so")) && strstr(moduleName, "lib") == moduleName)
+            {
+               int len = strlen(moduleName) - 3;
+               memmove(moduleName, moduleName + 3, len);
+               moduleName[len] = 0;
+            }
+            module.name = CopyString(moduleName);
+         }
          module.Unload = Unload;
          module.origImportType = normalImport;