Skip to content
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

Drop support for Godot 4.0 #820

Merged
merged 8 commits into from
Jul 27, 2024
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
10 changes: 0 additions & 10 deletions .github/workflows/full-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -381,16 +381,6 @@ jobs:
# Sanitizers can't build proc-macros and build scripts; with --target, cargo ignores RUSTFLAGS for those two.
rust-target: x86_64-unknown-linux-gnu

- name: linux-memcheck-4.0
os: ubuntu-20.04
artifact-name: linux-memcheck-4.0
godot-binary: godot.linuxbsd.editor.dev.x86_64.llvm.san
godot-prebuilt-patch: '4.0.4'
rust-toolchain: nightly
rust-env-rustflags: -Zrandomize-layout -Zsanitizer=address
# Sanitizers can't build proc-macros and build scripts; with --target, cargo ignores RUSTFLAGS for those two.
rust-target: x86_64-unknown-linux-gnu

steps:
- uses: actions/checkout@v4

Expand Down
10 changes: 0 additions & 10 deletions .github/workflows/minimal-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -186,16 +186,6 @@ jobs:
# Sanitizers can't build proc-macros and build scripts; with --target, cargo ignores RUSTFLAGS for those two.
rust-target: x86_64-unknown-linux-gnu

- name: linux-memcheck-4.0
os: ubuntu-20.04
artifact-name: linux-memcheck-4.0
godot-binary: godot.linuxbsd.editor.dev.x86_64.llvm.san
godot-prebuilt-patch: '4.0.4'
rust-toolchain: nightly
rust-env-rustflags: -Zrandomize-layout -Zsanitizer=address
# Sanitizers can't build proc-macros and build scripts; with --target, cargo ignores RUSTFLAGS for those two.
rust-target: x86_64-unknown-linux-gnu

steps:
- uses: actions/checkout@v4

Expand Down
3 changes: 0 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,3 @@ members = [
"examples/dodge-the-creeps/rust",
"examples/hot-reload/rust",
]

#[patch."https://github.com/godot-rust/godot4-prebuilt"]
#godot4-prebuilt = { git = "https://github.com//godot-rust/godot4-prebuilt", branch = "4.1" }
5 changes: 0 additions & 5 deletions godot-bindings/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ experimental-wasm-nothreads = []

