Example #1
0
    def visitInterface(self, node):
        self.__allInterfaces.append(node)
    
        scopedName = id.Name(node.scopedName())
        
        cxx_fqname = scopedName.fullyQualify()
        impl_flat_name = impl_fullname(scopedName)

        fqname = scopedName.fullyQualify(cxx = 0)

        
        # build methods corresponding to attributes, operations etc.
        # attributes[] and operations[] will contain lists of function
        # signatures eg
        #   [ char *echoString(const char *mesg) ]
        attributes = []

        # we need to consider all callables, including inherited ones
        # since this implementation class is not inheriting from anywhere
        # other than the IDL skeleton
        allInterfaces = [node] + ast.allInherits(node)

        allCallables = []
        for intf in allInterfaces:
            allCallables.extend(intf.callables())

        # declarations[] contains a list of in-class decl signatures
        # implementations[] contains a list of out of line impl signatures
        # (typically differ by classname::)
        declarations = []
        implementations = []
        
        for c in allCallables:
            if isinstance(c, idlast.Attribute):
                attrType = types.Type(c.attrType())

                for i in c.identifiers():
                    attribname = id.mapID(i)
                    returnType = attrType.op(types.RET)
                    inType = attrType.op(types.IN)
                    attributes.append(returnType + " " + attribname + "()")

                    # need a set method if not a readonly attribute
                    if not c.readonly():
                        args = attribname + "(" + inType + ")"
                        declarations.append("void " + args)
                        implementations.append("void " + impl_flat_name +\
                                               "::" + args)
                    declarations.append(returnType + " " + attribname + "()")
                    implementations.append(returnType + " " + impl_flat_name+\
                                           "::" + attribname + "()")

            elif isinstance(c, idlast.Operation):
                params = []
                for p in c.parameters():
                    paramType = types.Type(p.paramType())
                    cxx_type = paramType.op(types.direction(p), use_out = 0)
                    
                    argname = id.mapID(p.identifier())
                    params.append(cxx_type + " " + argname)

                # deal with possible "context"
                if c.contexts() != []:
                    params.append("CORBA::Context_ptr _ctxt")

                return_type = types.Type(c.returnType()).op(types.RET)

                opname = id.mapID(c.identifier())
                arguments = ", ".join(params)
                args = opname + "(" + arguments + ")"
                declarations.append(return_type + " " + args + ";")
                implementations.append(return_type + " " + impl_flat_name +
                                       "::" + args)
            else:
                util.fatalError("Internal error generating interface member")

        # the class definition has no actual code...
        defs = "\n".join(declarations)

        # Output the _i class definition definition
        self.stream.out(template.interface_def,
                        impl_fqname = impl_flat_name,
                        impl_name = impl_flat_name,
                        fq_name = fqname,
                        fq_POA_name = "POA_" + cxx_fqname,
                        operations = defs)

        # Output the implementations of the class methods
        impls = "".join([ """\
%s
{
  // insert code here and remove the warning
  #warning "Code missing in function <%s>"
}

""" % (impl,impl) for impl in implementations ])
               
        self.stream.out(template.interface_code,
                        fqname = fqname,
                        impl_name = impl_flat_name,
                        impl_fqname = impl_flat_name,
                        operations = impls)
