You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Bug Report: Invalid Type in Bindgen IR with foreign_class! Macro
Description
Hello, I'm encountering an issue with the bindgen tool when using the foreign_class! macro. The error message is as follows:
The issue seems to be related to the add_char method, which modifies the information field of the Paris struct by adding a character. When this method is included in the foreign_class! macro, bindgen generates a warning about an invalid type. This suggests that bindgen may have difficulty handling the char type or the mutable reference (&mut self) used in this method.
Code with Error
Here is the code that generates the error:
//Automatically generated by rifgen
use crate::jni_c_header::*;
struct Paris {
information: String,
}
impl Paris {
fn new(top: String) -> Paris {
Paris { information: top }
}
fn get_info(&self) -> &str {
&self.information
}
fn add_char(&mut self, c: char) {
self.information.push(c);
}
}
foreign_class!(
class Paris {
self_type Paris;
constructor Paris::new(top : String)->Paris;
fn Paris::get_info(& self)->&str; alias getInfo;
fn Paris::add_char(& mut self , c : char); alias addChar;
}
);
Yes, at the moment flapigen do not support Rust's char to Java's char conversation.
You can work around using &str with one char to pass char from java to rust.
Though error message that you provide is strange.
That I got when I try to compile your code:
--- stderr
error in flapigen_test_jni: src/java_glue.rs.in
parsing of flapigen_test_jni: src/java_glue.rs.in failed
error: Do not know conversion from Java type to such rust type 'char'
fn Paris::add_char(& mut self , c : char); alias addChar;
^^^^
have no idea what bindgen message is about,
may be you should report bindgen part (I suppose you use it to convert jni.h to Rust) to proper issue tracker.
Bug Report: Invalid Type in Bindgen IR with foreign_class! Macro
Description
Hello, I'm encountering an issue with the bindgen tool when using the foreign_class! macro. The error message is as follows:
The issue seems to be related to the add_char method, which modifies the information field of the Paris struct by adding a character. When this method is included in the foreign_class! macro, bindgen generates a warning about an invalid type. This suggests that bindgen may have difficulty handling the char type or the mutable reference (&mut self) used in this method.
Code with Error
Here is the code that generates the error:
Error
[WARN bindgen::ir::ty] invalid type Type(, kind: Invalid, cconv: 100, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
Code without Error
The following code does not produce the error:
Expected Behavior
The bindgen tool should generate valid bindings without any warnings or errors.
Actual Behavior
The bindgen tool generates a warning about an invalid type.
I would appreciate any assistance in resolving this issue. If more information is needed, please let me know.
The text was updated successfully, but these errors were encountered: