Skip to content

Commit 93c9f5b

Browse files
committed
Make the default the reentrant storage
1 parent 18e1f46 commit 93c9f5b

File tree

13 files changed

+116
-591
lines changed

13 files changed

+116
-591
lines changed

.github/workflows/full-ci.yml

Lines changed: 0 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ name: Full CI
77
# Runs before merging. Rebases on master to make sure CI passes for latest integration, not only for the PR at the time of creation.
88

99
on:
10-
push:
1110
merge_group:
1211
# push:
1312

@@ -189,50 +188,25 @@ jobs:
189188
artifact-name: macos-nightly
190189
godot-binary: godot.macos.editor.dev.x86_64
191190
rust-extra-args: --features godot/custom-godot
192-
193-
- name: macos-bind-self
194-
os: macos-12
195-
artifact-name: macos-nightly
196-
godot-binary: godot.macos.editor.dev.x86_64
197-
rust-extra-args: --features godot/custom-godot,itest/experimental-bind-self
198191

199192
- name: macos-double
200193
os: macos-12
201194
artifact-name: macos-double-nightly
202195
godot-binary: godot.macos.editor.dev.double.x86_64
203196
rust-extra-args: --features godot/custom-godot,godot/double-precision
204-
205-
- name: macos-double-bind-self
206-
os: macos-12
207-
artifact-name: macos-double-nightly
208-
godot-binary: godot.macos.editor.dev.double.x86_64
209-
rust-extra-args: --features godot/custom-godot,godot/double-precision,itest/experimental-bind-self
210197

211198
- name: macos-4.1
212199
os: macos-12
213200
artifact-name: macos-stable
214201
godot-binary: godot.macos.editor.dev.x86_64
215202
#godot-prebuilt-patch: '4.1'
216-
rust-extra-args: --features itest/experimental-bind-self
217-
218-
- name: macos-bind-self-4.1
219-
os: macos-12
220-
artifact-name: macos-stable
221-
godot-binary: godot.macos.editor.dev.x86_64
222-
#godot-prebuilt-patch: '4.1'
223203

224204
# TODO merge with other jobs
225205
- name: macos-lazy-fptrs
226206
os: macos-12
227207
artifact-name: macos-nightly
228208
godot-binary: godot.macos.editor.dev.x86_64
229209
rust-extra-args: --features godot/lazy-function-tables
230-
231-
- name: macos-lazy-fptrs-bind-self
232-
os: macos-12
233-
artifact-name: macos-nightly
234-
godot-binary: godot.macos.editor.dev.x86_64
235-
rust-extra-args: --features godot/lazy-function-tables,itest/experimental-bind-self
236210

237211
# Windows
238212

@@ -242,49 +216,24 @@ jobs:
242216
godot-binary: godot.windows.editor.dev.x86_64.exe
243217
rust-extra-args: --features godot/custom-godot
244218

245-
- name: windows-bind-self
246-
os: windows-latest
247-
artifact-name: windows-nightly
248-
godot-binary: godot.windows.editor.dev.x86_64.exe
249-
rust-extra-args: --features godot/custom-godot,itest/experimental-bind-self
250-
251219
- name: windows-double
252220
os: windows-latest
253221
artifact-name: windows-double-nightly
254222
godot-binary: godot.windows.editor.dev.double.x86_64.exe
255223
rust-extra-args: --features godot/custom-godot,godot/double-precision
256224

257-
- name: windows-double-bind-self
258-
os: windows-latest
259-
artifact-name: windows-double-nightly
260-
godot-binary: godot.windows.editor.dev.double.x86_64.exe
261-
rust-extra-args: --features godot/custom-godot,godot/double-precision,itest/experimental-bind-self
262-
263225
- name: windows-4.1
264226
os: windows-latest
265227
artifact-name: windows-stable
266228
godot-binary: godot.windows.editor.dev.x86_64.exe
267229
#godot-prebuilt-patch: '4.1'
268230

