r18769 - gnucash/trunk/src/libqof/qof - Add support for passing a Timespec as a boxed GValue

Phil Longstaff plongstaff at code.gnucash.org
Mon Mar 1 13:04:33 EST 2010


Author: plongstaff
Date: 2010-03-01 13:04:33 -0500 (Mon, 01 Mar 2010)
New Revision: 18769
Trac: http://svn.gnucash.org/trac/changeset/18769

Modified:
   gnucash/trunk/src/libqof/qof/gnc-date.c
   gnucash/trunk/src/libqof/qof/gnc-date.h
Log:
Add support for passing a Timespec as a boxed GValue


Modified: gnucash/trunk/src/libqof/qof/gnc-date.c
===================================================================
--- gnucash/trunk/src/libqof/qof/gnc-date.c	2010-03-01 18:03:51 UTC (rev 18768)
+++ gnucash/trunk/src/libqof/qof/gnc-date.c	2010-03-01 18:04:33 UTC (rev 18769)
@@ -1520,3 +1520,38 @@
     i = qof_strftime(buf, buf_len, "%a", &my_tm);
     buf[i] = 0;
 }
+
+/* *******************************************************************
+ *  GValue handling
+ ********************************************************************/
+static gpointer
+timespec_boxed_copy_func( gpointer in_timespec )
+{
+    Timespec* newvalue;
+
+    newvalue = g_malloc( sizeof( Timespec ) );
+    memcpy( newvalue, in_timespec, sizeof( Timespec ) );
+
+    return newvalue;
+}
+
+static void
+timespec_boxed_free_func( gpointer in_timespec )
+{
+    g_free( in_timespec );
+}
+
+GType
+timespec_get_type( void )
+{
+    static GType type = 0;
+
+    if ( type == 0 )
+    {
+        type = g_boxed_type_register_static( "timespec",
+                                             timespec_boxed_copy_func,
+                                             timespec_boxed_free_func );
+    }
+
+    return type;
+}

Modified: gnucash/trunk/src/libqof/qof/gnc-date.h
===================================================================
--- gnucash/trunk/src/libqof/qof/gnc-date.h	2010-03-01 18:03:51 UTC (rev 18768)
+++ gnucash/trunk/src/libqof/qof/gnc-date.h	2010-03-01 18:04:33 UTC (rev 18769)
@@ -67,8 +67,16 @@
 #ifndef GNC_DATE_H
 #define GNC_DATE_H
 
+#include <glib-object.h>
 #include <time.h>
 
+/** @name GValue
+  @{
+*/
+GType timespec_get_type( void );
+#define GNC_TYPE_TIMESPEC (timespec_get_type ())
+
+/** @} */
 /** The default date format for use with strftime. */
 extern const char *gnc_default_strftime_date_format;
 



More information about the gnucash-changes mailing list