Class: IDL::AST::Parameter

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

Overview

Const

Constant Summary collapse

IN =
0
OUT =
1
INOUT =
2
ATTRIBUTE_MAP =
{
  in: IN,
  out: OUT,
  inout: INOUT
}

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) ⇒ Parameter

Returns a new instance of Parameter.



2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
# File 'lib/ridl/node.rb', line 2254

def initialize(_name, _enclosure, params)
  super(_name, _enclosure)
  @idltype = params[:type]
  @attribute = params[:attribute]
  unless ATTRIBUTE_MAP.has_key?(@attribute)
    raise "invalid attribute for parameter: #{params[:attribute]}"
  end

  unless @idltype.is_a?(IDL::Type::ScopedName) && @idltype.is_node?(IDL::AST::TemplateParam)
    raise "Anonymous type definitions are not allowed!" if params[:type].is_anonymous?
    raise "Exception #{@idltype.typename} is not allowed in an argument of an operation!" if @idltype.is_node?(IDL::AST::Exception)

    if @idltype.is_local?
      if _enclosure.enclosure.is_a?(IDL::AST::Interface) && !_enclosure.enclosure.is_local?
        raise "Local type #{@idltype.typename} not allowed for operation on unrestricted interface"
      end
      ## IDL_Valuetype: no problem as valuetype operations are local
    end
    unless @idltype.is_complete?
      if _enclosure.enclosure.is_a?(IDL::AST::Interface)
        raise "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.



2252
2253
2254
# File 'lib/ridl/node.rb', line 2252

def idltype
  @idltype
end

Instance Method Details

#attributeObject



2281
2282
2283
# File 'lib/ridl/node.rb', line 2281

def attribute
  ATTRIBUTE_MAP[@attribute]
end

#instantiate(instantiation_context, _enclosure) ⇒ Object



2295
2296
2297
2298
2299
2300
2301
# File 'lib/ridl/node.rb', line 2295

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

#marshal_dumpObject



2285
2286
2287
# File 'lib/ridl/node.rb', line 2285

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

#marshal_load(vars) ⇒ Object



2289
2290
2291
2292
2293
# File 'lib/ridl/node.rb', line 2289

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