unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* Last minute fixes to the go bindings
@ 2012-05-09 10:23 Justus Winter
  2012-05-09 10:23 ` [PATCH 1/3] go: update notmuch-addrlookup to the new API Justus Winter
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Justus Winter @ 2012-05-09 10:23 UTC (permalink / raw)
  To: notmuch

Hi everyone :)

this is a small patch series that I'd like to see included in 0.13.

The first patch updates notmuch-addrlookup with respect to Austins
recent change of the notmuch_database_open function. This fixes the
compilation of the utility.

The second patch fixes the values of all the STATUS_* constants. Turns
out all of them were set to zero by accident. This isn't a c style
enum, golang has the iota operator to do this kind of stuff. This
fixes the error handling for all the users of the go bindings.

The third patch just brings the list of status constants up to date.

Cheers,
Justus

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/3] go: update notmuch-addrlookup to the new API
  2012-05-09 10:23 Last minute fixes to the go bindings Justus Winter
@ 2012-05-09 10:23 ` Justus Winter
  2012-05-09 10:23 ` [PATCH 2/3] go: fix the notmuch status constants Justus Winter
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Justus Winter @ 2012-05-09 10:23 UTC (permalink / raw)
  To: notmuch

notmuch.OpenDatabase now returns a status indicating success or
failure. Use this information to inform the user of any failures.

Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
---
 bindings/go/cmds/notmuch-addrlookup.go |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/bindings/go/cmds/notmuch-addrlookup.go b/bindings/go/cmds/notmuch-addrlookup.go
index 16958e5..03699fb 100644
--- a/bindings/go/cmds/notmuch-addrlookup.go
+++ b/bindings/go/cmds/notmuch-addrlookup.go
@@ -209,8 +209,12 @@ func (self *address_matcher) run(name string) {
 	queries := [3]*notmuch.Query{}
 	
 	// open the database
-	self.db = notmuch.OpenDatabase(self.user_db_path, 
-		notmuch.DATABASE_MODE_READ_ONLY)
+	if db, status := notmuch.OpenDatabase(self.user_db_path,
+		notmuch.DATABASE_MODE_READ_ONLY); status == notmuch.STATUS_SUCCESS {
+        self.db = db
+	} else {
+		log.Fatalf("Failed to open the database: %v\n", status)
+	}
 
 	// pass 1: look at all from: addresses with the address book tag
 	query := "tag:" + self.user_addrbook_tag
-- 
1.7.10

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/3] go: fix the notmuch status constants
  2012-05-09 10:23 Last minute fixes to the go bindings Justus Winter
  2012-05-09 10:23 ` [PATCH 1/3] go: update notmuch-addrlookup to the new API Justus Winter
@ 2012-05-09 10:23 ` Justus Winter
  2012-05-09 10:23 ` [PATCH 3/3] go: define the constant STATUS_UNBALANCED_ATOMIC Justus Winter
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Justus Winter @ 2012-05-09 10:23 UTC (permalink / raw)
  To: notmuch

Formerly all the constants were set to zero since in golang constants
are set to the previous value if no new value is specified. Use the
iota operator that is incremented after each use to fix this issue.

Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
---
 bindings/go/pkg/notmuch.go |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bindings/go/pkg/notmuch.go b/bindings/go/pkg/notmuch.go
index f9f86b5..e065b54 100644
--- a/bindings/go/pkg/notmuch.go
+++ b/bindings/go/pkg/notmuch.go
@@ -14,7 +14,7 @@ import "unsafe"
 // Status codes used for the return values of most functions
 type Status C.notmuch_status_t
 const (
-	STATUS_SUCCESS Status = 0
+	STATUS_SUCCESS Status = iota
 	STATUS_OUT_OF_MEMORY
     STATUS_READ_ONLY_DATABASE
     STATUS_XAPIAN_EXCEPTION
-- 
1.7.10

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/3] go: define the constant STATUS_UNBALANCED_ATOMIC
  2012-05-09 10:23 Last minute fixes to the go bindings Justus Winter
  2012-05-09 10:23 ` [PATCH 1/3] go: update notmuch-addrlookup to the new API Justus Winter
  2012-05-09 10:23 ` [PATCH 2/3] go: fix the notmuch status constants Justus Winter
@ 2012-05-09 10:23 ` Justus Winter
  2012-05-09 18:07 ` Last minute fixes to the go bindings Austin Clements
  2012-05-11 11:45 ` David Bremner
  4 siblings, 0 replies; 8+ messages in thread
From: Justus Winter @ 2012-05-09 10:23 UTC (permalink / raw)
  To: notmuch

Add the constant STATUS_UNBALANCED_ATOMIC to the list of notmuch
status codes.

Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
---
 bindings/go/pkg/notmuch.go |    1 +
 1 file changed, 1 insertion(+)

diff --git a/bindings/go/pkg/notmuch.go b/bindings/go/pkg/notmuch.go
index e065b54..8faf3bb 100644
--- a/bindings/go/pkg/notmuch.go
+++ b/bindings/go/pkg/notmuch.go
@@ -24,6 +24,7 @@ const (
     STATUS_NULL_POINTER
     STATUS_TAG_TOO_LONG
     STATUS_UNBALANCED_FREEZE_THAW
+    STATUS_UNBALANCED_ATOMIC
 
     STATUS_LAST_STATUS
 )
-- 
1.7.10

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: Last minute fixes to the go bindings
  2012-05-09 10:23 Last minute fixes to the go bindings Justus Winter
                   ` (2 preceding siblings ...)
  2012-05-09 10:23 ` [PATCH 3/3] go: define the constant STATUS_UNBALANCED_ATOMIC Justus Winter
@ 2012-05-09 18:07 ` Austin Clements
  2012-05-10 14:36   ` Justus Winter
  2012-05-11 11:45 ` David Bremner
  4 siblings, 1 reply; 8+ messages in thread
From: Austin Clements @ 2012-05-09 18:07 UTC (permalink / raw)
  To: Justus Winter; +Cc: notmuch

LGTM.

Quoth Justus Winter on May 09 at 12:23 pm:
> Hi everyone :)
> 
> this is a small patch series that I'd like to see included in 0.13.
> 
> The first patch updates notmuch-addrlookup with respect to Austins
> recent change of the notmuch_database_open function. This fixes the
> compilation of the utility.
> 
> The second patch fixes the values of all the STATUS_* constants. Turns
> out all of them were set to zero by accident. This isn't a c style
> enum, golang has the iota operator to do this kind of stuff. This
> fixes the error handling for all the users of the go bindings.

'Doh!  Is it possible to get the status values out of cgo, rather than
depending on the list in libnotmuch and the list in Go being in the
same order?

> The third patch just brings the list of status constants up to date.
> 
> Cheers,
> Justus

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Last minute fixes to the go bindings
  2012-05-09 18:07 ` Last minute fixes to the go bindings Austin Clements
@ 2012-05-10 14:36   ` Justus Winter
  2012-05-10 17:00     ` David Bremner
  0 siblings, 1 reply; 8+ messages in thread
From: Justus Winter @ 2012-05-10 14:36 UTC (permalink / raw)
  To: Austin Clements; +Cc: notmuch

Quoting Austin Clements (2012-05-09 20:07:00)
> LGTM.
> 
> Quoth Justus Winter on May 09 at 12:23 pm:
> > Hi everyone :)
> > 
> > this is a small patch series that I'd like to see included in 0.13.
> > 
> > The first patch updates notmuch-addrlookup with respect to Austins
> > recent change of the notmuch_database_open function. This fixes the
> > compilation of the utility.
> > 
> > The second patch fixes the values of all the STATUS_* constants. Turns
> > out all of them were set to zero by accident. This isn't a c style
> > enum, golang has the iota operator to do this kind of stuff. This
> > fixes the error handling for all the users of the go bindings.
> 
> 'Doh!  Is it possible to get the status values out of cgo, rather than
> depending on the list in libnotmuch and the list in Go being in the
> same order?

Yes, it is and I've prepared a patch. But since I'm living in go 1
land here I prepared it on top of my go 1 patchset and I'm thinking of
sending it once that one got merged.

@David: what do you think about merging this patch set?

Justus

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Last minute fixes to the go bindings
  2012-05-10 14:36   ` Justus Winter
@ 2012-05-10 17:00     ` David Bremner
  0 siblings, 0 replies; 8+ messages in thread
From: David Bremner @ 2012-05-10 17:00 UTC (permalink / raw)
  To: Justus Winter, Austin Clements; +Cc: notmuch

Justus Winter <4winter@informatik.uni-hamburg.de> writes:
> @David: what do you think about merging this patch set?

Yeah, unless I am convinced otherwise, I will merge for the next release
candidate.

d

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Last minute fixes to the go bindings
  2012-05-09 10:23 Last minute fixes to the go bindings Justus Winter
                   ` (3 preceding siblings ...)
  2012-05-09 18:07 ` Last minute fixes to the go bindings Austin Clements
@ 2012-05-11 11:45 ` David Bremner
  4 siblings, 0 replies; 8+ messages in thread
From: David Bremner @ 2012-05-11 11:45 UTC (permalink / raw)
  To: Justus Winter, notmuch

Justus Winter <4winter@informatik.uni-hamburg.de> writes:

> Hi everyone :)
>
> this is a small patch series that I'd like to see included in 0.13.

pushed to release and master

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-05-11 11:45 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-09 10:23 Last minute fixes to the go bindings Justus Winter
2012-05-09 10:23 ` [PATCH 1/3] go: update notmuch-addrlookup to the new API Justus Winter
2012-05-09 10:23 ` [PATCH 2/3] go: fix the notmuch status constants Justus Winter
2012-05-09 10:23 ` [PATCH 3/3] go: define the constant STATUS_UNBALANCED_ATOMIC Justus Winter
2012-05-09 18:07 ` Last minute fixes to the go bindings Austin Clements
2012-05-10 14:36   ` Justus Winter
2012-05-10 17:00     ` David Bremner
2012-05-11 11:45 ` David Bremner

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).