Rb_define_methods

[email protected]$G$9!#e(B

e$B!!e(BCe$B$G5-=R$7$?%a%=%C%I$NEPO?$r$^$H$a$F9T$($J$$$G$7$g$&$+!#e(B

e$B!!6qBNE*$K$O!":#e(B

void
Init_foo(void)
{
VALUE klass = …;
rb_define_method(klass, “foo”, foo_func, 0);
rb_define_method(klass, “bar”, bar_func, 1);
rb_define_method(klass, “baz”, baz_func, -1);
}

e$B$H$"$k$N$r!"e(B

typedef struct {
char name;
VALUE (
)(ANYARGS);
int argsize;
} rb_method_definition_info_t;

void
Init_foo(void)
{
VALUE klass = …;
const rb_method_definition_info_t[] = {
{“foo”, foo_func, 0},
{“bar”, bar_func, 1},
{“baz”, baz_func, -1},
};

rb_define_methods(klass, method_info_table,
sizeof(method_info_table)/
sizeof(rb_method_definition_info_t));
}

e$B$N$h$&$K=q$/$?$a$N7?e(B rb_method_definition_info_t e$B$He(B
rb_define_methods
API e$B$NDI2C$G$9!#e(B

e$B!!%a%j%C%H$O!"e(B

a) rb_define_method e$B$rJB$Y$k$h$j$b!“0lMw$K$J$C$FFI$$d$9$$e(B
b) e$B$^$?!"%a%=%C%I$NDI2C:o=|$bMF0W$K$J$k!J$+$b!Ke(B
c) Ce$B%a%=%C%IDI2C$4$H$K%a%=%C%I%-%c%C%7%e$r%/%j%"$7$F$$$k$,!"e(B
e$B$3$l$OL5BL$J$N$G;
$a$?$$e(B
d) e$B%a%=%C%IDI2C$N$?$a$K2?$+$r%m%C%/$9$kI,MW$,!”$3$l$+$i$"$ke(B
e$B$+$b$7$l$J$$$,!"$=$l$,0l2U=j$G:Q$`$h$&$K$J$ke(B

e$B!!$^$!!"$$$D$b$N$h$&$K!";d$NK>$_$Oe(B c, d
e$B$J$N$G$9$,!"$$$+$,$G$7$g$&$+!#e(B

e$B!!8!F$;v9`$H$7$F$O!“e(Brb_method_definition_info_t e$B$Oe(B
visibility e$B$r4^$a$F$be(B
e$B$$$$$h$&$J5$$,$9$k!”$H$$$&$H$3$m$G$7$g$&$+!#$[$H$s$I$Oe(B public
[email protected]$+e(B
e$B$i!"MW$i$J$$$H;W$$$^$9$,!#e(B

e$BKNIt$G$9!#e(B

SASADA Koichi wrote:

typedef struct {
char name;
VALUE (
)(ANYARGS);
int argsize;
} rb_method_definition_info_t;

e$B$3$l$r$d$k$/$i$$$J$ie(BANYARGSe$B$O$d$a$K$7$^$;$se(B?
e$B>/!9<B9T$,CY$$$3$H$h$j$be(Baritye$B$,0c$&$3$H$r%3%s%Q%$%i$,8!=P$G$-$J$$$3$H$Ne(B
e$B$[$&$,[email protected]$H;W$$$^$9!#$3$l$^$G$be(Brb_define_methode$B$^$o$j$Ge(Bprototype
mismatche$B7O$N%P%0$,$"$j$^$7$?$h$Me(B?e$B:[email protected][email protected]$^$G7Q>5$9e(B
e$B$kI,MW$O$J$$$O$:$G$9!#e(B

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:28876] Re: rb_define_methods”
on Wed, 28 Jun 2006 11:00:32 +0900, URABE Shyouhei
[email protected] writes:

|SASADA Koichi wrote:
|> typedef struct {
|> char name;
|> VALUE (
)(ANYARGS);
|> int argsize;
|> } rb_method_definition_info_t;
|>
|e$B$3$l$r$d$k$/$i$$$J$ie(BANYARGSe$B$O$d$a$K$7$^$;$se(B?
|e$B>/!9<B9T$,CY$$$3$H$h$j$be(Baritye$B$,0c$&$3$H$r%3%s%Q%$%i$,8!=P$G$-$J$$$3$H$Ne(B
|e$B$[$&$,[email protected]$H;W$$$^$9!#$3$l$^$G$be(Brb_define_methode$B$^$o$j$Ge(Bprototype
|mismatche$B7O$N%P%0$,$"$j$^$7$?$h$Me(B?e$B:[email protected][email protected]$^$G7Q>5$9e(B
|e$B$kI,MW$O$J$$$O$:$G$9!#e(B

e$B?7$7$$e(BAPIe$B$rDI2C$9$k$K$"$?$C$Fe(BANYARGSe$B$r$d$a$k$H$9$k$H!"$=$N>le(B
e$B9g$OA4Ite(Bargc, argve$B$G<u$1$k$s$G$9$+$M!#$=$l$O$=$l$G$"$s$^$j$&e(B
e$B$l$7$/$J$$$G$9$h$M$(!#$H$O$$$(!"0z?t%Q%?!<%s$4$H$K0c$&e(BAPIe$B$He(B
e$B$$$&$N$bHr$1$?$$!#e(B

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:28875] rb_define_methods”
on Wed, 28 Jun 2006 10:21:50 +0900, SASADA Koichi [email protected]
writes:

|e$B!!e(BCe$B$G5-=R$7$?%a%=%C%I$NEPO?$r$^$H$a$F9T$($J$$$G$7$g$&$+!#e(B
|
|e$B!!6qBNE*$K$O!":#e(B
|
|void
|Init_foo(void)
|{
| VALUE klass = …;
| rb_define_method(klass, “foo”, foo_func, 0);
| rb_define_method(klass, “bar”, bar_func, 1);
| rb_define_method(klass, “baz”, baz_func, -1);
|}
|
|e$B$H$"$k$N$r!"e(B
|
|typedef struct {
| char name;
| VALUE (
)(ANYARGS);
| int argsize;
|} rb_method_definition_info_t;
|
|void
|Init_foo(void)
|{
| VALUE klass = …;
| const rb_method_definition_info_t[] = {
| {“foo”, foo_func, 0},
| {“bar”, bar_func, 1},
| {“baz”, baz_func, -1},
| };
|
| rb_define_methods(klass, method_info_table,
| sizeof(method_info_table)/
| sizeof(rb_method_definition_info_t));
|}
|
|e$B$N$h$&$K=q$/$?$a$N7?e(B rb_method_definition_info_t e$B$He(B rb_define_methods
|API e$B$NDI2C$G$9!#e(B

e$B$&!<$`!#e(B

|e$B!!%a%j%C%H$O!“e(B
|
|a) rb_define_method e$B$rJB$Y$k$h$j$b!“0lMw$K$J$C$FFI$$d$9$$e(B
|b) e$B$^$?!"%a%=%C%I$NDI2C:o=|$bMF0W$K$J$k!J$+$b!Ke(B
|c) Ce$B%a%=%C%IDI2C$4$H$K%a%=%C%I%-%c%C%7%e$r%/%j%"$7$F$$$k$,!"e(B
| e$B$3$l$OL5BL$J$N$G;
$a$?$$e(B
|d) e$B%a%=%C%IDI2C$N$?$a$K2?$+$r%m%C%/$9$kI,MW$,!”$3$l$+$i$”$ke(B
| e$B$+$b$7$l$J$$$,!"$=$l$,0l2U=j$G:Q$`$h$&$K$J$ke(B

e$B%G%a%j%C%H$Oe(B

(1) [email protected]$i$+$K?7$7$$e(BAPIe$B$r;H$C$?J}$,FI$$K$/$$e(B
(2) b)e$B$N%a%j%C%H$O$J$5$=$&e(B
(3) c)e$B$Oe(Brb_define_methode$B$O%-%c%C%7%e$r%/%j%"$7$J$$J}8~$Ge(B
(4) d)e$B$Oe(BInit
*e$BA4BN$G%m%C%/$7$?$[$&$,$h$$$h$&$J5$$,e(B

e$B$"$s$^$j>h$j5$$8$c$J$$$G$9!#e(B

In article [email protected],
Yukihiro M. [email protected] writes:

e$B?7$7$$e(BAPIe$B$rDI2C$9$k$K$"$?$C$Fe(BANYARGSe$B$r$d$a$k$H$9$k$H!"$=$N>le(B
e$B9g$OA4Ite(Bargc, argve$B$G<u$1$k$s$G$9$+$M!#$=$l$O$=$l$G$"$s$^$j$&e(B
e$B$l$7$/$J$$$G$9$h$M$(!#$H$O$$$(!"0z?t%Q%?!<%s$4$H$K0c$&e(BAPIe$B$He(B
e$B$$$&$N$bHr$1$?$$!#e(B

#define rb_define_method(mod, meth, fun, argc)
rb_define_method_ ## argc (mod, meth, fun)

void rb_define_method_0(VALUE klass, const char *name, VALUE
(*func)(void))
void rb_define_method_1(VALUE klass, const char *name, VALUE
(*func)(VALUE))
void rb_define_method_2(VALUE klass, const char *name, VALUE
(*func)(VALUE, VALUE))
void rb_define_method_3(VALUE klass, const char *name, VALUE
(*func)(VALUE, VALUE, VALUE))

void rb_define_method_15(VALUE klass, const char *name, VALUE (*func)(
VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE,
VALUE, VALUE, VALUE, VALUE, VALUE))

e$B$H$$$&$h$&$K$7$?$i$$$$$N$G$O$J$$$+$H9M$($?$3$H$,$"$j$^$9!#e(B
(15 e$B$^$G$J$N$O8F$VB&$Ne(B call_cfunc e$B$,e(B 15e$B$^[email protected]$+$i$G$9e(B)

[email protected]!“e(Bargc e$B$,e(B -1, -2
e$B$N>l9g$K$OBP1~$G$-$J$$$N$G!”$=$l$OJL$Ne(B
e$B4X?t$KJ,$1$kI,MW$,$"$j$^$9!#e(B
e$B$?$H$($P!"e(Brb_define_method_values e$B$He(B rb_define_method_ary
e$B$He(B
e$B$+!#e(B

e$BKNIt$G$9!#e(B

Tanaka A. wrote:

void rb_define_method_ARG_VALUES(VALUE klass, const char *name, VALUE (*func)(int, VALUE *, VALUE))
void rb_define_method_ARG_ARRAY(VALUE klass, const char *name, VALUE (*func)(VALUE, VALUE))
e$B$H$$$&$N$r$D$/$C$Fe(B
rb_define_method(mod, name, fun, ARG_VALUES)
rb_define_method(mod, name, fun, ARG_ARRAY)
e$B$H=q$/$h$&$K$9$l$P!"%f!<%6$,;H$&e(B API e$B$OA}$d$5$J$/$F$b$$$$$+$J!#e(B

#define rb_define_method(m, n, f, c) rb_define_method_ ## c(m, n, f)

e$B$C$F$3$H$G$9$+e(B?

In article [email protected],
Tanaka A. [email protected] writes:

[email protected]!“e(Bargc e$B$,e(B -1, -2 e$B$N>l9g$K$OBP1~$G$-$J$$$N$G!”$=$l$OJL$Ne(B
e$B4X?t$KJ,$1$kI,MW$,$"$j$^$9!#e(B
e$B$?$H$($P!"e(Brb_define_method_values e$B$He(B rb_define_method_ary e$B$He(B
e$B$+!#e(B

e$B$"!":#;W$$IU$-$^$7$?$,!“e(B
void rb_define_method_ARG_VALUES(VALUE klass, const char *name, VALUE
(*func)(int, VALUE *, VALUE))
void rb_define_method_ARG_ARRAY(VALUE klass, const char *name, VALUE
(*func)(VALUE, VALUE))
e$B$H$$$&$N$r$D$/$C$Fe(B
rb_define_method(mod, name, fun, ARG_VALUES)
rb_define_method(mod, name, fun, ARG_ARRAY)
e$B$H=q$/$h$&$K$9$l$P!”%f!<%6$,;H$&e(B API
e$B$OA}$d$5$J$/$F$b$$$$$+$J!#e(B

e$B$"$H!"e(B1.8 e$B$Ge(B
#define VALS_ARG -1
#define ARY_ARG -2
e$B$H$7$F$*$1$P!"e(B1.8 e$B$KA0J}[email protected]$b$D$1$i$l$k$+$i$3$l$J$i:#<BAue(B
e$B$7$F$b$$$$$+$b$7$l$^$;$s!#e(B

[email protected]$G$9!#e(B

In mail “[ruby-dev:28875] rb_define_methods”
SASADA Koichi [email protected] wrote:

[email protected]$G$9!#e(B

e$B!!e(BCe$B$G5-=R$7$?%a%=%C%I$NEPO?$r$^$H$a$F9T$($J$$$G$7$g$&$+!#e(B

e$B!!%a%j%C%H$O!"e(B

a) rb_define_method e$B$rJB$Y$k$h$j$b!"0lMw$K$J$C$FFI$_$d$9$$e(B

ReFe (e$B$H!"$?$V$se(B ri e$B$be(B) e$B$G$Oe(B rb_define_method
[email protected],I=8=$Ge(B
e$B$R$C$+$1$F%a%=%C%I$H4X?t$N4XO"IU$1$r8!=P$7$F$$$^$9!#%F!<%V%k$G$be(B
[email protected]$G$-$J$$$3$H$O$J$$$s$G$9$,!"$$$^$N7A<0$N$[$&$,[email protected]$,3Z$J$N$G!"e(B
rb_define_methods e$B$K$O>C6KE*$KH?BP$7$F$*$-$^$9!#e(B

In article [email protected],
URABE Shyouhei [email protected] writes:

#define rb_define_method(m, n, f, c) rb_define_method_ ## c(m, n, f)

e$B$C$F$3$H$G$9$+e(B?

e$B$O$$!#e(B[ruby-dev:28878] e$B$NKAF,$Ke(B

#define rb_define_method(mod, meth, fun, argc)
rb_define_method_ ## argc (mod, meth, fun)

e$B$H=q$$$?DL$j$G$9!#e(B

e$B$"$H!"e(B[ruby-dev:28882] e$B$N:G8e$Ne(B
#define VALS_ARG -1
#define ARY_ARG -2
e$B$Oe(B
#define ARG_VALUES -1
#define ARG_ARRAY -2
e$B$N$^$A$,$$$G$9!#e(B

[email protected]$G$9!#e(B

Yukihiro M. wrote:

(1) [email protected]$i$+$K?7$7$$e(BAPIe$B$r;H$C$?J}$,FI$_$K$/$$e(B

e$B!!$(!<!#e(B

(3) c)e$B$Oe(Brb_define_methode$B$O%-%c%C%7%e$r%/%j%"$7$J$$J}8~$Ge(B
(4) d)e$B$Oe(BInit_*e$BA4BN$G%m%C%/$7$?$[$&$,$h$$$h$&$J5$$,e(B

e$B!!%3!<%k%P%C%/7O$N%a%=%C%I$r9M$($k$HFq$7$=$&$G$9!#e(Bmethod_added
e$B$H$+!"e(B
inherited e$B$H$+!#e(B

e$B!!e(Bdefine_methods e$B$G$b!“e(Bmethod_added
e$B$r$7$?$H$-$K$I$&[email protected]$m$&!”$H$+;We(B
e$B$&$s$G$9$,!"$^$!:G8e$K$^$H$a$F8F$V$H$$$&<j$,;H$($=$&$G$9!#e(B

e$B$3$s$K$A$O!"$J$+$`$ie(B(e$B$&e(B)e$B$G$9!#e(B

In message “[ruby-dev:28875] rb_define_methods”
on Jun.28,2006 10:21:50, [email protected] wrote:
| a) rb_define_method e$B$rJB$Y$k$h$j$b!"0lMw$K$J$C$FFI$_$d$9$$e(B

e$B$I$&$7$F$b<g4Q$,F~$k$N$G!"$$$A$,$$$K$I$A$i$,[email protected](B
e$B$($J$$$H;W$$$^$9!#e(B

e$B$G$9$,!“Nc$($Pe(B object.c e$B$Ne(B Init_Object()
e$B$N$h$&$K0l$D$N4X?t$Ne(B
e$BCf$GJ#?t$N%/%i%9$N%a%=%C%I$rDj5A$7$F$$$k>l9g!”%F!<%V%k$NDj5Ae(B
e$B$He(B rb_define_mothods()
e$B$N8F$S=P$7$,N%$l$?$H$3$m$K$J$C$F$7$^$&e(B
e$B$N$G!"$=$l$O$"$^$j$h$$%9%?%$%k$G$O$J$$$N$G$O$J$$$+$H46$8$^$9!#e(B

… e$B0l$D$N4X?tCf$GJ#?t$N%/%i%9$N%a%=%C%I$rDj5A$7$F$k$3$H$,$he(B
e$B$/$J$$%9%?%$%k$G!"$=$l$rJ,[email protected]$H$$$&;k3PE*05NO$,$+$+$Ce(B
e$B$F$`$7$m$h$+$C$?$j$7$Fe(B…

e$B$=$l$G$O!#e(B

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:28903] Re: rb_define_methods”
on Thu, 29 Jun 2006 20:05:50 +0900, SASADA Koichi [email protected]
writes:

|Yukihiro M. wrote:
|> (1) [email protected]$i$+$K?7$7$$e(BAPIe$B$r;H$C$?J}$,FI$_$K$/$$e(B
|
|e$B!!$(!<!#e(B

e$B;v<B$G$9$+$i!#e(BPythone$B$N%/%i%9Dj5A$H$+$o$1$,$o$+$j$^$;$s!#e(B

|> (3) c)e$B$Oe(Brb_define_methode$B$O%-%c%C%7%e$r%/%j%"$7$J$$J}8~$Ge(B
|> (4) d)e$B$Oe(BInit_*e$BA4BN$G%m%C%/$7$?$[$&$,$h$$$h$&$J5$$,e(B
|
|e$B!!%3!<%k%P%C%/7O$N%a%=%C%I$r9M$($k$HFq$7$=$&$G$9!#e(Bmethod_added e$B$H$+!"e(B
|inherited e$B$H$+!#e(B

e$B$G$b!"$3$l$i$rDj5A$7$F$$$-$J$j8F$P$l$k$h$&$J%1!<%9$O$a$C$?$Ke(B
e$B$J$$$H;W$$$^$9!#$$$$$s$8$c$J$$$+$J$"!#e(B

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs