From: David Bremner <david@tethera.net>
To: notmuch@notmuchmail.org
Subject: [PATCH 3/4] ruby: update bindings for new count API
Date: Sat, 7 Mar 2015 09:43:16 +0100 [thread overview]
Message-ID: <1425717797-19990-4-git-send-email-david@tethera.net> (raw)
In-Reply-To: <1425717797-19990-1-git-send-email-david@tethera.net>
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
next prev parent reply other threads:[~2015-03-07 8:44 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-30 20:29 update count API round 2 David Bremner
2014-12-30 20:29 ` [Patch v2 1/5] build: integrate building ruby bindings into notmuch build process David Bremner
2014-12-30 20:29 ` [Patch v2 2/5] test: add python tests for query.count_{messages,threads} David Bremner
2014-12-30 20:29 ` [Patch v2 3/5] test: port existing python tests to ruby David Bremner
2014-12-30 20:29 ` [Patch v2 4/5] bindings/ruby: gitignore *.o David Bremner
2014-12-30 20:29 ` [Patch v2 5/5] lib: add status return to notmuch_query_count_{message,threads} David Bremner
2015-03-07 8:43 ` update count API, round 3 David Bremner
2015-03-07 8:43 ` [PATCH 1/4] lib: add versions of notmuch_query_count_{message,threads} with status return David Bremner
2015-03-07 13:57 ` [PATCH 1/4] lib: add versions of notmuch_query_count_{message, threads} " Jani Nikula
2015-03-07 8:43 ` [PATCH 2/4] cli: update to use new count API David Bremner
2015-03-07 14:00 ` Jani Nikula
2015-03-07 8:43 ` David Bremner [this message]
2015-03-07 8:43 ` [PATCH 4/4] python: update bindings for " David Bremner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1425717797-19990-4-git-send-email-david@tethera.net \
--to=david@tethera.net \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).