|
@@ -3,8 +3,6 @@
|
|
|
|
|
|
|
|
#include <iostream>
|
|
#include <iostream>
|
|
|
|
|
|
|
|
-using namespace luwra;
|
|
|
|
|
-
|
|
|
|
|
struct Point {
|
|
struct Point {
|
|
|
double x, y;
|
|
double x, y;
|
|
|
|
|
|
|
@@ -35,24 +33,24 @@ int main() {
|
|
|
// Register our user type.
|
|
// Register our user type.
|
|
|
// This function also registers a garbage-collector hook and a string representation function.
|
|
// This function also registers a garbage-collector hook and a string representation function.
|
|
|
// Both can be overwritten using the third parameter, which lets you add custom meta methods.
|
|
// Both can be overwritten using the third parameter, which lets you add custom meta methods.
|
|
|
- register_user_type<Point>(
|
|
|
|
|
|
|
+ luwra::register_user_type<Point>(
|
|
|
state,
|
|
state,
|
|
|
// Methods which shall be availabe in the Lua user data, need to be declared here
|
|
// Methods which shall be availabe in the Lua user data, need to be declared here
|
|
|
{
|
|
{
|
|
|
- {"scale", wrap_method<Point, void(double), &Point::scale>},
|
|
|
|
|
- {"x", wrap_property<Point, double, &Point::x>},
|
|
|
|
|
- {"y", wrap_property<Point, double, &Point::y>}
|
|
|
|
|
|
|
+ {"scale", luwra::wrap_method<Point, void(double), &Point::scale>},
|
|
|
|
|
+ {"x", luwra::wrap_property<Point, double, &Point::x>},
|
|
|
|
|
+ {"y", luwra::wrap_property<Point, double, &Point::y>}
|
|
|
},
|
|
},
|
|
|
// Meta methods may be registered aswell
|
|
// Meta methods may be registered aswell
|
|
|
{
|
|
{
|
|
|
- {"__tostring", wrap_method<Point, std::string(), &Point::toString>}
|
|
|
|
|
|
|
+ {"__tostring", luwra::wrap_method<Point, std::string(), &Point::toString>}
|
|
|
}
|
|
}
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
// What's left, is registering a constructor for our type.
|
|
// What's left, is registering a constructor for our type.
|
|
|
// We have to specify which parameters our constructor takes, because there might be more than
|
|
// We have to specify which parameters our constructor takes, because there might be more than
|
|
|
// one constructor to deal with.
|
|
// one constructor to deal with.
|
|
|
- push(state, wrap_constructor<Point, double, double>);
|
|
|
|
|
|
|
+ luwra::push(state, luwra::wrap_constructor<Point, double, double>);
|
|
|
lua_setglobal(state, "Point");
|
|
lua_setglobal(state, "Point");
|
|
|
|
|
|
|
|
// Invoke the attached script
|
|
// Invoke the attached script
|