ffi 0.3.5 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of ffi might be problematic. Click here for more details.

Files changed (59) hide show
  1. data/README.rdoc +51 -1
  2. data/Rakefile +34 -26
  3. data/ext/ffi_c/AbstractMemory.c +73 -70
  4. data/ext/ffi_c/AbstractMemory.h +8 -4
  5. data/ext/ffi_c/AutoPointer.c +8 -9
  6. data/ext/ffi_c/AutoPointer.h +2 -2
  7. data/ext/ffi_c/Buffer.c +19 -20
  8. data/ext/ffi_c/Callback.c +85 -33
  9. data/ext/ffi_c/Callback.h +11 -5
  10. data/ext/ffi_c/{NativeLibrary.c → DynamicLibrary.c} +83 -16
  11. data/ext/ffi_c/{NativeLibrary.h → DynamicLibrary.h} +1 -1
  12. data/ext/ffi_c/Invoker.c +148 -192
  13. data/ext/ffi_c/LastError.c +135 -0
  14. data/ext/ffi_c/LastError.h +18 -0
  15. data/ext/ffi_c/MemoryPointer.c +26 -19
  16. data/ext/ffi_c/MemoryPointer.h +3 -3
  17. data/ext/ffi_c/NullPointer.c +49 -47
  18. data/ext/ffi_c/Platform.c +9 -10
  19. data/ext/ffi_c/Platform.h +1 -1
  20. data/ext/ffi_c/Pointer.c +52 -21
  21. data/ext/ffi_c/Pointer.h +8 -6
  22. data/ext/ffi_c/Struct.c +70 -61
  23. data/ext/ffi_c/Struct.h +2 -2
  24. data/ext/ffi_c/Type.c +230 -0
  25. data/ext/ffi_c/Type.h +28 -0
  26. data/ext/ffi_c/Types.c +47 -6
  27. data/ext/ffi_c/Types.h +8 -2
  28. data/ext/ffi_c/endian.h +40 -0
  29. data/ext/ffi_c/extconf.rb +6 -5
  30. data/ext/ffi_c/ffi.c +20 -43
  31. data/ext/ffi_c/libffi.bsd.mk +34 -0
  32. data/ext/ffi_c/libffi.darwin.mk +30 -10
  33. data/ext/ffi_c/libffi.gnu.mk +29 -0
  34. data/ext/ffi_c/libffi.mk +4 -2
  35. data/ext/ffi_c/rbffi.h +6 -8
  36. data/lib/ffi.rb +10 -1
  37. data/lib/ffi/autopointer.rb +1 -1
  38. data/lib/ffi/enum.rb +78 -0
  39. data/lib/ffi/ffi.rb +5 -6
  40. data/lib/ffi/io.rb +15 -1
  41. data/lib/ffi/library.rb +78 -17
  42. data/lib/ffi/pointer.rb +2 -2
  43. data/lib/ffi/struct.rb +68 -14
  44. data/lib/ffi/types.rb +6 -3
  45. data/lib/ffi/variadic.rb +2 -2
  46. data/spec/ffi/bool_spec.rb +24 -0
  47. data/spec/ffi/callback_spec.rb +217 -17
  48. data/spec/ffi/enum_spec.rb +164 -0
  49. data/spec/ffi/managed_struct_spec.rb +6 -1
  50. data/spec/ffi/number_spec.rb +30 -0
  51. data/spec/ffi/pointer_spec.rb +33 -8
  52. data/spec/ffi/rbx/memory_pointer_spec.rb +0 -6
  53. data/spec/ffi/spec_helper.rb +5 -1
  54. data/spec/ffi/string_spec.rb +65 -4
  55. data/spec/ffi/struct_callback_spec.rb +41 -0
  56. data/spec/ffi/struct_initialize_spec.rb +30 -0
  57. data/spec/ffi/struct_spec.rb +19 -20
  58. metadata +29 -52
  59. data/ext/ffi_c/ffi.mk +0 -23
@@ -0,0 +1,135 @@
1
+ #include <sys/param.h>
2
+ #include <sys/types.h>
3
+ #include <stdio.h>
4
+ #include <stdint.h>
5
+ #include <stdbool.h>
6
+ #include <errno.h>
7
+ #include <ruby.h>
8
+
9
+ #include "LastError.h"
10
+
11
+ #if defined(HAVE_NATIVETHREAD) && !defined(_WIN32) && !defined(__WIN32__)
12
+ # include <pthread.h>
13
+ #endif
14
+
15
+ #if defined(HAVE_NATIVETHREAD) && !defined(_WIN32) && !defined(__WIN32__)
16
+ # define USE_PTHREAD_LOCAL
17
+ #endif
18
+
19
+ typedef struct ThreadData {
20
+ int td_errno;
21
+ } ThreadData;
22
+
23
+ #if defined(USE_PTHREAD_LOCAL)
24
+ static pthread_key_t threadDataKey;
25
+ #endif
26
+
27
+ static inline ThreadData* thread_data_get(void);
28
+
29
+ #if defined(USE_PTHREAD_LOCAL)
30
+
31
+ static ThreadData*
32
+ thread_data_init(void)
33
+ {
34
+ ThreadData* td = ALLOC_N(ThreadData, 1);
35
+
36
+ memset(td, 0, sizeof(*td));
37
+ pthread_setspecific(threadDataKey, td);
38
+
39
+ return td;
40
+ }
41
+
42
+
43
+ static inline ThreadData*
44
+ thread_data_get(void)
45
+ {
46
+ ThreadData* td = pthread_getspecific(threadDataKey);
47
+ return td != NULL ? td : thread_data_init();
48
+ }
49
+
50
+ static void
51
+ thread_data_free(void *ptr)
52
+ {
53
+ xfree(ptr);
54
+ }
55
+
56
+ #else
57
+ static ID id_thread_data;
58
+
59
+ static ThreadData*
60
+ thread_data_init(void)
61
+ {
62
+ ThreadData* td;
63
+ VALUE obj;
64
+
65
+ obj = Data_Make_Struct(rb_cObject, ThreadData, NULL, -1, td);
66
+ rb_thread_local_aset(rb_thread_current(), id_thread_data, obj);
67
+
68
+ return td;
69
+ }
70
+
71
+ static inline ThreadData*
72
+ thread_data_get()
73
+ {
74
+ VALUE obj = rb_thread_local_aref(rb_thread_current(), id_thread_data);
75
+
76
+ if (obj != Qnil && TYPE(obj) == T_DATA) {
77
+ return (ThreadData *) DATA_PTR(obj);
78
+ }
79
+
80
+ return thread_data_init();
81
+ }
82
+
83
+ #endif
84
+
85
+
86
+ static VALUE
87
+ get_last_error(VALUE self)
88
+ {
89
+ return INT2NUM(thread_data_get()->td_errno);
90
+ }
91
+
92
+
93
+ static VALUE
94
+ set_last_error(VALUE self, VALUE error)
95
+ {
96
+
97
+ #ifdef _WIN32
98
+ SetLastError(NUM2INT(error));
99
+ #else
100
+ errno = NUM2INT(error);
101
+ #endif
102
+
103
+ return Qnil;
104
+ }
105
+
106
+
107
+ void
108
+ rbffi_save_errno(void)
109
+ {
110
+ int error = 0;
111
+
112
+ #ifdef _WIN32
113
+ error = GetLastError();
114
+ #else
115
+ error = errno;
116
+ #endif
117
+
118
+ thread_data_get()->td_errno = error;
119
+ }
120
+
121
+
122
+ void
123
+ rbffi_LastError_Init(VALUE moduleFFI)
124
+ {
125
+ VALUE moduleError = rb_define_module_under(moduleFFI, "LastError");
126
+
127
+ rb_define_module_function(moduleError, "error", get_last_error, 0);
128
+ rb_define_module_function(moduleError, "error=", set_last_error, 1);
129
+
130
+ #if defined(USE_PTHREAD_LOCAL)
131
+ pthread_key_create(&threadDataKey, thread_data_free);
132
+ #else
133
+ id_thread_data = rb_intern("ffi_thread_local_data");
134
+ #endif /* USE_PTHREAD_LOCAL */
135
+ }
@@ -0,0 +1,18 @@
1
+ #ifndef RBFFI_LASTERROR_H
2
+ #define RBFFI_LASTERROR_H
3
+
4
+ #ifdef __cplusplus
5
+ extern "C" {
6
+ #endif
7
+
8
+
9
+ void rbffi_LastError_Init(VALUE moduleFFI);
10
+
11
+ void rbffi_save_errno(void);
12
+
13
+ #ifdef __cplusplus
14
+ }
15
+ #endif
16
+
17
+ #endif /* RBFFI_LASTERROR_H */
18
+
@@ -20,14 +20,16 @@ static void memptr_release(MemoryPointer* ptr);
20
20
  static VALUE memptr_malloc(VALUE self, long size, long count, bool clear);
21
21
  static VALUE memptr_free(VALUE self);
22
22
 
23
- VALUE rb_FFI_MemoryPointer_class;
24
- static VALUE classMemoryPointer = Qnil;
25
- #define MEMPTR(obj) ((MemoryPointer *) rb_FFI_AbstractMemory_cast(obj, rb_FFI_MemoryPointer_class))
23
+ VALUE rbffi_MemoryPointerClass;
24
+
25
+ #define MEMPTR(obj) ((MemoryPointer *) rbffi_AbstractMemory_Cast(obj, rbffi_MemoryPointerClass))
26
+
27
+ static ID plus_id = 0;
26
28
 
27
29
  VALUE
28
- rb_FFI_MemoryPointer_new(long size, long count, bool clear)
30
+ rbffi_MemoryPointer_NewInstance(long size, long count, bool clear)
29
31
  {
30
- return memptr_malloc(memptr_allocate(classMemoryPointer), size, count, clear);
32
+ return memptr_malloc(memptr_allocate(rbffi_MemoryPointerClass), size, count, clear);
31
33
  }
32
34
 
33
35
  static VALUE
@@ -35,7 +37,7 @@ memptr_allocate(VALUE klass)
35
37
  {
36
38
  MemoryPointer* p;
37
39
  VALUE obj = Data_Make_Struct(klass, MemoryPointer, NULL, memptr_release, p);
38
- p->memory.ops = &rb_FFI_AbstractMemory_ops;
40
+ p->memory.ops = &rbffi_AbstractMemoryOps;
39
41
 
40
42
  return obj;
41
43
  }
@@ -45,12 +47,14 @@ memptr_initialize(int argc, VALUE* argv, VALUE self)
45
47
  {
46
48
  VALUE size = Qnil, count = Qnil, clear = Qnil;
47
49
  int nargs = rb_scan_args(argc, argv, "12", &size, &count, &clear);
48
- memptr_malloc(self, rb_FFI_type_size(size), nargs > 1 ? NUM2LONG(count) : 1,
49
- nargs > 2 && RTEST(clear));
50
+
51
+ memptr_malloc(self, rbffi_type_size(size), nargs > 1 ? NUM2LONG(count) : 1,
52
+ RTEST(clear) || clear == Qnil);
50
53
 
51
54
  if (rb_block_given_p()) {
52
55
  return rb_ensure(rb_yield, self, memptr_free, self);
53
56
  }
57
+
54
58
  return self;
55
59
  }
56
60
 
@@ -100,7 +104,7 @@ memptr_aref(VALUE self, VALUE which)
100
104
  {
101
105
  MemoryPointer* ptr = MEMPTR(self);
102
106
  VALUE offset = INT2NUM(ptr->type_size * NUM2INT(which));
103
- return rb_funcall2(self, rb_intern("+"), 1, &offset);
107
+ return rb_funcall2(self, plus_id, 1, &offset);
104
108
  }
105
109
 
106
110
  static VALUE
@@ -135,15 +139,18 @@ memptr_release(MemoryPointer* ptr)
135
139
  }
136
140
 
137
141
  void
138
- rb_FFI_MemoryPointer_Init()
142
+ rbffi_MemoryPointer_Init(VALUE moduleFFI)
139
143
  {
140
- VALUE moduleFFI = rb_define_module("FFI");
141
- rb_FFI_MemoryPointer_class = classMemoryPointer = rb_define_class_under(moduleFFI, "MemoryPointer", rb_FFI_Pointer_class);
142
- rb_define_alloc_func(classMemoryPointer, memptr_allocate);
143
- rb_define_method(classMemoryPointer, "initialize", memptr_initialize, -1);
144
- rb_define_method(classMemoryPointer, "inspect", memptr_inspect, 0);
145
- rb_define_method(classMemoryPointer, "autorelease=", memptr_autorelease, 1);
146
- rb_define_method(classMemoryPointer, "free", memptr_free, 0);
147
- rb_define_method(classMemoryPointer, "type_size", memptr_type_size, 0);
148
- rb_define_method(classMemoryPointer, "[]", memptr_aref, 1);
144
+ rbffi_MemoryPointerClass = rb_define_class_under(moduleFFI, "MemoryPointer", rbffi_PointerClass);
145
+ rb_global_variable(&rbffi_MemoryPointerClass);
146
+
147
+ rb_define_alloc_func(rbffi_MemoryPointerClass, memptr_allocate);
148
+ rb_define_method(rbffi_MemoryPointerClass, "initialize", memptr_initialize, -1);
149
+ rb_define_method(rbffi_MemoryPointerClass, "inspect", memptr_inspect, 0);
150
+ rb_define_method(rbffi_MemoryPointerClass, "autorelease=", memptr_autorelease, 1);
151
+ rb_define_method(rbffi_MemoryPointerClass, "free", memptr_free, 0);
152
+ rb_define_method(rbffi_MemoryPointerClass, "type_size", memptr_type_size, 0);
153
+ rb_define_method(rbffi_MemoryPointerClass, "[]", memptr_aref, 1);
154
+
155
+ plus_id = rb_intern("+");
149
156
  }
