[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Benchmarks of guile-www against HB's Guile module.
From: |
Alejandro Forero Cuervo |
Subject: |
Re: Benchmarks of guile-www against HB's Guile module. |
Date: |
Wed, 13 Feb 2002 12:11:35 -0500 |
User-agent: |
Mutt/1.2.5i |
Alejandro> void callback ( SCM data, SCM name, SCM proc );
Alejandro> /* assignments to hb_guile_hbfile_smob with the pointer
*/
Alejandro> gh_define("hbfile", hb_guile_hbfile_smob);
Alejandro> gh_new_procedure3_0("hb-register", &callback); ,
I don't completely understand what you're aiming for here. In the
example that you gave before, PROC doesn't accept any arguments, so
how can HB pass hbfile to it?
I'm sorry, I guess I didn't fully explain my self.
hbfile is not passed to PROC but to hb-register, which accepts 3
arguments.
Right before parsing the user's Scheme file, HB defines symbols
"hb-register" (a function) and "*hb-file*" (that must always be passed
as the first parameter to "hb-register").
The procedure "hb-register" thus takes as arguments a pointer to the
structure describing the file (this is "*hb-file*" in its particular
smob), a name of a function and the function to associate to that name.
As you say, PROC doesn't accept any arguments (I guess you found out
this by reading the example file in my original mail about the
benchmark). However, the user is not supposed to call "hb-register"
from the procedures he registers calling "hb-register".
What I mean to do is have HB automatically pass a void pointer to the
callback function that I assign to "hb-register" just like most
libraries that let the user register a callback function, let him
register a void pointer to be passed to it when it gets executed.
Is it anything like the example discussed in the `Callback Closure'
node of the manual?
No. :/
The manual says:
In languages without the ability to create functions dynamically,
this problem is usually solved by passing a `user_data' parameter on
the registration call, and including the value of this parameter as
one of the parameters on the callback function. Here is an example
of declarations using this solution in C:
typedef void (event_handler_t) (int event_type,
void *user_data);
void register_callback (int event_type,
event_handler_t *handler,
void *user_data);
What I need to do is simply register my callback function (hb-register,
which is registered from C code, not from Guile code) specifing that
Guile must always pass it my user_data pointer in addition the the
parameteres passed from the Guile code.
I currently solve this in an ugly way: making a smob for user_data and
forcing the programmer to always pass it as the first parameter to the
hb-register function.
I guess this must be something pretty trivial like "use
gh_new_procedure3_0_data instead" but I can't find the function I need.
I hope I made my self clear this time and I thank you for your input. :)
Alejo.
http://bachue.com/alejo
--
The mere formulation of a problem is far more essential than its solution.
-- Albert Einstein.
$0='!/sfldbi!yjoV0msfQ!sfiupob!utvK'x44;print map{("\e[7m \e[0m",chr ord
(chop$0)-1)[$_].("\n")[++$i%77]}split//,unpack'B*',pack'H*',($F='F'x19).
"F0F3E0607879CC1E0F0F339F3FF399C666733333CCF87F99E6133999999E67CFFCCF3".
"219CC1CCC033E7E660198CCE4E66798303873CCE60F3387$F"#Don't you love Perl?
pgpDXQVXFmSa4.pgp
Description: PGP signature
- Benchmarks of guile-www against HB's Guile module., Alejandro Forero Cuervo, 2002/02/11
- Re: Benchmarks of guile-www against HB's Guile module., Thien-Thi Nguyen, 2002/02/12
- Re: Benchmarks of guile-www against HB's Guile module., Alejandro Forero Cuervo, 2002/02/12
- Re: Benchmarks of guile-www against HB's Guile module., Thien-Thi Nguyen, 2002/02/12
- Re: Benchmarks of guile-www against HB's Guile module., Alejandro Forero Cuervo, 2002/02/13
- Re: Benchmarks of guile-www against HB's Guile module., Thien-Thi Nguyen, 2002/02/13
- Re: Benchmarks of guile-www against HB's Guile module., Alejandro Forero Cuervo, 2002/02/13
- Re: Benchmarks of guile-www against HB's Guile module., Thien-Thi Nguyen, 2002/02/14
- Re: Benchmarks of guile-www against HB's Guile module., Neil Jerram, 2002/02/12
- Re: Benchmarks of guile-www against HB's Guile module.,
Alejandro Forero Cuervo <=
- Re: Benchmarks of guile-www against HB's Guile module., Neil Jerram, 2002/02/13
- Re: Benchmarks of guile-www against HB's Guile module., Alejandro Forero Cuervo, 2002/02/13
- Re: Benchmarks of guile-www against HB's Guile module., Neil Jerram, 2002/02/15