All Projects → keplerproject → Lua Compat 5.3

keplerproject / Lua Compat 5.3

Licence: mit
Compatibility module providing Lua-5.3-style APIs for Lua 5.2 and 5.1

Programming Languages

c
50402 projects - #5 most used programming language
lua
6591 projects

Projects that are alternatives of or similar to Lua Compat 5.3

Swiftuix
Extensions and additions to the standard SwiftUI library.
Stars: ✭ 4,087 (+2571.24%)
Mutual labels:  compatibility
Win7fix
Cube World Beta Compatibility DLLs for Win7_64
Stars: ✭ 26 (-83.01%)
Mutual labels:  compatibility
Revapi
Revapi is an API analysis and change tracking tool written in Java. Its focus is mainly on Java language itself but it has been specifically designed to not be limited to just Java. API is much more than just java classes - also various configuration files, schemas, etc. can contribute to it and users can become reliant on them.
Stars: ✭ 122 (-20.26%)
Mutual labels:  compatibility
Php Compat Info
Library that find out the minimum version and the extensions required for a piece of code to run
Stars: ✭ 338 (+120.92%)
Mutual labels:  compatibility
Graphene
Graphene / Graphene-SGX - a library OS for Linux multi-process applications, with Intel SGX support
Stars: ✭ 614 (+301.31%)
Mutual labels:  compatibility
Shouldiprefix
A quick overview of what CSS features to prefix
Stars: ✭ 79 (-48.37%)
Mutual labels:  compatibility
wcecl
Allows to run Windows CE applications on Windows!
Stars: ✭ 54 (-64.71%)
Mutual labels:  compatibility
Stylecow
Modern CSS to all browsers
Stars: ✭ 147 (-3.92%)
Mutual labels:  compatibility
Preact Compat
🙌 React compatibility layer for Preact.
Stars: ✭ 927 (+505.88%)
Mutual labels:  compatibility
Browsers Support Badges
Browsers support badges for GitHub
Stars: ✭ 122 (-20.26%)
Mutual labels:  compatibility
React Lifecycles Compat
Backwards compatibility polyfill for React class components
Stars: ✭ 457 (+198.69%)
Mutual labels:  compatibility
Android Scanner Compat Library
A compat library for Bluetooth Low Energy scanning on Android.
Stars: ✭ 462 (+201.96%)
Mutual labels:  compatibility
Compat.jl
Compatibility across Julia versions
Stars: ✭ 86 (-43.79%)
Mutual labels:  compatibility
Browser Compat Data
This repository contains compatibility data for Web technologies as displayed on MDN
Stars: ✭ 3,710 (+2324.84%)
Mutual labels:  compatibility
Phpcompatibility
PHP Compatibility check for PHP_CodeSniffer
Stars: ✭ 1,705 (+1014.38%)
Mutual labels:  compatibility
Browser Update
Remind users to update their browser in an unobtrusive way
Stars: ✭ 274 (+79.08%)
Mutual labels:  compatibility
Yapypy
Yet another Python Python
Stars: ✭ 77 (-49.67%)
Mutual labels:  compatibility
Obsolete Webpack Plugin
🌈 A Webpack plugin generates a browser-side standalone script that detects browser compatibility based on `Browserslist` and prompts website users to upgrade it.
Stars: ✭ 148 (-3.27%)
Mutual labels:  compatibility
Caniuse.email
HTML and CSS Compatibility tables for emails
Stars: ✭ 133 (-13.07%)
Mutual labels:  compatibility
Fingerprintdialogcompat
FingerprintDialog from Android 28 (P) back ported to Android 23 (M).
Stars: ✭ 103 (-32.68%)
Mutual labels:  compatibility

Compat53 Status Bit32 Status

lua-compat-5.3

Lua-5.3-style APIs for Lua 5.2 and 5.1.

What is it

This is a small module that aims to make it easier to write code in a Lua-5.3-style that is compatible with Lua 5.1, Lua 5.2, and Lua 5.3. This does not make Lua 5.2 (or even Lua 5.1) entirely compatible with Lua 5.3, but it brings the API closer to that of Lua 5.3.

It includes:

  • For writing Lua: The Lua module compat53, which can be require'd from Lua scripts and run in Lua 5.1, 5.2, and 5.3, including a backport of the utf8 module, the 5.3 table module, and the string packing functions straight from the Lua 5.3 sources.
  • For writing C: A C header and file which can be linked to your Lua module written in C, providing some functions from the C API of Lua 5.3 that do not exist in Lua 5.2 or 5.1, making it easier to write C code that compiles with all three versions of liblua.

How to use it

Lua module

require("compat53")

compat53 makes changes to your global environment and does not return a meaningful return value, so the usual idiom of storing the return of require in a local variable makes no sense.

When run under Lua 5.3+, this module does nothing.

When run under Lua 5.2 or 5.1, it replaces some of your standard functions and adds new ones to bring your environment closer to that of Lua 5.3. It also tries to load the backported utf8, table, and string packing modules automatically. If unsuccessful, pure Lua versions of the new table functions are used as a fallback, and Roberto's struct library is tried for string packing.

Lua submodules

local _ENV = require("compat53.module")
if setfenv then setfenv(1, _ENV) end

The compat53.module module does not modify the global environment, and so it is safe to use in modules without affecting other Lua files. It is supposed to be set as the current environment (see above), i.e. cherry picking individual functions from this module is expressly not supported!). Not all features are available when using this module (e.g. yieldable (x)pcall support, string/file methods, etc.), so it is recommended to use plain require("compat53") whenever possible.

