diff --git a/modules/gdnative/nativescript/api_generator.cpp b/modules/gdnative/nativescript/api_generator.cpp index 7a8406380ca..b3aabda9218 100644 --- a/modules/gdnative/nativescript/api_generator.cpp +++ b/modules/gdnative/nativescript/api_generator.cpp @@ -139,6 +139,34 @@ static String get_type_name(const PropertyInfo &info) { return Variant::get_type_name(info.type); } +/* + * Some comparison helper functions we need + */ + +struct MethodInfoComparator { + StringName::AlphCompare compare; + bool operator()(const MethodInfo &p_a, const MethodInfo &p_b) const { + + return compare(p_a.name, p_b.name); + } +}; + +struct PropertyInfoComparator { + StringName::AlphCompare compare; + bool operator()(const PropertyInfo &p_a, const PropertyInfo &p_b) const { + + return compare(p_a.name, p_b.name); + } +}; + +struct ConstantAPIComparator { + NoCaseComparator compare; + bool operator()(const ConstantAPI &p_a, const ConstantAPI &p_b) const { + + return compare(p_a.constant_name, p_b.constant_name); + } +}; + /* * Reads the entire Godot API to a list */ @@ -148,6 +176,7 @@ List generate_c_api_classes() { List classes; ClassDB::get_class_list(&classes); + classes.sort_custom(); // Register global constants as a fake GlobalConstants singleton class { @@ -163,6 +192,7 @@ List generate_c_api_classes() { constant_api.constant_value = GlobalConstants::get_global_constant_value(i); global_constants_api.constants.push_back(constant_api); } + global_constants_api.constants.sort_custom(); api.push_back(global_constants_api); } @@ -194,6 +224,7 @@ List generate_c_api_classes() { { List constant; ClassDB::get_integer_constant_list(class_name, &constant, true); + constant.sort_custom(); for (List::Element *c = constant.front(); c != NULL; c = c->next()) { ConstantAPI constant_api; constant_api.constant_name = c->get(); @@ -207,6 +238,7 @@ List generate_c_api_classes() { { List signals_; ClassDB::get_signal_list(class_name, &signals_, true); + signals_.sort_custom(); for (int i = 0; i < signals_.size(); i++) { SignalAPI signal; @@ -246,6 +278,7 @@ List generate_c_api_classes() { { List properties; ClassDB::get_property_list(class_name, &properties, true); + properties.sort_custom(); for (List::Element *p = properties.front(); p != NULL; p = p->next()) { PropertyAPI property_api; @@ -273,6 +306,7 @@ List generate_c_api_classes() { { List methods; ClassDB::get_method_list(class_name, &methods, true); + methods.sort_custom(); for (List::Element *m = methods.front(); m != NULL; m = m->next()) { MethodAPI method_api;