Class: CType::Union

Inherits:
StructUnion show all
Defined in:
lib/caphir/ctype.rb

Overview

Struct

Constant Summary collapse

@@unions =
{}

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from StructUnion

#add, #evaluate, get, #get_members, #keyword, #lookup, #to_def, #to_init_s, #to_s

Constructor Details

#initialize(name = nil) ⇒ Union

Returns a new instance of Union.



179
180
181
# File 'lib/caphir/ctype.rb', line 179

def initialize(name = nil)
  super
end

Class Method Details

.[](val = nil) ⇒ Object

factory method



166
167
168
169
170
171
172
173
174
175
# File 'lib/caphir/ctype.rb', line 166

def Union.[](val = nil)
  # for unnamed structures
  return Union.send(:new) unless val

  result = @@unions[val]
  unless result
    result = @@unions[val] = Union.send(:new, val)
  end
  result
end