269-
- name: windows-bind-self-4.1
270-
os: windows-latest
271-
artifact-name: windows-stable
272-
godot-binary: godot.windows.editor.dev.x86_64.exe
273-
#godot-prebuilt-patch: '4.1'
274-
rust-extra-args: --features itest/experimental-bind-self
275-
276231
# TODO merge with other jobs
277232
- name: windows-lazy-fptrs
278233
os: windows-latest
279234
artifact-name: windows-nightly
280235
godot-binary: godot.windows.editor.dev.x86_64.exe
281236
rust-extra-args: --features godot/lazy-function-tables
282-
283-
- name: windows-lazy-fptrs-bind-self
284-
os: windows-latest
285-
artifact-name: windows-nightly
286-
godot-binary: godot.windows.editor.dev.x86_64.exe
287-
rust-extra-args: --features godot/lazy-function-tables,itest/experimental-bind-self
288237

289238
# Linux
290239

@@ -296,49 +245,25 @@ jobs:
296245
godot-binary: godot.linuxbsd.editor.dev.x86_64
297246
rust-extra-args: --features godot/custom-godot
298247

299-
- name: linux-bind-self
300-
os: ubuntu-20.04
301-
artifact-name: linux-nightly
302-
godot-binary: godot.linuxbsd.editor.dev.x86_64
303-
rust-extra-args: --features godot/custom-godot,itest/experimental-bind-self
304-
305248
- name: linux-double
306249
os: ubuntu-20.04
307250
artifact-name: linux-double-nightly
308251
godot-binary: godot.linuxbsd.editor.dev.double.x86_64
309252
rust-extra-args: --features godot/custom-godot,godot/double-precision
310253

311-
- name: linux-double-bind-self
312-
os: ubuntu-20.04
313-
artifact-name: linux-double-nightly
314-
godot-binary: godot.linuxbsd.editor.dev.double.x86_64
315-
rust-extra-args: --features godot/custom-godot,godot/double-precision,itest/experimental-bind-self
316-
317254
- name: linux-features
318255
os: ubuntu-20.04
319256
artifact-name: linux-nightly
320257
godot-binary: godot.linuxbsd.editor.dev.x86_64
321258
rust-extra-args: --features godot/custom-godot,godot/experimental-threads,godot/serde
322259

323-
- name: linux-features-bind-self
324-
os: ubuntu-20.04
325-
artifact-name: linux-nightly
326-
godot-binary: godot.linuxbsd.editor.dev.x86_64
327-
rust-extra-args: --features godot/custom-godot,godot/experimental-threads,godot/serde,itest/experimental-bind-self
328-
329260
# TODO merge with other jobs
330261
- name: linux-lazy-fptrs
331262
os: ubuntu-20.04
332263
artifact-name: linux-nightly
333264
godot-binary: godot.linuxbsd.editor.dev.x86_64
334265
rust-extra-args: --features godot/lazy-function-tables
335266

336-
- name: linux-lazy-fptrs-bind-self
337-
os: ubuntu-20.04
338-
artifact-name: linux-nightly
339-
godot-binary: godot.linuxbsd.editor.dev.x86_64
340-
rust-extra-args: --features godot/lazy-function-tables,itest/experimental-bind-self
341-
342267
# Linux compat
343268

344269
- name: linux-4.1.1
@@ -347,38 +272,18 @@ jobs:
347272
godot-binary: godot.linuxbsd.editor.dev.x86_64
348273
#godot-prebuilt-patch: '4.1.1'
349274

350-
- name: linux-bind-self-4.1.1
351-
os: ubuntu-20.04
352-
artifact-name: linux-stable
353-
godot-binary: godot.linuxbsd.editor.dev.x86_64
354-
#godot-prebuilt-patch: '4.1.1'
355-
rust-extra-args: --features itest/experimental-bind-self
356-
357275
- name: linux-4.1
358276
os: ubuntu-20.04
359277
artifact-name: linux-stable
360278
godot-binary: godot.linuxbsd.editor.dev.x86_64
361279
godot-prebuilt-patch: '4.1'
362280

363-
- name: linux-bind-self-4.1
364-
os: ubuntu-20.04
365-
artifact-name: linux-stable
366-
godot-binary: godot.linuxbsd.editor.dev.x86_64
367-
godot-prebuilt-patch: '4.1'
368-
rust-extra-args: --features itest/experimental-bind-self
369-
370281
- name: linux-4.0.4
371282
os: ubuntu-20.04
372283
artifact-name: linux-4.0.4
373284
godot-binary: godot.linuxbsd.editor.dev.x86_64
374285
godot-prebuilt-patch: '4.0.4'
375286

