Skip to content

Commit da275fb

Browse files
authored
Update gdext (#40)
1 parent 821b21a commit da275fb

File tree

7 files changed

+72
-81
lines changed

7 files changed

+72
-81
lines changed

Cargo.lock

Lines changed: 13 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ version = "0.1.0"
1010
edition = "2021"
1111

1212
[workspace.dependencies]
13-
godot = { git = "https://github.com/godot-rust/gdext", rev = "22fd33d4d5213a3fe5db9a58547888cebe35c647" }
14-
godot-cell = { git = "https://github.com/godot-rust/gdext", rev = "22fd33d4d5213a3fe5db9a58547888cebe35c647" }
13+
godot = { git = "https://github.com/godot-rust/gdext", rev = "4c8ea83fc3452485f7b33f2411c136a248457334", features = ["experimental-threads"] }
14+
godot-cell = { git = "https://github.com/godot-rust/gdext", rev = "4c8ea83fc3452485f7b33f2411c136a248457334" }
1515
itertools = "0.10.3"
1616
rand = "0.8.5"
1717
darling = { version = "0.20.3" }

rust-script/src/runtime/metadata.rs

Lines changed: 40 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ impl ToDictionary for PropertyInfo {
2525

2626
dict.set("name", self.property_name.clone());
2727
dict.set("class_name", self.class_name.to_string_name());
28-
dict.set("type", self.variant_type as i32);
28+
dict.set("type", self.variant_type.ord());
2929
dict.set("hint", self.hint.ord());
3030
dict.set("hint_string", self.hint_string.clone());
3131
dict.set("usage", self.usage.ord());
@@ -53,44 +53,45 @@ fn variant_type_to_str(var_type: VariantType) -> &'static str {
5353
use VariantType as V;
5454

5555
match var_type {
56-
V::Nil => "void",
57-
V::Bool => "Bool",
58-
V::Int => "Int",
59-
V::Float => "Float",
60-
V::String => "String",
61-
V::Vector2 => "Vector2",
62-
V::Vector2i => "Vector2i",
63-
V::Rect2 => "Rect2",
64-
V::Rect2i => "Rect2i",
65-
V::Vector3 => "Vector3",
66-
V::Vector3i => "Vector3i",
67-
V::Transform2D => "Transform2D",
68-
V::Vector4 => "Vector4",
69-
V::Vector4i => "Vector4i",
70-
V::Plane => "Plane",
71-
V::Quaternion => "Quaternion",
72-
V::Aabb => "Aabb",
73-
V::Basis => "Basis",
74-
V::Transform3D => "Transform3D",
75-
V::Projection => "Projection",
76-
V::Color => "Color",
77-
V::StringName => "StringName",
78-
V::NodePath => "NodePath",
79-
V::Rid => "Rid",
80-
V::Object => "Object",
81-
V::Callable => "Callable",
82-
V::Signal => "Signal",
83-
V::Dictionary => "Dictionary",
84-
V::Array => "Array",
85-
V::PackedByteArray => "PackedByteArray",
86-
V::PackedInt32Array => "PackedInt32Array",
87-
V::PackedInt64Array => "PackedInt64Array",
88-
V::PackedColorArray => "PackedColorArray",
89-
V::PackedStringArray => "PackedStringArray",
90-
V::PackedVector3Array => "PackedVector3Array",
91-
V::PackedVector2Array => "PackedVector2Array",
92-
V::PackedFloat64Array => "PackedFloat64Array",
93-
V::PackedFloat32Array => "PackedFloat32Array",
56+
V::NIL => "void",
57+
V::BOOL => "Bool",
58+
V::INT => "Int",
59+
V::FLOAT => "Float",
60+
V::STRING => "String",
61+
V::VECTOR2 => "Vector2",
62+
V::VECTOR2I => "Vector2i",
63+
V::RECT2 => "Rect2",
64+
V::RECT2I => "Rect2i",
65+
V::VECTOR3 => "Vector3",
66+
V::VECTOR3I => "Vector3i",
67+
V::TRANSFORM2D => "Transform2D",
68+
V::VECTOR4 => "Vector4",
69+
V::VECTOR4I => "Vector4i",
70+
V::PLANE => "Plane",
71+
V::QUATERNION => "Quaternion",
72+
V::AABB => "Aabb",
73+
V::BASIS => "Basis",
74+
V::TRANSFORM3D => "Transform3D",
75+
V::PROJECTION => "Projection",
76+
V::COLOR => "Color",
77+
V::STRING_NAME => "StringName",
78+
V::NODE_PATH => "NodePath",
79+
V::RID => "Rid",
80+
V::OBJECT => "Object",
81+
V::CALLABLE => "Callable",
82+
V::SIGNAL => "Signal",
83+
V::DICTIONARY => "Dictionary",
84+
V::ARRAY => "Array",
85+
V::PACKED_BYTE_ARRAY => "PackedByteArray",
86+
V::PACKED_INT32_ARRAY => "PackedInt32Array",
87+
V::PACKED_INT64_ARRAY => "PackedInt64Array",
88+
V::PACKED_COLOR_ARRAY => "PackedColorArray",
89+
V::PACKED_STRING_ARRAY => "PackedStringArray",
90+
V::PACKED_VECTOR3_ARRAY => "PackedVector3Array",
91+
V::PACKED_VECTOR2_ARRAY => "PackedVector2Array",
92+
V::PACKED_FLOAT64_ARRAY => "PackedFloat64Array",
93+
V::PACKED_FLOAT32_ARRAY => "PackedFloat32Array",
94+
_ => "UNKNOWN",
9495
}
9596
}
9697

rust-script/src/runtime/resource_saver.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@
44
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
55
*/
66

7+
use godot::global;
78
use godot::{
8-
engine::{
9-
file_access, global, resource_saver::SaverFlags, FileAccess, IResourceFormatSaver, Script,
10-
},
9+
engine::{file_access, resource_saver::SaverFlags, FileAccess, IResourceFormatSaver, Script},
1110
obj::EngineBitfield,
1211
prelude::{godot_api, godot_print, GString, Gd, GodotClass, PackedStringArray, Resource},
1312
};

rust-script/src/runtime/rust_script_instance.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
*/
66

77
use core::panic;
8-
use std::{collections::HashMap, fmt::Debug, ops::DerefMut, pin::Pin};
8+
use std::{collections::HashMap, fmt::Debug, ops::DerefMut};
99

1010
use godot::{
1111
builtin::meta::{MethodInfo, PropertyInfo},
1212
engine::{Script, ScriptInstance, SiMut},
1313
prelude::{GString, Gd, Object, StringName, Variant, VariantType},
1414
};
15-
use godot_cell::GdCell;
15+
use godot_cell::blocking::GdCell;
1616

1717
use crate::script_registry::GodotScriptObject;
1818

@@ -51,7 +51,7 @@ fn script_property_list(script: &Gd<RustScript>) -> Box<[PropertyInfo]> {
5151
}
5252

5353
pub struct Context<'a> {
54-
cell: Pin<&'a GdCell<Box<dyn GodotScriptObject>>>,
54+
cell: &'a GdCell<Box<dyn GodotScriptObject>>,
5555
data_ptr: *mut Box<dyn GodotScriptObject>,
5656
}
5757

