Class: IDL::AST::StateMember

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

Overview

Eventtype

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

Constructor Details

#initialize(_name, _enclosure, params) ⇒ StateMember

Returns a new instance of StateMember.



1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
# File 'lib/ridl/node.rb', line 1971

def initialize(_name, _enclosure, params)
  @is_recursive = false
  @has_incomplete_type = false
  super(_name, _enclosure)
  @idltype  = params[:type]
  @visibility = (params[:visibility] == :public ? :public : :private)
  unless @idltype.is_a?(IDL::Type::ScopedName) && @idltype.is_node?(IDL::AST::TemplateParam)
    raise RuntimeError, "Anonymous type definitions are not allowed!" if params[:type].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/valuetype 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
          end
          if mtype.resolved_type.is_a?(IDL::Type::Valuetype)
            # mark member as using an incomplete valuetype; allowed but needs special care
            @has_incomplete_type = true
            return
          end
        end
      elsif @idltype.resolved_type.is_a?(IDL::Type::Valuetype)
        mtype = @idltype.resolved_type
        enc = _enclosure
        while enc.is_a?(IDL::AST::Struct) || enc.is_a?(IDL::AST::Union) || enc.is_a?(IDL::AST::Valuetype)
          if enc.is_a?(IDL::AST::Valuetype) && enc.scoped_name == mtype.node.scoped_name
            ## statemember using recursive valuetype
            ## is enclosed in valuetype itself as part of constructed type
            ## which is allowed and not a problem
            @is_recursive = true
            ## mark enclosure as recursive
            enc.recursive = true
            return
          end
          enc = enc.enclosure
        end
        # mark member as using an incomplete valuetype; allowed but needs special care
        @has_incomplete_type = true
        return
      end
      raise RuntimeError, "Incomplete type #{@idltype.typename} not allowed here!"
    end
  end
end

Instance Attribute Details

#idltypeObject (readonly)

Returns the value of attribute idltype.



1970
1971
1972
# File 'lib/ridl/node.rb', line 1970

def idltype
  @idltype
end

#visibilityObject (readonly)

Returns the value of attribute visibility.



1970
1971
1972
# File 'lib/ridl/node.rb', line 1970

def visibility
  @visibility
end

Instance Method Details

#has_incomplete_type?Boolean

Returns:

  • (Boolean)


2071
2072
2073
# File 'lib/ridl/node.rb', line 2071

def has_incomplete_type?
  @has_incomplete_type
end

#instantiate(_context, _enclosure) ⇒ Object



2051
2052
2053
2054
2055
2056
2057
# File 'lib/ridl/node.rb', line 2051

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

#is_local?(recurstk) ⇒ Boolean

Returns:

  • (Boolean)


2059
2060
2061
# File 'lib/ridl/node.rb', line 2059

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

#is_public?Boolean

Returns:

  • (Boolean)


2063
2064
2065
# File 'lib/ridl/node.rb', line 2063

def is_public?
  @visibility == :public
end

#is_recursive?Boolean

Returns:

  • (Boolean)


2067
2068
2069
# File 'lib/ridl/node.rb', line 2067

def is_recursive?
  @is_recursive
end

#marshal_dumpObject



2039
2040
2041
# File 'lib/ridl/node.rb', line 2039

def marshal_dump
  super() << @idltype << @visibility << @is_recursive << @has_incomplete_type
end

#marshal_load(vars) ⇒ Object



2043
2044
2045
2046
2047
2048
2049
# File 'lib/ridl/node.rb', line 2043

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