-
Notifications
You must be signed in to change notification settings - Fork 354
Description
I have this issue where I am adding non abi-breaking methods to some of the structs emitted by cbindgen. However, some of them require the full definition of other structures to be emitted before.
For example, I have something equivalent to the following in my cbindgen.toml
[export.body]
"Bar" = """
public:
bar_method(Foo::Tag tag);
"""
(I am defining the body of bar_method using the trailing
configuration option).
In this case, a simple forward declaration for Foo
will not work, as I specifically want to use the generated Tag
field. FWIW, the rust code for Foo would look something like this:
pub enum Foo {
MyFoo1(u8),
MyFoo2(u8),
}
I saw issue #43 which is similar in a way. I think that having a field in the [export]
table (similar to [export.body]
) that allows manually specifying a dependency for an item would be beneficial. This feature would work as a workaround for that issue, in that we could use this configuration option to get around deficiencies in the dependency logic.
Right now, what I am doing is actually adding Foo
to [export.exclude]
, and then putting what cbindgen would generate for it in the after_includes
configuration field. This is fairly brittle, however, as I have to remember to change it should the definition of Foo
ever change.