@@ -9,9 +9,9 @@
9
9
  extern "C" {
10
10
  #endif
11
11
 
12
- extern void rb_FFI_MemoryPointer_Init(void);
13
- extern VALUE rb_FFI_MemoryPointer_class;
14
- extern VALUE rb_FFI_MemoryPointer_new(long size, long count, bool clear);
12
+ extern void rbffi_MemoryPointer_Init(VALUE moduleFFI);
13
+ extern VALUE rbffi_MemoryPointerClass;
14
+ extern VALUE rbffi_MemoryPointer_NewInstance(long size, long count, bool clear);
15
15
  #ifdef __cplusplus
16
16
  }
17
17
  #endif
@@ -7,15 +7,13 @@
7
7
  #include "AbstractMemory.h"
8
8
  #include "Pointer.h"
9
9
 
10
- static VALUE NullPointerError;
11
- static VALUE classNullPointer;
12
- static MemoryOps nullptr_ops;
10
+ static VALUE NullPointerErrorClass;
13
11
 
14
- VALUE rb_FFI_NullPointer_class;
15
- VALUE rb_FFI_NullPointer_singleton;
12
+ VALUE rbffi_NullPointerClass;
13
+ VALUE rbffi_NullPointerSingleton;
16
14
 
17
- VALUE
18
- rb_FFI_NullPointer_allocate(VALUE klass)
15
+ static VALUE
16
+ nullptr_allocate(VALUE klass)
19
17
  {
20
18
  AbstractMemory* p;
21
19
  VALUE retval;
@@ -23,7 +21,7 @@ rb_FFI_NullPointer_allocate(VALUE klass)
23
21
  retval = Data_Make_Struct(klass, AbstractMemory, NULL, -1, p);
24
22
  p->address = 0;
25
23
  p->size = 0;
26
- p->ops = &nullptr_ops;
24
+ p->ops = &rbffi_NullPointerOps;
27
25
 
28
26
  return retval;
29
27
  }
@@ -31,21 +29,21 @@ rb_FFI_NullPointer_allocate(VALUE klass)
31
29
  static VALUE
32
30
  nullptr_op(int argc, VALUE* argv, VALUE self)
33
31
  {
34
- rb_raise(NullPointerError, "NULL Pointer access attempted");
32
+ rb_raise(NullPointerErrorClass, "NULL Pointer access attempted");
35
33
  return Qnil;
36
34
  }
37
35
 
38
36
  static VALUE
39
37
  nullptr_op_get(AbstractMemory* ptr, long offset)
40
38
  {
41
- rb_raise(NullPointerError, "NULL Pointer access attempted");
39
+ rb_raise(NullPointerErrorClass, "NULL Pointer access attempted");
42
40
  return Qnil;
43
41
  }
44
42
 
45
43
  static void
46
44
  nullptr_op_put(AbstractMemory* ptr, long offset, VALUE value)
47
45
  {
48
- rb_raise(NullPointerError, "NULL Pointer access attempted");
46
+ rb_raise(NullPointerErrorClass, "NULL Pointer access attempted");
49
47
  }
50
48
 
51
49
  static VALUE
