mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-18 20:39:43 +02:00
pastojs: type helper for jsvalue
git-svn-id: trunk@43032 -
This commit is contained in:
parent
1145d0d18a
commit
c769b8dc7d
@ -10154,7 +10154,8 @@ begin
|
||||
end;
|
||||
// default: search for type helpers
|
||||
if (LeftResolved.BaseType in btAllStandardTypes)
|
||||
or (LeftResolved.BaseType=btContext) then
|
||||
or (LeftResolved.BaseType=btContext)
|
||||
or (LeftResolved.BaseType=btCustom) then
|
||||
begin
|
||||
if SearchInTypeHelpers(LeftResolved.HiTypeEl,LeftResolved.IdentEl) then exit;
|
||||
end
|
||||
|
@ -689,6 +689,7 @@ type
|
||||
Procedure TestTypeHelper_Word;
|
||||
Procedure TestTypeHelper_Double;
|
||||
Procedure TestTypeHelper_StringChar;
|
||||
Procedure TestTypeHelper_JSValue;
|
||||
Procedure TestTypeHelper_Array;
|
||||
Procedure TestTypeHelper_EnumType;
|
||||
Procedure TestTypeHelper_SetType;
|
||||
@ -23530,6 +23531,70 @@ begin
|
||||
'']));
|
||||
end;
|
||||
|
||||
procedure TTestModule.TestTypeHelper_JSValue;
|
||||
begin
|
||||
StartProgram(false);
|
||||
Add([
|
||||
'{$modeswitch typehelpers}',
|
||||
'type',
|
||||
' TExtValue = type jsvalue;',
|
||||
' THelper = type helper for TExtValue',
|
||||
' function ToStr: String;',
|
||||
' end;',
|
||||
'function THelper.ToStr: String;',
|
||||
'begin',
|
||||
'end;',
|
||||
'var',
|
||||
' s: string;',
|
||||
' v: TExtValue;',
|
||||
'begin',
|
||||
' s:=v.toStr;',
|
||||
' s:=v.toStr();',
|
||||
' TExtValue(s).toStr;',
|
||||
'']);
|
||||
ConvertProgram;
|
||||
CheckSource('TestTypeHelper_JSValue',
|
||||
LinesToStr([ // statements
|
||||
'rtl.createHelper($mod, "THelper", null, function () {',
|
||||
' this.ToStr = function () {',
|
||||
' var Result = "";',
|
||||
' return Result;',
|
||||
' };',
|
||||
'});',
|
||||
'this.s = "";',
|
||||
'this.v = undefined;',
|
||||
'']),
|
||||
LinesToStr([ // $mod.$main
|
||||
'$mod.s = $mod.THelper.ToStr.call({',
|
||||
' p: $mod,',
|
||||
' get: function () {',
|
||||
' return this.p.v;',
|
||||
' },',
|
||||
' set: function (v) {',
|
||||
' this.p.v = v;',
|
||||
' }',
|
||||
'});',
|
||||
'$mod.s = $mod.THelper.ToStr.call({',
|
||||
' p: $mod,',
|
||||
' get: function () {',
|
||||
' return this.p.v;',
|
||||
' },',
|
||||
' set: function (v) {',
|
||||
' this.p.v = v;',
|
||||
' }',
|
||||
'});',
|
||||
'$mod.THelper.ToStr.call({',
|
||||
' p: $mod,',
|
||||
' get: function () {',
|
||||
' return this.p.s;',
|
||||
' },',
|
||||
' set: function (v) {',
|
||||
' rtl.raiseE("EPropReadOnly");',
|
||||
' }',
|
||||
'});',
|
||||
'']));
|
||||
end;
|
||||
|
||||
procedure TTestModule.TestTypeHelper_Array;
|
||||
begin
|
||||
StartProgram(false);
|
||||
|
Loading…
Reference in New Issue
Block a user