summaryrefslogtreecommitdiff
path: root/gi/pygi-boxed.c
Commit message (Collapse)AuthorAgeFilesLines
* Remove GObject.Value.__del__Christoph Reiter2019-01-151-13/+4
| | | | | | We can move this into tp_dealloc now. Only call unset() in the slice allocate case since g_boxed_free() will do it anyway.
* boxed: remove __del__ implementation and free in tp_deallocChristoph Reiter2019-01-151-16/+18
| | | | | | | | | | | | This allows us to assume that the wrapper is always valid and remove the _is_valid attribute. One difference now is that g_boxed_free() is called when the wrapper can no longer be used and that breaks the custom glib sources where g_boxed_free() triggers the finalize callback which tries to call into a method of the wrapper. To work around this provide a _clear_boxed() method which allows the wrapper to free the underlying boxed in __del__ where the wrapper is still usable.
* boxed: don't look up the gtype in tp_dealloc, we already know itChristoph Reiter2019-01-151-3/+1
|
* boxed: hide the PyGIBoxed structChristoph Reiter2019-01-151-0/+6
|
* Don't crash on multiple calls to GObject.Value.__del__. See !66Christoph Reiter2018-05-041-0/+7
| | | | | | | | | After chaining up accessing anything on the instance will crash like accessing self.g_type in this case. Guard against that by exposing if the wrapped boxed is still there. Ideally we shouldn't invalidate the object in __del__, but various things depend on it atm. For another time..
* pypy: pass a warning subclass to PyErr_Warn and not an exception, pypy ↵Christoph Reiter2018-04-221-1/+1
| | | | | | does't support that. TypeError is wrong there anyway.
* Port more integer convertersChristoph Reiter2018-03-311-1/+2
|
* pygi-boxed: clean up function namesChristoph Reiter2018-03-311-17/+17
|
* Merge pygtype.c and pygi-type.cChristoph Reiter2018-03-311-1/+1
| | | | No need to have two similarly named files
* Make sure that types are fully initialized when they are first used.Christoph Reiter2018-03-241-0/+1
| | | | | | | This asserts that PyType_Ready() was called on the types before using them to create instances or as base class for other types. With this PyPy no longer crashes when importing the _gi module.
* Add error handling to all type init function.Christoph Reiter2018-03-231-6/+14
| | | | | They were all just ignoring errors. Also change those functions to use the pygi prefix.
* Rename pyglib-python-compat.h to pygi-python-compat.hChristoph Reiter2018-03-231-1/+1
| | | | There is no pyglib anymore
* Revert "Revert "pygi-boxed: make in-place copy safer""Mathieu Duponchelle2018-02-161-1/+7
| | | | This reverts commit 700c785367975995d24a8ffd00b2aa028ccf77e8.
* Revert "Revert "Revert "Refactor boxed wrapper memory management strategy"""Mathieu Duponchelle2018-02-161-25/+7
| | | | This reverts commit a506d5e3c64321c43a4ce7c2a72ca8d36e985999.
* Revert "Revert "Refactor boxed wrapper memory management strategy""Christoph Reiter2018-02-131-7/+25
| | | | This reverts commit daefdfa3e4dc97b4ae38250358d722f09764cc9b.
* Revert "pygi-boxed: make in-place copy safer"Christoph Reiter2018-02-131-7/+1
| | | | This reverts commit 9d96df1ea3ad533885fbcae4de693a3cd81e765a.
* pygi-boxed: make in-place copy saferMathieu Duponchelle2018-01-231-1/+7
| | | | | | Making sure we don't attempt to g_boxed_copy a NULL pointer, as this is explicitly disallowed, and setting slice-allocated to FALSE once g_slice_free has been called.
* Revert "Refactor boxed wrapper memory management strategy"Mathieu Duponchelle2018-01-231-25/+7
| | | | This reverts commit 85175047e66dfc0c0263eac91d8056a95d0a60a0.
* Remove pygobject-private.h and rename pygobject.c to pygobject-object.cChristoph Reiter2016-06-011-1/+2
| | | | | | | | | | | | | | | | | | | Move all the random declarations in pygobject-private.h to their respective header files. Rename pygobject.c to pygobject-object.c so it's clearer that it's not the implementation of pygobject.h. Add a new pygobject-internal.h which includes pygobject.h with _INSIDE_PYGOBJECT_ defined like pygobject-private.h did. In case you are looking at the git log and end up here due to the rename try: git log --follow pygobject-object.c or on the web interface go to the history of the old file name: https://git.gnome.org/browse/pygobject/log/gi/pygobject.c?id=6b702c052e9f26e809cff494f0c896d17a514c64 https://bugzilla.gnome.org/show_bug.cgi?id=767084
* Remove pygi.h and pygi-private.hChristoph Reiter2016-06-011-1/+2
| | | | | | Instead include things where needed. https://bugzilla.gnome.org/show_bug.cgi?id=767084
* Fix memory management problems with struct arguments to signalsSimon Feltman2014-09-081-0/+20
| | | | | | | | | | | Replicate struct marshaling logic for determining if struct arguments to signals should be passed by reference to callbacks. Maintain a list of these structs and apply an in-place copy of the struct pointer if the struct wrapper is held longer than the duration of the Python callback. This allows for both mutation of struct arguments from callbacks as well as memory safety incase a callbacks holds onto the struct. https://bugzilla.gnome.org/show_bug.cgi?id=736175
* Change boxed init with args to warn instead of raiseChristoph Reiter2014-08-221-1/+4
| | | | | | | | | Replace raising a TypeError in gi.types.Boxed() with a warning. Even though passing arguments or keywords to the parent class is incorrect here, raising an exception was causing a bit of fallout in some apps (Gramps). https://bugzilla.gnome.org/show_bug.cgi?id=727810
* Refactor boxed wrapper memory management strategySimon Feltman2014-08-171-11/+43
| | | | | | | | | | | | | | | | Change pygi_boxed_new() to accept "copy_boxed" instead of "free_on_dealloc". This changes memory management so the PyGIBoxed wrapper owns the boxed pointer given to it. Use __del__ instead of dealloc for freeing the boxed memory. This is needed for edge cases where objects like GSource can trigger the finalized callback during de-alloc, resulting in the PyObjects references counts being manipulated and triggering a re-entrant de-alloc. Add hack to keep Gtk.TreeIter.do_iter_next/previous implementations working which rely on pass-by-reference. See also: https://bugzilla.gnome.org/show_bug.cgi?id=734465 https://bugzilla.gnome.org/show_bug.cgi?id=722899 https://bugzilla.gnome.org/show_bug.cgi?id=726999
* Remove incorrect and unused casts from tp_free callsSimon Feltman2014-08-081-1/+1
| | | | | Arguments to Py_TYPE() do not need to be cast since the macro always casts to a PyObject* internall.
* Use accessors for getting and setting PyGBoxed pointersSimon Feltman2014-05-161-3/+3
| | | | | | | | Add pyg_boxed_get_ptr and pyg_boxed_set_ptr macros for getting and setting the boxed pointer field. This is preliminary cleanup work for supporting fundamental types. https://bugzilla.gnome.org/show_bug.cgi?id=631901
* Raise TypeError if arguments are passed to Boxed.__init__Christoph Reiter2014-04-141-0/+6
| | | | | | | | | | | This is a partial revert of https://git.gnome.org/browse/pygobject/commit/?id=2f2069c9efcd8 which removed a type check in __new__. This adds it back into __init__. Overrides which define __new__ now have to filter out any arguments in __init__ and not the other way around, which is a bit less surprising in the common case. https://bugzilla.gnome.org/show_bug.cgi?id=727810
* Update Free Software Foundation addressesSimon Feltman2014-03-151-3/+1
| | | | | Update all references to the FSF physical address to use the web address: http://www.gnu.org/licenses
* Merge gobject static code into the gi moduleSimon Feltman2014-01-141-1/+1
| | | | | | | | Remove gi._gobject._gobject as a separately compiled static module and move all the files into gi._gi. Remove dead module initialization macros from "pyglib-python-compat.h" https://bugzilla.gnome.org/show_bug.cgi?id=712197
* Cleanup disguised struct constructor error and add it to boxedSimon Feltman2014-01-011-3/+14
| | | | | | | | Give a cleaner error message when an attempt is made to create a disguised struct which also gives a hint to look at the pydoc. Add similar error to disguised boxed/unions. https://bugzilla.gnome.org/show_bug.cgi?id=647249
* Cleanup overzealous new and init implementationsSimon Feltman2013-11-121-6/+0
| | | | | | | | | | | | | Remove PyGObject initializer code attempting to set properties on GObjects that have already been created. There were a number of overridden __new__ and __init__ methods that stripped away arguments before calling the base class to work around attempted property sets and argument count errors (fixing the symptom not the problem). Use Gtk.ListStore/TreeStore.new with __new__ override instead of __init__ with set_column_types. https://bugzilla.gnome.org/show_bug.cgi?id=705810
* Remove half implemented GC in PyGIBaseInfo, PyGIStruct, and PyGIBoxedSimon Feltman2013-05-071-4/+0
| | | | | | | | | | | | Remove half implemented GC tracking from PyGIBaseInfo as it was not needed (the implemented was also missing usage of PyObject_GC_New/Track). Ensure weakref list for PyGIBaseInfo is initialized to NULL and cleared properly. Remove invalid calls to PyObject_GC_UnTrack and PyObject_ClearWeakRefs for both PyGIStruct and PyGIBoxed as these types were not being advertised as GC aware with Py_TPFLAGS_HAVE_GC. https://bugzilla.gnome.org/show_bug.cgi?id=677091
* Fix leak of caller-allocated boxed valuesMartin Pitt2013-02-281-4/+10
| | | | | | | | | | | | | | | Add a new "allocated_slice" argument to _pygi_boxed_new() which specifies whether its "boxed" pointer was allocated using a slice (by giving its size) or malloc (by specifying 0), as _pygi_boxed_new cannot determine that itself any more. Use this in _pygi_marshal_to_py_interface_struct() for caller-allocated boxed values, as _caller_alloc() uses _pygi_boxed_alloc() for those (i. e. slices), which would otherwise leak. Thanks to Mike Gorse <mgorse@suse.com> for the original patch! https://bugzilla.gnome.org/show_bug.cgi?id=691501
* Remove workaround for g_struct_info_get_size reporting incorrect sizeSimon Feltman2013-02-101-18/+13
| | | | | | | Remove workaround for g_struct_info_get_size reporting incorrect size for boxed GValues. Verified this now returns the correct size of 24. https://bugzilla.gnome.org/show_bug.cgi?id=622711
* Fix leaks with GValues holding boxed and object typesSimon Feltman2012-11-111-0/+12
| | | | | | | | Expose read access to PyGIBoxed.free_on_dealloc. Add GObject.Value.__del__ override and call unset() to correctly free reference counts. https://bugzilla.gnome.org/show_bug.cgi?id=688137
* convert to using PYGLIB_DEFINE_TYPE for module objectsJohn (J5) Palmieri2010-08-251-37/+6
| | | | https://bugzilla.gnome.org/show_bug.cgi?id=615872
* some more p3k PyString and PyInt eradication in GIJohn (J5) Palmieri2010-08-251-0/+1
| | | | | | | | | | * add the glib dir to the includes list in the build * make sure we include the compat macros * add GLIB_PyBytes_FromString to compat macros * add GLIB_PyNumber_Long to compat macros * use RichCompare instead of Compare https://bugzilla.gnome.org/show_bug.cgi?id=615872
* Properly allocate boxed structs that are (caller-allocates)Tomeu Vizoso2010-07-301-17/+33
| | | | | | | | | * gi/pygi-boxed.[hc]: Refactor out the allocation of boxed structs * gi/pygi-invoke.c: Don't use g_malloc0 for boxed structs that are (caller-allocates) * tests/test_overrides.py: Split the TreeView tests https://bugzilla.gnome.org/show_bug.cgi?id=625653
* Apply consistent whitespace formatting with:Tomeu Vizoso2010-05-261-54/+54
| | | | | | astyle -p -d -c -S -U -M60 This won't affect git blame nor git diff if the switch -w is used.
* Add basic support for unionsTomeu Vizoso2010-04-231-2/+16
| | | | https://bugzilla.gnome.org/show_bug.cgi?id=603598
* Suppress compilation warningsSimon van der Linden2010-01-051-2/+0
|
* Set a default constructor for boxed structs that don't have oneTomeu Vizoso2009-11-301-0/+184
https://bugzilla.gnome.org/show_bug.cgi?id=602735