Code Monkey home page Code Monkey logo

luabind's People

Contributors

acmorrow avatar arvidn avatar asarium avatar benjamin-l avatar dparshin avatar glehmann avatar jessehardy avatar mrwonko avatar oberon00 avatar obfuscated avatar petercolberg avatar rodsoft avatar rpavlik avatar senutar avatar siliconkiwi avatar thomasnelson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

luabind's Issues

std::shared_ptr support

Hello, I'm having some trouble std::shared_ptr smart-pointer support in luabind. It seems luabind uses luabind::detail::has_get_pointer to figure out if a type is a smart-pointer, and this does not work natively with std::shared_ptr (since that does not define a get_pointer function, at least not in VC2010). Prior to boost version 1.53.0, I worked around that by defining get_pointer in the namespaces of my pointee objects (since it isn't allowed to add anything to std::). Since boost 1.53.0 however, this no longer compiles. Boost now defines get_pointer in boost:: for std::shared_ptr, and it seems like luabind::detail::has_get_pointer either finds that one and the implementation in my pointee's namespace or none at all. In the first case it doesn't compile, in the second, if I remove my implementation, luabind seems to treat the shared_ptr as a base class which isn't registered and gives me a runtime-error.
The only fix I found was to add a partial specialization like this:

template<class T>
struct has_get_pointer<std::shared_ptr<T>> : boost::mpl::true_ {};

Is this a proper fix, or am I misunderstanding something?

C++ 11 exception

luabind call_function throw exception on destructor, but on C++ 11 this is default no throw.So you cannot catch exception.

Please 1. remove boost dependency 2. remove c++11 dependency

Hi,

I'd like to have the ability to do the following, ideally:

  1. call c++ from lua. This seems not so hard, eg this library probably does that. So does swig
  2. override c++ classes from lua, and have c++ call back into those. Swig doesnt do this. I heard that luabind does?
  3. not have to install boost. it's easy to install on linux, not so easy on windows
  4. be able to build using only c++0x and visual studio 2010. visual studio 2010 is the current version used by python, that I'm also linking with. c++0x is still the highest standard in many commonly available gcc versions

Failing tests on Windows

After compiling this version on Windows 8.1 VS2013, x64, I got seemingly working luabind.

However, 2 or 3 tests does fail. Maybe you will be able to locate the problems?
I use the library only to compile existing source code like OSRM, but can do any testing on my system if needed.

Boost 1.55, Lua 5.2.3 from https://github.com/LuaDist/lua , built with cmake in Visual Studio 2013 x64 command prompt.

Here is the detailed test log (ctest -V):
https://gist.github.com/alex85k/10016791#file-luabind_failing_tests-log

x86 Win32 exception issue

Wrapping the invoke-Call, including the try-catch block, inside the entry_point-method of function_object_impl with another not-inlined wrapper-function, seems to fix exception issues encountered on x86 builds for win32.

container_policy faulty

I think the container policy misses an overload to match for by_value
and more importantly, the loop that fetches the table elements from the stack has the table at position -2 (ie. index-1). I fixed that in my fork, however I don't know if this only applies to my reworked policy system.

out_value is broken

The policy "out_value" seems to be broken (for a long time?), it is also not covered by the tests (test_policies.cpp has "pure_out_value" only). The following example is copied from the luabind documentation, GCC and Clang generate an error about calling a non-static member function:

.../luabind/out_value_policy.hpp:126:71: error: cannot call member function β€˜int luabind::native_converter_base::match(lua_State*, luabind::detail::by_value, int) [with T = float; Derived = luabind::default_converter; lua_State = lua_State]’ without object
             return converter::match(L, LUABIND_DECORATE_TYPE(T), index);

Example:

#include "test.hpp"

#include 
#include 

void f(float& val) { val = val + 10.f; }

void test_main(lua_State* L)
{
    using namespace luabind;

    module(L)
    [
         def("f", &f, out_value(_1)) // compiles with "pure_out_value"
    ];

    // out_value
    DOSTRING(L,
        "a = f(5)\n"
        "assert(a == 15)");
}

Linker Error LNK2001.

"error LNK2001: unresolved external symbol "private: static unsigned int const luabind::detail::class_id_map::local_id_base" (?local_id_base@class_id_map@detail@luabind@@0ib) "

I get this when trying to compile my project using Luabind. How do I fix this? =S

Thanks!

shared_ptr use_count corruption

Luabind causes a shared_ptr corruption when you do this in lua:

local gSharedObject = nil;
function Testfunction()
    gSharedObject = SharedObject.Create();
    return gSharedObject;
end

where the C++ export looks like that:

class SharedObject {
public:
    SharedObject() {}

    static boost::shared_ptr<SharedObject> Create() {
        return boost::make_shared<SharedObject>();
    }
}

luabind::module(L) [
    luabind::class_<SharedObject, boost::shared_ptr<SharedObject>>("SharedObject")
        .scope [ luabind::def("Create", &SharedObject::Create) ]
];

Now when you do the following you will get a use_count == 1 where it should actually be 2 because lua should hold a shared_ptr and your code should:

boost::shared_ptr<SharedObject> obj = luabind::call_function<boost::shared_ptr<SharedObject>>(L, "Testfunction");
std::cout << obj.use_count() << std::endl;
// prints 1 but should actually be 2, one from the current scope and one in lua globals, because the lua state is still alive... ?!?

This is a huge problem when your GC runs because it always thinks the shared_ptr is the only one in use and it will always release objects created like that, not matter if a ptr is used by the c++ code atm.

Example:

boost::shared_ptr<SharedObject> obj = luabind::call_function<boost::shared_ptr<SharedObject>>(L, "Testfunction");
std::cout << obj.use_count() << std::endl;

