Writing Externals in Pascal?

classic Classic list List threaded Threaded
27 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Writing Externals in Pascal?

Scott McDonald
Hi All,

Trying to gauge the potential interest in a Revolution Externals SDK
that could allow you to develop externals in Lazarus/Free Pascal.
Instead of requiring some form of C/C++ wrapper, which is the only
language that is currently supported by the official Externals SDK.

To be able to write externals purely in a Pascal/Delphi dialect would be
useful to me, but I do not know for certain if it can be done with Free
Pascal -- there may be linking or name mangling issues which prevent it
from working.

* So before trying, I am just wondering what level of interest there
would be in such a resource?

If it's just me who still uses Pascal, then I probably won't even bother
thinking further about it. But if there is interest, who knows...

Note, I have little free time for such a project, so even if there is
significant interest, I make no promises about whether it will happen,
or when.
--
Scott McDonald

RunRevPlanet.com
"Components, Stacks, Tools and Resources for Runtime Revolution"
www.runrevplanet.com

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
--
Scott McDonald
"Components, Controls, Tools and Resources for LiveCode"
www.runrevplanet.com
Reply | Threaded
Open this post in threaded view
|

Re: Writing Externals in Pascal?

planix
Hi Scott,

I would be interested. I used to program in Delphi a fair bit- though I am purely an amateur.

I would certainly rather write externals in pascal than C. Like you I don't have a lot of time, and I doubt I have the expertise, but I would be interested in helping where I can.

cheers

Alistair
JB
Reply | Threaded
Open this post in threaded view
|

Re: Writing Externals in Pascal?

JB
In reply to this post by Scott McDonald
I would be interested in programming externals in Pascal but I am
not familiar with the pascal you mentioned so I can't comment on
the choice of pascal.

-=>JB<=-


On Jul 5, 2010, at 1:49 AM, RunRevPlanet wrote:

> Hi All,
>
> Trying to gauge the potential interest in a Revolution Externals  
> SDK that could allow you to develop externals in Lazarus/Free  
> Pascal. Instead of requiring some form of C/C++ wrapper, which is  
> the only language that is currently supported by the official  
> Externals SDK.
>
> To be able to write externals purely in a Pascal/Delphi dialect  
> would be useful to me, but I do not know for certain if it can be  
> done with Free Pascal -- there may be linking or name mangling  
> issues which prevent it from working.
>
> * So before trying, I am just wondering what level of interest  
> there would be in such a resource?
>
> If it's just me who still uses Pascal, then I probably won't even  
> bother thinking further about it. But if there is interest, who  
> knows...
>
> Note, I have little free time for such a project, so even if there  
> is significant interest, I make no promises about whether it will  
> happen, or when.
> --
> Scott McDonald
>
> RunRevPlanet.com
> "Components, Stacks, Tools and Resources for Runtime Revolution"
> www.runrevplanet.com
>
> _______________________________________________
> use-revolution mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your  
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
>

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: Writing Externals in Pascal?

Andre Garzia-3
In reply to this post by Scott McDonald
Scott,

Been there as well. I remember many many many years ago talking about this
exact topic with members of the community and with if I recall, there were
some troubles in the way FPC generated the libraries, some linker stuff
which might not be a problem these days.

It would be a wonderful feature if Rev had a comprehensive FFI so that we
could use other languages besides C/C++ to extend it.

Cheers
andre
PS: Stay tunned for some stuff I am about to release about interoperation.

On Mon, Jul 5, 2010 at 5:49 AM, RunRevPlanet <
[hidden email]> wrote:

> Hi All,
>
> Trying to gauge the potential interest in a Revolution Externals SDK that
> could allow you to develop externals in Lazarus/Free Pascal. Instead of
> requiring some form of C/C++ wrapper, which is the only language that is
> currently supported by the official Externals SDK.
>
> To be able to write externals purely in a Pascal/Delphi dialect would be
> useful to me, but I do not know for certain if it can be done with Free
> Pascal -- there may be linking or name mangling issues which prevent it from
> working.
>
> * So before trying, I am just wondering what level of interest there would
> be in such a resource?
>
> If it's just me who still uses Pascal, then I probably won't even bother
> thinking further about it. But if there is interest, who knows...
>
> Note, I have little free time for such a project, so even if there is
> significant interest, I make no promises about whether it will happen, or
> when.
> --
> Scott McDonald
>
> RunRevPlanet.com
> "Components, Stacks, Tools and Resources for Runtime Revolution"
> www.runrevplanet.com
>
>
> _______________________________________________
> use-revolution mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
>



--
http://www.andregarzia.com All We Do Is Code.
_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: Writing Externals in Pascal?

Scott McDonald
In reply to this post by Scott McDonald
Alistair,

Thank you for the offer. Nice to hear from another Delphi familiar. If I
start the project I will certainly let you know, if I need assistance.


-=>JB<=-,

Free Pascal is a cross platform Pascal compiler that does standard
Object Pascal plus more. It is also largely compatible with the Turbo
Pascal 7 and Delphi 7 extensions to the Pascal language that have been
part of the Borland (Embarcadero these days) line of compilers.

While Lararus is a IDE that is built on top of Free Pascal, initially to
"clone" the Delphi IDE, but which is now going in it's own direction.

Most significantly, both these tools are cross-platform and can produce
binaries for Mac and Windows (as well as many other platforms).


Andre,

I did a search here before launching this idea and found your previous
messages about it. The linker issues may still exist, but Free Pascal
has come quite a way since then, and I am hoping that the issues from
before may now be resolvable.

                           ooOOOoo

Before coming to Revolution, Pascal/Delphi was my language of choice
(which it still is for some types of projects) and so if I could write
Externals with it for Revolution that would be a nice productivity boost.
--
Scott McDonald

RunRevPlanet.com
"Components, Stacks, Tools and Resources for Runtime Revolution"
www.runrevplanet.com

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
--
Scott McDonald
"Components, Controls, Tools and Resources for LiveCode"
www.runrevplanet.com
JB
Reply | Threaded
Open this post in threaded view
|

Re: Writing Externals in Pascal?

JB
Thanks for the info.  I hope the problems can be resolved.

-=>JB<=-


On Jul 5, 2010, at 6:05 AM, RunRevPlanet wrote:

> Alistair,
>
> Thank you for the offer. Nice to hear from another Delphi familiar.  
> If I start the project I will certainly let you know, if I need  
> assistance.
>
>
> -=>JB<=-,
>
> Free Pascal is a cross platform Pascal compiler that does standard  
> Object Pascal plus more. It is also largely compatible with the  
> Turbo Pascal 7 and Delphi 7 extensions to the Pascal language that  
> have been part of the Borland (Embarcadero these days) line of  
> compilers.
>
> While Lararus is a IDE that is built on top of Free Pascal,  
> initially to "clone" the Delphi IDE, but which is now going in it's  
> own direction.
>
> Most significantly, both these tools are cross-platform and can  
> produce binaries for Mac and Windows (as well as many other  
> platforms).
>
>
> Andre,
>
> I did a search here before launching this idea and found your  
> previous messages about it. The linker issues may still exist, but  
> Free Pascal has come quite a way since then, and I am hoping that  
> the issues from before may now be resolvable.
>
>                           ooOOOoo
>
> Before coming to Revolution, Pascal/Delphi was my language of  
> choice (which it still is for some types of projects) and so if I  
> could write Externals with it for Revolution that would be a nice  
> productivity boost.
> --
> Scott McDonald
>
> RunRevPlanet.com
> "Components, Stacks, Tools and Resources for Runtime Revolution"
> www.runrevplanet.com
>
> _______________________________________________
> use-revolution mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your  
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
>

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: Writing Externals in Pascal?

mwieder
In reply to this post by Scott McDonald
Scott-

Things may have changed with Delphi, but I fear you may run into the
problem I had back in 2004 when I attempted this. See bug #1526. The
issue was the inability to coax Borland compilers into the proper
combination of compiler options to export symbols that the runrev
engine would recognize as valid.

