GNOME Bugzilla – Bug 584517
native type issues
Last modified: 2018-02-08 11:50:15 UTC
So I have this typedef in one of my projects /** * GUdevDeviceNumber: * * Corresponds to the standard #dev_t type as defined by POSIX. */ typedef dev_t GUdevDeviceNumber; which gives me <alias name="DeviceNumber" target="dev_t" c:type="GUdevDeviceNumber"/> in the GIR file. Of course, this is not very useful for e.g. seed or gjs, they simply don't understand what dev_t is. And I'd argue they shouldn't have to know. Wouldn't it be better if g-ir-scanner resolved 'dev_t' to 'int' at scan time? The easy fix is to do typedef int GUdevDeviceNumber; but that's not really a solution since dev_t, as specified by POSIX, can be any arithmetic type (e.g. int16_t, int32_t, whatever) and the decomposition into major:minor (and even existance of major:minor) is platform specific (e.g. can different on Linux and Solaris and why makedev(3) isn't specified by POSIX). Maybe it's just easier to teach g-ir-scanner about such POSIX types and then alias them to the right int... there's not a lot of them (other types include pid_t etc.). Thoughts?
For time_t we created an explicit type. I'm not sure how well that scales though to all of POSIX. We could make a POSIX.gir.
Could be, but how would we detect when to include the POSIX git or not?
(In reply to comment #2) > Could be, but how would we detect when to include the POSIX git or not? > Well, things like time_t is part of C so it wouldn't go into POSIX but rather stay in the introspection parser. Wit this, only things like GUdev-1.0 and GIO-unix-2.0 (which we don't have yet but probably want since it's not right to have GDesktopAppInfo in Gio-2.0) would pull in POSIX-1.0.
(In reply to comment #3) > GIO-unix-2.0 (which we don't have yet > but probably want since it's not right to have GDesktopAppInfo in Gio-2.0) Filed as bug 584936.
After thinking about this a bit more, I'd rather the scanner made it convenient to pass in alias definitions, like --alias dev_t=guint64, or parse it from a file. Or maybe even better --expand-typedef=dev_t which would make us walk through and expand to the typedef target.
[Mass-moving gobject-introspection tickets to its own Bugzilla product - see bug 708029. Mass-filter your bugmail for this message: introspection20150207 ]
(In reply to Colin Walters from comment #5) > Or maybe even better --expand-typedef=dev_t which would make us walk through > and expand to the typedef target. That will erase the information that the introspected typedef depends on a platform-specific type definition. For bindings that don't use the installed C headers, that information would be useful; see bug #757165.
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/gobject-introspection/issues/18.