Ruby 1.9.2p136(2010-12-25revision30365)

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

# ext/fiddle/conversions.h

Go to the documentation of this file.

    00001 #ifndef FIDDLE_CONVERSIONS_H
    00002 #define FIDDLE_CONVERSIONS_H
    00003
    00004 #include <fiddle.h>
    00005
    00006 typedef union
    00007 {
    00008     unsigned char uchar;   /* ffi_type_uchar */
    00009     signed char   schar;   /* ffi_type_schar */
    00010     unsigned short ushort; /* ffi_type_sshort */
    00011     signed short sshort;   /* ffi_type_ushort */
    00012     unsigned int uint;     /* ffi_type_uint */
    00013     signed int sint;       /* ffi_type_sint */
    00014     unsigned long ulong;   /* ffi_type_ulong */
    00015     signed long slong;     /* ffi_type_slong */
    00016     float ffloat;          /* ffi_type_float */
    00017     double ddouble;        /* ffi_type_double */
    00018 #if HAVE_LONG_LONG
    00019     unsigned LONG_LONG long_long; /* ffi_type_uint64 */
    00020 #endif
    00021     void * pointer;        /* ffi_type_pointer */
    00022 } fiddle_generic;
    00023
    00024 ffi_type * int_to_ffi_type(int type);
    00025 void value_to_generic(int type, VALUE src, fiddle_generic * dst);
    00026 VALUE generic_to_value(VALUE rettype, fiddle_generic retval);
    00027
    00028 #define VALUE2GENERIC(_type, _src, _dst) value_to_generic(_type, _src, _dst)
    00029 #define INT2FFI_TYPE(_type) int_to_ffi_type(_type)
    00030 #define GENERIC2VALUE(_type, _retval) generic_to_value(_type, _retval)
    00031
    00032 #if SIZEOF_VOIDP == SIZEOF_LONG
    00033 # define PTR2NUM(x)   (ULONG2NUM((unsigned long)(x)))
    00034 # define NUM2PTR(x)   ((void*)(NUM2ULONG(x)))
    00035 #else
    00036 /* # error --->> Ruby/DL2 requires sizeof(void*) == sizeof(long) to be compiled. <<--- */
    00037 # define PTR2NUM(x)   (ULL2NUM((unsigned long long)(x)))
    00038 # define NUM2PTR(x)   ((void*)(NUM2ULL(x)))
    00039 #endif
    00040
    00041 #endif
    00042