-
-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support BoxedInline without a get_type function #1297
base: main
Are you sure you want to change the base?
Conversation
src/codegen/general.rs
Outdated
sys_crate_name, | ||
get_type_fn | ||
)?; | ||
if let Some((ref get_type_fn, _get_type_version)) = get_type_fn { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This requires a get_type
function, or otherwise more changes in glib
are needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the case of not BoxedInline
but normal Boxed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the get_type_fn here can't be None then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, there won't be a copy/free function here otherwise and that won't compile without further changes in glib
src/library.rs
Outdated
@@ -1085,18 +1085,19 @@ impl Library { | |||
} | |||
} | |||
if let Some(tid) = env.library.find_type(0, &full_name) { | |||
let gobject_id = env.library.find_type(0, "GObject.Object").unwrap(); | |||
let gobject_id = env.library.find_type(0, "GObject.Object"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you don't have GObject
in your dependencies then there can't be any class hierarchy at all, so the code below should simply not run
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok gotcha
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise makes sense.
Why do you want to create bindings for GModule
though? I think that's going to require writing the whole bindings manually to end up with anything usable and somewhat safe. The autogenerated bindings won't be usable.
src/codegen/record.rs
Outdated
&analysis.init_function_expression, | ||
&analysis.copy_into_function_expression, | ||
&analysis.clear_function_expression, | ||
&analysis.glib_get_type, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe analysis.glib_get_type.map(|ref a,_| a)
or something like that to avoid passing the version that's unneeded here ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok
I want to use GModule to support "plug-ins" |
The |
Ok, thanks, I'll check that out |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't this work ?
src/codegen/general.rs
Outdated
@@ -377,7 +377,7 @@ pub fn define_auto_boxed_type( | |||
init_function_expression: &Option<String>, | |||
copy_into_function_expression: &Option<String>, | |||
clear_function_expression: &Option<String>, | |||
get_type_fn: &str, | |||
get_type_fn: Option<&String>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get_type_fn: Option<&String>, | |
get_type_fn: Option<&str>, |
src/codegen/record.rs
Outdated
&analysis.init_function_expression, | ||
&analysis.copy_into_function_expression, | ||
&analysis.clear_function_expression, | ||
analysis.glib_get_type.as_ref().map(|(ref a, _)| a), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
analysis.glib_get_type.as_ref().map(|(ref a, _)| a), | |
analysis.glib_get_type.as_ref().map(|(ref a, _)| a).as_deref(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Coercion still fails for me with as_deref()
This is my attempt at supporting BoxedInline without a get_type function #1236 #1295. Generating the bindings for gmodule does not panic and now outputs: