diff --git a/ChangeLog b/ChangeLog index e06efbe692..7fb0b71967 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ Thu Jan 22 00:37:47 1998 Yukihiro Matsumoto + * ruby.h (STR2CSTR): new macro to retrieve char*. + * class.c (rb_define_method): `initialize' should always be private, even if it defined by C extensions. diff --git a/object.c b/object.c index faf6983526..be551bd82a 100644 --- a/object.c +++ b/object.c @@ -721,6 +721,15 @@ f_string(obj, arg) return rb_funcall(arg, rb_intern("to_s"), 0); } +char* +str2cstr(str) + VALUE str; +{ + if (NIL_P(str)) return NULL; + Check_Type(str, T_STRING); + return RSTRING(str)->ptr; +} + VALUE rb_String(val) VALUE val; diff --git a/ruby.h b/ruby.h index 0c1d01c702..a3e3f47dc9 100644 --- a/ruby.h +++ b/ruby.h @@ -165,6 +165,9 @@ int num2int _((VALUE)); double num2dbl _((VALUE)); #define NUM2DBL(x) num2dbl((VALUE)(x)) +char *str2cstr _((VALUE)); +#define STR2CSTR(x) str2cstr((VALUE)(x)) + VALUE rb_newobj _((void)); #define NEWOBJ(obj,type) type *obj = (type*)rb_newobj() #define OBJSETUP(obj,c,t) {\