[PATCH] go: update bindings to compile with notmuch 0.25

classic Classic list List threaded Threaded
3 messages Options
Kamil Klimkiewicz Kamil Klimkiewicz
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCH] go: update bindings to compile with notmuch 0.25

Attached is a simple patch that fixes go bindings to compile with
notmuch 0.25. Please note it doesn't change the go API, ie. go methods
*don't* return Status values. I am not sure you also want to break go
API with the update. If you do, I can update the patch to return
go-idiomatic (*Messages, Status) tuple.

---
 contrib/go/src/notmuch/notmuch.go | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/contrib/go/src/notmuch/notmuch.go
b/contrib/go/src/notmuch/notmuch.go
index 2d684311..936f927c 100644
--- a/contrib/go/src/notmuch/notmuch.go
+++ b/contrib/go/src/notmuch/notmuch.go
@@ -455,11 +455,12 @@ func (self *Query) GetSort() Sort {
  * If a Xapian exception occurs this function will return NULL.
  */
 func (self *Query) SearchThreads() *Threads {
-       threads := C.notmuch_query_search_threads(self.query)
-       if threads == nil {
+       var threads Threads
+       C.notmuch_query_search_threads(self.query, &threads.threads)
+       if threads.threads == nil {
                return nil
        }
-       return &Threads{threads: threads}
+       return &threads
 }

 /* Execute a query for messages, returning a notmuch_messages_t object
@@ -501,11 +502,12 @@ func (self *Query) SearchThreads() *Threads {
  * If a Xapian exception occurs this function will return NULL.
  */
 func (self *Query) SearchMessages() *Messages {
-       msgs := C.notmuch_query_search_messages(self.query)
-       if msgs == nil {
+       var messages Messages
+       C.notmuch_query_search_messages(self.query, &messages.messages)
+       if messages.messages == nil {
                return nil
        }
-       return &Messages{messages: msgs}
+       return &messages
 }

 /* Destroy a notmuch_query_t along with any associated resources.
@@ -531,7 +533,9 @@ func (self *Query) Destroy() {
  * printing a message).
  */
 func (self *Query) CountMessages() uint {
-       return uint(C.notmuch_query_count_messages(self.query))
+       var count C.uint
+       C.notmuch_query_count_messages(self.query, &count)
+       return uint(count)
 }

 /* Is the given 'threads' iterator pointing at a valid thread.
--
2.14.0
_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
David Bremner-2 David Bremner-2
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [PATCH] go: update bindings to compile with notmuch 0.25

Kamil Klimkiewicz <[hidden email]> writes:

> Attached is a simple patch that fixes go bindings to compile with
> notmuch 0.25. Please note it doesn't change the go API, ie. go methods
> *don't* return Status values. I am not sure you also want to break go
> API with the update. If you do, I can update the patch to return
> go-idiomatic (*Messages, Status) tuple.
>

The problem we had in the past was getting any kind of review on go
patches. If you can find someone (or someone responds) to review the
patches then I don't mind an API update.

d
_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
David Bremner-2 David Bremner-2
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [PATCH] go: update bindings to compile with notmuch 0.25

In reply to this post by Kamil Klimkiewicz
Kamil Klimkiewicz <[hidden email]> writes:

> Attached is a simple patch that fixes go bindings to compile with
> notmuch 0.25. Please note it doesn't change the go API, ie. go methods
> *don't* return Status values. I am not sure you also want to break go
> API with the update. If you do, I can update the patch to return
> go-idiomatic (*Messages, Status) tuple.

for some reason this patch doesn't apply to current master

> ---
>  contrib/go/src/notmuch/notmuch.go | 18 +++++++++++-------
>  1 file changed, 11 insertions(+), 7 deletions(-)
>
> diff --git a/contrib/go/src/notmuch/notmuch.go
> b/contrib/go/src/notmuch/notmuch.go
> index 2d684311..936f927c 100644
> --- a/contrib/go/src/notmuch/notmuch.go
> +++ b/contrib/go/src/notmuch/notmuch.go
> @@ -455,11 +455,12 @@ func (self *Query) GetSort() Sort {
>   * If a Xapian exception occurs this function will return NULL.
>   */
>  func (self *Query) SearchThreads() *Threads {
> -       threads := C.notmuch_query_search_threads(self.query)
> -       if threads == nil {
> +       var threads Threads
> +       C.notmuch_query_search_threads(self.query, &threads.threads)
> +       if threads.threads == nil {

it seems like it would be better to check the return value of
notmuch_query_search_threads here, wouldn't it?

>  /* Destroy a notmuch_query_t along with any associated resources.
> @@ -531,7 +533,9 @@ func (self *Query) Destroy() {
>   * printing a message).
>   */
>  func (self *Query) CountMessages() uint {
> -       return uint(C.notmuch_query_count_messages(self.query))
> +       var count C.uint
> +       C.notmuch_query_count_messages(self.query, &count)
> +       return uint(count)
>  }

Here especially you should check the return value since the API does not
promise anything about the value of count in case of errors.

d
_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
Loading...