Skip to content

Commit

Permalink
codgen: generate doc_alias for static_type
Browse files Browse the repository at this point in the history
this allows finding *_type() functions using their c names
  • Loading branch information
bilelmoussaoui committed Aug 25, 2023
1 parent 6f75523 commit 24902d9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
17 changes: 11 additions & 6 deletions src/codegen/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,13 +421,18 @@ impl FromGlib<{sys_crate_name}::{ffi_name}> for {name} {{
writeln!(
w,
"impl StaticType for {name} {{
#[inline]
fn static_type() -> {glib_type} {{
unsafe {{ from_glib({sys_crate_name}::{get_type}()) }}
}}
}}",
sys_crate_name = sys_crate_name,
#[inline]",
name = enum_.name,
)?;
doc_alias(w, get_type, "", 1)?;
writeln!(
w,
"
fn static_type() -> {glib_type} {{
unsafe {{ from_glib({sys_crate_name}::{get_type}()) }}
}}
}}",
sys_crate_name = sys_crate_name,
get_type = get_type,
glib_type = use_glib_type(env, "Type")
)?;
Expand Down
17 changes: 11 additions & 6 deletions src/codegen/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,13 +259,18 @@ impl FromGlib<{sys_crate_name}::{ffi_name}> for {name} {{
writeln!(
w,
"impl StaticType for {name} {{
#[inline]
fn static_type() -> {glib_type} {{
unsafe {{ from_glib({sys_crate_name}::{get_type}()) }}
}}
}}",
sys_crate_name = sys_crate_name,
#[inline]",
name = flags.name,
)?;
doc_alias(w, get_type, "", 1)?;
writeln!(
w,
"
fn static_type() -> {glib_type} {{
unsafe {{ from_glib({sys_crate_name}::{get_type}()) }}
}}
}}",
sys_crate_name = sys_crate_name,
get_type = get_type,
glib_type = use_glib_type(env, "Type")
)?;
Expand Down

0 comments on commit 24902d9

Please sign in to comment.