Skip to content

Commit efa994e

Browse files
bors[bot]Bromeon
andauthored
Merge #935
935: Rename a few remaining occurrences of #[export] r=Bromeon a=Bromeon Forgot to include this commit in #933. bors r+ Co-authored-by: Jan Haller <[email protected]>
2 parents 29b89b0 + 00dd605 commit efa994e

File tree

12 files changed

+55
-55
lines changed

12 files changed

+55
-55
lines changed

.github/workflows/full-ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ jobs:
139139
testflags: '-- --skip ui_tests'
140140
- os: { id: ubuntu-latest, name: linux }
141141
rust: { toolchain: 'stable', postfix: ' (minimal-deps)', special: 'minimal-deps' }
142+
testflags: '-- --skip ui_tests'
142143
runs-on: ${{ matrix.os.id }}
143144
steps:
144145
- uses: actions/checkout@v3

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ impl HelloWorld {
8484
HelloWorld
8585
}
8686

87-
#[export]
88-
fn _ready(&self, _owner: &Node) {
87+
#[method]
88+
fn _ready(&self, #[base] _node: &Node) {
8989
godot_print!("Hello, world.");
9090
}
9191
}

examples/property-export/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ impl PropertyExport {
2121
Self::default()
2222
}
2323

24-
#[export]
25-
fn _ready(&self, _base: &Node) {
24+
#[method]
25+
fn _ready(&self) {
2626
godot_print!("------------------------------------------------------------------");
2727
godot_print!("Print from Rust (note the unordered map/set):");
2828
godot_print!(" Vec (name):");

gdnative/tests/ui/derive_fail_methods.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ impl Foo {
99
Foo {}
1010
}
1111

12-
#[export]
13-
fn draw(&self, _owner: &Node) {}
12+
#[method]
13+
fn draw(&self) {}
1414
}
1515

1616
fn main() {}
Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
error: cannot find attribute `export` in this scope
1+
error: cannot find attribute `method` in this scope
22
--> $DIR/derive_fail_methods.rs:12:7
33
|
4-
12 | #[export]
5-
| ^^^^^^ help: a built-in attribute with a similar name exists: `expect`
4+
12 | #[method]
5+
| ^^^^^^ help: an attribute macro with a similar name exists: `methods`
6+
|
7+
::: $WORKSPACE/gdnative-derive/src/lib.rs
8+
|
9+
| pub fn methods(meta: TokenStream, input: TokenStream) -> TokenStream {
10+
| -------------------------------------------------------------------- similarly named attribute macro `methods` defined here

test/src/lib.rs

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -115,28 +115,22 @@ impl NotFoo {
115115

116116
#[methods]
117117
impl Foo {
118-
#[export]
119-
fn answer(&self, _owner: &Reference) -> i64 {
118+
#[method]
119+
fn answer(&self, #[base] _base: &Reference) -> i64 {
120120
self.0
121121
}
122122

123-
#[export]
124-
fn choose(
125-
&self,
126-
_owner: &Reference,
127-
a: GodotString,
128-
which: bool,
129-
b: GodotString,
130-
) -> GodotString {
123+
#[method]
124+
fn choose(&self, a: GodotString, which: bool, b: GodotString) -> GodotString {
131125
if which {
132126
a
133127
} else {
134128
b
135129
}
136130
}
137131

138-
#[export]
139-
fn choose_variant(&self, _owner: &Reference, a: i32, what: Variant, b: f64) -> Variant {
132+
#[method]
133+
fn choose_variant(&self, a: i32, what: Variant, b: f64) -> Variant {
140134
let what = what.try_to::<String>().expect("should be string");
141135
match what.as_str() {
142136
"int" => a.to_variant(),
@@ -148,13 +142,13 @@ impl Foo {
148142

149143
godot_itest! { test_rust_class_construction {
150144
let foo = Foo::new_instance();
151-
assert_eq!(Ok(42), foo.map(|foo, owner| { foo.answer(&owner) }));
145+
assert_eq!(Ok(42), foo.map(|foo, base| { foo.answer(&base) }));
152146

153147
let base = foo.into_base();
154148
assert_eq!(Some(42), unsafe { base.call("answer", &[]).to() });
155149

156150
let foo = Instance::<Foo, _>::try_from_base(base).expect("should be able to downcast");
157-
assert_eq!(Ok(42), foo.map(|foo, owner| { foo.answer(&owner) }));
151+
assert_eq!(Ok(42), foo.map(|foo, base| { foo.answer(&base) }));
158152

159153
let base = foo.into_base();
160154
assert!(Instance::<NotFoo, _>::try_from_base(base).is_err());
@@ -172,11 +166,10 @@ impl OptionalArgs {
172166

173167
#[methods]
174168
impl OptionalArgs {
175-
#[export]
169+
#[method]
176170
#[allow(clippy::many_single_char_names)]
177171
fn opt_sum(
178-
&self,
179-
_owner: &Reference,
172+
&self, //
180173
a: i64,
181174
b: i64,
182175
#[opt] c: i64,

test/src/test_async.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ impl AsyncExecutorDriver {
4848

4949
#[methods]
5050
impl AsyncExecutorDriver {
51-
#[export]
52-
fn _process(&self, _owner: &Node, _delta: f64) {
51+
#[method]
52+
fn _process(&self, _delta: f64) {
5353
EXECUTOR.with(|e| e.pool.borrow_mut().run_until_stalled());
5454
}
5555
}

test/src/test_derive.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ impl MinimalDerive {
187187
Self(54)
188188
}
189189

190-
#[export]
190+
#[export] // deliberately use old attribute
191191
fn answer(&self, _owner: &Reference) -> i64 {
192192
self.0
193193
}
@@ -208,22 +208,22 @@ struct EmplacementOnly(i64);
208208

209209
#[methods]
210210
impl EmplacementOnly {
211-
#[export]
212-
fn answer(&self, _owner: &Reference) -> i64 {
211+
#[method]
212+
fn answer(&self, #[base] _base: &Reference) -> i64 {
213213
self.0
214214
}
215215
}
216216

217217
crate::godot_itest! { test_derive_nativeclass_without_constructor {
218218
let foo = Instance::emplace(EmplacementOnly(54));
219-
assert_eq!(Ok(54), foo.map(|foo, owner| { foo.answer(&owner) }));
219+
assert_eq!(Ok(54), foo.map(|foo, base| { foo.answer(&base) }));
220220

221221
let base = foo.into_base();
222222
assert_eq!(Some(54), unsafe { base.call("answer", &[]).to::<i64>() });
223223

224224
let foo = Instance::<EmplacementOnly, _>::try_from_base(base)
225225
.expect("should be able to downcast");
226-
assert_eq!(Ok(54), foo.map(|foo, owner| { foo.answer(&owner) }));
226+
assert_eq!(Ok(54), foo.map(|foo, base| { foo.answer(&base) }));
227227
}}
228228

229229
// ----------------------------------------------------------------------------------------------------------------------------------------------
@@ -237,8 +237,8 @@ impl WithoutInherit {
237237
Self(54)
238238
}
239239

240-
#[export]
241-
fn answer(&self, _owner: &Reference) -> i64 {
240+
#[method]
241+
fn answer(&self) -> i64 {
242242
self.0
243243
}
244244
}

test/src/test_free_ub.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@ struct Bar(i64, Arc<AtomicUsize>);
2121

2222
#[methods]
2323
impl Bar {
24-
#[export]
25-
fn free_is_not_ub(&mut self, owner: &Node) -> bool {
24+
#[method]
25+
fn free_is_not_ub(&mut self, #[base] owner: &Node) -> bool {
2626
unsafe {
2727
owner.assume_unique().free();
2828
}
2929
assert_eq!(42, self.0, "self should not point to garbage");
3030
true
3131
}
3232

33-
#[export]
34-
fn set_script_is_not_ub(&mut self, owner: &Node) -> bool {
33+
#[method]
34+
fn set_script_is_not_ub(&mut self, #[base] owner: &Node) -> bool {
3535
owner.set_script(Null::null());
3636
assert_eq!(42, self.0, "self should not point to garbage");
3737
true

test/src/test_map_owned.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ struct VecBuilder {
2323

2424
#[methods]
2525
impl VecBuilder {
26-
#[export]
27-
fn append(mut self, _owner: TRef<Reference>, mut numbers: Vec<i32>) -> Instance<Self> {
26+
#[method]
27+
fn append(mut self, mut numbers: Vec<i32>) -> Instance<Self> {
2828
self.v.append(&mut numbers);
2929
Instance::emplace(Self { v: self.v }).into_shared()
3030
}
@@ -35,15 +35,15 @@ crate::godot_itest! { test_map_owned {
3535
let v1 = unsafe { v1.assume_safe() };
3636

3737
let v2 = v1
38-
.map_owned(|s, owner| s.append(owner, vec![1, 2, 3]))
38+
.map_owned(|s, _base| s.append(vec![1, 2, 3]))
3939
.unwrap();
4040
let v2 = unsafe { v2.assume_safe() };
4141
assert!(v1
4242
.map_owned(|_, _| panic!("should never be called"))
4343
.is_err());
4444

4545
let v3 = v2
46-
.map_owned(|s, owner| s.append(owner, vec![4, 5, 6]))
46+
.map_owned(|s, _base| s.append(vec![4, 5, 6]))
4747
.unwrap();
4848
let v3 = unsafe { v3.assume_safe() };
4949
assert!(v2

0 commit comments

Comments
 (0)