diff --git a/cppwg/input/base_info.py b/cppwg/input/base_info.py index 87a3513..bf372dc 100644 --- a/cppwg/input/base_info.py +++ b/cppwg/input/base_info.py @@ -32,6 +32,8 @@ class BaseInfo: Any extra wrapper code for the feature. prefix_code : List[str] Any wrapper code that precedes the feature. + prefix_text : str, optional + Text to add at the top of all wrappers. custom_generator : str, optional A custom generator for the feature. excluded_methods : List[str] diff --git a/cppwg/parsers/package_info_parser.py b/cppwg/parsers/package_info_parser.py index 876d178..9f4c3af 100644 --- a/cppwg/parsers/package_info_parser.py +++ b/cppwg/parsers/package_info_parser.py @@ -128,6 +128,7 @@ def parse(self) -> PackageInfo: "excluded_variables": [], "custom_generator": None, "prefix_code": [], + "prefix_text": "", } # Get package config from the raw package info diff --git a/cppwg/writers/class_writer.py b/cppwg/writers/class_writer.py index 0999a29..cf9d22b 100644 --- a/cppwg/writers/class_writer.py +++ b/cppwg/writers/class_writer.py @@ -68,6 +68,10 @@ def add_hpp(self, class_py_name: str) -> None: class_py_name: str The Python name of the class e.g. Foo2_2 """ + # Add the top prefix text + self.hpp_string += self.class_info.module_info.package_info.prefix_text + "\n" + + # Add the header guard, includes and declarations class_hpp_dict = {"class_py_name": class_py_name} self.hpp_string += self.wrapper_templates["class_hpp_header"].format( @@ -85,6 +89,9 @@ def add_cpp_header(self, class_cpp_name: str, class_py_name: str) -> None: class_py_name : str The Python name of the class e.g. Foo2_2 """ + # Add the top prefix text + self.cpp_string += self.class_info.module_info.package_info.prefix_text + "\n" + # Add the includes for this class includes = "" diff --git a/cppwg/writers/module_writer.py b/cppwg/writers/module_writer.py index 65e2189..04ab447 100644 --- a/cppwg/writers/module_writer.py +++ b/cppwg/writers/module_writer.py @@ -26,8 +26,6 @@ class CppModuleWrapperWriter: String templates with placeholders for generating wrapper code wrapper_root : str The output directory for the generated wrapper code - package_license : str - The license to include in the generated wrapper code class_decls : List[pygccxml.declarations.class_t] A list of declarations of all classes to be wrapped in the module """ @@ -37,12 +35,10 @@ def __init__( module_info: "ModuleInfo", # noqa: F821 wrapper_templates: Dict[str, str], wrapper_root: str, - package_license: str = "", ): self.module_info: "ModuleInfo" = module_info # noqa: F821 self.wrapper_templates: Dict[str, str] = wrapper_templates self.wrapper_root: str = wrapper_root - self.package_license: str = package_license # For convenience, store a list of declarations of all # classes to be wrapped in the module @@ -69,8 +65,13 @@ def write_module_wrapper(self) -> None: } ``` """ + cpp_string = "" + + # Add the top prefix text + cpp_string += self.module_info.package_info.prefix_text + "\n" + # Add top level includes - cpp_string = "#include \n" + cpp_string += "#include \n" if self.module_info.package_info.common_include_file: cpp_string += f'#include "{CPPWG_HEADER_COLLECTION_FILENAME}"\n' diff --git a/examples/shapes/wrapper/geometry/Point2.cppwg.cpp b/examples/shapes/wrapper/geometry/Point2.cppwg.cpp index 6ca7333..8ac0ca9 100644 --- a/examples/shapes/wrapper/geometry/Point2.cppwg.cpp +++ b/examples/shapes/wrapper/geometry/Point2.cppwg.cpp @@ -1,3 +1,6 @@ +// This file is automatically generated by cppwg. +// Do not modify this file directly. + #include #include #include "wrapper_header_collection.hpp" diff --git a/examples/shapes/wrapper/geometry/Point2.cppwg.hpp b/examples/shapes/wrapper/geometry/Point2.cppwg.hpp index 0df78b5..376fb8f 100644 --- a/examples/shapes/wrapper/geometry/Point2.cppwg.hpp +++ b/examples/shapes/wrapper/geometry/Point2.cppwg.hpp @@ -1,3 +1,6 @@ +// This file is automatically generated by cppwg. +// Do not modify this file directly. + #ifndef Point2_hpp__cppwg_wrapper #define Point2_hpp__cppwg_wrapper diff --git a/examples/shapes/wrapper/geometry/Point3.cppwg.cpp b/examples/shapes/wrapper/geometry/Point3.cppwg.cpp index b489ecb..bf4dd42 100644 --- a/examples/shapes/wrapper/geometry/Point3.cppwg.cpp +++ b/examples/shapes/wrapper/geometry/Point3.cppwg.cpp @@ -1,3 +1,6 @@ +// This file is automatically generated by cppwg. +// Do not modify this file directly. + #include #include #include "wrapper_header_collection.hpp" diff --git a/examples/shapes/wrapper/geometry/Point3.cppwg.hpp b/examples/shapes/wrapper/geometry/Point3.cppwg.hpp index 769cfc5..630ecf2 100644 --- a/examples/shapes/wrapper/geometry/Point3.cppwg.hpp +++ b/examples/shapes/wrapper/geometry/Point3.cppwg.hpp @@ -1,3 +1,6 @@ +// This file is automatically generated by cppwg. +// Do not modify this file directly. + #ifndef Point3_hpp__cppwg_wrapper #define Point3_hpp__cppwg_wrapper diff --git a/examples/shapes/wrapper/geometry/geometry.main.cpp b/examples/shapes/wrapper/geometry/geometry.main.cpp index 3962804..b924795 100644 --- a/examples/shapes/wrapper/geometry/geometry.main.cpp +++ b/examples/shapes/wrapper/geometry/geometry.main.cpp @@ -1,3 +1,6 @@ +// This file is automatically generated by cppwg. +// Do not modify this file directly. + #include #include "wrapper_header_collection.hpp" #include "Point2.cppwg.hpp" diff --git a/examples/shapes/wrapper/math_funcs/math_funcs.main.cpp b/examples/shapes/wrapper/math_funcs/math_funcs.main.cpp index 093b493..ff93950 100644 --- a/examples/shapes/wrapper/math_funcs/math_funcs.main.cpp +++ b/examples/shapes/wrapper/math_funcs/math_funcs.main.cpp @@ -1,3 +1,6 @@ +// This file is automatically generated by cppwg. +// Do not modify this file directly. + #include #include "wrapper_header_collection.hpp" diff --git a/examples/shapes/wrapper/mesh/AbstractMesh2_2.cppwg.cpp b/examples/shapes/wrapper/mesh/AbstractMesh2_2.cppwg.cpp index cf6e523..ac95c23 100644 --- a/examples/shapes/wrapper/mesh/AbstractMesh2_2.cppwg.cpp +++ b/examples/shapes/wrapper/mesh/AbstractMesh2_2.cppwg.cpp @@ -1,3 +1,6 @@ +// This file is automatically generated by cppwg. +// Do not modify this file directly. + #include #include #include "wrapper_header_collection.hpp" diff --git a/examples/shapes/wrapper/mesh/AbstractMesh2_2.cppwg.hpp b/examples/shapes/wrapper/mesh/AbstractMesh2_2.cppwg.hpp index 9cef714..67fbb32 100644 --- a/examples/shapes/wrapper/mesh/AbstractMesh2_2.cppwg.hpp +++ b/examples/shapes/wrapper/mesh/AbstractMesh2_2.cppwg.hpp @@ -1,3 +1,6 @@ +// This file is automatically generated by cppwg. +// Do not modify this file directly. + #ifndef AbstractMesh2_2_hpp__cppwg_wrapper #define AbstractMesh2_2_hpp__cppwg_wrapper diff --git a/examples/shapes/wrapper/mesh/AbstractMesh3_3.cppwg.cpp b/examples/shapes/wrapper/mesh/AbstractMesh3_3.cppwg.cpp index c4e8c00..3f4c6f0 100644 --- a/examples/shapes/wrapper/mesh/AbstractMesh3_3.cppwg.cpp +++ b/examples/shapes/wrapper/mesh/AbstractMesh3_3.cppwg.cpp @@ -1,3 +1,6 @@ +// This file is automatically generated by cppwg. +// Do not modify this file directly. + #include #include #include "wrapper_header_collection.hpp" diff --git a/examples/shapes/wrapper/mesh/AbstractMesh3_3.cppwg.hpp b/examples/shapes/wrapper/mesh/AbstractMesh3_3.cppwg.hpp index a583113..8b4187e 100644 --- a/examples/shapes/wrapper/mesh/AbstractMesh3_3.cppwg.hpp +++ b/examples/shapes/wrapper/mesh/AbstractMesh3_3.cppwg.hpp @@ -1,3 +1,6 @@ +// This file is automatically generated by cppwg. +// Do not modify this file directly. + #ifndef AbstractMesh3_3_hpp__cppwg_wrapper #define AbstractMesh3_3_hpp__cppwg_wrapper diff --git a/examples/shapes/wrapper/mesh/ConcreteMesh2.cppwg.cpp b/examples/shapes/wrapper/mesh/ConcreteMesh2.cppwg.cpp index 9a33857..6529c4d 100644 --- a/examples/shapes/wrapper/mesh/ConcreteMesh2.cppwg.cpp +++ b/examples/shapes/wrapper/mesh/ConcreteMesh2.cppwg.cpp @@ -1,3 +1,6 @@ +// This file is automatically generated by cppwg. +// Do not modify this file directly. + #include #include #include "wrapper_header_collection.hpp" diff --git a/examples/shapes/wrapper/mesh/ConcreteMesh2.cppwg.hpp b/examples/shapes/wrapper/mesh/ConcreteMesh2.cppwg.hpp index 858dfeb..9d39f3b 100644 --- a/examples/shapes/wrapper/mesh/ConcreteMesh2.cppwg.hpp +++ b/examples/shapes/wrapper/mesh/ConcreteMesh2.cppwg.hpp @@ -1,3 +1,6 @@ +// This file is automatically generated by cppwg. +// Do not modify this file directly. + #ifndef ConcreteMesh2_hpp__cppwg_wrapper #define ConcreteMesh2_hpp__cppwg_wrapper diff --git a/examples/shapes/wrapper/mesh/ConcreteMesh3.cppwg.cpp b/examples/shapes/wrapper/mesh/ConcreteMesh3.cppwg.cpp index 817aac3..bed5dc4 100644 --- a/examples/shapes/wrapper/mesh/ConcreteMesh3.cppwg.cpp +++ b/examples/shapes/wrapper/mesh/ConcreteMesh3.cppwg.cpp @@ -1,3 +1,6 @@ +// This file is automatically generated by cppwg. +// Do not modify this file directly. + #include #include #include "wrapper_header_collection.hpp" diff --git a/examples/shapes/wrapper/mesh/ConcreteMesh3.cppwg.hpp b/examples/shapes/wrapper/mesh/ConcreteMesh3.cppwg.hpp index c2ba401..97f89c6 100644 --- a/examples/shapes/wrapper/mesh/ConcreteMesh3.cppwg.hpp +++ b/examples/shapes/wrapper/mesh/ConcreteMesh3.cppwg.hpp @@ -1,3 +1,6 @@ +// This file is automatically generated by cppwg. +// Do not modify this file directly. + #ifndef ConcreteMesh3_hpp__cppwg_wrapper #define ConcreteMesh3_hpp__cppwg_wrapper diff --git a/examples/shapes/wrapper/mesh/mesh.main.cpp b/examples/shapes/wrapper/mesh/mesh.main.cpp index bda9842..68facdd 100644 --- a/examples/shapes/wrapper/mesh/mesh.main.cpp +++ b/examples/shapes/wrapper/mesh/mesh.main.cpp @@ -1,3 +1,6 @@ +// This file is automatically generated by cppwg. +// Do not modify this file directly. + #include #include "wrapper_header_collection.hpp" #include "AbstractMesh2_2.cppwg.hpp" diff --git a/examples/shapes/wrapper/package_info.yaml b/examples/shapes/wrapper/package_info.yaml index e9d8cc9..460b47d 100644 --- a/examples/shapes/wrapper/package_info.yaml +++ b/examples/shapes/wrapper/package_info.yaml @@ -76,3 +76,8 @@ modules: classes: - name: AbstractMesh - name: ConcreteMesh + +# Text to add at the top of all wrappers +prefix_text: | + // This file is automatically generated by cppwg. + // Do not modify this file directly. diff --git a/examples/shapes/wrapper/primitives/Cuboid.cppwg.cpp b/examples/shapes/wrapper/primitives/Cuboid.cppwg.cpp index 1d65b55..1dc52a3 100644 --- a/examples/shapes/wrapper/primitives/Cuboid.cppwg.cpp +++ b/examples/shapes/wrapper/primitives/Cuboid.cppwg.cpp @@ -1,3 +1,6 @@ +// This file is automatically generated by cppwg. +// Do not modify this file directly. + #include #include #include "wrapper_header_collection.hpp" diff --git a/examples/shapes/wrapper/primitives/Cuboid.cppwg.hpp b/examples/shapes/wrapper/primitives/Cuboid.cppwg.hpp index 48c919f..f7dcedb 100644 --- a/examples/shapes/wrapper/primitives/Cuboid.cppwg.hpp +++ b/examples/shapes/wrapper/primitives/Cuboid.cppwg.hpp @@ -1,3 +1,6 @@ +// This file is automatically generated by cppwg. +// Do not modify this file directly. + #ifndef Cuboid_hpp__cppwg_wrapper #define Cuboid_hpp__cppwg_wrapper diff --git a/examples/shapes/wrapper/primitives/Rectangle.cppwg.cpp b/examples/shapes/wrapper/primitives/Rectangle.cppwg.cpp index 051c21d..ba9e4fc 100644 --- a/examples/shapes/wrapper/primitives/Rectangle.cppwg.cpp +++ b/examples/shapes/wrapper/primitives/Rectangle.cppwg.cpp @@ -1,3 +1,6 @@ +// This file is automatically generated by cppwg. +// Do not modify this file directly. + #include #include #include "wrapper_header_collection.hpp" diff --git a/examples/shapes/wrapper/primitives/Rectangle.cppwg.hpp b/examples/shapes/wrapper/primitives/Rectangle.cppwg.hpp index e063518..86b1c27 100644 --- a/examples/shapes/wrapper/primitives/Rectangle.cppwg.hpp +++ b/examples/shapes/wrapper/primitives/Rectangle.cppwg.hpp @@ -1,3 +1,6 @@ +// This file is automatically generated by cppwg. +// Do not modify this file directly. + #ifndef Rectangle_hpp__cppwg_wrapper #define Rectangle_hpp__cppwg_wrapper diff --git a/examples/shapes/wrapper/primitives/Shape2.cppwg.cpp b/examples/shapes/wrapper/primitives/Shape2.cppwg.cpp index 4bb1651..718530a 100644 --- a/examples/shapes/wrapper/primitives/Shape2.cppwg.cpp +++ b/examples/shapes/wrapper/primitives/Shape2.cppwg.cpp @@ -1,3 +1,6 @@ +// This file is automatically generated by cppwg. +// Do not modify this file directly. + #include #include #include "wrapper_header_collection.hpp" diff --git a/examples/shapes/wrapper/primitives/Shape2.cppwg.hpp b/examples/shapes/wrapper/primitives/Shape2.cppwg.hpp index 436f7ac..e25483f 100644 --- a/examples/shapes/wrapper/primitives/Shape2.cppwg.hpp +++ b/examples/shapes/wrapper/primitives/Shape2.cppwg.hpp @@ -1,3 +1,6 @@ +// This file is automatically generated by cppwg. +// Do not modify this file directly. + #ifndef Shape2_hpp__cppwg_wrapper #define Shape2_hpp__cppwg_wrapper diff --git a/examples/shapes/wrapper/primitives/Shape3.cppwg.cpp b/examples/shapes/wrapper/primitives/Shape3.cppwg.cpp index a43674f..3c86339 100644 --- a/examples/shapes/wrapper/primitives/Shape3.cppwg.cpp +++ b/examples/shapes/wrapper/primitives/Shape3.cppwg.cpp @@ -1,3 +1,6 @@ +// This file is automatically generated by cppwg. +// Do not modify this file directly. + #include #include #include "wrapper_header_collection.hpp" diff --git a/examples/shapes/wrapper/primitives/Shape3.cppwg.hpp b/examples/shapes/wrapper/primitives/Shape3.cppwg.hpp index eda2e80..bc8ea2f 100644 --- a/examples/shapes/wrapper/primitives/Shape3.cppwg.hpp +++ b/examples/shapes/wrapper/primitives/Shape3.cppwg.hpp @@ -1,3 +1,6 @@ +// This file is automatically generated by cppwg. +// Do not modify this file directly. + #ifndef Shape3_hpp__cppwg_wrapper #define Shape3_hpp__cppwg_wrapper diff --git a/examples/shapes/wrapper/primitives/primitives.main.cpp b/examples/shapes/wrapper/primitives/primitives.main.cpp index b109ca8..f90aac5 100644 --- a/examples/shapes/wrapper/primitives/primitives.main.cpp +++ b/examples/shapes/wrapper/primitives/primitives.main.cpp @@ -1,3 +1,6 @@ +// This file is automatically generated by cppwg. +// Do not modify this file directly. + #include #include "wrapper_header_collection.hpp" #include "Shape2.cppwg.hpp"