From: bajcik@kolos.math.uni.lodz.pl
Subject: one C function to many Scheme functions
Date: Mon, 6 Jan 2003 21:30:29 +0100 [thread overview]
Message-ID: <20030106203029.GA11033@gosia> (raw)
hello,
I know how to use gh_new_procedure* functions to declare function
visible in scheme script.
But I want to declare many functions in a loop. I have a table of names
and a table of C-functions [ mytype_t function(my_type arg) ] and only
ONE C-function that converts SCM to mytype_t. It is a wrapper.
I would like to do it this way:
typedef struct
{
mytype_t (*func)(mytype_t arg);
char *name;
} scm_func_t;
scm_func_t FuncTable[50]; /* Initialized */
SCM wrapper(SCM arg, void *data) /* !!! watch "data" */
{
scm_func_t *sf = (scm_func_t *)data;
my_type_t my_result;
...
my_arg = SCM2my(arg);
...
my_result = sf->func(my_arg)
...
return my2SCM(my_result);
}
void declare_all_functions()
{
int i;
for (i=0; i<50; i++)
gh_new_procedure_data(FuncTable[i].func, &FuncTable[i]);
}
Do you feel the sense?
FuncTable can't be a table with "SCM (*)(SCM)" functions, because my
program uses few script languages in plugins.
bajcik
--
.----- Krzysztof Garus ----- http://kolos.math.uni.lodz.pl/~bajcik/ --.
| http://kolos.math.uni.lodz.pl/~bajcik/duskc/ - proszę o krytykę :) |
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
next reply other threads:[~2003-01-06 20:30 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-01-06 20:30 bajcik [this message]
2003-01-08 20:45 ` one C function to many Scheme functions Neil Jerram
2003-01-09 10:26 ` Krzysztof Garus
2003-01-09 23:30 ` Neil Jerram
2003-01-09 11:40 ` Matthias Koeppe
2003-01-09 23:19 ` Neil Jerram
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20030106203029.GA11033@gosia \
--to=bajcik@kolos.math.uni.lodz.pl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).