From patchwork Mon Jun 10 21:41:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 14280 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id C527F17064; Mon, 10 Jun 2019 22:42:08 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.0 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTP id 777D51704B for ; Mon, 10 Jun 2019 22:42:08 +0100 (BST) Received: from localhost ([::1]:49904 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1haS3L-0003Vx-7a for patchwork@mira.cbaines.net; Mon, 10 Jun 2019 17:42:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35127) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1haS3H-0003Ps-S7 for guix-patches@gnu.org; Mon, 10 Jun 2019 17:42:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1haS3G-0001KK-RY for guix-patches@gnu.org; Mon, 10 Jun 2019 17:42:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:44041) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1haS3G-0001KF-O6 for guix-patches@gnu.org; Mon, 10 Jun 2019 17:42:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1haS3G-0006Ju-LT for guix-patches@gnu.org; Mon, 10 Jun 2019 17:42:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#36162] [PATCH 3/4] inferior: Add 'read-repl-response'. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 10 Jun 2019 21:42:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 36162 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 36162@debbugs.gnu.org Received: via spool by 36162-submit@debbugs.gnu.org id=B36162.156020291324257 (code B ref 36162); Mon, 10 Jun 2019 21:42:02 +0000 Received: (at 36162) by debbugs.gnu.org; 10 Jun 2019 21:41:53 +0000 Received: from localhost ([127.0.0.1]:57581 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1haS36-0006J6-SZ for submit@debbugs.gnu.org; Mon, 10 Jun 2019 17:41:53 -0400 Received: from eggs.gnu.org ([209.51.188.92]:54472) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1haS34-0006IU-Ia for 36162@debbugs.gnu.org; Mon, 10 Jun 2019 17:41:50 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:60154) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1haS2z-00018V-CB; Mon, 10 Jun 2019 17:41:45 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=33892 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1haS2y-0001fJ-SJ; Mon, 10 Jun 2019 17:41:45 -0400 From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Mon, 10 Jun 2019 23:41:29 +0200 Message-Id: <20190610214130.19378-3-ludo@gnu.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190610214130.19378-1-ludo@gnu.org> References: <20190610214130.19378-1-ludo@gnu.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * guix/inferior.scm (read-repl-response): New procedure. (read-inferior-response): Use it. --- guix/inferior.scm | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/guix/inferior.scm b/guix/inferior.scm index 63c95141d7..fee97750b6 100644 --- a/guix/inferior.scm +++ b/guix/inferior.scm @@ -59,6 +59,7 @@ inferior-eval inferior-eval-with-store inferior-object? + read-repl-response inferior-packages inferior-available-packages @@ -183,7 +184,8 @@ equivalent. Return #f if the inferior could not be launched." (set-record-type-printer! write-inferior-object) -(define (read-inferior-response inferior) +(define (read-repl-response port) + "Read a (guix repl) response from PORT and return it as a Scheme object." (define sexp->object (match-lambda (('value value) @@ -191,12 +193,15 @@ equivalent. Return #f if the inferior could not be launched." (('non-self-quoting address string) (inferior-object address string)))) - (match (read (inferior-socket inferior)) + (match (read port) (('values objects ...) (apply values (map sexp->object objects))) (('exception key objects ...) (apply throw key (map sexp->object objects))))) +(define (read-inferior-response inferior) + (read-repl-response (inferior-socket inferior))) + (define (send-inferior-request exp inferior) (write exp (inferior-socket inferior)) (newline (inferior-socket inferior)))