mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Phil Longstaff's patch to enable gnc_numeric to be a GValue
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@15854 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
7990568f9b
commit
b15d6171c7
@ -1263,6 +1263,40 @@ string_to_gnc_numeric(const gchar* str, gnc_numeric *n)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* *******************************************************************
|
||||||
|
* 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
|
* gnc_numeric misc testing
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
|
@ -50,6 +50,8 @@ See \ref gncnumericexample
|
|||||||
#ifndef GNC_NUMERIC_H
|
#ifndef GNC_NUMERIC_H
|
||||||
#define GNC_NUMERIC_H
|
#define GNC_NUMERIC_H
|
||||||
|
|
||||||
|
#include <glib-object.h>
|
||||||
|
|
||||||
struct _gnc_numeric
|
struct _gnc_numeric
|
||||||
{
|
{
|
||||||
gint64 num;
|
gint64 num;
|
||||||
@ -445,6 +447,13 @@ gnc_numeric gnc_numeric_convert_with_error(gnc_numeric in, gint64 denom,
|
|||||||
gnc_numeric gnc_numeric_reduce(gnc_numeric in);
|
gnc_numeric gnc_numeric_reduce(gnc_numeric in);
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
|
/** @name GValue
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
GType gnc_numeric_get_type( void );
|
||||||
|
|
||||||
|
/** @} */
|
||||||
|
|
||||||
/** @name Deprecated, backwards-compatible definitions
|
/** @name Deprecated, backwards-compatible definitions
|
||||||
@{
|
@{
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user