Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lyskov authored Mar 16, 2024
2 parents 1df59d4 + 45a7308 commit be50c7c
Show file tree
Hide file tree
Showing 44 changed files with 357 additions and 309 deletions.
19 changes: 16 additions & 3 deletions source/type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,11 @@ void request_bindings(clang::QualType const &qt, Context &context)
/// return standard string representation of a given type
std::string standard_name(clang::QualType const &qt)
{
//qt.dump();
//qt.getUnqualifiedType().dump();
//qt->getCanonicalTypeInternal().dump();
//qt.getTypePtr()->dump();
//outs() << qt->getTypeClassName() << '\n';

string r = qt.getAsString();

// if( r == "std::array::size_type" ) {
Expand All @@ -468,9 +472,18 @@ std::string standard_name(clang::QualType const &qt)
// }

// if( begins_with(r, "std::") ) return r; //standard_name(r);
static std::set<string> standard_names {"std::size_t"};

if( standard_names.count(r) ) return r;
// static std::set<string> standard_names {"std::size_t"};
// if( standard_names.count(r) ) return r;
// else return standard_name(qt.getCanonicalType().getAsString());


// static std::set<string> standard_names {"std::size_t"};
// if( standard_names.count(r) ) return r;
// else return standard_name(qt.getCanonicalType().getAsString());

static std::set<string> standard_names_to_ignore {"std::size_t", }; // "std::array::size_type",
if( standard_names_to_ignore.count(r) ) return r;
else return standard_name(qt.getCanonicalType().getAsString());
}

Expand Down
36 changes: 18 additions & 18 deletions test/T00.basic.ref.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,52 +19,52 @@

