-
Notifications
You must be signed in to change notification settings - Fork 16
Description
This project is very interesting.
Some of autoprogrammer's features in TODO status, so i wanted to add them.
I want to use some proposed features (like metaclasses) without waiting 3+ years for new C++ standard and can`t find stable (ready) solution.
Inspired by autoprogrammer's approach i created https://github.com/blockspacer/CXXCTP
Maybe some ideas from that project will be useful for autoprogrammer.
-
I found what jinja to C++ binding produced a lot of boilerplate code.
I replaced jinja with https://github.com/blockspacer/CXTPL
cxtpl uses approach similar to How to write a template engine in less than 30 lines of code from https://bits.theorem.co/how-to-write-a-template-library/
That approach allowed to removejinja2_reflector_generator.cppcompletely -
I can't find docs about autoprogrammer's C++ interpreter, so i used
Clingas C++ interpreter. Maybe autoprogrammer's solution is less verbose or feature rich (i just can't understand it without some docs). -
I wanted to add feature-complete Rust-like traits into C++. That's why i added to typeclasses generator
typeclass combinations(when some typeclasses may be not set),std::ref support,typeclass merging(when all typeclasses must be set), out-of-source methods (so method may be defined in separate lib),typeclass with template parameters. Now typeclass instance accepts impl as first template argument, and all other template arguments may be used to combine typeclasses. -
I wanted to chain multiple metaclasses, so i added custom C++ attribute syntax, very similar to calling C++ functions.
// $apply is just macro that adds attribute
class
$apply(make_interface;make_removefuncbody;make_reflect)
SomeInterfaceName {
virtual ~SomeInterfaceName() = 0;
/*int f ( ) { // {}
int i = 6;
{
// {
// }
}
return i;
};*/
int foo();
virtual void foobar(int& arg1) = 0;
virtual inline void zoobar(int& arg2);
//int m_bar;
//int m_bar2 = 2;
};
In attribute i can list needed metaclasses. Each metaclass is function (like make_interface) that returns modified source code or generated file.
- I wanted to create tool not focused on predefined set of source transformation rules. That's why i added per-project
ctp_scriptsfolder. Ifctp_scriptsused by separate project - all rules fromctp_scriptsmust be imported into Cling, so it behaves like interpreted plugin system. Because interpreted code runs slower - i addedcustom_plugins.cmake.example, so 'plugin' may be compiled and used as built-in tool plugin. Maybe it is better to create .dll/.so based plugin system.