Beispiel #1
0
    def _handler(self, node):
        """
        _handler(node) -> (handler_fwd, handler)
        
        Build ReplyHandler interface.
        """

        def amiHandler(n):
            while isinstance(n, idlast.Declarator):
                n = n.fullDecl()
            return n._ami_handler

        if node.inherits():
            base_handlers = [ amiHandler(n) for n in node.inherits() ]
        else:
            base_handlers = [ reply_handler_decl ]

        handler_ident  = self._amiName(node.scopedName(), "Handler")
        handler_scope  = node.scopedName()[:-1] + [handler_ident]
        handler_repoId = "IDL:%s:1.0" % idlutil.slashName(handler_scope)

        comment = idlast.Comment("// ReplyHandler for interface %s" %
                                 node.identifier(),
                                 node.file(), node.line())

        handler_fwd = idlast.Forward(node.file(), node.line(),
                                     node.mainFile(), [], [],
                                     handler_ident, handler_scope,
                                     handler_repoId, 0, 0)

        handler = idlast.Interface(node.file(), node.line(),
                                   node.mainFile(), [], [comment],
                                   handler_ident, handler_scope,
                                   handler_repoId, 0, 0, base_handlers)
        handler._ami_gen = 1

        operations = []

        # Success methods

        callables, clashes = self._callables(node)

        for cb in callables:

            op_scope  = handler_scope + [cb.identifier()]
            op_repoId = "IDL:%s:1.0" % idlutil.slashName(op_scope)

            params = []

            if cb.returnType().kind() != idltype.tk_void:
                params.append(idlast.Parameter(cb.file(), cb.line(),
                                               cb.mainFile(), [], [],
                                               0, cb.returnType(),
                                               "ami_return_val"))
            for param in cb.parameters():
                if param.is_out():
                    params.append(idlast.Parameter(param.file(),
                                                   param.line(),
                                                   param.mainFile(),
                                                   [], [],
                                                   0, param.paramType(),
                                                   param.identifier()))

            op = idlast.Operation(cb.file(), cb.line(),
                                  cb.mainFile(), [], [],
                                  0, idltype.Base(idltype.tk_void),
                                  cb.identifier(), op_scope, op_repoId,
                                  params, [], [])

            if hasattr(cb, "_ami_declarator"):
                if cb.identifier().startswith("set"):
                    cb._ami_declarator._ami_set_handler = op
                else:
                    cb._ami_declarator._ami_get_handler = op
            else:
                cb._ami_handler = op

            operations.append(op)


        # _excep methods
        exceps = []

        for cb in callables:

            ident = cb.identifier()

            excep_ident = self._suffixName("_excep", ident, clashes)

            params = [idlast.Parameter("<builtin>", 0, 0, [], [],
                                       0, exception_holder_type,
                                       "excep_holder")]

            op_scope  = handler_scope + [excep_ident]
            op_repoId = "IDL:%s:1.0" % idlutil.slashName(op_scope)

            op = idlast.Operation(cb.file(), cb.line(),
                                  cb.mainFile(), [], [],
                                  0, idltype.Base(idltype.tk_void),
                                  excep_ident, op_scope, op_repoId,
                                  params, [], [])

            

            if hasattr(cb, "_ami_declarator"):
                if cb.identifier().startswith("set"):
                    cb._ami_declarator._ami_set_handler_excep = op
                else:
                    cb._ami_declarator._ami_get_handler_excep = op
            else:
                cb._ami_handler_excep = op

            exceps.append(op)
            

        handler._setContents(operations + exceps)
        idlast.registerDecl(handler.scopedName(), handler)
        
        node._ami_handler = handler

        return handler_fwd, handler
