C/Ruby data type conversion functions and macros

上一篇 / 下一篇  2007-08-23 14:24:24 / 个人分类:Ruby

C/Ruby data type conversion functions and macros
C Data Types to Ruby Objects:
INT2NUM(int) → Fixnum or Bignum
INT2FIX(int) → Fixnum (faster)
LONG2NUM(long → Fixnum or Bignum
LONG2FIX(int) → Fixnum (faster)
LL2NUM(long long) → Fixnum or Bignum (if native
system supports long long type)
ULL2NUM(long long) → Fixnum or Bignum (if native
system supports long long type)
CHR2FIX(char) → Fixnum
rb_str_new2(char *) → String
rb_float_new(double) → Float
Ruby Objects to C Data Types:
int NUM2INT(Numeric) (Includes type check)
int FIX2INT(Fixnum) (Faster)
unsigned int NUM2UINT(Numeric) (Includes type check)
unsigned int FIX2UINT(Fixnum) (Includes type check)
long NUM2LONG(Numeric) (Includes type check)
long FIX2LONG(Fixnum) (Faster)
unsigned long NUM2ULONG(Numeric) (Includes type check)
char NUM2CHR(Numeric or String) (Includes type check)
double NUM2DBL(Numeric)
see text for strings. . .
Ruby strings, therefore, is to do what the interpreter does and use both a pointer and a
length. In fact, Ruby String objects are actually references to an RString structure,
and the RString structure contains both a length and a pointer field. You can access
the structure via the RSTRING macro.
VALUE str;
RSTRING(str)>
len ! length of the Ruby string
RSTRING(str)>
ptr ! pointer to string storage


TAG: extension ruby

 

评分:0

我来说两句

显示全部

:loveliness: :handshake :victory: :funk: :time: :kiss: :call: :hug: :lol :'( :Q :L ;P :$ :P :o :@ :D :( :)

我的栏目

日历

« 2009-01-08  
    123
45678910
11121314151617
18192021222324
25262728293031

我的存档

数据统计

  • 访问量: 46
  • 日志数: 1
  • 建立时间: 2007-08-23
  • 更新时间: 2007-08-23

RSS订阅

Open Toolbar