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 81040 - G_TYPE_GTYPE is missing from fundamental types
G_TYPE_GTYPE is missing from fundamental types
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gobject
2.0.x
Other All
: Normal enhancement
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2002-05-07 13:45 UTC by Sven Neumann
Modified: 2011-02-18 15:49 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
a patch (9.36 KB, patch)
2005-11-11 07:46 UTC, Matthias Clasen
none Details | Review

Description Sven Neumann 2002-05-07 13:45:04 UTC
I think the fundamental types should be extended to include G_TYPE_GTYPE.
Then GValue needs to be extended so it can hold GType and GParamSpecGType
should be introduced.

I see a couple of usage cases for this essential feature. Container objects
for example want to know about the type of elements they hold.
GimpContainer is such an example where we had to use a GParamSpecPointer
where GParamSpecGType would have been the appropriate solution. This
workaround fails if you try to write a serializable container where you'd
want to serialize the container properties in a generic fashion. This is
not possible if the element_type property is a pointer property.

Gtypes may also be used in signal emissions used in generic object
factories. G_TYPE_GTYPE would be useful here too.
 
Unless I miss something the addition of G_TYPE_GTYPE should be pretty
straightforward. Let me know if you would like me to come up with a patch.
Comment 1 Tim Janik 2002-11-18 20:58:18 UTC
i don't see why this needs to be a new fundamental. as for the merit
of it, i agree, i think i used something like type-gtype in beast for
a while, but that was nothing more than
g_pointer_type_register_static("GType"). a paramspec for that should
be pretty easy to create (derive from GParamSpecPointer and add a
GType default_type; field, that's it), so a patch would be apprechiated.
Comment 2 Matthias Clasen 2005-11-11 07:46:50 UTC
Created attachment 54619 [details] [review]
a patch

Here is a patch which adds a fundamental type for GType, a param spec to go
with it, and setter/getter for GValue. The param spec allows to restrict the
possible values by specifying an "is_a_type".
Comment 3 Matthias Clasen 2005-11-29 22:24:58 UTC
patch sent to timj for review
Comment 4 Tim Janik 2005-12-22 15:09:14 UTC
the patch required some fixes, as it tried to partly implement a fundamental type in one place. that's not quite suitable, fundamental types require much more things to be implemented. as outlined earlier, i don't think we need a new fundamental type here though, rather, i've added a G_TYPE_POINTER variant.

this needs some test code to be added though, i.e. something that simply makes sue of the newly written accessors, and tries to compare and vbalidate GType values.
Comment 5 Matthias Clasen 2006-02-18 21:08:27 UTC
Added a bunch of tests to tests/gobject/gvalue-test and tests/gobject/paramspec-test
Comment 6 Tim Janik 2006-02-20 12:44:10 UTC
the tests look good. thanks matthias.