2010-05-06 02:59:24 -04:00
|
|
|
#include <fiddle.h>
|
|
|
|
|
|
|
|
VALUE mFiddle;
|
|
|
|
|
2012-02-25 00:47:16 -05:00
|
|
|
#ifndef TYPE_SSIZE_T
|
|
|
|
# if SIZEOF_SIZE_T == SIZEOF_INT
|
|
|
|
# define TYPE_SSIZE_T TYPE_INT
|
|
|
|
# elif SIZEOF_SIZE_T == SIZEOF_LONG
|
|
|
|
# define TYPE_SSIZE_T TYPE_LONG
|
|
|
|
# elif defined HAVE_LONG_LONG && SIZEOF_SIZE_T == SIZEOF_LONG_LONG
|
|
|
|
# define TYPE_SSIZE_T TYPE_LONG_LONG
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
#define TYPE_SIZE_T (-1*SIGNEDNESS_OF_SIZE_T*TYPE_SSIZE_T)
|
|
|
|
|
|
|
|
#ifndef TYPE_PTRDIFF_T
|
|
|
|
# if SIZEOF_PTRDIFF_T == SIZEOF_INT
|
|
|
|
# define TYPE_PTRDIFF_T TYPE_INT
|
|
|
|
# elif SIZEOF_PTRDIFF_T == SIZEOF_LONG
|
|
|
|
# define TYPE_PTRDIFF_T TYPE_LONG
|
|
|
|
# elif defined HAVE_LONG_LONG && SIZEOF_PTRDIFF_T == SIZEOF_LONG_LONG
|
|
|
|
# define TYPE_PTRDIFF_T TYPE_LONG_LONG
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef TYPE_INTPTR_T
|
|
|
|
# if SIZEOF_INTPTR_T == SIZEOF_INT
|
|
|
|
# define TYPE_INTPTR_T TYPE_INT
|
|
|
|
# elif SIZEOF_INTPTR_T == SIZEOF_LONG
|
|
|
|
# define TYPE_INTPTR_T TYPE_LONG
|
|
|
|
# elif defined HAVE_LONG_LONG && SIZEOF_INTPTR_T == SIZEOF_LONG_LONG
|
|
|
|
# define TYPE_INTPTR_T TYPE_LONG_LONG
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
#define TYPE_UINTPTR_T (-TYPE_INTPTR_T)
|
|
|
|
|
2012-02-09 10:15:57 -05:00
|
|
|
void
|
|
|
|
Init_fiddle(void)
|
2010-05-06 02:59:24 -04:00
|
|
|
{
|
2011-08-15 19:48:59 -04:00
|
|
|
/*
|
|
|
|
* Document-module: Fiddle
|
|
|
|
*
|
|
|
|
* == Description
|
|
|
|
*
|
|
|
|
* A libffi wrapper.
|
|
|
|
*
|
|
|
|
*/
|
2010-05-06 02:59:24 -04:00
|
|
|
mFiddle = rb_define_module("Fiddle");
|
|
|
|
|
2011-08-15 19:48:59 -04:00
|
|
|
/* Document-const: TYPE_VOID
|
|
|
|
*
|
|
|
|
* C type - void
|
|
|
|
*/
|
2010-05-06 02:59:24 -04:00
|
|
|
rb_define_const(mFiddle, "TYPE_VOID", INT2NUM(TYPE_VOID));
|
2011-08-15 19:48:59 -04:00
|
|
|
|
|
|
|
/* Document-const: TYPE_VOIDP
|
|
|
|
*
|
|
|
|
* C type - void*
|
|
|
|
*/
|
2010-05-06 02:59:24 -04:00
|
|
|
rb_define_const(mFiddle, "TYPE_VOIDP", INT2NUM(TYPE_VOIDP));
|
2011-08-15 19:48:59 -04:00
|
|
|
|
|
|
|
/* Document-const: TYPE_CHAR
|
|
|
|
*
|
|
|
|
* C type - char
|
|
|
|
*/
|
2010-05-06 02:59:24 -04:00
|
|
|
rb_define_const(mFiddle, "TYPE_CHAR", INT2NUM(TYPE_CHAR));
|
2011-08-15 19:48:59 -04:00
|
|
|
|
|
|
|
/* Document-const: TYPE_SHORT
|
|
|
|
*
|
|
|
|
* C type - short
|
|
|
|
*/
|
2010-05-06 02:59:24 -04:00
|
|
|
rb_define_const(mFiddle, "TYPE_SHORT", INT2NUM(TYPE_SHORT));
|
2011-08-15 19:48:59 -04:00
|
|
|
|
|
|
|
/* Document-const: TYPE_INT
|
|
|
|
*
|
|
|
|
* C type - int
|
|
|
|
*/
|
2010-05-06 02:59:24 -04:00
|
|
|
rb_define_const(mFiddle, "TYPE_INT", INT2NUM(TYPE_INT));
|
2011-08-15 19:48:59 -04:00
|
|
|
|
|
|
|
/* Document-const: TYPE_LONG
|
|
|
|
*
|
|
|
|
* C type - long
|
|
|
|
*/
|
2010-05-06 02:59:24 -04:00
|
|
|
rb_define_const(mFiddle, "TYPE_LONG", INT2NUM(TYPE_LONG));
|
2011-08-15 19:48:59 -04:00
|
|
|
|
2010-05-06 02:59:24 -04:00
|
|
|
#if HAVE_LONG_LONG
|
2011-08-15 19:48:59 -04:00
|
|
|
/* Document-const: TYPE_LONG_LONG
|
|
|
|
*
|
|
|
|
* C type - long long
|
|
|
|
*/
|
2010-05-06 02:59:24 -04:00
|
|
|
rb_define_const(mFiddle, "TYPE_LONG_LONG", INT2NUM(TYPE_LONG_LONG));
|
|
|
|
#endif
|
2011-08-15 19:48:59 -04:00
|
|
|
|
|
|
|
/* Document-const: TYPE_FLOAT
|
|
|
|
*
|
|
|
|
* C type - float
|
|
|
|
*/
|
2010-05-06 02:59:24 -04:00
|
|
|
rb_define_const(mFiddle, "TYPE_FLOAT", INT2NUM(TYPE_FLOAT));
|
2011-08-15 19:48:59 -04:00
|
|
|
|
|
|
|
/* Document-const: TYPE_DOUBLE
|
|
|
|
*
|
|
|
|
* C type - double
|
|
|
|
*/
|
2010-05-06 02:59:24 -04:00
|
|
|
rb_define_const(mFiddle, "TYPE_DOUBLE", INT2NUM(TYPE_DOUBLE));
|
|
|
|
|
2012-02-25 00:47:16 -05:00
|
|
|
/* Document-const: TYPE_SIZE_T
|
|
|
|
*
|
|
|
|
* C type - size_t
|
|
|
|
*/
|
|
|
|
rb_define_const(mFiddle, "TYPE_SIZE_T", INT2NUM(TYPE_SIZE_T));
|
|
|
|
|
|
|
|
/* Document-const: TYPE_SSIZE_T
|
|
|
|
*
|
|
|
|
* C type - ssize_t
|
|
|
|
*/
|
|
|
|
rb_define_const(mFiddle, "TYPE_SSIZE_T", INT2NUM(TYPE_SSIZE_T));
|
|
|
|
|
|
|
|
/* Document-const: TYPE_PTRDIFF_T
|
|
|
|
*
|
|
|
|
* C type - ptrdiff_t
|
|
|
|
*/
|
|
|
|
rb_define_const(mFiddle, "TYPE_PTRDIFF_T", INT2NUM(TYPE_PTRDIFF_T));
|
|
|
|
|
|
|
|
/* Document-const: TYPE_INTPTR_T
|
|
|
|
*
|
|
|
|
* C type - intptr_t
|
|
|
|
*/
|
|
|
|
rb_define_const(mFiddle, "TYPE_INTPTR_T", INT2NUM(TYPE_INTPTR_T));
|
|
|
|
|
|
|
|
/* Document-const: TYPE_UINTPTR_T
|
|
|
|
*
|
|
|
|
* C type - uintptr_t
|
|
|
|
*/
|
|
|
|
rb_define_const(mFiddle, "TYPE_UINTPTR_T", INT2NUM(TYPE_UINTPTR_T));
|
|
|
|
|
2011-08-15 19:48:59 -04:00
|
|
|
/* Document-const: WINDOWS
|
|
|
|
*
|
|
|
|
* Returns a boolean regarding whether the host is WIN32
|
|
|
|
*/
|
2011-01-04 22:13:18 -05:00
|
|
|
#if defined(_WIN32)
|
2010-05-06 02:59:24 -04:00
|
|
|
rb_define_const(mFiddle, "WINDOWS", Qtrue);
|
|
|
|
#else
|
|
|
|
rb_define_const(mFiddle, "WINDOWS", Qfalse);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
Init_fiddle_function();
|
|
|
|
Init_fiddle_closure();
|
|
|
|
}
|
|
|
|
/* vim: set noet sws=4 sw=4: */
|