Class: IDL::AST::Parameter

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

Overview

Const

Constant Summary collapse

NAMETYPE =
:member
ATTRIBUTE_MAP =
{
  :in => IN,
  :out => OUT,
  :inout => INOUT
}

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_local?, #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) ⇒ Parameter

Returns a new instance of Parameter.



2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
# File 'lib/ridl/node.rb', line 2189

def initialize(_name, _enclosure, params)
  super(_name, _enclosure)
  @idltype  = params[:type]
  @attribute = params[:attribute]
  unless ATTRIBUTE_MAP.has_key?(@attribute)
    raise RuntimeError,
      "invalid attribute for parameter: #{params[:attribute]}"
  end
  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?
    if @idltype.is_local?
      if _enclosure.enclosure.is_a?(IDL::AST::Interface) && !_enclosure.enclosure.is_local?
        raise RuntimeError, "Local type #{@idltype.typename} not allowed for operation on unrestricted interface"
      end
      ## IDL_Valuetype: no problem as valuetype operations are local
    end
    if !@idltype.is_complete?
      if _enclosure.enclosure.is_a?(IDL::AST::Interface)
        raise RuntimeError, "Incomplete type #{@idltype.typename} not allowed here!"
      end
      ## IDL_Valuetype: no problem as valuetype operations are local
    end
  end
end

Instance Attribute Details

#idltypeObject (readonly)

Returns the value of attribute idltype.



2188
2189
2190
# File 'lib/ridl/node.rb', line 2188

def idltype
  @idltype
end

Instance Method Details

#attributeObject



2214
2215
2216
# File 'lib/ridl/node.rb', line 2214

def attribute
  ATTRIBUTE_MAP[@attribute]
end

#instantiate(_context, _enclosure) ⇒ Object



2228
2229
2230
2231
2232
2233
2234
# File 'lib/ridl/node.rb', line 2228

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

#marshal_dumpObject



2218
2219
2220
# File 'lib/ridl/node.rb', line 2218

def marshal_dump
  super() << @idltype << @attribute
end

#marshal_load(vars) ⇒ Object



2222
2223
2224
2225
2226
# File 'lib/ridl/node.rb', line 2222

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