summaryrefslogtreecommitdiff
path: root/gi/gimodule.c
Commit message (Collapse)AuthorAgeFilesLines
* Add extra safeguard in gimoduleArjan Molenaar2022-03-281-1/+5
| | | | Why does a g_instance_init() function only handle GObjects?
* Call PyEval_InitThreads() with PyPy for Python 3.9Christoph Reiter2022-03-271-1/+2
| | | | | | In theory it should no longer be needed, but PyPy hasn't updated this part of their implementation yet, and not initing threads will lead to crashes due to missing GIL init.
* gimodule: fix floating state of python objects created with g_object_newMathieu Duponchelle2021-12-061-3/+12
| | | | | | | | | | If C code calls g_object_new() for a GInitiallyUnowned subclass implemented in python, the expectation is to receive a floating reference. The solution is used is the same picked for 5efe2e5c8458d9f4d72329ea1209d96b5ebecfb4, this is simply a special case that was omitted at the time.
* Use quark variable for class on gtypeArjan Molenaar2021-09-191-1/+1
|
* Don't assume Py_TYPE being a macroTomas Hrnciar2020-11-111-1/+1
| | | | | | Py_TYPE was changed to a function in Python 3.10. Suggested approach is to use Py_SET_TYPE macro instead, see: https://docs.python.org/3.10/whatsnew/3.10.html.
* Don't call PyEval_InitThreads() with Python 3.9+Christoph Reiter2020-10-061-0/+4
| | | | | | The GIL is now created by Python at initialization time no matter what. PyEval_InitThreads() triggers a deprecation warning and will be removed in 3.10 so don't use it with 3.9+.
* gtk overrides: Fix template hierarchy issueJean Felder2020-04-171-4/+9
| | | | | | | | | | | | | | | | | | | | When a widget is inside a template it is created through a g_object_new and does not have a python wrapper when pygobject__g_instance_init is called. In that case, a wrapper is created and the "__init__" method is called to instantiate it. Then, "init_template" is called to init its own template (if it exists). However, "init_template" needs to be called before the object constructor in order to create and instantiate all its children, signals and properties. This issue is fixed by calling init_template before the contructor if the python object has been created through g_object_new. A new test for the template hierarchy is added (based on an example from Marinus Schraal). Closes: #257, #386
* gimodule: Remove trailing whitespacesJean Felder2020-04-161-8/+8
|
* Remove all Python 2 C codeChristoph Reiter2020-04-161-52/+73
|
* Port to g_object_new_with_properties()Christoph Reiter2019-10-041-7/+41
| | | | | | | | g_object_newv() and GParameter are deprecated now. Replace all GParameter usage with a separate GValue and char* array and add a compatibility function for g_object_new_with_properties() that also works with older glib and converts things back to GParameter.
* Avoid various new glib deprecation warningsChristoph Reiter2019-10-041-0/+4
| | | | | This should make things build with -Werror again once we port things to g_object_new_with_properties()
* Make PyGIDeprecationWarning always inherit from DeprecationWarningChristoph Reiter2019-08-181-10/+0
| | | | | | | | | | | To make deprecation warnings more visible we made it inherit from RuntimeWarning with unstable releases and DeprecationWarning for stabel releases. This is a bit confusing when being flooded with warnings when testing under jhbuild etc. Also recent pytest has changed to show deprecation warnings triggered during tests, so the warnings should be more visible now for devs using pytest. This changes it to inherit from DeprecationWarning always again.
* GObject.Value: add a static helper for fetching the GTypeChristoph Reiter2019-01-181-0/+2
| | | | | | | | The field marshalling code is slow and doesn't do any caching at all which in turn makes accessing Value.g_type slow. Add a static helper function for fetching the GType and use that instead. This reduced the time for creating a GValue + setting it by ~30%
* Start using g_struct_info_find_field()Christoph Reiter2018-12-121-16/+6
| | | | | | | Instead of iterating over the fields ourselves. g_struct_info_find_field() was added for libgirepository 1.46: https://gitlab.gnome.org/GNOME/gobject-introspection/commit/cf6ea68018 We now depend on 1.46 so start using it.
* gtktemplate: only call the custom init hook if the class has it. Fixes #267Christoph Reiter2018-11-261-1/+1
| | | | | | Otherwise we call into __getattr__ implementations of subclasses, like the overrides for Gio.DBusProxy. This is particularly bad because the instance isn't initialized at that point yet.
* foreign-cairo: Fix cairo marshalling not using the foreign converters in ↵Christoph Reiter2018-09-171-0/+1
| | | | | | | | | | | | some cases. Fixes #260 In case the first cairo marshall happens through the GType converters we wont have loaded the cairo foreign module yet and wont have registered the right converters. This results in the non-foreign version getting passed on which isn't accepted by all other marshalling paths which use the foreign module. Try importing the cairo foreign module at gi import type instead so the gtype converters are registered.
* pypy: avoid calling tp_init, doesn't work with PyPyChristoph Reiter2018-04-221-8/+6
| | | | | | | | Calling tp_init under PyPy does not call the Python level __init__. Filed under https://bitbucket.org/pypy/pypy/issues/2806 Just use PyObject_CallMethod() to call __init__ instead. It works just as well and there is no perf difference from a quick test.
* Add overrides for Gio.ListStore.sort and Gio.ListStore.insert_sorted. Fixes #130gio-liststore-sortChristoph Reiter2018-04-211-0/+27
| | | | | | | | Those functions use CompareDataFunc which works with pointers and doesn't know anything about GObjects. Add overrides which wrap the passed in sort function and convert the pointers to proper Python wrappers.
* Make pygi_source_new() a Python function and add error handlingChristoph Reiter2018-04-191-7/+1
| | | | It's only used for that, so no need to have an extra Python wrapper.
* pygi-source: cleanup function namesChristoph Reiter2018-04-191-4/+4
|
* Remove the PYGLIB_CPointer_ macrosChristoph Reiter2018-04-181-2/+2
| | | | They are simple aliases to the PyCapsule API, so just remove them.
* Add a minimal implementation of Gtk.Template. See #52Christoph Reiter2018-04-121-3/+16
| | | | | | | | | | | | | This tries to add a minimal API which allows for basic template usage with the possibility to maybe add more automation/subclassing/nesting later on. Compared to gi_composites.py this adds parameters to Child and Callback to set the name, init_template() doesn't need to be called and is stricter in what it supports to allow future improvements. The _gtktemplate.py file should be resuable with older PyGObject versions with the only difference that init_template() needs to be called.
* More compiler warning fixes for Windows/32bit #191Christoph Reiter2018-04-051-12/+8
|
* build: use -Wconversion -Wno-sign-conversion. Fixes #191Christoph Reiter2018-04-051-11/+37
| | | | | | | | | | In some cases changing the type used was enough, in some others I just force casted things as too many changes would be required and overflow unlikely (for array marshalling the cache uses gssize while the marshalling code uses garray and thus guint) My hope is that having this enabled will improve things gradually with future cleanups.
* ossig: add a C wrapper for PyOS_getsig() instead of accessing the API ↵Christoph Reiter2018-04-011-0/+12
| | | | | | | | through ctypes PyPy doesn't support the ctypes.PyDLL interface. The ctypes approach was a bit hacky anyway because the interface for loading the python DLL isn't really documented.
* Port more integer convertersChristoph Reiter2018-03-311-15/+16
|
* gboxed: clean up function namesChristoph Reiter2018-03-311-2/+2
|
* pygi-boxed: clean up function namesChristoph Reiter2018-03-311-1/+1
|
* Merge pygtype.c and pygi-type.cChristoph Reiter2018-03-311-2/+2
| | | | No need to have two similarly named files
* Make sure that types are fully initialized when they are first used.Christoph Reiter2018-03-241-6/+6
| | | | | | | 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-37/+83
| | | | | 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-2/+1
| | | | There is no pyglib anymore
* Remove pyglib.c/hChristoph Reiter2018-03-221-2/+0
| | | | Leftovers from the static bindings, move to their users.
* pygobject_register_version_tuples: fix a leakChristoph Reiter2018-03-221-0/+1
|
* Store the closure cache in the arg cache. Fixes #103Christoph Reiter2018-03-221-1/+3
| | | | | | | | | | | Instead of creating the closure cache on every call store it in the arg cache. The only potential problem here is that the arg cache owns the closure cache and needs to stay around. But afaics the cache stays around until interpreter shutdown and the closure code guards against that and will simply do nothing then. This would all be easier if the caches were refcounted.
* Remove gobjectmoduleChristoph Reiter2018-03-211-5/+1716
| | | | | | | | This finishes what was started in b2529624b3925adbef2671025e08cbf747f162e8 and moves the remaining code mostly into gimodule. While this makes the large file even larger, it's a good starting point for more cleanups.
* Remove pyg_type_name() and use GType.name insteadChristoph Reiter2018-03-211-1/+0
|
* Remove pyg_type_from_name() and use GType.from_name() insteadChristoph Reiter2018-03-211-1/+0
|
* Remove pyg_type_is_a() and use GType.is_a() insteadChristoph Reiter2018-03-211-1/+0
|
* Remove pygobject_register_features()Christoph Reiter2018-03-211-1/+0
| | | | All it does is provide GObject.features which we can do in the overrides directly.
* Remove unused signal_accumulator_true_handledChristoph Reiter2018-03-191-2/+0
|
* Revert "Revert "Revert "Refactor boxed wrapper memory management strategy"""Mathieu Duponchelle2018-02-161-5/+1
| | | | This reverts commit a506d5e3c64321c43a4ce7c2a72ca8d36e985999.
* Revert "Revert "Refactor boxed wrapper memory management strategy""Christoph Reiter2018-02-131-1/+5
| | | | This reverts commit daefdfa3e4dc97b4ae38250358d722f09764cc9b.
* Revert "Refactor boxed wrapper memory management strategy"Mathieu Duponchelle2018-01-231-5/+1
| | | | This reverts commit 85175047e66dfc0c0263eac91d8056a95d0a60a0.
* Fix potential uninitialized memory access during GCDaniel Colascione2017-10-261-1/+1
| | | | | | | | | | | | | | | | | We use _PyGIDefaultArgPlaceholder as a sentinel value to represent default values during function argument list construction. Right now, it's a Python type object. We make it using PyObject_New, so most of its fields end up uninitialized. The object body being uninitialized wouldn't be a problem if the placeholder object were unreachable, but the object *can* be reached during GC by traversal through frame objects. Depending on the exact contents of the uninitialized memory, the GC can go on to cause other kinds of memory corruption through the process. IMHO, the easiest fix for this problem is to just make the placeholder a simpler data structure, like a list. https://bugzilla.gnome.org/show_bug.cgi?id=786872
* Remove gi._gi._gobject and gi._gobject modulesChristoph Reiter2017-04-011-11/+37
| | | | | | | | | | Expose everything from _gi._gobject in _gi instead. This does not move any code around, just removes the module. Also removes the gi._gobject package and replaces it with a small dummy module in gi.__init__.py https://bugzilla.gnome.org/show_bug.cgi?id=735206
* Remove gi._gi._glib moduleChristoph Reiter2017-04-011-14/+17
| | | | | | | Move the code into gi._gi (gimodule) The module was a leftover from https://bugzilla.gnome.org/show_bug.cgi?id=712197 https://bugzilla.gnome.org/show_bug.cgi?id=735206
* Fix various compiler warnings for 32bit buildsChristoph Reiter2017-03-241-0/+1
| | | | | | | | Due to the switch to AX_COMPILER_FLAGS which adds some more warning flags. I didn't notice these as they only get triggered on 32bit builds. Tested with gcc 6.3 and clang 3.9. https://bugzilla.gnome.org/show_bug.cgi?id=780409
* Fix various potential compiler warningsChristoph Reiter2017-03-201-3/+4
| | | | | | | | This is useful for a the next commit which switches away from gnome-common and uses AX_COMPILER_FLAGS adding some new compiler warning flags. https://bugzilla.gnome.org/show_bug.cgi?id=777713
* Remove pygobject-private.h and rename pygobject.c to pygobject-object.cChristoph Reiter2016-06-011-1/+9
| | | | | | | | | | | | | | | | | | | 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