Skip to content
This repository was archived by the owner on Dec 29, 2024. It is now read-only.

Commit 8de338b

Browse files
authored
Bump to godot 4.2-stable (#180)
* Needed changes for godot-cpp#1280 * Bump to godot 4.2-stable
1 parent a7c659a commit 8de338b

12 files changed

Lines changed: 68 additions & 129 deletions

File tree

.github/workflows/runner.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ on:
2424
- "project/demo/*"
2525

2626
env:
27-
GODOT_VERSION: 4.1.2
27+
GODOT_VERSION: 4.2
2828

2929
jobs:
3030
static-checks:
@@ -37,31 +37,31 @@ jobs:
3737
uses: ./.github/workflows/linux.yml
3838
with:
3939
fullbuild: ${{ github.event_name == 'workflow_dispatch' }}
40-
godot_version: 4.1.2
40+
godot_version: 4.2
4141

4242
macos-build:
4343
name: 🍎 macOS
4444
needs: static-checks
4545
uses: ./.github/workflows/macos-build.yml
4646
with:
4747
fullbuild: ${{ github.event_name == 'workflow_dispatch' }}
48-
godot_version: 4.1.2
48+
godot_version: 4.2
4949

5050
macos-package:
5151
name: 🍎 macOS Package
5252
needs: macos-build
5353
uses: ./.github/workflows/macos-package.yml
5454
with:
5555
fullbuild: ${{ github.event_name == 'workflow_dispatch' }}
56-
godot_version: 4.1.2
56+
godot_version: 4.2
5757

5858
android-build:
5959
name: 🤖 Android
6060
needs: static-checks
6161
uses: ./.github/workflows/android-build.yml
6262
with:
6363
fullbuild: ${{ github.event_name == 'workflow_dispatch' }}
64-
godot_version: 4.1.2
64+
godot_version: 4.2
6565

6666
android-package:
6767
name: 🤖 Android Package
@@ -75,7 +75,7 @@ jobs:
7575
uses: ./.github/workflows/ios-build.yml
7676
with:
7777
fullbuild: ${{ github.event_name == 'workflow_dispatch' }}
78-
godot_version: 4.1.2
78+
godot_version: 4.2
7979

8080
ios-package:
8181
name: 🍎 IOS Package
@@ -89,23 +89,23 @@ jobs:
8989
uses: ./.github/workflows/web.yml
9090
with:
9191
fullbuild: ${{ github.event_name == 'workflow_dispatch' }}
92-
godot_version: 4.1.2
92+
godot_version: 4.2
9393

9494
windows-build:
9595
name: 🎨 Windows
9696
needs: static-checks
9797
uses: ./.github/workflows/windows.yml
9898
with:
9999
fullbuild: ${{ github.event_name == 'workflow_dispatch' }}
100-
godot_version: 4.1.2
100+
godot_version: 4.2
101101

102102
gdextension-build:
103103
name: ⚙️ GDExtension
104104
needs: static-checks
105105
uses: ./.github/workflows/gdextension.yml
106106
with:
107107
fullbuild: ${{ github.event_name == 'workflow_dispatch' }}
108-
godot_version: 4.1.2
108+
godot_version: 4.2
109109

110110
module-unit-tests:
111111
name: ⚙️ Module Unit Tests
@@ -117,7 +117,7 @@ jobs:
117117
needs: gdextension-build
118118
uses: ./.github/workflows/gdextension-unit-tests.yml
119119
with:
120-
godot_version: 4.1.2
120+
godot_version: 4.2
121121

122122
template-version-file:
123123
name: 📝 Create template version file

.gitmodules

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@
1212
branch = c4b71b7b
1313
[submodule "external/godot-cpp"]
1414
path = external/godot-cpp
15-
url = https://github.com/Trey2k/godot-cpp
16-
branch = 4.0
15+
url = https://github.com/godotengine/godot-cpp.git
16+
branch = 4.2

doc_classes/LuaAPI.xml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,6 @@
6161
Calls a function inside current Lua state. This can be either a exposed function or a function defined with with Lua. You may want to check if the function actually exists with [code]function_exists(LuaFunctionName)[/code]. This function supports 1 return value from lua. It will be returned as a variant and if Lua returns no value it will be null. If an error occurs while calling this function, a LuaError object will be returned.
6262
</description>
6363
</method>
64-
<method name="call_function_ref">
65-
<return type="Variant" />
66-
<param index="0" name="Args" type="Array" />
67-
<param index="1" name="LuaFunctionRef" type="int" />
68-
<description>
69-
This method is used to create a Callable when pulling a lua function from the stack. It is not intended to be called directly.
70-
When returning a Callable, the function ref is bound to the Callable. You must only supply the arguments.
71-
</description>
72-
</method>
7364
<method name="pull_variant">
7465
<return type="Variant" />
7566
<param index="0" name="Name" type="String" />

external/godot-cpp

Submodule godot-cpp updated 61 files

project/addons/luaAPI/luaAPI.gdextension

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[configuration]
22
entry_symbol = "luaAPI_library_init"
3-
compatibility_minimum = 4.1
3+
compatibility_minimum = 4.2
44

55
[libraries]
66
linux.x86_64.debug = "bin/libluaapi.linux.template_debug.x86_64.so"

project/project.godot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ config_version=5
1212

1313
config/name="LuaAPI Test Project"
1414
run/main_scene="res://testing/run_tests.tscn"
15-
config/features=PackedStringArray("4.1", "Mobile")
15+
config/features=PackedStringArray("4.2", "Mobile")
1616

1717
[autoload]
1818

project/testing/tests/LuaAPI.call_function.gd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func _process(delta):
5454
errors.append(LuaError.new_error("testCallable is not Callable but is '%d'" % typeof(testCallable), LuaError.ERR_TYPE))
5555
return fail()
5656

57-
var cret = testCallable.call([5])
57+
var cret = testCallable.call(5)
5858
if cret is LuaError:
5959
errors.append(cret)
6060
return fail()

src/classes/luaAPI.cpp

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@ void LuaAPI::_bind_methods() {
3737
ClassDB::bind_method(D_METHOD("get_registry_value", "Name"), &LuaAPI::getRegistryValue);
3838
ClassDB::bind_method(D_METHOD("set_registry_value", "Name", "var"), &LuaAPI::setRegistryValue);
3939
ClassDB::bind_method(D_METHOD("call_function", "LuaFunctionName", "Args"), &LuaAPI::callFunction);
40-
#ifdef LAPI_GDEXTENSION
41-
ClassDB::bind_method(D_METHOD("call_function_ref", "Args", "LuaFunctionRef"), &LuaAPI::callFunctionRef);
42-
#endif
4340
ClassDB::bind_method(D_METHOD("function_exists", "LuaFunctionName"), &LuaAPI::luaFunctionExists);
4441

4542
ClassDB::bind_method(D_METHOD("new_coroutine"), &LuaAPI::newCoroutine);
@@ -137,33 +134,6 @@ Variant LuaAPI::callFunction(String functionName, Array args) {
137134
return state.callFunction(functionName, args);
138135
}
139136

140-
#ifdef LAPI_GDEXTENSION
141-
// Invokes the passed lua reference
142-
Variant LuaAPI::callFunctionRef(Array args, int funcRef) {
143-
lua_pushcfunction(lState, LuaState::luaErrorHandler);
144-
145-
// Getting the lua function via the reference stored in funcRef
146-
lua_rawgeti(lState, LUA_REGISTRYINDEX, funcRef);
147-
148-
// Push all the argument on to the stack
149-
for (int i = 0; i < args.size(); i++) {
150-
LuaState::pushVariant(lState, args[i]);
151-
}
152-
153-
Variant toReturn;
154-
// execute the function using a protected call.
155-
int ret = lua_pcall(lState, args.size(), 1, -2 - args.size());
156-
if (ret != LUA_OK) {
157-
toReturn = LuaState::handleError(lState, ret);
158-
} else {
159-
toReturn = LuaState::getVariant(lState, -1);
160-
}
161-
162-
lua_pop(lState, 1);
163-
return toReturn;
164-
}
165-
#endif
166-
167137
// Calls LuaState::pushGlobalVariant()
168138
Ref<LuaError> LuaAPI::pushGlobalVariant(String name, Variant var) {
169139
return state.pushGlobalVariant(name, var);

src/classes/luaAPI.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,6 @@ class LuaAPI : public RefCounted {
4848

4949
Variant pullVariant(String name);
5050
Variant callFunction(String functionName, Array args);
51-
#ifdef LAPI_GDEXTENSION
52-
Variant callFunctionRef(Array args, int funcRef);
53-
#endif
5451

5552
Variant getRegistryValue(String name);
5653

src/classes/luaCallable.cpp

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1-
#ifndef LAPI_GDEXTENSION
2-
31
#include "luaCallable.h"
42
#include "luaAPI.h"
53

4+
#ifndef LAPI_GDEXTENSION
65
#include "core/templates/hashfuncs.h"
6+
#else
7+
#include <gdextension_interface.h>
8+
#include <godot_cpp/templates/hashfuncs.hpp>
9+
#endif
710

811
// I used "GDScriptLambdaCallable" as a template for this
9-
LuaCallable::LuaCallable(Ref<LuaAPI> p_obj, int ref, lua_State *p_state) {
10-
obj = p_obj;
12+
LuaCallable::LuaCallable(Ref<LuaAPI> obj, int ref, lua_State *p_state) {
13+
objectID = obj->get_instance_id();
1114
funcRef = ref;
1215
state = p_state;
1316
h = (uint32_t)hash_djb2_one_64((uint64_t)this);
@@ -36,7 +39,7 @@ CallableCustom::CompareLessFunc LuaCallable::get_compare_less_func() const {
3639
}
3740

3841
ObjectID LuaCallable::get_object() const {
39-
return obj->get_instance_id();
42+
return objectID;
4043
}
4144

4245
String LuaCallable::get_as_text() const {
@@ -53,31 +56,20 @@ uint32_t LuaCallable::hash() const {
5356
return h;
5457
}
5558

56-
void LuaCallable::call(const Variant **p_arguments, int p_argcount, Variant &r_return_value, Callable::CallError &r_call_error) const {
59+
bool LuaCallable::is_valid() const {
60+
return ObjectDB::get_instance(objectID);
61+
}
62+
63+
void LuaCallable::call(const Variant **p_arguments, int p_argcount, Variant &r_return_value, LAPI_CALL_ERROR &r_call_error) const {
5764
lua_pushcfunction(state, LuaState::luaErrorHandler);
5865

5966
// Getting the lua function via the reference stored in funcRef
6067
lua_rawgeti(state, LUA_REGISTRYINDEX, funcRef);
6168

62-
// ------------------
63-
// This is a hack to match the API with the GDExtension Callable workaround
64-
if (p_argcount != 1 || p_arguments[0]->get_type() != Variant::Type::ARRAY) {
65-
r_return_value = LuaError::newError("LuaCallable arguments must be supplied with a Godot Array", LuaError::ERR_TYPE);
66-
return;
67-
}
68-
69-
Array args = p_arguments[0]->operator Array();
70-
for (int i = 0; i < args.size(); i++) {
71-
LuaState::pushVariant(state, args[i]);
72-
}
73-
74-
p_argcount = args.size();
75-
// ------------------
76-
7769
// Push all the argument on to the stack
78-
// for (int i = 0; i < p_argcount; i++) {
79-
// LuaState::pushVariant(state, *p_arguments[i]);
80-
// }
70+
for (int i = 0; i < p_argcount; i++) {
71+
LuaState::pushVariant(state, *p_arguments[i]);
72+
}
8173

8274
// execute the function using a protected call.
8375
int ret = lua_pcall(state, p_argcount, 1, -2 - p_argcount);
@@ -88,9 +80,14 @@ void LuaCallable::call(const Variant **p_arguments, int p_argcount, Variant &r_r
8880
}
8981

9082
lua_pop(state, 1);
83+
// TODO: Tie the error handling systems together?
84+
#ifndef LAPI_GDEXTENSION
85+
r_call_error.error = LAPI_CALL_ERROR::CALL_OK;
86+
#else
87+
r_call_error.error = GDExtensionCallErrorType::GDEXTENSION_CALL_OK;
88+
#endif
9189
}
9290

9391
int LuaCallable::getFuncRef() {
9492
return funcRef;
95-
}
96-
#endif
93+
}

0 commit comments

Comments
 (0)