Open randomPoison opened 4 years ago
Currently, cs-bindgen-macro doesn't do anything to expand Self when generating the binding code. This means that any usage of Self will result in a compiler error. For example, the following function:
cs-bindgen-macro
Self
#[cs_bindgen] impl Foo { pub fn new() -> Self { ... } }
Will generate the following binding:
#[no_mangle] pub unsafe extern "C" fn __cs_bindgen_generated__Foo__new() -> <Self as IntoAbi>::Abi { IntoAbi::into_abi(Foo::new()) }
Since the generated binding is not in the context of an impl block, the usage of Self is no longer valid.
impl
To fix this, the proc macro will need to detect usage of Self in a type position and replace it with the full type name.
Currently,
cs-bindgen-macro
doesn't do anything to expandSelf
when generating the binding code. This means that any usage ofSelf
will result in a compiler error. For example, the following function:Will generate the following binding:
Since the generated binding is not in the context of an
impl
block, the usage ofSelf
is no longer valid.To fix this, the proc macro will need to detect usage of
Self
in a type position and replace it with the full type name.