Example #2
0
def visitInterface(node):
    ident = node.identifier()

    outer_environment = id.lookup(node)
    environment = outer_environment.enter(ident)

    insideInterface = self.__insideInterface
    self.__insideInterface = 1

    # produce skeletons for types declared here
    for n in node.declarations():
        n.accept(self)

    self.__insideInterface = insideInterface

    # Call descriptor names are of the form:
    #  TAG _ PREFIX _ BASE
    # Tag represents the type of thing {call descriptor, local callback...}
    # Prefix is derived from the first encountered scopedname[1]
    # Base is a counter to uniquify the identifier
    #
    # [1] Since the names are guaranteed unique, the prefix makes the
    #     names used by two different modules disjoint too. Not sure why
    #     as they are not externally visible?

    I = iface.Interface(node)
    I_Helper = iface.I_Helper(I)
    I_Helper.cc(stream)

    # the class itself
    node_name = id.Name(node.scopedName())

    if node.local():
        objref_name = node_name.prefix("_nil_")
    else:
        objref_name = node_name.prefix("_objref_")

    if node.abstract():
        stream.out(template.abstract_interface_duplicate_narrow,
                   name=node_name.fullyQualify())
    else:
        if node.local():
            stream.out(template.local_interface_duplicate_narrow,
                       name=node_name.fullyQualify())
        else:
            stream.out(template.interface_duplicate_narrow,
                       name=node_name.fullyQualify())

        for i in I.allInherits():
            if i.abstract():
                stream.out(template.interface_narrow_abstract,
                           name=node_name.fullyQualify())
                break

    stream.out(template.interface_nil,
               name=node_name.fullyQualify(),
               objref_name=objref_name.unambiguous(environment),
               repoID=node.repoId())

    # Output flattened aliases to inherited classes, to workaround an
    # MSVC bug.
    for i in ast.allInherits(node):
        inherits_name = id.Name(i.scopedName())
        if inherits_name.needFlatName(environment):
            guard_name = inherits_name.guard()
            flat_fqname = inherits_name.flatName()

            if i.local():
                inherits_nil_name = inherits_name.prefix("_nil_")
                nil_flat_fqname = inherits_nil_name.flatName()

                stream.out(template.local_interface_ALIAS,
                           guard_name=guard_name,
                           fqname=inherits_name.fullyQualify(),
                           flat_fqname=flat_fqname,
                           nil_fqname=inherits_nil_name.fullyQualify(),
                           nil_flat_fqname=nil_flat_fqname)

            else:
                inherits_impl_name = inherits_name.prefix("_impl_")
                inherits_objref_name = inherits_name.prefix("_objref_")

                impl_flat_fqname = inherits_impl_name.flatName()
                objref_flat_fqname = inherits_objref_name.flatName()

                stream.out(template.interface_ALIAS,
                           guard_name=guard_name,
                           fqname=inherits_name.fullyQualify(),
                           flat_fqname=flat_fqname,
                           impl_fqname=inherits_impl_name.fullyQualify(),
                           impl_flat_fqname=impl_flat_fqname,
                           objref_fqname=inherits_objref_name.fullyQualify(),
                           objref_flat_fqname=objref_flat_fqname)

    if node.local():
        _nil_I = iface._nil_I(I)
        _nil_I.cc(stream)

    else:
        _objref_I = iface._objref_I(I)
        _objref_I.cc(stream)

        _pof_I = iface._pof_I(I)
        _pof_I.cc(stream)

        _impl_I = iface._impl_I(I)
        _impl_I.cc(stream)

        # BOA compatible skeletons
        if config.state['BOA Skeletons']:
            sk_name = node_name.prefix("_sk_")
            stream.out(template.interface_sk,
                       sk_fqname=sk_name.fullyQualify(),
                       sk_name=sk_name.unambiguous(environment))
Example #3
0
 def allInherits(self):
     return map(lambda x:Interface(x), ast.allInherits(self._node))
