class IDL::AST::Port
def attributes
def attributes case @porttype when :port, :mirrorport @idltype.resolved_type.node.attributes.collect { |att| exp_a = att.expanded_copy(self.name, self.enclosure) exp_a.annotations << Annotation.new(EXTPORTDEF_ANNOTATION, { extended_port_name: self.name, base_name: att.name, mirror: (@porttype == :mirrorport) }) exp_a # return expanded copy } else [] end end
def expanded_copy(name_pfx, enc)
def expanded_copy(name_pfx, enc) p = IDL::AST::Port.new("#{name_pfx}_#{self.name}", enc, {type: @idltype, porttype: @porttype}) p.annotations << Annotation.new(EXTPORTDEF_ANNOTATION, { extended_port_name: name_pfx, base_name: self.name, mirror: false }) p # return expanded copy end
def expanded_mirror_copy(name_pfx, enc)
def expanded_mirror_copy(name_pfx, enc) p = IDL::AST::Port.new("#{name_pfx}_#{self.name}", enc, {type: @idltype, porttype: PORT_MIRRORS[@porttype]}) p.annotations << Annotation.new(EXTPORTDEF_ANNOTATION, { extended_port_name: name_pfx, base_name: self.name, mirror: true }) p # return expanded copy end
def initialize(_name, _enclosure, params)
def initialize(_name, _enclosure, params) super(_name, _enclosure) @idltype = params[:type] @porttype = params[:porttype] raise "unknown porttype for #{typename} #{scoped_lm_name}: #{@porttype}" unless PORTTYPES.include?(@porttype) case @porttype when :facet, :receptacle unless @idltype.is_a?(IDL::Type::Object) || (@idltype.is_a?(IDL::Type::NodeType) && (@idltype.is_node?(IDL::AST::Interface) || @idltype.is_node?(IDL::AST::TemplateParam))) raise "invalid type for #{typename} #{scoped_lm_name}: #{@idltype.typename}" end when :port, :mirrorport unless @idltype.is_a?(IDL::Type::NodeType) && (@idltype.is_node?(IDL::AST::Porttype) || @idltype.is_node?(IDL::AST::TemplateParam)) raise "invalid type for #{typename} #{scoped_lm_name}: #{@idltype.typename}" end else unless @idltype.is_a?(IDL::Type::NodeType) && (@idltype.is_node?(IDL::AST::Eventtype) || @idltype.is_node?(IDL::AST::TemplateParam)) raise "invalid type for #{typename} #{scoped_lm_name}: #{@idltype.typename}" end end @multiple = params[:multiple] ? true : false end
def instantiate(instantiation_context, _enclosure)
def instantiate(instantiation_context, _enclosure) _params = { type: @idltype.instantiate(instantiation_context), porttype: @porttype, multiple: @multiple } super(instantiation_context, _enclosure, _params) end
def multiple?
def multiple? @multiple end
def ports
def ports case @porttype when :port @idltype.resolved_type.node.ports.collect { |p| p.expanded_copy(self.name, self.enclosure) } when :mirrorport @idltype.resolved_type.node.ports.collect { |p| p.expanded_mirror_copy(self.name, self.enclosure) } else [self] end end