mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-17 17:49:13 +02:00
pastojs: nested external class constructor
git-svn-id: trunk@49351 -
This commit is contained in:
parent
9bfc731bb6
commit
4ddaa26fc0
@ -18003,11 +18003,20 @@ begin
|
|||||||
'{$modeswitch externalclass}',
|
'{$modeswitch externalclass}',
|
||||||
'type',
|
'type',
|
||||||
' TExtA = class external name ''ExtA''',
|
' 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;',
|
||||||
' constructor Create(i: longint; j: longint = 2);',
|
' constructor Create(i: longint; j: longint = 2);',
|
||||||
' end;',
|
' end;',
|
||||||
'var',
|
'var',
|
||||||
' A: texta;',
|
' A: texta;',
|
||||||
|
' C: texta.textb.textc;',
|
||||||
'begin',
|
'begin',
|
||||||
' a:=texta.create;',
|
' a:=texta.create;',
|
||||||
' a:=texta(texta.create);',
|
' a:=texta(texta.create);',
|
||||||
@ -18021,11 +18030,15 @@ begin
|
|||||||
' a:=test1.texta.create;',
|
' a:=test1.texta.create;',
|
||||||
' a:=test1.texta.create();',
|
' a:=test1.texta.create();',
|
||||||
' a:=test1.texta.create(3);',
|
' a:=test1.texta.create(3);',
|
||||||
|
' c:=texta.textb.textc.new;',
|
||||||
|
' c:=texta.textb.textc.new();',
|
||||||
|
' c:=texta.textb.textc.new(4);',
|
||||||
'']);
|
'']);
|
||||||
ConvertProgram;
|
ConvertProgram;
|
||||||
CheckSource('TestExternalClass_Constructor',
|
CheckSource('TestExternalClass_Constructor',
|
||||||
LinesToStr([ // statements
|
LinesToStr([ // statements
|
||||||
'this.A = null;',
|
'this.A = null;',
|
||||||
|
'this.C = null;',
|
||||||
'']),
|
'']),
|
||||||
LinesToStr([ // $mod.$main
|
LinesToStr([ // $mod.$main
|
||||||
'$mod.A = new ExtA.Create();',
|
'$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();',
|
'$mod.A = new ExtA.Create();',
|
||||||
'$mod.A = new ExtA.Create(3,2);',
|
'$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;
|
end;
|
||||||
|
|
||||||
|
@ -2723,10 +2723,10 @@ function(){
|
|||||||
Destructors are not allowed.<br>
|
Destructors are not allowed.<br>
|
||||||
Constructors are supported in four ways:
|
Constructors are supported in four ways:
|
||||||
<ul>
|
<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 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><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>
|
</ul>
|
||||||
|
|
||||||
<table class="sample">
|
<table class="sample">
|
||||||
|
Loading…
Reference in New Issue
Block a user