[pygobject] Move variable declaration to top of blocks (C99ism)



commit 2e7c458ef6377a872043634b47737ef12eed744a
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Fri Jan 25 13:00:48 2013 +0800

    Move variable declaration to top of blocks (C99ism)
    
    Move variable declarations to the top of their respective blocks, so that these
    code will build under C89 compilers such as Visual C++.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=692856

 gi/pygi-argument.c        |   10 ++++++----
 gi/pygi-closure.c         |   23 +++++++++++++++--------
 gi/pygi-invoke.c          |    3 ++-
 gi/pygi-marshal-cleanup.c |    3 ++-
 gi/pygi-property.c        |    3 ++-
 5 files changed, 27 insertions(+), 15 deletions(-)
---
diff --git a/gi/pygi-argument.c b/gi/pygi-argument.c
index 34c4970..0933e89 100644
--- a/gi/pygi-argument.c
+++ b/gi/pygi-argument.c
@@ -477,10 +477,11 @@ _pygi_g_type_info_check_object (GITypeInfo *type_info,
 #else
                 {
                     PyObject *lower_pybytes_obj = PyUnicode_AsUTF8String (lower_str);
+                    PyObject *upper_pybytes_obj;
                     if (!lower_pybytes_obj)
                         goto utf8_fail;
 
-                    PyObject *upper_pybytes_obj = PyUnicode_AsUTF8String (upper_str);                    
+                    upper_pybytes_obj = PyUnicode_AsUTF8String (upper_str);
                     if (!upper_pybytes_obj) {
                         Py_DECREF(lower_pybytes_obj);
                         goto utf8_fail;
@@ -803,6 +804,10 @@ _pygi_argument_to_array (GIArgument  *arg,
             } else {
                 length = g_type_info_get_array_fixed_size (type_info);
                 if (length < 0) {
+                    gint length_arg_pos;
+                    GIArgInfo length_arg_info;
+                    GITypeInfo length_type_info;
+
                     if (G_UNLIKELY (args == NULL)) {
                         g_critical ("Unable to determine array length for %p",
                                     arg->v_pointer);
@@ -810,9 +815,6 @@ _pygi_argument_to_array (GIArgument  *arg,
                         *out_free_array = TRUE;
                         return g_array;
                     }
-                    gint length_arg_pos;
-                    GIArgInfo length_arg_info;
-                    GITypeInfo length_type_info;
 
                     length_arg_pos = g_type_info_get_array_length (type_info);
                     g_assert (length_arg_pos >= 0);
diff --git a/gi/pygi-closure.c b/gi/pygi-closure.c
index f2f21f0..43f41d2 100644
--- a/gi/pygi-closure.c
+++ b/gi/pygi-closure.c
@@ -277,22 +277,28 @@ _pygi_closure_convert_arguments (GICallableInfo *callable_info, void **args,
     g_args = _pygi_closure_convert_ffi_arguments (callable_info, args);
 
     for (i = 0; i < n_args; i++) {
+        GIArgInfo arg_info;
+        GIDirection direction;
+
         /* Special case callbacks and skip over userdata and Destroy Notify */
         if (i == user_data_arg || i == destroy_notify_arg)
             continue;
 
-        GIArgInfo arg_info;
         g_callable_info_load_arg (callable_info, i, &arg_info);
-        GIDirection direction = g_arg_info_get_direction (&arg_info);
+        direction = g_arg_info_get_direction (&arg_info);
 
         if (direction == GI_DIRECTION_IN || direction == GI_DIRECTION_INOUT) {
             GITypeInfo arg_type;
-            g_arg_info_load_type (&arg_info, &arg_type);
-            GITypeTag arg_tag = g_type_info_get_tag (&arg_type);
-            GITransfer transfer = g_arg_info_get_ownership_transfer (&arg_info);
+            GITypeTag arg_tag;
+            GITransfer transfer;
             PyObject *value;
             GIArgument *arg;
-            gboolean free_array = FALSE;
+            gboolean free_array;
+
+            g_arg_info_load_type (&arg_info, &arg_type);
+            arg_tag = g_type_info_get_tag (&arg_type);
+            transfer = g_arg_info_get_ownership_transfer (&arg_info);
+            free_array = FALSE;
 
             if (direction == GI_DIRECTION_IN && arg_tag == GI_TYPE_TAG_VOID &&
                     g_type_info_is_pointer (&arg_type)) {
@@ -413,10 +419,11 @@ _pygi_closure_set_out_arguments (GICallableInfo *callable_info,
     n_args = g_callable_info_get_n_args (callable_info);
     for (i = 0; i < n_args; i++) {
         GIArgInfo arg_info;
-        g_callable_info_load_arg (callable_info, i, &arg_info);
         GITypeInfo type_info;
+        GIDirection direction;
+        g_callable_info_load_arg (callable_info, i, &arg_info);
         g_arg_info_load_type (&arg_info, &type_info);
-        GIDirection direction = g_arg_info_get_direction (&arg_info);
+        direction = g_arg_info_get_direction (&arg_info);
 
         if (direction == GI_DIRECTION_OUT || direction == GI_DIRECTION_INOUT) {
             GITransfer transfer = g_arg_info_get_ownership_transfer (&arg_info);
diff --git a/gi/pygi-invoke.c b/gi/pygi-invoke.c
index 195a830..96ffde3 100644
--- a/gi/pygi-invoke.c
+++ b/gi/pygi-invoke.c
@@ -501,6 +501,7 @@ _invoke_marshal_in_args (PyGIInvokeState *state, PyGICallableCache *cache)
 
         c_arg = state->args[i];
         if (arg_cache->from_py_marshaller != NULL) {
+            gboolean success;
             if (!arg_cache->allow_none && py_arg == Py_None) {
                 PyErr_Format (PyExc_TypeError,
                               "Argument %zd does not allow None as a value",
@@ -511,7 +512,7 @@ _invoke_marshal_in_args (PyGIInvokeState *state, PyGICallableCache *cache)
                                                                    i - 1);
                  return FALSE;
             }
-            gboolean success = arg_cache->from_py_marshaller (state,
+            success = arg_cache->from_py_marshaller (state,
                                                               cache,
                                                               arg_cache,
                                                               py_arg,
diff --git a/gi/pygi-marshal-cleanup.c b/gi/pygi-marshal-cleanup.c
index b4f5af3..bd9522a 100644
--- a/gi/pygi-marshal-cleanup.c
+++ b/gi/pygi-marshal-cleanup.c
@@ -108,6 +108,7 @@ void
 pygi_marshal_cleanup_args_to_py_marshal_success (PyGIInvokeState   *state,
                                                  PyGICallableCache *cache)
 {
+    GSList *cache_item;
     /* clean up the return if available */
     if (cache->return_cache != NULL) {
         PyGIMarshalCleanupFunc cleanup_func = cache->return_cache->to_py_cleanup;
@@ -119,7 +120,7 @@ pygi_marshal_cleanup_args_to_py_marshal_success (PyGIInvokeState   *state,
     }
 
     /* Now clean up args */
-    GSList *cache_item = cache->to_py_args;
+    cache_item = cache->to_py_args;
     while (cache_item) {
         PyGIArgCache *arg_cache = (PyGIArgCache *) cache_item->data;
         PyGIMarshalCleanupFunc cleanup_func = arg_cache->to_py_cleanup;
diff --git a/gi/pygi-property.c b/gi/pygi-property.c
index 2e32fea..e7afc6b 100644
--- a/gi/pygi-property.c
+++ b/gi/pygi-property.c
@@ -104,6 +104,7 @@ pygi_get_property_value_real (PyGObject *instance, GParamSpec *pspec)
     PyObject *py_value = NULL;
     GITypeInfo *type_info = NULL;
     GITransfer transfer;
+    GITypeTag type_tag;
 
     /* The owner_type of the pspec gives us the exact type that introduced the
      * property, even if it is a parent class of the instance in question. */
@@ -118,7 +119,7 @@ pygi_get_property_value_real (PyGObject *instance, GParamSpec *pspec)
     type_info = g_property_info_get_type (property_info);
     transfer = g_property_info_get_ownership_transfer (property_info);
 
-    GITypeTag type_tag = g_type_info_get_tag (type_info);
+    type_tag = g_type_info_get_tag (type_info);
     switch (type_tag) {
         case GI_TYPE_TAG_BOOLEAN:
             arg.v_boolean = g_value_get_boolean (&value);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]