@@ -65,7 +63,7 @@ nullptr_equals(VALUE self, VALUE other)
65
63
  {
66
64
  AbstractMemory* p2;
67
65
 
68
- if (!rb_obj_is_kind_of(other, rb_FFI_Pointer_class)) {
66
+ if (!rb_obj_is_kind_of(other, rbffi_PointerClass)) {
69
67
  rb_raise(rb_eArgError, "Comparing Pointer with non Pointer");
70
68
  }
71
69
 
@@ -80,41 +78,44 @@ nullptr_address(VALUE self)
80
78
  return INT2NUM(0);
81
79
  }
82
80
 
83
- static MemoryOp nullptr_memory_op = { nullptr_op_get, nullptr_op_put };
84
-
85
- static MemoryOps nullptr_ops = {
86
- .int8 = &nullptr_memory_op,
87
- .uint8 = &nullptr_memory_op,
88
- .int16 = &nullptr_memory_op,
89
- .int16 = &nullptr_memory_op,
90
- .int32 = &nullptr_memory_op,
91
- .uint32 = &nullptr_memory_op,
92
- .int64 = &nullptr_memory_op,
93
- .uint64 = &nullptr_memory_op,
94
- .float32 = &nullptr_memory_op,
95
- .float64 = &nullptr_memory_op,
96
- .pointer = &nullptr_memory_op,
97
- .strptr = &nullptr_memory_op,
81
+ static MemoryOp NullPointerMemoryOp = { nullptr_op_get, nullptr_op_put };
82
+
83
+ MemoryOps rbffi_NullPointerOps = {
84
+ .int8 = &NullPointerMemoryOp,
85
+ .uint8 = &NullPointerMemoryOp,
86
+ .int16 = &NullPointerMemoryOp,
87
+ .int16 = &NullPointerMemoryOp,
88
+ .int32 = &NullPointerMemoryOp,
89
+ .uint32 = &NullPointerMemoryOp,
90
+ .int64 = &NullPointerMemoryOp,
91
+ .uint64 = &NullPointerMemoryOp,
92
+ .float32 = &NullPointerMemoryOp,
93
+ .float64 = &NullPointerMemoryOp,
94
+ .pointer = &NullPointerMemoryOp,
95
+ .strptr = &NullPointerMemoryOp,
98
96
  };
99
97
 
100
98
  void
101
- rb_FFI_NullPointer_Init()
99
+ rbffi_NullPointer_Init(VALUE moduleFFI)
102
100
  {
103
- VALUE moduleFFI = rb_define_module("FFI");
104
- rb_FFI_NullPointer_class = classNullPointer = rb_define_class_under(moduleFFI, "NullPointer", rb_FFI_Pointer_class);
105
- NullPointerError = rb_define_class_under(moduleFFI, "NullPointerError", rb_eRuntimeError);
106
- rb_define_alloc_func(classNullPointer, rb_FFI_NullPointer_allocate);
107
- rb_define_method(classNullPointer, "inspect", nullptr_inspect, 0);
108
- rb_define_method(classNullPointer, "+", nullptr_op, -1);
109
- rb_define_method(classNullPointer, "null?", nullptr_null_p, 0);
110
- rb_define_method(classNullPointer, "address", nullptr_address, 0);
111
- rb_define_method(classNullPointer, "==", nullptr_equals, 1);
101
+ rbffi_NullPointerClass = rb_define_class_under(moduleFFI, "NullPointer", rbffi_PointerClass);
102
+ rb_global_variable(&rbffi_NullPointerClass);
103
+
104
+ NullPointerErrorClass = rb_define_class_under(moduleFFI, "NullPointerError", rb_eRuntimeError);
105
+ rb_global_variable(&NullPointerErrorClass);
106
+
107
+ rb_define_alloc_func(rbffi_NullPointerClass, nullptr_allocate);
108
+ rb_define_method(rbffi_NullPointerClass, "inspect", nullptr_inspect, 0);
109
+ rb_define_method(rbffi_NullPointerClass, "+", nullptr_op, -1);
110
+ rb_define_method(rbffi_NullPointerClass, "null?", nullptr_null_p, 0);
111
+ rb_define_method(rbffi_NullPointerClass, "address", nullptr_address, 0);
112
+ rb_define_method(rbffi_NullPointerClass, "==", nullptr_equals, 1);
112
113
 
113
114
  #define NOP(name) \
114
- rb_define_method(classNullPointer, "get_" #name, nullptr_op, -1); \
115
- rb_define_method(classNullPointer, "put_" #name, nullptr_op, -1); \
116
- rb_define_method(classNullPointer, "get_array_of_" #name, nullptr_op, -1); \
117
- rb_define_method(classNullPointer, "put_array_of_" #name, nullptr_op, -1); \
115
+ rb_define_method(rbffi_NullPointerClass, "get_" #name, nullptr_op, -1); \
116
+ rb_define_method(rbffi_NullPointerClass, "put_" #name, nullptr_op, -1); \
117
+ rb_define_method(rbffi_NullPointerClass, "get_array_of_" #name, nullptr_op, -1); \
118
+ rb_define_method(rbffi_NullPointerClass, "put_array_of_" #name, nullptr_op, -1); \
118
119
 
119
120
 
120
121
  NOP(int8); NOP(uint8); NOP(int16); NOP(uint16);
@@ -126,16 +127,17 @@ rb_FFI_NullPointer_Init()
126
127
 
127
128
  #undef NOP
128
129
  #define NOP(name) \
129
- rb_define_method(classNullPointer, "get_" #name, nullptr_op, -1); \
130
- rb_define_method(classNullPointer, "put_" #name, nullptr_op, -1);
130
+ rb_define_method(rbffi_NullPointerClass, "get_" #name, nullptr_op, -1); \
131
+ rb_define_method(rbffi_NullPointerClass, "put_" #name, nullptr_op, -1);
131
132
 
132
133
  NOP(string); NOP(bytes); NOP(pointer); NOP(callback);
133
134
 
134
- rb_define_method(classNullPointer, "clear", nullptr_op, -1); \
135
- rb_define_method(classNullPointer, "total", nullptr_op, -1);
135
+ rb_define_method(rbffi_NullPointerClass, "clear", nullptr_op, -1); \
136
+ rb_define_method(rbffi_NullPointerClass, "total", nullptr_op, -1);
136
137
 
137
138
  // Create a singleton instance of NullPointer that can be shared
138
- rb_FFI_NullPointer_singleton = rb_FFI_NullPointer_allocate(classNullPointer);
139
- rb_gc_register_address(&rb_FFI_NullPointer_singleton);
139
+ rbffi_NullPointerSingleton = nullptr_allocate(rbffi_NullPointerClass);
140
+ rb_global_variable(&rbffi_NullPointerSingleton);
141
+ rb_define_const(rbffi_PointerClass, "NULL", rbffi_NullPointerSingleton);
140
142
  }
141
143
 
@@ -4,9 +4,10 @@
4
4
  #include <stdbool.h>
5
5
  #include <ruby.h>
6
6
  #include <ctype.h>
7
+ #include "endian.h"
7
8
  #include "Platform.h"
8
9
 
9
- static VALUE modulePlatform = Qnil;
10
+ static VALUE PlatformModule = Qnil;
10
11
 
11
12
  /*
12
13
  * Determine the cpu type at compile time - useful for MacOSX where the the
@@ -47,14 +48,12 @@ export_primitive_types(VALUE module)
47
48
  }
48
49
 
49
50
  void
50
- rb_FFI_Platform_Init()
51
+ rbffi_Platform_Init(VALUE moduleFFI)
51
52
  {
52
- VALUE moduleFFI = rb_define_module("FFI");
53
- VALUE platform = rb_define_module_under(moduleFFI, "Platform");
54
- rb_define_const(platform, "BYTE_ORDER", INT2FIX(BYTE_ORDER));
55
- rb_define_const(platform, "LITTLE_ENDIAN", INT2FIX(LITTLE_ENDIAN));
56
- rb_define_const(platform, "BIG_ENDIAN", INT2FIX(BIG_ENDIAN));
57
- rb_define_const(platform, "CPU", rb_str_new2(CPU));
58
- export_primitive_types(platform);
59
- modulePlatform = platform;
53
+ PlatformModule = rb_define_module_under(moduleFFI, "Platform");
54
+ rb_define_const(PlatformModule, "BYTE_ORDER", INT2FIX(BYTE_ORDER));
55
+ rb_define_const(PlatformModule, "LITTLE_ENDIAN", INT2FIX(LITTLE_ENDIAN));
56
+ rb_define_const(PlatformModule, "BIG_ENDIAN", INT2FIX(BIG_ENDIAN));
57
+ rb_define_const(PlatformModule, "CPU", rb_str_new2(CPU));
58
+ export_primitive_types(PlatformModule);
60
59
  }
@@ -5,7 +5,7 @@
5
5
  extern "C" {
6
6
  #endif
7
7
 
8
- extern void rb_FFI_Platform_Init(void);
8
+ extern void rbffi_Platform_Init(VALUE moduleFFI);
9
9
 
10
10
 
11
11
  #ifdef __cplusplus