[breaking] Fix generation when excluding entities
Had to change generation options retrieval.
This commit is contained in:
parent
59eee1f75a
commit
315fb3a98f
5 changed files with 253 additions and 128 deletions
|
|
@ -85,10 +85,85 @@ struct foo{
|
|||
excluded c()const&;
|
||||
|
||||
operator excluded();
|
||||
};
|
||||
)";
|
||||
};)";
|
||||
|
||||
auto file = parse({}, "code_generator_exclude_return.cpp", code);
|
||||
REQUIRE(get_code(*file, code_generator::exclude_return) == synopsis);
|
||||
}
|
||||
SECTION("exclude")
|
||||
{
|
||||
// exclude all entities starting with `e`
|
||||
class exclude_generator : public test_generator
|
||||
{
|
||||
public:
|
||||
using test_generator::test_generator;
|
||||
|
||||
private:
|
||||
generation_options do_get_options(const cpp_entity& e) override
|
||||
{
|
||||
if (e.name().front() == 'e')
|
||||
return code_generator::exclude;
|
||||
return {};
|
||||
}
|
||||
};
|
||||
|
||||
auto code = R"(
|
||||
void e();
|
||||
|
||||
void func(int a, int e, int c);
|
||||
|
||||
template <typename e1, typename e2>
|
||||
void tfunc(int a);
|
||||
|
||||
struct base {};
|
||||
struct e_t {};
|
||||
|
||||
struct bar : e_t, base {};
|
||||
|
||||
class foo : e_t
|
||||
{
|
||||
int a;
|
||||
|
||||
public:
|
||||
int e1;
|
||||
|
||||
private:
|
||||
int b;
|
||||
|
||||
public:
|
||||
int c;
|
||||
int e2;
|
||||
|
||||
private:
|
||||
int e3;
|
||||
};
|
||||
)";
|
||||
|
||||
auto synopsis = R"(void func(int a,int c);
|
||||
|
||||
void tfunc(int a);
|
||||
|
||||
struct base{
|
||||
};
|
||||
|
||||
struct bar
|
||||
:base{
|
||||
};
|
||||
|
||||
class foo{
|
||||
int a;
|
||||
|
||||
int b;
|
||||
|
||||
public:
|
||||
int c;
|
||||
};
|
||||
)";
|
||||
|
||||
auto file = parse({}, "code_generator_exclude.cpp", code);
|
||||
|
||||
exclude_generator generator(code_generator::generation_options{});
|
||||
generate_code(generator, *file);
|
||||
REQUIRE(generator.str() == synopsis);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,12 +55,7 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
generation_options on_container_begin(const cppast::cpp_entity&) override
|
||||
{
|
||||
return options_;
|
||||
}
|
||||
|
||||
generation_options on_leaf(const cppast::cpp_entity&) override
|
||||
generation_options do_get_options(const cppast::cpp_entity&) override
|
||||
{
|
||||
return options_;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue