From 7515b8c4ad0b094664b537ac7718ef5d7477a63f Mon Sep 17 00:00:00 2001 From: ThePhD Date: Tue, 1 Dec 2015 13:46:32 -0500 Subject: [PATCH] make sure examples compile --- examples/userdata.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/examples/userdata.cpp b/examples/userdata.cpp index 96d269f4..e7f5d6f2 100644 --- a/examples/userdata.cpp +++ b/examples/userdata.cpp @@ -43,15 +43,15 @@ int main() { lua.open_libraries(sol::lib::base, sol::lib::math); // the simplest way to create a class is through - // sol::state::new_userdata + // sol::state::new_usertype // the first template is the class type // the rest are the constructor parameters - // using new_userdata you can only have one constructor + // using new_usertype you can only have one constructor // you must make sure that the name of the function // goes before the member function pointer - lua.new_userdata("foo", "print", &foo::print, "test", &foo::test); + lua.new_usertype("foo", "print", &foo::print, "test", &foo::test); // making the class from lua is simple // same with calling member functions @@ -63,8 +63,8 @@ int main() { assert(y == 14); // if you want a class to have more than one constructor - // the way to do so is through set_userdata and creating - // a userdata yourself with constructor types + // the way to do so is through set_usertype and creating + // a usertype yourself with constructor types { // Notice the brace: this means we're in a new scope @@ -75,15 +75,15 @@ int main() { // the first argument of construction is the name // second is the constructor types // then the rest are function name and member function pointer pairs - sol::userdata udata("vector", ctor, "is_unit", &vector::is_unit); + sol::usertype udata(ctor, "is_unit", &vector::is_unit); // then you must register it - lua.set_userdata(udata); - // You can throw away the userdata after you set it: you do NOT + lua.set_usertype("vector", udata); + // You can throw away the usertype after you set it: you do NOT // have to keep it around // cleanup happens automagically } - // calling it is the same as new_userdata + // calling it is the same as new_usertype lua.script("v = vector.new()\n" "v = vector.new(12)\n" @@ -92,7 +92,7 @@ int main() { // You can even have C++-like member-variable-access // just pass is public member variables in the same style as functions - lua.new_userdata("variables", "low_gravity", &variables::low_gravity, "boost_level", &variables::boost_level); + lua.new_usertype("variables", "low_gravity", &variables::low_gravity, "boost_level", &variables::boost_level); // making the class from lua is simple // same with calling member functions/variables