oldfisher / lua-api-pp Goto Github PK
View Code? Open in Web Editor NEWLua API wrapper for C++11
License: Other
Lua API wrapper for C++11
License: Other
How are you think about it
Hello,
while working on performance comparison for different lua bindings libraries (https://github.com/bagobor/cpp2lua-buindings-battle) I found that lua-api-pp failed to build with VS2015 + Lua 5.2 and latest boost.
I created separate fork for testing:
https://github.com/bagobor/lua-api-pp (with premake script and git-submodules for boost and lua)
build log:
https://gist.github.com/bagobor/80e8a647dee8e94d10b5
I'm using visual studio 2015 (msbuild) and having an issue with wrapping function calls.
I have a function that looks like this:
GetMethodFromModule(module_name, method_name).pcall(std::forward<Args>(args)...);
How do I actually check for an error, pcall returns a lazy, and I've tried explicitly setting it to a lua::Value but it doesn't seem to give me what I want.
I can do
auto error = GetMethodFromModule(module_name, method_name).pcall(std::forward<Args>(args)...).cast<std::string>();
But then I'll get a bad cast if there is no error.
Any suggestions of how to get the error out of the pcall method?
Is it possible to wrap std::vector types (ideally just float, string, int etc...) to automatically convert to tables? This library is great but I feel this is something it's possibly missing. I'm just looking to be able to do something like:
std::vector read_list(size_t count);
void write_list(std::vector list);
...
c.global["read_list"] = read_list;
c.global["write_list"] = write_list;
I'll look into seeing if it's something I can maybe try developing myself but was just wondering if anyone else has already either done it or at least thought about it.
Anytime this function is called, I'm getting quite verbose compile errors:
[build] ../modules/lua-api-pp/luapp/lua_impl.hxx:405:6: error: call to member function 'push' is ambiguous
[build] S.push(V);
[build] ~~^~~~
[build] ../modules/lua-api-pp/luapp/lua_lazy.hxx:442:12: note: in instantiation of member function 'lua::_::lazyImmediateValue<unsigned long>::push' requested here
[build] policy.push(S);
[build] ^
[build] ../modules/lua-api-pp/luapp/lua_impl.hxx:898:8: note: in instantiation of member function 'lua::_::Lazy<lua::_::lazyImmediateValue<unsigned long> >::push' requested here
[build] l2.push();
[build] ^
[build] ../modules/lua-api-pp/luapp/lua_operations.hxx:162:25: note: in instantiation of function template specialization 'lua::_::lazyConcatSelector::pushOnly<lua::_::Lazy<lua::_::lazyConcat<lua::_::Lazy<lua::_::lazyConcat<lua::_::Lazy<lua::_::lazyWhere>, const char *> >, unsigned long> >, const char *, unsigned long>' requested here
[build] lazyConcatSelector::pushOnly(S, L1, L2);
[build] ^
[build] ../modules/lua-api-pp/luapp/lua_lazy.hxx:454:12: note: in instantiation of member function 'lua::_::lazyConcat<lua::_::Lazy<lua::_::lazyConcat<lua::_::Lazy<lua::_::lazyConcat<lua::_::Lazy<lua::_::lazyConcat<lua::_::Lazy<lua::_::lazyWhere>, const char *> >, unsigned long> >, const char *> >, unsigned long>::pushOnly' requested here
[build] policy.pushOnly(S);
[build] ^
[build] ../modules/lua-api-pp/luapp/lua_lazy.hxx:728:10: note: in instantiation of member function 'lua::_::Lazy<lua::_::lazyConcat<lua::_::Lazy<lua::_::lazyConcat<lua::_::Lazy<lua::_::lazyConcat<lua::_::Lazy<lua::_::lazyConcat<lua::_::Lazy<lua::_::lazyWhere>, const char *> >, unsigned long> >, const char *> >, unsigned long> >::pushOnly' requested here
[build] lref.pushOnly();
[build] ^
[build] ../modules/lua-api-pp/luapp/lua_lazy.hxx:454:12: note: (skipping 5 contexts in backtrace; use -ftemplate-backtrace-limit=0 to see all)
[build] policy.pushOnly(S);
[build] ^
[build] ../modules/lua-api-pp/luapp/lua_context.hxx:767:6: note: in instantiation of member function 'lua::_::Lazy<lua::_::lazyConcat<lua::_::Lazy<lua::_::lazyConcat<lua::_::Lazy<lua::_::lazyConcat<lua::_::Lazy<lua::_::lazyConcat<lua::_::Lazy<lua::_::lazyConcat<lua::_::Lazy<lua::_::lazyWhere>, const char *> >, unsigned long> >, const char *> >, unsigned long> >, const char *> >::push' requested here
[build] l.push();
[build] ^
[build] ../modules/lua-api-pp/luapp/lua_context.hxx:684:4: note: in instantiation of function template specialization 'lua::Context::push<lua::_::lazyConcat<lua::_::Lazy<lua::_::lazyConcat<lua::_::Lazy<lua::_::lazyConcat<lua::_::Lazy<lua::_::lazyConcat<lua::_::Lazy<lua::_::lazyConcat<lua::_::Lazy<lua::_::lazyWhere>, const char *> >, unsigned long> >, const char *> >, unsigned long> >, const char *> >' requested here
[build] push(std::forward<T>(val));
[build] ^
[build] ../modules/lua-api-pp/luapp/lua_context.hxx:294:4: note: in instantiation of function template specialization 'lua::Context::ipush<lua::_::Lazy<lua::_::lazyConcat<lua::_::Lazy<lua::_::lazyConcat<lua::_::Lazy<lua::_::lazyConcat<lua::_::Lazy<lua::_::lazyConcat<lua::_::Lazy<lua::_::lazyConcat<lua::_::Lazy<lua::_::lazyWhere>, const char *> >, unsigned long> >, const char *> >, unsigned long> >, const char *> > >' requested here
[build] ipush(std::forward<MsgType>(msg));
[build] ^
[build] ../modules/lua-api-pp/luapp/lua_impl.hxx:1487:4: note: in instantiation of function template specialization 'lua::Context::error<lua::_::Lazy<lua::_::lazyConcat<lua::_::Lazy<lua::_::lazyConcat<lua::_::Lazy<lua::_::lazyConcat<lua::_::Lazy<lua::_::lazyConcat<lua::_::Lazy<lua::_::lazyConcat<lua::_::Lazy<lua::_::lazyWhere>, const char *> >, unsigned long> >, const char *> >, unsigned long> >, const char *> > >' requested here
[build] error(where() & " Insufficient number of arguments (" & nArgsExpected & " expected, " & args.size() & " passed).");
[build] ^
[build] ../modules/Script/include/Script/Observer.hpp:20:17: note: in instantiation of function template specialization 'lua::Context::requireArgs<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >' requested here
[build] context.requireArgs<std::string>(1);
[build] ^
[build] ../modules/lua-api-pp/luapp/lua_context.hxx:697:8: note: candidate function
[build] void push(bool) noexcept;
[build] ^
<and many more possible candidate functions...>
I have diagnosed it and turns out that the Context
class is lacking the following member function overloads:
void push(long val) noexcept;
void push(unsigned long val) noexcept;
It's because Context::requireArgs
and Context::requireArg
use string concatenation with the operator&
overload combined with arguments of size_t
. Adding the overloads above seems to have fixed this issue.
Hi, I'm finding C++11 Lua wrapper library. I have found sol, selene and this library. but I found some diffcult to try this library:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.