unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* Guile questions
@ 2004-08-26 18:49 Jim Norris
  2004-08-26 21:39 ` Stephen Compall
  2004-08-27 10:01 ` (slightly OT) Dynamic link w/o *.h [was: Guile questions] tomas
  0 siblings, 2 replies; 6+ messages in thread
From: Jim Norris @ 2004-08-26 18:49 UTC (permalink / raw)


Hi, I was working on a tool to let someone dynamically link to dlls in
Windows at runtime when I saw Guile. I couldn't tell if Guile had the
features I'm looking for. If it doesn't maybe I could help add them or
find some other way to help out?

Could you guys answer some questions for me please?

Does Guile let you dynamically link to dlls / object library files at run
time without the need for header (*.h) files, *.def files, or *.lib files?
(or the Unix equivalent)

If it does, does Guile automatically load the function names into Guile's
namespace at runtime?

If the funtion names autoload, does Guile have a mechanism for allowing
the user to select which dll's functions are in the name space at any
given time? This is in case two dll's have functions with the same names
and to speed up script interpretation.

Are there any features users are asking for that Guile currently doesn't
have? If so is there a need for someone to work on those?

Does Guile support Forth like stack based parameter passing from the input
script? Would there be an interest in this if it doesn't?






_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Guile questions
  2004-08-26 18:49 Guile questions Jim Norris
@ 2004-08-26 21:39 ` Stephen Compall
  2004-08-27 10:01 ` (slightly OT) Dynamic link w/o *.h [was: Guile questions] tomas
  1 sibling, 0 replies; 6+ messages in thread
From: Stephen Compall @ 2004-08-26 21:39 UTC (permalink / raw)
  Cc: guile-user

"Jim Norris" <fromfast@rainbarrel.com> writes:

> Does Guile let you dynamically link to dlls / object library files
> at run time without the need for header (*.h) files, *.def files, or
> *.lib files?  (or the Unix equivalent)

You can do this even in C, even fairly portably with libltdl.

> If it does, does Guile automatically load the function names into Guile's
> namespace at runtime?

Do you mean does it find all the so's exported symbols and generate
foreign-function interface calls, exporting the results to Scheme?
No.

The usual manner of making a C library available to Guile is to
manually write a wrapper function, though the tools g-wrap and SWIG,
which use interface descriptions, are available to generate these
wrappers.  Here is an example:

#include <libguile.h>

SCM_DEFINE (jim_norris_puts, "jim-norris-puts", 1, 0, 0,
            (SCM string),
            "Put @var{string} on FILE* stdout.")
#define FUNC_NAME s_jim_norris_puts
{
  SCM_VALIDATE_STRING (SCM_ARG1, string);
  /* warning -- SCM_STRING_CHARS is deprecated.  Plus, one day the
     chars won't be null-terminated */
  fputs (SCM_STRING_CHARS (string), stdout);
  /* I don't think you have to do this (IIRC Guile waits for all
     threads to enter the SCM API before GC), but you might someday: */
  scm_remember_upto_here_1 (string);
  return SCM_UNSPECIFIED;
}
#undef FUNC_NAME

void
init_jim_norris (void)
{
#ifndef SCM_MAGIC_SNARFER
#include "jim_norris.x"
#endif
}

Then call guile-snarf -o jim_norris.x jim_norris.c, compile to a so,
add a module that calls
(load-extension "libjimnorris" "init_jim_norris")

If it's more complicated, you might create a Scheme module that
exports your bindings, then the magic renamery can be done.

> If the funtion names autoload, does Guile have a mechanism for
> allowing the user to select which dll's functions are in the name
> space at any given time? This is in case two dll's have functions
> with the same names and to speed up script interpretation.

You can control the symbol import how you like, including renaming
symbols, and even not importing symbols at all and using @ instead (@
is in HEAD, not 1.6.x).

> Are there any features users are asking for that Guile currently
> doesn't have? If so is there a need for someone to work on those?

If you have a piece of software, consider whether it could benefit
from having a powerful extension language built-in, like Guile, and
integrate it.

--
Stephen Compall or s11 or sirian

Sigh.  I like to think it's just the Linux people who want to be on
the "leading edge" so bad they walk right off the precipice.
(Craig E. Groeschel)

SWAT ANZUS csystems S Box ASPIC BRLO Taiwan MP5K-SD TELINT AUTODIN
jihad argus STARLAN electronic surveillance spies


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 6+ messages in thread

* (slightly OT) Dynamic link w/o *.h [was: Guile questions]
  2004-08-26 18:49 Guile questions Jim Norris
  2004-08-26 21:39 ` Stephen Compall
@ 2004-08-27 10:01 ` tomas
  2004-08-27 13:55   ` Linas Vepstas
  1 sibling, 1 reply; 6+ messages in thread
From: tomas @ 2004-08-27 10:01 UTC (permalink / raw)
  Cc: guile-user

On Thu, Aug 26, 2004 at 02:49:06PM -0400, Jim Norris wrote:
> Hi, I was working on a tool to let someone dynamically link to dlls in
> Windows at runtime when I saw Guile. I couldn't tell if Guile had the
> features I'm looking for. If it doesn't maybe I could help add them or
> find some other way to help out?
> 
> Could you guys answer some questions for me please?
> 
> Does Guile let you dynamically link to dlls / object library files at run
> time without the need for header (*.h) files, *.def files, or *.lib files?
> (or the Unix equivalent)

How do you want to accomplish this? Has a Windows DLL enough info
about how to call a function (i.e. which parameters to expect,
maybe the layout of structs and so on)?

The question might sound ironic. No, I'm genuinley curious. I'm
pondering for a while about `glueless bindings' myself (along the
lines: if gdb can do that... -- but gdb uses the source plus
debugging info: I'd be happy to get that, and you seem to be even
more ambitious).