Example #4
0
	def visitInterface(self, node):
		self.__allInterfaces.append(node)
	
		scopedName = id.Name(node.scopedName())
		
		cxx_fqname = scopedName.fullyQualify()
		impl_flat_name = impl_fullname(scopedName)

		fqname = scopedName.fullyQualify(cxx = 0)

		
		# build methods corresponding to attributes, operations etc.
		# attributes[] and operations[] will contain lists of function
		# signatures eg
		#   [ char *echoString(const char *mesg) ]
		attributes = []
		operations = []
		virtual_operations = []

		# we need to consider all callables, including inherited ones
		# since this implementation class is not inheriting from anywhere
		# other than the IDL skeleton
		allInterfaces = [node] + ast.allInherits(node)
		allCallables = util.fold( map(lambda x:x.callables(), allInterfaces),
								  [], lambda x, y: x + y )


		# declarations[] contains a list of in-class decl signatures
		# implementations[] contains a list of out of line impl signatures
		# (typically differ by classname::)
		declarations = []
		implementations = []
		
		for c in allCallables:

			if isinstance(c, idlast.Attribute) :
				attrType = types.Type(c.attrType())
				d_attrType = attrType.deref()

				for i in c.identifiers():
					attribname = id.mapID(i)
					returnType = attrType.op(types.RET)
					inType = attrType.op(types.IN)
					attributes.append(returnType + " " + attribname + "()")
					# need a set method if not a readonly attribute
					if not c.readonly():
						args = attribname + "(" + inType + ")"
						declarations.append("void " + args)
						implementations.append("void " + impl_flat_name +\
											   "::" + args)
					if not attribname in self.ignore_operations:
						declarations.append(returnType + " " + attribname + "()")
						implementations.append(returnType + " " + impl_flat_name+\
										   "::" + attribname + "()")
			elif isinstance(c, idlast.Operation):
				params = []
				for p in c.parameters():
					paramType = types.Type(p.paramType())
					cxx_type = paramType.op(types.direction(p), use_out = 0)
					
					argname = id.mapID(p.identifier())
					params.append(cxx_type + " " + argname)

				# deal with possible "context"
				if c.contexts() != []:
					params.append("CORBA::Context_ptr _ctxt")

				return_type = types.Type(c.returnType()).op(types.RET)

				opname = id.mapID(c.identifier())
				if not opname in self.ignore_operations:
					arguments = string.join(params, ", ")
					args = opname + "(" + arguments + ")"
					declarations.append(return_type + " " + args)
					implementations.append(return_type + " " + \
										   impl_flat_name + \
										   "::" + args)
			else:
				util.fatalError("Internal error generating interface member")
				raise "No code for interface member: " + repr(c)

		# the class definition has no actual code...
		defs = string.join(map(lambda x:x + ";\n", declarations), "")

		# Output the class definition of the implementation
		self.stream_h.out(interface_def,
						  impl_fqname = impl_flat_name,
						  impl_name = impl_flat_name,
						  fq_name = fqname,
						  fq_POA_name = "POA_" + cxx_fqname,
						  operations = defs)

		# Output the class methods implementations
		impls = string.join(map(lambda x: x + """\

{
  // Please insert your code here and remove the following warning pragma
#ifndef WIN32
  #warning "Code missing in function <""" + x + """>"
#endif
}

""",
								implementations), "")
		
		self.stream_cpp.out(interface_code,
							fqname = fqname,
							impl_name = impl_flat_name,
							impl_fqname = impl_flat_name,
							operations = impls)