C code

There are two ways of adding the C API compatibility functions/macros to your project:

  • If COMPAT53_PREFIX is not #defined, compat-5.3.h #includes compat-5.3.c, and all functions are made static. You don't have to compile/link/add compat-5.3.c yourself. This is useful for one-file projects.
  • If COMPAT53_PREFIX is #defined, all exported functions are renamed behind the scenes using this prefix to avoid linker conflicts with other code using this package. This doesn't change the way you call the compatibility functions in your code. You have to compile and link compat-5.3.c to your project yourself. You can change the way the functions are exported using the COMPAT53_API macro (e.g. if you need some __declspec magic). While it is technically possible to use the "lua" prefix (and it looks better in the debugger), this is discouraged because LuaJIT has started to implement its own Lua 5.2+ C API functions, and with the "lua" prefix you'd violate the one-definition rule with recent LuaJIT versions.

What's implemented

Lua

  • the utf8 module backported from the Lua 5.3 sources
  • string.pack, string.packsize, and string.unpack from the Lua 5.3 sources or from the struct module. (struct is not 100% compatible to Lua 5.3's string packing!) (See here)
  • math.maxinteger and math.mininteger, math.tointeger, math.type, and math.ult (see here)
  • assert accepts non-string error messages
  • ipairs respects __index metamethod
  • table.move
  • table library respects metamethods

For Lua 5.1 additionally:

  • load and loadfile accept mode and env parameters
  • table.pack and table.unpack
  • string patterns may contain embedded zeros (but see here)
  • string.rep accepts sep argument
  • string.format calls tostring on arguments for %s
  • math.log accepts base argument
  • xpcall takes additional arguments
  • pcall and xpcall can execute functions that yield (see here for a possible problem with coroutine.running)
  • pairs respects __pairs metamethod (see here)
  • rawlen (but # still doesn't respect __len for tables)
  • package.searchers as alias for package.loaders
  • package.searchpath (see here)
  • coroutine functions dealing with the main coroutine (see here for a possible problem with coroutine.running)
  • coroutine.create accepts functions written in C
  • return code of os.execute (see here)
  • io.write and file:write return file handle
  • io.lines and file:lines accept format arguments (like io.read) (see here and here)
  • debug.setmetatable returns object
  • debug.getuservalue (see here)
  • debug.setuservalue (see here)

C

  • lua_KContext (see here)
  • lua_KFunction (see here)
  • lua_dump (extra strip parameter, ignored, see here)
  • lua_getextraspace (limited compatibilitiy, see here)
  • lua_getfield (return value)
  • lua_geti and lua_seti
  • lua_getglobal (return value)
  • lua_getmetafield (return value)
  • lua_gettable (return value)
  • lua_getuservalue (limited compatibility, see here)
  • lua_setuservalue (limited compatibility, see here)
  • lua_isinteger
  • lua_numbertointeger
  • lua_callk and lua_pcallk (limited compatibility, see here)
  • lua_resume
  • lua_rawget and lua_rawgeti (return values)
  • lua_rawgetp and lua_rawsetp
  • luaL_requiref (now checks package.loaded first)
  • lua_rotate
  • lua_stringtonumber (see here)

For Lua 5.1 additionally:

  • LUA_OK
  • LUA_ERRGCMM
  • LUA_OP* macros for lua_arith and lua_compare
  • LUA_FILEHANDLE
  • lua_Unsigned
  • luaL_Stream (limited compatibility, see here)
  • lua_absindex
  • lua_arith (see here)
  • lua_compare
  • lua_len, lua_rawlen, and luaL_len
  • lua_load (mode argument)
  • lua_pushstring, lua_pushlstring (return value)
  • lua_copy
  • lua_pushglobaltable
  • luaL_testudata
  • luaL_setfuncs, luaL_newlibtable, and luaL_newlib
  • luaL_setmetatable
  • luaL_getsubtable
  • luaL_traceback
  • luaL_execresult
  • luaL_fileresult
  • luaL_loadbufferx
  • luaL_loadfilex
  • luaL_checkversion (with empty body, only to avoid compile errors, see here)
  • luaL_tolstring
  • luaL_buffinitsize, luaL_prepbuffsize, and luaL_pushresultsize (see here)
  • lua_pushunsigned, lua_tounsignedx, lua_tounsigned, luaL_checkunsigned, luaL_optunsigned, if LUA_COMPAT_APIINTCASTS is defined.

What's not implemented

  • bit operators
  • integer division operator
  • utf8 escape sequences
  • 64 bit integers
  • coroutine.isyieldable
  • Lua 5.1: _ENV, goto, labels, ephemeron tables, etc. See lua-compat-5.2 for a detailed list.
  • the following C API functions/macros:
    • lua_isyieldable
    • lua_arith (new operators missing)
    • lua_push(v)fstring (new formats missing)
    • lua_upvalueid (5.1)
    • lua_upvaluejoin (5.1)
    • lua_version (5.1)
    • lua_yieldk (5.1)

See also

  • For Lua-5.2-style APIs under Lua 5.1, see lua-compat-5.2, which also is the basis for most of the code in this project.
  • For Lua-5.1-style APIs under Lua 5.0, see Compat-5.1

Credits

This package contains code written by:

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].