Skip to content

Instantly share code, notes, and snippets.

@CedricGuillemet
Last active November 17, 2017 06:27
Show Gist options
  • Save CedricGuillemet/5f67f4e18fbba194d9ab5eac4671a2d5 to your computer and use it in GitHub Desktop.
Save CedricGuillemet/5f67f4e18fbba194d9ab5eac4671a2d5 to your computer and use it in GitHub Desktop.
//Expose c++ class
newDSLClass(); // global
endClass();
newDSLClass("Health");
member("Life", OFFSETOF(Health.Life"), DSL::Int_t);
endClass();
newDSLClass("Entity");
member("Pos", OFFSETOF(Entity.Pos), DSL::vec4_t);
member("health", OFFSETOF(entity.health", "Health");
endClass();
// create DSL class
dslVar = DSLInstanciate("Entity", &myEntity);
// call DSL class
DSLCall(dslVar, "Update");
DSLCall(dslVar, "Update", deltaTime);
// query DSL object/ DOM
dslVar2 = DSLQuery(dslVar, "health");
dslVar2 = DSLQuery(dslVar, "health.Life");
// define DSL class
foo(val)
{
return val + 3
}
class Player extend Entity
anotherMember:vec4
Update(dt)
{
anotherMember.x += dt
}
end
// impl
struct Function_t
{
int parameterCount;
};
struct Word_t
{
const char *name;
union
{
void *function;
int _int;
float _float;
};
unsigned unmutableType:1;// coming from C++
};
std::vector<Word_t> Heap;
std::vector<Word_t> Stack;
std::vector<Word_t> Definitions; // compositions of c++ and DSL classes
-> gen def
-> gen bytecode
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment