From: Oliver Date: 2007-07-17T21:34:00+09:00 Subject: Re: ruby extension help thanks for reply. even if I could put a constraint on how Ruby user supply call back function: say, all arguments must go into an array. And on the C wrapper side, I can extract those argument out - then what? I can't re-structure the C function pointer struct and just call "register(&mytabs)" ... Oliver On 7/17/07, Nobuyoshi Nakada wrote: > Hi, > > At Tue, 17 Jul 2007 11:55:36 +0900, > Oliver wrote in [ruby-core:11724]: > > The C library I am working on has a so-called dynamic command dispatch > > structure, it is basically a hook meant for accommodating a set of > > user-provided call back functions. It is defined as follows: > > > > /* command dispatch structure */ > > typedef int (*proxy_cmd)(int trans_id, int nargs, char **args); > > How would char **args be supplied? > > > === C usage > > > > Under normal case, a C library user will supply the following > > structure and make use of above structure. > > > > int my_init(server,port) { ... } > > int my_connect( ... ) { ...} > > > > /* put all function pointer into array */ > > proxy_cmd cmds[] = { > > my_init, > > my_connect, > > my_finish, > > ... > > }; > > Seems impossible to pass callback arguments per commands, > right? > > If so, it is quite awkward. > > -- > Nobu Nakada > > -- Oliver