After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 620406 - support for caller-allocates annotations for structs
support for caller-allocates annotations for structs
Status: RESOLVED FIXED
Product: pygi
Classification: Deprecated
Component: general
unspecified
Other All
: Normal normal
: 0.6
Assigned To: pygi-maint
pygi-maint
Depends on:
Blocks:
 
 
Reported: 2010-06-02 20:59 UTC by johnp
Modified: 2010-06-07 09:30 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
support for caller-allocates annotations for structs (7.48 KB, patch)
2010-06-02 20:59 UTC, johnp
needs-work Details | Review
support for caller-allocates annotations for structs (7.64 KB, patch)
2010-06-03 16:30 UTC, johnp
accepted-commit_now Details | Review

Description johnp 2010-06-02 20:59:36 UTC
* out caller-allocates parameters expect an already constructed structure
  to be passed in by reference.  It is then modified and the caller uses the
  modified value.  We support this by using only one level of pointer
  indirection.
* Only structs are considered to be caller-allocates parameters even if
  they are marked as such by GI.  This is because the GI scanner isn't smart
  enough to correctly guess 100% of the time
* GValues are a special case of a caller-allocates parameter when cleaning
  up (e.g. g_value_unset is called).  GValues make no sense in a scripting
  language.  Developers should never deal with them.
Comment 1 johnp 2010-06-02 20:59:37 UTC
Created attachment 162573 [details] [review]
support for caller-allocates annotations for structs
Comment 2 Tomeu Vizoso 2010-06-03 15:14:41 UTC
Review of attachment 162573 [details] [review]:

Nice, please run autogen.sh so astyle gets run.

::: gi/pygi-invoke.c
@@ +300,3 @@
             GIDirection direction;
+            GIBaseInfo *info;
+

Extraneous space?

@@ +328,3 @@
+                    	GITypeTag type_tag;
+
+                        /* reset to False */

I wouldn't add such comments or we'll end up with more comments than code. This is a common enough idiom.

@@ +908,3 @@
+        	}
+
+        	g_free (state->args[i]);

Before we are malloc'inf if (caller_allocates && is_struct), but here we free always that caller_allocates.

::: tests/test_everything.py
@@ +78,3 @@
+        self.assertEquals(struct_b.nested_a.some_int8, struct_b_clone.nested_a.some_int8)
+        self.assertEquals(struct_b.nested_a.some_double, struct_b_clone.nested_a.some_double)
+        self.assertEquals(struct_b.nested_a.some_enum, struct_b_clone.nested_a.some_enum)

Aren't some of this tests already being called somewhere else?
Comment 3 johnp 2010-06-03 16:30:18 UTC
Created attachment 162668 [details] [review]
support for caller-allocates annotations for structs

* out caller-allocates parameters expect an already constructed structure
  to be passed in by reference.  It is then modified and the caller uses the
  modified value.  We support this by using only one level of pointer
  indirection.
* Only structs are considered to be caller-allocates parameters even if
  they are marked as such by GI.  This is because the GI scanner isn't smart
  enough to correctly guess 100% of the time
* GValues are a special case of a caller-allocates parameter when cleaning
  up (e.g. g_value_unset is called).  GValues make no sense in a scripting
  language.  Developers should never deal with them.
Comment 4 johnp 2010-06-03 16:31:51 UTC
You would think that the tests would be called somewhere else but they weren't so I added them.


Fixed up formatting, removed some comments, made sure to check for struct when freeing.
Comment 5 Tomeu Vizoso 2010-06-03 16:35:24 UTC
Review of attachment 162668 [details] [review]:

Great!