[virt-tools-list] [PATCH 06/47] Sanitize API naming for OsinfoEntity class

Daniel P. Berrange berrange at redhat.com
Wed Aug 25 19:37:01 UTC 2010


The GObject naming conversion is lowercase, separated
by underscores. This needs to be followed to allow
gobject introspection to be auto-generated easily.

* osinfo/osinfo_common.h: Remove declaration of
  methods that belong in osinfo_entity.h
* osinfo/osinfo_entity.c, osinfo/osinfo_entity.h: Convert
  API naming to use lowercase + underscores. Add an
  explicit constructor.
* osinfo/osinfo_filter.c, osinfo/osinfo_hypervisor.c: Update
  for changed API names
---
 osinfo/osinfo_common.h     |    7 ++-----
 osinfo/osinfo_dataread.c   |    6 +++---
 osinfo/osinfo_entity.c     |   20 ++++++++++----------
 osinfo/osinfo_entity.h     |   10 ++++++----
 osinfo/osinfo_filter.c     |    4 ++--
 osinfo/osinfo_hypervisor.c |    2 +-
 6 files changed, 24 insertions(+), 25 deletions(-)

diff --git a/osinfo/osinfo_common.h b/osinfo/osinfo_common.h
index 4046043..386446d 100644
--- a/osinfo/osinfo_common.h
+++ b/osinfo/osinfo_common.h
@@ -120,8 +120,8 @@ void __osinfoListAdd(OsinfoList *self, OsinfoEntity *entity);
 int __osinfoAddDeviceToSection(GTree *allSections, GTree *allSectionsAsList, gchar *sectionName, gchar *id, gchar *driver);
 void __osinfoClearDeviceSection(GTree *allSections, GTree *allSectionsAsList, gchar *section);
 
-gboolean __osinfoGetKeys(gpointer key, gpointer value, gpointer data);
-void __osinfoDupArray(gpointer data, gpointer user_data);
+gboolean osinfo_get_keys(gpointer key, gpointer value, gpointer data);
+void osinfo_dup_array(gpointer data, gpointer user_data);
 
 int __osinfoEntityPassesFilter(OsinfoFilter *filter, OsinfoEntity *device);
 int __osinfoDevicePassesFilter(OsinfoFilter *filter, OsinfoDevice *device);
@@ -249,6 +249,3 @@ void __osinfoRemoveHvSectionFromOs(OsinfoOs *self, gchar *hvId);
 int __osinfoAddDeviceToSectionHv(OsinfoHypervisor *self, gchar *section, gchar *id, gchar *driver);
 void __osinfoClearDeviceSectionHv(OsinfoHypervisor *self, gchar *section);
 
