compiler/i18n: Modified .bowl/.pot generation to always use '/' for paths, so as...
[sdk] / compiler / ecs / ecs.ec
index f9aa228..1e5c755 100644 (file)
@@ -1114,7 +1114,7 @@ static void BindDCOMClient()
                         f.Printf(" = 0");
                      f.Printf(";\n\n");
                   }
-                  //f.Printf("      incref this;\n");
+                  f.Printf("      incref this;\n");
                   for(param = method.dataType.params.first; param; param = param.next)
                   {
                      char type[1024] = "";
@@ -1175,7 +1175,7 @@ static void BindDCOMClient()
                   }
                   f.Printf("      }\n");
                   f.Printf("      __ecereBuffer.Free();\n");
-                  //f.Printf("      delete this;\n");
+                  f.Printf("      delete this;\n");
                   if(method.dataType.returnType.kind != voidType)
                   {
                      f.Printf("      return __ecereResult;\n");
@@ -1256,6 +1256,8 @@ static void BindDCOMServer()
             // f.Printf("\n");
             f.Printf("   virtual void CallMethod(uint __ecereMethodID, SerialBuffer __ecereBuffer)\n");
             f.Printf("   {\n");
+            f.Printf("      %s inst = (%s)instance;\n", _class.fullName, _class.fullName);
+            f.Printf("      incref inst;\n");
             f.Printf("      switch(__ecereMethodID)\n");
             f.Printf("      {\n");
 
@@ -1412,6 +1414,7 @@ static void BindDCOMServer()
                }
             }
             f.Printf("      }\n");
+            f.Printf("      delete inst;\n");
             f.Printf("   }\n");
 
             // *** VIRTUAL FUNCTIONS BINDINGS ***
@@ -1489,7 +1492,8 @@ static void BindDCOMServer()
                               f.Printf(" = 0");
                            f.Printf(";\n\n");
                         }
-
+                        
+                        f.Printf("      incref __ecereObject;\n");
                         f.Printf("      __ecereMethod___ecereNameSpace__ecere__sys__Mutex_Wait(__ecereObject.mutex);\n");
 
                         //f.Printf("      incref this;\n");
@@ -1515,10 +1519,10 @@ static void BindDCOMServer()
                            if(param.kind == classType && !strcmp(param._class.string, "String"))
                            {
                               DeclareClass(FindClass("StaticString"), "__ecereClass_StaticString");
-                              f.Printf("      __ecereObject.virtualsBuffer.Serialize((StaticString)%s);\n", param.name);
+                              f.Printf("      __ecereObject.argsBuffer.Serialize((StaticString)%s);\n", param.name);
                            }
                            else
-                              f.Printf("      __ecereObject.virtualsBuffer.Serialize(%s);\n", param.name);
+                              f.Printf("      __ecereObject.argsBuffer.Serialize(%s);\n", param.name);
                         }
 
                         DeclareMethod(
@@ -1528,13 +1532,16 @@ static void BindDCOMServer()
 
                         // Check if this method needs to return anything (hasReturnValue)
                         {
-                           bool hasReturnValue = false;
-                           for(param = method.dataType.params.first; param; param = param.next)
+                           bool hasReturnValue = method.dataType.returnType.kind != voidType;
+                           if(!hasReturnValue)
                            {
-                              if(param.kind == classType && ((param._class && param._class.registered && param._class.registered.type == structClass) || !strcmp(param._class.string, "String")) && !param.constant)
+                              for(param = method.dataType.params.first; param; param = param.next)
                               {
-                                 hasReturnValue = true;
-                                 break;
+                                 if(param.kind == classType && ((param._class && param._class.registered && param._class.registered.type == structClass) || !strcmp(param._class.string, "String")) && !param.constant)
+                                 {
+                                    hasReturnValue = true;
+                                    break;
+                                 }
                               }
                            }
                            f.Printf("      if(__ecereObject.CallVirtualMethod(%d, %s))\n", vid - _class.base.vTblSize,
@@ -1548,10 +1555,10 @@ static void BindDCOMServer()
                               if(!strcmp(param._class.string, "String"))
                               {
                                  DeclareClass(FindClass("StaticString"), "__ecereClass_StaticString");
-                                 f.Printf("         __ecereObject.virtualsBuffer.Unserialize((StaticString)%s);\n", param.name);
+                                 f.Printf("         __ecereObject.returnBuffer.Unserialize((StaticString)%s);\n", param.name);
                               }
                               else
-                                 f.Printf("         __ecereObject.virtualsBuffer.Unserialize(%s);\n", param.name);
+                                 f.Printf("         __ecereObject.returnBuffer.Unserialize(%s);\n", param.name);
                            }
                         }
                         if(method.dataType.returnType.kind != voidType)
@@ -1559,10 +1566,10 @@ static void BindDCOMServer()
                            if(method.dataType.returnType.kind == classType && !strcmp(method.dataType.returnType._class.string, "String"))
                            {
                               DeclareClass(FindClass("StaticString"), "__ecereClass_StaticString");
-                              f.Printf("         __ecereObject.virtualsBuffer.Unserialize((StaticString)__ecereResult);\n");
+                              f.Printf("         __ecereObject.returnBuffer.Unserialize((StaticString)__ecereResult);\n");
                            }
                            else
-                              f.Printf("         __ecereObject.virtualsBuffer.Unserialize(__ecereResult);\n");
+                              f.Printf("         __ecereObject.returnBuffer.Unserialize(__ecereResult);\n");
                         }
                         f.Printf("      }\n");
                         f.Printf("      else\n");
