diff --git a/CMakeLists.txt b/CMakeLists.txt index 63604bd..4b975b2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,7 +35,7 @@ SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib${LIB_SUFFIX}") SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin${LIB_SUFFIX}") SET(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/bin${LIB_SUFFIX}") -SET (LIB_LUA_VER "54" CACHE STRING "Suffix of version (for library name) e.g lua54") +SET (LIB_LUA_VER "55" CACHE STRING "Suffix of version (for library name) e.g lua55") # # Include dir COPY diff --git a/Makefile b/Makefile index 6e21588..a5e96ad 100644 --- a/Makefile +++ b/Makefile @@ -45,8 +45,8 @@ TO_LIB= liblua.a TO_MAN= lua.1 luac.1 # Lua version and release. -V= 5.4 -R= $V.8 +V= 5.5 +R= $V.0 # Targets start here. all: $(PLAT) diff --git a/README.md b/README.md index 719c3c2..587070c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -This is Lua 5.4.8, released on 21 May 2025. +This is Lua 5.5.0, released on 22 Dec 2025. [![Build Status](https://dev.azure.com/codefoco/NuGets/_apis/build/status/lua?branchName=main)](https://dev.azure.com/codefoco/NuGets/_build/latest?definitionId=66&branchName=main) diff --git a/android_build/jni/Android.mk b/android_build/jni/Android.mk index d966a32..d5343c9 100755 --- a/android_build/jni/Android.mk +++ b/android_build/jni/Android.mk @@ -1,7 +1,7 @@ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_C_INCLUDES += ../include -LOCAL_MODULE := lua54 +LOCAL_MODULE := lua55 LOCAL_LDFLAGS += "-Wl,-z,max-page-size=16384" LOCAL_CFLAGS := -DLUA_USE_POSIX -DLUA_USE_C89 -DLUA_USE_LONGLONG -I../include LOCAL_SRC_FILES := \ diff --git a/android_build/jni/Application.mk b/android_build/jni/Application.mk index 079c19f..4f3f223 100755 --- a/android_build/jni/Application.mk +++ b/android_build/jni/Application.mk @@ -1,4 +1,4 @@ -APP_MODULES := lua54 +APP_MODULES := lua55 APP_PLATFORM := android-16 APP_OPTIM := release APP_ABI := armeabi-v7a arm64-v8a x86 x86_64 diff --git a/doc/contents.html b/doc/contents.html index 18b677d..b549321 100644 --- a/doc/contents.html +++ b/doc/contents.html @@ -1,7 +1,7 @@ -Lua 5.4 Reference Manual - contents +Lua 5.5 Reference Manual - contents @@ -10,8 +10,8 @@

-Lua -Lua 5.4 Reference Manual +Lua +Lua 5.5 Reference Manual

@@ -44,7 +44,7 @@

Contents

  • 2 – Basic Concepts
  • 3.4 – Expressions @@ -85,10 +85,8 @@

    Contents

  • 3.4.9 – Table Constructors
  • 3.4.10 – Function Calls
  • 3.4.11 – Function Definitions -
  • 3.4.12 – Lists of expressions, multiple results, and adjustment - +
  • 3.4.12 – Lists of Expressions, Multiple Results, and Adjustment -
  • 3.5 – Visibility Rules

  • 4 – The Application Program Interface @@ -97,7 +95,7 @@

    Contents

  • 4.2 – C Closures
  • 4.3 – Registry @@ -117,20 +115,21 @@

    Contents

  • 6 – The Standard Libraries

  • 7 – Lua Standalone @@ -151,7 +150,7 @@

    Index

    Lua functions

    -basic
    +basic
    _G
    _VERSION
    assert
    @@ -180,7 +179,7 @@

    Lua functions

    xpcall

    -coroutine
    +coroutine
    coroutine.close
    coroutine.create
    coroutine.isyieldable
    @@ -191,7 +190,7 @@

    Lua functions

    coroutine.yield

    -debug
    +debug
    debug.debug
    debug.gethook
    debug.getinfo
    @@ -210,7 +209,7 @@

    Lua functions

    debug.upvaluejoin

    -io
    +io
    io.close
    io.flush
    io.input
    @@ -238,7 +237,7 @@

    Lua functions

     

    -math
    +math
    math.abs
    math.acos
    math.asin
    @@ -249,7 +248,9 @@

     

    math.exp
    math.floor
    math.fmod
    +math.frexp
    math.huge
    +math.ldexp
    math.log
    math.max
    math.maxinteger
    @@ -268,7 +269,7 @@

     

    math.ult

    -os
    +os
    os.clock
    os.date
    os.difftime
    @@ -282,7 +283,7 @@

     

    os.tmpname

    -package
    +package
    package.config
    package.cpath
    package.loaded
    @@ -293,7 +294,7 @@

     

    package.searchpath

    -string
    +string
    string.byte
    string.char
    string.dump
    @@ -313,8 +314,9 @@

     

    string.upper

    -table
    +table
    table.concat
    +table.create
    table.insert
    table.move
    table.pack
    @@ -323,7 +325,7 @@

     

    table.unpack

    -utf8
    +utf8
    utf8.char
    utf8.charpattern
    utf8.codepoint
    @@ -366,11 +368,11 @@

    metamethods

    environment
    variables

    LUA_CPATH
    -LUA_CPATH_5_4
    +LUA_CPATH_5_5
    LUA_INIT
    -LUA_INIT_5_4
    +LUA_INIT_5_5
    LUA_PATH
    -LUA_PATH_5_4
    +LUA_PATH_5_5
    @@ -399,6 +401,7 @@

    C API

    lua_checkstack
    lua_close
    lua_closeslot
    +lua_closethread
    lua_compare
    lua_concat
    lua_copy
    @@ -444,6 +447,7 @@

    C API

    lua_newthread
    lua_newuserdatauv
    lua_next
    +lua_numbertocstring
    lua_numbertointeger
    lua_pcall
    lua_pcallk
    @@ -451,6 +455,7 @@

    C API

    lua_pushboolean
    lua_pushcclosure
    lua_pushcfunction
    +lua_pushexternalstring
    lua_pushfstring
    lua_pushglobaltable
    lua_pushinteger
    @@ -474,7 +479,6 @@

    C API

    lua_register
    lua_remove
    lua_replace
    -lua_resetthread
    lua_resume
    lua_rotate
    lua_setallocf
    @@ -529,6 +533,7 @@

    auxiliary library

    luaL_addsize
    luaL_addstring
    luaL_addvalue
    +luaL_alloc
    luaL_argcheck
    luaL_argerror
    luaL_argexpected
    @@ -563,11 +568,13 @@

    auxiliary library

    luaL_loadfile
    luaL_loadfilex
    luaL_loadstring
    +luaL_makeseed
    luaL_newlib
    luaL_newlibtable
    luaL_newmetatable
    luaL_newstate
    luaL_openlibs
    +luaL_openselectedlibs
    luaL_opt
    luaL_optinteger
    luaL_optlstring
    @@ -590,18 +597,8 @@

    auxiliary library

    luaL_unref
    luaL_where
    -

    standard library

    -luaopen_base
    -luaopen_coroutine
    -luaopen_debug
    -luaopen_io
    -luaopen_math
    -luaopen_os
    -luaopen_package
    -luaopen_string
    -luaopen_table
    -luaopen_utf8
    +LUAL_BUFFERSIZE

    constants

    @@ -610,6 +607,22 @@

    constants

    LUA_ERRMEM
    LUA_ERRRUN
    LUA_ERRSYNTAX
    +LUA_GCCOLLECT
    +LUA_GCCOUNT
    +LUA_GCCOUNTB
    +LUA_GCGEN
    +LUA_GCINC
    +LUA_GCISRUNNING
    +LUA_GCPARAM
    +LUA_GCPMAJORMINOR
    +LUA_GCPMINORMAJOR
    +LUA_GCPMINORMUL
    +LUA_GCPPAUSE
    +LUA_GCPSTEPMUL
    +LUA_GCPSTEPSIZE
    +LUA_GCRESTART
    +LUA_GCSTEP
    +LUA_GCSTOP
    LUA_HOOKCALL
    LUA_HOOKCOUNT
    LUA_HOOKLINE
    @@ -624,6 +637,7 @@

    constants

    LUA_MININTEGER
    LUA_MINSTACK
    LUA_MULTRET
    +LUA_N2SBUFFSZ
    LUA_NOREF
    LUA_OK
    LUA_OPADD
    @@ -660,7 +674,30 @@

    constants

    LUA_TUSERDATA
    LUA_USE_APICHECK
    LUA_YIELD
    -LUAL_BUFFERSIZE
    + +

    standard library

    +

    +LUA_COLIBK
    +LUA_DBLIBK
    +LUA_GLIBK
    +LUA_IOLIBK
    +LUA_LOADLIBK
    +LUA_MATHLIBK
    +LUA_OSLIBK
    +LUA_STRLIBK
    +LUA_TABLIBK
    +LUA_UTF8LIBK
    + +

    +LUA_COLIBNAME
    +LUA_DBLIBNAME
    +LUA_IOLIBNAME
    +LUA_LOADLIBNAME
    +LUA_MATHLIBNAME
    +LUA_OSLIBNAME
    +LUA_STRLIBNAME
    +LUA_TABLIBNAME
    +LUA_UTF8LIBNAME
    @@ -668,10 +705,10 @@

    constants

    diff --git a/doc/logo.gif b/doc/logo.png similarity index 100% rename from doc/logo.gif rename to doc/logo.png diff --git a/doc/manual.html b/doc/manual.html index 8239bc2..e237325 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -1,7 +1,8 @@ + -Lua 5.4 Reference Manual +Lua 5.5 Reference Manual @@ -10,8 +11,8 @@

    -Lua -Lua 5.4 Reference Manual +Lua +Lua 5.5 Reference Manual

    @@ -166,7 +167,7 @@

    2.1 – Values and Types

    Unless stated otherwise, any overflow when manipulating integer values wrap around, -according to the usual rules of two-complement arithmetic. +according to the usual rules of two's complement arithmetic. (In other words, the actual result is the unique representable integer that is equal modulo 2n to the mathematical result, @@ -190,7 +191,8 @@

    2.1 – Values and Types

    including embedded zeros ('\0'). Lua is also encoding-agnostic; it makes no assumptions about the contents of a string. -The length of any string in Lua must fit in a Lua integer. +The length of any string in Lua must fit in a Lua integer, +and the string plus a small header must fit in size_t.

    @@ -295,12 +297,105 @@

    2.1 – Values and Types

    -

    2.2 – Environments and the Global Environment

    +

    2.2 – Scopes, Variables, and Environments

    + +

    +A variable name refers to a global or a local variable according +to the declaration that is in context at that point of the code. +(For the purposes of this discussion, +a function's formal parameter is equivalent to a local variable.) + + +

    +All chunks start with an implicit declaration global *, +which declares all free names as global variables; +this preambular declaration becomes void inside the scope of any other +global declaration, +as the following example illustrates: + +

    +     X = 1       -- Ok, global by default
    +     do
    +       global Y  -- voids the implicit initial declaration
    +       Y = 1     -- Ok, Y declared as global
    +       X = 1     -- ERROR, X not declared
    +     end
    +     X = 2       -- Ok, global by default again
    +

    +So, outside any global declaration, +Lua works as global-by-default. +Inside any global declaration, +Lua works without a default: +All variables must be declared. + + +

    +Lua is a lexically scoped language. +The scope of a variable declaration begins at the first statement after +the declaration and lasts until the last non-void statement +of the innermost block that includes the declaration. +(Void statements are labels and empty statements.) + + +

    +A declaration shadows any declaration for the same name that +is in context at the point of the declaration. Inside this +shadow, any outer declaration for that name is void. +See the next example: + +

    +     global print, x
    +     x = 10                -- global variable
    +     do                    -- new block
    +       local x = x         -- new 'x', with value 10
    +       print(x)            --> 10
    +       x = x+1
    +       do                  -- another block
    +         local x = x+1     -- another 'x'
    +         print(x)          --> 12
    +       end
    +       print(x)            --> 11
    +     end
    +     print(x)              --> 10  (the global one)
    +
    + +

    +Notice that, in a declaration like local x = x, +the new x being declared is not in scope yet, +and so the x on the right-hand side refers to the outside variable. + + +

    +Because of the lexical scoping rules, +local variables can be freely accessed by functions +defined inside their scope. +A local variable used by an inner function is called an upvalue +(or external local variable, or simply external variable) +inside the inner function. + + +

    +Notice that each execution of a local statement +defines new local variables. +Consider the following example: + +

    +     a = {}
    +     local x = 20
    +     for i = 1, 10 do
    +       local y = 0
    +       a[i] = function () y = y + 1; return x + y end
    +     end
    +

    +The loop creates ten closures +(that is, ten instances of the anonymous function). +Each of these closures uses a different y variable, +while all of them share the same x. +

    As we will discuss further in §3.2 and §3.3.3, -any reference to a free name -(that is, a name not bound to any declaration) var +any reference to a global variable var is syntactically translated to _ENV.var. Moreover, every chunk is compiled in the scope of an external local variable named _ENV (see §3.3.2), @@ -310,12 +405,14 @@

    2.2 – Environments and the Global Environment

    Despite the existence of this external _ENV variable and the translation of free names, -_ENV is a completely regular name. +_ENV is a regular name. In particular, you can define new variables and parameters with that name. -Each reference to a free name uses the _ENV that is -visible at that point in the program, -following the usual visibility rules of Lua (see §3.5). +(However, you should not define _ENV as a global variable, +otherwise _ENV.var would translate to +_ENV._ENV.var and so on, in an infinite loop.) +Each reference to a global variable name uses the _ENV that is +visible at that point in the program.

    @@ -335,8 +432,8 @@

    2.2 – Environments and the Global Environment

    the default value for its _ENV variable is the global environment (see load). Therefore, by default, -free names in Lua code refer to entries in the global environment -and, therefore, they are also called global variables. +global variables in Lua code refer to entries in the global environment +and, therefore, they act as conventional global variables. Moreover, all standard libraries are loaded in the global environment and some functions there operate on that environment. You can use load (or loadfile) @@ -392,7 +489,9 @@

    2.3 – Error Handling

    is propagated with information about the error. Lua itself only generates errors whose error object is a string, but programs can generate errors with -any value as the error object. +any value as the error object, +except nil. +(Lua will change a nil as error object to a string message.) It is up to the Lua program or its host to handle such error objects. For historical reasons, an error object is often called an error message, @@ -467,7 +566,7 @@

    2.4 – Metatables and Metamethods

    You can replace the metatable of tables using the setmetatable function. You cannot change the metatable of other types from Lua code, -except by using the debug library (§6.10). +except by using the debug library (§6.11).

    @@ -477,7 +576,7 @@

    2.4 – Metatables and Metamethods

    that is, there is one single metatable for all numbers, one for all strings, etc. By default, a value has no metatable, -but the string library sets a metatable for the string type (see §6.4). +but the string library sets a metatable for the string type (see §6.5).

    @@ -490,7 +589,7 @@

    2.4 – Metatables and Metamethods