luabind-user Mailing List for luabind (Page 3)
Brought to you by:
arvidn,
daniel_wallin
You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
(54) |
May
(66) |
Jun
(56) |
Jul
(114) |
Aug
(84) |
Sep
(20) |
Oct
(30) |
Nov
(16) |
Dec
(38) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(36) |
Feb
(27) |
Mar
(32) |
Apr
(83) |
May
(66) |
Jun
(64) |
Jul
(63) |
Aug
(45) |
Sep
(14) |
Oct
(24) |
Nov
(19) |
Dec
(17) |
2005 |
Jan
(28) |
Feb
(20) |
Mar
(30) |
Apr
(19) |
May
(14) |
Jun
(18) |
Jul
(18) |
Aug
(6) |
Sep
(34) |
Oct
(46) |
Nov
(26) |
Dec
(44) |
2006 |
Jan
(41) |
Feb
(25) |
Mar
(42) |
Apr
(23) |
May
(21) |
Jun
(34) |
Jul
(44) |
Aug
(25) |
Sep
(29) |
Oct
(36) |
Nov
(7) |
Dec
(1) |
2007 |
Jan
(46) |
Feb
(22) |
Mar
(6) |
Apr
(10) |
May
(19) |
Jun
(20) |
Jul
|
Aug
(11) |
Sep
(33) |
Oct
(18) |
Nov
(13) |
Dec
(10) |
2008 |
Jan
(7) |
Feb
(6) |
Mar
(9) |
Apr
(5) |
May
(14) |
Jun
(29) |
Jul
(15) |
Aug
(10) |
Sep
(75) |
Oct
(43) |
Nov
(38) |
Dec
(40) |
2009 |
Jan
(62) |
Feb
(61) |
Mar
(74) |
Apr
(22) |
May
(31) |
Jun
(32) |
Jul
(32) |
Aug
(36) |
Sep
(7) |
Oct
(20) |
Nov
(51) |
Dec
(65) |
2010 |
Jan
(38) |
Feb
(48) |
Mar
(57) |
Apr
(21) |
May
(23) |
Jun
(41) |
Jul
(58) |
Aug
(17) |
Sep
(39) |
Oct
(15) |
Nov
(3) |
Dec
(13) |
2011 |
Jan
(35) |
Feb
(40) |
Mar
(17) |
Apr
(34) |
May
(39) |
Jun
(34) |
Jul
(19) |
Aug
(23) |
Sep
|
Oct
(20) |
Nov
(7) |
Dec
(12) |
2012 |
Jan
(13) |
Feb
(27) |
Mar
(15) |
Apr
(32) |
May
(9) |
Jun
(5) |
Jul
(4) |
Aug
|
Sep
(26) |
Oct
(4) |
Nov
(18) |
Dec
(4) |
2013 |
Jan
(15) |
Feb
(4) |
Mar
|
Apr
(20) |
May
(6) |
Jun
(10) |
Jul
(17) |
Aug
(6) |
Sep
(19) |
Oct
(3) |
Nov
(1) |
Dec
|
2014 |
Jan
(1) |
Feb
(6) |
Mar
|
Apr
|
May
(4) |
Jun
|
Jul
|
Aug
(3) |
Sep
(6) |
Oct
|
Nov
(6) |
Dec
|
2015 |
Jan
|
Feb
|
Mar
(3) |
Apr
(1) |
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
(2) |
Dec
(10) |
2016 |
Jan
(2) |
Feb
(1) |
Mar
|
Apr
(1) |
May
(1) |
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
From: Glen F. <hol...@gm...> - 2013-10-26 17:45:03
|
Hi there, I know it's possible to set "properties" on luabind classes in Lua. You can set and get these keys, no problem. However, it doesn't seem possible to "get" (or test for the existence of) an unset key -- you'd expect it to return 'nil', but it crashes. Is there a way to test a luabind class for the existence of a key (as though it were a table), without crashing? Here is a made-up example: function testKey(obj, key) if obj[key] then print(type(obj) .. " key: '" .. key .. "' value: " .. obj[key]) else print(type(obj) .. " key: '" .. key .. "' doesn't exist.") end end class 'MyClass' MyClass.someFlag = 5 function MyClass:__init(name) self.name = name end -- Test on an instance of the class: a = MyClass('example') testKey(a, 'name') testKey(a, 'doesNotExist') -- not an error to access an unset key; simply returns nil testKey(a, 'someFlag') a.someFlag = -12 testKey(a, 'someFlag') -- Now do a similar test on the class itself (not an instance): testKey(MyClass, 'someFlag') -- works fine; the key has already been set -- But for undefined keys, it fails (if MyClass were a table instead of -- a userdata (class), you'd expect it to simply return nil). testKey(MyClass, 'doesNotExist') -- crash So, is there a way I can test if a luabind class has a particular key? (I'm using Lua-derived C++ classes, but I have the same problem even with simple luabind classes, as shown in the above simple example). Thanks, Glen. |
From: Michael S. <mic...@tu...> - 2013-09-29 15:03:45
|
Doesn't the unsubscribe-function on the admin page work? |
From: Maha A. <mah...@gm...> - 2013-09-29 14:59:00
|
-- -------------------------------------------------------------------------------------------- *Facebook : akkari.maha **"Never Look down on people unless you are helping them get up" * |
From: Michael S. <mic...@tu...> - 2013-09-29 14:55:40
|
Hello again, digging through the list I found this issue to pop up again and again. People were trying to use refs to native types, or there were complaining why luabind wouldn't support it etc.. Maybe it would be wise to add a paragraph to the documentation stating that is just not possible to implement that, since lua does not know about references/pointers? The only thing that I can imagine one could do would be to provide an opt-in type boxing support. So you could inject boxed native types into lua that could be unboxed into references on the c++ side again (I think this is quite similar to what Java has?). And some way to box native types on the lua side to, to simulate references. One would then have to differ between lua and c++ boxes, because c++ boxes would contain pointers to a c++ value, whereas boxes created in lua would have a true datamember... The unboxing converter would then have to differ between c++ boxes and lua boxes, because the latter would have to write back to the table, whereas the former supplied the true pointer and wouldn't have to do anything. But any way, we'd have to manually box and unbox the types in native and in lua code. So I really doubt that it's worth the great effort that is necessary to implement that. Michael |
From: Michael S. <mic...@tu...> - 2013-09-29 12:22:53
|
Hi there, I was playing around with the rvalue reference stuff whereby I broke a test case, which happened to declare a function to lua with the signature "int(int&)". Now you could make that work by registering "int" as a class and when passing in a value by reference, it would wrap that one up to a userdata object. However when you do that, you basically disable the ability to call functions on the lua side that accept numbers. My question is, should registering functions taking references to native types even be allowed? I think I will have to somewhate differ in all calls between native&user defined types. Because for example when you call into lua with a rvalue ref to a user defined type, it could move it to the internal pointer holder (and on the other end it could move it out, if there was a flag indicating rvalue reference), however for native types they must be treated as per-value under all circumstances (probably the passing is broken in current head because of that, call_function took a const& of all parameters and the default_converter was somehow "optimized" to catch const int& (but not int&!) and treat it by value. This stuff is pretty fragile and I intend to replace it by something that is reasonably understandable). Michael |
From: Willi S. <wi...@sc...> - 2013-09-28 09:27:36
|
I downloaded it sometime in the afternoon - judging from your name you're probably German as well so we likely share a timezone, so chances are I didn't have the latest version. I'll try again later, using 4.8 as well. Circular dependencies are indeed something I thought of as well but didn't want to investigate at the time. Willi |
From: Michael S. <ms...@tu...> - 2013-09-28 05:50:29
|
Hello Willi, which version did you use on which compiler? I had exactly these error messages before getting it compatible to gcc 4.8.1 yesterday evening. This was a problem that started, because MSVC delays template instantiation (contra the standard) and so conforming compilers need certain function definitions earlier in cases. But including the definitions led to a circular header dependency, which never ends well. I fixed that one last evening, so I'm curious if you used the latest master? Michael |
From: Willi S. <wi...@sc...> - 2013-09-27 22:39:20
|
I've fiddled with it for a while but couldn't get it to compile with the Android NDK. Got a couple of errors, like one about luabind::get_back_reference() not being found in pointer_converter.hpp although it clearly includes back_reference.hpp. Strange. Well, I'll use the Lua C API for now, using experimental C++11-based libraries might not be the best thing to do in your first Android NDK program. Willi |
From: Willi S. <wi...@sc...> - 2013-09-26 18:45:29
|
Hi, just wanted to say thank you for this. I'll probably give this a try soon-ish and report back. (Any problems I encounter will go to the github issue tracker, that what it's for after all.) Willi |
From: Michael S. <mic...@tu...> - 2013-09-26 15:43:41
|
Hello, thank you so much for the input, I will work on it. Michael PS: Do you mind me contacting you directly in case if questions? Mustn't have all the noise here for implementation details, I figure. |
From: Lorenzo P. <bla...@gm...> - 2013-09-26 15:43:31
|
Actually it is a very good thing to require an extra flag, as c++11 doesn't only add stuff but changes the behaviour of some subtleties. On 09/26/2013 05:14 PM, Michael Steinberg wrote: > Gnarg! > I will try to find out how to set that with the CMake files. This was > the first CMake project I used and I didn't think about other compilers > might need an extra flag for c++11. Many more beginner's mistakes to come! > > Michael > > ------------------------------------------------------------------------------ > October Webinars: Code for Performance > Free Intel webinars can help you accelerate application performance. > Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from > the latest Intel processors and coprocessors. See abstracts and register > > http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk > _______________________________________________ > luabind-user mailing list > lua...@li... > https://lists.sourceforge.net/lists/listinfo/luabind-user |
From: Lorenzo P. <bla...@gm...> - 2013-09-26 15:40:03
|
Right now I'm busy so I can't fix all the problems, but here's something that might be interesting to you. A patch for some trivial problems with path names (replace \ with /, which is cross-platform) and the -std=c++11 flag: http://pastebin.com/maSTChZy A log of "make -k" to spot the compilation errors on all the compile units: http://pastebin.com/KgjZtULV I urge you to also add a newline at the end of the source files, not having that is a bit annoying on linux because basically every tool try to add it, and it's general wisdom to put them otherwise "some programs might not work". On 09/26/2013 05:14 PM, Michael Steinberg wrote: > Gnarg! > I will try to find out how to set that with the CMake files. This was > the first CMake project I used and I didn't think about other compilers > might need an extra flag for c++11. Many more beginner's mistakes to come! > > Michael > > ------------------------------------------------------------------------------ > October Webinars: Code for Performance > Free Intel webinars can help you accelerate application performance. > Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from > the latest Intel processors and coprocessors. See abstracts and register > > http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk > _______________________________________________ > luabind-user mailing list > lua...@li... > https://lists.sourceforge.net/lists/listinfo/luabind-user |
From: Lorenzo P. <bla...@gm...> - 2013-09-26 15:16:11
|
Hold on, I have already fixed it, plus another thingie. I'll share the patch in moments On 09/26/2013 05:14 PM, Michael Steinberg wrote: > Gnarg! > I will try to find out how to set that with the CMake files. This was > the first CMake project I used and I didn't think about other compilers > might need an extra flag for c++11. Many more beginner's mistakes to come! > > Michael > > ------------------------------------------------------------------------------ > October Webinars: Code for Performance > Free Intel webinars can help you accelerate application performance. > Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from > the latest Intel processors and coprocessors. See abstracts and register > > http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk > _______________________________________________ > luabind-user mailing list > lua...@li... > https://lists.sourceforge.net/lists/listinfo/luabind-user |
From: Michael S. <mic...@tu...> - 2013-09-26 15:14:43
|
Gnarg! I will try to find out how to set that with the CMake files. This was the first CMake project I used and I didn't think about other compilers might need an extra flag for c++11. Many more beginner's mistakes to come! Michael |
From: Lorenzo P. <bla...@gm...> - 2013-09-26 15:08:08
|
It doesn't seem to set the -std=c++11 flag On 09/26/2013 04:51 PM, Michael Steinberg wrote: > Hello, >> Do I just compile all the .cpp files? > the project comes with CMake files that should probably be able to set > up the project files for your build environment (It was very simple here > on windows). You will need a version of the lua library however. > > Michael > > ------------------------------------------------------------------------------ > October Webinars: Code for Performance > Free Intel webinars can help you accelerate application performance. > Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from > the latest Intel processors and coprocessors. See abstracts and register > > http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk > _______________________________________________ > luabind-user mailing list > lua...@li... > https://lists.sourceforge.net/lists/listinfo/luabind-user |
From: Michael S. <mic...@tu...> - 2013-09-26 15:04:08
|
Hello, > I believe it reduces the codebase ? It > should make the code a lot clearer also, allowing for more third party > contributions. Lots of old code has gone, the statistics are about +4k -5k lines. Note that this includes my replacement for boost::mpl usage (boost::mpl + boost::lexical_cast are really big buggers and noone seems to care to make c++11-ready) and other boost stuff, so it could have been even less (plus the meta header in the end provides much more than I used at the end). But I fear that I might have broken stuff all over the place, so this needs testing and the provided tests do not cover the whole code. I tried to make the stuff clearer, if anybody has improvement ideas, I'll gladly accept patches (when I find out how to apply them :D)/ideas. Other than that I'm watching the other repositories and try to port their patches. Michael |
From: Michael S. <mic...@tu...> - 2013-09-26 14:52:21
|
Hello, > Do I just compile all the .cpp files? the project comes with CMake files that should probably be able to set up the project files for your build environment (It was very simple here on windows). You will need a version of the lua library however. Michael |
From: Lorenzo P. <bla...@gm...> - 2013-09-26 14:48:07
|
Looks interesting. I could test with gcc 4.8.1 and possibly even clang on Mac OSX 10.8, but I'm not familiar with the original build method of luabind, I don't know if I should mimic it. Do I just compile all the .cpp files? On 09/26/2013 04:31 PM, Michael Steinberg wrote: > Hello, > I have so far been developing privately on a fork of Ryan Pavlik's > luabind version (https://github.com/decimad/luabind-deboostified) to > make it independent of boost and use variadic templates and c++11 > constructs unconditionally. With the advent of Visual C++ 2013 RC I felt > it was time to tame the beast down in order to not cripple Intellisense > by its pure complexity of all boost preprocessor magic going on there, > but maybe there is something in it for users of different compilers. > I basically replaced the policy system and reworked all the > calling-wrapper-code while trying to maintain test stability (adapting > the tests where I found a breaking change was farvorable). > Now I don't want to urge anyone using it (it would even create some > porting work, as it is not 100% source compatible), but I want to ask if > anyone could take the time to test if it compiles and tests ok on other > c++11 compilers or if I made it unbuildable by accident (maybe even > giving hints of what is wrong). If anyone ever feels like he would like > to use a c++11-version, I would like to contribute back a working thing > (or at least try to offer it). > > With kind regards, > Michael > > ------------------------------------------------------------------------------ > October Webinars: Code for Performance > Free Intel webinars can help you accelerate application performance. > Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from > the latest Intel processors and coprocessors. See abstracts and register > > http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk > _______________________________________________ > luabind-user mailing list > lua...@li... > https://lists.sourceforge.net/lists/listinfo/luabind-user |
From: Teto <mat...@gm...> - 2013-09-26 14:43:33
|
That's truly awesome. I had started myself a port of luabind to C++11 but had given up in front facing the huge amount of work needed. I won't have time to check this anytime soon but I will in a few months and give you feedback. I believe it reduces the codebase ? It should make the code a lot clearer also, allowing for more third party contributions. Thanks a lot for your work. Matt On Thu, Sep 26, 2013 at 4:31 PM, Michael Steinberg <mic...@tu...> wrote: > Hello, > I have so far been developing privately on a fork of Ryan Pavlik's > luabind version (https://github.com/decimad/luabind-deboostified) to > make it independent of boost and use variadic templates and c++11 > constructs unconditionally. With the advent of Visual C++ 2013 RC I felt > it was time to tame the beast down in order to not cripple Intellisense > by its pure complexity of all boost preprocessor magic going on there, > but maybe there is something in it for users of different compilers. > I basically replaced the policy system and reworked all the > calling-wrapper-code while trying to maintain test stability (adapting > the tests where I found a breaking change was farvorable). > Now I don't want to urge anyone using it (it would even create some > porting work, as it is not 100% source compatible), but I want to ask if > anyone could take the time to test if it compiles and tests ok on other > c++11 compilers or if I made it unbuildable by accident (maybe even > giving hints of what is wrong). If anyone ever feels like he would like > to use a c++11-version, I would like to contribute back a working thing > (or at least try to offer it). > > With kind regards, > Michael > > ------------------------------------------------------------------------------ > October Webinars: Code for Performance > Free Intel webinars can help you accelerate application performance. > Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from > the latest Intel processors and coprocessors. See abstracts and register > > http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk > _______________________________________________ > luabind-user mailing list > lua...@li... > https://lists.sourceforge.net/lists/listinfo/luabind-user |
From: Michael S. <mic...@tu...> - 2013-09-26 14:31:21
|
Hello, I have so far been developing privately on a fork of Ryan Pavlik's luabind version (https://github.com/decimad/luabind-deboostified) to make it independent of boost and use variadic templates and c++11 constructs unconditionally. With the advent of Visual C++ 2013 RC I felt it was time to tame the beast down in order to not cripple Intellisense by its pure complexity of all boost preprocessor magic going on there, but maybe there is something in it for users of different compilers. I basically replaced the policy system and reworked all the calling-wrapper-code while trying to maintain test stability (adapting the tests where I found a breaking change was farvorable). Now I don't want to urge anyone using it (it would even create some porting work, as it is not 100% source compatible), but I want to ask if anyone could take the time to test if it compiles and tests ok on other c++11 compilers or if I made it unbuildable by accident (maybe even giving hints of what is wrong). If anyone ever feels like he would like to use a c++11-version, I would like to contribute back a working thing (or at least try to offer it). With kind regards, Michael |
From: Glen F. <hol...@gm...> - 2013-08-28 21:24:28
|
Okay, thanks, that works. I also need to do a pop afterwards, or the stack keeps growing, right? (Seems to be the case, judging by printing out lua_gettop(L) before and after the method.) > luabind::object(L, &foo).push(L); > // Note: -1 instead of lua_gettop(L) would not work in the following line > // because of a bug in luabind::argument's ctor. > luabind::argument myArg(luabind::from_stack(L, lua_gettop(L))); > luabind::class_info info = luabind::get_class_info(myArg); ::lua_pop(L, 1); Great, thanks -- I guess my problems were because of that bug you mention, because I was using -1 in luabind::argument's ctor. Didn't know there was any problem with that. Glen. On Aug 28, 2013, at 6:23 PM, Christian <cn...@gm...> wrote: > You are right, argument has no constructor that takes a C++ object, sorry. But using push() and from_stackworks, as in the following example (tested): > > #include <luabind/luabind.hpp> > #include <luabind/class_info.hpp> > > #include <iostream> > > class Foo {}; > > int main() > { > lua_State* L = luaL_newstate(); > luabind::open(L); > luabind::module(L) [ > luabind::class_<Foo>("LuaFoo") > ]; > > Foo foo; > > luabind::object(L, &foo).push(L); > // Note: -1 instead of lua_gettop(L) would not work in the following line > // because of a bug in luabind::argument's ctor. > luabind::argument myArg(luabind::from_stack(L, lua_gettop(L))); > luabind::class_info info = luabind::get_class_info(myArg); > std::cout << info.name << '\n'; // Prints "LuaFoo". > } > > > From: Glen Fraser [mailto:hol...@gm...] > Sent: Wednesday, August 28, 2013 5:38 PM > To: lua...@li... > Subject: Re: [luabind] How to get Lua class name from C++ class? > > Thanks, Christian, but I didn't manage to get anything to work in the way you describe. I can't seem to simply substitute 'object' with 'argument'… I also tried using myObject.push(L), then using the "from_stack" referenced argument to call get_class_info(), then doing a lua_pop(), but that just crashes on me (a bit later on)…and before that, it hasn't returned the correct class_info structure. I think I'd need to see a simple example, sorry. > > On the other hand, the "hacky" code from Eduard (see his earlier reply) does seem to work fine, as does another approach I came up with, where I just use luabind::call_function() to call the bound "class_info" function in Lua, then get the class_info structure by doing object_cast on the returned object. Of course, this may be (?) a bit less efficient than doing the direct stack-fiddling you guys suggest, but it works. > > Thanks, > Glen. > |
From: Christian <cn...@gm...> - 2013-08-28 16:24:05
|
You are right, argument has no constructor that takes a C++ object, sorry. But using push() and from_stack works, as in the following example (tested): #include <luabind/luabind.hpp> #include <luabind/class_info.hpp> #include <iostream> class Foo {}; int main() { lua_State* L = luaL_newstate(); luabind::open(L); luabind::module(L) [ luabind::class_<Foo>("LuaFoo") ]; Foo foo; luabind::object(L, &foo).push(L); // Note: -1 instead of lua_gettop(L) would not work in the following line // because of a bug in luabind::argument's ctor. luabind::argument myArg(luabind::from_stack(L, lua_gettop(L))); luabind::class_info info = luabind::get_class_info(myArg); std::cout << info.name << '\n'; // Prints "LuaFoo". } From: Glen Fraser [mailto:hol...@gm...] Sent: Wednesday, August 28, 2013 5:38 PM To: lua...@li... Subject: Re: [luabind] How to get Lua class name from C++ class? Thanks, Christian, but I didn't manage to get anything to work in the way you describe. I can't seem to simply substitute 'object' with 'argument'… I also tried using myObject.push(L), then using the "from_stack" referenced argument to call get_class_info(), then doing a lua_pop(), but that just crashes on me (a bit later on)…and before that, it hasn't returned the correct class_info structure. I think I'd need to see a simple example, sorry. On the other hand, the "hacky" code from Eduard (see his earlier reply) does seem to work fine, as does another approach I came up with, where I just use luabind::call_function() to call the bound "class_info" function in Lua, then get the class_info structure by doing object_cast on the returned object. Of course, this may be (?) a bit less efficient than doing the direct stack-fiddling you guys suggest, but it works. Thanks, Glen. On Aug 28, 2013, at 4:07 PM, "Christian" <cn...@gm...> wrote: Just replace luabind::object with luabind::argument in your code. They work both the same, only that the first stores the referenced object in the registry, while the latter just leaves it on the stack. If you ever have to convert one into another, just use the ones push() method and the others from_stack constructor (but avoid relative indices with luabind::argument). From: Glen Fraser [mailto:holaglen@ <http://gmail.com> gmail.com] Sent: Wednesday, August 28, 2013 1:09 PM To: <mailto:lua...@li...> lua...@li... Subject: [luabind] How to get Lua class name from C++ class? Hello there, I'm using luabind and trying to get the Lua subclass name from an instance of the base class in C++. I want to use get_class_info(), but it expects an "argument" rather than an "object". Perhaps there is a better way to do this, besides trying to figure out how to convert a luabind::object into a luabind::adl::argument… Here is some example code that should illustrate the problem: class BaseClass { public: virtual ~BaseClass() {} std::string getClassName(lua_State* L); // ... more stuff... }; class BaseClass_wrapper : public BaseClass, public luabind::wrap_base { // ... some stuff... }; std::string BaseClass::getClassName(lua_State* L) { BaseClass_wrapper* p = dynamic_cast<BaseClass_wrapper*>(this); std::string className("UNKNOWN"); if (p != 0) { luabind::object myObject(L, p); luabind::class_info info = luabind::get_class_info(myObject); // no good! // no viable conversion from 'luabind::object' to 'const luabind::adl::argument' className = info.name; } return className; } Thanks for any suggestions, Glen. ------------------------------------------------------------------------------ Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more! Discover the easy way to master current and previous Microsoft technologies and advance your career. Get an incredible 1,500+ hours of step-by-step tutorial videos with LearnDevNow. Subscribe today and save! <http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk_______________________________________________> http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk_______________________________________________ luabind-user mailing list <mailto:lua...@li...> lua...@li... <https://lists.sourceforge.net/lists/listinfo/luabind-user> https://lists.sourceforge.net/lists/listinfo/luabind-user |
From: Glen F. <hol...@gm...> - 2013-08-28 15:38:23
|
Thanks, Christian, but I didn't manage to get anything to work in the way you describe. I can't seem to simply substitute 'object' with 'argument'… I also tried using myObject.push(L), then using the "from_stack" referenced argument to call get_class_info(), then doing a lua_pop(), but that just crashes on me (a bit later on)…and before that, it hasn't returned the correct class_info structure. I think I'd need to see a simple example, sorry. On the other hand, the "hacky" code from Eduard (see his earlier reply) does seem to work fine, as does another approach I came up with, where I just use luabind::call_function() to call the bound "class_info" function in Lua, then get the class_info structure by doing object_cast on the returned object. Of course, this may be (?) a bit less efficient than doing the direct stack-fiddling you guys suggest, but it works. Thanks, Glen. On Aug 28, 2013, at 4:07 PM, "Christian" <cn...@gm...> wrote: > Just replace luabind::object with luabind::argument in your code. They work both the same, only that the first stores the referenced object in the registry, while the latter just leaves it on the stack. > > If you ever have to convert one into another, just use the ones push() method and the others from_stack constructor (but avoid relative indices with luabind::argument). > > From: Glen Fraser [mailto:hol...@gm...] > Sent: Wednesday, August 28, 2013 1:09 PM > To: lua...@li... > Subject: [luabind] How to get Lua class name from C++ class? > > Hello there, I'm using luabind and trying to get the Lua subclass name from an instance of the base class in C++. > > I want to use get_class_info(), but it expects an "argument" rather than an "object". Perhaps there is a better way to do this, besides trying to figure out how to convert a luabind::object into a luabind::adl::argument… Here is some example code that should illustrate the problem: > > class BaseClass { > public: > virtual ~BaseClass() {} > std::string getClassName(lua_State* L); > // ... more stuff... > }; > > class BaseClass_wrapper : public BaseClass, public luabind::wrap_base { > // ... some stuff... > }; > > std::string BaseClass::getClassName(lua_State* L) > { > BaseClass_wrapper* p = dynamic_cast<BaseClass_wrapper*>(this); > std::string className("UNKNOWN"); > if (p != 0) { > luabind::object myObject(L, p); > luabind::class_info info = luabind::get_class_info(myObject); // no good! > // no viable conversion from 'luabind::object' to 'const luabind::adl::argument' > className = info.name; > } > return className; > } > > > Thanks for any suggestions, > Glen. > > ------------------------------------------------------------------------------ > Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more! > Discover the easy way to master current and previous Microsoft technologies > and advance your career. Get an incredible 1,500+ hours of step-by-step > tutorial videos with LearnDevNow. Subscribe today and save! > http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk_______________________________________________ > luabind-user mailing list > lua...@li... > https://lists.sourceforge.net/lists/listinfo/luabind-user |
From: Christian <cn...@gm...> - 2013-08-28 14:07:26
|
Just replace luabind::object with luabind::argument in your code. They work both the same, only that the first stores the referenced object in the registry, while the latter just leaves it on the stack. If you ever have to convert one into another, just use the ones push() method and the others from_stack constructor (but avoid relative indices with luabind::argument). From: Glen Fraser [mailto:hol...@gm...] Sent: Wednesday, August 28, 2013 1:09 PM To: lua...@li... Subject: [luabind] How to get Lua class name from C++ class? Hello there, I'm using luabind and trying to get the Lua subclass name from an instance of the base class in C++. I want to use get_class_info(), but it expects an "argument" rather than an "object". Perhaps there is a better way to do this, besides trying to figure out how to convert a luabind::object into a luabind::adl::argument… Here is some example code that should illustrate the problem: class BaseClass { public: virtual ~BaseClass() {} std::string getClassName(lua_State* L); // ... more stuff... }; class BaseClass_wrapper : public BaseClass, public luabind::wrap_base { // ... some stuff... }; std::string BaseClass::getClassName(lua_State* L) { BaseClass_wrapper* p = dynamic_cast<BaseClass_wrapper*>(this); std::string className("UNKNOWN"); if (p != 0) { luabind::object myObject(L, p); luabind::class_info info = luabind::get_class_info(myObject); // no good! // no viable conversion from 'luabind::object' to 'const luabind::adl::argument' className = info.name; } return className; } Thanks for any suggestions, Glen. |
From: eduard m. <mue...@go...> - 2013-08-28 12:06:52
|
Hey, you can use the "private" luabind::detail::object_rep* luabind::detail::get_instance(lua_State* L, int index) here instead. This is quite a hack, but we at found no other "official" way on doing this within a wrap_base: std::string BaseClass::getClassName(lua_State* L) { luabind::detail::wrap_access::ref(*this).get(L); luabind::detail::object_rep* pObjectRep = luabind::detail::get_instance(L, -1); ::lua_pop(L, 1); //ref.get if (pObjectRep) { return std::string (pObjectRep->crep()->name()); } else { throw std::runtime_error( "Internal Error: failed to resolve a Lua wrapper class name"); } } Hope this helps. Best regards, Eduard On Wed, Aug 28, 2013 at 1:09 PM, Glen Fraser <hol...@gm...> wrote: > > Hello there, I'm using luabind and trying to get the Lua subclass name from an instance of the base class in C++. > > I want to use get_class_info(), but it expects an "argument" rather than an "object". Perhaps there is a better way to do this, besides trying to figure out how to convert a luabind::object into a luabind::adl::argument… Here is some example code that should illustrate the problem: > > class BaseClass { > public: > virtual ~BaseClass() {} > std::string getClassName(lua_State* L); > // ... more stuff... > }; > > class BaseClass_wrapper : public BaseClass, public luabind::wrap_base { > // ... some stuff... > }; > > std::string > BaseClass::getClassName(lua_State* L) > { > BaseClass_wrapper* p = dynamic_cast<BaseClass_wrapper*>(this); > std::string className("UNKNOWN"); > if (p != 0) { > luabind::object myObject(L, p); > luabind::class_info info = luabind::get_class_info(myObject); // no good! > // no viable conversion from 'luabind::object' to 'const luabind::adl::argument' > className = info.name; > } > return className; > } > > > Thanks for any suggestions, > Glen. > > > ------------------------------------------------------------------------------ > Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more! > Discover the easy way to master current and previous Microsoft technologies > and advance your career. Get an incredible 1,500+ hours of step-by-step > tutorial videos with LearnDevNow. Subscribe today and save! > http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk > _______________________________________________ > luabind-user mailing list > lua...@li... > https://lists.sourceforge.net/lists/listinfo/luabind-user > |