Module: FFI
- Defined in:
- lib/ffi/extra.rb
Defined Under Namespace
Modules: Library Classes: Pointer
Class Method Summary collapse
Class Method Details
.type_size(type) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/ffi/extra.rb', line 32 def self.type_size (type) type = FFI.find_type(type) if type.is_a?(Symbol) if type.is_a?(Type::Builtin) || type.is_a?(Class) && type.ancestors.member?(FFI::Struct) || type.ancestors.member?(FFI::ManagedStruct) type.size elsif type.respond_to? :from_native type.native_type.size else raise ArgumentError, 'you have to pass a Struct, a Builtin type or a Symbol' end end |