@@ -63,7 +63,7 @@ impl<'a> Debug for Context<'a> {
6363

6464
impl<'a> Context<'a> {
6565
unsafe fn new(
66-
cell: Pin<&'a GdCell<Box<dyn GodotScriptObject>>>,
66+
cell: &'a GdCell<Box<dyn GodotScriptObject>>,
6767
data_ptr: *mut Box<dyn GodotScriptObject>,
6868
) -> Self {
6969
Self { cell, data_ptr }
@@ -100,7 +100,7 @@ impl<'a> Context<'a> {
100100
}
101101

102102
pub(super) struct RustScriptInstance {
103-
data: Pin<Box<GdCell<Box<dyn GodotScriptObject>>>>,
103+
data: GdCell<Box<dyn GodotScriptObject>>,
104104

105105
script: Gd<RustScript>,
106106
generic_script: Gd<Script>,
@@ -132,14 +132,14 @@ impl ScriptInstance for RustScriptInstance {
132132
}
133133

134134
fn set_property(this: SiMut<Self>, name: StringName, value: &Variant) -> bool {
135-
let cell_ref = this.data.as_ref();
135+
let cell_ref = &this.data;
136136
let mut mut_data = cell_ref.borrow_mut().unwrap();
137137

138138
mut_data.set(name, value.to_owned())
139139
}
140140

141141
fn get_property(&self, name: StringName) -> Option<Variant> {
142-
let guard = self.data.as_ref().borrow().unwrap();
142+
let guard = self.data.borrow().unwrap();
143143

144144
guard.get(name)
145145
}
@@ -157,7 +157,7 @@ impl ScriptInstance for RustScriptInstance {
157157
method: StringName,
158158
args: &[&Variant],
159159
) -> Result<Variant, godot::sys::GDExtensionCallErrorType> {
160-
let cell = this.data.as_ref();
160+
let cell = &this.data;
161161
let mut data_guard = cell.borrow_mut().unwrap();
162162
let data = data_guard.deref_mut();
163163
let data_ptr = data as *mut _;
@@ -186,7 +186,7 @@ impl ScriptInstance for RustScriptInstance {
186186
.iter()
187187
.find(|prop| prop.property_name == name)
188188
.map(|prop| prop.variant_type)
189-
.unwrap_or(godot::sys::VariantType::Nil)
189+
.unwrap_or(godot::sys::VariantType::NIL)
190190
}
191191

192192
fn to_string(&self) -> GString {
@@ -306,7 +306,7 @@ impl ScriptInstance for RustScriptPlaceholder {
306306
.iter()
307307
.find(|prop| prop.property_name == name)
308308
.map(|prop| prop.variant_type)
309-
.unwrap_or(VariantType::Nil)
309+
.unwrap_or(VariantType::NIL)
310310
}
311311

312312
fn to_string(&self) -> GString {

rust-script/src/runtime/rust_script_language.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,10 @@ impl IScriptLanguageExtension for RustScriptLanguage {
213213
) -> Dictionary {
214214
let mut validation = Dictionary::new();
215215

216-
validation.insert("valid", "true");
217-
validation.insert("errors", VariantArray::new());
218-
validation.insert("functions", VariantArray::new());
219-
validation.insert("warnings", VariantArray::new());
216+
validation.set("valid", "true");
217+
validation.set("errors", VariantArray::new());
218+
validation.set("functions", VariantArray::new());
219+
validation.set("warnings", VariantArray::new());
220220

221221
validation
222222
}

rust-script/src/script_registry.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ impl From<&RustScriptSignalInfo> for MethodInfo {
156156
method_name: value.name.into(),
157157
class_name: ClassName::none(),
158158
return_type: PropertyInfo {
159-
variant_type: VariantType::Nil,
159+
variant_type: VariantType::NIL,
160160
class_name: ClassName::none(),
161161
property_name: StringName::default(),
162162
hint: PropertyHint::NONE,

0 commit comments

Comments
 (0)