Skip to content

Commit bcbf978

Browse files
committed
Implement LuaScript::_get_script_property_list
1 parent 3f56420 commit bcbf978

File tree

4 files changed

+47
-2
lines changed

4 files changed

+47
-2
lines changed

src/script-language/LuaScript.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,11 @@ TypedArray<Dictionary> LuaScript::_get_script_method_list() const {
187187
}
188188

189189
TypedArray<Dictionary> LuaScript::_get_script_property_list() const {
190-
// TODO
191-
return {};
190+
TypedArray<Dictionary> list;
191+
for (auto [name, prop] : metadata.properties) {
192+
list.append(prop.to_dictionary());
193+
}
194+
return list;
192195
}
193196

194197
int32_t LuaScript::_get_member_line(const StringName &p_member) const {

src/script-language/LuaScriptMetadata.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ void LuaScriptMetadata::setup(const sol::table& t) {
7575
else {
7676
Variant var = to_variant(value);
7777
properties.insert(name, LuaScriptProperty {
78+
.name = name,
7879
.type = var.get_type(),
7980
.default_value = var,
8081
.getter = sol::nullopt,
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/**
2+
* Copyright (C) 2025 Gil Barbosa Reis.
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
5+
* this software and associated documentation files (the “Software”), to deal in
6+
* the Software without restriction, including without limitation the rights to
7+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
8+
* of the Software, and to permit persons to whom the Software is furnished to do
9+
* so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in all
12+
* copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
* SOFTWARE.
21+
*/
22+
23+
#include "LuaScriptProperty.hpp"
24+
25+
namespace luagdextension {
26+
27+
Dictionary LuaScriptProperty::to_dictionary() const {
28+
Dictionary d;
29+
d["name"] = name;
30+
// d["class_name"]
31+
d["type"] = int(type);
32+
// d["hint"]
33+
// d["hint_string"]
34+
// d["usage"]
35+
return d;
36+
}
37+
38+
}

src/script-language/LuaScriptProperty.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,14 @@ using namespace godot;
3131
namespace luagdextension {
3232

3333
struct LuaScriptProperty {
34+
StringName name;
3435
Variant::Type type;
3536
Variant default_value;
3637

3738
sol::optional<sol::protected_function> getter; // Variant getter(self)
3839
sol::optional<sol::protected_function> setter; // void setter(self, Variant value)
40+
41+
Dictionary to_dictionary() const;
3942
};
4043

4144
}

0 commit comments

Comments
 (0)