On Wed, 14 Jun 2000, Stefan Matthias Aust wrote:
I'm not aware of a general solution, but it's pretty easy to call external programs in Windows using the FFI. This is my first contact with FFI, so I'm not sure whether this is the most elegant solution but it seems to work.
Yes - this seems like the best option. Which means I will have to move to Squeak 2.8. I'll have to see if I can make this work on all platforms (winShellOpen:, macShellOpen: and unixShellOpen:) inside a single image.
To cool thing about ShellExecute is that Windows knows the right application from the file extension. So it opens a *.html file in your favorite browser.
Perfect! This lets me avoid have a preference dialog to set the browser path. On the other hand, having that dialog would allow the option of using Scamper...
-- Jecel
Just for fun I tried to play with the FFI plugin on the mac but it failed and when I listed the built in plugins on the 2.8beta5 I could not see it:
Smalltalk listBuiltinModules #('BitBltPlugin 12 June 2000 (i)' 'B2DPlugin 12 June 2000 (i)' 'SurfacePlugin' 'FilePlugin 12 June 2000 (i)' 'SocketPlugin 12 June 2000 (i)' 'SoundPlugin 12 June 2000 (i)' 'MIDIPlugin 12 June 2000 (i)' 'SerialPlugin 12 June 2000 (i)' 'JoystickTabletPlugin 12 June 2000 (i)' 'AsynchFilePlugin 12 June 2000 (i)' 'LargeIntegers v1.1 12 June 2000 (i)' 'FFTPlugin 12 June 2000 (i)' 'FloatArrayPlugin 12 June 2000 (i)' 'Matrix2x3Plugin 12 June 2000 (i)' 'ZipPlugin 12 June 2000 (i)')
So my question goes: where is it ?
Karl
Jecel Assumpcao Jr wrote:
On Wed, 14 Jun 2000, Stefan Matthias Aust wrote:
I'm not aware of a general solution, but it's pretty easy to call external programs in Windows using the FFI. This is my first contact with FFI, so I'm not sure whether this is the most elegant solution but it seems to work.
Yes - this seems like the best option. Which means I will have to move to Squeak 2.8. I'll have to see if I can make this work on all platforms (winShellOpen:, macShellOpen: and unixShellOpen:) inside a single image.
To cool thing about ShellExecute is that Windows knows the right application from the file extension. So it opens a *.html file in your favorite browser.
Perfect! This lets me avoid have a preference dialog to set the browser path. On the other hand, having that dialog would allow the option of using Scamper...
-- Jecel
Karl Ramberg wrote:
Just for fun I tried to play with the FFI plugin on the mac but it failed and when I listed the built in plugins on the 2.8beta5 I could not see it:
...
So my question goes: where is it ?
Karl
_Now_ you know why I had some misgivings about Squeakworld, as yet another Squeak-related site that will increase the _entropy_ of the Squeak universe, in addition to the total mass as is the intention.
Oh, and try Andreas Raab's website. Or look in the mail archives. Or--eh, you get the idea.
Henrik
At 01:11 pm 6/14/00, Jecel Assumpcao Jr wrote:
To cool thing about ShellExecute is that Windows knows the right application from the file extension. So it opens a *.html file in your favorite browser.
<chuckle>
Perfect! This lets me avoid have a preference dialog to set the browser path. On the other hand, having that dialog would allow the option of using Scamper...
Hmm, the ability to register a SqueakOpenRequest stub of some sort would be a good thing for Scamper and other "desktop" clients. A miniature client executable Object that can relay a Set of the OS open request paramenters as a localhost Smalltalk message to the active Squeak image.
Could we just port AppleScript and Internet Config to Windoze? <grin>
-- Lantz Rowland lantz@aabysgallery.com PgpKey: 0x67E5DFA5 The Geek Under The FloorBoards of AabysGallery AabysGallery http://aabysgallery.com/ ----------------------------------------------------------------------
[Yes, I realize that I'm following up to a 20 day old post. I've been ignoring the list and enjoying the nice weather instead, as of late ;)]
On Wed, Jun 14, 2000 at 05:11:11PM -0300, Jecel Assumpcao Jr wrote:
On Wed, 14 Jun 2000, Stefan Matthias Aust wrote:
I'm not aware of a general solution, but it's pretty easy to call external programs in Windows using the FFI. This is my first contact with FFI, so I'm not sure whether this is the most elegant solution but it seems to work.
Yes - this seems like the best option. Which means I will have to move to Squeak 2.8. I'll have to see if I can make this work on all platforms (winShellOpen:, macShellOpen: and unixShellOpen:) inside a single image.
Actually, the "system" function will do this and, since it's part of the ANSI C library specification, should be available on every system that runs Squeak.
There are a few other ANSI lib OS functions that would also be useful to reach from Squeak such as getenv() and setenv().
--Chris
On Wed, 05 Jul 2000, Chris Reuter wrote:
[Yes, I realize that I'm following up to a 20 day old post. I've been ignoring the list and enjoying the nice weather instead, as of late ;)]
Since I have been busy with other things, this was still very timely and helpful.
Actually, the "system" function will do this and, since it's part of the ANSI C library specification, should be available on every system that runs Squeak.
I have actually used this function quite a bit in my programs (mostly due to laziness - it is much simpler to system("rm /tmp/xxx") than to look up the proper functions to do this ;-)
Still, it took me quite a while to find that it was declared in stdlib.h in Linux. I had somehow managed to miss it when grepping /usr/include and subdirectories.
My impression is that FFI is for calling functions in external libraries. Can it also be used for stuff like this that is in that standard library?
There are a few other ANSI lib OS functions that would also be useful to reach from Squeak such as getenv() and setenv().
That would be nice.
-- Jecel
On Wed, Jul 05, 2000 at 06:36:04PM -0300, Jecel Assumpcao Jr wrote:
On Wed, 05 Jul 2000, Chris Reuter wrote:
[Yes, I realize that I'm following up to a 20 day old post. I've been ignoring the list and enjoying the nice weather instead, as of late ;)]
Since I have been busy with other things, this was still very timely and helpful.
Actually, the "system" function will do this and, since it's part of the ANSI C library specification, should be available on every system that runs Squeak.
I have actually used this function quite a bit in my programs (mostly due to laziness - it is much simpler to system("rm /tmp/xxx") than to look up the proper functions to do this ;-)
The only problem is that it won't work on platforms without rm.
Still, it took me quite a while to find that it was declared in stdlib.h in Linux. I had somehow managed to miss it when grepping /usr/include and subdirectories.
My impression is that FFI is for calling functions in external libraries. Can it also be used for stuff like this that is in that standard library?
It shouldn't be an issue. Most compilers/OSs put the standard libraries in a shared library. Of course, implementing an interface in Squeak means determining *which* shared library/.dll contains the ANSI lib, which varies between platforms and even between compilers on some platforms.
So the Right Thing to do is to link them to a plugin so that the Squeak side doesn't have to know what platform it's running on (bare-metal ports could just use stubs).
Of course, that's not necessarily enough for "system()" because it passes the command to a shell, which varies between platforms. The Right Thing here would be to wrap it with a function that takes the name, arguments, and whether or not to run the program in the background and then calls the relevant platform-dependent function.
Fortunately, the other useful ANSI C functions (getenv() and setenv()) are straightforward.
There are a few other ANSI lib OS functions that would also be useful to reach from Squeak such as getenv() and setenv().
That would be nice.
Having just looked through Harbison&Steele, I can't see any other OS-type functions that are in ANSI whose functionality isn't already provided by the Squeak environment (with the possible exception of raise() and signal()--probably more trouble than they are worth). This would actually make a nice little learning exercise to teach myself FFI.
--Chris
On Wed, 5 Jul 2000, Jecel Assumpcao Jr wrote:
My impression is that FFI is for calling functions in external libraries. Can it also be used for stuff like this that is in that standard library?
Yes. If you don't supply a module name the function gets looked up in the executable itself, which includes the standard lib. For the system() call, that would be:
system: aString <cdecl: long 'system' (char *)> ^ExternalFunction externalCallFailed
Now, the recent external primitive rework has broken this. To look up an internal function, the program module itself must be loaded via dlopen(NULL,...) - something that has vanished from the sources.
I've attached a diff for both sqUnixExternalPrims.c and the omni-platform sqNamedPrims.c.
THIS AFFECTS OTHER PLATFORMS!
Now, ioLoadModule() is called once with an empty module name to load the intrinsics. The resulting handle is stored in squeakModule->handle. Someone should make this work for other platforms ;^)
-- Bert
In message Pine.LNX.4.21.0007061001460.13752-200000@balloon.cs.uni-magdeburg.de you wrote:
Now, the recent external primitive rework has broken this. To look up an internal function, the program module itself must be loaded via dlopen(NULL,...) - something that has vanished from the sources.
If I'm understanding your problem right, this is done by adding your function to the list in the file platform.exports which then adds it to the list of internal prims.
tim
On Thu, 6 Jul 2000, Tim Rowledge wrote:
Now, the recent external primitive rework has broken this. To look up an internal function, the program module itself must be loaded via dlopen(NULL,...) - something that has vanished from the sources.
If I'm understanding your problem right, this is done by adding your function to the list in the file platform.exports which then adds it to the list of internal prims.
Not quite. This is for *FFI* calls, like the system() example. You can't know in advance what function will be called. That's the whole point of having FFI. It's about calling functions in the libc which is already linked to the VM so it can't be loaded as external library.
-- Bert
(This is a repost of my previous patch as changeset. It's also enhanced to allow other platforms than Unix to continue to work. Note that the SourceForge CVS already has this patch.)
"Change Set: intrinsicFFI-bf Date: 12 July 2000 Author: Bert Freudenberg
Changes sqNamedPrims.c to try to load the squeakModule via ioLoadModule(''). This gives the platform code the chance to actually load the intrinsics - for Unix, that's dlopen(NULL). Platforms not needing this feature should just return NULL from ioLoadModule('')."
-- Bert
Bert,
Bert Freudenberg wrote:
(This is a repost of my previous patch as changeset. It's also enhanced to allow other platforms than Unix to continue to work.
Note that the SourceForge CVS already has this patch.)
Thanks for changing SF CVS yourself!
Greetings,
Stephan
"Change Set: intrinsicFFI-bf Date: 12 July 2000 Author: Bert Freudenberg
Changes sqNamedPrims.c to try to load the squeakModule via ioLoadModule(''). This gives the platform code the chance to actually load the intrinsics - for Unix, that's dlopen(NULL). Platforms not needing this feature should just return NULL from ioLoadModule('')."
-- Bert
Name: intrinsicFFI-bf.1.cs.gz
intrinsicFFI-bf.1.cs.gz Type: APPLICATION/x-gzip Encoding: BASE64
squeak-dev@lists.squeakfoundation.org