Recent

Author Topic: 64 bits and PascalScript  (Read 7128 times)

maurog

  • Jr. Member
  • **
  • Posts: 84
Re: 64 bits and PascalScript
« Reply #15 on: June 15, 2025, 06:06:29 pm »
Yes, that would be a possibility. Thank you very much.
And yes, Lazarus is definitely a beast – it comes with everything you need, but sometimes also more than you expect. 😅 (Chat-GPT)

LV

  • Sr. Member
  • ****
  • Posts: 427
Re: 64 bits and PascalScript
« Reply #16 on: June 15, 2025, 07:17:33 pm »
Sometimes I catch myself thinking that I stubbornly do some things in Pascal. Although it may be suitable, such as Lua (https://github.com/malcome/Lua4Lazarus), for these purposes.  :)

maurog

  • Jr. Member
  • **
  • Posts: 84
Re: 64 bits and PascalScript
« Reply #17 on: June 15, 2025, 08:27:56 pm »
Yes, Pascal is simply more fun. Besides, if you use PascalScript, you don’t need any DLLs or shared objects.
And on top of that, for PascalScript there’s already a simple IDE with full debugger support implemented.
I’ll probably stick with PascalScript, and when I have more time (right now I’m busy with TurboBird), I plan to take a deep dive into the PascalScript source code.
Maybe I’ll be able to improve something. And if not, I’ll contact Carlo (the author). Maybe he’ll help us.

And yes, Lazarus is definitely a beast – it comes with everything you need, but sometimes also more than you expect. 😅 (Chat-GPT)

PascalDragon

  • Hero Member
  • *****
  • Posts: 6395
  • Compiler Developer
Re: 64 bits and PascalScript
« Reply #18 on: June 16, 2025, 09:58:12 pm »
Newer versions of Delphi have some API to make calls using RTTI... I don't know what is avail in FPC 3.3.1 (and I heard somewhere it may need some so/dll - but I may have mistaken something else).

The API is available even in FPC 3.2.2. Without a function call manager it can be used for register-functions on i386 as well as on x86_64-win64. For other platforms (and calling conventions) the use of libffi through the FFI.Manager unit is required (and thus the use of libffi.so).

LV

  • Sr. Member
  • ****
  • Posts: 427
Re: 64 bits and PascalScript
« Reply #19 on: June 19, 2025, 11:17:30 pm »
Hi

The suggestion above to solve this problem is a workaround. It consisted of writing wrappers and registering in the script engine for the host program procedures that ran additional event handler scripts. This is not very convenient. After getting to know the PascalScript source code a little, you can find another solution. The attached project shows the idea of ​​registering handlers that can be created in the main script code using a simple example.
The functionality has been tested using Lazarus 3.4; FPC 3.2.2 on Win32, Win64, and Deb64.


lhl

  • New Member
  • *
  • Posts: 10
Re: 64 bits and PascalScript
« Reply #20 on: January 04, 2026, 02:03:27 pm »
O https://github.com/pult
 helped me use this fork: https://github.com/pult/pascalscript
, in which the issue with x64 events started to work correctly.
Link to the discussion in 2020: https://github.com/remobjects/pascalscript/issues/230

However, I was not completely satisfied with this solution, as I believe the fix should be made by RemObjects itself and officially made available in the Lazarus distribution. For this reason, I raise this question on the Lazarus forum:
https://forum.lazarus.freepascal.org/index.php/topic,70668

maurog

  • Jr. Member
  • **
  • Posts: 84
Re: 64 bits and PascalScript
« Reply #21 on: January 05, 2026, 07:33:38 pm »
I have discussed this issue directly with the PascalScript developers on GitHub:
https://github.com/remobjects/pascalscript/issues/271

My original post there:

Hello, I have integrated PascalScript into LazCAD (a 2D CAD application based on Lazarus/FPC).
The problem with events in GUI scripts only occurs in 64-bit applications.
Hence the speculation in the Lazarus forum that the scripter always uses 32-bit pointers for events, regardless of whether it is compiled in 32- or 64-bit.
https://forum.lazarus.freepascal.org/index.php/topic,71170.0.html

In the 32-bit version of LazCAD, the events are triggered correctly.

Response from the PascalScript team:

This was fixed in commit 2ebc623 for Delphi.
The fix is not enabled for FPC, because it's not known if it works there.
I can enable it in FPC if you can confirm it works.

If I understand this correctly, Lazarus/FPC uses its own port of PascalScript, and this 64-bit fix is currently not enabled or integrated there.
Therefore, it seems that the FPC/Lazarus port may need to be adjusted or tested so that GUI events work correctly in 64-bit applications.

Best regards,
Maurog
And yes, Lazarus is definitely a beast – it comes with everything you need, but sometimes also more than you expect. 😅 (Chat-GPT)

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12345
  • Debugger - SynEdit - and more
    • wiki
Re: 64 bits and PascalScript
« Reply #22 on: January 05, 2026, 09:25:48 pm »
If I understand this correctly, Lazarus/FPC uses its own port of PascalScript, and this 64-bit fix is currently not enabled or integrated there.
Therefore, it seems that the FPC/Lazarus port may need to be adjusted or tested so that GUI events work correctly in 64-bit applications.

True, but as explained, the inclusion is made only to fulfill editor-macro needs, and they do not use events. So the current version fully works.

Its a long time, since I checked (probably a year, maybe longer), in the past most updates had commit messages marking them as Delphi only. And its been unclear which branch to follow.
I see that there have been cherry picks, since...

So when I find time, I may merge them into 4.99.



But even if, I will only test that it works for editor macros. And nothing else.

If the commit you look for is
Quote
86a057c8686143ce0443be6995d6515c5c9b705c
* 1)InvokeCall added, instead of all different callers (x86, x64, powerpc etc) for Delphi 2010+. (#207)

then I don't know if it will work... From hear say, if at all then only with fpc 3.3.1, and potentially some extra conditions on top (but I have no idea).

So for your own project, I am afraid, but I can't help you.
All that any update would do, is to save you from downloading a copy from remobjects, and you probably have done that already.

If it is InvokeCall, then ask on the fpc list (or the fpc section of the forum) what you need to use the function. Once that works, you should then be able to use it with PascalScript too. (I guess).

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12345
  • Debugger - SynEdit - and more
    • wiki
Re: 64 bits and PascalScript
« Reply #23 on: January 05, 2026, 09:31:19 pm »
As for the changes that are in lazarus, they are mostly removal of ifdef code.
Or fixing ifdef, for unsupported targets, ie. make it compile, even if it will not run.

There is an addition (that IIRC exists as PR to upstream) for an alternative registration of methods.


So using the upstream version should work just as well, if not better.

LV

  • Sr. Member
  • ****
  • Posts: 427
Re: 64 bits and PascalScript
« Reply #24 on: January 05, 2026, 10:56:43 pm »
Some time ago, I needed to create a cross-platform application that would work on both Windows 64-bit and Debian 64-bit. The integrated script had to manage various types of numerical and symbolic mathematics, plot graphs, interact with the host program's GUI, dynamically create forms and components, and handle events. To my surprise, Lazarus, along with the included Pascal Script, accomplished this task with ease and without any masochism. The challenge of event handling in a 64-bit environment was effectively addressed by managing events in child scripts.

franciscoluiz

  • New Member
  • *
  • Posts: 26
Re: 64 bits and PascalScript
« Reply #25 on: January 06, 2026, 04:07:20 pm »
Hi

The suggestion above to solve this problem is a workaround. It consisted of writing wrappers and registering in the script engine for the host program procedures that ran additional event handler scripts. This is not very convenient. After getting to know the PascalScript source code a little, you can find another solution. The attached project shows the idea of ​​registering handlers that can be created in the main script code using a simple example.
The functionality has been tested using Lazarus 3.4; FPC 3.2.2 on Win32, Win64, and Deb64.

estas granda plezuro renkonti iun, kiu scias esperanton.

en: it's a great pleasure to meet someone who knows esperanto
« Last Edit: January 07, 2026, 12:06:58 am by franciscoluiz »

PascalDragon

  • Hero Member
  • *****
  • Posts: 6395
  • Compiler Developer
Re: 64 bits and PascalScript
« Reply #26 on: January 06, 2026, 09:22:01 pm »
estas granda plezuro renkonti iun, kiu scias esperanton.

Please only use English on the international part of the forum or at least provide an English translation.

maurog

  • Jr. Member
  • **
  • Posts: 84
Re: 64 bits and PascalScript
« Reply #27 on: January 07, 2026, 02:37:59 am »
@Martin_fr
Quote
So when I find time, I may merge them into 4.99.

Thank you very much for your effort.

@lhl
Quote
O https://github.com/pult
 helped me use this fork: https://github.com/pult/pascalscript
, in which the issue with x64 events started to work correctly.

Thank you for the hint.
Does this fork also work under Linux?

If so, since I am already using a slightly modified version of PascalScript from the Lazarus repository (among other things for the debugger), I will most likely use the fork at
https://github.com/pult/pascalscript

for the time being.
And yes, Lazarus is definitely a beast – it comes with everything you need, but sometimes also more than you expect. 😅 (Chat-GPT)

LV

  • Sr. Member
  • ****
  • Posts: 427
Re: 64 bits and PascalScript
« Reply #28 on: January 07, 2026, 09:15:41 am »
estas granda plezuro renkonti iun, kiu scias esperanton.

en: it's a great pleasure to meet someone who knows esperanto

Mi ĵus lernas Esperanton. Ĝi estas eleganta lingvo, kiu mi esperas baldaŭ fariĝos la lingvo de la forumo Lazarus. 😉.

Kaj en programado, mi ĵus malkovris Lape, unu el la plej rapidaj enigitaj skriptoj por la Pascal-mondo.
- malpeza;
- plurplatforma;
- potenca (grandordo pli rapida ol PascalScript, pli rapida ol pura Python);
- povas fari ĉion, aŭ preskaŭ ĉion.

Mi finos per iu grava laboro kaj iom post iom reverkos la skriptajn partojn de miaj projektoj en Lape.

P.S. Dankon al @zamtmn, kiu prezentis al mi Lape en sia mallonga afiŝo https://forum.lazarus.freepascal.org/index.php/topic,16665.msg571301.html#msg571301 👌

En:
I'm just learning Esperanto. It's an elegant language that I hope will soon become the language of the Lazarus forum. 😉.

And in programming, I recently discovered Lape, one of the fastest embedded scripts for the Pascal world.
- lightweight;
- cross-platform;
- powerful (an order of magnitude faster than PascalScript, faster than pure Python);
- can do everything, or almost everything.

I'll finish up with some important work and gradually rewrite the scripting parts of my projects in Lape.

P.S. Thanks to @zamtmn, who introduced me to Lape in his short post https://forum.lazarus.freepascal.org/index.php/topic,16665.msg571301.html#msg571301 👌



DonAlfredo

  • Hero Member
  • *****
  • Posts: 1877
Re: 64 bits and PascalScript
« Reply #29 on: January 07, 2026, 10:46:39 am »
Lape looks very interesting. I have added it (as an installable module) into fpcupdeluxe.
Will be available next release.

 

TinyPortal © 2005-2018