Beispiel #2
0
    def _implied(self, node, handler, poller):
        """
        _implied(node, handler, poller) -> interface

        Generate implied client-side sendc / sendp operations. Returns
        a new idlast.Interface containing just those methods, and sets
        _ami_ops attribute on the original Interface node.
        """
        operations = []

        handler_type = idltype.Declared(handler, handler.scopedName(),
                                        idltype.tk_objref, 0)

        poller_type  = idltype.Declared(poller, poller.scopedName(),
                                        idltype.tk_value, 0)

        intf_scope = node.scopedName()

        callables, clashes = self._callables(node)

        for cb in callables:

            if cb.oneway():
                continue

            params = []
            for param in cb.parameters():
                if param.is_in():
                    params.append(idlast.Parameter(param.file(),
                                                   param.line(),
                                                   param.mainFile(),
                                                   [], [],
                                                   0, param.paramType(),
                                                   param.identifier()))

            # sendc...

            op_ident  = self._prefixName("sendc_", cb.identifier(), clashes)
            op_scope  = intf_scope + [op_ident]
            op_repoId = "IDL:%s:1.0" % idlutil.slashName(op_scope)

            handler_param = idlast.Parameter(cb.file(), cb.line(),
                                             cb.mainFile(), [], [],
                                             0,
                                             handler_type,
                                             "ami_handler")

            op = idlast.Operation(cb.file(), cb.line(),
                                  cb.mainFile(), [], [],
                                  0, idltype.Base(idltype.tk_void),
                                  op_ident, op_scope, op_repoId,
                                  [handler_param] + params,
                                  [], cb.contexts())
            operations.append(op)

            if hasattr(cb, "_ami_declarator"):
                op._ami_from = cb._ami_declarator

                if cb.identifier().startswith("set"):
                    cb._ami_declarator._ami_set_sendc = op
                    op._ami_setter = 1
                else:
                    cb._ami_declarator._ami_get_sendc = op
                    op._ami_setter = 0
            else:
                cb._ami_sendc = op
                op._ami_from  = cb


            # sendp...

            op_ident  = self._prefixName("sendp_", cb.identifier(), clashes)
            op_scope  = intf_scope + [op_ident]
            op_repoId = "IDL:%s:1.0" % idlutil.slashName(op_scope)

            poller_param  = idlast.Parameter(cb.file(), cb.line(),
                                             cb.mainFile(), [], [],
                                             0,
                                             poller_type,
                                             "ami_poller")

            op = idlast.Operation(cb.file(), cb.line(),
                                  cb.mainFile(), [], [],
                                  0, poller_type,
                                  op_ident, op_scope, op_repoId,
                                  params[:], [], cb.contexts())

            operations.append(op)

            if hasattr(cb, "_ami_declarator"):
                op._ami_from = cb._ami_declarator

                if cb.identifier().startswith("set"):
                    cb._ami_declarator._ami_set_sendp = op
                    op._ami_setter = 1
                else:
                    cb._ami_declarator._ami_get_sendp = op
                    op._ami_setter = 0
            else:
                cb._ami_sendp = op
                op._ami_from  = cb

                
        node._ami_ops = operations

        comment = idlast.Comment("// AMI implied operations for interface %s" %
                                 node.identifier(),
                                 node.file(), node.line())

        implied_intf  = idlast.Interface(node.file(), node.line(),
                                         node.mainFile(), node.pragmas(),
                                         [comment], node.identifier(),
                                         node.scopedName(), node.repoId(),
                                         node.abstract(), node.local(),
                                         node.inherits())
        implied_intf._setContents(operations)

        return implied_intf
Beispiel #3
0
from omniidl import idlast, idltype, idlutil, idlvisitor, output
from omniidl_be.dump import DumpVisitor
import sys

usage_string = """\
  -Wbinline       Output declarations from #included files inline
  -Wbdump         Dump original IDL as well as AMI IDL"""


#
# Static declarations of types defined in messaging.idl

reply_handler_decl = idlast.Interface("messaging.idl", 0, 0, [], [],
                                      "ReplyHandler",
                                      ["Messaging", "ReplyHandler"],
                                      "IDL:omg.org/Messaging/ReplyHandler:1.0",
                                      0, 0, [])
reply_handler_decl._setContents([])

poller_decl = idlast.ValueAbs("messaging.idl", 0, 0, [], [],
                              "Poller",
                              ["Messaging", "Poller"],
                              "IDL:omg.org/Messaging/Poller/1.0",
                              [], [])
poller_decl._setContents([])

exception_holder_decl = idlast.Value("messaging.idl", 0, 0, [], [],
                                     "ExceptionHolder",
                                     ["Messaging", "ExceptionHolder"],
                                     "IDL:omg.org/Messaging/ExceptionHolder:1.0",