r15186 - gnucash/branches/gda-dev/lib/libqof/qof - Add support for gnc_numeric as a boxed GValue

Phil Longstaff plongstaff at cvs.gnucash.org
Tue Dec 5 22:16:19 EST 2006


Author: plongstaff
Date: 2006-12-05 22:16:18 -0500 (Tue, 05 Dec 2006)
New Revision: 15186
Trac: http://svn.gnucash.org/trac/changeset/15186

Modified:
   gnucash/branches/gda-dev/lib/libqof/qof/gnc-numeric.c
   gnucash/branches/gda-dev/lib/libqof/qof/gnc-numeric.h
Log:
Add support for gnc_numeric as a boxed GValue


Modified: gnucash/branches/gda-dev/lib/libqof/qof/gnc-numeric.c
===================================================================
--- gnucash/branches/gda-dev/lib/libqof/qof/gnc-numeric.c	2006-12-05 21:21:21 UTC (rev 15185)
+++ gnucash/branches/gda-dev/lib/libqof/qof/gnc-numeric.c	2006-12-06 03:16:18 UTC (rev 15186)
@@ -1261,6 +1261,40 @@
 }
 
 /* *******************************************************************
+ *  GValue handling
+ ********************************************************************/
+static gpointer
+gnc_numeric_boxed_copy_func( gpointer in_gnc_numeric )
+{
+	gnc_numeric* newvalue;
+
+	newvalue = g_malloc( sizeof( gnc_numeric ) );
+	memcpy( newvalue, in_gnc_numeric, sizeof( gnc_numeric ) );
+
+	return newvalue;
+}
+
+static void
+gnc_numeric_boxed_free_func( gpointer in_gnc_numeric )
+{
+	g_free( in_gnc_numeric );
+}
+
+GType
+gnc_numeric_get_type( void )
+{
+	static GType type = 0;
+
+	if( type == 0 ) {
+		type = g_boxed_type_register_static( "gnc_numeric",
+											gnc_numeric_boxed_copy_func,
+											gnc_numeric_boxed_free_func );
+	}
+
+	return type;
+}
+
+/* *******************************************************************
  *  gnc_numeric misc testing
  ********************************************************************/
 #ifdef _GNC_NUMERIC_TEST

Modified: gnucash/branches/gda-dev/lib/libqof/qof/gnc-numeric.h
===================================================================
--- gnucash/branches/gda-dev/lib/libqof/qof/gnc-numeric.h	2006-12-05 21:21:21 UTC (rev 15185)
+++ gnucash/branches/gda-dev/lib/libqof/qof/gnc-numeric.h	2006-12-06 03:16:18 UTC (rev 15186)
@@ -50,6 +50,8 @@
 #ifndef GNC_NUMERIC_H
 #define GNC_NUMERIC_H
 
+#include <glib-object.h>
+
 struct _gnc_numeric 
 {
   gint64  num;
@@ -445,6 +447,13 @@
 gnc_numeric gnc_numeric_reduce(gnc_numeric in);
 /** @} */
 
+/** @name GValue 
+  @{
+*/
+GType gnc_numeric_get_type( void );
+
+/** @} */
+
 /** @name Deprecated, backwards-compatible definitions 
   @{
 */



More information about the gnucash-changes mailing list