lua_close(L); // invokes ~SharedObject -_-

std::cout << obj.use_count() << std::endl; // still 1

The problem exists in lua 5.1 and 5.2, everywhere I checked

Release plan?

Is it planned to bring up future releases of luabind, bundeling the progress of all the recent development efforts? And if so, what is preventing the next release?

I would like to base my other software on luabind again (and abandon the luaponte fork). Some kind of stable release would be very helpful here.

BTW, a reasonable versioning policy call "semantic versioning" has been suggested here: http://semver.org/

Luabind::open fails

Hello everyone.

I have build luabind on Window 10 with bjam, toolset msvc, 32bit latest VC++, boost 1.59.0 and Lua 5.2. When running the following code:

#include <lua.hpp>
#include <luabind/luabind.hpp>

int main()
{
    lua_State* L = luaL_newstate();

    try
    {
        luabind::open(L);
    }
    catch(std::runtime_error& e)
    {
        printf("%s\n", e.what());
    }

    return 0;
}

I get the following error:

luabind::open() must be called with the main thread lua_State*

luabind::open() calls the following function in open.cpp, line 115:

  LUABIND_API void open(lua_State* L)
    {
        bool is_main_thread = lua_pushthread(L) == 1;
        lua_pop(L, 1);

        if (!is_main_thread)
        {
            throw std::runtime_error(
                "luabind::open() must be called with the main thread "
                "lua_State*"
            );
        }

        createGarbageCollectedRegistryUserdata<detail::class_registry>(L, "__luabind_classes", L);
        createGarbageCollectedRegistryUserdata<detail::class_id_map>(L, "__luabind_class_id_map");
        createGarbageCollectedRegistryUserdata<detail::cast_graph>(L, "__luabind_cast_graph");
        createGarbageCollectedRegistryUserdata<detail::class_map>(L, "__luabind_class_map");

        // add functions (class, cast etc...)
        lua_pushcclosure(L, detail::create_class::stage1, 0);
        lua_setglobal(L, "class");

        lua_pushcclosure(L, &make_property, 0);
        lua_setglobal(L, "property");

        lua_pushlightuserdata(L, &main_thread_tag);
        lua_pushlightuserdata(L, L);
        lua_rawset(L, LUA_REGISTRYINDEX);

        lua_pushcclosure(L, &deprecated_super, 0);
        lua_setglobal(L, "super");

        //set_package_preload(L, "luabind.function_introspection", &bind_function_introspection);
    }

Might there be an issue with the following line?

bool is_main_thread = lua_pushthread(L) == 1;

I can't find anything on Google at all, that is why I am asking it here.

Problems building when lua52 is present

this issue is probably related to the way homebrew makes lua51 and lua(52) live together.

Header Library
Lua51 /usr/local/include/lua5.1/lua.h /usr/local/lib/liblua5.1.dylib
Lua(52) /usr/local/include/lua.h /usr/local/lib/liblua.dylib

So the cmake-bundled FindLua51.cmake finds lua.h and (incorrectly) sets LUA_INCLUDE_DIR to /usr/local/include, and LUA_LIBRARY to /usr/local/lib/liblua5.1.dylib. This produces all sorts of Undefined symbols for architecture... during the build phase.

Given that homebrew is (one of) Mac's preferred package manager(s) this may be an issue for lots of Mac users. Until the solution (likely making a custom FindLua51) is found, maybe we can generate a warning if both versions are found on a Mac?

runtime error when calling lua function from C++, passing a const char*

Trying to convert from luabind(the boost version) to this one, getting error at startup.

const char* path = "..\code\script?.lua;"
luabind::call_function(_State, "set_path",path);

It seems to be trying to find the class_id for "const char_", not finding anything, and then reporting that const char_ is not a registered class.

" Trying to use unregistered class: char const *"

test_exception_handlers.cpp fails to compile with clang 3.2

Trying to build with clang 3.2
I am getting this error message

In file included from ../test/test_exception_handlers.cpp:7:
In file included from ../luabind/luabind.hpp:27:
In file included from ../luabind/class.hpp:89:
../luabind/function.hpp:28:43: error: no matching function for call to 'deduce_signature'
          object fn = make_function(L, f, deduce_signature(f), policies);
                                          ^~~~~~~~~~~~~~~~
../luabind/function.hpp:48:13: note: in instantiation of member function 'luabind::detail::function_registration<void (*)() __attribute__((noreturn)), luabind::detail::null_type>::register_' requested here
        new detail::function_registration<F, Policies>(name, f, policies)));
            ^
../luabind/function.hpp:54:12: note: in instantiation of function template specialization 'luabind::def<void (*)() __attribute__((noreturn)), luabind::detail::null_type>' requested here
    return def(name, f, detail::null_type());
           ^
../test/test_exception_handlers.cpp:50:9: note: in instantiation of function template specialization 'luabind::def<void (*)() __attribute__((noreturn))>' requested here
        def("raise", &raise_my_exception),
        ^
../luabind/detail/deduce_signature.hpp:47:5: note: candidate template ignored: disabled by 'enable_if' [with F = void (*)() __attribute__((noreturn))]
    is_function<F>,
    ^
../luabind/detail/deduce_signature.hpp:60:1: note: candidate function template not viable: requires 2 arguments, but 1 was provided
deduce_signature(F, Wrapped*)
^
1 error generated.

Where to follow luabind development?

Hi,

There are numerous forks from the luabind repository. An I do believe this one seems to be the reference from other development done around.

Who is in charge now of taking care of pull requests, releases, etc?
Is there anybody left on the boat? :)

Would there be a possibility to gather the multiple efforts done there?

Best regards,

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.