class IDL::Delegator

Attributes

root[R]
root_namespace[R]

Public Class Methods

add_pragma_handler(key, h = nil, &block) click to toggle source
# File lib/ridl/delegate.rb, line 25
def self.add_pragma_handler(key, h = nil, &block)
  raise 'add_pragma_handler requires a callable object or a block' unless h&.respond_to?(:call) || block_given?

  @@pragma_handlers[key] = block_given? ? block : h
end
get_pragma_handler(key) click to toggle source
# File lib/ridl/delegate.rb, line 31
def self.get_pragma_handler(key)
  @@pragma_handlers[key]
end
new(params = {}) click to toggle source
# File lib/ridl/delegate.rb, line 35
def initialize(params = {})
  @annotation_stack = IDL::AST::Annotations.new
  @includes = {}
  @expand_includes = params[:expand_includes] || false
  @preprocess = params[:preprocess] || false
  @preprocout = params[:output] if @preprocess
  @ignore_pidl = params[:ignore_pidl] || false
  @root_namespace = nil
  unless params[:namespace].nil?
    @root_namespace = IDL::AST::Module.new(params[:namespace], nil, {})
  end
end

Public Instance Methods

declare_attribute(_type, _name, _readonly = false) click to toggle source
# File lib/ridl/delegate.rb, line 686
def declare_attribute(_type, _name, _readonly = false)
  params = {}
  params[:type] = _type
  params[:readonly] = _readonly
  params[:annotations] = @annotation_stack
  @annotation_stack = IDL::AST::Annotations.new
  set_last(@cur.define(IDL::AST::Attribute, _name, params))
end
declare_component(name) click to toggle source
# File lib/ridl/delegate.rb, line 405
def declare_component(name)
  params = {}
  params[:forward] = true
  raise "annotations with forward declaration of #{name} not allowed" unless @annotation_stack.empty?

  set_last
  @cur.define(IDL::AST::Component, name, params)
end
declare_enumerator(_name) click to toggle source
# File lib/ridl/delegate.rb, line 795
def declare_enumerator(_name)
  n = @cur.enumerators.length
  params = {
    value: n,
    enum: @cur
  }
  params[:annotations] = @annotation_stack
  @annotation_stack = IDL::AST::Annotations.new
  set_last(@cur.enclosure.define(IDL::AST::Enumerator, _name, params))
  @cur
end
declare_eventtype(name, attrib = nil) click to toggle source
# File lib/ridl/delegate.rb, line 467
def declare_eventtype(name, attrib = nil)
  params = {}
  params[:abstract] = attrib == :abstract
  params[:forward] = true
  raise "annotations with forward declaration of #{name} not allowed" unless @annotation_stack.empty?

  set_last
  @cur.define(IDL::AST::Eventtype, name, params)
  @cur
end
declare_finder(name, params_, raises_) click to toggle source
# File lib/ridl/delegate.rb, line 552
def declare_finder(name, params_, raises_)
  params = {}
  params[:params] = params_
  params[:raises] = raises_
  params[:annotations] = @annotation_stack
  @annotation_stack = IDL::AST::Annotations.new
  set_last(@cur.define(IDL::AST::Finder, name, params))
  @cur
end
declare_include(s) click to toggle source
# File lib/ridl/delegate.rb, line 230
def declare_include(s)
  params = { filename: s, fullpath: @includes[s].fullpath }
  params[:defined] = false
  params[:preprocessed] = @includes[s].is_preprocessed?
  @cur.define(IDL::AST::Include, "$INC:" + s, params)
end
declare_initializer(name, params_, raises_) click to toggle source
# File lib/ridl/delegate.rb, line 542
def declare_initializer(name, params_, raises_)
  params = {}
  params[:params] = params_
  params[:raises] = raises_
  params[:annotations] = @annotation_stack
  @annotation_stack = IDL::AST::Annotations.new
  set_last(@cur.define(IDL::AST::Initializer, name, params))
  @cur
end
declare_interface(name, attrib = nil) click to toggle source
# File lib/ridl/delegate.rb, line 357
def declare_interface(name, attrib = nil)
  params = {}
  params[:abstract] = attrib == :abstract
  params[:local] = attrib == :local
  params[:forward] = true
  params[:pseudo] = false
  raise "annotations with forward declaration of #{name} not allowed" unless @annotation_stack.empty?

  @cur.define(IDL::AST::Interface, name, params)
  set_last
  @cur
