1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
#ifndef RUBY_COMPAT_H
#define RUBY_COMPAT_H
/*
* Rules for better ruby C extensions:
*
* Never use the R<TYPE> macros directly, always use R<TYPE>_<FIELD>
*
* Never compare with RBASIC(obj)->klass, always use
* rb_obj_is_instance_of()
*
* Never use RHASH(obj)->tbl or RHASH_TBL().
*
*/
// Array
#ifndef RARRAY_PTR
#define RARRAY_PTR(obj) RARRAY(obj)->ptr
#endif
#ifndef RARRAY_LEN
#define RARRAY_LEN(obj) RARRAY(obj)->len
#endif
// String
#ifndef RSTRING_PTR
#define RSTRING_PTR(obj) RSTRING(obj)->ptr
#endif
#ifndef RSTRING_LEN
#define RSTRING_LEN(obj) RSTRING(obj)->len
#endif
#ifndef rb_str_ptr
#define rb_str_ptr(str) RSTRING_PTR(str)
#endif
#ifndef rb_str_ptr_readonly
#define rb_str_ptr_readonly(str) RSTRING_PTR(str)
#endif
#ifndef rb_str_flush
#define rb_str_flush(str)
#endif
#ifndef rb_str_update
#define rb_str_update(str)
#endif
#ifndef rb_str_len
#define rb_str_len(str) RSTRING_LEN(str)
#endif
#endif
|