1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

use STR2CSTR

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@46 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 1998-01-22 10:07:53 +00:00
parent 7a249d7acc
commit 2f99f3b41a
3 changed files with 14 additions and 0 deletions

View file

@ -1,5 +1,7 @@
Thu Jan 22 00:37:47 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
* 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.

View file

@ -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;

3
ruby.h
View file

@ -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) {\