Example #5
0
    def visitInterface(self, node):
        self.__allInterfaces.append(node)

        scopedName = id.Name(node.scopedName())

        cxx_fqname = scopedName.fullyQualify()
        impl_flat_name = impl_fullname(scopedName)

        fqname = scopedName.fullyQualify(cxx=0)

        # build methods corresponding to attributes, operations etc.
        # attributes[] and operations[] will contain lists of function
        # signatures eg
        #   [ char *echoString(const char *mesg) ]
        attributes = []

        # we need to consider all callables, including inherited ones
        # since this implementation class is not inheriting from anywhere
        # other than the IDL skeleton
        allInterfaces = [node] + ast.allInherits(node)

        allCallables = []
        for intf in allInterfaces:
            allCallables.extend(intf.callables())

        # declarations[] contains a list of in-class decl signatures
        # implementations[] contains a list of out of line impl signatures
        # (typically differ by classname::)
        declarations = []
        implementations = []

        for c in allCallables:
            if isinstance(c, idlast.Attribute):
                attrType = types.Type(c.attrType())

                for i in c.identifiers():
                    attribname = id.mapID(i)
                    returnType = attrType.op(types.RET)
                    inType = attrType.op(types.IN)
                    attributes.append(returnType + " " + attribname + "()")

                    # need a set method if not a readonly attribute
                    if not c.readonly():
                        args = attribname + "(" + inType + ")"
                        declarations.append("void " + args)
                        implementations.append("void " + impl_flat_name +\
                                               "::" + args)
                    declarations.append(returnType + " " + attribname + "()")
                    implementations.append(returnType + " " + impl_flat_name+\
                                           "::" + attribname + "()")

            elif isinstance(c, idlast.Operation):
                params = []
                for p in c.parameters():
                    paramType = types.Type(p.paramType())
                    cxx_type = paramType.op(types.direction(p), use_out=0)

                    argname = id.mapID(p.identifier())
                    params.append(cxx_type + " " + argname)

                # deal with possible "context"
                if c.contexts() != []:
                    params.append("CORBA::Context_ptr _ctxt")

                return_type = types.Type(c.returnType()).op(types.RET)

                opname = id.mapID(c.identifier())
                arguments = ", ".join(params)
                args = opname + "(" + arguments + ")"
                declarations.append(return_type + " " + args + ";")
                implementations.append(return_type + " " + impl_flat_name +
                                       "::" + args)
            else:
                util.fatalError("Internal error generating interface member")

        # the class definition has no actual code...
        defs = "\n".join(declarations)

        # Output the _i class definition definition
        self.stream.out(template.interface_def,
                        impl_fqname=impl_flat_name,
                        impl_name=impl_flat_name,
                        fq_name=fqname,
                        fq_POA_name="POA_" + cxx_fqname,
                        operations=defs)

        # Output the implementations of the class methods
        impls = "".join([
            """\
%s
{
  // insert code here and remove the warning
  #warning "Code missing in function <%s>"
}

""" % (impl, impl) for impl in implementations
        ])

        self.stream.out(template.interface_code,
                        fqname=fqname,
                        impl_name=impl_flat_name,
                        impl_fqname=impl_flat_name,
                        operations=impls)
Example #6
0
def visitInterface(node):
    ident = node.identifier()

    outer_environment = id.lookup(node)
    environment = outer_environment.enter(ident)

    insideInterface = self.__insideInterface
    self.__insideInterface = 1

    # produce skeletons for types declared here
    for n in node.declarations():
        n.accept(self)

    self.__insideInterface = insideInterface

    # Call descriptor names are of the form:
    #  TAG _ PREFIX _ BASE
    # Tag represents the type of thing {call descriptor, local callback...}
    # Prefix is derived from the first encountered scopedname[1]
    # Base is a counter to uniquify the identifier
    #
    # [1] Since the names are guaranteed unique, the prefix makes the
    #     names used by two different modules disjoint too. Not sure why
    #     as they are not externally visible?

    I = omniidl_be.cxx.iface.Interface(node)
    I_Helper = omniidl_be.cxx.iface.instance("I_Helper")(I)
    I_Helper.cc(stream)


    # the class itself
    node_name = id.Name(node.scopedName())

    if node.local():
        objref_name = node_name.prefix("_nil_")
    else:
        objref_name = node_name.prefix("_objref_")

    if node.abstract():
        stream.out(template.abstract_interface_duplicate_narrow,
                   name = node_name.fullyQualify())
    else:
        if node.local():
            stream.out(template.local_interface_duplicate_narrow,
                       name = node_name.fullyQualify())
        else:
            stream.out(template.interface_duplicate_narrow,
                       name = node_name.fullyQualify())

        for i in I.allInherits():
            if i.abstract():
                stream.out(template.interface_narrow_abstract,
                           name = node_name.fullyQualify())
                break

    stream.out(template.interface_nil,
               name = node_name.fullyQualify(),
               objref_name = objref_name.unambiguous(environment),
               repoID = node.repoId())

    # Output flattened aliases to inherited classes, to workaround an
    # MSVC bug.
    for i in ast.allInherits(node):
        inherits_name = id.Name(i.scopedName())
        if inherits_name.needFlatName(environment):
            guard_name = inherits_name.guard()
            flat_fqname = inherits_name.flatName()

            if i.local():
                inherits_nil_name  = inherits_name.prefix("_nil_")
                nil_flat_fqname    = inherits_nil_name.flatName()

                stream.out(template.local_interface_ALIAS,
                           guard_name = guard_name,
                           fqname = inherits_name.fullyQualify(),
                           flat_fqname = flat_fqname,
                           nil_fqname = inherits_nil_name.fullyQualify(),
                           nil_flat_fqname = nil_flat_fqname)

            else:
                inherits_impl_name   = inherits_name.prefix("_impl_")
                inherits_objref_name = inherits_name.prefix("_objref_")

                impl_flat_fqname   = inherits_impl_name.flatName()
                objref_flat_fqname = inherits_objref_name.flatName()

                stream.out(template.interface_ALIAS,
                           guard_name = guard_name,
                           fqname = inherits_name.fullyQualify(),
                           flat_fqname = flat_fqname,
                           impl_fqname = inherits_impl_name.fullyQualify(),
                           impl_flat_fqname = impl_flat_fqname,
                           objref_fqname = inherits_objref_name.fullyQualify(),
                           objref_flat_fqname = objref_flat_fqname)

    if node.local():
        _nil_I = omniidl_be.cxx.iface.instance("_nil_I")(I)
        _nil_I.cc(stream)

    else:
        _objref_I = omniidl_be.cxx.iface.instance("_objref_I")(I)
        _objref_I.cc(stream)

        _pof_I = omniidl_be.cxx.iface.instance("_pof_I")(I)
        _pof_I.cc(stream)

        _impl_I = omniidl_be.cxx.iface.instance("_impl_I")(I)
        _impl_I.cc(stream)


        # BOA compatible skeletons
        if config.state['BOA Skeletons']:
            sk_name = node_name.prefix("_sk_")
            stream.out(template.interface_sk,
                       sk_fqname = sk_name.fullyQualify(),
                       sk_name = sk_name.unambiguous(environment))
