From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id D1A86431FC3 for ; Sat, 7 Mar 2015 00:44:35 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 2.438 X-Spam-Level: ** X-Spam-Status: No, score=2.438 tagged_above=-999 required=5 tests=[DNS_FROM_AHBL_RHSBL=2.438] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id dvrd5YXFPaVD for ; Sat, 7 Mar 2015 00:44:35 -0800 (PST) Received: from mx.xen14.node3324.gplhost.com (gitolite.debian.net [87.98.215.224]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 8F2E6431FBC for ; Sat, 7 Mar 2015 00:44:32 -0800 (PST) Received: from remotemail by mx.xen14.node3324.gplhost.com with local (Exim 4.80) (envelope-from ) id 1YUAKs-0002Jo-Gp; Sat, 07 Mar 2015 08:43:50 +0000 Received: (nullmailer pid 20412 invoked by uid 1000); Sat, 07 Mar 2015 08:43:23 -0000 From: David Bremner To: notmuch@notmuchmail.org Subject: [PATCH 3/4] ruby: update bindings for new count API Date: Sat, 7 Mar 2015 09:43:16 +0100 Message-Id: <1425717797-19990-4-git-send-email-david@tethera.net> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1425717797-19990-1-git-send-email-david@tethera.net> References: <1419971380-10307-6-git-send-email-david@tethera.net> <1425717797-19990-1-git-send-email-david@tethera.net> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 07 Mar 2015 08:44:36 -0000 Compared to the CLI changes, this does something clearly useful, transforming an error status into a ruby exception. --- bindings/ruby/query.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/bindings/ruby/query.c b/bindings/ruby/query.c index a7dacba..ea9ca37 100644 --- a/bindings/ruby/query.c +++ b/bindings/ruby/query.c @@ -173,14 +173,17 @@ VALUE notmuch_rb_query_count_messages (VALUE self) { notmuch_query_t *query; + notmuch_status_t status; + unsigned count; Data_Get_Notmuch_Query (self, query); - /* Xapian exceptions are not handled properly. - * (function may return 0 after printing a message) - * Thus there is nothing we can do here... - */ - return UINT2NUM(notmuch_query_count_messages(query)); + status = notmuch_query_count_messages_st (query, &count); + + if (status) + notmuch_rb_status_raise (status); + else + return UINT2NUM(count); } /* @@ -192,12 +195,15 @@ VALUE notmuch_rb_query_count_threads (VALUE self) { notmuch_query_t *query; + notmuch_status_t status; + unsigned count; Data_Get_Notmuch_Query (self, query); - /* Xapian exceptions are not handled properly. - * (function may return 0 after printing a message) - * Thus there is nothing we can do here... - */ - return UINT2NUM(notmuch_query_count_threads(query)); + status = notmuch_query_count_threads_st (query, &count); + if (status) + notmuch_rb_status_raise (status); + else + return UINT2NUM(count); + } -- 2.1.4