Skip to content

Commit

Permalink
Merge #935
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
bors[bot] and Bromeon authored Aug 31, 2022
2 parents 29b89b0 + f0ae398 commit 1bab81d
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 49 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ impl HelloWorld {
HelloWorld
}

#[export]
fn _ready(&self, _owner: &Node) {
#[method]
fn _ready(&self, #[base] _node: &Node) {
godot_print!("Hello, world.");
}
}
Expand Down
4 changes: 2 additions & 2 deletions examples/property-export/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ impl PropertyExport {
Self::default()
}

#[export]
fn _ready(&self, _base: &Node) {
#[method]
fn _ready(&self) {
godot_print!("------------------------------------------------------------------");
godot_print!("Print from Rust (note the unordered map/set):");
godot_print!(" Vec (name):");
Expand Down
4 changes: 2 additions & 2 deletions gdnative/tests/ui/derive_fail_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ impl Foo {
Foo {}
}

#[export]
fn draw(&self, _owner: &Node) {}
#[method]
fn draw(&self) {}
}

fn main() {}
11 changes: 8 additions & 3 deletions gdnative/tests/ui/derive_fail_methods.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
error: cannot find attribute `export` in this scope
error: cannot find attribute `method` in this scope
--> $DIR/derive_fail_methods.rs:12:7
|
12 | #[export]
| ^^^^^^ help: a built-in attribute with a similar name exists: `expect`
12 | #[method]
| ^^^^^^ help: an attribute macro with a similar name exists: `methods`
|
::: $WORKSPACE/gdnative-derive/src/lib.rs
|
| pub fn methods(meta: TokenStream, input: TokenStream) -> TokenStream {
| -------------------------------------------------------------------- similarly named attribute macro `methods` defined here
23 changes: 8 additions & 15 deletions test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,28 +115,22 @@ impl NotFoo {

#[methods]
impl Foo {
#[export]
fn answer(&self, _owner: &Reference) -> i64 {
#[method]
fn answer(&self) -> i64 {
self.0
}

#[export]
fn choose(
&self,
_owner: &Reference,
a: GodotString,
which: bool,
b: GodotString,
) -> GodotString {
#[method]
fn choose(&self, a: GodotString, which: bool, b: GodotString) -> GodotString {
if which {
a
} else {
b
}
}

#[export]
fn choose_variant(&self, _owner: &Reference, a: i32, what: Variant, b: f64) -> Variant {
#[method]
fn choose_variant(&self, a: i32, what: Variant, b: f64) -> Variant {
let what = what.try_to::<String>().expect("should be string");
match what.as_str() {
"int" => a.to_variant(),
Expand Down Expand Up @@ -172,11 +166,10 @@ impl OptionalArgs {

#[methods]
impl OptionalArgs {
#[export]
#[method]
#[allow(clippy::many_single_char_names)]
fn opt_sum(
&self,
_owner: &Reference,
&self, //
a: i64,
b: i64,
#[opt] c: i64,
Expand Down
4 changes: 2 additions & 2 deletions test/src/test_async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ impl AsyncExecutorDriver {

#[methods]
impl AsyncExecutorDriver {
#[export]
fn _process(&self, _owner: &Node, _delta: f64) {
#[method]
fn _process(&self, _delta: f64) {
EXECUTOR.with(|e| e.pool.borrow_mut().run_until_stalled());
}
}
Expand Down
10 changes: 5 additions & 5 deletions test/src/test_derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ impl MinimalDerive {
Self(54)
}

#[export]
#[export] // deliberately use old attribute
fn answer(&self, _owner: &Reference) -> i64 {
self.0
}
Expand All @@ -208,8 +208,8 @@ struct EmplacementOnly(i64);

#[methods]
impl EmplacementOnly {
#[export]
fn answer(&self, _owner: &Reference) -> i64 {
#[method]
fn answer(&self) -> i64 {
self.0
}
}
Expand Down Expand Up @@ -237,8 +237,8 @@ impl WithoutInherit {
Self(54)
}

#[export]
fn answer(&self, _owner: &Reference) -> i64 {
#[method]
fn answer(&self) -> i64 {
self.0
}
}
Expand Down
8 changes: 4 additions & 4 deletions test/src/test_free_ub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ struct Bar(i64, Arc<AtomicUsize>);

#[methods]
impl Bar {
#[export]
fn free_is_not_ub(&mut self, owner: &Node) -> bool {
#[method]
fn free_is_not_ub(&mut self, #[base] owner: &Node) -> bool {
unsafe {
owner.assume_unique().free();
}
assert_eq!(42, self.0, "self should not point to garbage");
true
}

#[export]
fn set_script_is_not_ub(&mut self, owner: &Node) -> bool {
#[method]
fn set_script_is_not_ub(&mut self, #[base] owner: &Node) -> bool {
owner.set_script(Null::null());
assert_eq!(42, self.0, "self should not point to garbage");
true
Expand Down
4 changes: 2 additions & 2 deletions test/src/test_map_owned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ struct VecBuilder {

#[methods]
impl VecBuilder {
#[export]
fn append(mut self, _owner: TRef<Reference>, mut numbers: Vec<i32>) -> Instance<Self> {
#[method]
fn append(mut self, mut numbers: Vec<i32>) -> Instance<Self> {
self.v.append(&mut numbers);
Instance::emplace(Self { v: self.v }).into_shared()
}
Expand Down
8 changes: 4 additions & 4 deletions test/src/test_register.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ impl StaticallyNamed for RegisterProperty {

#[methods]
impl RegisterProperty {
#[export]
fn set_value(&mut self, _owner: TRef<Reference>, value: i64) {
#[method]
fn set_value(&mut self, value: i64) {
self.value = value;
}

#[export]
fn get_value(&self, _owner: TRef<Reference>) -> i64 {
#[method]
fn get_value(&self) -> i64 {
self.value
}
}
Expand Down
16 changes: 8 additions & 8 deletions test/src/test_variant_call_args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,23 @@ impl StaticallyNamed for VariantCallArgs {

#[methods]
impl VariantCallArgs {
#[export]
fn zero(&mut self, _owner: &Reference) -> i32 {
#[method]
fn zero(&mut self) -> i32 {
42
}

#[export]
fn one(&mut self, _owner: &Reference, a: i32) -> i32 {
#[method]
fn one(&mut self, a: i32) -> i32 {
a * 42
}

#[export]
fn two(&mut self, _owner: &Reference, a: i32, b: i32) -> i32 {
#[method]
fn two(&mut self, a: i32, b: i32) -> i32 {
a * 42 + b
}

#[export]
fn three(&mut self, _owner: &Reference, a: i32, b: i32, c: i32) -> i32 {
#[method]
fn three(&mut self, a: i32, b: i32, c: i32) -> i32 {
a * 42 + b * c
}
}
Expand Down

0 comments on commit 1bab81d

Please sign in to comment.