Example #7
0
    def visitInterface(self, node):
        self.__allInterfaces.append(node)
        # listed scope and interface name
        dict = self.createDecl('interface')
        self.createInterfaceIdent(dict, node)
        self.createInterfaceFileInfo(dict, node)

        dict['inherits'] = []
        for ihnode in ast.allInherits(node):
            idict = self.createDecl('inherit')
            self.createInterfaceIdent(idict, ihnode)
            self.createInterfaceFileInfo(idict, ihnode)
            dict['inherits'].append(idict)

        env = id.lookup(node)

        allInterfaces = [node]# + ast.allInherits(node)
        allCallables = util.fold( map(lambda x:x.callables(), allInterfaces),
                                  [], lambda x, y: x + y )

        dict['operations'] = []
        dict['attributes'] = []
        for c in allCallables:
            if isinstance(c, idlast.Attribute):
                attrType = types.Type(c.attrType())
                d_attrType = attrType.deref()
                (corba_atype, local_atype, is_primitive) = self.getType(attrType)

                for i in c.identifiers():
                    ident = id.mapID(i)
                    returnType = attrType.op(types.RET)
                    inType = attrType.op(types.IN)

                    adict = createDecl('attribute')
                    cdict = adict['corba']
                    ldict = adict['local']
                    cdict['base_type'] = corba_atype;
                    ldict['base_type'] = local_atype
                    cdict['name'] = ident
                    adict['return'] = self.createReturn(c)
                    adict['arg'] = {}
                    self.createArg(adict['arg'], attrType, False)

                    dict['attributes'].append(adict)
                    if c.readonly():
                        dict['readonly'] = 'yes'
                    dict['attributes'].append(gdict)

            elif isinstance(c, idlast.Operation):
                # operations
                op_dict           = self.createOperation(c)
                op_dict['return'] = self.createReturn(c)
                op_dict['args']   = self.createArgs(c, env)
                dict['operations'].append(op_dict)
            else:
                util.fatalError("Internal error generating interface member")
                raise "No code for interface member: " + repr(c)

