nielsAD / lape

Scripting engine with Pascal-like syntax for FPC and Delphi
118 stars 28 forks source link

Lape usage on Delphi #170

Closed Vizit0r closed 3 years ago

Vizit0r commented 3 years ago

Seems like last year nobody test it (or even try to compile) on Delphi, many new FP-only things found.

So, i've made changes for Delphi (including Linux & MacOs) in my repo (all changes described) https://github.com/Vizit0r/lape/commit/7125790e3b15a8f99466387823039fbcd5a011a7

dont want to pull it here yet due to some amount of failed tests (especially on Linux-MacOs) - read commit description. From my side, i fix all what i can, remaining failed tests need real understanding of internal mechanics, i'm not good in that.

@ollydev , can you please install Delphi, and find the reason of bugs?

in Lazarus all tests passed successfully.

Linux tests results attached for reference - Linux tests.txt

P.S. In FFI all is much worse, last time i make it work partially, but not fully. Later on will try again from zero.

ollydev commented 3 years ago

Lape has never really been used much on Delphi - just compile fixes once in a while. The Linux tests are quite worrying. I suspect this was because Delphi was Windows only when Lape was mainly being developed in early 2010s.

FFI is another story. FPC and Delphi seem to have a lot of differences at what they do with parameters with calling conventions.

I will soon download Delphi on Linux and have a look though.

Vizit0r commented 3 years ago

Ok, call me if any question with Delphi, linux\macos preparation, running, etc.

Vizit0r commented 3 years ago

@ollydev any news?

ollydev commented 3 years ago

Ugh! The regular tests on windows all pass. Was annoying. It's 4:30 AM right now... https://github.com/ollydev/lape/tree/delphi-fixes

I guess that's step one. Will look at the tests on Linux next.

Vizit0r commented 3 years ago

good job! As i see, a lot of extra code written for dynarrays, thats really great.

Few notices: 1) lptypes.pas. As i write in my commit,

  UInt32 = LongWord; //LongWord in Delphi - Platform-dependent type, so in POSIX x64 we have troubles
  Int32 = LongInt;   //LongInt - same

but you remove this defines block, and left
Int32 = LongInt;

so, you will have 100% problems with non-Win x64 platforms on Delphi.

2) if {$DEFINE Lape_Unicode} switched on in lape.inc, test SetOfChar.lap failed. Thats because Unicode Char is 2 bytes in Delphi unlike to FPC's UTF8 unicode.

ollydev commented 3 years ago

Updated https://github.com/ollydev/lape/tree/delphi-fixes

Every normal test passes on macOS. Can't test linux but should be the same. Will tidy up and merge here soon.

ollydev commented 3 years ago

merged #172

For FFI, fpc now has it's own FFI stuff. Lape should take note from it as some of lape FFI was guessed and hacked. Where this should have the answers. https://gitlab.com/freepascal.org/fpc/source/-/blob/main/packages/libffi/src/ffi.manager.pp