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

Constant Summary collapse

NAMETYPE =
:member

Instance Attribute Summary collapse

Attributes inherited from Leaf

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

Instance Method Summary collapse

Methods inherited from Leaf

#_set_prefix, #has_annotations?, #is_template?, #lm_name_for_scope, #parsed_name_scope, #replace_prefix, #repo_scopes, #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.



2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
# File 'lib/ridl/node.rb', line 2566

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 RuntimeError, "Anonymous type definitions are not allowed!" if @idltype.is_anonymous?
    ## check for use of incomplete types
    if !@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
            if !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 RuntimeError, "Incomplete type #{@idltype.typename} not allowed here!"
    end
  end
end

Instance Attribute Details

#idltypeObject (readonly)

Returns the value of attribute idltype.



2564
2565
2566
# File 'lib/ridl/node.rb', line 2564

def idltype
  @idltype
end

Instance Method Details

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



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

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

#is_local?(recurstk) ⇒ Boolean

Returns:

  • (Boolean)


2609
2610
2611
# File 'lib/ridl/node.rb', line 2609

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

#marshal_dumpObject



2613
2614
2615
# File 'lib/ridl/node.rb', line 2613

def marshal_dump
  super() << @idltype
end

#marshal_load(vars) ⇒ Object



2617
2618
2619
2620
# File 'lib/ridl/node.rb', line 2617

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