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

Commit 5a43565

Browse files
authored
Add permissive mode (#127)
1 parent def7cab commit 5a43565

18 files changed

Lines changed: 76 additions & 10 deletions

doc_classes/LuaAPI.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@
8989
</description>
9090
</method>
9191
</methods>
92+
<members>
93+
<member name="permissive" type="bool" setter="set_permissive" getter="get_permissive" default="false">
94+
Set weather an objects lua_fields method should be treated as a blacklist instead of a whitelist.
95+
</member>
96+
</members>
9297
<constants>
9398
<constant name="HOOK_MASK_CALL" value="1" enum="HookMask">
9499
Specifies on which events the hook will be called.

project/demo/HelloLua.gd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ func _lua_print(message: String):
77
return LuaError.new_error("test", LuaError.ERR_RUNTIME)
88

99
func _ready():
10+
# All builtin libraries are available to bind with. Use Debug, OS and IO at your own risk.
11+
lua.bind_libraries(["base", "table", "string"])
12+
1013
lua.push_variant("print", _lua_print)
1114
lua.push_variant("message", "Hello lua!")
1215

13-
# All builtin libraries are available to bind with. Use OS and IO at your own risk.
14-
lua.bind_libraries(["base", "table", "string"])
15-
1616
# Most methods return a LuaError in case of an error
1717
var err: LuaError = lua.do_string("""
1818
for i=1,10,1 do

project/testing/tests/LuaAPI.call_function.gd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ func _ready():
88
id = 9970
99

1010
lua = LuaAPI.new()
11+
lua.permissive = true
1112

1213
# testName and testDescription are for any needed context about the test.
1314
testName = "LuaAPI.call_function"

project/testing/tests/LuaAPI.expose_constructor.gd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ func _ready():
1212
id = 9950
1313

1414
lua = LuaAPI.new()
15+
lua.permissive = true
1516
var err = lua.expose_constructor("TestObj", TestObject)
1617
if err is LuaError:
1718
errors.append(err)

project/testing/tests/LuaAPI.expose_function.gd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ func _ready():
4040
id = 9940
4141

4242
lua = LuaAPI.new()
43+
lua.permissive = true
4344
lua.set_meta("isValid", true)
4445
var err = lua.push_variant("test1", LuaCallableExtra.with_tuple(testFuncTuple, 2))
4546
if err is LuaError:

project/testing/tests/LuaCoroutine.resume.gd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ func _ready():
99
id = 9500
1010

1111
lua = LuaAPI.new()
12+
lua.permissive = true
1213
co = lua.new_coroutine()
1314

1415
co.load_string("

project/testing/tests/LuaCoroutine.yield_await.gd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ func _ready():
1313
id = 9490
1414

1515
lua = LuaAPI.new()
16+
lua.permissive = true
1617
co = lua.new_coroutine()
1718
co.push_variant("test_yield_await", _test_yield_await)
1819

project/testing/tests/general.base_types.gd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ func _ready():
88
id = 9825
99

1010
lua = LuaAPI.new()
11+
lua.permissive = true
1112

1213
# testName and testDescription are for any needed context about the test.
1314
testName = "General.base_types"

project/testing/tests/general.object_metamethods.gd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ func _ready():
1616
id = 9850
1717

1818
lua = LuaAPI.new()
19+
lua.permissive = true
1920
lua.set_meta("isValid", true)
2021
testObj = TestObject.new()
2122
lua.push_variant("testObj", testObj)

project/testing/tests/general.object_push.gd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ func _ready():
1414

1515
testObj = TestObject.new()
1616
lua = LuaAPI.new()
17+
lua.permissive = true
1718
var err = lua.push_variant("testObj", testObj)
1819
if err is LuaError:
1920
errors.append(err)

0 commit comments

Comments
 (0)