[aravis/dom] gc: code cleanup.
- From: Emmanuel Pacaud <emmanuel src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [aravis/dom] gc: code cleanup.
- Date: Fri, 2 Mar 2012 15:27:01 +0000 (UTC)
commit 2e00e37b81dad5d1bf298247d01a668f9d8c2b10
Author: Emmanuel Pacaud <emmanuel gnome org>
Date: Fri Mar 2 16:26:42 2012 +0100
gc: code cleanup.
src/arvgc.c | 84 --------------------------------------------------
src/arvgc.h | 4 --
src/arvgcindexnode.c | 35 +++++++++++++-------
src/arvgcindexnode.h | 3 +-
4 files changed, 25 insertions(+), 101 deletions(-)
---
diff --git a/src/arvgc.c b/src/arvgc.c
index a26efca..cc4a845 100644
--- a/src/arvgc.c
+++ b/src/arvgc.c
@@ -232,90 +232,6 @@ arv_gc_get_device (ArvGc *genicam)
return genicam->device;
}
-gint64
-arv_gc_get_int64_from_value (ArvGc *genicam, GValue *value)
-{
- g_return_val_if_fail (ARV_IS_GC (genicam), 0);
- g_return_val_if_fail (G_IS_VALUE (value), 0);
-
- if (G_VALUE_HOLDS_INT64 (value))
- return g_value_get_int64 (value);
- else if (G_VALUE_HOLDS_STRING (value)) {
- ArvGcNode *node;
-
- node = arv_gc_get_node (genicam, g_value_get_string (value));
- if (ARV_IS_GC_INTEGER (node))
- return arv_gc_integer_get_value (ARV_GC_INTEGER (node));
- else
- arv_warning_genicam ("[Gc::set_int64_to_value] Invalid node '%s'",
- arv_gc_feature_node_get_name (ARV_GC_FEATURE_NODE (node)));
- }
-
- return 0;
-}
-
-void
-arv_gc_set_int64_to_value (ArvGc *genicam, GValue *value, gint64 v_int64)
-{
- g_return_if_fail (ARV_IS_GC (genicam));
- g_return_if_fail (G_IS_VALUE (value));
-
- if (G_VALUE_HOLDS_INT64 (value))
- return g_value_set_int64 (value, v_int64);
- else if (G_VALUE_HOLDS_STRING (value)) {
- ArvGcNode *node;
-
- node = arv_gc_get_node (genicam, g_value_get_string (value));
- if (ARV_IS_GC_INTEGER (node))
- arv_gc_integer_set_value (ARV_GC_INTEGER (node), v_int64);
- else
- arv_warning_genicam ("[Gc::set_int64_to_value] Invalid node '%s'",
- arv_gc_feature_node_get_name (ARV_GC_FEATURE_NODE (node)));
- }
-}
-
-double
-arv_gc_get_double_from_value (ArvGc *genicam, GValue *value)
-{
- g_return_val_if_fail (ARV_IS_GC (genicam), 0);
- g_return_val_if_fail (G_IS_VALUE (value), 0);
-
- if (G_VALUE_HOLDS_DOUBLE (value))
- return g_value_get_double (value);
- else if (G_VALUE_HOLDS_STRING (value)) {
- ArvGcNode *node;
-
- node = arv_gc_get_node (genicam, g_value_get_string (value));
- if (ARV_IS_GC_FLOAT (node))
- return arv_gc_float_get_value (ARV_GC_FLOAT (node));
- else
- arv_warning_genicam ("[Gc::set_double_to_value] Invalid node '%s'",
- arv_gc_feature_node_get_name (ARV_GC_FEATURE_NODE (node)));
- }
-
- return 0.0;
-}
-
-void
-arv_gc_set_double_to_value (ArvGc *genicam, GValue *value, double v_double)
-{
- g_return_if_fail (ARV_IS_GC (genicam));
- g_return_if_fail (G_IS_VALUE (value));
-
- if (G_VALUE_HOLDS_DOUBLE (value))
- return g_value_set_double (value, v_double);
- else if (G_VALUE_HOLDS_STRING (value)) {
- ArvGcNode *node;
-
- node = arv_gc_get_node (genicam, g_value_get_string (value));
- if (ARV_IS_GC_FLOAT (node))
- arv_gc_float_set_value (ARV_GC_FLOAT (node), v_double);
- else
- arv_warning_genicam ("[Gc::set_double_to_value] Invalid node '%s'",
- arv_gc_feature_node_get_name (ARV_GC_FEATURE_NODE (node)));
- }
-}
-
void
arv_gc_register_feature_node (ArvGc *genicam, ArvGcFeatureNode *node)
{
diff --git a/src/arvgc.h b/src/arvgc.h
index 67c7722..3b6f5f9 100644
--- a/src/arvgc.h
+++ b/src/arvgc.h
@@ -52,10 +52,6 @@ GType arv_gc_get_type (void);
ArvGc * arv_gc_new (ArvDevice *device, const void *xml, size_t size);
void arv_gc_register_feature_node (ArvGc *genicam, ArvGcFeatureNode *node);
-gint64 arv_gc_get_int64_from_value (ArvGc *genicam, GValue *value);
-void arv_gc_set_int64_to_value (ArvGc *genicam, GValue *value, gint64 v_int64);
-double arv_gc_get_double_from_value (ArvGc *genicam, GValue *value);
-void arv_gc_set_double_to_value (ArvGc *genicam, GValue *value, double v_double);
ArvGcNode * arv_gc_get_node (ArvGc *genicam, const char *name);
ArvDevice * arv_gc_get_device (ArvGc *genicam);
diff --git a/src/arvgcindexnode.c b/src/arvgcindexnode.c
index ae88277..e40d7d5 100644
--- a/src/arvgcindexnode.c
+++ b/src/arvgcindexnode.c
@@ -27,6 +27,7 @@
#include <arvgcindexnode.h>
#include <arvgcpropertynode.h>
+#include <arvgcinteger.h>
#include <arvgc.h>
#include <arvdomtext.h>
#include <arvmisc.h>
@@ -55,10 +56,15 @@ arv_gc_index_node_set_attribute (ArvDomElement *self, const char *name, const ch
{
ArvGcIndexNode *index_node = ARV_GC_INDEX_NODE (self);
- if (strcmp (name, "Offset") == 0)
- arv_force_g_value_to_int64 (&index_node->offset, g_ascii_strtoll (value, NULL, 0));
- else if (strcmp (name, "pOffset") == 0)
- arv_force_g_value_to_string (&index_node->offset, value);
+ if (strcmp (name, "Offset") == 0) {
+ g_free (index_node->offset);
+ index_node->offset = g_strdup (value);
+ index_node->is_p_offset = FALSE;
+ } else if (strcmp (name, "pOffset") == 0) {
+ g_free (index_node->offset);
+ index_node->offset = g_strdup (value);
+ index_node->is_p_offset = TRUE;
+ }
}
static const char *
@@ -78,13 +84,18 @@ arv_gc_index_node_get_index (ArvGcIndexNode *index_node, gint64 default_offset)
g_return_val_if_fail (ARV_IS_GC_INDEX_NODE (index_node), 0);
- if (G_VALUE_HOLDS_BOOLEAN (&index_node->offset))
+ if (index_node->offset == NULL)
offset = default_offset;
else {
- ArvGc *genicam;
-
- genicam = arv_gc_node_get_genicam (ARV_GC_NODE (index_node));
- offset = arv_gc_get_int64_from_value (genicam, &index_node->offset);
+ if (index_node->is_p_offset) {
+ ArvGcNode *node;
+ ArvGc *genicam;
+
+ genicam = arv_gc_node_get_genicam (ARV_GC_NODE (index_node));
+ node = arv_gc_get_node (genicam, index_node->offset);
+ offset = arv_gc_integer_get_value (ARV_GC_INTEGER (node));
+ } else
+ offset = g_ascii_strtoll (index_node->offset, NULL, 0);
}
return offset * arv_gc_property_node_get_int64 (ARV_GC_PROPERTY_NODE (index_node));
@@ -104,8 +115,8 @@ arv_gc_index_node_new (void)
static void
arv_gc_index_node_init (ArvGcIndexNode *index_node)
{
- g_value_init (&index_node->offset, G_TYPE_BOOLEAN);
- g_value_set_boolean (&index_node->offset, FALSE);
+ index_node->offset = NULL;
+ index_node->is_p_offset = FALSE;
}
static void
@@ -113,7 +124,7 @@ arv_gc_index_node_finalize (GObject *object)
{
ArvGcIndexNode *index_node = ARV_GC_INDEX_NODE (object);
- g_value_unset (&index_node->offset);
+ g_free (index_node->offset);
parent_class->finalize (object);
}
diff --git a/src/arvgcindexnode.h b/src/arvgcindexnode.h
index 8c2a550..b29abee 100644
--- a/src/arvgcindexnode.h
+++ b/src/arvgcindexnode.h
@@ -40,7 +40,8 @@ typedef struct _ArvGcIndexNodeClass ArvGcIndexNodeClass;
struct _ArvGcIndexNode {
ArvGcPropertyNode base;
- GValue offset;
+ char *offset;
+ gboolean is_p_offset;
};
struct _ArvGcIndexNodeClass {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]