end
declare_member(_type, name) click to toggle source
# File lib/ridl/delegate.rb, line 712
def declare_member(_type, name)
  params = {}
  params[:type] = _type
  params[:annotations] = @annotation_stack
  @annotation_stack = IDL::AST::Annotations.new
  set_last(@cur.define(IDL::AST::Member, name, params))
  @cur
end
declare_op_header(_oneway, _type, _name) click to toggle source
# File lib/ridl/delegate.rb, line 655
def declare_op_header(_oneway, _type, _name)
  params = {}
  params[:oneway] = (_oneway == :oneway)
  params[:type]   = _type
  params[:annotations] = @annotation_stack
  @annotation_stack = IDL::AST::Annotations.new
  set_last
  @cur = @cur.define(IDL::AST::Operation, _name, params)
end
declare_op_parameter(_attribute, _type, _name) click to toggle source
# File lib/ridl/delegate.rb, line 665
def declare_op_parameter(_attribute, _type, _name)
  params = {}
  params[:attribute] = _attribute
  params[:type] = _type
  params[:annotations] = @annotation_stack
  @annotation_stack = IDL::AST::Annotations.new
  set_last(@cur.define(IDL::AST::Parameter, _name, params))
  @cur
end
declare_port(name, porttype, type, multiple = false) click to toggle source
# File lib/ridl/delegate.rb, line 456
def declare_port(name, porttype, type, multiple = false)
  params = {}
  params[:porttype] = porttype
  params[:type] = type
  params[:multiple] = multiple
  params[:annotations] = @annotation_stack
  @annotation_stack = IDL::AST::Annotations.new
  set_last(@cur.define(IDL::AST::Port, name, params))
  @cur
end
declare_state_member(type, name, public_) click to toggle source
# File lib/ridl/delegate.rb, line 524
def declare_state_member(type, name, public_)
  params = {}
  params[:type] = type
  params[:visibility] = (public_ ? :public : :private)
  params[:annotations] = @annotation_stack
  @annotation_stack = IDL::AST::Annotations.new
  set_last(@cur.define(IDL::AST::StateMember, name, params))
  @cur
end
declare_struct(name) click to toggle source
# File lib/ridl/delegate.rb, line 695
def declare_struct(name)
  params = { forward: true }
  raise "annotations with forward declaration of #{name} not allowed" unless @annotation_stack.empty?

  set_last
  @cur.define(IDL::AST::Struct, name, params)
  @cur
end
declare_template_reference(name, type, tpl_params) click to toggle source
# File lib/ridl/delegate.rb, line 347
def declare_template_reference(name, type, tpl_params)
  params = {}
  params[:tpl_type] = type
  params[:tpl_params] = tpl_params || []
  params[:annotations] = @annotation_stack
  @annotation_stack = IDL::AST::Annotations.new
  set_last(@cur.define(IDL::AST::TemplateModuleReference, name, params))
  @cur
end
declare_typedef(_type, _name) click to toggle source
# File lib/ridl/delegate.rb, line 814
def declare_typedef(_type, _name)
  params = {}
  params[:type] = _type
  params[:annotations] = @annotation_stack
  @annotation_stack = IDL::AST::Annotations.new
  set_last(@cur.define(IDL::AST::Typedef, _name, params))
  @cur
end
declare_union(name) click to toggle source
# File lib/ridl/delegate.rb, line 744
def declare_union(name)
  params = { forward: true }
  raise "annotations with forward declaration of #{name} not allowed" unless @annotation_stack.empty?

  set_last
  @cur.define(IDL::AST::Union, name, params)
  @cur
end
declare_valuetype(name, attrib = nil) click to toggle source
# File lib/ridl/delegate.rb, line 491
def declare_valuetype(name, attrib = nil)
  params = {}
  params[:abstract] = attrib == :abstract
  params[:forward] = true
  raise "annotations with forward declaration of #{name} not allowed" unless @annotation_stack.empty?

  set_last
  @cur.define(IDL::AST::Valuetype, name, params)
  @cur
