Class: CAStruct::Builder::Member
- Inherits:
-
Object
- Object
- CAStruct::Builder::Member
- Defined in:
- lib/carray/struct_builder.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#byte_length ⇒ Object
readonly
Returns the value of attribute byte_length.
-
#bytes ⇒ Object
readonly
Returns the value of attribute bytes.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#offset ⇒ Object
readonly
Returns the value of attribute offset.
-
#opt ⇒ Object
readonly
Returns the value of attribute opt.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(name, type, opt = {}) ⇒ Member
constructor
:nodoc:.
Constructor Details
#initialize(name, type, opt = {}) ⇒ Member
:nodoc:
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/carray/struct_builder.rb', line 16 def initialize (name, type, opt={}) @name, @type, @opt = name, type, opt if @type == :bitfield # Bit members carry their own offset/length math via the # Builder's bit() method; the standard byte cursor in # member() does not advance for them. Setting byte_length=0 # keeps any defensive byte-loop arithmetic harmless. @bytes = 0 @byte_length = 0 elsif @type.kind_of?(CArray) @type = @type.copy @byte_length = @type.bytes * @type.elements @bytes = 0 else data_type, @bytes = CArray.guess_type_and_bytes(@type, @opt[:bytes]) if data_type == CA_OBJECT raise CAStruct::DefinitionError, "CA_OBJECT cannot be a member of struct or union" end @byte_length = @bytes end @offset = @opt[:offset] end |
Instance Attribute Details
#byte_length ⇒ Object (readonly)
Returns the value of attribute byte_length.
40 41 42 |
# File 'lib/carray/struct_builder.rb', line 40 def byte_length @byte_length end |
#bytes ⇒ Object (readonly)
Returns the value of attribute bytes.
40 41 42 |
# File 'lib/carray/struct_builder.rb', line 40 def bytes @bytes end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
40 41 42 |
# File 'lib/carray/struct_builder.rb', line 40 def name @name end |
#offset ⇒ Object (readonly)
Returns the value of attribute offset.
40 41 42 |
# File 'lib/carray/struct_builder.rb', line 40 def offset @offset end |
#opt ⇒ Object (readonly)
Returns the value of attribute opt.
40 41 42 |
# File 'lib/carray/struct_builder.rb', line 40 def opt @opt end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
40 41 42 |
# File 'lib/carray/struct_builder.rb', line 40 def type @type end |