def __init__(self, inject=1): self.current = [] self.added = [] self.inject = inject idlast.registerDecl(messaging_module_decl.scopedName(), messaging_module_decl) idlast.registerDecl(reply_handler_decl.scopedName(), reply_handler_decl) idlast.registerDecl(poller_decl.scopedName(), poller_decl) idlast.registerDecl(exception_holder_decl.scopedName(), exception_holder_decl)
def _poller(self, node): """ _poller(node) -> (poller_fwd, poller) Build Poller valuetype. """ def amiPoller(n): while isinstance(n, idlast.Declarator): n = n.fullDecl() return n._ami_poller if node.inherits(): base_pollers = [ amiPoller(n) for n in node.inherits() ] else: base_pollers = [ poller_decl ] poller_ident = self._amiName(node.scopedName(), "Poller") poller_scope = node.scopedName()[:-1] + [poller_ident] poller_repoId = "IDL:%s:1.0" % idlutil.slashName(poller_scope) comment = idlast.Comment("// Poller valuetype for interface %s" % node.identifier(), node.file(), node.line()) poller_fwd = idlast.ValueForward(node.file(), node.line(), node.mainFile(), [], [], poller_ident, poller_scope, poller_repoId, 1) poller = idlast.ValueAbs(node.file(), node.line(), node.mainFile(), [], [comment], poller_ident, poller_scope, poller_repoId, base_pollers, []) poller._ami_gen = 1 operations = [] callables, clashes = self._callables(node) for cb in callables: if cb.oneway(): continue op_scope = poller_scope + [cb.identifier()] op_repoId = "IDL:%s:1.0" % idlutil.slashName(op_scope) params = [idlast.Parameter(cb.file(), cb.line(), cb.mainFile(), [], [], 0, idltype.Base(idltype.tk_ulong), "ami_timeout")] if cb.returnType().kind() != idltype.tk_void: params.append(idlast.Parameter(cb.file(), cb.line(), cb.mainFile(), [], [], 1, cb.returnType(), "ami_return_val")) for param in cb.parameters(): if param.is_out(): params.append(idlast.Parameter(param.file(), param.line(), param.mainFile(), [], [], 1, 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, cb.raises(), []) if hasattr(cb, "_ami_declarator"): if cb.identifier().startswith("set"): cb._ami_declarator._ami_set_poller = op else: cb._ami_declarator._ami_get_poller = op op._ami_from = cb._ami_declarator else: cb._ami_poller = op op._ami_from = cb operations.append(op) poller._setContents(operations) idlast.registerDecl(poller.scopedName(), poller) node._ami_poller = poller poller._ami_from = node return poller_fwd, poller
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