Skip to content

Object notification API, engine intra-doc links #223

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

Merged
merged 8 commits into from
Apr 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 14 additions & 21 deletions godot-codegen/src/central_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ fn make_sys_code(central_items: &CentralItems) -> String {
#(#opaque_types)*
}

// ----------------------------------------------------------------------------------------------------------------------------------------------

pub struct GlobalMethodTable {
#(#variant_fn_decls)*
}
Expand All @@ -148,6 +150,8 @@ fn make_sys_code(central_items: &CentralItems) -> String {
}
}

// ----------------------------------------------------------------------------------------------------------------------------------------------

#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
#[repr(i32)]
pub enum VariantType {
Expand Down Expand Up @@ -182,6 +186,8 @@ fn make_sys_code(central_items: &CentralItems) -> String {
ffi_methods! { type GDExtensionTypePtr = *mut Self; .. }
}

// ----------------------------------------------------------------------------------------------------------------------------------------------

#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
#[repr(i32)]
pub enum VariantOperator {
Expand Down Expand Up @@ -256,6 +262,12 @@ fn make_core_code(central_items: &CentralItems) -> String {
}
}

/// Global enums and constants.
///
/// A list of global-scope enumerated constants.
/// For global built-in functions, check out the [`utilities` module][crate::engine::utilities].
///
/// See also [Godot docs for `@GlobalScope`](https://docs.godotengine.org/en/stable/classes/[email protected]#enumerations).
pub mod global {
use crate::sys;
#( #global_enum_defs )*
Expand All @@ -266,7 +278,7 @@ fn make_core_code(central_items: &CentralItems) -> String {
}

fn make_central_items(api: &ExtensionApi, build_config: &str, ctx: &mut Context) -> CentralItems {
let mut opaque_types = vec![];
let mut opaque_types = Vec::new();
for class in &api.builtin_class_sizes {
if class.build_configuration == build_config {
for ClassSize { name, size } in &class.sizes {
Expand Down Expand Up @@ -331,7 +343,7 @@ fn make_central_items(api: &ExtensionApi, build_config: &str, ctx: &mut Context)

result
.variant_op_enumerators_pascal
.push(ident(&shout_to_pascal(name)));
.push(ident(&util::shout_to_pascal(name)));
result
.variant_op_enumerators_ord
.push(Literal::i32_unsuffixed(op.value));
Expand Down Expand Up @@ -707,22 +719,3 @@ fn is_trivial(type_names: &TypeNames) -> bool {

list.contains(&type_names.json_builtin_name.as_str())
}

fn shout_to_pascal(shout_case: &str) -> String {
let mut result = String::with_capacity(shout_case.len());
let mut next_upper = true;

for ch in shout_case.chars() {
if next_upper {
assert_ne!(ch, '_'); // no double underscore
result.push(ch); // unchanged
next_upper = false;
} else if ch == '_' {
next_upper = true;
} else {
result.push(ch.to_ascii_lowercase());
}
}

result
}
Loading