GNOME Bugzilla – Bug 767718
Nested namespaces not handled correctly by GIR Writer
Last modified: 2018-05-22 15:36:05 UTC
Created attachment 329893 [details] [review] Fixes nested namespace generation When generating a GIR file for a Vala project, Classes in nested namespaces are handled correctly. I.e. namespace Valadate.Framework { public abstract class TestCase : Object { } } Is rendered in the GIR file as: <type name="Valadate.FrameworkTestCase" c:type="ValadateFrameworkTestCase"/> When this class is used by another project that then generates its own GIR file, these types are rendered incorrectly. i.e. <type name="Valadate.TestCase" c:type="ValadateFrameworkTestCase"/> This causes the g-ir-compiler to cause an error. This bug appears to be caused by the method gi_type_name only returning the actual Class name as defined in the vapi file and the root namespace. The attached patch fixes this bug and allows classes in nested namespaces to be used in other Typelibs.
Possible duplicate of https://bugzilla.gnome.org/show_bug.cgi?id=677591 and https://bugzilla.gnome.org/show_bug.cgi?id=660594
Created attachment 348130 [details] First Test File This is an example abstract class with a nested namespace
Created attachment 348131 [details] Second Test File This is the second library which tries to make a subclass of the abstract class defined in the first library
Created attachment 348132 [details] Makefile As the error is picked up by the g-ir-compiler, this Makefile attempts to build the typelibs for both libraries and demonstrates the bug
Nested namespaces are not supported by GIR itself, so this is not a Vala's limitation. If you are developing a library, avoid nested namespaces and add your namespace to your classes' names. So Goo.Foo.Bar become Good.FooBar, with same result at C API and makes GIR happy
(In reply to Daniel Espinosa from comment #5) > Nested namespaces are not supported by GIR itself, so this is not a Vala's > limitation. > > If you are developing a library, avoid nested namespaces and add your > namespace to your classes' names. > > So Goo.Foo.Bar become Good.FooBar, with same result at C API and makes GIR > happy This is not a satisfactory resolution to this problem and the report bug should be reopened. Vala allows you to create multiple nested namespaces and this is easily translated in the Gir files as my patch does by concatenating all the of the nested namespaces. Otherwise this is defective behaviour - the language should not allow you to create a construct - i.e nested namespaces and then create incorrect output - the way it currently handles Gir files. The resolution is to either fix this defective behaviour or remove Vala's ability to generate nested namespaces.
Created attachment 348185 [details] [review] girwriter: GIR.name defines the final name under gir's namespace
-- 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/vala/issues/541.