end
define_annotation(annid, annpos, anncomment, annbody) click to toggle source
# File lib/ridl/delegate.rb, line 277
def define_annotation(annid, annpos, anncomment, annbody)
  IDL.log(3, "parsed #{anncomment ? 'commented ' : ''}Annotation #{annid}(#{annbody}) @ #{annpos}")
  if anncomment && @last && (@last_pos.line == annpos.line) && (@last_pos.name == annpos.name)
    IDL.log(3, 'adding annotation to last node')
    @last.annotations << IDL::AST::Annotation.new(annid, annbody)
  else
    IDL.log(3, 'appending annotation cached stack')
    @annotation_stack << IDL::AST::Annotation.new(annid, annbody)
  end
end
define_case(_labels, _type, _name) click to toggle source
# File lib/ridl/delegate.rb, line 768
def define_case(_labels, _type, _name)
  params = {}
  params[:type] = _type
  params[:labels] = _labels
  params[:annotations] = @annotation_stack
  @annotation_stack = IDL::AST::Annotations.new
  set_last(@cur.define(IDL::AST::UnionMember, _name, params))
  @cur
end
define_component(name, base, supports = nil) click to toggle source
# File lib/ridl/delegate.rb, line 414
def define_component(name, base, supports = nil)
  params = {}
  params[:base] = base
  params[:supports] = supports || []
  params[:annotations] = @annotation_stack
  @annotation_stack = IDL::AST::Annotations.new
  set_last
  @cur = @cur.define(IDL::AST::Component, name, params)
end
define_connector(name, base = nil) click to toggle source
# File lib/ridl/delegate.rb, line 429
def define_connector(name, base = nil)
  params = {}
  params[:base] = base
  params[:annotations] = @annotation_stack
  @annotation_stack = IDL::AST::Annotations.new
  set_last
  @cur = @cur.define(IDL::AST::Connector, name, params)
end
define_const(_type, _name, _expression) click to toggle source
# File lib/ridl/delegate.rb, line 647
def define_const(_type, _name, _expression)
  params = { type: _type, expression: _expression }
  params[:annotations] = @annotation_stack
  @annotation_stack = IDL::AST::Annotations.new
  set_last(@cur.define(IDL::AST::Const, _name, params))
  @cur
end
define_enum(_name) click to toggle source
# File lib/ridl/delegate.rb, line 787
def define_enum(_name)
  params = {}
  params[:annotations] = @annotation_stack
  @annotation_stack = IDL::AST::Annotations.new
  set_last
  @cur = @cur.define(IDL::AST::Enum, _name, params)
end
define_eventtype(name, attrib, inherits = {}) click to toggle source
# File lib/ridl/delegate.rb, line 478
def define_eventtype(name, attrib, inherits = {})
  params = {}
  params[:abstract] = attrib == :abstract
  params[:custom] = attrib == :custom
  params[:forward] = false
  params[:inherits] = inherits
  params[:annotations] = @annotation_stack
  @annotation_stack = IDL::AST::Annotations.new
  set_last
  @cur = @cur.define(IDL::AST::Eventtype, name, params)
  @cur
end
define_exception(name) click to toggle source
# File lib/ridl/delegate.rb, line 729
def define_exception(name)
  params = { forward: false }
  params[:annotations] = @annotation_stack
  @annotation_stack = IDL::AST::Annotations.new
  set_last
  @cur = @cur.define(IDL::AST::Exception, name, params)
end
define_home(name, base, component, key = nil, supports = nil) click to toggle source
# File lib/ridl/delegate.rb, line 388
def define_home(name, base, component, key = nil, supports = nil)
  params = {}
  params[:base] = base
  params[:component] = component
  params[:key] = key
  params[:supports] = supports || []
  params[:annotations] = @annotation_stack
  @annotation_stack = IDL::AST::Annotations.new
  set_last
  @cur = @cur.define(IDL::AST::Home, name, params)
end
define_interface(name, attrib, inherits = []) click to toggle source
# File lib/ridl/delegate.rb, line 370
def define_interface(name, attrib, inherits = [])
  params = {}
  params[:abstract] = attrib == :abstract
  params[:local] = attrib == :local
  params[:pseudo] = attrib == :pseudo
  params[:forward] = false
  params[:inherits] = inherits
  params[:annotations] = @annotation_stack
  @annotation_stack = IDL::AST::Annotations.new
  set_last
  @cur = @cur.define(IDL::AST::Interface, name, params)
end
define_module(name) click to toggle source
# File lib/ridl/delegate.rb, line 288
def define_module(name)
  @cur = @cur.define(IDL::AST::Module, name)
  @cur.annotations.concat(@annotation_stack)
  @annotation_stack = IDL::AST::Annotations.new
  set_last
  @cur
end
define_porttype(name) click to toggle source
# File lib/ridl/delegate.rb, line 443
def define_porttype(name)
  params = {}
  params[:annotations] = @annotation_stack
  @annotation_stack = IDL::AST::Annotations.new
  set_last
  @cur = @cur.define(IDL::AST::Porttype, name, params)
end
define_struct(name) click to toggle source
# File lib/ridl/delegate.rb, line 704
def define_struct(name)
  params = { forward: false }
  params[:annotations] = @annotation_stack
  @annotation_stack = IDL::AST::Annotations.new
  set_last
  @cur = @cur.define(IDL::AST::Struct, name, params)
end
define_template_module(global, names) click to toggle source
# File lib/ridl/delegate.rb, line 305
def define_template_module(global, names)
  if global || names.size > 1
    raise "no scoped identifier allowed for template module: #{(global ? '::' : '') + names.join('::')}"
  end

  @cur = @cur.define(IDL::AST::TemplateModule, names[0])
  @cur.annotations.concat(@annotation_stack)
  @annotation_stack = IDL::AST::Annotations.new
  set_last
  @cur
end
define_template_parameter(name, type) click to toggle source
# File lib/ridl/delegate.rb, line 318
def define_template_parameter(name, type)
  if @template_module_name
    tmp = @template_module_name
    @template_module_name = nil # reset
    define_template_module(*tmp)
  end
  params = { type: type }
  params[:annotations] = @annotation_stack
  @annotation_stack = IDL::AST::Annotations.new
  set_last(@cur.define(IDL::AST::TemplateParam, name, params))
  @cur
end
define_typeid(type, tid) click to toggle source
# File lib/ridl/delegate.rb, line 273
def define_typeid(type, tid)
  type.node.set_repo_id(tid.to_s)
end
define_typeprefix(type, pfx) click to toggle source
# File lib/ridl/delegate.rb, line 269
def define_typeprefix(type, pfx)
  type.node.replace_prefix(pfx.to_s)
end
define_union(name) click to toggle source
# File lib/ridl/delegate.rb, line 753
def define_union(name)
  params = { forward: false }
  params[:annotations] = @annotation_stack
  @annotation_stack = IDL::AST::Annotations.new
  set_last
  @cur = @cur.define(IDL::AST::Union, name, params)
end
define_union_switchtype(union_node, switchtype) click to toggle source
# File lib/ridl/delegate.rb, line 761
def define_union_switchtype(union_node, switchtype)
  union_node.set_switchtype(switchtype)
  union_node.annotations.concat(@annotation_stack)
  @annotation_stack = IDL::AST::Annotations.new
  union_node
end
define_valuebox(name, type) click to toggle source
# File lib/ridl/delegate.rb, line 534
def define_valuebox(name, type)
  params = { type: type }
  params[:annotations] = @annotation_stack
  @annotation_stack = IDL::AST::Annotations.new
  set_last(@cur.define(IDL::AST::Valuebox, name, params))
  @cur
end
define_valuetype(name, attrib, inherits = {}) click to toggle source
# File lib/ridl/delegate.rb, line 502
def define_valuetype(name, attrib, inherits = {})
  params = {}
  params[:abstract] = attrib == :abstract
  params[:custom] = attrib == :custom
  params[:forward] = false
  params[:inherits] = inherits
  params[:annotations] = @annotation_stack
  @annotation_stack = IDL::AST::Annotations.new
  set_last
  @cur = @cur.define(IDL::AST::Valuetype, name, params)
  @cur
end
end_component(_node) click to toggle source
# File lib/ridl/delegate.rb, line 424
def end_component(_node)
  set_last(@cur)
  @cur = @cur.enclosure
end
end_connector(_node) click to toggle source
# File lib/ridl/delegate.rb, line 438
def end_connector(_node)
  set_last(@cur)
  @cur = @cur.enclosure
end
end_enum(_node) click to toggle source
# File lib/ridl/delegate.rb, line 807
def end_enum(_node)
  set_last(@cur)
  ret = IDL::Type::ScopedName.new(@cur)
  @cur = @cur.enclosure
  ret
