Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cppwg/input/base_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
1 change: 1 addition & 0 deletions cppwg/parsers/package_info_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions cppwg/writers/class_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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 = ""

Expand Down
11 changes: 6 additions & 5 deletions cppwg/writers/module_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""
Expand All @@ -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
Expand All @@ -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 <pybind11/pybind11.h>\n"
cpp_string += "#include <pybind11/pybind11.h>\n"

if self.module_info.package_info.common_include_file:
cpp_string += f'#include "{CPPWG_HEADER_COLLECTION_FILENAME}"\n'
Expand Down
3 changes: 3 additions & 0 deletions examples/shapes/wrapper/geometry/Point2.cppwg.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// This file is automatically generated by cppwg.
// Do not modify this file directly.

#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include "wrapper_header_collection.hpp"
Expand Down
3 changes: 3 additions & 0 deletions examples/shapes/wrapper/geometry/Point2.cppwg.hpp
Original file line number Diff line number Diff line change
@@ -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

Expand Down
3 changes: 3 additions & 0 deletions examples/shapes/wrapper/geometry/Point3.cppwg.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// This file is automatically generated by cppwg.
// Do not modify this file directly.

#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include "wrapper_header_collection.hpp"
Expand Down
3 changes: 3 additions & 0 deletions examples/shapes/wrapper/geometry/Point3.cppwg.hpp
Original file line number Diff line number Diff line change
@@ -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

Expand Down
3 changes: 3 additions & 0 deletions examples/shapes/wrapper/geometry/geometry.main.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// This file is automatically generated by cppwg.
// Do not modify this file directly.

#include <pybind11/pybind11.h>
#include "wrapper_header_collection.hpp"
#include "Point2.cppwg.hpp"
Expand Down
3 changes: 3 additions & 0 deletions examples/shapes/wrapper/math_funcs/math_funcs.main.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// This file is automatically generated by cppwg.
// Do not modify this file directly.

#include <pybind11/pybind11.h>
#include "wrapper_header_collection.hpp"

Expand Down
3 changes: 3 additions & 0 deletions examples/shapes/wrapper/mesh/AbstractMesh2_2.cppwg.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// This file is automatically generated by cppwg.
// Do not modify this file directly.

#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include "wrapper_header_collection.hpp"
Expand Down
3 changes: 3 additions & 0 deletions examples/shapes/wrapper/mesh/AbstractMesh2_2.cppwg.hpp
Original file line number Diff line number Diff line change
@@ -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

Expand Down
3 changes: 3 additions & 0 deletions examples/shapes/wrapper/mesh/AbstractMesh3_3.cppwg.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// This file is automatically generated by cppwg.
// Do not modify this file directly.

#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include "wrapper_header_collection.hpp"
Expand Down
3 changes: 3 additions & 0 deletions examples/shapes/wrapper/mesh/AbstractMesh3_3.cppwg.hpp
Original file line number Diff line number Diff line change
@@ -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

Expand Down
3 changes: 3 additions & 0 deletions examples/shapes/wrapper/mesh/ConcreteMesh2.cppwg.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// This file is automatically generated by cppwg.
// Do not modify this file directly.

#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include "wrapper_header_collection.hpp"
Expand Down
3 changes: 3 additions & 0 deletions examples/shapes/wrapper/mesh/ConcreteMesh2.cppwg.hpp
Original file line number Diff line number Diff line change
@@ -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

Expand Down
3 changes: 3 additions & 0 deletions examples/shapes/wrapper/mesh/ConcreteMesh3.cppwg.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// This file is automatically generated by cppwg.
// Do not modify this file directly.

#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include "wrapper_header_collection.hpp"
Expand Down
3 changes: 3 additions & 0 deletions examples/shapes/wrapper/mesh/ConcreteMesh3.cppwg.hpp
Original file line number Diff line number Diff line change
@@ -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

Expand Down
3 changes: 3 additions & 0 deletions examples/shapes/wrapper/mesh/mesh.main.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// This file is automatically generated by cppwg.
// Do not modify this file directly.

#include <pybind11/pybind11.h>
#include "wrapper_header_collection.hpp"
#include "AbstractMesh2_2.cppwg.hpp"
Expand Down
5 changes: 5 additions & 0 deletions examples/shapes/wrapper/package_info.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
3 changes: 3 additions & 0 deletions examples/shapes/wrapper/primitives/Cuboid.cppwg.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// This file is automatically generated by cppwg.
// Do not modify this file directly.

#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include "wrapper_header_collection.hpp"
Expand Down
3 changes: 3 additions & 0 deletions examples/shapes/wrapper/primitives/Cuboid.cppwg.hpp
Original file line number Diff line number Diff line change
@@ -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

Expand Down
3 changes: 3 additions & 0 deletions examples/shapes/wrapper/primitives/Rectangle.cppwg.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// This file is automatically generated by cppwg.
// Do not modify this file directly.

#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include "wrapper_header_collection.hpp"
Expand Down
3 changes: 3 additions & 0 deletions examples/shapes/wrapper/primitives/Rectangle.cppwg.hpp
Original file line number Diff line number Diff line change
@@ -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

Expand Down
3 changes: 3 additions & 0 deletions examples/shapes/wrapper/primitives/Shape2.cppwg.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// This file is automatically generated by cppwg.
// Do not modify this file directly.

#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include "wrapper_header_collection.hpp"
Expand Down
3 changes: 3 additions & 0 deletions examples/shapes/wrapper/primitives/Shape2.cppwg.hpp
Original file line number Diff line number Diff line change
@@ -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

Expand Down
3 changes: 3 additions & 0 deletions examples/shapes/wrapper/primitives/Shape3.cppwg.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// This file is automatically generated by cppwg.
// Do not modify this file directly.

#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include "wrapper_header_collection.hpp"
Expand Down
3 changes: 3 additions & 0 deletions examples/shapes/wrapper/primitives/Shape3.cppwg.hpp
Original file line number Diff line number Diff line change
@@ -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

Expand Down
3 changes: 3 additions & 0 deletions examples/shapes/wrapper/primitives/primitives.main.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// This file is automatically generated by cppwg.
// Do not modify this file directly.

#include <pybind11/pybind11.h>
#include "wrapper_header_collection.hpp"
#include "Shape2.cppwg.hpp"
Expand Down