Module: FFI
- Defined in:
- lib/ffi/io.rb,
lib/ffi/enum.rb,
lib/ffi/errno.rb,
lib/ffi/types.rb,
lib/ffi/union.rb,
lib/ffi/struct.rb,
lib/ffi/library.rb,
lib/ffi/pointer.rb,
lib/ffi/version.rb,
lib/ffi/platform.rb,
lib/ffi/variadic.rb,
lib/ffi/autopointer.rb,
lib/ffi/managedstruct.rb,
lib/ffi/struct_layout.rb,
lib/ffi/data_converter.rb,
lib/ffi/tools/generator.rb,
lib/ffi/struct_by_reference.rb,
lib/ffi/struct_layout_builder.rb,
lib/ffi/tools/const_generator.rb,
lib/ffi/tools/types_generator.rb,
lib/ffi/tools/struct_generator.rb,
ext/ffi_c/ffi.c,
ext/ffi_c/ffi.c
Overview
This module embbed type constants from NativeType.
Defined Under Namespace
Modules: DataConverter, IO, LastError, Library, NativeType, Platform Classes: AbstractMemory, ArrayType, AutoPointer, Bitmask, Buffer, ConstGenerator, DynamicLibrary, Enum, Enums, Function, FunctionType, Generator, ManagedStruct, MemoryPointer, NotFoundError, NullPointerError, PlatformError, Pointer, StrPtrConverter, Struct, StructByReference, StructByValue, StructGenerator, StructLayout, StructLayoutBuilder, Type, TypesGenerator, Union, VariadicInvoker
Constant Summary collapse
- CURRENT_PROCESS =
USE_THIS_PROCESS_AS_LIBRARY = Object.new
- VERSION =
'1.11.1'
- TypeDefs =
FFI::TypeDefs
Document-constant
- SizeTypes =
sizeMap = rb_hash_new()
- CallbackInfo =
rbffi_FunctionTypeClass
- FunctionInfo =
rbffi_FunctionTypeClass
- NativeLibrary =
backwards compat library
LibraryClass
Class Method Summary collapse
-
.add_typedef(old, add) ⇒ Type
Add a definition type to type definitions.
- .errno ⇒ Numeric
- .errno=(error) ⇒ nil
-
.find_type(name, type_map = nil) ⇒ Type
Find a type in
type_map
(TypeDefs, by default) from a type objet, a type name (symbol). -
.map_library_name(lib) ⇒ String
Transform a generic library name to a platform library name.
-
.type_size(type) ⇒ Numeric
Get
type
size, in bytes. -
.typedef(old, add) ⇒ Type
Add a definition type to type definitions.
Class Method Details
.add_typedef(old, add) ⇒ Type
Add a definition type to type definitions.
45 46 47 |
# File 'lib/ffi/types.rb', line 45 def self.add_typedef(old, add) typedef old, add end |
.errno ⇒ Numeric
34 35 36 |
# File 'lib/ffi/errno.rb', line 34 def self.errno FFI::LastError.error end |
.errno=(error) ⇒ nil
40 41 42 |
# File 'lib/ffi/errno.rb', line 40 def self.errno=(error) FFI::LastError.error = error end |
.find_type(name, type_map = nil) ⇒ Type
Find a type in type_map
(TypeDefs, by default) from a type objet, a type name (symbol). If name
is a DataConverter, a new FFI::Type::Mapped is created.
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/ffi/types.rb', line 56 def self.find_type(name, type_map = nil) if name.is_a?(Type) name elsif type_map && type_map.has_key?(name) type_map[name] elsif TypeDefs.has_key?(name) TypeDefs[name] elsif name.is_a?(DataConverter) (type_map || TypeDefs)[name] = Type::Mapped.new(name) else raise TypeError, "unable to resolve type '#{name}'" end end |
.map_library_name(lib) ⇒ String
Transform a generic library name to a platform library name
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/ffi/library.rb', line 44 def self.map_library_name(lib) # Mangle the library name to reflect the native library naming conventions lib = Library::LIBC if lib == 'c' if lib && File.basename(lib) == lib lib = Platform::LIBPREFIX + lib unless lib =~ /^#{Platform::LIBPREFIX}/ r = Platform::IS_GNU ? "\\.so($|\\.[1234567890]+)" : "\\.#{Platform::LIBSUFFIX}$" lib += ".#{Platform::LIBSUFFIX}" unless lib =~ /#{r}/ end lib end |
.type_size(type) ⇒ Numeric
Get type
size, in bytes.
176 177 178 |
# File 'lib/ffi/types.rb', line 176 def self.type_size(type) find_type(type).size end |