Skip to content

Commit

Permalink
Godot 4.2 compatibility
Browse files Browse the repository at this point in the history
Renames call() to invoke_call() to avoid "The function signature doesn't match the parent" errors.

Since gdscript doesn't support function overloading, classes can no longer have a method named "call" because the Object class has one.
  • Loading branch information
Treer committed Jan 21, 2024
1 parent c879863 commit a7d9232
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 14 deletions.
4 changes: 2 additions & 2 deletions addons/quentincaffeino/array-utils/src/Collection.gd
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ func fill(value = null, startIndex = 0, length = null):
# @returns Collection
func map(callback):
for key in self:
self._collection[key] = callback.call([self._collection[key], key, self._collection])
self._collection[key] = callback.invoke_call([self._collection[key], key, self._collection])

self.first()
return self
Expand All @@ -214,7 +214,7 @@ func filter(callback = null):
var key = new_collection.get_keys()[i]
var value = new_collection.get(key)

call = callback.call([key, value, i, new_collection])
call = callback.invoke_call([key, value, i, new_collection])

if !call:
new_collection.remove_by_index(i)
Expand Down
10 changes: 5 additions & 5 deletions addons/quentincaffeino/callback/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ func _ready(): # void
var func_cb = CallbackBuilder.new(self).set_name("callable_function").build()
var funcref_cb = CallbackBuilder.new(funcref(self, "callable_function")).build()
print(prop_cb.call()) # Prints: Hello world!
print(prop_cb.invoke_call()) # Prints: Hello world!
print(func_cb.call(["Hello, sam!"])) # Prints: [Reference...]
print(prop_cb.call()) # Prints: Hello, sam!
print(func_cb.invoke_call(["Hello, sam!"])) # Prints: [Reference...]
print(prop_cb.invoke_call()) # Prints: Hello, sam!
print(funcref_cb.call(["Hello, peter!"])) # Prints: [Reference...]
print(prop_cb.call()) # Prints: Hello, peter!
print(funcref_cb.invoke_call(["Hello, peter!"])) # Prints: [Reference...]
print(prop_cb.invoke_call()) # Prints: Hello, peter!
```

## License
Expand Down
2 changes: 1 addition & 1 deletion addons/quentincaffeino/callback/src/AbstractCallback.gd
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func bind(argv = []):

# @param Variant[] argv
# @returns Variant
func call(argv = []):
func invoke_call(argv = []):
pass


Expand Down
2 changes: 1 addition & 1 deletion addons/quentincaffeino/callback/src/CallableCallback.gd
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func ensure():

# @param Variant[] argv
# @returns Variant
func call(argv = []):
func invoke_call(argv = []):
# Ensure callback target still exists
if !ensure():
print(errors["qc.callback.call.ensure_failed"] % [ self._target ])
Expand Down
3 changes: 1 addition & 2 deletions addons/quentincaffeino/callback/src/Callback.gd
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

extends "./AbstractCallback.gd"


Expand Down Expand Up @@ -40,7 +39,7 @@ func ensure():

# @param Variant[] argv
# @returns Variant
func call(argv = []):
func invoke_call(argv = []):
# Ensure callback target still exists
if !ensure():
print(errors["qc.callback.call.ensure_failed"] % [ self._target, self._name ])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void
### call

```gdscript
func call(argv: Variant[])
func invoke_call(argv: Variant[])
```

Variant
2 changes: 1 addition & 1 deletion addons/quentincaffeino/console/docs/generated/Callback.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ boolean
### call

```gdscript
func call(argv: Variant[])
func invoke_call(argv: Variant[])
```

Variant
2 changes: 1 addition & 1 deletion addons/quentincaffeino/console/src/Command/Command.gd
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func execute(inArgs = []):
i += 1

# Execute command
return self._target.call(args)
return self._target.invoke_call(args)


# @returns void
Expand Down

0 comments on commit a7d9232

Please sign in to comment.