Пример #1
0
    def callables(self):
        """Return a list of Callable objects representing the combined operations
       and attributes for this interface"""

        if hasattr(self, "_callables"):
            return self._callables

        # build a list of all the Callable objects
        # The old backend processed all operations first
        # (FIXME: duplicate for the sake of easy checking)
        self._callables = []

        for c in self._node.callables():
            if isinstance(c, idlast.Operation):
                self._callables.append(call.operation(self, c))

        for c in self._node.callables():
            if isinstance(c, idlast.Attribute):
                self._callables = self._callables + call.read_attributes(
                    self, c)
                if c.readonly(): continue
                self._callables = self._callables + call.write_attributes(
                    self, c)

        return self._callables
Пример #2
0
    def ami_callables(self):
        """
        Return a list of Callable objects representing the AMI
        pseudo-operations for this interface.
        """
        if self._ami_callables is not None:
            return self._ami_callables
        
        self._ami_callables = []

        if not hasattr(self._node, "_ami_ops"):
            return self._ami_callables

        for c in self._node._ami_ops:
            self._ami_callables.append(call.operation(self, c))
            
        return self._ami_callables
Пример #3
0
    def ami_callables(self):
        """
        Return a list of Callable objects representing the AMI
        pseudo-operations for this interface.
        """
        if self._ami_callables is not None:
            return self._ami_callables

        self._ami_callables = []

        if not hasattr(self._node, "_ami_ops"):
            return self._ami_callables

        for c in self._node._ami_ops:
            self._ami_callables.append(call.operation(self, c))

        return self._ami_callables
Пример #4
0
    def callables(self):
        """
        Return a list of Callable objects representing the combined
        operations and attributes for this interface
        """
        if self._callables is not None:
            return self._callables
        
        # build a list of all the Callable objects
        self._callables = []

        for c in self._node.callables():
            if isinstance(c, idlast.Operation):
                self._callables.append(call.operation(self, c))
            else:
                self._callables.extend(call.read_attributes(self, c))
                if not c.readonly():
                    self._callables.extend(call.write_attributes(self, c))
            
        return self._callables
Пример #5
0
    def callables(self):
        """
        Return a list of Callable objects representing the combined
        operations and attributes for this interface
        """
        if self._callables is not None:
            return self._callables

        # build a list of all the Callable objects
        self._callables = []

        for c in self._node.callables():
            if isinstance(c, idlast.Operation):
                self._callables.append(call.operation(self, c))
            else:
                self._callables.extend(call.read_attributes(self, c))
                if not c.readonly():
                    self._callables.extend(call.write_attributes(self, c))

        return self._callables
Пример #6
0
  def callables(self):
    """Return a list of Callable objects representing the combined operations
       and attributes for this interface"""
    
    if hasattr(self, "_callables"):
      return self._callables
    
    # build a list of all the Callable objects
    # The old backend processed all operations first
    # (FIXME: duplicate for the sake of easy checking)
    self._callables = []

    for c in self._node.callables():
      if isinstance(c, idlast.Operation):
        self._callables.append(call.operation(self, c))
        
    for c in self._node.callables():
      if isinstance(c, idlast.Attribute):
        self._callables = self._callables + call.read_attributes(self, c)
        if c.readonly(): continue
        self._callables = self._callables + call.write_attributes(self, c)
      
    return self._callables
