Skip to content

Commit afe29c2

Browse files
committed
Generate Rust wrappers for class structs too
1 parent 0409d73 commit afe29c2

3 files changed

Lines changed: 7 additions & 2 deletions

File tree

src/analysis/object.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use traits::*;
1515
pub struct Info {
1616
pub base: InfoBase,
1717
pub c_type: String,
18+
pub class_type: Option<String>,
1819
pub c_class_type: Option<String>,
1920
pub get_type: String,
2021
pub supertypes: Vec<general::StatusedTypeId>,
@@ -218,6 +219,7 @@ pub fn class(env: &Env, obj: &GObject, deps: &[library::TypeId]) -> Option<Info>
218219
let info = Info {
219220
base: base,
220221
c_type: klass.c_type.clone(),
222+
class_type: klass.type_struct.clone(),
221223
c_class_type: klass.c_class_type.clone(),
222224
get_type: klass.glib_get_type.clone(),
223225
supertypes: supertypes,
@@ -341,6 +343,7 @@ pub fn interface(env: &Env, obj: &GObject, deps: &[library::TypeId]) -> Option<I
341343
let info = Info {
342344
base: base,
343345
c_type: iface.c_type.clone(),
346+
class_type: iface.type_struct.clone(),
344347
c_class_type: iface.c_class_type.clone(),
345348
get_type: iface.glib_get_type.clone(),
346349
supertypes: supertypes,

src/codegen/general.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ pub fn define_object_type(
4242
env: &Env,
4343
type_name: &str,
4444
glib_name: &str,
45+
class_name: &Option<&str>,
4546
glib_class_name: &Option<&str>,
4647
glib_func_name: &str,
4748
parents: &[StatusedTypeId],
@@ -64,8 +65,8 @@ pub fn define_object_type(
6465
.collect();
6566

6667
let (separator, class_name) = {
67-
if let &Some(s) = glib_class_name {
68-
(", ".to_string(), format!("ffi::{}", s))
68+
if let (&Some(name), &Some(ffi_name)) = (class_name, glib_class_name) {
69+
(", ".to_string(), format!("{}, ffi::{}", name, ffi_name))
6970
} else {
7071
("".to_string(), "".to_string())
7172
}

src/codegen/object.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ pub fn generate(w: &mut Write, env: &Env, analysis: &analysis::object::Info) ->
2020
env,
2121
&analysis.name,
2222
&analysis.c_type,
23+
&analysis.class_type.as_ref().map(|s| &s[..]),
2324
&analysis.c_class_type.as_ref().map(|s| &s[..]),
2425
&analysis.get_type,
2526
&analysis.supertypes,

0 commit comments

Comments
 (0)