end
end_eventtype(node)
Alias for: end_valuetype
end_exception(_node) click to toggle source
# File lib/ridl/delegate.rb, line 737
def end_exception(_node)
  set_last(@cur)
  ret = IDL::Type::ScopedName.new(@cur)
  @cur = @cur.enclosure
  ret
end
end_home(_node) click to toggle source
# File lib/ridl/delegate.rb, line 400
def end_home(_node)
  set_last(@cur)
  @cur = @cur.enclosure
end
end_interface(_node) click to toggle source
# File lib/ridl/delegate.rb, line 383
def end_interface(_node)
  set_last(@cur)
  @cur = @cur.enclosure # must equals to argument mod
end
end_module(_node) click to toggle source
# File lib/ridl/delegate.rb, line 296
def end_module(_node)
  set_last(@cur)
  @cur = @cur.enclosure # must equals to argument mod
end
Also aliased as: end_template_module
end_porttype(_node) click to toggle source
# File lib/ridl/delegate.rb, line 451
def end_porttype(_node)
  set_last(@cur)
  @cur = @cur.enclosure
end
end_struct(node) click to toggle source
# File lib/ridl/delegate.rb, line 721
def end_struct(node)
  node.defined = true
  set_last(@cur)
  ret = IDL::Type::ScopedName.new(@cur)
  @cur = @cur.enclosure
  ret
end
end_template_module(_node)
Alias for: end_module
end_union(node) click to toggle source
# File lib/ridl/delegate.rb, line 778
def end_union(node)
  node.validate_labels
  node.defined = true
  set_last(@cur)
  ret = IDL::Type::ScopedName.new(@cur)
  @cur = @cur.enclosure
  ret
end
end_valuetype(node) click to toggle source
# File lib/ridl/delegate.rb, line 515
def end_valuetype(node)
  node.defined = true
  set_last(@cur)
  ret = IDL::Type::ScopedName.new(@cur)
  @cur = @cur.enclosure # must equals to argument mod
  ret
end
Also aliased as: end_eventtype
enter_include(s, fullpath) click to toggle source
# File lib/ridl/delegate.rb, line 215
def enter_include(s, fullpath)
  params = { filename: s, fullpath: fullpath }
  params[:defined] = true
  params[:preprocessed] = @preprocess
  @cur = @cur.define(IDL::AST::Include, "$INC:" + s, params)
  @includes[s] = @cur
  set_last
  @cur
end
handle_pragma(pragma_string) click to toggle source
# File lib/ridl/delegate.rb, line 263
def handle_pragma(pragma_string)
  unless @@pragma_handlers.values.reduce(false) { |rc, h| h.call(self, @cur, pragma_string) || rc }
    IDL.log(1, "RIDL - unrecognized pragma encountered: #{pragma_string}.")
  end
end
instantiate_template_module(name, parameters) click to toggle source
# File lib/ridl/delegate.rb, line 331
def instantiate_template_module(name, parameters)
  tmp = @template_module_name
  @template_module_name = nil # reset
  template_type = parse_scopedname(*tmp)
  unless template_type.node.is_a?(IDL::AST::TemplateModule)
    raise "invalid module template specification: #{template_type.node.typename} #{template_type.node.scoped_lm_name}"
  end

  params = { template: template_type.node, template_params: parameters }
  mod_inst = @cur.define(IDL::AST::Module, name, params)
  mod_inst.annotations.concat(@annotation_stack)
  @annotation_stack = IDL::AST::Annotations.new
  set_last(mod_inst.template.instantiate(mod_inst))
  @cur
end
is_included?(s) click to toggle source
# File lib/ridl/delegate.rb, line 211
def is_included?(s)
  @includes.has_key?(s)
end
leave_include() click to toggle source
# File lib/ridl/delegate.rb, line 225
def leave_include
  set_last
  @cur = @cur.enclosure