# [version-sync] [[
# [line] api-$kebabVersion = []
api-4-0 = []
api-4-0-1 = []
api-4-0-2 = []
api-4-0-3 = []
api-4-0-4 = []
api-4-1 = []
api-4-1-1 = []
api-4-1-2 = []
Expand Down
5 changes: 0 additions & 5 deletions godot-bindings/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ fn main() {

// [version-sync] [[
// [line] \tif cfg!(feature = "api-$kebabVersion") { count += 1; }
if cfg!(feature = "api-4-0") { count += 1; }
if cfg!(feature = "api-4-0-1") { count += 1; }
if cfg!(feature = "api-4-0-2") { count += 1; }
if cfg!(feature = "api-4-0-3") { count += 1; }
if cfg!(feature = "api-4-0-4") { count += 1; }
if cfg!(feature = "api-4-1") { count += 1; }
if cfg!(feature = "api-4-1-1") { count += 1; }
if cfg!(feature = "api-4-1-2") { count += 1; }
Expand Down
25 changes: 0 additions & 25 deletions godot-bindings/src/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ pub const ALL_VERSIONS: &[(u8, u8, u8)] = &[
// [version-sync] [[
// [include] past+current+future
// [line] \t$triple,
(4, 0, 0),
(4, 0, 1),
(4, 0, 2),
(4, 0, 3),
(4, 0, 4),
(4, 1, 0),
(4, 1, 1),
(4, 1, 2),
Expand All @@ -34,21 +29,6 @@ pub const ALL_VERSIONS: &[(u8, u8, u8)] = &[

// [version-sync] [[
// [line] #[cfg(feature = "api-$kebabVersion")]\npub use gdextension_api::version_$snakeVersion as prebuilt;\n
#[cfg(feature = "api-4-0")]
pub use gdextension_api::version_4_0 as prebuilt;

#[cfg(feature = "api-4-0-1")]
pub use gdextension_api::version_4_0_1 as prebuilt;

#[cfg(feature = "api-4-0-2")]
pub use gdextension_api::version_4_0_2 as prebuilt;

#[cfg(feature = "api-4-0-3")]
pub use gdextension_api::version_4_0_3 as prebuilt;

#[cfg(feature = "api-4-0-4")]
pub use gdextension_api::version_4_0_4 as prebuilt;

#[cfg(feature = "api-4-1")]
pub use gdextension_api::version_4_1 as prebuilt;

Expand Down Expand Up @@ -82,11 +62,6 @@ pub use gdextension_api::version_4_2_2 as prebuilt;
// [pre] #[cfg(not(any(
// [post] \tfeature = "api-custom",\n)))]
#[cfg(not(any(
feature = "api-4-0",
feature = "api-4-0-1",
feature = "api-4-0-2",
feature = "api-4-0-3",
feature = "api-4-0-4",
feature = "api-4-1",
feature = "api-4-1-1",
feature = "api-4-1-2",
Expand Down
3 changes: 0 additions & 3 deletions godot-codegen/src/generator/extension_interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,6 @@ fn generate_proc_address_funcs(h_path: &Path) -> TokenStream {

// Do not derive Copy -- even though the struct is bitwise-copyable, this is rarely needed and may point to an error.
let code = quote! {
pub use crate::compat::InitCompat;
// pub use crate::compat::compat_4_1plus::InitCompat;

pub struct GDExtensionInterface {
#( #fptr_decls )*
}
Expand Down
5 changes: 0 additions & 5 deletions godot-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ trace = []
api-custom = ["godot-ffi/api-custom", "godot-codegen/api-custom"]
# [version-sync] [[
# [line] api-$kebabVersion = ["godot-ffi/api-$kebabVersion"]
api-4-0 = ["godot-ffi/api-4-0"]
api-4-0-1 = ["godot-ffi/api-4-0-1"]
api-4-0-2 = ["godot-ffi/api-4-0-2"]
api-4-0-3 = ["godot-ffi/api-4-0-3"]
api-4-0-4 = ["godot-ffi/api-4-0-4"]
api-4-1 = ["godot-ffi/api-4-1"]
api-4-1-1 = ["godot-ffi/api-4-1-1"]
api-4-1-2 = ["godot-ffi/api-4-1-2"]
Expand Down
16 changes: 0 additions & 16 deletions godot-core/src/builtin/basis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,27 +142,11 @@ impl Basis {
}
}

/// Creates a `Basis` with a rotation such that the forward axis (-Z) points
/// towards the `target` position.
///
/// The up axis (+Y) points as close to the `up` vector as possible while
/// staying perpendicular to the forward axis. The resulting Basis is
/// orthonormalized. The `target` and `up` vectors cannot be zero, and
/// cannot be parallel to each other.
///
#[cfg(before_api = "4.1")]
/// _Godot equivalent: `Basis.looking_at()`_
#[doc(alias = "looking_at")]
pub fn new_looking_at(target: Vector3, up: Vector3) -> Self {
super::inner::InnerBasis::looking_at(target, up)
}

/// If `use_model_front` is true, the +Z axis (asset front) is treated as forward (implies +X is left)
/// and points toward the target position. By default, the -Z axis (camera forward) is treated as forward
/// (implies +X is right).
///
/// _Godot equivalent: `Basis.looking_at()`_
#[cfg(since_api = "4.1")]
pub fn new_looking_at(target: Vector3, up: Vector3, use_model_front: bool) -> Self {
super::inner::InnerBasis::looking_at(target, up, use_model_front)
}
Expand Down
2 changes: 1 addition & 1 deletion godot-core/src/builtin/callable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl Callable {
// upcast not needed
let method = method_name.into();
unsafe {
sys::new_with_uninit_or_init::<Self>(|self_ptr| {
Self::new_with_uninit(|self_ptr| {
let ctor = sys::builtin_fn!(callable_from_object_method);
let raw = object.to_ffi();
let args = [raw.as_arg_ptr(), method.sys()];
Expand Down
2 changes: 1 addition & 1 deletion godot-core/src/builtin/collections/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,7 @@ impl<T: ArrayElement> GodotFfiVariant for Array<T> {
}

let array = unsafe {
sys::new_with_uninit_or_init::<Self>(|self_ptr| {
Self::new_with_uninit(|self_ptr| {
let array_from_variant = sys::builtin_fn!(array_from_variant);
array_from_variant(self_ptr, sys::SysPtr::force_mut(variant.var_sys()));
})
Expand Down
2 changes: 1 addition & 1 deletion godot-core/src/builtin/signal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl Signal {
{
let signal_name = signal_name.into();
unsafe {
sys::new_with_uninit_or_init::<Self>(|self_ptr| {
Self::new_with_uninit(|self_ptr| {
let ctor = sys::builtin_fn!(signal_from_object_signal);
let raw = object.to_ffi();
let args = [raw.as_arg_ptr(), signal_name.sys()];
Expand Down
78 changes: 13 additions & 65 deletions godot-core/src/builtin/string/gstring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

use std::fmt::Write;
use std::{convert::Infallible, ffi::c_char, fmt, str::FromStr};

use godot_ffi as sys;
use sys::types::OpaqueString;
use sys::{ffi_methods, interface_fn, GodotFfi};

use crate::builtin::inner;

use super::string_chars::validate_unicode_scalar_sequence;
use super::{NodePath, StringName};
use crate::builtin::{inner, NodePath, StringName};

/// Godot's reference counted string type.
///
Expand Down Expand Up @@ -84,16 +82,9 @@ impl GString {
}

/// Gets the internal chars slice from a [`GString`].
///
/// Note: This operation is *O*(*n*). Consider using [`chars_unchecked`][Self::chars_unchecked]
/// if you can make sure the string is a valid UTF-32.
#[cfg_attr(
since_api = "4.1",
deprecated = "Use `chars()` instead. \n\
Since version 4.1, Godot ensures valid UTF-32, checked and unchecked overloads are no longer needed. \n\
For details, see [godotengine/godot#74760](https://github.com/godotengine/godot/pull/74760)."
)]
pub fn chars_checked(&self) -> &[char] {
pub fn chars(&self) -> &[char] {
// SAFETY: Godot 4.1 ensures valid UTF-32, making interpreting as char slice safe.
// See https://github.com/godotengine/godot/pull/74760.
unsafe {
let s = self.string_sys();
let len = interface_fn!(string_to_utf32_chars)(s, std::ptr::null_mut(), 0);
Expand All @@ -104,43 +95,7 @@ impl GString {
return &[];
}

validate_unicode_scalar_sequence(std::slice::from_raw_parts(ptr, len as usize))
.expect("GString::chars_checked: string contains invalid unicode scalar values")
}
}

/// Gets the internal chars slice from a [`GString`].
///
/// # Safety
///
/// Make sure the string only contains valid unicode scalar values, currently
/// Godot allows for unpaired surrogates and out of range code points to be appended
/// into the string.
#[cfg_attr(
since_api = "4.1",
deprecated = "Use `chars()` instead. \n\
Since version 4.1, ensures valid UTF-32, checked and unchecked overloads are no longer needed. \n\
For details, see [godotengine/godot#74760](https://github.com/godotengine/godot/pull/74760)."
)]
pub unsafe fn chars_unchecked(&self) -> &[char] {
let s = self.string_sys();
let len = interface_fn!(string_to_utf32_chars)(s, std::ptr::null_mut(), 0);
let ptr = interface_fn!(string_operator_index_const)(s, 0);

// Even when len == 0, from_raw_parts requires ptr != 0
if ptr.is_null() {
return &[];
}
std::slice::from_raw_parts(ptr as *const char, len as usize)
}

/// Gets the internal chars slice from a [`GString`].
#[cfg(since_api = "4.1")]
pub fn chars(&self) -> &[char] {
// SAFETY: Godot 4.1 ensures valid UTF-32, making this safe to call.
#[allow(deprecated)]
unsafe {
self.chars_unchecked()
std::slice::from_raw_parts(ptr as *const char, len as usize)
}
}

Expand Down Expand Up @@ -230,26 +185,19 @@ impl_builtin_traits! {

impl fmt::Display for GString {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let s: String;

#[cfg(before_api = "4.1")]
{
s = self.chars_checked().iter().collect();
}
#[cfg(since_api = "4.1")]
{
s = self.chars().iter().collect();
for ch in self.chars() {
f.write_char(*ch)?;
}

f.write_str(s.as_str())
Ok(())
}
}

/// Uses literal syntax from GDScript: `"string"`
impl fmt::Debug for GString {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let s = String::from(self);
write!(f, "\"{s}\"")
// Reuse Display impl.
write!(f, "\"{self}\"")
}
}

Expand Down Expand Up @@ -329,7 +277,7 @@ impl FromStr for GString {
impl From<&StringName> for GString {
fn from(string: &StringName) -> Self {
unsafe {
sys::new_with_uninit_or_init::<Self>(|self_ptr| {
Self::new_with_uninit(|self_ptr| {
let ctor = sys::builtin_fn!(string_from_string_name);
let args = [string.sys()];
ctor(self_ptr, args.as_ptr());
Expand All @@ -350,7 +298,7 @@ impl From<StringName> for GString {
impl From<&NodePath> for GString {
fn from(path: &NodePath) -> Self {
unsafe {
sys::new_with_uninit_or_init::<Self>(|self_ptr| {
Self::new_with_uninit(|self_ptr| {
let ctor = sys::builtin_fn!(string_from_node_path);
let args = [path.sys()];
ctor(self_ptr, args.as_ptr());
Expand Down
1 change: 0 additions & 1 deletion godot-core/src/builtin/string/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
mod gstring;
mod macros;
mod node_path;
mod string_chars;
mod string_name;

use crate::meta::error::ConvertError;
Expand Down
2 changes: 1 addition & 1 deletion godot-core/src/builtin/string/node_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl From<&String> for NodePath {
impl From<&GString> for NodePath {
fn from(string: &GString) -> Self {
unsafe {
sys::new_with_uninit_or_init::<Self>(|self_ptr| {
Self::new_with_uninit(|self_ptr| {
let ctor = sys::builtin_fn!(node_path_from_string);
let args = [string.sys()];
ctor(self_ptr, args.as_ptr());
Expand Down
Loading
Loading