Skip to content

Commit 685e0a2

Browse files
committed
Remove NODE_RECACHE_REQUESTED notification on older API levels, too
1 parent 4e6bd93 commit 685e0a2

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

godot-codegen/src/generator/notifications.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ pub fn make_notification_enum(
9898
/// Makes it easier to keep an overview all possible notification variants for a given class, including
9999
/// notifications defined in base classes.
100100
///
101-
/// Contains the [`Unknown`] variant for forward compatibility.
101+
/// Contains the [`Unknown`][Self::Unknown] variant for forward compatibility.
102102
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
103103
#[repr(i32)]
104104
#[allow(non_camel_case_types)]
@@ -110,6 +110,9 @@ pub fn make_notification_enum(
110110

111111
/// Since Godot represents notifications as integers, it's always possible that a notification outside the known types
112112
/// is received. For example, the user can manually issue notifications through `Object::notify()`.
113+
///
114+
/// This is also necessary if you develop an extension on a Godot version and want to be forward-compatible with newer
115+
/// versions. If Godot adds new notifications, they will be unknown to your extension, but you can still handle them.
113116
Unknown(i32),
114117
}
115118

@@ -153,16 +156,9 @@ pub fn try_to_notification(constant: &JsonClassConstant) -> Option<Ident> {
153156
/// Godot has a collision for two notification constants (DRAW, NODE_CACHE_REQUESTED) in the same inheritance branch (as of 4.0.2).
154157
/// This cannot be represented in a Rust enum, so we merge the two constants into a single enumerator.
155158
fn workaround_constant_collision(all_constants: &mut Vec<(Ident, i32)>) {
159+
// This constant has never been used by the engine.
156160
#[cfg(before_api = "4.2")]
157-
for first in ["Draw", "VisibilityChanged"] {
158-
if let Some(index_of_draw) = all_constants
159-
.iter()
160-
.position(|(constant_name, _)| constant_name == first)
161-
{
162-
all_constants[index_of_draw].0 = quote::format_ident!("{first}OrNodeRecacheRequested");
163-
all_constants.retain(|(constant_name, _)| constant_name != "NodeRecacheRequested");
164-
}
165-
}
161+
all_constants.retain(|(constant_name, _)| constant_name != "NODE_RECACHE_REQUESTED");
166162

167163
let _ = &all_constants; // unused warning
168164
}

0 commit comments

Comments
 (0)