#        self.dict['interfaces'].append(dict)
        self.dict['tree'].append(dict)
        return
Example #8
0
 def allInherits(self):
     return [Interface(x) for x in ast.allInherits(self._node)]
Example #9
0
 def allInherits(self):
     return [Interface(x) for x in ast.allInherits(self._node)]
Example #10
0
 def allInherits(self):
     return map(lambda x:Interface(x), ast.allInherits(self._node))
Example #11
0
	def visitInterface(self, node):
		self.__allInterfaces.append(node)
	
		scopedName = id.Name(node.scopedName())
		
		cxx_fqname = scopedName.fullyQualify()
		impl_flat_name = impl_fullname(scopedName)

		fqname = scopedName.fullyQualify(cxx = 0)

		
		# build methods corresponding to attributes, operations etc.
		# attributes[] and operations[] will contain lists of function
		# signatures eg
		#   [ char *echoString(const char *mesg) ]
		attributes = []
		operations = []
		virtual_operations = []

		# we need to consider all callables, including inherited ones
		# since this implementation class is not inheriting from anywhere
		# other than the IDL skeleton
		allInterfaces = [node] + ast.allInherits(node)
		allCallables = util.fold( map(lambda x:x.callables(), allInterfaces),
								  [], lambda x, y: x + y )


		# declarations[] contains a list of in-class decl signatures
		# implementations[] contains a list of out of line impl signatures
		# (typically differ by classname::)
		declarations = []
		implementations = []
		
		for c in allCallables:

			if isinstance(c, idlast.Attribute) :
				attrType = types.Type(c.attrType())
				d_attrType = attrType.deref()

				for i in c.identifiers():
					attribname = id.mapID(i)
					returnType = attrType.op(types.RET)
					inType = attrType.op(types.IN)
					attributes.append(returnType + " " + attribname + "()")
					# need a set method if not a readonly attribute
					if not c.readonly():
						args = attribname + "(" + inType + ")"
						declarations.append("void " + args)
						implementations.append("void " + impl_flat_name +\
											   "::" + args)
					if not attribname in self.ignore_operations:
						declarations.append(returnType + " " + attribname + "()")
						implementations.append(returnType + " " + impl_flat_name+\
										   "::" + attribname + "()")
			elif isinstance(c, idlast.Operation):
				params = []
				for p in c.parameters():
					paramType = types.Type(p.paramType())
					cxx_type = paramType.op(types.direction(p), use_out = 0)
					
					argname = id.mapID(p.identifier())
					params.append(cxx_type + " " + argname)

				# deal with possible "context"
				if c.contexts() != []:
					params.append("CORBA::Context_ptr _ctxt")

				return_type = types.Type(c.returnType()).op(types.RET)

				opname = id.mapID(c.identifier())
				if not opname in self.ignore_operations:
					arguments = string.join(params, ", ")
					args = opname + "(" + arguments + ")"
					declarations.append(return_type + " " + args)
					implementations.append(return_type + " " + \
										   impl_flat_name + \
										   "::" + args)
			else:
				util.fatalError("Internal error generating interface member")
				raise "No code for interface member: " + repr(c)

		# the class definition has no actual code...
		defs = string.join(map(lambda x:x + ";\n", declarations), "")

		# Output the class definition of the implementation
		self.stream_h.out(interface_def,
						  impl_fqname = impl_flat_name,
						  impl_name = impl_flat_name,
						  fq_name = fqname,
						  fq_POA_name = "POA_" + cxx_fqname,
						  operations = defs)

		# Output the class methods implementations
		impls = string.join(map(lambda x: x + """\

{
  // Please insert your code here and remove the following warning pragma
#ifndef WIN32
  #warning "Code missing in function <""" + x + """>"
#endif
}

""",
								implementations), "")
		
		self.stream_cpp.out(interface_code,
							fqname = fqname,
							impl_name = impl_flat_name,
							impl_fqname = impl_flat_name,
							operations = impls)