Skip to content

Commit a91509a

Browse files
committed
Implement more LuaScriptLanguage methods
1 parent e64a96e commit a91509a

File tree

3 files changed

+23
-6
lines changed

3 files changed

+23
-6
lines changed

src/script-language/LuaScriptInstance.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2020
* SOFTWARE.
2121
*/
22+
#include <godot_cpp/classes/script.hpp>
23+
2224
#include "LuaScriptInstance.hpp"
2325

2426
#include "LuaScriptLanguage.hpp"

src/script-language/LuaScriptLanguage.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@
2222
#include "LuaScriptLanguage.hpp"
2323

2424
#include "LuaScript.hpp"
25+
#include "../LuaTable.hpp"
2526
#include "../LuaState.hpp"
26-
#include "godot_cpp/variant/dictionary.hpp"
2727

2828
#include <godot_cpp/classes/engine.hpp>
29+
#include <godot_cpp/variant/dictionary.hpp>
2930
#include <godot_cpp/variant/packed_string_array.hpp>
3031

3132
namespace luagdextension {
@@ -100,6 +101,11 @@ bool LuaScriptLanguage::_is_using_templates() {
100101
return false;
101102
}
102103

104+
Dictionary LuaScriptLanguage::_validate(const String &script, const String &path, bool validate_functions, bool validate_errors, bool validate_warnings, bool validate_safe_lines) const {
105+
// TODO
106+
return {};
107+
}
108+
103109
String LuaScriptLanguage::_validate_path(const String &path) const {
104110
return "";
105111
}
@@ -128,6 +134,12 @@ bool LuaScriptLanguage::_overrides_external_editor() {
128134
return false;
129135
}
130136

137+
void LuaScriptLanguage::_thread_enter() {
138+
}
139+
140+
void LuaScriptLanguage::_thread_exit() {
141+
}
142+
131143
PackedStringArray LuaScriptLanguage::_get_recognized_extensions() const {
132144
return godot::helpers::append_all(PackedStringArray(),
133145
"lua"
@@ -157,6 +169,10 @@ Dictionary LuaScriptLanguage::_get_global_class_name(const String &path) const {
157169
return Dictionary();
158170
}
159171

172+
bool LuaScriptLanguage::_handles_global_class_type(const String &type) const {
173+
return lua_state->get_globals()->get(type);
174+
}
175+
160176
LuaState *LuaScriptLanguage::get_lua_state() {
161177
return lua_state;
162178
}

src/script-language/LuaScriptLanguage.hpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#ifndef __LUA_SCRIPT_LANGUAGE_EXTENSION_HPP__
2323
#define __LUA_SCRIPT_LANGUAGE_EXTENSION_HPP__
2424

25-
#include <godot_cpp/classes/script.hpp>
2625
#include <godot_cpp/classes/script_language_extension.hpp>
2726

2827
using namespace godot;
@@ -46,7 +45,7 @@ class LuaScriptLanguage : public ScriptLanguageExtension {
4645
Ref<Script> _make_template(const String &_template, const String &class_name, const String &base_class_name) const override;
4746
/* TypedArray<Dictionary> _get_built_in_templates(const StringName &object) const override; */
4847
bool _is_using_templates() override;
49-
/* Dictionary _validate(const String &script, const String &path, bool validate_functions, bool validate_errors, bool validate_warnings, bool validate_safe_lines) const override; */
48+
Dictionary _validate(const String &script, const String &path, bool validate_functions, bool validate_errors, bool validate_warnings, bool validate_safe_lines) const override;
5049
String _validate_path(const String &path) const override;
5150
Object *_create_script() const override;
5251
bool _has_named_classes() const override;
@@ -63,8 +62,8 @@ class LuaScriptLanguage : public ScriptLanguageExtension {
6362
/* void _add_global_constant(const StringName &name, const Variant &value) override; */
6463
/* void _add_named_global_constant(const StringName &name, const Variant &value) override; */
6564
/* void _remove_named_global_constant(const StringName &name) override; */
66-
/* void _thread_enter() override; */
67-
/* void _thread_exit() override; */
65+
void _thread_enter() override;
66+
void _thread_exit() override;
6867
/* String _debug_get_error() const override; */
6968
/* int32_t _debug_get_stack_level_count() const override; */
7069
/* int32_t _debug_get_stack_level_line(int32_t level) const override; */
@@ -86,7 +85,7 @@ class LuaScriptLanguage : public ScriptLanguageExtension {
8685
/* int32_t _profiling_get_accumulated_data(ScriptLanguageExtensionProfilingInfo *info_array, int32_t info_max) override; */
8786
/* int32_t _profiling_get_frame_data(ScriptLanguageExtensionProfilingInfo *info_array, int32_t info_max) override; */
8887
void _frame() override;
89-
/* bool _handles_global_class_type(const String &type) const override; */
88+
bool _handles_global_class_type(const String &type) const override;
9089
Dictionary _get_global_class_name(const String &path) const override;
9190

9291
LuaState *get_lua_state();

0 commit comments

Comments
 (0)