From de01b04e25bf0e1ec1b011906839fec477f25d7d Mon Sep 17 00:00:00 2001 From: Kwabena N Amponsah Date: Mon, 24 Jun 2024 17:03:16 +0000 Subject: [PATCH 1/4] #43 skip generating trampoline for excluded methods --- cppwg/writers/method_writer.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cppwg/writers/method_writer.py b/cppwg/writers/method_writer.py index 3d4d621..0395fb9 100644 --- a/cppwg/writers/method_writer.py +++ b/cppwg/writers/method_writer.py @@ -65,7 +65,7 @@ def exclude(self) -> bool: bool True if the method should be excluded, False otherwise """ - # Exclude private methods without over-rides + # Exclude private methods if self.method_decl.access_type == "private": return True @@ -220,8 +220,8 @@ def generate_virtual_override_wrapper(self) -> str: str The virtual override wrapper code. """ - # Skip private methods - if self.method_decl.access_type == "private": + # Skip excluded methods + if self.exclude(): return "" # Get list of arguments and types From 514b6d9a2fee9a0cddc5d095e16d53f27ccb9216 Mon Sep 17 00:00:00 2001 From: Kwabena N Amponsah Date: Mon, 24 Jun 2024 17:28:45 +0000 Subject: [PATCH 2/4] #43 process class exclusion list in class writer --- cppwg/writers/class_writer.py | 5 ----- cppwg/writers/method_writer.py | 6 ++++++ 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/cppwg/writers/class_writer.py b/cppwg/writers/class_writer.py index 0f1fbba..0999a29 100644 --- a/cppwg/writers/class_writer.py +++ b/cppwg/writers/class_writer.py @@ -336,11 +336,6 @@ def write(self, work_dir: str) -> None: for member_function in class_decl.member_functions( function=query, allow_empty=True ): - if self.class_info.excluded_methods: - # Skip excluded methods - if member_function.name in self.class_info.excluded_methods: - continue - method_writer = CppMethodWrapperWriter( self.class_info, idx, diff --git a/cppwg/writers/method_writer.py b/cppwg/writers/method_writer.py index 0395fb9..c62cb18 100644 --- a/cppwg/writers/method_writer.py +++ b/cppwg/writers/method_writer.py @@ -65,6 +65,12 @@ def exclude(self) -> bool: bool True if the method should be excluded, False otherwise """ + + # Skip methods marked for exclusion + if self.class_info.excluded_methods: + if self.method_decl.name in self.class_info.excluded_methods: + return True + # Exclude private methods if self.method_decl.access_type == "private": return True From b38e11aff40d4049c9032bd0856ac30b6b715749 Mon Sep 17 00:00:00 2001 From: Kwabena N Amponsah Date: Mon, 24 Jun 2024 17:36:26 +0000 Subject: [PATCH 3/4] #43 fix docstring --- cppwg/writers/method_writer.py | 1 - 1 file changed, 1 deletion(-) diff --git a/cppwg/writers/method_writer.py b/cppwg/writers/method_writer.py index c62cb18..6309c2b 100644 --- a/cppwg/writers/method_writer.py +++ b/cppwg/writers/method_writer.py @@ -65,7 +65,6 @@ def exclude(self) -> bool: bool True if the method should be excluded, False otherwise """ - # Skip methods marked for exclusion if self.class_info.excluded_methods: if self.method_decl.name in self.class_info.excluded_methods: From 8ecfce98b4c263ea3113286bd12092794085ce08 Mon Sep 17 00:00:00 2001 From: Kwabena N Amponsah Date: Mon, 24 Jun 2024 18:34:29 +0000 Subject: [PATCH 4/4] #5 fix template parameters with two or more args --- cppwg/input/info_helper.py | 3 ++- examples/shapes/src/mesh/AbstractMesh.cpp | 5 +++++ examples/shapes/src/mesh/AbstractMesh.hpp | 7 +++++++ examples/shapes/wrapper/mesh/AbstractMesh2_2.cppwg.cpp | 4 ++++ examples/shapes/wrapper/mesh/AbstractMesh3_3.cppwg.cpp | 4 ++++ 5 files changed, 22 insertions(+), 1 deletion(-) diff --git a/cppwg/input/info_helper.py b/cppwg/input/info_helper.py index b2883d8..4b4f387 100644 --- a/cppwg/input/info_helper.py +++ b/cppwg/input/info_helper.py @@ -139,7 +139,8 @@ def extract_templates_from_source(self, feature_info: BaseInfo) -> None: template_params = [] for tp in template_substitution["signature"].split(","): template_params.append( - tp.replace("<", "") + tp.strip() + .replace("<", "") .replace(">", "") .split(" ")[1] .split("=")[0] diff --git a/examples/shapes/src/mesh/AbstractMesh.cpp b/examples/shapes/src/mesh/AbstractMesh.cpp index d03d193..7f6ec65 100644 --- a/examples/shapes/src/mesh/AbstractMesh.cpp +++ b/examples/shapes/src/mesh/AbstractMesh.cpp @@ -22,5 +22,10 @@ void AbstractMesh::SetIndex(unsigned index) mIndex = index; } +template +void AbstractMesh::AddVertex(Point vertex) +{ +} + template class AbstractMesh<2, 2>; template class AbstractMesh<3, 3>; diff --git a/examples/shapes/src/mesh/AbstractMesh.hpp b/examples/shapes/src/mesh/AbstractMesh.hpp index 83cf7de..4ccbae6 100644 --- a/examples/shapes/src/mesh/AbstractMesh.hpp +++ b/examples/shapes/src/mesh/AbstractMesh.hpp @@ -1,6 +1,8 @@ #ifndef _ABSTRACT_MESH_HPP #define _ABSTRACT_MESH_HPP +#include "Point.hpp" + /** * A mesh in SPACE_DIM space with ELEMENT_DIM dimensional elements */ @@ -34,6 +36,11 @@ class AbstractMesh */ void SetIndex(unsigned index); + /** + * Add a vertex to the mesh + */ + void AddVertex(Point vertex); + /** * Scale the mesh by a factor */ diff --git a/examples/shapes/wrapper/mesh/AbstractMesh2_2.cppwg.cpp b/examples/shapes/wrapper/mesh/AbstractMesh2_2.cppwg.cpp index 8706232..cf6e523 100644 --- a/examples/shapes/wrapper/mesh/AbstractMesh2_2.cppwg.cpp +++ b/examples/shapes/wrapper/mesh/AbstractMesh2_2.cppwg.cpp @@ -31,6 +31,10 @@ py::class_)) &AbstractMesh2_2::AddVertex, + " " , py::arg("vertex") ) .def( "Scale", (void(AbstractMesh2_2::*)(double const)) &AbstractMesh2_2::Scale, diff --git a/examples/shapes/wrapper/mesh/AbstractMesh3_3.cppwg.cpp b/examples/shapes/wrapper/mesh/AbstractMesh3_3.cppwg.cpp index a5eea68..c4e8c00 100644 --- a/examples/shapes/wrapper/mesh/AbstractMesh3_3.cppwg.cpp +++ b/examples/shapes/wrapper/mesh/AbstractMesh3_3.cppwg.cpp @@ -31,6 +31,10 @@ py::class_)) &AbstractMesh3_3::AddVertex, + " " , py::arg("vertex") ) .def( "Scale", (void(AbstractMesh3_3::*)(double const)) &AbstractMesh3_3::Scale,