From afe29c2106a74f9761e22599b5e36aae2f38447a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Fri, 10 Nov 2017 16:10:00 +0100 Subject: [PATCH] Generate Rust wrappers for class structs too --- src/analysis/object.rs | 3 +++ src/codegen/general.rs | 5 +++-- src/codegen/object.rs | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/analysis/object.rs b/src/analysis/object.rs index b9074f96e..f4bfdb9b5 100644 --- a/src/analysis/object.rs +++ b/src/analysis/object.rs @@ -15,6 +15,7 @@ use traits::*; pub struct Info { pub base: InfoBase, pub c_type: String, + pub class_type: Option, pub c_class_type: Option, pub get_type: String, pub supertypes: Vec, @@ -218,6 +219,7 @@ pub fn class(env: &Env, obj: &GObject, deps: &[library::TypeId]) -> Option let info = Info { base: base, c_type: klass.c_type.clone(), + class_type: klass.type_struct.clone(), c_class_type: klass.c_class_type.clone(), get_type: klass.glib_get_type.clone(), supertypes: supertypes, @@ -341,6 +343,7 @@ pub fn interface(env: &Env, obj: &GObject, deps: &[library::TypeId]) -> Option, glib_class_name: &Option<&str>, glib_func_name: &str, parents: &[StatusedTypeId], @@ -64,8 +65,8 @@ pub fn define_object_type( .collect(); let (separator, class_name) = { - if let &Some(s) = glib_class_name { - (", ".to_string(), format!("ffi::{}", s)) + if let (&Some(name), &Some(ffi_name)) = (class_name, glib_class_name) { + (", ".to_string(), format!("{}, ffi::{}", name, ffi_name)) } else { ("".to_string(), "".to_string()) } diff --git a/src/codegen/object.rs b/src/codegen/object.rs index 5f851cb1f..64de385f1 100644 --- a/src/codegen/object.rs +++ b/src/codegen/object.rs @@ -20,6 +20,7 @@ pub fn generate(w: &mut Write, env: &Env, analysis: &analysis::object::Info) -> env, &analysis.name, &analysis.c_type, + &analysis.class_type.as_ref().map(|s| &s[..]), &analysis.c_class_type.as_ref().map(|s| &s[..]), &analysis.get_type, &analysis.supertypes,