Class | C |
In: |
lib/inline.rb
|
Parent: | Object |
Inline::C is the default builder used and the only one provided by Inline. It can be used as a template to write builders for other languages. It understands type-conversions for the basic types and can be extended as needed using add_type_converter, alias_type_converter and remove_type_converter.
MAGIC_ARITY_THRESHOLD | = | 15 | ||
MAGIC_ARITY | = | -1 | ||
TYPE_MAP | = | { 'char' => [ 'NUM2CHR', 'CHR2FIX' ], 'char *' => [ 'StringValuePtr', 'rb_str_new2' ], 'double' => [ 'NUM2DBL', 'rb_float_new' ], 'int' => [ "FI\X2INT", 'INT2FIX' ], 'unsigned int' => [ 'NUM2UINT', 'UINT2NUM' ], 'unsigned' => [ 'NUM2UINT', 'UINT2NUM' ], 'long' => [ 'NUM2LONG', 'LONG2NUM' ], 'unsigned long' => [ 'NUM2ULONG', 'ULONG2NUM' ], 'long long' => [ 'NUM2LL', 'LL2NUM' ], 'unsigned long long' => [ 'NUM2ULL', 'ULL2NUM' ], 'off_t' => [ 'NUM2OFFT', 'OFFT2NUM' ], 'VALUE' => [ '', '' ], # Can't do these converters because they conflict with the above: # ID2SYM(x), SYM2ID(x), F\IX2UINT(x) } | Default C to ruby and ruby to C type map |
Adds a reader and writer for a C struct member wrapped via Data_Wrap_Struct. method is the ruby name to give the accessor, type is the C type. Unless the C member name is overridden with member, the method name is used as the struct member.
builder.struct_name = 'MyStruct' builder.accessor :title, 'char *' builder.accessor :stream_index, 'int', :index
The latter accesses MyStruct->index via the stream_index method.
Adds compiler options to the compiler command line. No preprocessing is done, so you must have all your dashes and everything.
Adds linker flags to the link command line. No preprocessing is done, so you must have all your dashes and everything.
Registers C type alias_type as an alias of existing_type
Adds a C function to the source, including performing automatic type conversion to arguments and the return value. The Ruby method name can be overridden by providing method_name. Unknown type conversions can be extended by using add_type_converter.
Adds a raw C function to the source. This version does not perform any type conversion and must conform to the ruby/C coding conventions. The Ruby method name can be overridden by providing method_name.
Adds an include to the top of the file. Don‘t forget to use quotes or angle brackets.
Specifies that the the ruby.h header should be included after custom header(s) instead of before them.