Ejemplo n.º 1
0
        def dispatch(self=self, stream=stream):
            # first check if method is from this interface
            dispatched = []
            for method in self.methods():
                callable = self._callables[method]
                operation_name = callable.operation_name()
                if operation_name not in dispatched:
                    signature = callable.signature()
                    call_descriptor = _proxy_call_descriptors[signature]
                    localcall_fn = descriptor.local_callback_fn(
                        self.interface().name(), operation_name, signature)
                    call_descriptor.out_implcall(stream, operation_name,
                                                 localcall_fn)
                    dispatched.append(operation_name)

            # next call dispatch methods of superclasses
            for i in self.interface().inherits():
                inherited_name = i.name().prefix("_impl_")
                impl_inherits = inherited_name.simple()
                # The MSVC workaround might be needed here again
                if inherited_name.needFlatName(self._environment):
                    impl_inherits = inherited_name.flatName()
                stream.out(omniidl_be.cxx.skel.template.
                           interface_impl_inherit_dispatch,
                           impl_inherited_name=impl_inherits)
Ejemplo n.º 2
0
    def dispatch(self = self, stream = stream):
      # first check if method is from this interface
      dispatched = []
      for method in self.methods():
        callable = self._callables[method]
        operation_name = callable.operation_name()
        if operation_name not in dispatched:
          signature = callable.signature()
          call_descriptor = _proxy_call_descriptors[signature]
          localcall_fn = descriptor.local_callback_fn(self.interface().name(),
                                                      operation_name,signature)
          call_descriptor.out_implcall(stream,operation_name,localcall_fn)
          dispatched.append(operation_name)

      # next call dispatch methods of superclasses
      for i in self.interface().inherits():
        inherited_name = i.name().prefix("_impl_")
        impl_inherits = inherited_name.simple()
        # The MSVC workaround might be needed here again
        if inherited_name.needFlatName(self._environment):
          impl_inherits = inherited_name.flatName()
        stream.out(omniidl_be.cxx.skel.template.interface_impl_inherit_dispatch,
                   impl_inherited_name = impl_inherits)
Ejemplo n.º 3
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(omniidl_be.cxx.skel.template.interface_objref_repoID_ptr,
                   inherits_fqname = i.name().fullyQualify())

      if has_abstract:
        stream.out(omniidl_be.cxx.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(omniidl_be.cxx.skel.template.interface_objref_repoID_str,
                   inherits_fqname = i.name().fullyQualify())

      if has_abstract:
        stream.out(omniidl_be.cxx.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)"

      # FIXME:
      # The powerpc-aix OMNIORB_BASE_CTOR workaround still works here
      # (in precendence to the flattened base name) but lacking a
      # powerpc-aix test machine I can't properly test it. It's probably
      # not required any more.
      if objref_name.relName(self._environment) != i.name().fullName():
        prefix = []
        for x in objref_name.fullName():
          if x == "_objref_" + objref_name.relName(self._environment)[0]:
            break
          prefix.append(x)
        inherits_scope_prefix = string.join(prefix, "::") + "::"
        this_inherits_str = "OMNIORB_BASE_CTOR(" + inherits_scope_prefix +\
                            ")" + this_inherits_str

      inherits_str_list.append(this_inherits_str)

    inherits_str = string.join(inherits_str_list, ",\n")
    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 = omniidl_be.cxx.skel.template.\
                         interface_release_refcount_shortcut
    else:
      release_shortcut = ""

    stream.out(omniidl_be.cxx.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_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(omniidl_be.cxx.skel.template.interface_shortcut_inh,
                      parent=objref_str)

      if shortcut_mode == 1:
        tmpl = omniidl_be.cxx.skel.template.interface_shortcut
      else:
        tmpl = omniidl_be.cxx.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))
      
    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 _proxy_call_descriptors.has_key(signature):
        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 = omniidl_be.cxx.skel.template.\
                 interface_operation_shortcut_refcount
        else:
          tmpl = omniidl_be.cxx.skel.template.\
                 interface_operation_shortcut
        
        body.out(tmpl,
                 impl_type = implname,
                 callreturn = callreturn,
                 voidreturn = voidreturn,
                 args = string.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)
Ejemplo n.º 4
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(
                    omniidl_be.cxx.skel.template.interface_objref_repoID_ptr,
                    inherits_fqname=i.name().fullyQualify())

            if has_abstract:
                stream.out(
                    omniidl_be.cxx.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(
                    omniidl_be.cxx.skel.template.interface_objref_repoID_str,
                    inherits_fqname=i.name().fullyQualify())

            if has_abstract:
                stream.out(
                    omniidl_be.cxx.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)"

            # FIXME:
            # The powerpc-aix OMNIORB_BASE_CTOR workaround still works here
            # (in precendence to the flattened base name) but lacking a
            # powerpc-aix test machine I can't properly test it. It's probably
            # not required any more.
            if objref_name.relName(self._environment) != i.name().fullName():
                prefix = []
                for x in objref_name.fullName():
                    if x == "_objref_" + objref_name.relName(
                            self._environment)[0]:
                        break
                    prefix.append(x)
                inherits_scope_prefix = string.join(prefix, "::") + "::"
                this_inherits_str = "OMNIORB_BASE_CTOR(" + inherits_scope_prefix +\
                                    ")" + this_inherits_str

            inherits_str_list.append(this_inherits_str)

        inherits_str = string.join(inherits_str_list, ",\n")
        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 = omniidl_be.cxx.skel.template.\
                               interface_release_refcount_shortcut
        else:
            release_shortcut = ""

        stream.out(omniidl_be.cxx.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_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(
                    omniidl_be.cxx.skel.template.interface_shortcut_inh,
                    parent=objref_str)

            if shortcut_mode == 1:
                tmpl = omniidl_be.cxx.skel.template.interface_shortcut
            else:
                tmpl = omniidl_be.cxx.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))

        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 _proxy_call_descriptors.has_key(signature):
                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 = omniidl_be.cxx.skel.template.\
                           interface_operation_shortcut_refcount
                else:
                    tmpl = omniidl_be.cxx.skel.template.\
                           interface_operation_shortcut

                body.out(tmpl,
                         impl_type=implname,
                         callreturn=callreturn,
                         voidreturn=voidreturn,
                         args=string.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)