Пример #7
0
    def cc(self, stream):

        def _ptrToObjRef_ptr(self = self, stream = stream):
            has_abstract = self.interface().abstract()

            for i in self.interface().allInherits():
                if i.abstract(): has_abstract = 1

                stream.out(skel_template.interface_objref_repoID_ptr,
                           inherits_fqname = i.name().fullyQualify())

            if has_abstract:
                stream.out(skel_template.interface_objref_repoID_ptr,
                           inherits_fqname = "CORBA::AbstractBase")

        def _ptrToObjRef_str(self = self, stream = stream):
            has_abstract = self.interface().abstract()

            for i in self.interface().allInherits():
                if i.abstract(): has_abstract = 1

                stream.out(skel_template.interface_objref_repoID_str,
                           inherits_fqname = i.name().fullyQualify())

            if has_abstract:
                stream.out(skel_template.interface_objref_repoID_str,
                           inherits_fqname = "CORBA::AbstractBase")

        #
        # Build the inherits list
        
        inherits_str_list = []
        for i in self.interface().inherits():
            objref_name = i.name().prefix("_objref_")

            objref_str = objref_name.unambiguous(self._environment)

            if objref_name.needFlatName(self._environment):
                objref_str = objref_name.flatName()

            this_inherits_str = objref_str + "(ior, id)"
            inherits_str_list.append(this_inherits_str)

        inherits_str = ",\n".join(inherits_str_list)
        if inherits_str:
            comma = ","
        else:
            comma = ""

        if config.state['Shortcut']:
            inherits_str  = inherits_str + ","
            init_shortcut = "_shortcut(0)"
        else:
            init_shortcut = ""

        if config.state['Shortcut'] == 2:
            release_shortcut = skel_template.interface_release_refcount_shortcut
        else:
            release_shortcut = ""

        stream.out(skel_template.interface_objref,
                   name             = self.interface().name().fullyQualify(),
                   fq_objref_name   = self.name().fullyQualify(),
                   objref_name      = self.name().simple(),
                   inherits_str     = inherits_str,
                   comma            = comma,
                   _ptrToObjRef_ptr = _ptrToObjRef_ptr,
                   _ptrToObjRef_str = _ptrToObjRef_str,
                   init_shortcut    = init_shortcut,
                   release_shortcut = release_shortcut)


        #
        # Shortcut

        shortcut_mode = config.state['Shortcut']

        if shortcut_mode:
            inherited = output.StringStream()
            for i in self.interface().inherits():
                objref_name = i.name().prefix("_objref_")

                objref_str = objref_name.unambiguous(self._environment)

                if objref_name.needFlatName(self._environment):
                    objref_str = objref_name.flatName()

                inherited.out(skel_template.interface_shortcut_inh,
                              parent=objref_str)
                
            if shortcut_mode == 1:
                tmpl = skel_template.interface_shortcut
            else:
                tmpl = skel_template.interface_shortcut_refcount
                
            stream.out(tmpl,
                       name           = self.interface().name().fullyQualify(),
                       basename       = self.interface().name().simple(),
                       fq_objref_name = self.name().fullyQualify(),
                       inherited      = str(inherited))


        #
        # AMI poller

        poller           = self.interface().amiPoller()
        poller_impl_name = None
        poller_methods   = {}
        
        if poller is not None:
            astdecl = poller.astdecl()

            poller_impl_name = descriptor.ami_poller_impl(poller.name())
            poller_class = AMIPoller(poller_impl_name)

            method_decls      = []
            inherited_methods = []
            direct_callables  = astdecl.callables()

            for c in astdecl.all_callables():
                op = call.operation(poller, c)
                method_decl = _impl_Method(op, poller_class)
                method_decls.append(method_decl.hh())

                if c not in direct_callables:
                    inherited_methods.append(method_decl)
                else:
                    poller_methods[op.operation_name()] = method_decl

            stream.out(skel_template.interface_ami_poller_impl,
                       poller_impl_name = poller_impl_name,
                       poller_name      = poller.name().fullyQualify(),
                       method_decls     = "\n".join(method_decls))

            for method in inherited_methods:
                method.cc(stream, "_wrongOperation();")


        #
        # Methods

        ami_descriptors = {}

        for method in self.methods():
            callable = self._callables[method]

            # signature is a text string form of the complete
            # operation signature
            signature = callable.signature()

            # we only need one descriptor for each _signature_ (not operation)

            if signature in _proxy_call_descriptors:
                call_descriptor = _proxy_call_descriptors[signature]
            else:
                call_descriptor = call.CallDescriptor(signature, callable)
                call_descriptor.out_desc(stream)
                _proxy_call_descriptors[signature] = call_descriptor

            # produce a localcall function
            node_name = self.interface().name()
            localcall_fn = descriptor.\
                           local_callback_fn(node_name,
                                             callable.operation_name(),
                                             signature)
            call_descriptor.out_localcall(stream,
                                          node_name,
                                          callable.method_name(),
                                          localcall_fn)

            # produce member function for this operation/attribute.
            body = output.StringStream()

            argnames = method.arg_names()

            if config.state['Shortcut']:
                if method.return_type().kind() != idltype.tk_void:
                    callreturn = "return "
                    voidreturn = ""
                else:
                    callreturn = ""
                    voidreturn = " return;"

                objref_class = method.parent_class()
                interface = objref_class.interface()
                implname = interface.name().prefix("_impl_").\
                           unambiguous(self._environment)

                if config.state['Shortcut'] == 2:
                    tmpl = skel_template.interface_operation_shortcut_refcount
                else:
                    tmpl = skel_template.interface_operation_shortcut
                
                body.out(tmpl,
                         impl_type  = implname,
                         callreturn = callreturn,
                         voidreturn = voidreturn,
                         args       = ", ".join(argnames),
                         name       = method.name())


            intf_env = self._environment.enter("_objref_" +
                                               self.interface().name().simple())

            call_descriptor.out_objrefcall(body,
                                           callable.operation_name(),
                                           argnames,
                                           localcall_fn,
                                           intf_env)
            method.cc(stream, body)

            # Generate AMI descriptor
            if callable.ami():
                cd_names = call_descriptor.out_ami_descriptor(stream, callable,
                                                              node_name,
                                                              localcall_fn,
                                                              poller_impl_name)

                for ami_method in method._ami_methods:

                    ami_callable = ami_method.callable()

                    body = output.StringStream()

                    ami_op_name = ami_callable.operation_name()
                    if ami_op_name.startswith("sendc_"):
                        call_descriptor.out_ami_sendc(body, ami_method,
                                                      cd_names, intf_env)

                    else:
                        # sendp
                        call_descriptor.out_ami_sendp(body, ami_method,
                                                      cd_names, intf_env)

                        poller_body   = output.StringStream()
                        poller_method = poller_methods[ami_op_name[6:]]

                        call_descriptor.out_ami_poller(poller_body,
                                                       ami_method,
                                                       poller_method,
                                                       cd_names)

                        poller_method.cc(stream, poller_body)

                    ami_method.cc(stream, body)
