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 601181 - Add interfaces support to pygi
Add interfaces support to pygi
Status: RESOLVED FIXED
Product: pygi
Classification: Deprecated
Component: general
unspecified
Other All
: Normal enhancement
: 0.6
Assigned To: pygi-maint
pygi-maint
Depends on: 557383
Blocks:
 
 
Reported: 2009-11-08 18:28 UTC by Tomeu Vizoso
Modified: 2009-11-28 15:49 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Register interfaces (2.02 KB, patch)
2009-11-08 18:28 UTC, Tomeu Vizoso
needs-work Details | Review
Treat GI_INFO_TYPE_INTERFACE same as GI_INFO_TYPE_OBJECT (1.44 KB, patch)
2009-11-08 18:28 UTC, Tomeu Vizoso
committed Details | Review
Start tests about interfaces (5.54 KB, patch)
2009-11-08 18:28 UTC, Tomeu Vizoso
rejected Details | Review
Register interfaces (2.31 KB, patch)
2009-11-22 14:32 UTC, Tomeu Vizoso
none Details | Review
Register interfaces (2.52 KB, patch)
2009-11-22 14:53 UTC, Tomeu Vizoso
needs-work Details | Review
Register interfaces (2.60 KB, patch)
2009-11-22 16:25 UTC, Tomeu Vizoso
committed Details | Review
Register interfaces (2.60 KB, patch)
2009-11-22 16:47 UTC, Tomeu Vizoso
committed Details | Review
A few tests about interfaces (3.33 KB, patch)
2009-11-22 17:13 UTC, Tomeu Vizoso
needs-work Details | Review
A few tests about interfaces (3.33 KB, patch)
2009-11-28 11:04 UTC, Tomeu Vizoso
committed Details | Review
A few tests about interfaces (3.33 KB, patch)
2009-11-28 15:49 UTC, Tomeu Vizoso
committed Details | Review

Description Tomeu Vizoso 2009-11-08 18:28:19 UTC
This just adds the ability to discover and use interface types,
implementing interfaces will come once https://bugzilla.gnome.org/show_bug.cgi?id=557383
is solved.
Comment 1 Tomeu Vizoso 2009-11-08 18:28:22 UTC
Created attachment 147221 [details] [review]
Register interfaces
Comment 2 Tomeu Vizoso 2009-11-08 18:28:26 UTC
Created attachment 147222 [details] [review]
Treat GI_INFO_TYPE_INTERFACE same as GI_INFO_TYPE_OBJECT
Comment 3 Tomeu Vizoso 2009-11-08 18:28:31 UTC
Created attachment 147223 [details] [review]
Start tests about interfaces
Comment 4 Simon van der Linden 2009-11-14 22:47:15 UTC
Review of attachment 147221 [details] [review]:

::: gi/module.py
@@ +126,3 @@
                 metaclass = GObjectMeta
                 bases = (gobject.GInterface,)
+                info.register()

Do that in GObjectMeta.__init__.