-// Private
-int __osinfoAddParam(OsinfoEntity *self, gchar *key, gchar *value);
-void __osinfoClearParam(OsinfoEntity *self, gchar *key);
diff --git a/osinfo/osinfo_dataread.c b/osinfo/osinfo_dataread.c
index e301cb9..e186e83 100644
--- a/osinfo/osinfo_dataread.c
+++ b/osinfo/osinfo_dataread.c
@@ -524,7 +524,7 @@ static int __osinfoProcessOs(OsinfoDb *db,
             if (err != 0 || !key || !val)
                 goto cleanup_error;
 
-            err = __osinfoAddParam(OSINFO_ENTITY(os), key, val);
+            err = osinfo_entity_add_param(OSINFO_ENTITY(os), key, val);
             if (err != 0)
                 goto cleanup_error;
 
@@ -636,7 +636,7 @@ static int __osinfoProcessHypervisor(OsinfoDb *db,
                 goto cleanup_error;
 
 
-            err = __osinfoAddParam(OSINFO_ENTITY(hv), key, val);
+            err = osinfo_entity_add_param(OSINFO_ENTITY(hv), key, val);
             free(key);
             free(val);
             if (err != 0)
@@ -730,7 +730,7 @@ static int __osinfoProcessDevice(OsinfoDb *db,
         if (err != 0 || !key || !val)
             goto cleanup_error;
 
-        err = __osinfoAddParam(OSINFO_ENTITY(dev), key, val);
+        err = osinfo_entity_add_param(OSINFO_ENTITY(dev), key, val);
         if (err != 0)
             goto cleanup_error;
 
diff --git a/osinfo/osinfo_entity.c b/osinfo/osinfo_entity.c
index 5aab00f..e9492db 100644
--- a/osinfo/osinfo_entity.c
+++ b/osinfo/osinfo_entity.c
@@ -111,7 +111,7 @@ osinfo_entity_init (OsinfoEntity *self)
     self->priv->params = g_tree_new_full(__osinfoStringCompare, NULL, g_free, __osinfoFreeParamVals);
 }
 
-int __osinfoAddParam(OsinfoEntity *self, gchar *key, gchar *value)
+int osinfo_entity_add_param(OsinfoEntity *self, gchar *key, gchar *value)
 {
     if (!OSINFO_IS_ENTITY(self) || !key || !value)
         return -EINVAL;
@@ -140,12 +140,12 @@ int __osinfoAddParam(OsinfoEntity *self, gchar *key, gchar *value)
     return 0;
 }
 
-void __osinfoClearParam(OsinfoEntity *self, gchar *key)
+void osinfo_entity_clear_param(OsinfoEntity *self, gchar *key)
 {
     g_tree_remove(self->priv->params, key);
 }
 
-gboolean __osinfoGetKeys(gpointer key, gpointer value, gpointer data)
+gboolean osinfo_get_keys(gpointer key, gpointer value, gpointer data)
 {
     struct __osinfoPtrArrayErr *arrayErr = (struct __osinfoPtrArrayErr *) data;
     GPtrArray *results = arrayErr->array;
@@ -155,7 +155,7 @@ gboolean __osinfoGetKeys(gpointer key, gpointer value, gpointer data)
     return FALSE; // Continue iterating
 }
 
-void __osinfoDupArray(gpointer data, gpointer user_data)
+void osinfo_dup_array(gpointer data, gpointer user_data)
 {
     struct __osinfoPtrArrayErr *arrayErr = (struct __osinfoPtrArrayErr *) data;
     GPtrArray *results = arrayErr->array;
@@ -168,7 +168,7 @@ void __osinfoDupArray(gpointer data, gpointer user_data)
     g_ptr_array_add(results, valueDup);
 }
 
-gchar *osinfoGetId(OsinfoEntity *self, GError **err)
+gchar *osinfo_entity_get_id(OsinfoEntity *self, GError **err)
 {
     if (!__osinfoCheckGErrorParamValid(err))
         return NULL;
@@ -183,7 +183,7 @@ gchar *osinfoGetId(OsinfoEntity *self, GError **err)
     return dupId;
 }
 
-GPtrArray *osinfoGetParams(OsinfoEntity *self, GError **err)
+GPtrArray *osinfo_entity_get_params(OsinfoEntity *self, GError **err)
 {
     if (!__osinfoCheckGErrorParamValid(err))
         return NULL;
@@ -200,7 +200,7 @@ GPtrArray *osinfoGetParams(OsinfoEntity *self, GError **err)
     }
 
     struct __osinfoPtrArrayErr arrayErr = {params, 0};
-    g_tree_foreach(self->priv->params, __osinfoGetKeys, &arrayErr);
+    g_tree_foreach(self->priv->params, osinfo_get_keys, &arrayErr);
 
     // If we had an error, cleanup and return NULL
     if (arrayErr.err != 0) {
@@ -215,7 +215,7 @@ GPtrArray *osinfoGetParams(OsinfoEntity *self, GError **err)
     return params;
 }
 
-gchar *osinfoGetParamValue(OsinfoEntity *self, gchar *key, GError **err)
+gchar *osinfo_entity_get_param_value(OsinfoEntity *self, gchar *key, GError **err)
 {
     if (!__osinfoCheckGErrorParamValid(err))
         return NULL;
@@ -247,7 +247,7 @@ gchar *osinfoGetParamValue(OsinfoEntity *self, gchar *key, GError **err)
     return firstValueDup;
 }
 
-GPtrArray *osinfoGetParamAllValues(OsinfoEntity *self, gchar *key, GError **err)
+GPtrArray *osinfo_entity_get_param_all_values(OsinfoEntity *self, gchar *key, GError **err)
 {
     if (!__osinfoCheckGErrorParamValid(err))
         return NULL;
@@ -280,7 +280,7 @@ GPtrArray *osinfoGetParamAllValues(OsinfoEntity *self, gchar *key, GError **err)
         return retArray;
 
     struct __osinfoPtrArrayErr arrayErr = {retArray, 0};
-    g_ptr_array_foreach(srcArray, __osinfoDupArray, &arrayErr);
+    g_ptr_array_foreach(srcArray, osinfo_dup_array, &arrayErr);
     if (arrayErr.err) {
         g_set_error_literal(err, g_quark_from_static_string("libosinfo"), arrayErr.err, __osinfoErrorToString(arrayErr.err));
         g_ptr_array_set_free_func(retArray, g_free);
diff --git a/osinfo/osinfo_entity.h b/osinfo/osinfo_entity.h
index e4ffa06..e5a2bc1 100644
--- a/osinfo/osinfo_entity.h
+++ b/osinfo/osinfo_entity.h
@@ -45,9 +45,11 @@ struct _OsinfoEntityClass
 
 GType osinfo_entity_get_type(void);
 
-gchar *osinfoGetId(OsinfoEntity *self, GError **err);
-GPtrArray *osinfoGetParams(OsinfoEntity *self, GError **err);
-gchar *osinfoGetParamValue(OsinfoEntity *self, gchar *key, GError **err);
-GPtrArray *osinfoGetParamAllValues(OsinfoEntity *self, gchar *key, GError **err);
+gchar *osinfo_entity_get_id(OsinfoEntity *self, GError **err);
+GPtrArray *osinfo_entity_get_params(OsinfoEntity *self, GError **err);
+gchar *osinfo_entity_get_param_value(OsinfoEntity *self, gchar *key, GError **err);
+GPtrArray *osinfo_entity_get_param_all_values(OsinfoEntity *self, gchar *key, GError **err);
+int osinfo_entity_add_param(OsinfoEntity *self, gchar *key, gchar *value);
+void osinfo_entity_clear_param(OsinfoEntity *self, gchar *key);
 
 #endif /* __OSINFO_ENTITY_H__ */
diff --git a/osinfo/osinfo_filter.c b/osinfo/osinfo_filter.c
index ed3bd6d..6a2a833 100644
--- a/osinfo/osinfo_filter.c
+++ b/osinfo/osinfo_filter.c
@@ -184,7 +184,7 @@ GPtrArray *osinfoGetFilterConstraintKeys(OsinfoFilter *self, GError **err)
     }
 
     struct __osinfoPtrArrayErr arrayErr = {constraints, 0};
-    g_tree_foreach(self->priv->propertyConstraints, __osinfoGetKeys, &arrayErr);
+    g_tree_foreach(self->priv->propertyConstraints, osinfo_get_keys, &arrayErr);
 
     // If we had an error, cleanup and return NULL
     if (arrayErr.err != 0) {
@@ -233,7 +233,7 @@ GPtrArray *osinfoGetFilterConstraintValues(OsinfoFilter *self, gchar *propName,
         return retArray;
 
     struct __osinfoPtrArrayErr arrayErr = {retArray, 0};
-    g_ptr_array_foreach(srcArray, __osinfoDupArray, &arrayErr);
+    g_ptr_array_foreach(srcArray, osinfo_dup_array, &arrayErr);
     if (arrayErr.err) {
         g_set_error_literal(err, g_quark_from_static_string("libosinfo"), arrayErr.err, __osinfoErrorToString(arrayErr.err));
         g_ptr_array_set_free_func(retArray, g_free);
diff --git a/osinfo/osinfo_hypervisor.c b/osinfo/osinfo_hypervisor.c
index 712766f..e2c7951 100644
--- a/osinfo/osinfo_hypervisor.c
+++ b/osinfo/osinfo_hypervisor.c
@@ -72,7 +72,7 @@ GPtrArray *osinfoGetHypervisorDeviceTypes(OsinfoHypervisor *self, GError **err)
 
     // For each key in our tree of device sections, dup and add to the array
     struct __osinfoPtrArrayErr arrayErr = {deviceTypes, 0};
-    g_tree_foreach(self->priv->sections, __osinfoGetKeys, &arrayErr);
+    g_tree_foreach(self->priv->sections, osinfo_get_keys, &arrayErr);
     return deviceTypes;
 }
 
-- 
1.7.2.1




More information about the virt-tools-list mailing list