Regards
-- tomás


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: (slightly OT) Dynamic link w/o *.h [was: Guile questions]
  2004-08-27 10:01 ` (slightly OT) Dynamic link w/o *.h [was: Guile questions] tomas
@ 2004-08-27 13:55   ` Linas Vepstas
  2004-08-27 13:57     ` Linas Vepstas
  0 siblings, 1 reply; 6+ messages in thread
From: Linas Vepstas @ 2004-08-27 13:55 UTC (permalink / raw)
  Cc: Jim Norris, guile-user

On Fri, Aug 27, 2004 at 12:01:18PM +0200, tomas@fabula.de was heard to remark:
> pondering for a while about `glueless bindings' myself (along the
> lines: if gdb can do that... -- but gdb uses the source plus
> debugging info: I'd be happy to get that, and you seem to be even

I thought (and might be wrong) that the function signatures are in 
the debug (-g) info in the .o (the gnu elf 'stabs'), and that the 
source wasn't needed.  Not so?  I wonder if 'objdump' already knows 
this: this would imply that the ability to get the signatures is 
already in a gas library, vastly simplifying your task.

--linas


-- 
pub  1024D/01045933 2001-02-01 Linas Vepstas (Labas!) <linas@linas.org>
PGP Key fingerprint = 8305 2521 6000 0B5E 8984  3F54 64A9 9A82 0104 5933


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: (slightly OT) Dynamic link w/o *.h [was: Guile questions]
  2004-08-27 13:55   ` Linas Vepstas
@ 2004-08-27 13:57     ` Linas Vepstas
  2004-08-27 14:07       ` tomas
  0 siblings, 1 reply; 6+ messages in thread
From: Linas Vepstas @ 2004-08-27 13:57 UTC (permalink / raw)
  Cc: Jim Norris, guile-user

On Fri, Aug 27, 2004 at 08:55:34AM -0500, Linas Vepstas was heard to remark:
> On Fri, Aug 27, 2004 at 12:01:18PM +0200, tomas@fabula.de was heard to remark:
> > pondering for a while about `glueless bindings' myself (along the
> > lines: if gdb can do that... -- but gdb uses the source plus
> > debugging info: I'd be happy to get that, and you seem to be even
> 
> I thought (and might be wrong) that the function signatures are in 
> the debug (-g) info in the .o (the gnu elf 'stabs'), and that the 
> source wasn't needed.  Not so?  I wonder if 'objdump' already knows 
> this: this would imply that the ability to get the signatures is 
> already in a gas library, vastly simplifying your task.

and, of course, this is totally the wrong mailing list for this
discussion, you want to do that on the gcc mailing lists, and/or the
glibc mailing lists.

--linas

-- 
pub  1024D/01045933 2001-02-01 Linas Vepstas (Labas!) <linas@linas.org>
PGP Key fingerprint = 8305 2521 6000 0B5E 8984  3F54 64A9 9A82 0104 5933


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: (slightly OT) Dynamic link w/o *.h [was: Guile questions]
  2004-08-27 13:57     ` Linas Vepstas
@ 2004-08-27 14:07       ` tomas
  0 siblings, 0 replies; 6+ messages in thread
From: tomas @ 2004-08-27 14:07 UTC (permalink / raw)
  Cc: Jim Norris, guile-user, tomas

On Fri, Aug 27, 2004 at 08:57:59AM -0500, Linas Vepstas wrote:
> On Fri, Aug 27, 2004 at 08:55:34AM -0500, Linas Vepstas was heard to remark:
> > On Fri, Aug 27, 2004 at 12:01:18PM +0200, tomas@fabula.de was heard to remark:
> > > pondering for a while about `glueless bindings' myself [...]

> > I thought (and might be wrong) that the function signatures are in 
> > the debug (-g) info in the .o (the gnu elf 'stabs'), [...]

And you might well be right, of course ;-)

> and, of course, this is totally the wrong mailing list for this
> discussion, you want to do that on the gcc mailing lists, and/or the
> glibc mailing lists.

That's why I tagged this as slightly off-topic. Nevertheless, the
possibility of doing automatic run-time bindings (given e.g.
debugging info) might be of interest here.

Thanks for the pointers

-- tomás


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2004-08-27 14:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-08-26 18:49 Guile questions Jim Norris
2004-08-26 21:39 ` Stephen Compall
2004-08-27 10:01 ` (slightly OT) Dynamic link w/o *.h [was: Guile questions] tomas
2004-08-27 13:55   ` Linas Vepstas
2004-08-27 13:57     ` Linas Vepstas
2004-08-27 14:07       ` tomas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).