void bind_T00_basic(std::function< pybind11::module &(std::string const &namespace_) > &M)
{
// foo() file:T00.basic.hpp line:25
// foo() file:T00.basic.hpp line:
M("").def("foo", (void (*)()) &foo, "C++: foo() --> void");

// foo_char(char) file:T00.basic.hpp line:29
// foo_char(char) file:T00.basic.hpp line:
M("").def("foo_char", (int (*)(char)) &foo_char, "C++: foo_char(char) --> int", pybind11::arg(""));

// foo_char(char &) file:T00.basic.hpp line:33
// foo_char(char &) file:T00.basic.hpp line:
M("").def("foo_char", (int (*)(char &)) &foo_char, "C++: foo_char(char &) --> int", pybind11::arg(""));

// foo_char(char *) file:T00.basic.hpp line:37
// foo_char(char *) file:T00.basic.hpp line:
M("").def("foo_char", (int (*)(char *)) &foo_char, "C++: foo_char(char *) --> int", pybind11::arg(""));

// foo_int(int) file:T00.basic.hpp line:42
// foo_int(int) file:T00.basic.hpp line:
M("").def("foo_int", (int (*)(int)) &foo_int, "C++: foo_int(int) --> int", pybind11::arg(""));

// foo_int(int &) file:T00.basic.hpp line:46
// foo_int(int &) file:T00.basic.hpp line:
M("").def("foo_int", (int (*)(int &)) &foo_int, "C++: foo_int(int &) --> int", pybind11::arg(""));

// foo_int(int *) file:T00.basic.hpp line:50
// foo_int(int *) file:T00.basic.hpp line:
M("").def("foo_int", (int (*)(int *)) &foo_int, "C++: foo_int(int *) --> int", pybind11::arg(""));

// foo_float(float) file:T00.basic.hpp line:55
// foo_float(float) file:T00.basic.hpp line:
M("").def("foo_float", (float (*)(float)) &foo_float, "C++: foo_float(float) --> float", pybind11::arg(""));

// foo_float(float &) file:T00.basic.hpp line:59
// foo_float(float &) file:T00.basic.hpp line:
M("").def("foo_float", (float (*)(float &)) &foo_float, "C++: foo_float(float &) --> float", pybind11::arg(""));

// foo_float(float *) file:T00.basic.hpp line:63
// foo_float(float *) file:T00.basic.hpp line:
M("").def("foo_float", (float (*)(float *)) &foo_float, "C++: foo_float(float *) --> float", pybind11::arg(""));

// foo_double(double) file:T00.basic.hpp line:68
// foo_double(double) file:T00.basic.hpp line:
M("").def("foo_double", (double (*)(double)) &foo_double, "C++: foo_double(double) --> double", pybind11::arg(""));

// foo_double(double &) file:T00.basic.hpp line:72
// foo_double(double &) file:T00.basic.hpp line:
M("").def("foo_double", (double (*)(double &)) &foo_double, "C++: foo_double(double &) --> double", pybind11::arg(""));

// foo_double(double *) file:T00.basic.hpp line:76
// foo_double(double *) file:T00.basic.hpp line:
M("").def("foo_double", (double (*)(double *)) &foo_double, "C++: foo_double(double *) --> double", pybind11::arg(""));

// foo_void_p(void *) file:T00.basic.hpp line:83
// foo_void_p(void *) file:T00.basic.hpp line:
M("").def("foo_void_p", (void * (*)(void *)) &foo_void_p, "C++: foo_void_p(void *) --> void *", pybind11::return_value_policy::automatic, pybind11::arg(""));

// foo_void_p(void *const &) file:T00.basic.hpp line:87
// foo_void_p(void *const &) file:T00.basic.hpp line:
M("").def("foo_void_p", (void * (*)(void *const &)) &foo_void_p, "C++: foo_void_p(void *const &) --> void *", pybind11::return_value_policy::automatic, pybind11::arg(""));

// foo_void_p(void *&) file:T00.basic.hpp line:91
// foo_void_p(void *&) file:T00.basic.hpp line:
M("").def("foo_void_p", (void * (*)(void *&)) &foo_void_p, "C++: foo_void_p(void *&) --> void *", pybind11::return_value_policy::automatic, pybind11::arg(""));

}
Expand All @@ -86,7 +86,7 @@ void bind_T00_basic(std::function< pybind11::module &(std::string const &namespa

void bind_T00_basic_1(std::function< pybind11::module &(std::string const &namespace_) > &M)
{
// global::foo() file:T00.basic.hpp line:97
// global::foo() file:T00.basic.hpp line:
M("global").def("foo", (void (*)()) &global::foo, "C++: global::foo() --> void");

}
Expand All @@ -108,7 +108,7 @@ void bind_T00_basic_1(std::function< pybind11::module &(std::string const &names

void bind_T00_basic_2(std::function< pybind11::module &(std::string const &namespace_) > &M)
{
// nonlocal::foo() file:T00.basic.hpp line:102
// nonlocal::foo() file:T00.basic.hpp line:
M("nonlocal").def("foo", (void (*)()) &nonlocal::foo, "C++: nonlocal::foo() --> void");

}
Expand Down
2 changes: 2 additions & 0 deletions test/T01.enum.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
-namespace aaaa

-enum E4_not_binded

-enum E6_class_not_binded
+enum aaaa::E7_class

Expand Down
1 change: 1 addition & 0 deletions test/T01.enum.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ enum E1 { E1_V0, E1_V1 };
enum struct E2_struct { V0, V1 };
enum class E3_class { V0, V1 };

enum E4_not_binded { E4_V0, E4_V1 };

class A
{
Expand Down
10 changes: 5 additions & 5 deletions test/T01.enum.ref.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,30 @@

void bind_T01_enum(std::function< pybind11::module &(std::string const &namespace_) > &M)
{
// E1 file:T01.enum.hpp line:16
// E1 file:T01.enum.hpp line:
pybind11::enum_<E1>(M(""), "E1", pybind11::arithmetic(), "")
.value("E1_V0", E1_V0)
.value("E1_V1", E1_V1)
.export_values();

;

// E2_struct file:T01.enum.hpp line:18
// E2_struct file:T01.enum.hpp line:
pybind11::enum_<E2_struct>(M(""), "E2_struct", "")
.value("V0", E2_struct::V0)
.value("V1", E2_struct::V1)
.export_values();

;

// E3_class file:T01.enum.hpp line:19
// E3_class file:T01.enum.hpp line:
pybind11::enum_<E3_class>(M(""), "E3_class", "")
.value("V0", E3_class::V0)
.value("V1", E3_class::V1);

;

{ // A file:T01.enum.hpp line:22
{ // A file:T01.enum.hpp line:
pybind11::class_<A, std::shared_ptr<A>> cl(M(""), "A", "");
cl.def( pybind11::init( [](){ return new A(); } ) );

Expand Down Expand Up @@ -82,7 +82,7 @@ void bind_T01_enum(std::function< pybind11::module &(std::string const &namespac

void bind_T01_enum_1(std::function< pybind11::module &(std::string const &namespace_) > &M)
{
// aaaa::E7_class file:T01.enum.hpp line:46
// aaaa::E7_class file:T01.enum.hpp line:
pybind11::enum_<aaaa::E7_class>(M("aaaa"), "E7_class", "")
.value("V0", aaaa::E7_class::V0)
.value("V1", aaaa::E7_class::V1);
Expand Down
76 changes: 38 additions & 38 deletions test/T02.function.ref.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,119 +29,119 @@

void bind_T02_function(std::function< pybind11::module &(std::string const &namespace_) > &M)
{
{ // A file:T02.function.hpp line:20
{ // A file:T02.function.hpp line:
pybind11::class_<A, std::shared_ptr<A>> cl(M(""), "A", "");
cl.def( pybind11::init( [](){ return new A(); } ) );
}
// foo(bool) file:T02.function.hpp line:24
// foo(bool) file:T02.function.hpp line:
M("").def("foo", (void (*)(bool)) &foo, "C++: foo(bool) --> void", pybind11::arg(""));

// foo(int) file:T02.function.hpp line:27
// foo(int) file:T02.function.hpp line:
M("").def("foo", (void (*)(int)) &foo, "C++: foo(int) --> void", pybind11::arg(""));

// foo(long) file:T02.function.hpp line:30
// foo(long) file:T02.function.hpp line:
M("").def("foo", (void (*)(long)) &foo, "C++: foo(long) --> void", pybind11::arg(""));

// foo(float) file:T02.function.hpp line:33
// foo(float) file:T02.function.hpp line:
M("").def("foo", (void (*)(float)) &foo, "C++: foo(float) --> void", pybind11::arg(""));

// foo(double) file:T02.function.hpp line:36
// foo(double) file:T02.function.hpp line:
M("").def("foo", (void (*)(double)) &foo, "C++: foo(double) --> void", pybind11::arg(""));

// foo(class A) file:T02.function.hpp line:39
// foo(class A) file:T02.function.hpp line:
M("").def("foo", (void (*)(class A)) &foo, "C++: foo(class A) --> void", pybind11::arg(""));

// foo(class std::shared_ptr<class A>) file:T02.function.hpp line:42
// foo(class std::shared_ptr<class A>) file:T02.function.hpp line:
M("").def("foo", (void (*)(class std::shared_ptr<class A>)) &foo, "C++: foo(class std::shared_ptr<class A>) --> void", pybind11::arg(""));

// foo_r(bool &) file:T02.function.hpp line:46
// foo_r(bool &) file:T02.function.hpp line:
M("").def("foo_r", (void (*)(bool &)) &foo_r, "C++: foo_r(bool &) --> void", pybind11::arg(""));

// foo_r(int &) file:T02.function.hpp line:49
// foo_r(int &) file:T02.function.hpp line:
M("").def("foo_r", (void (*)(int &)) &foo_r, "C++: foo_r(int &) --> void", pybind11::arg(""));

// foo_r(long &) file:T02.function.hpp line:52
// foo_r(long &) file:T02.function.hpp line:
M("").def("foo_r", (void (*)(long &)) &foo_r, "C++: foo_r(long &) --> void", pybind11::arg(""));

// foo_r(float &) file:T02.function.hpp line:55
// foo_r(float &) file:T02.function.hpp line:
M("").def("foo_r", (void (*)(float &)) &foo_r, "C++: foo_r(float &) --> void", pybind11::arg(""));

// foo_r(double &) file:T02.function.hpp line:58
// foo_r(double &) file:T02.function.hpp line:
M("").def("foo_r", (void (*)(double &)) &foo_r, "C++: foo_r(double &) --> void", pybind11::arg(""));

// foo_r(class A &) file:T02.function.hpp line:61
// foo_r(class A &) file:T02.function.hpp line:
M("").def("foo_r", (void (*)(class A &)) &foo_r, "C++: foo_r(class A &) --> void", pybind11::arg(""));

// foo_r(class std::shared_ptr<class A> &) file:T02.function.hpp line:64
// foo_r(class std::shared_ptr<class A> &) file:T02.function.hpp line:
M("").def("foo_r", (void (*)(class std::shared_ptr<class A> &)) &foo_r, "C++: foo_r(class std::shared_ptr<class A> &) --> void", pybind11::arg(""));

// foo_cr(const bool &) file:T02.function.hpp line:74
// foo_cr(const bool &) file:T02.function.hpp line:
M("").def("foo_cr", (void (*)(const bool &)) &foo_cr, "C++: foo_cr(const bool &) --> void", pybind11::arg(""));

// foo_cr(const int &) file:T02.function.hpp line:77
// foo_cr(const int &) file:T02.function.hpp line:
M("").def("foo_cr", (void (*)(const int &)) &foo_cr, "C++: foo_cr(const int &) --> void", pybind11::arg(""));

// foo_cr(const long &) file:T02.function.hpp line:80
// foo_cr(const long &) file:T02.function.hpp line:
M("").def("foo_cr", (void (*)(const long &)) &foo_cr, "C++: foo_cr(const long &) --> void", pybind11::arg(""));

// foo_cr(const float &) file:T02.function.hpp line:83
// foo_cr(const float &) file:T02.function.hpp line:
M("").def("foo_cr", (void (*)(const float &)) &foo_cr, "C++: foo_cr(const float &) --> void", pybind11::arg(""));

// foo_cr(const double &) file:T02.function.hpp line:86
// foo_cr(const double &) file:T02.function.hpp line:
M("").def("foo_cr", (void (*)(const double &)) &foo_cr, "C++: foo_cr(const double &) --> void", pybind11::arg(""));

// foo_cr(const class A &) file:T02.function.hpp line:89
// foo_cr(const class A &) file:T02.function.hpp line:
M("").def("foo_cr", (void (*)(const class A &)) &foo_cr, "C++: foo_cr(const class A &) --> void", pybind11::arg(""));

// foo_cr(const class std::shared_ptr<class A> &) file:T02.function.hpp line:92
// foo_cr(const class std::shared_ptr<class A> &) file:T02.function.hpp line:
M("").def("foo_cr", (void (*)(const class std::shared_ptr<class A> &)) &foo_cr, "C++: foo_cr(const class std::shared_ptr<class A> &) --> void", pybind11::arg(""));

// foo_cr(const class std::shared_ptr<const class A> &) file:T02.function.hpp line:95
// foo_cr(const class std::shared_ptr<const class A> &) file:T02.function.hpp line:
M("").def("foo_cr", (void (*)(const class std::shared_ptr<const class A> &)) &foo_cr, "C++: foo_cr(const class std::shared_ptr<const class A> &) --> void", pybind11::arg(""));

// foo_cr(const struct std::pair<int, int> &) file:T02.function.hpp line:98
// foo_cr(const struct std::pair<int, int> &) file:T02.function.hpp line:
M("").def("foo_cr", (void (*)(const struct std::pair<int, int> &)) &foo_cr, "C++: foo_cr(const struct std::pair<int, int> &) --> void", pybind11::arg(""));

// foo_cr(const class std::tuple<int, int> &) file:T02.function.hpp line:101
// foo_cr(const class std::tuple<int, int> &) file:T02.function.hpp line:
M("").def("foo_cr", (void (*)(const class std::tuple<int, int> &)) &foo_cr, "C++: foo_cr(const class std::tuple<int, int> &) --> void", pybind11::arg(""));

// foo_p(bool *) file:T02.function.hpp line:105
// foo_p(bool *) file:T02.function.hpp line:
M("").def("foo_p", (void (*)(bool *)) &foo_p, "C++: foo_p(bool *) --> void", pybind11::arg(""));

// foo_p(int *) file:T02.function.hpp line:108
// foo_p(int *) file:T02.function.hpp line:
M("").def("foo_p", (void (*)(int *)) &foo_p, "C++: foo_p(int *) --> void", pybind11::arg(""));

// foo_p(long *) file:T02.function.hpp line:111
// foo_p(long *) file:T02.function.hpp line:
M("").def("foo_p", (void (*)(long *)) &foo_p, "C++: foo_p(long *) --> void", pybind11::arg(""));

// foo_p(float *) file:T02.function.hpp line:114
// foo_p(float *) file:T02.function.hpp line:
M("").def("foo_p", (void (*)(float *)) &foo_p, "C++: foo_p(float *) --> void", pybind11::arg(""));

// foo_p(double *) file:T02.function.hpp line:117
// foo_p(double *) file:T02.function.hpp line:
M("").def("foo_p", (void (*)(double *)) &foo_p, "C++: foo_p(double *) --> void", pybind11::arg(""));

// foo_p(class A *) file:T02.function.hpp line:120
// foo_p(class A *) file:T02.function.hpp line:
M("").def("foo_p", (void (*)(class A *)) &foo_p, "C++: foo_p(class A *) --> void", pybind11::arg(""));

// foo_p(class std::shared_ptr<class A> *) file:T02.function.hpp line:123
// foo_p(class std::shared_ptr<class A> *) file:T02.function.hpp line:
M("").def("foo_p", (void (*)(class std::shared_ptr<class A> *)) &foo_p, "C++: foo_p(class std::shared_ptr<class A> *) --> void", pybind11::arg(""));

// foo_f1(const class std::function<bool (const std::string &)> &) file:T02.function.hpp line:144
// foo_f1(const class std::function<bool (const std::string &)> &) file:T02.function.hpp line:
M("").def("foo_f1", (void (*)(const class std::function<bool (const std::string &)> &)) &foo_f1, "C++: foo_f1(const class std::function<bool (const std::string &)> &) --> void", pybind11::arg("f"));

// foo_f2(const class std::function<void (*(void))(void)> &) file:T02.function.hpp line:147
// foo_f2(const class std::function<void (*(void))(void)> &) file:T02.function.hpp line:
M("").def("foo_f2", (void (*)(const class std::function<void (*(void))(void)> &)) &foo_f2, "C++: foo_f2(const class std::function<void (*(void))(void)> &) --> void", pybind11::arg("f"));

// foo_f3(const class std::function<bool (void (**)(void), int (&)[1])> &) file:T02.function.hpp line:150
// foo_f3(const class std::function<bool (void (**)(void), int (&)[1])> &) file:T02.function.hpp line:
M("").def("foo_f3", (void (*)(const class std::function<bool (void (**)(void), int (&)[1])> &)) &foo_f3, "C++: foo_f3(const class std::function<bool (void (**)(void), int (&)[1])> &) --> void", pybind11::arg("f"));

// foo_f5(void (&)(void)) file:T02.function.hpp line:157
// foo_f5(void (&)(void)) file:T02.function.hpp line:
M("").def("foo_f5", (void (*)(void (&)(void))) &foo_f5, "C++: foo_f5(void (&)(void)) --> void", pybind11::arg(""));

// foo_f7(void (&)(void)) file:T02.function.hpp line:160
// foo_f7(void (&)(void)) file:T02.function.hpp line:
M("").def("foo_f7", (void (*)(void (&)(void))) &foo_f7, "C++: foo_f7(void (&)(void)) --> void", pybind11::arg(""));

// foo_f8(void (&)(void)) file:T02.function.hpp line:164
// foo_f8(void (&)(void)) file:T02.function.hpp line:
M("").def("foo_f8", (void (*)(void (&)(void))) &foo_f8, "C++: foo_f8(void (&)(void)) --> void", pybind11::arg("f"));

}
Expand Down
10 changes: 5 additions & 5 deletions test/T05.default.ref.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

void bind_T05_default(std::function< pybind11::module &(std::string const &namespace_) > &M)
{
// foo(int, int, int &, float, const double &, void *, int) file:T05.default.hpp line:17
// foo(int, int, int &, float, const double &, void *, int) file:T05.default.hpp line:
M("").def("foo", [](int const & a0) -> double { return foo(a0); }, "", pybind11::arg("a"));
M("").def("foo", [](int const & a0, int const & a1) -> double { return foo(a0, a1); }, "", pybind11::arg("a"), pybind11::arg("i1"));
M("").def("foo", [](int const & a0, int const & a1, int & a2) -> double { return foo(a0, a1, a2); }, "", pybind11::arg("a"), pybind11::arg("i1"), pybind11::arg("i2"));
Expand All @@ -28,12 +28,12 @@ void bind_T05_default(std::function< pybind11::module &(std::string const &names
M("").def("foo", [](int const & a0, int const & a1, int & a2, float const & a3, const double & a4, void * a5) -> double { return foo(a0, a1, a2, a3, a4, a5); }, "", pybind11::arg("a"), pybind11::arg("i1"), pybind11::arg("i2"), pybind11::arg("f"), pybind11::arg("d"), pybind11::arg("p"));
M("").def("foo", (double (*)(int, int, int &, float, const double &, void *, int)) &foo, "C++: foo(int, int, int &, float, const double &, void *, int) --> double", pybind11::arg("a"), pybind11::arg("i1"), pybind11::arg("i2"), pybind11::arg("f"), pybind11::arg("d"), pybind11::arg("p"), pybind11::arg("q"));

{ // A file:T05.default.hpp line:22
{ // A file:T05.default.hpp line:
pybind11::class_<A, std::shared_ptr<A>> cl(M(""), "A", "");
cl.def( pybind11::init( [](){ return new A(); } ) );
cl.def( pybind11::init( [](A const &o){ return new A(o); } ) );
}
{ // B file:T05.default.hpp line:28
{ // B file:T05.default.hpp line:
pybind11::class_<B, std::shared_ptr<B>> cl(M(""), "B", "");
cl.def( pybind11::init( [](){ return new B(); } ), "doc" );
cl.def( pybind11::init( [](const int & a0){ return new B(a0); } ), "doc" , pybind11::arg("a"));
Expand All @@ -60,10 +60,10 @@ void bind_T05_default(std::function< pybind11::module &(std::string const &names
cl.def_static("foo_static", [](int const & a0, float const & a1) -> double { return B::foo_static(a0, a1); }, "", pybind11::arg("i"), pybind11::arg("f"));
cl.def_static("foo_static", (double (*)(int, float, double)) &B::foo_static, "C++: B::foo_static(int, float, double) --> double", pybind11::arg("i"), pybind11::arg("f"), pybind11::arg("d"));
}
// foo_f0(void (void), int, float) file:T05.default.hpp line:42
// foo_f0(void (void), int, float) file:T05.default.hpp line:
M("").def("foo_f0", (void (*)(void (void), int, float)) &foo_f0, "C++: foo_f0(void (void), int, float) --> void", pybind11::arg("f"), pybind11::arg("a"), pybind11::arg("b"));

// foo_f1(void (&)(void), int, float) file:T05.default.hpp line:45
// foo_f1(void (&)(void), int, float) file:T05.default.hpp line:
M("").def("foo_f1", (void (*)(void (&)(void), int, float)) &foo_f1, "C++: foo_f1(void (&)(void), int, float) --> void", pybind11::arg("f"), pybind11::arg("a"), pybind11::arg("b"));

}
Expand Down
2 changes: 1 addition & 1 deletion test/T07.class.match_args.ref.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

void bind_T07_class_match_args(std::function< pybind11::module &(std::string const &namespace_) > &M)
{
{ // MatchArgs file:T07.class.match_args.hpp line:14
{ // MatchArgs file:T07.class.match_args.hpp line:
pybind11::class_<MatchArgs, std::shared_ptr<MatchArgs>> cl(M(""), "MatchArgs", "");
cl.def( pybind11::init( [](){ return new MatchArgs(); } ) );
cl.def( pybind11::init( [](MatchArgs const &o){ return new MatchArgs(o); } ) );
Expand Down
Loading

0 comments on commit be50c7c

Please sign in to comment.