Пример #8
0
    def cc(self, stream):
        def _ptrToObjRef_ptr(self=self, stream=stream):
            has_abstract = self.interface().abstract()

            for i in self.interface().allInherits():
                if i.abstract(): has_abstract = 1

                stream.out(skel_template.interface_objref_repoID_ptr,
                           inherits_fqname=i.name().fullyQualify())

            if has_abstract:
                stream.out(skel_template.interface_objref_repoID_ptr,
                           inherits_fqname="CORBA::AbstractBase")

        def _ptrToObjRef_str(self=self, stream=stream):
            has_abstract = self.interface().abstract()

            for i in self.interface().allInherits():
                if i.abstract(): has_abstract = 1

                stream.out(skel_template.interface_objref_repoID_str,
                           inherits_fqname=i.name().fullyQualify())

            if has_abstract:
                stream.out(skel_template.interface_objref_repoID_str,
                           inherits_fqname="CORBA::AbstractBase")

        #
        # Build the inherits list

        inherits_str_list = []
        for i in self.interface().inherits():
            objref_name = i.name().prefix("_objref_")

            objref_str = objref_name.unambiguous(self._environment)

            if objref_name.needFlatName(self._environment):
                objref_str = objref_name.flatName()

            this_inherits_str = objref_str + "(ior, id)"
            inherits_str_list.append(this_inherits_str)

        inherits_str = ",\n".join(inherits_str_list)
        if inherits_str:
            comma = ","
        else:
            comma = ""

        if config.state['Shortcut']:
            inherits_str = inherits_str + ","
            init_shortcut = "_shortcut(0)"
        else:
            init_shortcut = ""

        if config.state['Shortcut'] == 2:
            release_shortcut = skel_template.interface_release_refcount_shortcut
        else:
            release_shortcut = ""

        stream.out(skel_template.interface_objref,
                   name=self.interface().name().fullyQualify(),
                   fq_objref_name=self.name().fullyQualify(),
                   objref_name=self.name().simple(),
                   inherits_str=inherits_str,
                   comma=comma,
                   _ptrToObjRef_ptr=_ptrToObjRef_ptr,
                   _ptrToObjRef_str=_ptrToObjRef_str,
                   init_shortcut=init_shortcut,
                   release_shortcut=release_shortcut)

        #
        # Shortcut

        shortcut_mode = config.state['Shortcut']

        if shortcut_mode:
            inherited = output.StringStream()
            for i in self.interface().inherits():
                objref_name = i.name().prefix("_objref_")

                objref_str = objref_name.unambiguous(self._environment)

                if objref_name.needFlatName(self._environment):
                    objref_str = objref_name.flatName()

                inherited.out(skel_template.interface_shortcut_inh,
                              parent=objref_str)

            if shortcut_mode == 1:
                tmpl = skel_template.interface_shortcut
            else:
                tmpl = skel_template.interface_shortcut_refcount

            stream.out(tmpl,
                       name=self.interface().name().fullyQualify(),
                       basename=self.interface().name().simple(),
                       fq_objref_name=self.name().fullyQualify(),
                       inherited=str(inherited))

        #
        # AMI poller

        poller = self.interface().amiPoller()
        poller_impl_name = None
        poller_methods = {}

        if poller is not None:
            astdecl = poller.astdecl()

            poller_impl_name = descriptor.ami_poller_impl(poller.name())
            poller_class = AMIPoller(poller_impl_name)

            method_decls = []
            inherited_methods = []
            direct_callables = astdecl.callables()

            for c in astdecl.all_callables():
                op = call.operation(poller, c)
                method_decl = _impl_Method(op, poller_class)
                method_decls.append(method_decl.hh())

                if c not in direct_callables:
                    inherited_methods.append(method_decl)
                else:
                    poller_methods[op.operation_name()] = method_decl

            stream.out(skel_template.interface_ami_poller_impl,
                       poller_impl_name=poller_impl_name,
                       poller_name=poller.name().fullyQualify(),
                       method_decls="\n".join(method_decls))

            for method in inherited_methods:
                method.cc(stream, "_wrongOperation();")

        #
        # Methods

        ami_descriptors = {}

        for method in self.methods():
            callable = self._callables[method]

            stream.out(skel_template.interface_operation_marker,
                       iface=self.interface().name().fullyQualify(),
                       operation=callable.operation_name())

            # signature is a text string form of the complete
            # operation signature
            signature = callable.signature()

            # we only need one descriptor for each _signature_ (not operation)

            if signature in _proxy_call_descriptors:
                call_descriptor = _proxy_call_descriptors[signature]
            else:
                call_descriptor = call.CallDescriptor(signature, callable)
                call_descriptor.out_desc(stream)
                _proxy_call_descriptors[signature] = call_descriptor

            # produce a localcall function
            node_name = self.interface().name()
            localcall_fn = descriptor.\
                           local_callback_fn(node_name,
                                             callable.operation_name(),
                                             signature)
            call_descriptor.out_localcall(stream, node_name,
                                          callable.method_name(), localcall_fn)

            # produce member function for this operation/attribute.
            body = output.StringStream()

            argnames = method.arg_names()

            if config.state['Shortcut']:
                if method.return_type().kind() != idltype.tk_void:
                    callreturn = "return "
                    voidreturn = ""
                else:
                    callreturn = ""
                    voidreturn = " return;"

                objref_class = method.parent_class()
                interface = objref_class.interface()
                implname = interface.name().prefix("_impl_").\
                           unambiguous(self._environment)

                if config.state['Shortcut'] == 2:
                    tmpl = skel_template.interface_operation_shortcut_refcount
                else:
                    tmpl = skel_template.interface_operation_shortcut

                body.out(tmpl,
                         impl_type=implname,
                         callreturn=callreturn,
                         voidreturn=voidreturn,
                         args=", ".join(argnames),
                         name=method.name())

            intf_env = self._environment.enter(
                "_objref_" + self.interface().name().simple())

            call_descriptor.out_objrefcall(body, callable.operation_name(),
                                           argnames, localcall_fn, intf_env)
            method.cc(stream, body)

            # Generate AMI descriptor
            if callable.ami():
                cd_names = call_descriptor.out_ami_descriptor(
                    stream, callable, node_name, localcall_fn,
                    poller_impl_name)

                for ami_method in method._ami_methods:

                    ami_callable = ami_method.callable()

                    body = output.StringStream()

                    ami_op_name = ami_callable.operation_name()
                    if ami_op_name.startswith("sendc_"):
                        call_descriptor.out_ami_sendc(body, ami_method,
                                                      cd_names, intf_env)

                    else:
                        # sendp
                        call_descriptor.out_ami_sendp(body, ami_method,
                                                      cd_names, intf_env)

                        poller_body = output.StringStream()
                        poller_method = poller_methods[ami_op_name[6:]]

                        call_descriptor.out_ami_poller(poller_body, ami_method,
                                                       poller_method, cd_names)

                        poller_method.cc(stream, poller_body)

                    ami_method.cc(stream, body)