Giter Site home page Giter Site logo

luna's People

Contributors

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

luna's Issues

函数调用结束后,没有把返回结果pop出来

函数调用结束后,没有把返回结果pop出来。几个类似的函数都存在相同的问题。

template <typename... ret_types, typename... arg_types>
bool lua_call_table_function(lua_State* L, std::string* err, const char table[], const char function[], std::tuple<ret_types&...>&& rets, arg_types... args) {
    lua_get_table_function(L, table, function);
    int _[] = { 0, (native_to_lua(L, args), 0)... };
    if (!lua_call_function(L, err, sizeof...(arg_types), sizeof...(ret_types)))
        return false;
    lua_to_native_mutil(L, rets, std::make_index_sequence<sizeof...(ret_types)>());
    return true;
}

当pcall失败,return false前没有把errstring 和debug.traceback pop出来,会导致栈溢出。

当pcall失败,return false前没有把errstring 和debug.traceback pop出来,会导致栈溢出。

bool lua_call_function(lua_State* L, std::string* err, int arg_count, int ret_count) {
    int func_idx = lua_gettop(L) - arg_count;
    if (func_idx <= 0 || !lua_isfunction(L, func_idx))
        return false;
    lua_getglobal(L, "debug");
    lua_getfield(L, -1, "traceback");
    lua_remove(L, -2); // remove 'debug'
    lua_insert(L, func_idx);
    if (lua_pcall(L, arg_count, ret_count, func_idx)) {
        if (err != nullptr) {
            *err = lua_tostring(L, -1);
        }
        return false;
    }
    lua_remove(L, -ret_count - 1); // remove 'traceback'
    return true;
}

varint编码会出现正0和负0

考虑解码函数

    if (number & 0x1)
    {
        number >>= 1;
        number = ~number;
        number++;
    }
    else
    {
        number >>= 1;
    }

当number = 0时,有结果= 0
当number = 1时,有结果= ~(1 >> 1) + 1 = 0xFFFFFFFF + 1 = 0
建议参照Zigzag编码修改对有符号整数的编解码。

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.