Hi,
The library I'm currently writing an OO interface for (libmono) has an
iteration construct that is used something like this:
MonoMethod m;
gpointer iter = NULL;
while ((m = mono_class_get_methods (klass, &iter))) {
// Do stuff with "m".
}
Ideally, I'd like to change this interface so that it can be used from
Pepsi something like this:
class whileTrueWithMethod: [ :method | "Do stuff with method". true. ]
implemented as:
MonoClass whileTrueWithMethod: methodBlock
[
| iter iterp |
"FIXME: For some reason v_iterp isn't available."
"{ v_iterp = (oop)&v_iter; }."
{ ((oop *)_state1)[2] = (oop)&v_iter; }.
[| method |
method := MonoMethod _new: (libmono mono_class_get_methods : _ptr : iterp);
and: (methodBlock value: method)] whileTrue.
]
Please let me know if there's a better (more idiomatic) way to do this
kind of iteration. I'd also like to fix the FIXME: the v_iterp symbol
isn't available to the C code maybe because it's captured by the block
closure.
I'm a little stuck as to how I could use this method from Jolt. It
looks like I should construct a callback with lambda, then convert it
to a BlockClosure, but I don't understand what all the arguments to
BlockClosure function_:arity_:outer:state:nlr_ should be.
[BTW, thanks, Ian, for the replies to my other questions. I'll just
go on implementing the libmono wrappers I need ad hoc until the great
C include file parser is done, and I'll go without variadic arguments
until I figure out enough about exactly how I want to use them.]
--
Michael FIG <[EMAIL PROTECTED]> //\
http://michael.fig.org/ \//
_______________________________________________
fonc mailing list
[email protected]
http://vpri.org/mailman/listinfo/fonc