Class: CAStruct::Builder::Member

Inherits:
Object
  • Object
show all
Defined in:
lib/carray/struct.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, type, opt = {}) ⇒ Member

:nodoc:



297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
# File 'lib/carray/struct.rb', line 297

def initialize (name, type, opt={})
  @name, @type, @opt = name, type, opt
  if @type.kind_of?(CArray)
    @type = @type.to_ca
    @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 RuntimeError, "CA_OBJECT type can't be a member of struct or union"
    end 
    @byte_length = @bytes
  end
  @offset = @opt[:offset]
end

Instance Attribute Details

#byte_lengthObject (readonly)

Returns the value of attribute byte_length.



313
314
315
# File 'lib/carray/struct.rb', line 313

def byte_length
  @byte_length
end

#bytesObject (readonly)

Returns the value of attribute bytes.



313
314
315
# File 'lib/carray/struct.rb', line 313

def bytes
  @bytes
end

#nameObject (readonly)

Returns the value of attribute name.



313
314
315
# File 'lib/carray/struct.rb', line 313

def name
  @name
end

#offsetObject (readonly)

Returns the value of attribute offset.



313
314
315
# File 'lib/carray/struct.rb', line 313

def offset
  @offset
end

#typeObject (readonly)

Returns the value of attribute type.



313
314
315
# File 'lib/carray/struct.rb', line 313

def type
  @type
end