--
-Mark Wieder
 [hidden email]

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
--
 Mark Wieder
 ahsoftware@gmail.com
Reply | Threaded
Open this post in threaded view
|

Re: Writing Externals in Pascal?

Andre Garzia-3
Argh! I remember that bug in 2005...

just commented and voted on it again.

argh!

On Mon, Jul 5, 2010 at 12:28 PM, Mark Wieder <[hidden email]> wrote:

> Scott-
>
> Things may have changed with Delphi, but I fear you may run into the
> problem I had back in 2004 when I attempted this. See bug #1526. The
> issue was the inability to coax Borland compilers into the proper
> combination of compiler options to export symbols that the runrev
> engine would recognize as valid.
>
> --
> -Mark Wieder
>  [hidden email]
>
> _______________________________________________
> use-revolution mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
>



--
http://www.andregarzia.com All We Do Is Code.
_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: Writing Externals in Pascal?

Alejandro Tejada
In reply to this post by Scott McDonald
Hi Scott,

Hopefully, you could find help among the Free Pascal
developers and programmers to workaround the
problems that Mark Wieder reported in 2004:
--------------------------------------------------
http://quality.runrev.com/qacenter/show_bug.cgi?id=1526

Presently only external libraries in Microsoft-compatible
binary form will work with the engine. This is due to the
necessity of recognizing a signature of the exported
Xtable and Xname items. It is impossible to get the level
of granularity of compiler options with Borland's compilers
(C++ Builder, Delphi) to get the combination of:

1. no leading underscore
2. mixed case exported symbols
3. C-style parameter passing (first to last)
4- C-style stack frames (calling program cleans up
the stack)

The way around this would be to accept alternate entry
points of _Xtable and _Xname if the first check of Xtable
and Xname failed. This would open up the development
of external libraries to existing BCCB and Delphi programmers
and allow the simple modification of libraries that currently
exist for other environments. To me this seems like a simple
change to the engine with large paybacks in terms of
opening things up for third-parties to develop add-ons.
----------------------------------------------------
Al

Reply | Threaded
Open this post in threaded view
|

Re: Writing Externals in Pascal?

mwieder
In reply to this post by Andre Garzia-3
Andre-

Monday, July 5, 2010, 8:35:01 AM, you wrote:

> Argh! I remember that bug in 2005...

> just commented and voted on it again.

> argh!

I wouldn't bother wasting votes on this. I finally pulled my votes
away and put them to better use on other bug reports. It's

A) filed as an enhancement, so it'll get *no* attention from the team
B) assigned to an engineer no longer with the company

--
-Mark Wieder
 [hidden email]

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
--
 Mark Wieder
 ahsoftware@gmail.com
Reply | Threaded
Open this post in threaded view
|

Re: Writing Externals in Pascal?

Scott McDonald
In reply to this post by Scott McDonald
Thanks for the extra tips. At this stage I have only done a quick read
of the documentation of the Free Pascal Compiler, but from what I have
read it appears more flexible than the Borland compilers in terms of the
  libraries it can produce.

But I won't really know what it is capable of until I do some experiments.

The comments and interest are encouraging though.
--
Scott McDonald

RunRevPlanet.com
"Components, Stacks, Tools and Resources for Runtime Revolution"
www.runrevplanet.com

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
--
Scott McDonald
"Components, Controls, Tools and Resources for LiveCode"
www.runrevplanet.com
Reply | Threaded
Open this post in threaded view
|

Re: Writing Externals in Pascal?

Peter W A Wood
In reply to this post by Alejandro Tejada
Hi Scott

I am also be interested in being able to develop externals in Free Pascal. At the moment, I am testing calling a dynamic load library written in Free Pascal from Rebol (a language written in C) using C calling conventions.

> It is impossible to get the level
> of granularity of compiler options with Borland's compilers
> (C++ Builder, Delphi) to get the combination of:
> 1. no leading underscore

You get to name the function in FPC. Here is an extract from my dll:

{$ifndef Darwin}
exports  
  version name 'version';
{$else}
exports
  version name '_version';
{$endif}

> 2. mixed case exported symbols

I tested with a mixed case function name:

exports
  accountingformat name '_accountingFormat',
  version name '_version';


> 3. C-style parameter passing (first to last)
> 4- C-style stack frames (calling program cleans up
> the stack)

FPC includes a modifier for the cdecl calling convention (which I believe answers 3 & 4). Here is an example:

procedure version(var answer: shortstring);cdecl;
begin
  answer := CurrentVersion;
end;

Regards

Peter Wood

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: Writing Externals in Pascal?

Scott McDonald
In reply to this post by Scott McDonald
Peter,

Thanks for your tips from using Free Pascal with Rebol. You have
confirmed what I though from the Free Pascal Compiler (FPC)
documentation, that it should be able to make libraries that are
indistinguishable from those made from a C compiler.

Now it is more a question of time, as I am busy with some other (paying)
projects written in Revolution, and so the FPC Externals SDK really is
just a side project to do in those spare(?!) moments.
--
Scott McDonald

RunRevPlanet.com
"Components, Stacks, Tools and Resources for Runtime Revolution"
www.runrevplanet.com
_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
--
Scott McDonald
"Components, Controls, Tools and Resources for LiveCode"
www.runrevplanet.com
Reply | Threaded
Open this post in threaded view
|

Re: Writing Externals in Pascal?

mwieder
In reply to this post by Peter W A Wood
Peter-

Monday, July 5, 2010, 4:59:11 PM, you wrote:

> Free Pascal. At the moment, I am testing calling a dynamic load
> library written in Free Pascal from Rebol (a language written in C)
> using C calling conventions.

Keep us posted on your progress - that's a promising start.

--
-Mark Wieder
 [hidden email]

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
--
 Mark Wieder
 ahsoftware@gmail.com
Reply | Threaded
Open this post in threaded view
|

Re: Writing Externals in Pascal?

slylabs13
Whoa! Pascal still lives?? Maybe I am not so old after all.

Bob


On Jul 7, 2010, at 9:26 AM, Mark Wieder wrote:

> Peter-
>
> Monday, July 5, 2010, 4:59:11 PM, you wrote:
>
>> Free Pascal. At the moment, I am testing calling a dynamic load
>> library written in Free Pascal from Rebol (a language written in C)
>> using C calling conventions.
>
> Keep us posted on your progress - that's a promising start.
>
> --
> -Mark Wieder
> [hidden email]
>
> _______________________________________________
> use-revolution mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: Writing Externals in Pascal?

Neal Campbell K3NC
The 2010 version of Delphi is a killer development environment and the 2011
version will have cross-compile for OS X. You can tell its what I do a lot
of work in!

Neal Campbell
Abroham Neal Software
www.abrohamnealsoftware.com
(540) 645 5394 NEW PHONE NUMBER





On Wed, Jul 7, 2010 at 1:56 PM, Bob Sneidar <[hidden email]> wrote:

> Whoa! Pascal still lives?? Maybe I am not so old after all.
>
> Bob
>
>
> On Jul 7, 2010, at 9:26 AM, Mark Wieder wrote:
>
> > Peter-
> >
> > Monday, July 5, 2010, 4:59:11 PM, you wrote:
> >
> >> Free Pascal. At the moment, I am testing calling a dynamic load
> >> library written in Free Pascal from Rebol (a language written in C)
> >> using C calling conventions.
> >
> > Keep us posted on your progress - that's a promising start.
> >
> > --
> > -Mark Wieder
> > [hidden email]
> >
> > _______________________________________________
> > use-revolution mailing list
> > [hidden email]
> > Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> > http://lists.runrev.com/mailman/listinfo/use-revolution
>
> _______________________________________________
> use-revolution mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
>
_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: Writing Externals in Pascal?

Richmond Mathewson-2
In reply to this post by slylabs13
On 07/07/2010 08:56 PM, Bob Sneidar wrote:
> Whoa! Pascal still lives?? Maybe I am not so old after all.
>
> Bob
>
>
>    
Sorry to dash your illusions; I studied PASCAL 5 in 1985;