@@ -1574,9 +1581,10 @@ static void BindDCOMServer()
                         }
                         f.Printf(");\n");
 
-                        f.Printf("      __ecereObject.virtualsBuffer.Free();\n");
+                        f.Printf("      __ecereObject.returnBuffer.Free();\n");
                         f.Printf("      __ecereMethod___ecereNameSpace__ecere__sys__Mutex_Release(__ecereObject.mutex);\n");
                         //f.Printf("      delete this;\n");
+                        f.Printf("      delete __ecereObject;\n");
                         if(method.dataType.returnType.kind != voidType)
                         {
                            f.Printf("      return __ecereResult;\n");
@@ -1693,7 +1701,7 @@ class SymbolgenApp : Application
          valid = false;
      
       if(!valid)
-         printf("Syntax:\n   ecs [-t <target platform>] <input>[, <input>]* -o <output>\n");
+         printf($"Syntax:\n   ecs [-t <target platform>] <input>[, <input>]* -o <output>\n");
       else
       {
          int c;
@@ -1719,6 +1727,9 @@ class SymbolgenApp : Application
 
          //if(!strcmp(ext, "c"))
          {
+            String symbolsDir = GetSymbolsDir();
+            // Only generating .pot files when building from release.* directory for now
+            bool outputPot = symbolsDir && SearchString(symbolsDir, 0, "release.", false, false);
             Map<ContextStringPair, List<String> > intlStrings { };
             MapIterator<ContextStringPair, List<String>> it { map = intlStrings };
 
@@ -1897,17 +1908,33 @@ class SymbolgenApp : Application
             }
             WriteMain(output);
 
-            if(intlStrings.count)
+            if(outputPot && intlStrings.count)
             {
                File potFile;
                char potFileName[MAX_LOCATION];
                //strcpy(potFileName, output);
                //StripExtension(potFileName);
-               strcpy(potFileName, projectName);
+               strcpy(potFileName, "locale");
+               MakeDir(potFileName);
+               PathCat(potFileName, projectName);
                ChangeExtension(potFileName, "pot", potFileName);
                potFile = FileOpen(potFileName, write);
                if(potFile)
                {
+                  // Write header:
+                  potFile.Puts("msgid \"\"\n");
+                  potFile.Puts("msgstr \"\"\n");
+                  potFile.Puts("\"Project-Id-Version: \\n\"\n");
+                  potFile.Puts("\"POT-Creation-Date: \\n\"\n");
+                  potFile.Puts("\"PO-Revision-Date: \\n\"\n");
+                  potFile.Puts("\"Last-Translator: \\n\"\n");
+                  potFile.Puts("\"Language-Team: \\n\"\n");
+                  potFile.Puts("\"MIME-Version: 1.0\\n\"\n");
+                  potFile.Puts("\"Content-Type: text/plain; charset=iso-8859-1\\n\"\n");
+                  potFile.Puts("\"Content-Transfer-Encoding: 8bit\\n\"\n");
+                  potFile.Puts("\"X-Poedit-Basepath: ../\\n\"\n");
+                  potFile.Puts("\n");
+
                   for(i : intlStrings)
                   {
                      ContextStringPair pair = &i;
@@ -1918,11 +1945,11 @@ class SymbolgenApp : Application
                         potFile.Puts("\n");
                      }
 
-                     potFile.Puts("msgid \""); potFile.Puts(pair.string); potFile.Puts("\"\n");
                      if(pair.context)
                      {
                         potFile.Puts("msgctxt \""); potFile.Puts(pair.context); potFile.Puts("\"\n");
                      }
+                     potFile.Puts("msgid \""); potFile.Puts(pair.string); potFile.Puts("\"\n");
                      potFile.Puts("msgstr \""); potFile.Puts(pair.string); potFile.Puts("\"\n");
                      potFile.Puts("\n");
                   }