siplasplas
A library for C++ reflection and introspection
examples/reflection/static/chaiscript.cpp

This example shows how the binding of a C++ API to an external language can be automated using static reflection. In the example, Member functions of a class are binded into a chaiscript context

#include <chaiscript/chaiscript.hpp>
#include <chaiscript/chaiscript_stdlib.hpp>
#include <siplasplas/utility/fusion.hpp>
#include "myclass.hpp"
int main()
{
chaiscript::ChaiScript chai{chaiscript::Std_Lib::library()};
cpp::foreach_type<cpp::srfl::Class<MyClass>::Methods>([&](auto method)
{
using Method = cpp::meta::type_t<decltype(method)>;
chai.add(chaiscript::fun(Method::get()), Method::SourceInfo::spelling());
});
}