end
parse_literal(_typestring, _value) click to toggle source
# File lib/ridl/delegate.rb, line 598
def parse_literal(_typestring, _value)
  k = Expression::Value
  case _typestring
  when :boolean
    k.new(Type::Boolean.new, _value)
  when :integer
    _type = [
      Type::Octet,
      Type::Short,
      Type::Long,
      Type::LongLong,
      Type::ULongLong
    ].detect { |t| t::Range === _value }
    if _type.nil?
      raise "it's not a valid integer: #{v.to_s}"
    end

    k.new(_type.new, _value)
  when :string
    k.new(Type::String.new, _value)
  when :wstring
    k.new(Type::WString.new, _value)
  when :char
    k.new(Type::Char.new, _value)
  when :wchar
    k.new(Type::WChar.new, _value)
  when :fixed
    k.new(Type::Fixed.new, _value)
  when :float
    k.new(Type::Float.new, _value)
  else
    raise ParseError, "unknown literal type: #{type}"
  end
end
parse_positive_int(_expression) click to toggle source
# File lib/ridl/delegate.rb, line 633
def parse_positive_int(_expression)
  if _expression.is_template?
    _expression
  else
    if not ::Integer === _expression.value
      raise "must be integer: #{_expression.value.inspect}"
    elsif _expression.value.negative?
      raise "must be positive integer: #{_expression.value}"
    end

    _expression.value
  end
end
parse_scopedname(global, namelist) click to toggle source
# File lib/ridl/delegate.rb, line 562
def parse_scopedname(global, namelist)
  node = root = if global then @root else @cur end
  first = nil
  namelist.each do |nm|
    n = node.resolve(nm)
    if n.nil?
      raise "cannot find type name '#{nm}' in scope '#{node.scoped_name}'"
    end

    node = n
    first = node if first.nil?
  end
  root.introduce(first)
  case node
  when IDL::AST::Module, IDL::AST::TemplateModule,
       IDL::AST::Interface, IDL::AST::Home, IDL::AST::Component,
       IDL::AST::Porttype, IDL::AST::Connector,
       IDL::AST::Struct, IDL::AST::Union, IDL::AST::Typedef,
       IDL::AST::Exception, IDL::AST::Enum,
       IDL::AST::Valuetype, IDL::AST::Valuebox
    Type::ScopedName.new(node)
  when IDL::AST::TemplateParam
    if node.idltype.is_a?(IDL::Type::Const)
      Expression::ScopedName.new(node)
    else
      Type::ScopedName.new(node)
    end
  when IDL::AST::Const
    Expression::ScopedName.new(node)
  when IDL::AST::Enumerator
    Expression::Enumerator.new(node)
  else
    raise "invalid reference to #{node.class.name}: #{node.scoped_name}"
  end
end
post_parse() click to toggle source
# File lib/ridl/delegate.rb, line 76
def post_parse
  if @preprocess
    Marshal.dump([@root, @includes], @preprocout)
  end
end
pragma_id(id, repo_id) click to toggle source
# File lib/ridl/delegate.rb, line 252
def pragma_id(id, repo_id)
  ids = id.split('::')
  global = false
  if ids.first.empty?
    global = true
    ids.shift
  end
  t = parse_scopedname(global, ids)
  t.node.set_repo_id(repo_id)
end
pragma_prefix(s) click to toggle source
# File lib/ridl/delegate.rb, line 237
def pragma_prefix(s)
  @cur.prefix = s
end
pragma_version(id, major, minor) click to toggle source
# File lib/ridl/delegate.rb, line 241
def pragma_version(id, major, minor)
  ids = id.split('::')
  global = false
  if ids.first.empty?
    global = true
    ids.shift
  end
  t = parse_scopedname(global, ids)
  t.node.set_repo_version(major, minor)
end
pre_parse() click to toggle source
# File lib/ridl/delegate.rb, line 50
def pre_parse
  @root = nil
  unless @preprocess || @ignore_pidl
    IDL.backend.lookup_path.each do |be_root|
      pidl_file = File.join(be_root, ORB_PIDL)
      if File.file?(pidl_file) && File.readable?(pidl_file)
        f = File.open(pidl_file, 'r')
        begin
          @root, @includes = Marshal.load(f)
          @cur = @root
        rescue Exception => e
          IDL.error("RIDL - failed to load ORB pidlc [#{e}]\n You probably need to rebuild the bootstrap file (compile orb.idl to orb.pidlc).")
          exit(1)
        ensure
          f.close
        end
        break
      end
    end
    return if @root
  end
  @root = @cur = IDL::AST::Module.new(nil, nil, {}) # global root
  @last = nil
  @last_pos = nil
end
register_template_module_name(name_spec) click to toggle source
# File lib/ridl/delegate.rb, line 301
def register_template_module_name(name_spec)
  @template_module_name = name_spec
