Recent

Author Topic: Can LCL be used from other programming languages?  (Read 8859 times)

LazaruX

  • Hero Member
  • *****
  • Posts: 597
  • Lazarus original cheetah.The cheetah doesn't cheat
Can LCL be used from other programming languages?
« on: January 16, 2015, 03:40:36 pm »
I am curious, can LCL be "called" from other languages? (e.g. C++?)

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12567
  • FPC developer.
Re: Can LCL be used from other programming languages?
« Reply #1 on: January 16, 2015, 03:55:46 pm »
Hacks are always possible, but not in a straightforward way.

It is like how C++ QT has to be flattened by qtpas. You need to cater for the change in object model and for the use of types the other language doesn't have (templates, ansistring etc)

LazaruX

  • Hero Member
  • *****
  • Posts: 597
  • Lazarus original cheetah.The cheetah doesn't cheat
Re: Can LCL be used from other programming languages?
« Reply #2 on: January 16, 2015, 04:01:04 pm »
Actually I meant calling the methods like in a DLL...But thanks for the reply




Btw you should put some sugar on that oliebol

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12567
  • FPC developer.
Re: Can LCL be used from other programming languages?
« Reply #3 on: January 16, 2015, 04:26:16 pm »
Actually I meant calling the methods like in a DLL...But thanks for the reply

Yes, me too :-)  QT is also in a DLL, but to access this C++ code  from FPC, we must flatten it to plain procedural code (qtpas.dll), and then rebuild it OO in the QT widgetset of Lazarus.

IOW the otherway around (C++ code using Object Pascal code) would need the same treatment, since C++ can't directly call Pascal methods, and doesn't know all Pascal types.

Fred vS

  • Hero Member
  • *****
  • Posts: 3724
    • StrumPract is the musicians best friend
Re: Can LCL be used from other programming languages?
« Reply #4 on: January 16, 2015, 08:38:44 pm »
Quote
I am curious, can LCL be "called" from other languages? (e.g. C++?)

Hum, other languages may use fpGUIlib (library version of fpGUI who is 100 % pure fpc library)  :-[
https://github.com/fredvs/fpGUIlib
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

Leledumbo

  • Hero Member
  • *****
  • Posts: 8833
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Can LCL be used from other programming languages?
« Reply #5 on: January 17, 2015, 05:52:21 am »
I am curious, can LCL be "called" from other languages? (e.g. C++?)
There you go. The project is a stub with TApplication, TForm and TButton only, but it works. No one seems interested enough to continue its development so it stays as a stub. LCL is quite HUGE to port and if nobody uses the bindings, the effort will be useless.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12567
  • FPC developer.
Re: Can LCL be used from other programming languages?
« Reply #6 on: January 18, 2015, 04:28:07 pm »
It probably would have to be autogenerated to be of any use.

TurboRascal

  • Hero Member
  • *****
  • Posts: 672
  • "Good sysadmin. Bad programmer."™
Re: Can LCL be used from other programming languages?
« Reply #7 on: January 19, 2015, 05:20:39 pm »
BTW, I was wondering about the possibility of using LCL and FPC classes in general from Delphi... Is it possible to export/import classes without flattening?
Regards, ArNy the Turbo Rascal
-
"The secret is to give them what they need, not what they want." - Scotty, STTNG:Relics

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Can LCL be used from other programming languages?
« Reply #8 on: January 19, 2015, 05:23:55 pm »
...sigh... Interfaces?

TurboRascal

  • Hero Member
  • *****
  • Posts: 672
  • "Good sysadmin. Bad programmer."™
Re: Can LCL be used from other programming languages?
« Reply #9 on: January 19, 2015, 05:41:55 pm »
Thanks, I'll look into it. But, since I'm pretty much dumb about interfaces, I'm sure to trip up on something soon, if nothing else some memory management issue...

Any tips&hints to get me going? :)
Regards, ArNy the Turbo Rascal
-
"The secret is to give them what they need, not what they want." - Scotty, STTNG:Relics

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Can LCL be used from other programming languages?
« Reply #10 on: January 19, 2015, 06:21:36 pm »
Any tips&hints to get me going? :)
Sure, do exactly what you don't want to do! - flat the interface.
Do the plugin first.
Make sure it works (without mem leaks and other issues).

Once "flat" works, you can study interfaces and do the same plugin with interfaces.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12567
  • FPC developer.
Re: Can LCL be used from other programming languages?
« Reply #11 on: January 19, 2015, 08:03:34 pm »
One of the reasons is that interfaces are usually only an escape when designed in from the start, i.e. for new class hierarchies, not for already existing ones.

Moreover, the Delphi way relies on widestring being an automatable type over all borders, something that is windows specific.

TurboRascal

  • Hero Member
  • *****
  • Posts: 672
  • "Good sysadmin. Bad programmer."™
Re: Can LCL be used from other programming languages?
« Reply #12 on: January 20, 2015, 02:28:29 pm »
Thanks, so it seems to me that maybe flattening and rebuilding the class in Delphi the same way as I would for C++ is maybe the easiest way. For the simplest needs I'd say it's easiest to create objects in the lib and make them do all the work, while only passing them input variables from the host and providing procedure calls telling them to do the job. ;)
Regards, ArNy the Turbo Rascal
-
"The secret is to give them what they need, not what they want." - Scotty, STTNG:Relics

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12567
  • FPC developer.
Re: Can LCL be used from other programming languages?
« Reply #13 on: January 20, 2015, 04:58:10 pm »
Yes, and memory management must remain separated (so no automated types, and the RTL that is used to create an object must be used to free it).

There are exceptions to those rules, but in general it is wise to start with the above philosophy.

If it is windows only, it is probably better to turn both sides into COM Objects.

 

TinyPortal © 2005-2018