Class: IDL::AST::Enum

Inherits:
Leaf
  • Object
show all
Defined in:
lib/ridl/node.rb,
lib/ridl/node.rb

Overview

UnionMember

Instance Attribute Summary collapse

Attributes inherited from Leaf

#annotations, #enclosure, #intern, #name, #prefix, #scopes

Instance Method Summary collapse

Methods inherited from Leaf

#has_annotations?, #is_local?, #is_template?, #lm_name, #lm_scopes, #replace_prefix, #repository_id, #resolve, #scoped_lm_name, #scoped_name, #set_repo_id, #set_repo_version, #typename, #unescaped_name

Constructor Details

#initialize(_name, enclosure, params) ⇒ Enum

Returns a new instance of Enum.



2868
2869
2870
2871
2872
2873
2874
2875
# File 'lib/ridl/node.rb', line 2868

def initialize(_name, enclosure, params)
  super(_name, enclosure)
  @enums = []
  @idltype = IDL::Type::Enum.new(self)
  @bitbound = IDL::Type::ULong.new
  @bitbound_bits = 32
  annotations.concat(params[:annotations])
end

Instance Attribute Details

#bitboundObject (readonly)

Returns the value of attribute bitbound.



2866
2867
2868
# File 'lib/ridl/node.rb', line 2866

def bitbound
  @bitbound
end

#bitbound_bitsObject (readonly)

Returns the value of attribute bitbound_bits.



2866
2867
2868
# File 'lib/ridl/node.rb', line 2866

def bitbound_bits
  @bitbound_bits
end

#idltypeObject (readonly)

Returns the value of attribute idltype.



2866
2867
2868
# File 'lib/ridl/node.rb', line 2866

def idltype
  @idltype
end

Instance Method Details

#add_enumerator(n) ⇒ Object



2893
2894
2895
# File 'lib/ridl/node.rb', line 2893

def add_enumerator(n)
  @enums << n
end

#determine_bitboundObject



2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
# File 'lib/ridl/node.rb', line 2897

def determine_bitbound
  bitbound = annotations[:bit_bound].first
  unless bitbound.nil?
    @bitbound_bits = bitbound.fields[:value]
    raise "Missing number of bits for bit_bound annotation for #{name}" if @bitbound_bits.nil?
    raise "Illegal negative bit_bound #{bits} value for #{name}" if @bitbound_bits.negative?
    raise "Illegal zero bit_bound value for #{name}, not #{bits}" if @bitbound_bits.zero?
    raise "Bitbound for #{name} must be <= 32" unless @bitbound_bits <= 32
  end
  @bitbound = IDL::Type::UTinyShort.new if @bitbound_bits.between?(1,8)
  @bitbound = IDL::Type::UShort.new if @bitbound_bits.between?(9,16)
end

#enumeratorsObject



2889
2890
2891
# File 'lib/ridl/node.rb', line 2889

def enumerators
  @enums
end

#instantiate(instantiation_context, _enclosure) ⇒ Object



2910
2911
2912
# File 'lib/ridl/node.rb', line 2910

def instantiate(instantiation_context, _enclosure)
  super(instantiation_context, _enclosure, {})
end

#marshal_dumpObject



2877
2878
2879
# File 'lib/ridl/node.rb', line 2877

def marshal_dump
  super() << @idltype << @bitbound << @bitbound_bits << @enums
end

#marshal_load(vars) ⇒ Object



2881
2882
2883
2884
2885
2886
2887
# File 'lib/ridl/node.rb', line 2881

def marshal_load(vars)
  @enums = vars.pop
  @bitbound = vars.pop
  @bitbound_bits = vars.pop
  @idltype = vars.pop
  super(vars)
end