Browse Source

pastojs: nested external class constructor

git-svn-id: trunk@49351 -
Mattias Gaertner 4 years ago
parent
commit
4ddaa26fc0
2 changed files with 18 additions and 2 deletions
  1. 16 0
      packages/pastojs/tests/tcmodules.pas
  2. 2 2
      utils/pas2js/docs/translation.html

+ 16 - 0
packages/pastojs/tests/tcmodules.pas

@@ -18003,11 +18003,20 @@ begin
   '{$modeswitch externalclass}',
   'type',
   '  TExtA = class external name ''ExtA''',
+  '  public type',
+  '    TExtB = class external name ''ExtB''',
+  '    public type',
+  '      TExtC = class external name ''ExtC''',
+  '        constructor New;',
+  '        constructor New(i: word);',
+  '      end;',
+  '    end;',
   '    constructor Create;',
   '    constructor Create(i: longint; j: longint = 2);',
   '  end;',
   'var',
   '  A: texta;',
+  '  C: texta.textb.textc;',
   'begin',
   '  a:=texta.create;',
   '  a:=texta(texta.create);',
@@ -18021,11 +18030,15 @@ begin
   '  a:=test1.texta.create;',
   '  a:=test1.texta.create();',
   '  a:=test1.texta.create(3);',
+  '  c:=texta.textb.textc.new;',
+  '  c:=texta.textb.textc.new();',
+  '  c:=texta.textb.textc.new(4);',
   '']);
   ConvertProgram;
   CheckSource('TestExternalClass_Constructor',
     LinesToStr([ // statements
     'this.A = null;',
+    'this.C = null;',
     '']),
     LinesToStr([ // $mod.$main
     '$mod.A = new ExtA.Create();',
@@ -18038,6 +18051,9 @@ begin
     '$mod.A = new ExtA.Create();',
     '$mod.A = new ExtA.Create();',
     '$mod.A = new ExtA.Create(3,2);',
+    '$mod.C = new ExtA.ExtB.ExtC();',
+    '$mod.C = new ExtA.ExtB.ExtC();',
+    '$mod.C = new ExtA.ExtB.ExtC(4);',
     '']));
 end;
 

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

@@ -2723,10 +2723,10 @@ function(){
     Destructors are not allowed.<br>
     Constructors are supported in four ways:
     <ul>
-      <li><i>constructor New</i> is translated to <i>new ExtClass(params)</i>.</li>
+      <li><i>constructor New</i> is translated to <i>new ExtClass(params)</i>, and for nested external class: <i>new ExtParentClass.ExtClass(Params)</i></li>
       <li><i>constructor New; external name ''GlobalFunc''</i> is translated to <i>new GlobalFunc(params)</i>.</li>
       <li><i>constructor SomeName; external name </i>'{}'</i> is translated to <i>{}</i>.</li>
-      <li>Otherwise it is translated to <i>new ExtClass.FuncName(params)</i>.</li>
+      <li>Otherwise it is translated to <i>new ExtClass.FuncName(params)</i>, and for nested external class: <i>new ExtParentClass.ExtClass.FuncName(params)</i>.</li>
     </ul>
 
     <table class="sample">