Module: FFI::DataConverter
- Included in:
- AutoPointer, Enum, StrPtrConverter
- Defined in:
- ext/ffi_c/DataConverter.c,
ext/ffi_c/DataConverter.c
Overview
This module is used to extend somes classes and give then a common API.
Most of methods defined here must be overriden.
Instance Method Summary collapse
-
#from_native(value, ctx) ⇒ value
Convert from a native type.
-
#native_type(*args) ⇒ Object
Get native type.
-
#to_native(value, ctx) ⇒ value
Convert to a native type.
Instance Method Details
#from_native(value, ctx) ⇒ value
Convert from a native type.
65 66 67 68 69 |
# File 'ext/ffi_c/DataConverter.c', line 65 static VALUE conv_from_native(VALUE self, VALUE value, VALUE ctx) { return value; } |
#native_type(type) ⇒ Type #native_type ⇒ Object
Get native type.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'ext/ffi_c/DataConverter.c', line 23 static VALUE conv_native_type(int argc, VALUE* argv, VALUE self) { if (argc == 0) { if (!rb_ivar_defined(self, id_native_type_ivar)) { rb_raise(rb_eNotImpError, "native_type method not overridden and no native_type set"); } return rb_ivar_get(self, id_native_type_ivar); } else if (argc == 1) { VALUE type = rbffi_Type_Find(argv[0]); rb_ivar_set(self, id_native_type_ivar, type); return type; } else { rb_raise(rb_eArgError, "incorrect arguments"); } } |
#to_native(value, ctx) ⇒ value
Convert to a native type.
52 53 54 55 56 |
# File 'ext/ffi_c/DataConverter.c', line 52 static VALUE conv_to_native(VALUE self, VALUE value, VALUE ctx) { return value; } |