Open gnuhub opened 10 years ago
VALUE
and object structhttps://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L88
typedef unsigned long VALUE;
VALUE v1;
printf("%d\n",sizeof(v1));
8
Hello Ruby from C!
https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L748
struct RBasic {
VALUE flags;
const VALUE klass;
}
VALUE flags;
struct type [0,71]
https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L442
enum ruby_value_type {
RUBY_T_NONE = 0x00,
RUBY_T_OBJECT = 0x01,
RUBY_T_CLASS = 0x02,
RUBY_T_MODULE = 0x03,
RUBY_T_FLOAT = 0x04,
RUBY_T_STRING = 0x05,
RUBY_T_REGEXP = 0x06,
RUBY_T_ARRAY = 0x07,
RUBY_T_HASH = 0x08,
RUBY_T_STRUCT = 0x09,
RUBY_T_BIGNUM = 0x0a,
RUBY_T_FILE = 0x0b,
RUBY_T_DATA = 0x0c,
RUBY_T_MATCH = 0x0d,
RUBY_T_COMPLEX = 0x0e,
RUBY_T_RATIONAL = 0x0f,
RUBY_T_NIL = 0x11,
RUBY_T_TRUE = 0x12,
RUBY_T_FALSE = 0x13,
RUBY_T_SYMBOL = 0x14,
RUBY_T_FIXNUM = 0x15,
RUBY_T_UNDEF = 0x1b,
RUBY_T_NODE = 0x1c,
RUBY_T_ICLASS = 0x1d,
RUBY_T_ZOMBIE = 0x1e,
RUBY_T_MASK = 0x1f
};
#define T_NONE RUBY_T_NONE
#define T_NIL RUBY_T_NIL
#define T_OBJECT RUBY_T_OBJECT
#define T_CLASS RUBY_T_CLASS
#define T_ICLASS RUBY_T_ICLASS
#define T_MODULE RUBY_T_MODULE
#define T_FLOAT RUBY_T_FLOAT
#define T_STRING RUBY_T_STRING
#define T_REGEXP RUBY_T_REGEXP
#define T_ARRAY RUBY_T_ARRAY
#define T_HASH RUBY_T_HASH
#define T_STRUCT RUBY_T_STRUCT
#define T_BIGNUM RUBY_T_BIGNUM
#define T_FILE RUBY_T_FILE
#define T_FIXNUM RUBY_T_FIXNUM
#define T_TRUE RUBY_T_TRUE
#define T_FALSE RUBY_T_FALSE
#define T_DATA RUBY_T_DATA
#define T_MATCH RUBY_T_MATCH
#define T_SYMBOL RUBY_T_SYMBOL
#define T_RATIONAL RUBY_T_RATIONAL
#define T_COMPLEX RUBY_T_COMPLEX
#define T_UNDEF RUBY_T_UNDEF
#define T_NODE RUBY_T_NODE
#define T_ZOMBIE RUBY_T_ZOMBIE
#define T_MASK RUBY_T_MASK
1 | 2 | 3 | 4 |
---|---|---|---|
T_NONE | RUBY_T_NONE | 0x00 | 0 |
T_OBJECT | RUBY_T_OBJECT | 0x01 | 1 |
T_CLASS | RUBY_T_CLASS | 0x02 | 2 |
T_MODULE | RUBY_T_MODULE | 0x03 | 3 |
T_FLOAT | RUBY_T_FLOAT | 0x04 | 4 |
T_STRING | RUBY_T_STRING | 0x05 | 5 |
T_REGEXP | RUBY_T_REGEXP | 0x06 | 6 |
T_ARRAY | RUBY_T_ARRAY | 0x07 | 7 |
T_HASH | RUBY_T_HASH | 0x08 | 8 |
T_STRUCT | RUBY_T_STRUCT | 0x09 | 9 |
T_BIGNUM | RUBY_T_BIGNUM | 0x0a | 10 |
T_FILE | RUBY_T_FILE | 0x0b | 11 |
T_DATA | RUBY_T_DATA | 0x0c | 12 |
T_MATCH | RUBY_T_MATCH | 0x0d | 13 |
T_COMPLEX | RUBY_T_COMPLEX | 0x0e | 14 |
T_RATIONAL | RUBY_T_RATIONAL | 0x0f | 15 |
T_NIL | RUBY_T_NIL | 0x11 | 16 |
T_TRUE | RUBY_T_TRUE | 0x12 | 17 |
T_FALSE | RUBY_T_FALSE | 0x13 | 18 |
T_SYMBOL | RUBY_T_SYMBOL | 0x14 | 19 |
T_FIXNUM | RUBY_T_FIXNUM | 0x15 | 20 |
T_UNDEF | RUBY_T_UNDEF | 0x1b | 27 |
T_NODE | RUBY_T_NODE | 0x1c | 28 |
T_ICLASS | RUBY_T_ICLASS | 0x1d | 29 |
T_ZOMBIE | RUBY_T_ZOMBIE | 0x1e | 30 |
T_MASK | RUBY_T_MASK | 0x1f | 31 |
Ruby Hacking Guide