diff options
Diffstat (limited to 'src/tools.cpp')
-rw-r--r-- | src/tools.cpp | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/src/tools.cpp b/src/tools.cpp index aa95f04..4a6f2a2 100644 --- a/src/tools.cpp +++ b/src/tools.cpp | |||
@@ -104,7 +104,7 @@ void luaG_dump( lua_State* L) | |||
104 | 104 | ||
105 | for( i = 1; i <= top; ++ i) | 105 | for( i = 1; i <= top; ++ i) |
106 | { | 106 | { |
107 | int type = lua_type( L, i); | 107 | LuaType type{ lua_type_as_enum(L, i) }; |
108 | 108 | ||
109 | fprintf( stderr, "\t[%d]= (%s) ", i, lua_typename( L, type)); | 109 | fprintf( stderr, "\t[%d]= (%s) ", i, lua_typename( L, type)); |
110 | 110 | ||
@@ -1851,8 +1851,8 @@ static constexpr UniqueKey CLONABLES_CACHE_KEY{ 0xD04EE018B3DEE8F5ull }; | |||
1851 | [[nodiscard]] bool inter_copy_one(Universe* U, Dest L2, int L2_cache_i, Source L, int i, VT vt_, LookupMode mode_, char const* upName_) | 1851 | [[nodiscard]] bool inter_copy_one(Universe* U, Dest L2, int L2_cache_i, Source L, int i, VT vt_, LookupMode mode_, char const* upName_) |
1852 | { | 1852 | { |
1853 | bool ret{ true }; | 1853 | bool ret{ true }; |
1854 | int val_type = lua_type( L, i); | 1854 | LuaType val_type{ lua_type_as_enum(L, i) }; |
1855 | static int const pod_mask = (1 << LUA_TNIL) | (1 << LUA_TBOOLEAN) | (1 << LUA_TLIGHTUSERDATA) | (1 << LUA_TNUMBER) | (1 << LUA_TSTRING); | 1855 | static constexpr int pod_mask = (1 << LUA_TNIL) | (1 << LUA_TBOOLEAN) | (1 << LUA_TLIGHTUSERDATA) | (1 << LUA_TNUMBER) | (1 << LUA_TSTRING); |
1856 | STACK_GROW( L2, 1); | 1856 | STACK_GROW( L2, 1); |
1857 | STACK_CHECK_START_REL(L, 0); // L // L2 | 1857 | STACK_CHECK_START_REL(L, 0); // L // L2 |
1858 | STACK_CHECK_START_REL(L2, 0); // L // L2 | 1858 | STACK_CHECK_START_REL(L2, 0); // L // L2 |
@@ -1862,7 +1862,7 @@ static constexpr UniqueKey CLONABLES_CACHE_KEY{ 0xD04EE018B3DEE8F5ull }; | |||
1862 | DEBUGSPEW_CODE( fprintf( stderr, INDENT_BEGIN "%s %s: " INDENT_END, lua_type_names[val_type], vt_names[static_cast<int>(vt_)])); | 1862 | DEBUGSPEW_CODE( fprintf( stderr, INDENT_BEGIN "%s %s: " INDENT_END, lua_type_names[val_type], vt_names[static_cast<int>(vt_)])); |
1863 | 1863 | ||
1864 | // Non-POD can be skipped if its metatable contains { __lanesignore = true } | 1864 | // Non-POD can be skipped if its metatable contains { __lanesignore = true } |
1865 | if( ((1 << val_type) & pod_mask) == 0) | 1865 | if( ((1 << static_cast<int>(val_type)) & pod_mask) == 0) |
1866 | { | 1866 | { |
1867 | if( lua_getmetatable( L, i)) // ... mt | 1867 | if( lua_getmetatable( L, i)) // ... mt |
1868 | { | 1868 | { |
@@ -1870,7 +1870,7 @@ static constexpr UniqueKey CLONABLES_CACHE_KEY{ 0xD04EE018B3DEE8F5ull }; | |||
1870 | if( lua_isboolean( L, -1) && lua_toboolean( L, -1)) | 1870 | if( lua_isboolean( L, -1) && lua_toboolean( L, -1)) |
1871 | { | 1871 | { |
1872 | DEBUGSPEW_CODE( fprintf( stderr, INDENT_BEGIN "__lanesignore -> LUA_TNIL\n" INDENT_END)); | 1872 | DEBUGSPEW_CODE( fprintf( stderr, INDENT_BEGIN "__lanesignore -> LUA_TNIL\n" INDENT_END)); |
1873 | val_type = LUA_TNIL; | 1873 | val_type = LuaType::NIL; |
1874 | } | 1874 | } |
1875 | lua_pop( L, 2); // ... | 1875 | lua_pop( L, 2); // ... |
1876 | } | 1876 | } |
@@ -1882,7 +1882,7 @@ static constexpr UniqueKey CLONABLES_CACHE_KEY{ 0xD04EE018B3DEE8F5ull }; | |||
1882 | { | 1882 | { |
1883 | /* Basic types allowed both as values, and as table keys */ | 1883 | /* Basic types allowed both as values, and as table keys */ |
1884 | 1884 | ||
1885 | case LUA_TBOOLEAN: | 1885 | case LuaType::BOOLEAN: |
1886 | { | 1886 | { |
1887 | int const v{ lua_toboolean(L, i) }; | 1887 | int const v{ lua_toboolean(L, i) }; |
1888 | DEBUGSPEW_CODE( fprintf( stderr, "%s\n", v ? "true" : "false")); | 1888 | DEBUGSPEW_CODE( fprintf( stderr, "%s\n", v ? "true" : "false")); |
@@ -1890,7 +1890,7 @@ static constexpr UniqueKey CLONABLES_CACHE_KEY{ 0xD04EE018B3DEE8F5ull }; | |||
1890 | } | 1890 | } |
1891 | break; | 1891 | break; |
1892 | 1892 | ||
1893 | case LUA_TNUMBER: | 1893 | case LuaType::NUMBER: |
1894 | /* LNUM patch support (keeping integer accuracy) */ | 1894 | /* LNUM patch support (keeping integer accuracy) */ |
1895 | #if defined LUA_LNUM || LUA_VERSION_NUM >= 503 | 1895 | #if defined LUA_LNUM || LUA_VERSION_NUM >= 503 |
1896 | if( lua_isinteger( L, i)) | 1896 | if( lua_isinteger( L, i)) |
@@ -1909,7 +1909,7 @@ static constexpr UniqueKey CLONABLES_CACHE_KEY{ 0xD04EE018B3DEE8F5ull }; | |||
1909 | } | 1909 | } |
1910 | break; | 1910 | break; |
1911 | 1911 | ||
1912 | case LUA_TSTRING: | 1912 | case LuaType::STRING: |
1913 | { | 1913 | { |
1914 | size_t len; | 1914 | size_t len; |
1915 | char const* s = lua_tolstring( L, i, &len); | 1915 | char const* s = lua_tolstring( L, i, &len); |
@@ -1918,7 +1918,7 @@ static constexpr UniqueKey CLONABLES_CACHE_KEY{ 0xD04EE018B3DEE8F5ull }; | |||
1918 | } | 1918 | } |
1919 | break; | 1919 | break; |
1920 | 1920 | ||
1921 | case LUA_TLIGHTUSERDATA: | 1921 | case LuaType::LIGHTUSERDATA: |
1922 | { | 1922 | { |
1923 | void* p = lua_touserdata( L, i); | 1923 | void* p = lua_touserdata( L, i); |
1924 | DEBUGSPEW_CODE( fprintf( stderr, "%p\n", p)); | 1924 | DEBUGSPEW_CODE( fprintf( stderr, "%p\n", p)); |
@@ -1928,11 +1928,11 @@ static constexpr UniqueKey CLONABLES_CACHE_KEY{ 0xD04EE018B3DEE8F5ull }; | |||
1928 | 1928 | ||
1929 | /* The following types are not allowed as table keys */ | 1929 | /* The following types are not allowed as table keys */ |
1930 | 1930 | ||
1931 | case LUA_TUSERDATA: | 1931 | case LuaType::USERDATA: |
1932 | ret = inter_copy_userdata(U, L2, L2_cache_i, L, i, vt_, mode_, upName_); | 1932 | ret = inter_copy_userdata(U, L2, L2_cache_i, L, i, vt_, mode_, upName_); |
1933 | break; | 1933 | break; |
1934 | 1934 | ||
1935 | case LUA_TNIL: | 1935 | case LuaType::NIL: |
1936 | if (vt_ == VT::KEY) | 1936 | if (vt_ == VT::KEY) |
1937 | { | 1937 | { |
1938 | ret = false; | 1938 | ret = false; |
@@ -1941,18 +1941,18 @@ static constexpr UniqueKey CLONABLES_CACHE_KEY{ 0xD04EE018B3DEE8F5ull }; | |||
1941 | lua_pushnil( L2); | 1941 | lua_pushnil( L2); |
1942 | break; | 1942 | break; |
1943 | 1943 | ||
1944 | case LUA_TFUNCTION: | 1944 | case LuaType::FUNCTION: |
1945 | ret = inter_copy_function(U, L2, L2_cache_i, L, i, vt_, mode_, upName_); | 1945 | ret = inter_copy_function(U, L2, L2_cache_i, L, i, vt_, mode_, upName_); |
1946 | break; | 1946 | break; |
1947 | 1947 | ||
1948 | case LUA_TTABLE: | 1948 | case LuaType::TABLE: |
1949 | ret = inter_copy_table(U, L2, L2_cache_i, L, i, vt_, mode_, upName_); | 1949 | ret = inter_copy_table(U, L2, L2_cache_i, L, i, vt_, mode_, upName_); |
1950 | break; | 1950 | break; |
1951 | 1951 | ||
1952 | /* The following types cannot be copied */ | 1952 | /* The following types cannot be copied */ |
1953 | 1953 | ||
1954 | case 10: // LuaJIT CDATA | 1954 | case LuaType::CDATA: |
1955 | case LUA_TTHREAD: | 1955 | case LuaType::THREAD: |
1956 | ret = false; | 1956 | ret = false; |
1957 | break; | 1957 | break; |
1958 | } | 1958 | } |