::: gi/pygi-info.c
@@ +1741,3 @@
+{
+initialize_interface (GTypeInterface *iface, PyTypeObject *pytype)
+static void

Everywhere else, I used g_type rather than gtype, or simply type when there is no ambiguity between a Py or a G type.

@@ +1742,3 @@
+{
+initialize_interface (GTypeInterface *iface, PyTypeObject *pytype)
+static void

info instead of info_struct is fine;

@@ +1752,3 @@
+
+    Py_INCREF(Py_None);
+    return Py_None;

Use Py_RETURN_NONE.

@@ +1758,3 @@
     { "get_constants", (PyCFunction)_wrap_g_interface_info_get_constants, METH_NOARGS },
     { "get_methods", (PyCFunction)_wrap_g_interface_info_get_methods, METH_NOARGS },
+    { "register", (PyCFunction)_wrap_g_interface_info_register, METH_NOARGS },

It seems cleaner to me to do something like _wrap_pyg_set_object_has_new_constructor for pyg_register_interface_info. There is no method named g_interface_info_register, so this implementation is misleading, IMHO.
Comment 5 Simon van der Linden 2009-11-14 22:49:37 UTC
Review of attachment 147222 [details] [review]:

Looks OK.
Comment 6 Simon van der Linden 2009-11-14 22:57:03 UTC
Review of attachment 147223 [details] [review]:

I don't get the point of having many methods in the interface.

When one implement an interface in Python, does one expect the virtual functions to be bound to the Python methods somehow?
Comment 7 Tomeu Vizoso 2009-11-20 17:54:19 UTC
(In reply to comment #6)
> Review of attachment 147223 [details] [review]:
> 
> I don't get the point of having many methods in the interface.
> 
> When one implement an interface in Python, does one expect the virtual
> functions to be bound to the Python methods somehow?

Yes, and we need quite a bit of code to marshall the arguments from C to Python, so we'll need some more test cases. But those will better come in a ticket about implementing vfuncs in python.
Comment 8 Tomeu Vizoso 2009-11-22 14:32:12 UTC
Created attachment 148269 [details] [review]
Register interfaces
Comment 9 Tomeu Vizoso 2009-11-22 14:53:09 UTC
Created attachment 148271 [details] [review]
Register interfaces
Comment 10 Simon van der Linden 2009-11-22 16:17:45 UTC
Review of attachment 148271 [details] [review]:

Almost perfect :-)

::: gi/gimodule.c
@@ +120,3 @@
+    info->interface_finalize = NULL;
+    info->interface_data = NULL;
+

No need to set them again to NULL (g_new0 does it already).

@@ +121,3 @@
+    info->interface_data = NULL;
+
+    g_type = pyg_type_from_object(py_g_type);

Perhaps we want to check that the g_type is a G_TYPE_INTERFACE?
Comment 11 Tomeu Vizoso 2009-11-22 16:25:26 UTC
Created attachment 148277 [details] [review]
Register interfaces
Comment 12 Simon van der Linden 2009-11-22 16:42:00 UTC
Review of attachment 148277 [details] [review]:

Excellent. Thanks!
Comment 13 Tomeu Vizoso 2009-11-22 16:47:34 UTC
The following fix has been pushed:
1dc62a9 Register interfaces
Comment 14 Tomeu Vizoso 2009-11-22 16:47:41 UTC
Created attachment 148280 [details] [review]
Register interfaces
Comment 15 Simon van der Linden 2009-11-22 16:59:02 UTC
And what about the tests?
Comment 16 Tomeu Vizoso 2009-11-22 17:01:53 UTC
(In reply to comment #15)
> And what about the tests?

Coming with the vfuncs stuff, but can be split here if you prefer to.
Comment 17 Tomeu Vizoso 2009-11-22 17:13:34 UTC
Created attachment 148283 [details] [review]
A few tests about interfaces
Comment 18 Tomeu Vizoso 2009-11-27 17:56:46 UTC
Ping, this is a very easy patch to review.
Comment 19 Simon van der Linden 2009-11-27 21:12:35 UTC
Review of attachment 148283 [details] [review]:

::: tests/test_gi.py
@@ +1432,3 @@
+class TestInterfaces(unittest.TestCase):
+
+# Interface

I'd prefer if you could split this tests: one for the interface wrapper, one for the implementation in Python.
Comment 20 Tomeu Vizoso 2009-11-28 11:04:22 UTC
Created attachment 148642 [details] [review]
A few tests about interfaces
Comment 21 Simon van der Linden 2009-11-28 15:42:04 UTC
Review of attachment 148642 [details] [review]:

Good.
Comment 22 Tomeu Vizoso 2009-11-28 15:48:56 UTC
The following fix has been pushed:
96f6c63 A few tests about interfaces
Comment 23 Tomeu Vizoso 2009-11-28 15:49:04 UTC
Created attachment 148651 [details] [review]
A few tests about interfaces