C++ embedded scripting language for game development - can't find anything I like
For C-like syntax, checkout
- Ch a commercial, embeddable C interpreter
- CINT an open source C/C++ interpreter
- Pawn - a "simple, typeless, 32-bit extension language with a C-like syntax"
Probably not for you, but as this question might turn up a list of alternatives others would find interesting, I offer you QtScript which gives you a Javascript-like syntax. Wrapping can be straightforward, but you need to adopt the Qt framework to do it, particularly concept of signals and slots.
There's also SpiderMonkey, the JS engine from Firefox.
You might look at using JavaScript. The V8 scripting engine can be embedded in your program and there is documentation on how to expose your types.
You might be interested in Dao (http://daoscript.org/, https://github.com/daokoder/dao).
Dao is implemented in standard C with minimum dependency (if you exclude the optional modules and tools). It is lightweight and efficient with good support for embedding and extending. Its interface for calling C functions is not based on stack. Here is a simple example:
#include "stdio.h"
#include "daoValue.h"
static void Square( DaoProcess *proc, DaoValue *param[], int nparam )
{
daoint num = param[0]->xInteger.value;
DaoProcess_PutInteger( proc, num*num );
}
int DaoOnLoad( DaoVmSpace *vmspace, DaoNamespace *nspace )
{
DaoNamespace_WrapFunction( nspace, Square, "Square( num : int ) => int" );
return 0;
}
You may noticed that there is NO boilerplate code for checking the parameter types in the wrapped function. This is because this function is registered as Square(num:int)=>int
, which means this function can only accept an integer as parameter, and is guaranteed by the Dao runtime.
You may also be interested to know that it also has a tool based on Clang for automatic/semiautomatic generation of C/C++ bindings.
Disclaimer: I am the author of this language.