376-
- name: linux-bind-self-4.0.4
377-
os: ubuntu-20.04
378-
artifact-name: linux-4.0.4
379-
godot-binary: godot.linuxbsd.editor.dev.x86_64
380-
godot-prebuilt-patch: '4.0.4'
381-
rust-extra-args: --features itest/experimental-bind-self
382287

383288
# Memory checks: special Godot binaries compiled with AddressSanitizer/LeakSanitizer to detect UB/leaks.
384289
# See also https://rustc-dev-guide.rust-lang.org/sanitizers.html.
@@ -397,16 +302,6 @@ jobs:
397302
# Sanitizers can't build proc-macros and build scripts; with --target, cargo ignores RUSTFLAGS for those two.
398303
rust-target: x86_64-unknown-linux-gnu
399304

400-
- name: linux-memcheck-bind-self
401-
os: ubuntu-20.04
402-
artifact-name: linux-memcheck-clang-nightly
403-
godot-binary: godot.linuxbsd.editor.dev.x86_64.llvm.san
404-
rust-toolchain: nightly
405-
rust-env-rustflags: -Zrandomize-layout -Zsanitizer=address
406-
rust-extra-args: --features godot/custom-godot,itest/experimental-bind-self
407-
# Sanitizers can't build proc-macros and build scripts; with --target, cargo ignores RUSTFLAGS for those two.
408-
rust-target: x86_64-unknown-linux-gnu
409-
410305
- name: linux-memcheck-4.0.4
411306
os: ubuntu-20.04
412307
artifact-name: linux-memcheck-clang-4.0.4
@@ -416,17 +311,6 @@ jobs:
416311
rust-env-rustflags: -Zrandomize-layout -Zsanitizer=address
417312
# Sanitizers can't build proc-macros and build scripts; with --target, cargo ignores RUSTFLAGS for those two.
418313
rust-target: x86_64-unknown-linux-gnu
419-
420-
- name: linux-memcheck-bind-self-4.0.4
421-
os: ubuntu-20.04
422-
artifact-name: linux-memcheck-clang-4.0.4
423-
godot-binary: godot.linuxbsd.editor.dev.x86_64.llvm.san
424-
godot-prebuilt-patch: '4.0.4'
425-
rust-toolchain: nightly
426-
rust-env-rustflags: -Zrandomize-layout -Zsanitizer=address
427-
rust-extra-args: --features itest/experimental-bind-self
428-
# Sanitizers can't build proc-macros and build scripts; with --target, cargo ignores RUSTFLAGS for those two.
429-
rust-target: x86_64-unknown-linux-gnu
430314

431315
steps:
432316
- uses: actions/checkout@v3

godot-core/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ custom-godot = ["godot-ffi/custom-godot", "godot-codegen/custom-godot"]
1919
double-precision = ["godot-codegen/double-precision"]
2020
experimental-godot-api = ["godot-codegen/experimental-godot-api"]
2121
experimental-threads = []
22-
experimental-bind-self = ["godot-cell"]
2322
trace = ["godot-ffi/trace"]
2423

2524
[dependencies]
@@ -28,7 +27,7 @@ godot-ffi = { path = "../godot-ffi" }
2827
# See https://docs.rs/glam/latest/glam/index.html#feature-gates
2928
glam = { version = "0.23", features = ["debug-glam-assert"] }
3029
serde = { version = "1", features = ["derive"], optional = true }
31-
godot-cell = { path = "../godot-cell", optional = true }
30+
godot-cell = { path = "../godot-cell" }
3231

3332
# Reverse dev dependencies so doctests can use `godot::` prefix
3433
[dev-dependencies]

