[PATCH 3/4] ruby: update bindings for new count API
David Bremner
david at tethera.net
Sat Mar 7 00:43:16 PST 2015
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
More information about the notmuch
mailing list