class IDL::AST::Leaf
def copy_from(template, _)
def copy_from(template, _) @prefix = template.instance_variable_get(:@prefix) @repo_id = template.instance_variable_get(:@repo_id) @repo_ver = template.instance_variable_get(:@repo_ver) @annotations = template.instance_variable_get(:@annotations) self end
def has_annotations?
def has_annotations? !@annotations.empty? end
def initialize(_name, _enclosure)
def initialize(_name, _enclosure) _name ||= '' _name = IDL::Scanner::Identifier.new(_name, _name) unless IDL::Scanner::Identifier === _name @name = _name @lm_name = nil @intern = _name.rjust(1).downcase.intern @enclosure = _enclosure @scopes = if @enclosure then (@enclosure.scopes.dup << self) else [] end @prefix = '' @repo_id = nil @repo_ver = nil @annotations = Annotations.new end
def instantiate(instantiation_context, _enclosure, _params = {})
def instantiate(instantiation_context, _enclosure, _params = {}) (instantiation_context[self] = self.class.new(self.name, _enclosure, _params)).copy_from(self, instantiation_context) end
def is_local?
def is_local? false end
def is_template?
def is_template? @enclosure && @enclosure.is_template? end
def lm_name
def lm_name @lm_name ||= @name.checked_name.dup end
def lm_scopes
def lm_scopes @lm_scopes ||= if @enclosure then (@enclosure.lm_scopes.dup << lm_name) else [] end end
def marshal_dump
def marshal_dump [@name, lm_name, @intern, @enclosure, @scopes, @prefix, @repo_id, @repo_ver, @annotations] end
def marshal_load(vars)
def marshal_load(vars) @name, @lm_name, @intern, @enclosure, @scopes, @prefix, @repo_id, @repo_ver, @annotations = vars @scoped_name = nil @scoped_lm_name = nil @lm_scopes = nil end
def prefix=(pfx)
def prefix=(pfx) unless pfx.to_s.empty? raise 'ID prefix should not start or end with \'/\'' if pfx[0, 1] == '/' or pfx[-1, 1] == '/' raise "ID prefix should not start with one of '#{REPO_ID_XCHARS.join("', '")}'" if REPO_ID_XCHARS.include?(pfx[0, 1]) raise 'Invalid ID prefix! Only a..z, A..Z, 0..9, \'.\', \'-\', \'_\' or \'\/\' allowed' unless REPO_ID_RE =~ pfx end self.set_prefix(pfx) end
def replace_prefix(pfx)
def replace_prefix(pfx) self.prefix = pfx end
def repository_id
def repository_id if @repo_id.nil? @repo_ver = "1.0" unless @repo_ver format("IDL:%s%s:%s", if @prefix.empty? then "" else @prefix + "/" end, self.scopes.collect { |s| s.name }.join("/"), @repo_ver) else @repo_id end end
def resolve(_name)
def resolve(_name) nil end
def scoped_lm_name
def scoped_lm_name @scoped_lm_name ||= lm_scopes.join("::").freeze end
def scoped_name
def scoped_name @scoped_name ||= @scopes.collect { |s| s.name }.join("::").freeze end
def set_prefix(pfx)
def set_prefix(pfx) @prefix = pfx.to_s end
def set_repo_id(id)
def set_repo_id(id) if @repo_id if id != @repo_id raise "#{self.scoped_name} already has a different repository ID assigned: #{@repo_id}" end end id_arr = id.split(':') if @repo_ver if id_arr.first != 'IDL' or id_arr.last != @repo_ver raise "supplied repository ID (#{id}) does not match previously assigned repository version for #{self.scoped_name} = #{@repo_ver}" end end # check validity of IDL format repo IDs if id_arr.first == 'IDL' id_arr.shift id_str = id_arr.shift.to_s raise 'ID identifiers should not start or end with \'/\'' if id_str[0, 1] == '/' or id_str[-1, 1] == '/' raise "ID identifiers should not start with one of '#{REPO_ID_XCHARS.join("', '")}'" if REPO_ID_XCHARS.include?(id_str[0, 1]) raise 'Invalid ID! Only a..z, A..Z, 0..9, \'.\', \'-\', \'_\' or \'\/\' allowed for identifiers' unless REPO_ID_RE =~ id_str end @repo_id = id end
def set_repo_version(ma, mi)
def set_repo_version(ma, mi) ver = "#{ma}.#{mi}" if @repo_ver if ver != @repo_ver raise "#{self.scoped_name} already has a repository version assigned: #{@repo_ver}" end end if @repo_id l = @repo_id.split(':') if l.last != ver raise "supplied repository version (#{ver}) does not match previously assigned repository ID for #{self.scoped_name}: #{@repo_id}" end end @repo_ver = ver end
def typename
def typename self.class.name end
def unescaped_name
def unescaped_name @name.unescaped_name end