Class: IDL::AST::Member

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

Overview

Exception

Direct Known Subclasses

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_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) ⇒ Member

Returns a new instance of Member.



2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
# File 'lib/ridl/node.rb', line 2627

def initialize(_name, _enclosure, params)
  super(_name, _enclosure)
  @idltype = params[:type]
  unless @idltype.is_a?(IDL::Type::ScopedName) && @idltype.is_node?(IDL::AST::TemplateParam)
    raise "Anonymous type definitions are not allowed!" if @idltype.is_anonymous?
    raise "Exception #{@idltype.typename} is not allowed as member!" if @idltype.is_node?(IDL::AST::Exception)

    ## check for use of incomplete types
    unless @idltype.is_complete?
      ## verify type is used in sequence
      if @idltype.resolved_type.is_a? IDL::Type::Sequence
        ## find the (non-sequence) elementtype
        seq_ = @idltype.resolved_type
        mtype = seq_.basetype
        while mtype.resolved_type.is_a? IDL::Type::Sequence
          seq_ = mtype.resolved_type
          mtype = seq_.basetype
        end
        ## is it an incomplete struct, union or valuetype?
        if mtype.is_a? IDL::Type::ScopedName
          case mtype.resolved_type
          when IDL::Type::Struct, IDL::Type::Union, IDL::Type::Valuetype
            unless mtype.node.is_defined?
              ## check if incomplete struct/union is contained within definition of self
              enc = _enclosure
              while enc.is_a?(IDL::AST::Struct) || enc.is_a?(IDL::AST::Union) || enc.is_a?(IDL::AST::Valuetype)
                if enc.scoped_name == mtype.node.scoped_name
                  ## mark enclosure as recursive
                  enc.recursive = true
                  ## mark sequence as recursive type !!! DEPRECATED !!!; leave till R2CORBA updated
                  seq_.recursive = true
                  return
                end
                enc = enc.enclosure
              end
            end
            return # incomplete types in sequences allowed
          end
        end
      end
      raise "Incomplete type #{@idltype.typename} not allowed here!"
    end
  end
end

Instance Attribute Details

#idltypeObject (readonly)

Returns the value of attribute idltype.



2625
2626
2627
# File 'lib/ridl/node.rb', line 2625

def idltype
  @idltype
end

Instance Method Details

#instantiate(instantiation_context, _enclosure, _params = {}) ⇒ Object



2685
2686
2687
2688
2689
2690
# File 'lib/ridl/node.rb', line 2685

def instantiate(instantiation_context, _enclosure, _params = {})
  _params.merge!({
    type: @idltype.instantiate(instantiation_context)
  })
  super(instantiation_context, _enclosure, _params)
end

#is_local?(recurstk) ⇒ Boolean

Returns:

  • (Boolean)


2672
2673
2674
# File 'lib/ridl/node.rb', line 2672

def is_local?(recurstk)
  idltype.is_local?(recurstk)
end

#marshal_dumpObject



2676
2677
2678
# File 'lib/ridl/node.rb', line 2676

def marshal_dump
  super() << @idltype
end

#marshal_load(vars) ⇒ Object



2680
2681
2682
2683
# File 'lib/ridl/node.rb', line 2680

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