123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- #include <ruby.h>
- #ifdef rb_intern
- # undef rb_intern
- #endif
- #ifdef write
- # undef write
- #endif
- #ifdef read
- # undef read
- #endif
- #ifdef bind
- # undef bind
- #endif
- #ifdef close
- # undef close
- #endif
- #ifdef connect
- # undef connect
- #endif
- #ifndef NUM2LL
- #define NUM2LL(x) NUM2LONG((x))
- #endif
- #ifndef LL2NUM
- #define LL2NUM(x) INT2NUM((long) (x))
- #endif
- #ifndef ULL2NUM
- #define ULL2NUM(x) UINT2NUM((unsigned long) (x))
- #endif
- #ifndef NUM2ULL
- #ifdef HAVE_LONG_LONG
- #define NUM2ULL(x) rb_num2ull((x))
- #else
- #define NUM2ULL(x) NUM2ULONG(x)
- #endif
- #endif
- #ifndef RSTRING_LEN
- # define RSTRING_LEN(x) RSTRING(x)->len
- #endif
- #ifndef RSTRING_PTR
- # define RSTRING_PTR(x) RSTRING(x)->ptr
- #endif
- #ifndef RSTRING_END
- # define RSTRING_END(x) (RSTRING_PTR(x) + RSTRING_LEN(x))
- #endif
- #ifndef RARRAY_LEN
- # define RARRAY_LEN(x) RARRAY(x)->len
- #endif
- #ifndef RARRAY_PTR
- # define RARRAY_PTR(x) RARRAY(x)->ptr
- #endif
- #ifndef RFLOAT_VALUE
- # define RFLOAT_VALUE(x) RFLOAT(x)->value
- #endif
- #ifndef DOUBLE2NUM
- # define DOUBLE2NUM(x) rb_float_new(x)
- #endif
- #ifndef RHASH_TBL
- # define RHASH_TBL(x) (RHASH(x)->tbl)
- #endif
- #ifndef RHASH_ITER_LEV
- # define RHASH_ITER_LEV(x) (RHASH(x)->iter_lev)
- #endif
- #ifndef RHASH_IFNONE
- # define RHASH_IFNONE(x) (RHASH(x)->ifnone)
- #endif
- #ifndef RHASH_SIZE
- # define RHASH_SIZE(x) (RHASH(x)->tbl->num_entries)
- #endif
- #ifndef RHASH_EMPTY_P
- # define RHASH_EMPTY_P(x) (RHASH_SIZE(x) == 0)
- #endif
- #ifndef RSTRUCT_LEN
- # define RSTRUCT_LEN(x) RSTRUCT(x)->len
- #endif
- #ifndef RSTRUCT_PTR
- # define RSTRUCT_PTR(x) RSTRUCT(x)->ptr
- #endif
-
- #ifdef __cplusplus
- # ifndef RUBY_METHOD_FUNC
- # define PROTECTFUNC(f) ((VALUE (*)()) f)
- # define VALUEFUNC(f) ((VALUE (*)()) f)
- # define VOIDFUNC(f) ((void (*)()) f)
- # else
- # ifndef ANYARGS
- # define PROTECTFUNC(f) ((VALUE (*)()) f)
- # define VALUEFUNC(f) ((VALUE (*)()) f)
- # define VOIDFUNC(f) ((RUBY_DATA_FUNC) f)
- # else
- # define PROTECTFUNC(f) ((VALUE (*)(VALUE)) f)
- # define VALUEFUNC(f) ((VALUE (*)(ANYARGS)) f)
- # define VOIDFUNC(f) ((RUBY_DATA_FUNC) f)
- # endif
- # endif
- #else
- # define VALUEFUNC(f) (f)
- # define VOIDFUNC(f) (f)
- #endif
- #ifndef RB_STRING_VALUE
- #define RB_STRING_VALUE(s) (TYPE(s) == T_STRING ? (s) : (*(volatile VALUE *)&(s) = rb_str_to_str(s)))
- #endif
- #ifndef StringValue
- #define StringValue(s) RB_STRING_VALUE(s)
- #endif
- #ifndef StringValuePtr
- #define StringValuePtr(s) RSTRING_PTR(RB_STRING_VALUE(s))
- #endif
- #ifndef StringValueLen
- #define StringValueLen(s) RSTRING_LEN(RB_STRING_VALUE(s))
- #endif
- #ifndef SafeStringValue
- #define SafeStringValue(v) do {\
- StringValue(v)
- rb_check_safe_str(v)
- } while (0)
- #endif
- #ifndef HAVE_RB_DEFINE_ALLOC_FUNC
- #define rb_define_alloc_func(klass, func) rb_define_singleton_method((klass), "new", VALUEFUNC((func)), -1)
- #define rb_undef_alloc_func(klass) rb_undef_method(CLASS_OF((klass)), "new")
- #endif
- static VALUE _mSWIG = Qnil
|