Skip to content

Commit

Permalink
Reject a class which already has a Py2C converters
Browse files Browse the repository at this point in the history
- add back the any test with manual template spec for convertion
  to test the stl/any converter.
  • Loading branch information
parcollet committed Nov 14, 2024
1 parent f67266a commit 58800d2
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/plugins/c2py/matchers.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "./matchers.hpp"
#include "clang/Basic/SourceManager.h"
#include "clu/misc.hpp"
#include "clu/concept.hpp"
#include "utility/logger.hpp"
#include "utility/macros.hpp"
#include "clang/ASTMatchers/ASTMatchers.h"
Expand Down Expand Up @@ -199,6 +200,16 @@ template <> void matcher<mtch::Cls>::run(const clang::ast_matchers::MatchFinder:
// Reject classes defined in c2py_module
if (qname.starts_with("c2py_module::")) return;

// reject a class which already HAS a converter Py2C
// NB : if the class has already a C2py converter, it is overuled
// by the wrapping. It is necessary since all classes with iterator
// can have a default c2py converter as a generator
// which is superseded by the wrapping it is exists
if (clu::satisfy_concept(cls, worker->IsConvertiblePy2C, worker->ci)) {
logs.rejected(fmt::format(R"RAW({0} [{1}])RAW", qname, "Already has a converter"));
return;
}

// Insert in the module class list
str_t py_name = util::camel_case(cls->getNameAsString());
M.classes.emplace_back(py_name, cls_info_t{cls}); //
Expand Down

0 comments on commit 58800d2

Please sign in to comment.