This is a basic usage example where I do some random stuff to show and somewhat see for myself what happens.
A more in depth and somewhat serious example can be seen here.
A more in depth and somewhat serious example can be seen here.
//==================================================================================================
// main.cpp : generates code in output.cpp
// This is a playful example - parts of the code generated in "output.cpp" will obviously not compile
//==================================================================================================
#include "JMeta.h"
using namespace JMeta;
//==================================================================================================
int main (int, char **)
{
//create class
JMeta::Class jamesClass = "JamesClass";
jamesClass.newFunction(jamesClass.toPointer(), "name");
//add function
auto function = jamesClass.newFunction(Char16_t, "someFunction");
function->addModifier(FunctionModifier::InlineLocally);
function->signature().append(jamesClass.toConstReference(), "cheeseburger", 2);
function->signature().append(intrinsic(Char32_t)->toPointer()->toPointer()->toReference(), "cheeseburger2", 2);
//add for loop to "someFunction"
new ForLoop(express(153), function); //using "new" for now, need better memory management
//add stuff to for-loop's body
auto f = new ForLoop(express("pie"), function, "ihouse");
f->newObject(Char, "cat", f->i());
f->newObject(Char16_t, "dog");
new RangedForLoop(f->i(), Char, "letter", f);
//add object to class
jamesClass.newObject(UInt, "onion");
//create nested class within "jamesClass"
Class *c2 = jamesClass.newClass("Class2");
c2->addBase(&jamesClass);
c2->newObject(&jamesClass, "var", f->i());
//print "jamesClass"
saveToFile("output.cpp", jamesClass.declaration(), false);
return 0;
}
//==================================================================================================
//==================================================================================================
// output.cpp
//==================================================================================================
class JamesClass
{
public:
JamesClass *name();
char16_t someFunction(const JamesClass &cheeseburger, char32_t **&cheeseburger2)
{
for(int i = 0; i<153; ++i);
for(int ihouse = 0; ihouse<pie; ++ihouse)
{
char cat = ihouse;
char16_t dog;
for(char letter : ihouse)
{
}
}
}
uint onion;
class Class2 : public JamesClass
{
public:
JamesClass var = someFunction::<for_loop>::ihouse;
};
};
//==================================================================================================