From 0f0ce4fe159867327112e18de96b7e591ce80a30 Mon Sep 17 00:00:00 2001 From: Jessica Tallon Date: Thu, 19 Jan 2023 12:57:50 +0100 Subject: [PATCH] Fix sending of keyword arguments over CapTP We need to ensure that when we send keyword arguments over CapTP we gather them up and include them at the end of the arg list. before we were ignoring keyword arguments when sending a message over CapTP, this fixes that. --- goblins/ocapn/captp.rkt | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/goblins/ocapn/captp.rkt b/goblins/ocapn/captp.rkt index 8441e17..54399b6 100644 --- a/goblins/ocapn/captp.rkt +++ b/goblins/ocapn/captp.rkt @@ -831,6 +831,15 @@ [other-message (error 'invalid-message "~a" other-message)])) + (define (keyword-args->args kws kw-vals args) + (if (null? kws) + args + (for/fold ([args (reverse args)] + #:result (reverse args)) + ([kw kws] + [kw-val kw-vals]) + (cons kw-val (cons kw args))))) + (define ((^internal-handler bcom) cmd) (define (running-handle-cmd cmd) (match cmd @@ -843,18 +852,20 @@ (values msg (question-finder->question-pos! answer-this-question))])) (match-define (message to resolve-me kws kw-vals args) real-msg) + (define collected-args + (keyword-args->args kws kw-vals args)) (define deliver-msg (if resolve-me (op:deliver (marshall-to to) #;(desc:import (maybe-install-export! to)) #f ;; TODO: support methods ;; TODO: correctly marshall everything here - (outgoing-pre-marshall! args) + (outgoing-pre-marshall! collected-args) answer-pos (marshall-local-refr! resolve-me)) (op:deliver-only (marshall-to to) #f ;; TODO: support methods - (outgoing-pre-marshall! args)))) + (outgoing-pre-marshall! collected-args)))) (send-to-remote deliver-msg)] [(cmd-send-listen (? remote-refr? to-refr) (? local-refr? listener-refr) (? boolean? wants-partial?))