end
visit_nodes(walker) click to toggle source
# File lib/ridl/delegate.rb, line 92
def visit_nodes(walker)
  walker.visit_nodes(self)
end
walk_member(m, w) click to toggle source
# File lib/ridl/delegate.rb, line 100
def walk_member(m, w)
  case m
  when IDL::AST::Include
    unless m.is_preprocessed?
      if @expand_includes
        if m.is_defined?
          w.enter_include(m)
          m.walk_members { |cm| walk_member(cm, w) }
          w.leave_include(m)
        end
      else
        w.visit_include(m)
      end
    end
  when IDL::AST::Porttype, IDL::AST::TemplateModule
    # these are template types and do not generally generate
    # code by themselves but only when 'instantiated' (used)
    # in another type
  when IDL::AST::Module
    w.enter_module(m)
    m.walk_members { |cm| walk_member(cm, w) }
    w.leave_module(m)
  when IDL::AST::Interface
    if m.is_forward?
      w.declare_interface(m)
    else
      w.enter_interface(m)
      m.walk_members { |cm| walk_member(cm, w) }
      w.leave_interface(m)
    end
  when IDL::AST::Home
    _te = w.respond_to?(:enter_home)
    _tl = w.respond_to?(:leave_home)
    return unless _te || _tl

    w.enter_home(m) if _te
    m.walk_members { |cm| walk_member(cm, w) }
    w.leave_home(m) if _tl
  when IDL::AST::Component
    if m.is_forward?
      w.declare_component(m) if w.respond_to?(:declare_component)
    else
      _te = w.respond_to?(:enter_component)
      _tl = w.respond_to?(:leave_component)
      return unless _te || _tl

      w.enter_component(m) if _te
      m.walk_members { |cm| walk_member(cm, w) }
      w.leave_component(m) if _tl
    end
  when IDL::AST::Connector
    _te = w.respond_to?(:enter_connector)
    _tl = w.respond_to?(:leave_connector)
    return unless _te || _tl

    w.enter_connector(m) if _te
    m.walk_members { |cm| walk_member(cm, w) }
    w.leave_connector(m) if _tl
  when IDL::AST::Port
    w.visit_port(m) if w.respond_to?(:visit_port)
  when IDL::AST::Valuebox
    w.visit_valuebox(m)
  when IDL::AST::Valuetype, IDL::AST::Eventtype
    if m.is_forward?
      w.declare_valuetype(m)
    else
      w.enter_valuetype(m)
      m.walk_members { |cm| walk_member(cm, w) }
      w.leave_valuetype(m)
    end
  when IDL::AST::Finder
    w.visit_finder(m) if w.respond_to?(:visit_finder)
  when IDL::AST::Initializer
    w.visit_factory(m) if w.respond_to?(:visit_factory)
  when IDL::AST::Const
    w.visit_const(m)
  when IDL::AST::Operation
    w.visit_operation(m)
  when IDL::AST::Attribute
    w.visit_attribute(m)
  when IDL::AST::Exception
    w.enter_exception(m)
    m.walk_members { |cm| walk_member(cm, w) }
    w.leave_exception(m)
  when IDL::AST::Struct
    if m.is_forward?
      w.declare_struct(m)
    else
      w.enter_struct(m)
      m.walk_members { |cm| walk_member(cm, w) }
      w.leave_struct(m)
    end
  when IDL::AST::Union
    if m.is_forward?
      w.declare_union(m)
    else
      w.enter_union(m)
      m.walk_members { |cm| walk_member(cm, w) }
      w.leave_union(m)
    end
  when IDL::AST::Typedef
    w.visit_typedef(m)
  when IDL::AST::Enum
    w.visit_enum(m)
  when IDL::AST::Enumerator
    w.visit_enumerator(m)
  else
    raise "Invalid IDL member type for walkthrough: #{m.class.name}"
  end
end
walk_nodes(walker, root_node = nil) click to toggle source
# File lib/ridl/delegate.rb, line 96
def walk_nodes(walker, root_node = nil)
  (root_node || @root).walk_members { |m| walk_member(m, walker) }
end

Private Instance Methods

set_last(node = nil) click to toggle source
# File lib/ridl/delegate.rb, line 84
def set_last(node = nil)
  @last = node
  @last_pos = @scanner.position.dup if node
  node
end