diff options
| author | David Bremner <david@tethera.net> | 2015-12-13 08:39:11 -0400 |
|---|---|---|
| committer | David Bremner <david@tethera.net> | 2015-12-13 08:39:11 -0400 |
| commit | e3cd357fdddd2d8d29e8eea0b40a1043c46f1791 (patch) | |
| tree | b0e4f0549fc1216439e4593b73206c7923995ad4 /bindings | |
| parent | ad5b7434978ed98b1eb832b77684869f5d02594a (diff) | |
| parent | 1432a4f946e0f236179b53ac71d03764da725f33 (diff) | |
Merge tag 'debian/0.21-3' into jessie-backports
uploaded to unstable
Diffstat (limited to 'bindings')
| -rw-r--r-- | bindings/Makefile | 7 | ||||
| -rw-r--r-- | bindings/Makefile.local | 21 | ||||
| -rw-r--r-- | bindings/python/notmuch/query.py | 22 | ||||
| -rw-r--r-- | bindings/python/notmuch/version.py | 2 | ||||
| -rw-r--r-- | bindings/ruby/README | 7 | ||||
| -rw-r--r-- | bindings/ruby/extconf.rb | 16 | ||||
| -rw-r--r-- | bindings/ruby/query.c | 38 |
7 files changed, 78 insertions, 35 deletions
diff --git a/bindings/Makefile b/bindings/Makefile new file mode 100644 index 00000000..de492a7c --- /dev/null +++ b/bindings/Makefile @@ -0,0 +1,7 @@ +# See Makefile.local for the list of files to be compiled in this +# directory. +all: + $(MAKE) -C .. all + +.DEFAULT: + $(MAKE) -C .. $@ diff --git a/bindings/Makefile.local b/bindings/Makefile.local new file mode 100644 index 00000000..4ecf839d --- /dev/null +++ b/bindings/Makefile.local @@ -0,0 +1,21 @@ +# -*- makefile -*- + +dir := bindings + +# force the shared library to be built +ruby-bindings: lib/$(LINKER_NAME) +ifeq ($(HAVE_RUBY_DEV),1) + cd $(dir)/ruby && \ + EXTRA_LDFLAGS="$(NO_UNDEFINED_LDFLAGS)" \ + LIBNOTMUCH="../../lib/$(LINKER_NAME)" \ + ruby extconf.rb --vendor + $(MAKE) -C $(dir)/ruby +else + @echo Missing dependency, skipping ruby bindings +endif + +CLEAN += $(patsubst %,$(dir)/ruby/%, \ + .RUBYARCHDIR.time \ + Makefile database.o directory.o filenames.o\ + init.o message.o messages.o mkmf.log notmuch.so query.o \ + status.o tags.o thread.o threads.o) diff --git a/bindings/python/notmuch/query.py b/bindings/python/notmuch/query.py index 94773ac5..378aa47d 100644 --- a/bindings/python/notmuch/query.py +++ b/bindings/python/notmuch/query.py @@ -17,7 +17,7 @@ along with notmuch. If not, see <http://www.gnu.org/licenses/>. Copyright 2010 Sebastian Spaeth <Sebastian@SSpaeth.de> """ -from ctypes import c_char_p, c_uint +from ctypes import c_char_p, c_uint, POINTER, byref from .globals import ( nmlib, Enum, @@ -178,8 +178,8 @@ class Query(object): raise NullPointerError return Messages(msgs_p, self) - _count_messages = nmlib.notmuch_query_count_messages - _count_messages.argtypes = [NotmuchQueryP] + _count_messages = nmlib.notmuch_query_count_messages_st + _count_messages.argtypes = [NotmuchQueryP, POINTER(c_uint)] _count_messages.restype = c_uint def count_messages(self): @@ -191,10 +191,14 @@ class Query(object): :rtype: int ''' self._assert_query_is_initialized() - return Query._count_messages(self._query) + count = c_uint(0) + status = Query._count_messages(self._query, byref(count)) + if status != 0: + raise NotmuchError(status) + return count.value - _count_threads = nmlib.notmuch_query_count_threads - _count_threads.argtypes = [NotmuchQueryP] + _count_threads = nmlib.notmuch_query_count_threads_st + _count_threads.argtypes = [NotmuchQueryP, POINTER(c_uint)] _count_threads.restype = c_uint def count_threads(self): @@ -210,7 +214,11 @@ class Query(object): :rtype: int ''' self._assert_query_is_initialized() - return Query._count_threads(self._query) + count = c_uint(0) + status = Query._count_threads(self._query, byref(count)) + if status != 0: + raise NotmuchError(status) + return count.value _destroy = nmlib.notmuch_query_destroy _destroy.argtypes = [NotmuchQueryP] diff --git a/bindings/python/notmuch/version.py b/bindings/python/notmuch/version.py index 1295ac5a..db9d0764 100644 --- a/bindings/python/notmuch/version.py +++ b/bindings/python/notmuch/version.py @@ -1,3 +1,3 @@ # this file should be kept in sync with ../../../version -__VERSION__ = '0.20.2' +__VERSION__ = '0.21' SOVERSION = '4' diff --git a/bindings/ruby/README b/bindings/ruby/README new file mode 100644 index 00000000..a2946b66 --- /dev/null +++ b/bindings/ruby/README @@ -0,0 +1,7 @@ +To build the the notmuch ruby extension, run the following commands +from the *top level* notmuch source directory: + +% ./configure +% make ruby-bindings + +The generic documentation about building notmuch also applies. diff --git a/bindings/ruby/extconf.rb b/bindings/ruby/extconf.rb index 6160db26..ddaa6841 100644 --- a/bindings/ruby/extconf.rb +++ b/bindings/ruby/extconf.rb @@ -10,22 +10,16 @@ dir = File.join('..', '..', 'lib') # includes $INCFLAGS = "-I#{dir} #{$INCFLAGS}" -# make sure there are no undefined symbols -$LDFLAGS += ' -Wl,--no-undefined' - -def have_local_library(lib, path, func, headers = nil) - checking_for checking_message(func, lib) do - lib = File.join(path, lib) - if try_func(func, lib, headers) - $LOCAL_LIBS += lib - end - end +if ENV['EXTRA_LDFLAGS'] + $LDFLAGS += " " + ENV['EXTRA_LDFLAGS'] end -if not have_local_library('libnotmuch.so', dir, 'notmuch_database_create', 'notmuch.h') +if not ENV['LIBNOTMUCH'] exit 1 end +$LOCAL_LIBS += ENV['LIBNOTMUCH'] + # Create Makefile dir_config('notmuch') create_makefile('notmuch') diff --git a/bindings/ruby/query.c b/bindings/ruby/query.c index a7dacba3..8cbc73f2 100644 --- a/bindings/ruby/query.c +++ b/bindings/ruby/query.c @@ -134,12 +134,13 @@ notmuch_rb_query_search_threads (VALUE self) { notmuch_query_t *query; notmuch_threads_t *threads; + notmuch_status_t status; Data_Get_Notmuch_Query (self, query); - threads = notmuch_query_search_threads (query); - if (!threads) - rb_raise (notmuch_rb_eMemoryError, "Out of memory"); + status = notmuch_query_search_threads_st (query, &threads); + if (status) + notmuch_rb_status_raise (status); return Data_Wrap_Struct (notmuch_rb_cThreads, NULL, NULL, threads); } @@ -154,12 +155,13 @@ notmuch_rb_query_search_messages (VALUE self) { notmuch_query_t *query; notmuch_messages_t *messages; + notmuch_status_t status; Data_Get_Notmuch_Query (self, query); - messages = notmuch_query_search_messages (query); - if (!messages) - rb_raise (notmuch_rb_eMemoryError, "Out of memory"); + status = notmuch_query_search_messages_st (query, &messages); + if (status) + notmuch_rb_status_raise (status); return Data_Wrap_Struct (notmuch_rb_cMessages, NULL, NULL, messages); } @@ -173,14 +175,16 @@ VALUE notmuch_rb_query_count_messages (VALUE self) { notmuch_query_t *query; + notmuch_status_t status; + unsigned int 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); + + return UINT2NUM(count); } /* @@ -192,12 +196,14 @@ VALUE notmuch_rb_query_count_threads (VALUE self) { notmuch_query_t *query; + notmuch_status_t status; + unsigned int 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); + + return UINT2NUM(count); } |
