diff options
Diffstat (limited to 'compat53')
| -rw-r--r-- | compat53/module.lua | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/compat53/module.lua b/compat53/module.lua index 52b1dd6..6133a34 100644 --- a/compat53/module.lua +++ b/compat53/module.lua | |||
| @@ -826,7 +826,20 @@ if lua_version < "5.3" then | |||
| 826 | end | 826 | end |
| 827 | end -- not luajit | 827 | end -- not luajit |
| 828 | 828 | ||
| 829 | if is_luajit then | 829 | local is_full_compat = package.loaded["compat53"] or package.loaded["compat53.init"] |
| 830 | |||
| 831 | -- When using the full `compat53.init` module, we override the global state, so | ||
| 832 | -- we can patch the FILE metatable. When using `compat53.module` on its own, however, | ||
| 833 | -- we have to choose between being compatible with the Lua 5.3 API of the file metamethods, | ||
| 834 | -- or with the pointer identity of the original LuaJIT metatable in the C API (see issue #70). | ||
| 835 | -- We default to be Lua 5.3 API compatible, but we offer the user a choice to override this | ||
| 836 | -- by setting a special global `LUA_COMPAT53_NO_FILE_META_OVERRIDE` to `true`, prior to | ||
| 837 | -- requiring `compat53.module`. | ||
| 838 | local use_modular_compat_file_meta = is_luajit | ||
| 839 | and not is_full_compat | ||
| 840 | and not _G.LUA_COMPAT53_NO_FILE_META_OVERRIDE | ||
| 841 | |||
| 842 | if use_modular_compat_file_meta then | ||
| 830 | local compat_file_meta = {} | 843 | local compat_file_meta = {} |
| 831 | local compat_file_meta_loaded = 0 | 844 | local compat_file_meta_loaded = 0 |
| 832 | 845 | ||
