Implementing method_missing in C and blocks

J

John Lam

------=_Part_3412_11152901.1127532352184
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

I'm implementing a CLR <-> Ruby bridge using Managed C++ and the Whidbey
(.NET 2.0 runtime).
There are a lot of novel things in my bridge since I completely avoid usin=
g
Reflection to invoke methods. Instead, I use the lightweight code generatio=
n
(LCG) feature the Whidbey runtime to emit IL instructions on the fly that
form "shims" that call the appropriate CLR object methods.
I'd like to provide an elegant implementation of delegate shimming as well=
 
N

nobu.nokada

Hi,

At Sat, 24 Sep 2005 12:25:55 +0900,
John Lam wrote in [ruby-talk:157383]:
Now, you could provide a specific implementation of method_missing to
"capture" the block in the parameter b, as in this example:
def method_missing(name, &b) ...

static VALUE
method_missing(int argc, VALUE *argv, VALUE self)
{
VALUE block = rb_block_given_p() ? rb_block_proc() : Qnil;
...
}
 
J

John Lam

------=_Part_4300_9997234.1127568462063
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

Thanks Nobu! That's exactly what I needed.
-John
static VALUE
method_missing(int argc, VALUE *argv, VALUE self)
{
VALUE block =3D rb_block_given_p() ? rb_block_proc() : Qnil;
...
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top