From bd8362dfcee6f9ea9ab9d60754afdca8335d05f1 Mon Sep 17 00:00:00 2001 From: Mattias Gaertner Date: Fri, 13 Nov 2020 10:22:45 +0000 Subject: [PATCH] pastojs: typecast integer to widechar git-svn-id: trunk@47407 - --- packages/pastojs/src/fppas2js.pp | 4 ++-- packages/pastojs/tests/tcmodules.pas | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/pastojs/src/fppas2js.pp b/packages/pastojs/src/fppas2js.pp index 2d7d80f912..575547e075 100644 --- a/packages/pastojs/src/fppas2js.pp +++ b/packages/pastojs/src/fppas2js.pp @@ -12305,9 +12305,9 @@ begin end; end; end - else if to_bt=btChar then + else if to_bt in [btChar,btWideChar] then begin - if from_bt=btChar then + if from_bt in [btChar,btWideChar] then begin // char to char Result:=ConvertExpression(Param,AContext); diff --git a/packages/pastojs/tests/tcmodules.pas b/packages/pastojs/tests/tcmodules.pas index ff0494f405..5b65b69caf 100644 --- a/packages/pastojs/tests/tcmodules.pas +++ b/packages/pastojs/tests/tcmodules.pas @@ -7937,9 +7937,11 @@ begin 'var', ' c: char;', ' wc: widechar;', + ' w: word;', 'begin', ' Fly(wc);', ' Run(c);', + ' wc:=WideChar(w);', '']); ConvertProgram; CheckSource('TestWideChar_VarArg', @@ -7950,6 +7952,7 @@ begin '};', 'this.c = "";', 'this.wc = "";', + 'this.w = 0;', '']), LinesToStr([ // this.$main '$mod.Fly({', @@ -7970,6 +7973,7 @@ begin ' this.p.c = v;', ' }', '});', + '$mod.wc = String.fromCharCode($mod.w);', '', ''])); end;