Browse Source

pastojs: added option -FN<x>, marked -NS as obsolete

git-svn-id: trunk@38940 -
Mattias Gaertner 7 years ago
parent
commit
d323bd087e

+ 1 - 1
packages/pastojs/src/fppas2js.pp

@@ -344,7 +344,7 @@ Works:
 - typecast byte(longword) -> value & $ff
 
 ToDos:
-- forbid typecast record to record
+- check rtl.js version
 - 'new', 'Function' -> class var use .prototype
 - btArrayLit
   a: array of jsvalue;

+ 11 - 4
packages/pastojs/src/pas2jscompiler.pp

@@ -3056,6 +3056,8 @@ begin
           'e': Log.OutputFilename:=String(p);
           'i': if not FileCache.AddIncludePaths(String(p),FromCmdLine,ErrorMsg) then
                  ParamFatal('invalid include path (-Fi) "'+ErrorMsg+'"');
+          'N': if not FileCache.AddNamespaces(String(p),FromCmdLine,ErrorMsg) then
+                 ParamFatal('invalid namespace (-FN) "'+ErrorMsg+'"');
           'u': if not FileCache.AddUnitPaths(String(p),FromCmdLine,ErrorMsg) then
                  ParamFatal('invalid unit path (-Fu) "'+ErrorMsg+'"');
           'U': FileCache.UnitOutputPath:=String(p);
@@ -3203,8 +3205,12 @@ begin
         begin
           inc(p);
           case p^ of
-          'S': if not FileCache.AddNamespaces(String(p+1),FromCmdLine,ErrorMsg) then
-                 ParamFatal('invalid namespace (-NS) "'+ErrorMsg+'"');
+          'S':
+            begin
+            Log.Log(mtWarning,'obsolete option -NS, use -FN instead');
+            if not FileCache.AddNamespaces(String(p+1),FromCmdLine,ErrorMsg) then
+              ParamFatal('invalid namespace (-NS) "'+ErrorMsg+'"');
+            end;
           else UnknownParam;
           end;
         end;
@@ -3865,6 +3871,8 @@ begin
   l('  -F...   Set file names and paths:');
   l('   -Fe<x> : Redirect output to <x>. UTF-8 encoded.');
   l('   -Fi<x> : Add <x> to include paths');
+  l('   -FN<x> : add <x> to namespaces. Namespaces with trailing - are removed.');
+  l('            Delphi calls this flag "unit scope names".');
   l('   -Fu<x> : Add <x> to unit paths');
   l('   -FU<x> : Set unit output path to <x>');
   l('  -I<x>   : Add <x> to include paths, same as -Fi');
@@ -3898,8 +3906,7 @@ begin
   l('  -l      : Write logo');
   l('  -MDelphi: Delphi 7 compatibility mode');
   l('  -MObjFPC: FPC''s Object Pascal compatibility mode (default)');
-  l('  -NS<x>  : add <x> to namespaces. Namespaces with trailing - are removed.');
-  l('            Delphi calls this flag "unit scope names".');
+  l('  -NS<x>  : obsolete: add <x> to namespaces. Same as -FN<x>');
   l('  -n      : Do not read the default config files');
   l('  -o<x>   : Change main JavaScript file to <x>, "." means stdout');
   l('  -O<x>   : Optimizations:');

+ 1 - 1
packages/pastojs/tests/tcmodules.pas

@@ -2018,7 +2018,7 @@ begin
     'this.i7 =-0x10000000000000;',
     'this.i8 = 0;',
     'this.u8 = 0xfffffffffffff;',
-    'this.u9 = 0x0000000000000;'
+    'this.u9 = 0x0;'
     ]),
     '');
 end;

+ 1 - 1
packages/pastojs/tests/tcprecompile.pas

@@ -171,7 +171,7 @@ begin
     'begin',
     '  i:=3;',
     'end.']);
-  CheckPrecompile('test1.pas','src',LinesToList(['-NSfoo']));
+  CheckPrecompile('test1.pas','src',LinesToList(['-FNfoo']));
 end;
 
 procedure TTestCLI_Precompile.TestPCU_Overloads;

+ 3 - 2
utils/pas2js/docs/translation.html

@@ -137,6 +137,8 @@ Put + after a boolean switch option to enable it, - to disable it
   -F...   Set file names and paths:
    -Fe&lt;x&gt; : Redirect output to &lt;x&gt;
    -Fi&lt;x&gt; : Add &lt;x&gt; to include paths
+   -FN&lt;x&gt; : add &lt;x&gt; to namespaces. Namespaces with trailing - are removed.
+                  Delphi calls this flag "unit scope names".
    -Fu&lt;x&gt; : Add &lt;x&gt; to unit paths
    -FU&lt;x&gt; : Set unit output path to &lt;x&gt;
   -I&lt;x&gt;   : Add &lt;x&gt; to include paths, same as -Fi
@@ -161,8 +163,7 @@ Put + after a boolean switch option to enable it, - to disable it
   -l      : Write logo
   -MDelphi: Delphi 7 compatibility mode
   -MObjFPC: FPC's Object Pascal compatibility mode (default)
-  -NS&lt;x&gt;  : add &lt;x&gt; to namespaces. Namespaces with trailing - are removed.
-                  Delphi calls this flag "unit scope names".
+  -NS&lt;x&gt;  : obsolete: add &lt;x&gt; to namespaces. Same as -FN&lt;x&gt;
   -n      : Do not read the default config files
   -o&lt;x&gt;   : Change main JavaScript file to &lt;x&gt;, "." means stdout
   -O&lt;x&gt;   : Optimizations: