unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] go: add binding for notmuch_message_get_date
@ 2015-03-02 20:39 Trevor Jim
  2015-03-03 12:32 ` Tomi Ollila
  0 siblings, 1 reply; 6+ messages in thread
From: Trevor Jim @ 2015-03-02 20:39 UTC (permalink / raw)
  To: notmuch


---
 bindings/go/src/notmuch/notmuch.go | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/bindings/go/src/notmuch/notmuch.go b/bindings/go/src/notmuch/notmuch.go
index b9230ad..f5fd54c 100644
--- a/bindings/go/src/notmuch/notmuch.go
+++ b/bindings/go/src/notmuch/notmuch.go
@@ -801,7 +801,13 @@ func (self *Message) SetFlag(flag Flag, value bool) {
 	C.notmuch_message_set_flag(self.message, C.notmuch_message_flag_t(flag), v)
 }
 
-// TODO: wrap notmuch_message_get_date
+func  (self *Message) GetDate() int64 {
+	if self.message == nil {
+		return -1
+	}
+	timestamp := C.notmuch_message_get_date(self.message)
+	return int64(timestamp)
+}
 
 /* Get the value of the specified header from 'message'.
  *
-- 
2.2.2

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

* Re: [PATCH] go: add binding for notmuch_message_get_date
  2015-03-02 20:39 [PATCH] go: add binding for notmuch_message_get_date Trevor Jim
@ 2015-03-03 12:32 ` Tomi Ollila
  2015-03-03 14:10   ` David Bremner
  2015-03-03 16:39   ` Trevor Jim
  0 siblings, 2 replies; 6+ messages in thread
From: Tomi Ollila @ 2015-03-03 12:32 UTC (permalink / raw)
  To: Trevor Jim, notmuch

On Mon, Mar 02 2015, Trevor Jim <tjim@mac.com> wrote:

> ---
>  bindings/go/src/notmuch/notmuch.go | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/bindings/go/src/notmuch/notmuch.go b/bindings/go/src/notmuch/notmuch.go
> index b9230ad..f5fd54c 100644
> --- a/bindings/go/src/notmuch/notmuch.go
> +++ b/bindings/go/src/notmuch/notmuch.go
> @@ -801,7 +801,13 @@ func (self *Message) SetFlag(flag Flag, value bool) {
>  	C.notmuch_message_set_flag(self.message, C.notmuch_message_flag_t(flag), v)
>  }
>  
> -// TODO: wrap notmuch_message_get_date
> +func  (self *Message) GetDate() int64 {
> +	if self.message == nil {
> +		return -1

-1 is 1969-dec-31 23:59:59 UTC

Should we care -- and e.g. return status in separate return value ?

Tomi

> +	}
> +	timestamp := C.notmuch_message_get_date(self.message)
> +	return int64(timestamp)
> +}
>  
>  /* Get the value of the specified header from 'message'.
>   *
> -- 
> 2.2.2

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

* Re: [PATCH] go: add binding for notmuch_message_get_date
  2015-03-03 12:32 ` Tomi Ollila
@ 2015-03-03 14:10   ` David Bremner
  2015-03-03 16:22     ` Trevor Jim
  2015-03-03 16:39   ` Trevor Jim
  1 sibling, 1 reply; 6+ messages in thread
From: David Bremner @ 2015-03-03 14:10 UTC (permalink / raw)
  To: Tomi Ollila, Trevor Jim, notmuch

Tomi Ollila <tomi.ollila@iki.fi> writes:

>On Mon, Mar 02 2015, Trevor Jim <tjim@mac.com> wrote:
>>  
>> -// TODO: wrap notmuch_message_get_date
>> +func  (self *Message) GetDate() int64 {
>> +	if self.message == nil {
>> +		return -1
>
> -1 is 1969-dec-31 23:59:59 UTC
>
> Should we care -- and e.g. return status in separate return value ?

Given the current troubles with the main library API and missing status
values, I'd say in the long run we'll be happier with a real status
return. OTOH, I don't much about go.

d

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

* Re: [PATCH] go: add binding for notmuch_message_get_date
  2015-03-03 14:10   ` David Bremner
@ 2015-03-03 16:22     ` Trevor Jim
  2015-03-06  7:20       ` David Bremner
  0 siblings, 1 reply; 6+ messages in thread
From: Trevor Jim @ 2015-03-03 16:22 UTC (permalink / raw)
  To: David Bremner, Tomi Ollila, notmuch

> Given the current troubles with the main library API and missing status
> values, I'd say in the long run we'll be happier with a real status
> return. OTOH, I don't much about go.

I'm not sure what the "current troubles" are (happy to hear more), but
the way I've handled the nil case is in keeping with the way it's
handled in the other function bindings for go.  Adding an error return
to all relevant functions seems like a big change that should be handled
separately, yes?

In defense of the current strategy, any caller can check for the nil
case before calling.

-T

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

* Re: [PATCH] go: add binding for notmuch_message_get_date
  2015-03-03 12:32 ` Tomi Ollila
  2015-03-03 14:10   ` David Bremner
@ 2015-03-03 16:39   ` Trevor Jim
  1 sibling, 0 replies; 6+ messages in thread
From: Trevor Jim @ 2015-03-03 16:39 UTC (permalink / raw)
  To: Tomi Ollila, notmuch

> -1 is 1969-dec-31 23:59:59 UTC
>
> Should we care -- and e.g. return status in separate return value ?

BTW, I notice that when a message has no Date: field, notmuch reports its
timestamp as 0 without reporting an error :-)

-Trevor

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

* Re: [PATCH] go: add binding for notmuch_message_get_date
  2015-03-03 16:22     ` Trevor Jim
@ 2015-03-06  7:20       ` David Bremner
  0 siblings, 0 replies; 6+ messages in thread
From: David Bremner @ 2015-03-06  7:20 UTC (permalink / raw)
  To: Trevor Jim, Tomi Ollila, notmuch

Trevor Jim <tjim@mac.com> writes:


> I'm not sure what the "current troubles" are (happy to hear more), but
> the way I've handled the nil case is in keeping with the way it's
> handled in the other function bindings for go.  Adding an error return
> to all relevant functions seems like a big change that should be handled
> separately, yes?

It seems like at least some functions [1] already use multiple return values
to return a status value.  There is also already a STATUS_NULL_POINTER
defined.  

[1]: from notmuch.go

func NewDatabase(path string) (*Database, Status) {
func OpenDatabase(path string, mode DatabaseMode) (*Database, Status) {
func (self *Database) Close() Status {
func (self *Database) GetDirectory(path string) (*Directory, Status) {
func (self *Database) AddMessage(fname string) (*Message, Status) {
func (self *Database) RemoveMessage(fname string) Status {
func (self *Database) FindMessage(message_id string) (*Message, Status) {
func (self *Message) AddTag(tag string) Status {
func (self *Message) RemoveTag(tag string) Status {
func (self *Message) RemoveAllTags() Status {
func (self *Message) Freeze() Status {
func (self *Message) Thaw() Status {

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

end of thread, other threads:[~2015-03-06  7:23 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-02 20:39 [PATCH] go: add binding for notmuch_message_get_date Trevor Jim
2015-03-03 12:32 ` Tomi Ollila
2015-03-03 14:10   ` David Bremner
2015-03-03 16:22     ` Trevor Jim
2015-03-06  7:20       ` David Bremner
2015-03-03 16:39   ` Trevor Jim

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