diff options
Diffstat (limited to 'modules/gdnative/nativescript/api_generator.cpp')
-rw-r--r-- | modules/gdnative/nativescript/api_generator.cpp | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/modules/gdnative/nativescript/api_generator.cpp b/modules/gdnative/nativescript/api_generator.cpp index 850871579b..62f2ec5024 100644 --- a/modules/gdnative/nativescript/api_generator.cpp +++ b/modules/gdnative/nativescript/api_generator.cpp @@ -41,12 +41,11 @@ // helper stuff static Error save_file(const String &p_path, const List<String> &p_content) { - FileAccessRef file = FileAccess::open(p_path, FileAccess::WRITE); ERR_FAIL_COND_V(!file, ERR_FILE_CANT_WRITE); - for (const List<String>::Element *e = p_content.front(); e != NULL; e = e->next()) { + for (const List<String>::Element *e = p_content.front(); e != nullptr; e = e->next()) { file->store_string(e->get()); } @@ -98,7 +97,7 @@ struct SignalAPI { struct EnumAPI { String name; - List<Pair<int, String> > values; + List<Pair<int, String>> values; }; struct ClassAPI { @@ -146,7 +145,6 @@ static String get_type_name(const PropertyInfo &info) { struct MethodInfoComparator { StringName::AlphCompare compare; bool operator()(const MethodInfo &p_a, const MethodInfo &p_b) const { - return compare(p_a.name, p_b.name); } }; @@ -154,7 +152,6 @@ struct MethodInfoComparator { struct PropertyInfoComparator { StringName::AlphCompare compare; bool operator()(const PropertyInfo &p_a, const PropertyInfo &p_b) const { - return compare(p_a.name, p_b.name); } }; @@ -162,7 +159,6 @@ struct PropertyInfoComparator { 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); } }; @@ -171,7 +167,6 @@ struct ConstantAPIComparator { * Reads the entire Godot API to a list */ List<ClassAPI> generate_c_api_classes() { - List<ClassAPI> api; List<StringName> classes; @@ -197,7 +192,7 @@ List<ClassAPI> generate_c_api_classes() { api.push_back(global_constants_api); } - for (List<StringName>::Element *e = classes.front(); e != NULL; e = e->next()) { + for (List<StringName>::Element *e = classes.front(); e != nullptr; e = e->next()) { StringName class_name = e->get(); ClassAPI class_api; @@ -229,7 +224,7 @@ List<ClassAPI> generate_c_api_classes() { List<String> constant; ClassDB::get_integer_constant_list(class_name, &constant, true); constant.sort_custom<NoCaseComparator>(); - for (List<String>::Element *c = constant.front(); c != NULL; c = c->next()) { + for (List<String>::Element *c = constant.front(); c != nullptr; c = c->next()) { ConstantAPI constant_api; constant_api.constant_name = c->get(); constant_api.constant_value = ClassDB::get_integer_constant(class_name, c->get()); @@ -284,7 +279,7 @@ List<ClassAPI> generate_c_api_classes() { ClassDB::get_property_list(class_name, &properties, true); properties.sort_custom<PropertyInfoComparator>(); - for (List<PropertyInfo>::Element *p = properties.front(); p != NULL; p = p->next()) { + for (List<PropertyInfo>::Element *p = properties.front(); p != nullptr; p = p->next()) { PropertyAPI property_api; property_api.name = p->get().name; @@ -312,7 +307,7 @@ List<ClassAPI> generate_c_api_classes() { ClassDB::get_method_list(class_name, &methods, true); methods.sort_custom<MethodInfoComparator>(); - for (List<MethodInfo>::Element *m = methods.front(); m != NULL; m = m->next()) { + for (List<MethodInfo>::Element *m = methods.front(); m != nullptr; m = m->next()) { MethodAPI method_api; MethodBind *method_bind = ClassDB::get_method(class_name, m->get().name); MethodInfo &method_info = m->get(); @@ -392,10 +387,10 @@ List<ClassAPI> generate_c_api_classes() { enum_api.name = E->get(); ClassDB::get_enum_constants(class_name, E->get(), &value_names, true); for (List<StringName>::Element *val_e = value_names.front(); val_e; val_e = val_e->next()) { - int int_val = ClassDB::get_integer_constant(class_name, val_e->get(), NULL); + int int_val = ClassDB::get_integer_constant(class_name, val_e->get(), nullptr); enum_api.values.push_back(Pair<int, String>(int_val, val_e->get())); } - enum_api.values.sort_custom<PairSort<int, String> >(); + enum_api.values.sort_custom<PairSort<int, String>>(); class_api.enums.push_back(enum_api); } } @@ -410,14 +405,13 @@ List<ClassAPI> generate_c_api_classes() { * Generates the JSON source from the API in p_api */ static List<String> generate_c_api_json(const List<ClassAPI> &p_api) { - // I'm sorry for the \t mess List<String> source; source.push_back("[\n"); - for (const List<ClassAPI>::Element *c = p_api.front(); c != NULL; c = c->next()) { + for (const List<ClassAPI>::Element *c = p_api.front(); c != nullptr; c = c->next()) { ClassAPI api = c->get(); source.push_back("\t{\n"); @@ -497,7 +491,7 @@ static List<String> generate_c_api_json(const List<ClassAPI> &p_api) { source.push_back("\t\t\t{\n"); source.push_back("\t\t\t\t\"name\": \"" + e->get().name + "\",\n"); source.push_back("\t\t\t\t\"values\": {\n"); - for (List<Pair<int, String> >::Element *val_e = e->get().values.front(); val_e; val_e = val_e->next()) { + for (List<Pair<int, String>>::Element *val_e = e->get().values.front(); val_e; val_e = val_e->next()) { source.push_back("\t\t\t\t\t\"" + val_e->get().second + "\": " + itos(val_e->get().first)); source.push_back(String((val_e->next() ? "," : "")) + "\n"); } @@ -520,7 +514,6 @@ static List<String> generate_c_api_json(const List<ClassAPI> &p_api) { * p_path */ Error generate_c_api(const String &p_path) { - #ifndef TOOLS_ENABLED return ERR_BUG; #else |