diff --git a/binding_generator.py b/binding_generator.py index 7a48fa8..9ac720b 100644 --- a/binding_generator.py +++ b/binding_generator.py @@ -11,6 +11,33 @@ def correct_method_name(method_list): if method["name"] == "get_node": method["name"] = "get_node_internal" +def class_name_to_file_name(class_name): + new_name = "" + + upper_count = 0 + upper_str = "" + for i in range(len(class_name)): + c = class_name[i] + + if c.isupper(): + upper_str += c + else: + if len(upper_str) > 0: + if len(new_name) > 0: + new_name += "_" + + new_name += upper_str.lower() + upper_str = "" + + new_name += c + + if len(upper_str) > 0: + if len(new_name) > 0: + new_name += "_" + + new_name += upper_str.lower() + + return new_name classes = [] @@ -23,8 +50,8 @@ def get_file_list(api_filepath, output_dir, headers=False, sources=False): include_gen_folder = Path(output_dir) / "include" / "gen" source_gen_folder = Path(output_dir) / "src" / "gen" for _class in classes: - header_filename = include_gen_folder / (strip_name(_class["name"]) + ".h") - source_filename = source_gen_folder / (strip_name(_class["name"]) + ".cpp") + header_filename = include_gen_folder / (class_name_to_file_name(strip_name(_class["name"])) + ".h") + source_filename = source_gen_folder / (class_name_to_file_name(strip_name(_class["name"])) + ".cpp") if headers: files.append(str(header_filename.as_posix())) if sources: @@ -79,11 +106,11 @@ def generate_bindings(api_filepath, use_template_get_node, output_dir="."): impl = generate_class_implementation(icalls, used_classes, c, use_template_get_node) - header_filename = include_gen_folder / (strip_name(c["name"]) + ".h") + header_filename = include_gen_folder / (class_name_to_file_name(strip_name(c["name"])) + ".h") with header_filename.open("w+") as header_file: header_file.write(header) - source_filename = source_gen_folder / (strip_name(c["name"]) + ".cpp") + source_filename = source_gen_folder / (class_name_to_file_name(strip_name(c["name"]) )+ ".cpp") with source_filename.open("w+") as source_file: source_file.write(impl) @@ -128,8 +155,8 @@ def make_gdnative_type(t, ref_allowed): def generate_class_header(used_classes, c, use_template_get_node): source = [] - source.append("#ifndef PANDEMONIUM_CPP_" + strip_name(c["name"]).upper() + "_HPP") - source.append("#define PANDEMONIUM_CPP_" + strip_name(c["name"]).upper() + "_HPP") + source.append("#ifndef PANDEMONIUM_CPP_" + strip_name(c["name"]).upper() + "_H") + source.append("#define PANDEMONIUM_CPP_" + strip_name(c["name"]).upper() + "_H") source.append("") source.append("") @@ -144,7 +171,7 @@ def generate_class_header(used_classes, c, use_template_get_node): # Ref is not included in object.h in Pandemonium either, # so don't include it here because it's not needed if class_name != "Object" and class_name != "Reference": - source.append("#include ") + source.append("#include ") ref_allowed = True else: source.append("#include ") @@ -157,17 +184,17 @@ def generate_class_header(used_classes, c, use_template_get_node): used_class_name = remove_enum_prefix(extract_nested_type(used_class)) if used_class_name not in included: included.append(used_class_name) - source.append('#include "' + used_class_name + '.h"') + source.append('#include "' + class_name_to_file_name(used_class_name) + '.h"') elif is_enum(used_class) and is_nested_type(used_class) and not is_nested_type(used_class, class_name): used_class_name = remove_enum_prefix(used_class) if used_class_name not in included: included.append(used_class_name) - source.append('#include "' + used_class_name + '.h"') + source.append('#include "' + class_name_to_file_name(used_class_name) + '.h"') source.append("") if c["base_class"] != "": - source.append('#include "' + strip_name(c["base_class"]) + '.h"') + source.append('#include "' + class_name_to_file_name(strip_name(c["base_class"])) + '.h"') source.append("namespace pandemonium {") source.append("") @@ -418,13 +445,13 @@ def generate_class_implementation(icalls, used_classes, c, use_template_get_node ref_allowed = class_name != "Object" and class_name != "Reference" source = [] - source.append('#include "' + class_name + '.h"') + source.append('#include "' + class_name_to_file_name(class_name) + '.h"') source.append("") source.append("") source.append("#include ") source.append("#include ") - source.append("#include ") + source.append("#include ") source.append("#include ") source.append("") @@ -437,7 +464,7 @@ def generate_class_implementation(icalls, used_classes, c, use_template_get_node if is_enum(used_class): continue else: - source.append('#include "' + strip_name(used_class) + '.h"') + source.append('#include "' + class_name_to_file_name(strip_name(used_class)) + '.h"') source.append("") source.append("") @@ -677,8 +704,8 @@ def generate_class_implementation(icalls, used_classes, c, use_template_get_node def generate_icall_header(icalls): source = [] - source.append("#ifndef PANDEMONIUM_CPP__ICALLS_HPP") - source.append("#define PANDEMONIUM_CPP__ICALLS_HPP") + source.append("#ifndef PANDEMONIUM_CPP__ICALLS_H") + source.append("#define PANDEMONIUM_CPP__ICALLS_H") source.append("") @@ -688,7 +715,7 @@ def generate_icall_header(icalls): source.append("#include ") source.append("#include ") - source.append('#include "Object.h"') + source.append('#include "object.h"') source.append("") source.append("") @@ -785,7 +812,7 @@ def generate_type_registry(classes): source.append("\n") for c in classes: - source.append("#include <" + strip_name(c["name"]) + ".h>") + source.append("#include <" + class_name_to_file_name(strip_name(c["name"])) + ".h>") source.append("") source.append("") @@ -828,7 +855,7 @@ def generate_init_method_bindings(classes): source = [] for c in classes: - source.append("#include <" + strip_name(c["name"]) + ".h>") + source.append("#include <" + class_name_to_file_name(strip_name(c["name"])) + ".h>") source.append("") source.append("") diff --git a/include/core/pandemonium.h b/include/core/pandemonium.h index d3c1d4f..fbd6be3 100644 --- a/include/core/pandemonium.h +++ b/include/core/pandemonium.h @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef PANDEMONIUM_HPP -#define PANDEMONIUM_HPP +#ifndef PANDEMONIUM_H +#define PANDEMONIUM_H #include #include @@ -43,7 +43,7 @@ #include "tag_db.h" #include "variant.h" -#include "Object.h" +#include "object.h" #include "pandemonium_global.h" @@ -616,4 +616,4 @@ T *Object::cast_to(const Object *obj) { } // namespace pandemonium -#endif // PANDEMONIUM_HPP +#endif // PANDEMONIUM_H diff --git a/include/core/pandemonium_global.h b/include/core/pandemonium_global.h index 913a176..a93bdd9 100644 --- a/include/core/pandemonium_global.h +++ b/include/core/pandemonium_global.h @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef PANDEMONIUM_GLOBAL_HPP -#define PANDEMONIUM_GLOBAL_HPP +#ifndef PANDEMONIUM_GLOBAL_H +#define PANDEMONIUM_GLOBAL_H #include diff --git a/include/core/pandemonium_profiling.h b/include/core/pandemonium_profiling.h index 0001171..219e5ce 100644 --- a/include/core/pandemonium_profiling.h +++ b/include/core/pandemonium_profiling.h @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef PANDEMONIUM_PROFILING_HPP -#define PANDEMONIUM_PROFILING_HPP +#ifndef PANDEMONIUM_PROFILING_H +#define PANDEMONIUM_PROFILING_H #include "defs.h" diff --git a/include/core/reference.h b/include/core/ref.h similarity index 99% rename from include/core/reference.h rename to include/core/ref.h index 1d7de27..fe03a26 100644 --- a/include/core/reference.h +++ b/include/core/ref.h @@ -32,7 +32,7 @@ #define REF_H #include "pandemonium_global.h" -#include "Reference.h" +#include "reference.h" #include "variant.h" namespace pandemonium { diff --git a/include/core/tag_db.h b/include/core/tag_db.h index 14042e2..d95778b 100644 --- a/include/core/tag_db.h +++ b/include/core/tag_db.h @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef TAGDB_HPP -#define TAGDB_HPP +#ifndef TAGDB_H +#define TAGDB_H #include @@ -46,4 +46,4 @@ bool is_type_compatible(size_t type_tag, size_t base_type_tag); } // namespace pandemonium -#endif // TAGDB_HPP +#endif // TAGDB_H diff --git a/include/core/vector3.h b/include/core/vector3.h index 8ae90d8..1dee0ef 100644 --- a/include/core/vector3.h +++ b/include/core/vector3.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* Vector3.h */ +/* vector3.h */ /*************************************************************************/ /* This file is part of: */ /* PANDEMONIUM ENGINE */ diff --git a/include/core/wrapped.h b/include/core/wrapped.h index f2e0e02..0313b26 100644 --- a/include/core/wrapped.h +++ b/include/core/wrapped.h @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef WRAPPED_HPP -#define WRAPPED_HPP +#ifndef WRAPPED_H +#define WRAPPED_H #include @@ -44,4 +44,4 @@ public: } // namespace pandemonium -#endif // WRAPPED_HPP +#endif // WRAPPED_H diff --git a/src/core/pandemonium_profiling.cpp b/src/core/pandemonium_profiling.cpp index 1dbe55c..f57bea5 100644 --- a/src/core/pandemonium_profiling.cpp +++ b/src/core/pandemonium_profiling.cpp @@ -1,7 +1,7 @@ #include "pandemonium_profiling.h" -#include "OS.h" +#include "os.h" #include diff --git a/src/core/variant.cpp b/src/core/variant.cpp index 31045ba..20c392e 100644 --- a/src/core/variant.cpp +++ b/src/core/variant.cpp @@ -35,7 +35,7 @@ #include "core_types.h" #include "defs.h" #include "pandemonium_global.h" -#include "Object.h" +#include "object.h" namespace pandemonium {