diff options
| author | Li Jin <dragon-fly@qq.com> | 2021-03-03 21:31:01 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2021-03-03 21:33:37 +0800 |
| commit | 1df786307c1983b8ce693e3916081a8bcd4e95ae (patch) | |
| tree | 6c7aeb2198d825877fd3d179c394b7a5c1f06a17 /src/lua/luaconf.h | |
| parent | 66168b112b707172b9035edf8c1daed469781e06 (diff) | |
| download | yuescript-1df786307c1983b8ce693e3916081a8bcd4e95ae.tar.gz yuescript-1df786307c1983b8ce693e3916081a8bcd4e95ae.tar.bz2 yuescript-1df786307c1983b8ce693e3916081a8bcd4e95ae.zip | |
add new metatable syntax for issue #41, fix reusing local variable issue, update built-in Lua.
Diffstat (limited to '')
| -rw-r--r-- | src/lua/luaconf.h | 103 |
1 files changed, 62 insertions, 41 deletions
diff --git a/src/lua/luaconf.h b/src/lua/luaconf.h index d9cf18c..ae73e2f 100644 --- a/src/lua/luaconf.h +++ b/src/lua/luaconf.h | |||
| @@ -16,13 +16,13 @@ | |||
| 16 | ** =================================================================== | 16 | ** =================================================================== |
| 17 | ** General Configuration File for Lua | 17 | ** General Configuration File for Lua |
| 18 | ** | 18 | ** |
| 19 | ** Some definitions here can be changed externally, through the | 19 | ** Some definitions here can be changed externally, through the compiler |
| 20 | ** compiler (e.g., with '-D' options). Those are protected by | 20 | ** (e.g., with '-D' options): They are commented out or protected |
| 21 | ** '#if !defined' guards. However, several other definitions should | 21 | ** by '#if !defined' guards. However, several other definitions |
| 22 | ** be changed directly here, either because they affect the Lua | 22 | ** should be changed directly here, either because they affect the |
| 23 | ** ABI (by making the changes here, you ensure that all software | 23 | ** Lua ABI (by making the changes here, you ensure that all software |
| 24 | ** connected to Lua, such as C libraries, will be compiled with the | 24 | ** connected to Lua, such as C libraries, will be compiled with the same |
| 25 | ** same configuration); or because they are seldom changed. | 25 | ** configuration); or because they are seldom changed. |
| 26 | ** | 26 | ** |
| 27 | ** Search for "@@" to find all configurable definitions. | 27 | ** Search for "@@" to find all configurable definitions. |
| 28 | ** =================================================================== | 28 | ** =================================================================== |
| @@ -81,27 +81,13 @@ | |||
| 81 | 81 | ||
| 82 | /* | 82 | /* |
| 83 | ** {================================================================== | 83 | ** {================================================================== |
| 84 | ** Configuration for Number types. | 84 | ** Configuration for Number types. These options should not be |
| 85 | ** set externally, because any other code connected to Lua must | ||
| 86 | ** use the same configuration. | ||
| 85 | ** =================================================================== | 87 | ** =================================================================== |
| 86 | */ | 88 | */ |
| 87 | 89 | ||
| 88 | /* | 90 | /* |
| 89 | @@ LUA_32BITS enables Lua with 32-bit integers and 32-bit floats. | ||
| 90 | */ | ||
| 91 | /* #define LUA_32BITS */ | ||
| 92 | |||
| 93 | |||
| 94 | /* | ||
| 95 | @@ LUA_C89_NUMBERS ensures that Lua uses the largest types available for | ||
| 96 | ** C89 ('long' and 'double'); Windows always has '__int64', so it does | ||
| 97 | ** not need to use this case. | ||
| 98 | */ | ||
| 99 | #if defined(LUA_USE_C89) && !defined(LUA_USE_WINDOWS) | ||
| 100 | #define LUA_C89_NUMBERS | ||
| 101 | #endif | ||
| 102 | |||
| 103 | |||
| 104 | /* | ||
| 105 | @@ LUA_INT_TYPE defines the type for Lua integers. | 91 | @@ LUA_INT_TYPE defines the type for Lua integers. |
| 106 | @@ LUA_FLOAT_TYPE defines the type for Lua floats. | 92 | @@ LUA_FLOAT_TYPE defines the type for Lua floats. |
| 107 | ** Lua should work fine with any mix of these options supported | 93 | ** Lua should work fine with any mix of these options supported |
| @@ -121,7 +107,31 @@ | |||
| 121 | #define LUA_FLOAT_DOUBLE 2 | 107 | #define LUA_FLOAT_DOUBLE 2 |
| 122 | #define LUA_FLOAT_LONGDOUBLE 3 | 108 | #define LUA_FLOAT_LONGDOUBLE 3 |
| 123 | 109 | ||
| 124 | #if defined(LUA_32BITS) /* { */ | 110 | |
| 111 | /* Default configuration ('long long' and 'double', for 64-bit Lua) */ | ||
| 112 | #define LUA_INT_DEFAULT LUA_INT_LONGLONG | ||
| 113 | #define LUA_FLOAT_DEFAULT LUA_FLOAT_DOUBLE | ||
| 114 | |||
| 115 | |||
| 116 | /* | ||
| 117 | @@ LUA_32BITS enables Lua with 32-bit integers and 32-bit floats. | ||
| 118 | */ | ||
| 119 | #define LUA_32BITS 0 | ||
| 120 | |||
| 121 | |||
| 122 | /* | ||
| 123 | @@ LUA_C89_NUMBERS ensures that Lua uses the largest types available for | ||
| 124 | ** C89 ('long' and 'double'); Windows always has '__int64', so it does | ||
| 125 | ** not need to use this case. | ||
| 126 | */ | ||
| 127 | #if defined(LUA_USE_C89) && !defined(LUA_USE_WINDOWS) | ||
| 128 | #define LUA_C89_NUMBERS 1 | ||
| 129 | #else | ||
| 130 | #define LUA_C89_NUMBERS 0 | ||
| 131 | #endif | ||
| 132 | |||
| 133 | |||
| 134 | #if LUA_32BITS /* { */ | ||
| 125 | /* | 135 | /* |
| 126 | ** 32-bit integers and 'float' | 136 | ** 32-bit integers and 'float' |
| 127 | */ | 137 | */ |
| @@ -132,26 +142,21 @@ | |||
| 132 | #endif | 142 | #endif |
| 133 | #define LUA_FLOAT_TYPE LUA_FLOAT_FLOAT | 143 | #define LUA_FLOAT_TYPE LUA_FLOAT_FLOAT |
| 134 | 144 | ||
| 135 | #elif defined(LUA_C89_NUMBERS) /* }{ */ | 145 | #elif LUA_C89_NUMBERS /* }{ */ |
| 136 | /* | 146 | /* |
| 137 | ** largest types available for C89 ('long' and 'double') | 147 | ** largest types available for C89 ('long' and 'double') |
| 138 | */ | 148 | */ |
| 139 | #define LUA_INT_TYPE LUA_INT_LONG | 149 | #define LUA_INT_TYPE LUA_INT_LONG |
| 140 | #define LUA_FLOAT_TYPE LUA_FLOAT_DOUBLE | 150 | #define LUA_FLOAT_TYPE LUA_FLOAT_DOUBLE |
| 141 | 151 | ||
| 142 | #endif /* } */ | 152 | #else /* }{ */ |
| 153 | /* use defaults */ | ||
| 143 | 154 | ||
| 155 | #define LUA_INT_TYPE LUA_INT_DEFAULT | ||
| 156 | #define LUA_FLOAT_TYPE LUA_FLOAT_DEFAULT | ||
| 144 | 157 | ||
| 145 | /* | 158 | #endif /* } */ |
| 146 | ** default configuration for 64-bit Lua ('long long' and 'double') | ||
| 147 | */ | ||
| 148 | #if !defined(LUA_INT_TYPE) | ||
| 149 | #define LUA_INT_TYPE LUA_INT_LONGLONG | ||
| 150 | #endif | ||
| 151 | 159 | ||
| 152 | #if !defined(LUA_FLOAT_TYPE) | ||
| 153 | #define LUA_FLOAT_TYPE LUA_FLOAT_DOUBLE | ||
| 154 | #endif | ||
| 155 | 160 | ||
| 156 | /* }================================================================== */ | 161 | /* }================================================================== */ |
| 157 | 162 | ||
| @@ -373,14 +378,13 @@ | |||
| 373 | 378 | ||
| 374 | /* | 379 | /* |
| 375 | ** {================================================================== | 380 | ** {================================================================== |
| 376 | ** Configuration for Numbers. | 381 | ** Configuration for Numbers (low-level part). |
| 377 | ** Change these definitions if no predefined LUA_FLOAT_* / LUA_INT_* | 382 | ** Change these definitions if no predefined LUA_FLOAT_* / LUA_INT_* |
| 378 | ** satisfy your needs. | 383 | ** satisfy your needs. |
| 379 | ** =================================================================== | 384 | ** =================================================================== |
| 380 | */ | 385 | */ |
| 381 | 386 | ||
| 382 | /* | 387 | /* |
| 383 | @@ LUA_NUMBER is the floating-point type used by Lua. | ||
| 384 | @@ LUAI_UACNUMBER is the result of a 'default argument promotion' | 388 | @@ LUAI_UACNUMBER is the result of a 'default argument promotion' |
| 385 | @@ over a floating number. | 389 | @@ over a floating number. |
| 386 | @@ l_floatatt(x) corrects float attribute 'x' to the proper float type | 390 | @@ l_floatatt(x) corrects float attribute 'x' to the proper float type |
| @@ -473,10 +477,7 @@ | |||
| 473 | 477 | ||
| 474 | 478 | ||
| 475 | /* | 479 | /* |
| 476 | @@ LUA_INTEGER is the integer type used by Lua. | ||
| 477 | ** | ||
| 478 | @@ LUA_UNSIGNED is the unsigned version of LUA_INTEGER. | 480 | @@ LUA_UNSIGNED is the unsigned version of LUA_INTEGER. |
| 479 | ** | ||
| 480 | @@ LUAI_UACINT is the result of a 'default argument promotion' | 481 | @@ LUAI_UACINT is the result of a 'default argument promotion' |
| 481 | @@ over a LUA_INTEGER. | 482 | @@ over a LUA_INTEGER. |
| 482 | @@ LUA_INTEGER_FRMLEN is the length modifier for reading/writing integers. | 483 | @@ LUA_INTEGER_FRMLEN is the length modifier for reading/writing integers. |
| @@ -659,6 +660,26 @@ | |||
| 659 | #define lua_getlocaledecpoint() (localeconv()->decimal_point[0]) | 660 | #define lua_getlocaledecpoint() (localeconv()->decimal_point[0]) |
| 660 | #endif | 661 | #endif |
| 661 | 662 | ||
| 663 | |||
| 664 | /* | ||
| 665 | ** macros to improve jump prediction, used mostly for error handling | ||
| 666 | ** and debug facilities. | ||
| 667 | */ | ||
| 668 | #if (defined(LUA_CORE) || defined(LUA_LIB)) && !defined(l_likely) | ||
| 669 | |||
| 670 | #include <stdio.h> | ||
| 671 | #if defined(__GNUC__) | ||
| 672 | #define l_likely(x) (__builtin_expect(((x) != 0), 1)) | ||
| 673 | #define l_unlikely(x) (__builtin_expect(((x) != 0), 0)) | ||
| 674 | #else | ||
| 675 | #define l_likely(x) (x) | ||
| 676 | #define l_unlikely(x) (x) | ||
| 677 | #endif | ||
| 678 | |||
| 679 | #endif | ||
| 680 | |||
| 681 | |||
| 682 | |||
| 662 | /* }================================================================== */ | 683 | /* }================================================================== */ |
| 663 | 684 | ||
| 664 | 685 | ||
