Git Product home page Git Product logo

luabind-deboostified's Introduction

luabind

This is a customized luabind fork that's used by X-Ray Engine. Comparing to the old version (presumably beta7-devel-rc4) previously used in X-Ray, this version speeds up xrGame (the most heavy engine module) compilation by about 100%.

Currently, at least the following compilers are supported:

  • MSVC 2015
  • Clang/LLVM 3.6.0
  • G++ 4.9

If you can confirm support on another platform, please let me know!

Create Lua bindings for your C++ code easily - my improvements

  • Variadic templates.
  • Got rid of the arrays created in invoke.
  • All boost removed.
  • No backward compatibility to any old or faulty (MS) compilers.
  • This is 24mb of Intellisense db versus close to 90mb with original luabind, also Intellisense is not crippled by boost preprocessor usage.

Important: This is not drop in replacable.

  • The template parameters to class class_ work a bit differently to the original (Wrapper and Holder have a specific index, if you don't want one of them, use null_type and/or no_bases)
  • The policies are not implemented as functions with a wrapped integer argument, they're aliases to policy lists containing exactly the one respective policy
  • The error callback is no longer the function that is pushed as pcall's error handler, but is instead called to push the error handler onto the stack
  • Exceptions thrown by luabind will now carry the error message, it no longer has to be pulled from the lua stack separately
  • Since the requirement to Boost.Optional has been dropped, object_cast_nothrow now has a mandatory default argument that is returned when the cast failed. Use boost::optional() for that to get the old behavior

luabind-deboostified's People

Contributors

007exe avatar acmorrow avatar arvidn avatar bagobor avatar bkchr avatar crossvr avatar cschreib avatar decimad avatar eagleivg avatar garyttierney avatar germanaizek avatar intorr avatar jaehoshim avatar jessehardy avatar kazade avatar ltjax avatar masterkatze avatar mrwonko avatar oberon00 avatar obfuscated avatar petercolberg avatar q4a avatar qweasdd136963 avatar rodsoft avatar rpavlik avatar senutar avatar shokerstlk avatar siliconkiwi avatar wohlstand avatar xottab-duty avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

luabind-deboostified's Issues

GCC: wrong number of template arguments in out_value_policy.hpp

When building on Linux with GCC following error occures:

out_value_policy.hpp:220:33: error: wrong number of template arguments (1, should be 3)
    storage_.template construct<T>();

out_value_policy.hpp:241:33: error: wrong number of template arguments (1, should be 3)
storage_.template construct<T>();

Incorrect function overloading

If you have function with default arguments, like this:

void Kill(CScriptGameObject* who, bool bypass_actor_check = false);

It would be exported to Lua as a functions that accepts two arguments, but not one. If you will try to call it with one argument it will crash.

In the previous luabind version you could use casts to fix the problem:

.def("kill", (void (CScriptGameObject::*)(CScriptGameObject*))&CScriptGameObject::Kill)
.def("kill", (void (CScriptGameObject::*)(CScriptGameObject*, bool))(&CScriptGameObject::Kill))

In this new version this doesn't help. The second parameter will be filled with trash.

Error build : error: ‘adopt_policy’ was not declared in this scope

Compiling on linux. Compiler gcc version 5.3.0 20151204 (Ubuntu 5.3.0-3ubuntu1~14.04)

CMakeFiles/test_abstract_base.dir/test_abstract_base.cpp.o: In function `luabind::detail::call_allocator(void const*, unsigned long)':
test_abstract_base.cpp:(.text._ZN7luabind6detail14call_allocatorEPKvm[_ZN7luabind6detail14call_allocatorEPKvm]+0x13): undefined reference to `luabind::allocator'
test_abstract_base.cpp:(.text._ZN7luabind6detail14call_allocatorEPKvm[_ZN7luabind6detail14call_allocatorEPKvm]+0x1a): undefined reference to `luabind::allocator_context'
collect2: error: ld returned 1 exit status
make[2]: *** [test/test_abstract_base] Error 1
make[1]: *** [test/CMakeFiles/test_abstract_base.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
CMakeFiles/test_attributes.dir/test_attributes.cpp.o: In function `luabind::detail::call_allocator(void const*, unsigned long)':
test_attributes.cpp:(.text._ZN7luabind6detail14call_allocatorEPKvm[_ZN7luabind6detail14call_allocatorEPKvm]+0x13): undefined reference to `luabind::allocator'
test_attributes.cpp:(.text._ZN7luabind6detail14call_allocatorEPKvm[_ZN7luabind6detail14call_allocatorEPKvm]+0x1a): undefined reference to `luabind::allocator_context'
collect2: error: ld returned 1 exit status
make[2]: *** [test/test_attributes] Error 1
make[1]: *** [test/CMakeFiles/test_attributes.dir/all] Error 2
/home/razor/Documents/luabind-deboostified/test/test_adopt_wrapper.cpp: In function ‘void test_main(lua_State*)’:
/home/razor/Documents/luabind-deboostified/test/test_adopt_wrapper.cpp:34:28: error: ‘adopt_policy’ was not declared in this scope
         def("make", &make, adopt_policy<0>()),
                            ^
/home/razor/Documents/luabind-deboostified/test/test_adopt_wrapper.cpp:34:44: error: expected primary-expression before ‘)’ token
         def("make", &make, adopt_policy<0>()),
                                            ^
/home/razor/Documents/luabind-deboostified/test/test_adopt_wrapper.cpp:35:44: error: expected primary-expression before ‘)’ token
         def("take", &take, adopt_policy<1>())
                                            ^
/home/razor/Documents/luabind-deboostified/test/test_adopt.cpp: In function ‘void test_main(lua_State*)’:
/home/razor/Documents/luabind-deboostified/test/test_adopt.cpp:57:42: error: ‘adopt_policy’ was not declared in this scope
   def("take_ownership", &take_ownership, adopt_policy<1>()),
                                          ^
/home/razor/Documents/luabind-deboostified/test/test_adopt.cpp:57:58: error: expected primary-expression before ‘)’ token
   def("take_ownership", &take_ownership, adopt_policy<1>()),
                                                          ^
make[2]: *** [test/CMakeFiles/test_adopt_wrapper.dir/test_adopt_wrapper.cpp.o] Error 1
make[1]: *** [test/CMakeFiles/test_adopt_wrapper.dir/all] Error 2
make[2]: *** [test/CMakeFiles/test_adopt.dir/test_adopt.cpp.o] Error 1
make[1]: *** [test/CMakeFiles/test_adopt.dir/all] Error 2
make: *** [all] Error 2

Permissive mode

The previous version of luabind was very permissive for script errors.
For example, you have a function and it is exported to Lua:

void func(int arg1, int arg2); // functions itself

def("func", &func) // export

If you pass to this functions wrong parameters, like this:

func("__") -- Passing string instead of a number. This is wrong!!!
		   -- The second argument is forgotten. This is wrong too!!!

Nothing will happen. The script just hang and that's all. No crash will proceed.

But in this new version it crashes on every error and doesn't have a permissive mode, which is bad for compatibility.

We should add some sort of permissive mode that ignores the errors like it was before.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.