Giter Site home page Giter Site logo

Comments (3)

Unril avatar Unril commented on May 15, 2024

I think it can be fixed using something like this:

template <typename TRef>
struct lua_type_traits<
    TRef, typename traits::enable_if<
              traits::is_lvalue_reference<TRef>::value &&
              !traits::is_function<typename traits::remove_reference<TRef>::type>::value &&
              !traits::is_const_reference<TRef>::value>::type> {

    typedef typename traits::remove_reference<TRef>::type T;
    typedef void Registerable;

    typedef T &get_type;
    typedef T &push_type;

    static bool strictCheckType(lua_State *l, int index) {
        return object_wrapper(l, index, metatableName<T>()) != nullptr;
    }

    static bool checkType(lua_State *l, int index) {
        int type = lua_type(l, index);
        if (type == LUA_TLIGHTUSERDATA) {
            return true;
        }
        return object_wrapper(l, index, metatableName<T>()) != nullptr;
    }

    static get_type get(lua_State *l, int index) {
        return *get_pointer(l, index, types::typetag<T>());
    }

    static int push(lua_State *l, push_type v) {
        if (!available_metatable<T>(l)) {
            lua_pushlightuserdata(l, &v);
        } else {
            typedef ObjectPointerWrapper<T> wrapper_type;
            void *storage = lua_newuserdata(l, sizeof(wrapper_type));
            new (storage) wrapper_type(&v);
            class_userdata::setmetatable<T>(l);
        }
        return 1;
    }
};

from kaguya.

Unril avatar Unril commented on May 15, 2024

In 4c19986 you forget about LUA_TLIGHTUSERDATA I think.

from kaguya.

satoren avatar satoren commented on May 15, 2024

thanks!

from kaguya.

Related Issues (20)

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.