Skip to content

Commit df08300

Browse files
committed
Add experimental-godot-api feature and hide experimental classes behind it
1 parent e7cafaa commit df08300

File tree

6 files changed

+12
-6
lines changed

6 files changed

+12
-6
lines changed

godot-codegen/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ codegen-fmt = []
1313
codegen-full = []
1414
double-precision = []
1515
custom-godot = ["godot-bindings/custom-godot"]
16+
experimental-godot-api = []
1617

1718
[dependencies]
1819
godot-bindings = { path = "../godot-bindings" }

godot-codegen/src/special_cases.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,12 @@ pub(crate) fn is_deleted(class_name: &TyName, method: &ClassMethod, ctx: &mut Co
4444

4545
#[rustfmt::skip]
4646
pub(crate) fn is_class_deleted(class_name: &TyName) -> bool {
47-
let class_name = class_name.godot_ty.as_str();
48-
49-
// TODO feature-gate experimental classes.
50-
/*
47+
// Exclude experimental APIs unless opted-in.
5148
if !cfg!(feature = "experimental-godot-api") && is_class_experimental(class_name) {
5249
return true;
5350
}
54-
*/
51+
52+
let class_name = class_name.godot_ty.as_str();
5553

5654
// OpenXR has not been available for macOS before 4.2.
5755
// See e.g. https://github.com/GodotVR/godot-xr-tools/issues/479.
@@ -105,7 +103,6 @@ pub(crate) fn is_class_deleted(class_name: &TyName) -> bool {
105103
}
106104

107105
#[rustfmt::skip]
108-
#[allow(dead_code)] // remove once used.
109106
fn is_class_experimental(class_name: &TyName) -> bool {
110107
// These classes are currently hardcoded, but the information is available in Godot's doc/classes directory.
111108
// The XML file contains a property <class name="NavigationMesh" ... is_experimental="true">.

godot-core/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ codegen-fmt = ["godot-ffi/codegen-fmt", "godot-codegen/codegen-fmt"]
1414
codegen-full = ["godot-codegen/codegen-full"]
1515
double-precision = ["godot-codegen/double-precision"]
1616
custom-godot = ["godot-ffi/custom-godot", "godot-codegen/custom-godot"]
17+
experimental-godot-api = ["godot-codegen/experimental-godot-api"]
1718
threads = []
1819

1920
[dependencies]

godot-ffi/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ categories = ["game-engines", "graphics"]
1010
[features]
1111
custom-godot = ["godot-bindings/custom-godot"]
1212
codegen-fmt = ["godot-codegen/codegen-fmt"]
13+
experimental-godot-api = ["godot-codegen/experimental-godot-api"]
1314
trace = []
1415

1516
[dependencies]

godot/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ double-precision = ["godot-core/double-precision"]
1414
formatted = ["godot-core/codegen-fmt"]
1515
serde = ["godot-core/serde"]
1616
threads = ["godot-core/threads"]
17+
experimental-godot-api = ["godot-core/experimental-godot-api"]
1718

1819
# Private features, they are under no stability guarantee
1920
codegen-full = ["godot-core/codegen-full"]

godot/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,11 @@
141141
//! multi-threaded references. The safety aspects of this are not ironed out yet; use at your own risk. The API may also change
142142
//! at any time.
143143
//!
144+
//! * **`experimental-godot-api`**
145+
//!
146+
//! Access to `godot::engine` APIs that Godot marks "experimental". These are under heavy development and may change at any time.
147+
//! If you opt in to this feature, expect breaking changes at compile and runtime.
148+
//!
144149
//! # Public API
145150
//!
146151
//! Some symbols in the API are not intended for users, however Rust's visibility feature is not strong enough to express that in all cases

0 commit comments

Comments
 (0)