Class: IDL::AST::Home
- Inherits:
-
ComponentBase
- Object
- Leaf
- Node
- Derivable
- ComponentBase
- IDL::AST::Home
- Defined in:
- lib/ridl/node.rb,
lib/ridl/node.rb
Overview
ComponentBase
Constant Summary collapse
- DEFINABLE =
[IDL::AST::Const, IDL::AST::Operation, IDL::AST::Attribute, IDL::AST::Initializer, IDL::AST::Finder, IDL::AST::Struct, IDL::AST::Union, IDL::AST::Typedef, IDL::AST::Enum, IDL::AST::Enumerator]
Instance Attribute Summary collapse
-
#component ⇒ Object
readonly
Returns the value of attribute component.
-
#primarykey ⇒ Object
readonly
Returns the value of attribute primarykey.
Attributes inherited from ComponentBase
Attributes inherited from Leaf
#annotations, #enclosure, #intern, #name, #prefix, #scopes
Instance Method Summary collapse
- #attributes(include_bases = false, traversed = nil) ⇒ Object
-
#initialize(_name, _enclosure, params) ⇒ Home
constructor
A new instance of Home.
- #instantiate(instantiation_context, _enclosure) ⇒ Object
- #marshal_dump ⇒ Object
- #marshal_load(vars) ⇒ Object
- #operations(include_bases = false, traversed = nil) ⇒ Object
- #set_component_and_key(comp, key) ⇒ Object
Methods inherited from ComponentBase
#add_interfaces, #ancestors, #has_base?, #has_support?, #redefine, #set_base, #supports?
Methods inherited from Derivable
#has_ancestor?, #search_self, #search_self_before_derived
Methods inherited from Node
#define, #introduce, #is_definable?, #match_members, #redefine, #replace_prefix, #resolve, #select_members, #undo_introduction, #walk_members
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) ⇒ Home
1330 1331 1332 1333 1334 1335 1336 1337 1338 |
# File 'lib/ridl/node.rb', line 1330 def initialize(_name, _enclosure, params) @component = nil @resolved_comp = nil @primarykey = nil @resolved_pk = nil @idltype = IDL::Type::Home.new(self) super(_name, _enclosure, params) set_component_and_key(params[:component], params[:primarykey]) end |
Instance Attribute Details
#component ⇒ Object (readonly)
Returns the value of attribute component.
1328 1329 1330 |
# File 'lib/ridl/node.rb', line 1328 def component @component end |
#primarykey ⇒ Object (readonly)
Returns the value of attribute primarykey.
1328 1329 1330 |
# File 'lib/ridl/node.rb', line 1328 def primarykey @primarykey end |
Instance Method Details
#attributes(include_bases = false, traversed = nil) ⇒ Object
1392 1393 1394 1395 1396 |
# File 'lib/ridl/node.rb', line 1392 def attributes(include_bases = false, traversed = nil) atts = @children.find_all { |c| c.is_a?(IDL::AST::Attribute) } atts.concat(base_attributes(traversed || [])) if include_bases atts end |
#instantiate(instantiation_context, _enclosure) ⇒ Object
1352 1353 1354 1355 1356 1357 1358 1359 |
# File 'lib/ridl/node.rb', line 1352 def instantiate(instantiation_context, _enclosure) _params = { component: IDL::AST::TemplateParam.concrete_param(instantiation_context, @component), primarykey: @primarykey ? IDL::AST::TemplateParam.concrete_param(instantiation_context, @primarykey) : @primarykey } # instantiate concrete home def and validate super(instantiation_context, _enclosure, _params) end |
#marshal_dump ⇒ Object
1340 1341 1342 |
# File 'lib/ridl/node.rb', line 1340 def marshal_dump super() << @component << @resolved_comp << @primarykey << @resolved_pk end |
#marshal_load(vars) ⇒ Object
1344 1345 1346 1347 1348 1349 1350 |
# File 'lib/ridl/node.rb', line 1344 def marshal_load(vars) @resolved_pk = vars.pop @primarykey = vars.pop @resolved_comp = vars.pop @component = vars.pop super(vars) end |
#operations(include_bases = false, traversed = nil) ⇒ Object
1386 1387 1388 1389 1390 |
# File 'lib/ridl/node.rb', line 1386 def operations(include_bases = false, traversed = nil) ops = @children.find_all { |c| c.is_a?(IDL::AST::Operation) } ops.concat(base_operations(traversed || [])) if include_bases ops end |
#set_component_and_key(comp, key) ⇒ Object
1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 |
# File 'lib/ridl/node.rb', line 1361 def set_component_and_key(comp, key) unless comp&.is_a?(IDL::Type::ScopedName) && comp.is_node?(IDL::AST::TemplateParam) unless comp&.is_a?(IDL::Type::ScopedName) && comp.is_node?(IDL::AST::Component) raise (comp ? "invalid managed component for #{typename} #{scoped_lm_name}: #{comp.typename}" : "missing managed component specification for #{typename} #{scoped_lm_name}") end unless comp.resolved_type.node.is_defined? raise "#{scoped_lm_name}: #{comp.typename} cannot manage forward declared component #{comp.node.scoped_lm_name}" end @resolved_comp = comp.resolved_type.node end unless key&.is_a?(IDL::Type::ScopedName) && key.is_node?(IDL::AST::TemplateParam) ## TODO : add check for Components::PrimaryKeyBase base type unless key.nil? || (key.is_a?(IDL::Type::ScopedName) && key.is_node?(IDL::AST::Valuetype)) raise "invalid primary key for #{typename} #{scoped_lm_name}: #{key.typename}" end @resolved_pk = key.resolved_type.node if key end @component = comp.node @primarykey = key.node if key end |