Skip to content

Commit

Permalink
Store an extra vector of KtProperty in Tool mode to preserve declarat…
Browse files Browse the repository at this point in the history
…ion order. (#390)
  • Loading branch information
CedNaru authored Nov 25, 2022
1 parent 2cb7689 commit 70b3678
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/kt_class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ KtClass::~KtClass() {
for (auto& constructor : constructors) {
delete constructor;
}

#if TOOLS_ENABLED
property_list.clear();
#endif
}

KtObject* KtClass::create_instance(jni::Env& env, const Variant** p_args, int p_arg_count, Object* p_owner) {
Expand Down Expand Up @@ -104,6 +108,10 @@ void KtClass::fetch_properties(jni::Env& env) {
for (int i = 0; i < propertiesArray.length(env); i++) {
auto* ktProperty { new KtProperty(propertiesArray.get(env, i), ClassLoader::get_default_loader()) };
properties[ktProperty->get_name()] = ktProperty;
#if TOOLS_ENABLED
property_list.push_back(ktProperty);
#endif

#ifdef DEBUG_ENABLED
LOG_VERBOSE(vformat("Fetched property %s for class %s", ktProperty->get_name(), name));
#endif
Expand Down Expand Up @@ -145,7 +153,14 @@ void KtClass::get_method_list(List<MethodInfo>* p_list) {
}

void KtClass::get_property_list(List<PropertyInfo>* p_list) {
#if TOOLS_ENABLED
uint32_t size = property_list.size();
for (auto i = 0; i < size; i++) {
p_list->push_back(property_list[i]->get_member_info());
}
#else
get_member_list(p_list, properties);
#endif
}

void KtClass::get_signal_list(List<MethodInfo>* p_list) {
Expand Down
4 changes: 4 additions & 0 deletions src/kt_class.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ class KtClass : public JavaInstanceWrapper<KtClass> {
HashMap<StringName, KtSignalInfo*> signal_infos;
KtConstructor* constructors[MAX_CONSTRUCTOR_SIZE];

#if TOOLS_ENABLED
LocalVector<KtProperty*> property_list;
#endif

StringName get_name(jni::Env& env);

String get_registered_name(jni::Env& env);
Expand Down

0 comments on commit 70b3678

Please sign in to comment.