swig/Lib/ruby/rubyhead.swg
Logan Johnson 2de683e019 Replaced all occurrences of the deprecated STR2CSTR() in Ruby code with
the new StringValuePtr().


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@4682 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2003-04-15 17:14:18 +00:00

82 lines
2.3 KiB
Text

/* ruby.swg */
/* Implementation : RUBY */
#define SWIGRUBY 1
#include "ruby.h"
#define NUM2USHRT(n) (\
(0 <= NUM2UINT(n) && NUM2UINT(n) <= USHRT_MAX)\
? (unsigned short) NUM2UINT(n) \
: (rb_raise(rb_eArgError, "integer %d out of range of `unsigned short'",\
NUM2UINT(n)), (short)0)\
)
#define NUM2SHRT(n) (\
(SHRT_MIN <= NUM2INT(n) && NUM2INT(n) <= SHRT_MAX)\
? (short)NUM2INT(n)\
: (rb_raise(rb_eArgError, "integer %d out of range of `short'",\
NUM2INT(n)), (short)0)\
)
/* Ruby 1.7 defines NUM2LL(), LL2NUM() and ULL2NUM() macros */
#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
/* Ruby 1.7 doesn't (yet) define NUM2ULL() */
#ifndef NUM2ULL
#ifdef HAVE_LONG_LONG
#define NUM2ULL(x) rb_num2ull((x))
#else
#define NUM2ULL(x) NUM2ULONG(x)
#endif
#endif
/* Ruby 1.8 deprecates STR2CSTR() in favor of StringValuePtr() */
#ifndef StringValuePtr
#define StringValuePtr(x) STR2CSTR((x))
#endif
/*
* Need to be very careful about how these macros are defined, especially
* when compiling C++ code or C code with an ANSI C compiler.
*
* VALUEFUNC(f) is a macro used to typecast a C function that implements
* a Ruby method so that it can be passed as an argument to API functions
* like rb_define_method() and rb_define_singleton_method().
*
* VOIDFUNC(f) is a macro used to typecast a C function that implements
* either the "mark" or "free" stuff for a Ruby Data object, so that it
* can be passed as an argument to API functions like Data_Wrap_Struct()
* and Data_Make_Struct().
*/
#ifdef __cplusplus
# ifndef RUBY_METHOD_FUNC /* These definitions should work for Ruby 1.4.6 */
# define VALUEFUNC(f) ((VALUE (*)()) f)
# define VOIDFUNC(f) ((void (*)()) f)
# else
# ifndef ANYARGS /* These definitions should work for Ruby 1.6 */
# define VALUEFUNC(f) ((VALUE (*)()) f)
# define VOIDFUNC(f) ((RUBY_DATA_FUNC) f)
# else /* These definitions should work for Ruby 1.7 */
# 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
typedef struct {
VALUE klass;
void (*mark)(void *);
void (*destroy)(void *);
} swig_class;