* Calling function (command-line) from c++ dll
@ 2003-11-17 9:31 Laurent Marzullo
2003-11-17 11:13 ` Stephen Compall
2003-11-17 15:00 ` Marius Vollmer
0 siblings, 2 replies; 4+ messages in thread
From: Laurent Marzullo @ 2003-11-17 9:31 UTC (permalink / raw)
Hello,
I'm currently writting a module that I load with (load-extension)
function and I'm tryin to get the command line option of the guile
script into the init function of the dll.
------ guile script ----------------------------
#!/usr/local/bin/guile -s
!#
(load-extension "libpvcs" "init_pvcs")
-----------------------------------------------
------ c++ source file -------------------------
void
init_pvcs( void )
{
SCM command_line_func = scm_c_lookup( "command-line" );
// Now I'm trying to call command-line, which must return
// a list, isn't it ???
//
SCM arg_lst = scm_c_call_with_current_module(
scm_current_module(),
????????? ,
0 );
// How do I call it ??
}
------------------------------------------------
How to call command-line from a C module ?????
Thanks a lot !!
--
Laurent Marzullo <marzullo@la-defense.oilfield.slb.com>
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Calling function (command-line) from c++ dll
2003-11-17 9:31 Calling function (command-line) from c++ dll Laurent Marzullo
@ 2003-11-17 11:13 ` Stephen Compall
2003-11-17 15:00 ` Marius Vollmer
1 sibling, 0 replies; 4+ messages in thread
From: Stephen Compall @ 2003-11-17 11:13 UTC (permalink / raw)
Cc: Guile
Laurent Marzullo <marzullo@la-defense.oilfield.slb.com> writes:
> I'm currently writting a module that I load with (load-extension)
> function and I'm tryin to get the command line option of the guile
> script into the init function of the dll.
http://www.gnu.org/software/guile/docs/guile-ref/Runtime-Environment.html
says use C function scm_program_arguments (void). Much healthier for
you.
--
Stephen Compall or s11 or sirian
Are you mentally here at Pizza Hut??
ASIO BRLO secure Telex PLO genetic e-cash world domination radar
counter terrorism credit card Marxist kilo class CID Forte
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Calling function (command-line) from c++ dll
2003-11-17 9:31 Calling function (command-line) from c++ dll Laurent Marzullo
2003-11-17 11:13 ` Stephen Compall
@ 2003-11-17 15:00 ` Marius Vollmer
2003-11-17 18:18 ` Stephen Compall
1 sibling, 1 reply; 4+ messages in thread
From: Marius Vollmer @ 2003-11-17 15:00 UTC (permalink / raw)
Cc: Guile
Laurent Marzullo <marzullo@la-defense.oilfield.slb.com> writes:
> I'm currently writting a module that I load with (load-extension)
> function and I'm tryin to get the command line option of the guile
> script into the init function of the dll.
As Stephen has pointed out, just use the C function
scm_program_arguments for this.
But in case you are wondering how to call Scheme functions in general:
SCM
call_named_function_with_no_args (const char *name)
{
return scm_call_0 (scm_variable_ref (scm_c_lookup (name)));
}
SCM
call_named_function_with_one_arg (const char *name, SCM arg1)
{
return scm_call_1 (scm_variable_ref (scm_c_lookup (name)), arg1);
}
But if you want to call a function more than once, you should of
course store away the result of scm_variable_ref and use it directly
with scm_call_<n>.
The function scm_c_call_with_current_module is used to temporarily
switch to a different module and execute code there. It is not
related to calling Scheme functions.
(scm_call_<n> is unfortunately not yet in the 1.6.x manual...)
--
GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3 331E FAF8 226A D5D4 E405
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Calling function (command-line) from c++ dll
2003-11-17 15:00 ` Marius Vollmer
@ 2003-11-17 18:18 ` Stephen Compall
0 siblings, 0 replies; 4+ messages in thread
From: Stephen Compall @ 2003-11-17 18:18 UTC (permalink / raw)
Cc: Guile
Marius Vollmer <mvo@zagadka.de> writes:
> But if you want to call a function more than once, you should of
> course store away the result of scm_variable_ref and use it directly
> with scm_call_<n>.
(marzullo et guile-user): Though if the function variable's value may
change as a result of some operation made between calls, you may want
to simply store away the symbol from the name, and do a
scm_variable_ref each time, which is alot like how Scheme code is read
(store symbol) and evaluated (variable ref). The difference is
somewhat -- though not quite -- akin to:
(map mylist myfunc)
versus
(map mylist (lambda args (apply myfunc args)))
...which was recently discussed on guile-devel :)
The possibilities are, of course, endless.
--
Stephen Compall or s11 or sirian
Do people know you have freckles everywhere?
ASIO industrial intelligence mailbomb UNSCOM virus emc Forte digicash
chameleon man AIEWS BRLO Cocaine Ft. Meade bootleg data haven
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2003-11-17 18:18 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-11-17 9:31 Calling function (command-line) from c++ dll Laurent Marzullo
2003-11-17 11:13 ` Stephen Compall
2003-11-17 15:00 ` Marius Vollmer
2003-11-17 18:18 ` Stephen Compall
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).