Skip to content

Commit 2c9c960

Browse files
committed
Override is_instantiable key for all Godot tweener classes
1 parent 9f60c2e commit 2c9c960

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

godot-codegen/src/models/domain_mapping.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ impl Class {
9191

9292
// Already checked in is_class_deleted(), but code remains more maintainable if those are separate, and it's cheap to validate.
9393
let is_experimental = special_cases::is_class_experimental(&ty_name.godot_ty);
94+
let is_instantiable =
95+
special_cases::is_class_instantiable(&ty_name).unwrap_or(json.is_instantiable);
9496

9597
let mod_name = ModName::from_godot(&ty_name.godot_ty);
9698

@@ -129,7 +131,7 @@ impl Class {
129131
mod_name,
130132
},
131133
is_refcounted: json.is_refcounted,
132-
is_instantiable: json.is_instantiable,
134+
is_instantiable,
133135
is_experimental,
134136
inherits: json.inherits.clone(),
135137
api_level: get_api_level(json),

godot-codegen/src/special_cases/special_cases.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,24 @@ pub fn is_class_experimental(godot_class_name: &str) -> bool {
206206
}
207207
}
208208

209+
/// Whether a class can be instantiated (overrides Godot's defaults in some cases).
210+
///
211+
/// Returns `None` if the Godot default should be taken.
212+
pub fn is_class_instantiable(class_ty: &TyName) -> Option<bool> {
213+
let class_name = class_ty.godot_ty.as_str();
214+
215+
// The default constructor is available but callers meet with the following Godot error:
216+
// "ERROR: XY can't be created directly. Use create_tween() method."
217+
// for the following classes XY:
218+
//Tween, PropertyTweener, PropertyTweener, IntervalTweener, CallbackTweener, MethodTweener, SubtweenTweener,
219+
220+
if class_name == "Tween" || class_name.ends_with("Tweener") {
221+
return Some(false);
222+
}
223+
224+
None
225+
}
226+
209227
/// Whether a method is available in the method table as a named accessor.
210228
#[rustfmt::skip]
211229
pub fn is_named_accessor_in_table(class_or_builtin_ty: &TyName, godot_method_name: &str) -> bool {

0 commit comments

Comments
 (0)