Class: CrystalRuby::Types::VariableWidth
- Inherits:
-
FixedWidth
- Object
- Type
- FixedWidth
- CrystalRuby::Types::VariableWidth
- Defined in:
- lib/crystalruby/types/variable_width.rb
Overview
A variable with type operates much like a fixed width type, but it writes a size and a pointer to the type memory instead of the data itself. When we decrement our internal ref count we need to resolve the pointer. The layout is a tiny bit different (data begins at byte 8 to allow room for size uint32 at byte 4)
Constant Summary
Constants inherited from Type
Constants included from CrystalRuby::Typemaps
CrystalRuby::Typemaps::CRYSTAL_TYPE_MAP, CrystalRuby::Typemaps::C_TYPE_CONVERSIONS, CrystalRuby::Typemaps::C_TYPE_MAP, CrystalRuby::Typemaps::ERROR_VALUE, CrystalRuby::Typemaps::FFI_TYPE_MAP
Instance Attribute Summary
Attributes inherited from Type
Class Method Summary collapse
- .build(typename = nil, error: nil, inner_types: nil, inner_keys: nil, ffi_type: :pointer, size_offset: 4, data_offset: 8, memsize: FFI.type_size(ffi_type), refsize: 8, convert_if: [], superclass: VariableWidth, &block) ⇒ Object
- .crystal_supertype ⇒ Object
- .variable_width? ⇒ Boolean
Methods inherited from FixedWidth
#address, #allocate_new_from_reference!, #allocate_new_from_value!, crystal_type, #data_pointer, decr_inner_ref_counts!, decrement_ref_count!, fetch_multi, fetch_single, finalize, free!, increment_ref_count!, #initialize, #ref_count, #ref_count=, #size, to_ffi_repr, #value=, write_single
Methods inherited from Type
#==, [], anonymous?, base_crystal_class_name, bind_local_vars!, cast!, #coerce, crystal_class_name, crystal_type, crystal_type_to_pointer_type_conversion, #deep_dup, #dup, each_child_address, finalize, fixed_width?, from_ffi_array_repr, #initialize, inner_type, #inner_value, inspect, #inspect, inspect_name, #item_size, #method_missing, #native, native_type_expr, nested_types, #nil?, numeric?, pointer_to_crystal_type_conversion, primitive?, template_name, type_defn, type_digest, type_expr, union_types, valid?, valid_cast?, validate!, |
Methods included from CrystalRuby::Typemaps
#build_type_map, #convert_crystal_to_lib_type, #convert_lib_to_crystal_type, #crystal_type, #error_value, #ffi_type, #lib_type
Methods included from Allocator
Constructor Details
This class inherits a constructor from CrystalRuby::Types::FixedWidth
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class CrystalRuby::Types::Type
Class Method Details
.build(typename = nil, error: nil, inner_types: nil, inner_keys: nil, ffi_type: :pointer, size_offset: 4, data_offset: 8, memsize: FFI.type_size(ffi_type), refsize: 8, convert_if: [], superclass: VariableWidth, &block) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/crystalruby/types/variable_width.rb', line 16 def self.build( typename = nil, error: nil, inner_types: nil, inner_keys: nil, ffi_type: :pointer, size_offset: 4, data_offset: 8, memsize: FFI.type_size(ffi_type), refsize: 8, convert_if: [], superclass: VariableWidth, &block ) inner_types&.each(&Type.method(:validate!)) Class.new(superclass) do bind_local_vars!( %i[typename error inner_types inner_keys ffi_type memsize convert_if data_offset size_offset refsize], binding ) class_eval(&block) if block_given? end end |
.crystal_supertype ⇒ Object
12 13 14 |
# File 'lib/crystalruby/types/variable_width.rb', line 12 def self.crystal_supertype "CrystalRuby::Types::VariableWidth" end |
.variable_width? ⇒ Boolean
8 9 10 |
# File 'lib/crystalruby/types/variable_width.rb', line 8 def self.variable_width? true end |