Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2002-07

Re: plugin frameworks.

12 messages · 10 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Full_Name
to Alan Grimes: K... I have no intention of buying much less programming a current version of windows...…

Quoting Alan Grimes :

Take a look on Torry (www.torry.net) and search form 'plugin' (right hand, toppish corner.)

If you're feeling lazy, this link is to the first freeware example with source on the list I got back:

http://www.torry.net/samples/samples/plugins/plugin.zip

I have no idea if it will help you, but I've looked at a lot of these, and they do merit some consideration.

Matt

"Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." Kristian Wilson, Nintendo, Inc, 1989 -----BEGIN GEEK CODE BLOCK----- Version: 3.12 GCS d? s+++:+ a- C++ UL+ P L++ E---- W- N+ o+ K- w O- M V PS PE-- Y PGP- t- 5-- X- R- tv+ b+ DI++ D+ G e++ h--- r+++ y+++ ------END GEEK CODE BLOCK------

Reply by email

Carlo Kok
to Aitor Santamaría: Yes, they do. I overlooked it and got the idea. Now I have a question: what if the…

----- Original Message -----

Earlier message 46 lines
From: "Aitor Santamaría" To: Sent: Thursday, July 18, 2002 4:20 PM Subject: Re: [fpc-pascal]plugin frameworks. > Full_Name wrote: > > >Quoting Alan Grimes : > > > >Take a look on Torry (www.torry.net) and search form 'plugin' (right hand, > >toppish corner.) > > > >If you're feeling lazy, this link is to the first freeware example with source > >on the list I got back: > > > >http://www.torry.net/samples/samples/plugins/plugin.zip > > > >I have no idea if it will help you, but I've looked at a lot of these, and they > >do merit some consideration. > > > Yes, they do. I overlooked it and got the idea. Now I have a question: > what if the plug-in would want to use a function (better, an API) which > lies in the main program? > Would I have to pass an array of pointers to procedures/functions/vars > from the main program to the plug-in? Any less-dirty idea? Use a record like Winamp does: type PPluginData = ^TPluginData; TPluginData = record PluginInterfaceVersion: Word; ShowMessageProc: procedure (msg: pchar); end; > Maybe the answer to this question comes from: "how does GDI32.DLL do > when it has to use KERNEL32.DLL functions? (from the SAME already loaded > kernel, not from a new instance)" Anyone knows about this? A dll is loaded only once per process. Ck

Reply by email

Aitor Santamaría
to Full_Name: Quoting Alan Grimes : Take a look on Torry (www.torry.net) and search form 'plugin'…
Full_Name wrote 13 lines
Quoting Alan Grimes : Take a look on Torry (www.torry.net) and search form 'plugin' (right hand, toppish corner.) If you're feeling lazy, this link is to the first freeware example with source on the list I got back: http://www.torry.net/samples/samples/plugins/plugin.zip I have no idea if it will help you, but I've looked at a lot of these, and they do merit some consideration.

Yes, they do. I overlooked it and got the idea. Now I have a question: what if the plug-in would want to use a function (better, an API) which lies in the main program?
Would I have to pass an array of pointers to procedures/functions/vars from the main program to the plug-in? Any less-dirty idea? Maybe the answer to this question comes from: "how does GDI32.DLL do when it has to use KERNEL32.DLL functions? (from the SAME already loaded kernel, not from a new instance)" Anyone knows about this?

Aitor

Reply by email

Aitor Santamaría
to Carlo Kok: ----- Original Message ----- From: "Aitor Santamaría" To: Sent: Thursday, July 18, 2002…
Show quoted text 9 lines
>Maybe the answer to this question comes from: "how does GDI32.DLL do >when it has to use KERNEL32.DLL functions? (from the SAME already loaded >kernel, not from a new instance)" Anyone knows about this? > A dll is loaded only once per process.

ok, so if I understood: let's suppose P is a program that calls A.DLL and B.DLL. Suppose that A.DLL calls B.DLL too. B.DLL is loaded *once* and the *same* instance is seen for both P and A.DLL under Windows, right? By the way, this is what I was told that does *not* happen with WDOSX (different instances of B.DLL are opened), unfortunately. Does anyone have experiences with WDOSX and Win32-FPC executables about this topic?

Aitor

Reply by email

Marco van de Voort
to Alan Grimes: K... I have no intention of buying much less programming a current version of windows...…
Show quoted text 8 lines
> Plugins can be implemented in a variety of ways, ranging > from DLL's/.so's (look to LoadLibrary and GetProcAddress API functions > in Windows, I don't know the Linux versions for .so's) I have no intention of buying much less programming a current version of windows... I poked around in Borland C++ 4.51 looking for said functions but I couldn't find them in the helpfile... There was nothing resembling those in the Free Pascal docs either.

For what OSes do you need these functions?

For win32 and *nix you can use unit dynlibs.

For Win32 this means DLLs.

For Unix this means shared libraries. There are currently some limitations with FPC shared libraries (no PIC), which means that the implementation will have some problems ( everything must be compiled at once)

Afaik there hasn't been much testing with larger numbers of FPC generated (so non PIC) shared libraries under *nix yet.

> to named pipes (doable in windows and linux) to COM/COM+/DCOM > implementations (Windows only?).

COM becomes CORBA under *nix, but is less common. (but e.g. Gnome uses it)

