https://kotlinlang.org logo
#squarelibraries
Title
# squarelibraries
b

Big Chungus

03/14/2023, 5:29 PM
[KotlinPoet] Is it possible to add explicit wildstar imports to a generated file? I'm working with c imports and have no way to distinguish where a known type comes from, but I know that one of the given packages will have it.
v

vbsteven

03/14/2023, 5:37 PM
I haven't found a way to do it directly using KotlinPoet but the problem sounds familiar. Are you having this issue because of cinterop-mapped enums by any chance?
b

Big Chungus

03/14/2023, 5:48 PM
Not just enums, cinterop stuff in general
Seems like I'll have to use stub package during generation and then just manually replace all imports from there with my set of wildcards via raw string manipulation.
As in rewrite generated files
v

vbsteven

03/14/2023, 5:53 PM
for enums you can get around it by using the
strictEnums
in the def file, this will skip the barely documented heuristics for determining how enums are mapped
I have not encountered any other cases where the package was not clearly known post-cinterop
I'm interested in any other cases you encounter since I might need to solve a similar thing soon. Which C library are you generating bindings for?
b

Big Chungus

03/14/2023, 5:57 PM
I'm parsing gir and generating oo wrappers over cinterop. Haven't progressed too far with actual generation just yet as I've been focusing on gir parsing for now, but trying to resolve my open questions before I'm blocked by them 😀
v

vbsteven

03/14/2023, 6:39 PM
Then we are likely working on the same thing so I'd love to trade experiences. We have PoC code going from .gir to Gtk windows showing on the screen without manual intervention and are currently rewriting the parser/generator in a clean repository.
so far the enum thing is the only thing I've had some issues with, but it is fixed by adding the enumerations from gir to the .def file before generating the cinterop bindings.
7 Views