Skip to content

Commit 70a27db

Browse files
committed
Add section for script exported properties
1 parent 9546650 commit 70a27db

File tree

3 files changed

+20
-22
lines changed

3 files changed

+20
-22
lines changed

src/jvm_wrapper/registration/kt_property.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ PropertyInfo KtPropertyInfo::toPropertyInfo() const {
3030
info.class_name = class_name;
3131
info.hint = hint;
3232
info.hint_string = hint_string;
33-
info.usage = usage;
33+
info.usage = usage | PropertyUsageFlags::PROPERTY_USAGE_SCRIPT_VARIABLE;
3434
return info;
3535
}
3636

src/script/jvm_script.cpp

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -173,15 +173,6 @@ void JvmScript::get_script_property_list(List<PropertyInfo>* p_list) const {
173173
if (is_valid()) { kotlin_class->get_property_list(p_list); }
174174
}
175175

176-
void JvmScript::get_script_exported_property_list(List<PropertyInfo>* p_list) const {
177-
List<PropertyInfo> all_properties;
178-
get_script_property_list(&all_properties);
179-
180-
for (const PropertyInfo& property_info : all_properties) {
181-
if (property_info.usage & PropertyUsageFlags::PROPERTY_USAGE_EDITOR) { p_list->push_back(property_info); }
182-
}
183-
}
184-
185176
void JvmScript::get_constants(HashMap<StringName, Variant> *p_constants) {}
186177

187178
void JvmScript::get_members(HashSet<StringName> *p_members){
@@ -203,13 +194,19 @@ const Variant JvmScript::get_rpc_config() const {
203194
}
204195

205196
#ifdef TOOLS_ENABLED
206-
Vector<DocData::ClassDoc> JvmScript::get_documentation() const {
207-
// TODO: Add ability to register documentation to Godot
208-
return {};
197+
198+
void JvmScript::get_script_exported_property_list(List<PropertyInfo>* p_list) const {
199+
List<PropertyInfo> all_properties;
200+
get_script_property_list(&all_properties);
201+
202+
p_list->push_back(get_class_category());
203+
for (const PropertyInfo& property_info : all_properties) {
204+
if (property_info.usage & PropertyUsageFlags::PROPERTY_USAGE_EDITOR) { p_list->push_back(property_info); }
205+
}
209206
}
210207

211-
PropertyInfo JvmScript::get_class_category() const {
212-
// TODO: Investigate what it's supposed to do.
208+
Vector<DocData::ClassDoc> JvmScript::get_documentation() const {
209+
// TODO: Add ability to register documentation to Godot
213210
return {};
214211
}
215212

@@ -219,19 +216,21 @@ String JvmScript::get_class_icon_path() const {
219216
}
220217

221218
StringName JvmScript::get_doc_class_name() const {
222-
// TODO: Add ability to register documentation to Godot
223-
return {};
219+
String class_name = get_global_name();
220+
if (class_name.is_empty()) {
221+
return get_path().get_file();
222+
}
223+
return class_name;
224224
}
225225

226226
PlaceHolderScriptInstance* JvmScript::placeholder_instance_create(Object* p_this) {
227227
PlaceHolderScriptInstance* placeholder {memnew(JvmPlaceHolderInstance(GdjLanguage::get_instance(), Ref<Script>(this), p_this))};
228228

229+
update_script_exports();// Update in case this method is called between the (re)loading and the delayed update_script_exports().
230+
229231
List<PropertyInfo> exported_properties;
230232
get_script_exported_property_list(&exported_properties);
231-
232-
update_script_exports();// Update in case this method is called between the (re)loading and the delayed update_script_exports().
233233
placeholder->update(exported_properties, exported_members_default_value_cache);
234-
235234
placeholders.insert(placeholder);
236235
return placeholder;
237236
}

src/script/jvm_script.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ class JvmScript : public Script {
4646
bool get_property_default_value(const StringName& p_property, Variant& r_value) const override;
4747
void get_script_method_list(List<MethodInfo>* p_list) const override;
4848
void get_script_property_list(List<PropertyInfo>* p_list) const override;
49-
void get_script_exported_property_list(List<PropertyInfo>* p_list) const;
5049
void get_constants(HashMap<StringName, Variant> *p_constants) override;
5150
void get_members(HashSet<StringName> *p_members) override;
5251
const Variant get_rpc_config() const override;
@@ -70,9 +69,9 @@ class JvmScript : public Script {
7069
PlaceHolderScriptInstance* placeholder_instance_create(Object* p_this) override;
7170
uint64_t get_last_time_source_modified();
7271
void set_last_time_source_modified(uint64_t p_time);
72+
void get_script_exported_property_list(List<PropertyInfo>* p_list) const;
7373

7474
Vector<DocData::ClassDoc> get_documentation() const override;
75-
PropertyInfo get_class_category() const override;
7675
String get_class_icon_path() const override;
7776
StringName get_doc_class_name() const override;
7877

0 commit comments

Comments
 (0)