gir
gir copied to clipboard
`gir` offers no way of ignoring tests for opaque pointers
In Aravis, the GIR file contains field definitions for some structs (eg. ArvGcStructEntryNode
).
However, the .h
file only contains it as an opaque pointer.
As a consequence, when attempting to run cargo test
, tests fail due to the C definition of the struct not being found. In this specific case it can be worked around (the C definition is available, though under an ARV_H_INSIDE
-guarded header), but there is no reason for it to be possible for any library -- or even for the workaround to still work at the next aravis version.
Ideally there'd be a way to tell gir
“this is an opaque pointer on the C side, please don't generate tests for it”, I guess?
Sad, but there no way to tell that now.
Opaque objects usually have disguised="1"
in gir file.
Why you can't include this header?
Well, the issue is this header is this one, which has the protection to make it so that only arv.h
is allowed to include it, and the arv.h
I get in my /usr/include
doesn't actually appear to include it -- I guess the installed arv.h
is different from the build arv.h
, and this is done so that the implementation details stay hidden.
IOW, including the header file is possible and works (it's the workaround I'm using for now), but it's quite prone to breakage, as it's using an explicitly not-for-the-public API. (I don't really understand whether the header file being there in /usr/include
is not even a packaging bug)
As for disguised="1"
, do you know where I should put it to get gir
to handle the thing as an opaque pointer? I have no occurrence of disguised
in all the .gir
files I have
Ex. see https://github.com/gtk-rs/gir-files/blob/master/Atk-1.0.gir#L4002
Hmm weird, the thing previously looked like:
<class name="DomDocumentFragment"
c:symbol-prefix="dom_document_fragment"
c:type="ArvDomDocumentFragment"
parent="DomNode"
abstract="1"
glib:type-name="ArvDomDocumentFragment"
glib:get-type="arv_dom_document_fragment_get_type"
glib:type-struct="DomDocumentFragmentClass">
…
I added disguised="1"
below the abstract="1"
, reran gir
, and things just failed the same way, with a call to sizeof
on an incomplete type.
Anyway, I guess I'll just keep the other workaround for now, and will leave this open waiting for the more general fix of allowing to manually set a type as being allowed to be used only behind an opaque pointer? :)