godot-core/src/obj/traits.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,8 @@ pub trait WithBaseField: GodotClass<Declarer = dom::UserDomain> {
287287

288288
/// Returns a mutable reference suitable for calling engine methods on this object.
289289
///
290-
/// If the feature `experimental-bind-self` is enabled, then this method will allow you to call back into
291-
/// the same object from Godot.
290+
/// This method will allow you to call back into the same object from Godot, unlike what would happen
291+
/// if you used [`to_gd()`](WithBaseField::to_gd).
292292
///
293293
/// # Examples
294294
///
@@ -316,7 +316,7 @@ pub trait WithBaseField: GodotClass<Declarer = dom::UserDomain> {
316316
/// # unsafe impl ExtensionLibrary for Test {}
317317
/// ```
318318
///
319-
/// And with `experimental-bind-self` enabled, code such as this works:
319+
/// We can call back into `self` through Godot:
320320
///
321321
/// ```
322322
/// use godot::prelude::*;
@@ -331,8 +331,6 @@ pub trait WithBaseField: GodotClass<Declarer = dom::UserDomain> {
331331
/// #[godot_api]
332332
/// impl INode for MyClass {
333333
/// fn process(&mut self, _delta: f64) {
334-
/// // Only works with `experimental-bind-self` enabled. Without that feature, this will panic at
335-
/// // runtime.
336334
/// self.base_mut().call("other_method".into(), &[]);
337335
/// }
338336
/// }

godot-core/src/storage.rs

Lines changed: 4 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -49,30 +49,11 @@ impl AtomicLifecycle {
4949
}
5050
}
5151

52-
#[cfg_attr(
53-
all(
54-
not(feature = "experimental-bind-self"),
55-
feature = "experimental-threads"
56-
),
57-
allow(dead_code)
58-
)]
52+
#[cfg_attr(feature = "experimental-threads", allow(dead_code))]
5953
mod single_threaded;
6054

61-
#[cfg_attr(
62-
all(
63-
not(feature = "experimental-bind-self"),
64-
not(feature = "experimental-threads")
65-
),
66-
allow(dead_code)
67-
)]
68-
mod multi_threaded;
69-
70-
#[cfg(feature = "experimental-bind-self")]
7155
#[cfg_attr(not(feature = "experimental-threads"), allow(dead_code))]
72-
mod reentrant_multi_threaded;
73-
#[cfg(feature = "experimental-bind-self")]
74-
#[cfg_attr(feature = "experimental-threads", allow(dead_code))]
75-
mod reentrant_single_threaded;
56+
mod multi_threaded;
7657

7758
/// A storage for an instance binding.
7859
///
@@ -130,8 +111,6 @@ pub unsafe trait Storage {
130111
///
131112
/// This can use the provided `instance` to provide extra safety guarantees such as allowing reentrant
132113
/// code to create new mutable references.
133-
///
134-
/// Currently only has an effect if `experimental-bind-self` is enabled.
135114
fn get_base_mut<'a: 'b, 'b>(
136115
&'a self,
137116
instance: &'b mut Self::Instance,
@@ -202,27 +181,12 @@ pub(crate) trait StorageRefCounted: Storage {
202181
fn on_dec_ref(&self);
203182
}
204183

205-
#[cfg(all(
206-
not(feature = "experimental-threads"),
207-
not(feature = "experimental-bind-self")
208-
))]
184+
#[cfg(not(feature = "experimental-threads"))]
209185
pub type InstanceStorage<T> = single_threaded::InstanceStorage<T>;
210186

211-
#[cfg(all(
212-
feature = "experimental-threads",
213-
not(feature = "experimental-bind-self")
214-
))]
187+
#[cfg(feature = "experimental-threads")]
215188
pub type InstanceStorage<T> = multi_threaded::InstanceStorage<T>;
216189

217-
#[cfg(all(
218-
not(feature = "experimental-threads"),
219-
feature = "experimental-bind-self"
220-
))]
221-
pub type InstanceStorage<T> = reentrant_single_threaded::InstanceStorage<T>;
222-
223-
#[cfg(all(feature = "experimental-threads", feature = "experimental-bind-self"))]
224-
pub type InstanceStorage<T> = reentrant_multi_threaded::InstanceStorage<T>;
225-
226190
pub type RefGuard<'a, T> = <InstanceStorage<T> as Storage>::RefGuard<'a>;
227191
pub type MutGuard<'a, T> = <InstanceStorage<T> as Storage>::MutGuard<'a>;
228192
pub type BaseMutGuard<'a, T> = <InstanceStorage<T> as Storage>::BaseMutGuard<'a>;

0 commit comments

Comments
 (0)