Thee and Me are alive, and so is PASCAL; neither Thee, not
Me, nor PASCAL are as young as we were in 1985.

Hey; anybody remember MINIFORTRAN?

----------------------------------------------------------------------------------------

I remember when I was visiting Mum and Dad at New Year
seeing my PASCAL final project lurking in the attic; maybe
I should get it out and 'give it a whirl'. Mind you typing the
whole thing into the machine will be a real labour of love.

What I do remember is:

1. It was a program for making a concordance of a text.
    [This was conceived because I was sent 'over' from the
     Philosophy department to the Maths dept. for computer
     programming. The lecturers all made loud and public
     fun of the "wierdo in the kilt from the Philosophy dept"
     and said that ONLY mathematicians could program;
     and that PASCAL, being a serious, hairy-chested sort
     of computer language, could only deal with crunching
     numbers - hence my determination to crunch text].

2. A long-suffering 'slave' in the computer building
     (full of enormous tape drives that went "whirr, whirr")
     typed in an English translation of Leibniz's 'Monadologie'.

3. The program crashed the University computer (hurrah,
     hurrah - let's hear it for Mathewson).

I will probably be able to run it on a Pentium II I have,
running FreeDOS with the GEM GUI (lovely job) and
some sort of cheapo PASCAL - in all likelihood the 32 MB
RAM is more than the University of Durham had in 1985.

4. An incredibly seedy man who was my computer
     supervisor almost tied himself in knots having to admit
    that my program was the best of the 100 students in the year.
    Extra fun was had because I asked the head of Philosophy to
    accompany me to the meeting so that I could make a formal
    complaint about departmental bullying towards me because
    I was an Arts student.

About once every 5 years I go back to Durham to visit . . .
. . . the pubs where I did most of my studying; and everytime
I pass the building that housed the VAX (I wonder what is in
there now?) I blow it a kiss - Wow I wish my life now was
as much fun as when I was an undergraduate!!!!
_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: Writing Externals in Pascal?

Peter W A Wood
In reply to this post by mwieder
Mark

I suspect that writing a dynamic link library for use with Rebol is likely to be easier than writing an external for Revolution. The Rebol language is evaluated not compiled.

I found writing a dynamic link library with FPC quite straightforward though I encountered two problems which I have been able to overcome.

The first could hinder developing complicated externals for Revolution. FPC does not support error handling in dynamic link libraries, so no try/finally etc.. I believe this is due to the difficulty of coming up with a cross-platform implementation. This limitation can probably be overcome through conservative and defensive coding in most cases. In my case, I perform additional validations in the Rebol module that calls the dynamic link library.

The second is that there is a conflict between the Mac OS X Snow Leopard linker and FPC. There is a work around but the resulting dynamic link library is not fully stable. I believe this is something to do with initialisation and termination routines. The workaround is to compile the dynamic link library under Mac OS X Leopard.

The dynamic link library is very simple but runs successfully on Windows, Ubuntu and Mac OS X.

Regards

Peter



On 8 Jul 2010, at 00:26, Mark Wieder wrote:

> Peter-
>
> Monday, July 5, 2010, 4:59:11 PM, you wrote:
>
>> Free Pascal. At the moment, I am testing calling a dynamic load
>> library written in Free Pascal from Rebol (a language written in C)
>> using C calling conventions.
>
> Keep us posted on your progress - that's a promising start.
>
> --
> -Mark Wieder
> [hidden email]
>
> _______________________________________________
> use-revolution mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: Writing Externals in Pascal?

Peter Alcibiades
In reply to this post by Richmond Mathewson-2
You see, Richmond, what you needed was regular expressions.....
Reply | Threaded
Open this post in threaded view
|

Re: Writing Externals in Pascal?

Richmond Mathewson-2
On 07/08/2010 10:06 PM, Peter Alcibiades wrote:
> You see, Richmond, what you needed was regular expressions.....
>    

What I need is a da*n good holiday!
_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
12