Pure Dos is harder. The default extender Go32V2 can easily (and quite well) create DXE's, but that nearly excludes runtime library usage in the plugins.

An alternative would be the dos extender WDOSX, which supports DLLs. There was some research into the feasability of this, and IIRC it worked, but I don't know details.

Reply by email

Alan Grimes
Show quoted text 5 lines
>I was greatly saddened when I read in one of the manuals that the >overlay feature had been removed... What you are looking for would probably be better suited by a plugin architecture.

K...

Plugins can be implemented in a variety of ways, ranging from DLL's/.so's (look to LoadLibrary and GetProcAddress API functions in Windows, I don't know the Linux versions for .so's)

I have no intention of buying much less programming a current version of windows... I poked around in Borland C++ 4.51 looking for said functions but I couldn't find them in the helpfile... There was nothing resembling those in the Free Pascal docs either.

to named pipes (doable in windows and linux) to COM/COM+/DCOM implementations (Windows only?).

Pipes suck... Furthermore I don't know how to be tyranical over the child process if it had that much autonomy.

Look for sample plugin frameworks and see what you can find that suits your needs.

What keywords should I google?

It may be Delphi code, and may be Windows specific, but it should get you thinking about methods that don't require quite the hassles and dangers that TP's old overlay method brought.

=\

Linux has more source code than my brain. http://users.rcn.com/alangrimes/

Reply by email

Jeff Wormsley
to Marco van de Voort: For what OSes do you need these functions? For win32 and *nix you can use unit dynlibs.…

*********** REPLY SEPARATOR ***********

PM wrote
For what OSes do you need these functions?

Indeed, that is the most important question.

I spend most of my time (read 99.9%) in Win32, so the only help I can give is for this platform. With DLL's, a neat way to handle bi-directional "function calls" is to build a window handle and message loop and pass this to the DLL. Then use SendMessage or PostMessage (depending upon desired blocking behavior) with paramaters that are pointers to the data structures to exchange. For Delphi, COM is preferred for this type thing, but I don't think FPC has interfaces yet, so you need to use this message method instead. It is a bit clunky, and not very RAD, but it does work. I don't know what the linux equivalent is, nor the various DOS extenders.

Jeff.

Reply by email

Sergey Korshunoff
to Marco van de Voort: For what OSes do you need these functions? For win32 and *nix you can use unit dynlibs.…

18 jule 2002 18:45, Marco van de Voort wrote:
.> For Unix this means shared libraries. There are currently some limitations

with FPC shared libraries (no PIC), which means that the implementation will have some problems ( everything must be compiled at once)

Another problem with FPC made *.so: this libs can not be used with a fpc made main program!!!

It is planned to add ".hidden PASCALMAIN" in FPC generated asm?

Regards,
Sergey Korshunoff

Reply by email

Sebastian Günther
to Marco van de Voort: For what OSes do you need these functions? For win32 and *nix you can use unit dynlibs.…
COM becomes CORBA under *nix, but is less common. (but e.g. Gnome uses it)

not necessarily; COM and CORBA are two totally different things. COM can be used on non-Windows systems as well (more or less); for example Mozilla's XPCOM is just a portable version of COM. (XP = Cross Platform) COM is much less powerful than CORBA, but OTOH much more lightweight... (as long as you really mean COM and not DCOM)

- Sebastian

Reply by email

A.J. Venter
to Olaf Leidinger: Hi If you're looking for a portable way have a look at the glib unit from gtk - either…

Ok all this considdered then I though I should share my typecase code with you and ask for help correcting it.

{$H+}
program mysql_example;

....

Function S2P (Str: AnsiString) : Pchar;
Begin
	S2P := StrAlloc (length(Str)+1);
	S2P := StrPCopy (S2P,Str);
end;

....
{Then when I want to do a mysql_query with web data I would do something like: mysql_query(sock,s2p('SELECT * FROM table WHERE name="'+Data[1].value'));

Which consistently fail whenever the total lenth of Str exceeds 255 characters (everything after 255 gets thrown away);

The explicit declaration of Str as type AnsiString was added later (when trying to debug) I get the same results using just string with {$H+} declared.

Any help would be greatly appreciated.

CIao
A.J. Venter

Olaf Leidinger wrote 16 lines
Hi If you're looking for a portable way have a look at the glib unit from gtk - either 1.0 or 2.0. The original C-Reference is found here: http://developer.gnome.org/doc/API/2.0/glib/glib-dynamic-loading-of-modules . html Ciao, Olaf _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply by email

Marco van de Voort
to A.J. Venter
Show quoted text 13 lines
Ok all this considdered then I though I should share my typecase code with you and ask for help correcting it. {$H+} program mysql_example; .... Function S2P (Str: AnsiString) : Pchar; Begin S2P := StrAlloc (length(Str)+1); S2P := StrPCopy (S2P,Str);

StrPCopy is defined for shortstring only.
So it will typecast the ansistring shortstring first, and then pass it to strpcopy to copy it into the pchar.

{Then when I want to do a mysql_query with web data I would do something like: mysql_query(sock,s2p('SELECT * FROM table WHERE name="'+Data[1].value'));

Much to complicated. Remember that ansistrings are relatives of pchars, and can be typecast to such beasts.

If the system will only read from the pchar, you can directly pass an
ansistring;
var s:ansistring;
S:='SELECT * FROM table WHERE NAME="'+Data[1].value+'"';
mysql_query(sock,pchar(S));

Reply by email