fixes for renoise install

This commit is contained in:
tumillanino
2026-04-08 11:48:35 +10:00
parent ab913ad8f5
commit 1d328bcbc5
3922 changed files with 639049 additions and 4 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

View File

@@ -0,0 +1,14 @@
[Desktop Entry]
Version=1.0
Encoding=UTF-8
Name=Renoise
GenericName=Music Tracker
Comment=A music composition program
Type=Application
Categories=AudioVideo;Audio;
Exec=renoise %f
Terminal=false
StartupNotify=false
Icon=renoise
MimeType=application/x-renoise-module;application/x-renoise-rns-module;

View File

@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
<mime-type type="application/x-renoise-tool">
<comment>Extended Renoise Tool</comment>
<comment xml:lang="en">Extended Renoise Tool</comment>
<glob pattern="*.xrnx"/>
</mime-type>
<mime-type type="application/x-renoise-tool">
<comment>Extended Renoise Sound Library</comment>
<comment xml:lang="en">Extended Renoise Sound Library</comment>
<glob pattern="*.xrnl"/>
</mime-type>
<mime-type type="application/x-renoise-module">
<comment>Extended Renoise Song</comment>
<comment xml:lang="en">Extended Renoise Song</comment>
<glob pattern="*.xrns"/>
</mime-type>
<mime-type type="application/x-renoise-rns-module">
<comment>Renoise Song</comment>
<comment xml:lang="en">Renoise Song</comment>
<glob pattern="*.rns"/>
</mime-type>
<mime-type type="application/x-renoise-instrument">
<comment>Extended Renoise Instrument</comment>
<comment xml:lang="en">Extended Renoise Instrument</comment>
<glob pattern="*.xrni"/>
</mime-type>
<mime-type type="application/x-renoise-rni-instrument">
<comment>Renoise Instrument</comment>
<comment xml:lang="en">Renoise Instrument</comment>
<glob pattern="*.rni"/>
</mime-type>
<mime-type type="application/x-renoise-devicechain">
<comment>Extended Renoise Effect Chain</comment>
<comment xml:lang="en">Extended Renoise Effect Chain</comment>
<glob pattern="*.xrnt"/>
</mime-type>
<mime-type type="application/x-renoise-effect-preset">
<comment>Extended Renoise Effect Preset</comment>
<comment xml:lang="en">Extended Renoise Effect Preset</comment>
<glob pattern="*.xrdp"/>
</mime-type>
<mime-type type="application/x-renoise-modulationset">
<comment>Extended Renoise Modulation Set</comment>
<comment xml:lang="en">Extended Renoise Modulation Set</comment>
<glob pattern="*.xrno"/>
</mime-type>
<mime-type type="application/x-renoise-phrase">
<comment>Extended Renoise Phrase</comment>
<comment xml:lang="en">Extended Renoise Phrase</comment>
<glob pattern="*.xrnz"/>
</mime-type>
<mime-type type="application/x-renoise-theme">
<comment>Renoise Theme</comment>
<comment xml:lang="en">Renoise Theme</comment>
<glob pattern="*.xrnc"/>
</mime-type>
</mime-info>

View File

@@ -0,0 +1,18 @@
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -0,0 +1,549 @@
#!/bin/sh
#---------------------------------------------
# xdg-desktop-icon
#
# Utility script to install desktop items on a Linux desktop.
#
# Refer to the usage() function below for usage.
#
# Copyright 2006, Kevin Krammer <kevin.krammer@gmx.at>
# Copyright 2006, Jeremy White <jwhite@codeweavers.com>
#
# LICENSE:
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
#
#---------------------------------------------
usage()
{
cat << _USAGE
xdg-desktop-icon - command line tool for (un)installing icons to the desktop
Synopsis
xdg-desktop-icon install [--novendor] FILE
xdg-desktop-icon uninstall FILE
xdg-desktop-icon { --help | --manual | --version }
_USAGE
}
manualpage()
{
cat << _MANUALPAGE
Name
xdg-desktop-icon - command line tool for (un)installing icons to the desktop
Synopsis
xdg-desktop-icon install [--novendor] FILE
xdg-desktop-icon uninstall FILE
xdg-desktop-icon { --help | --manual | --version }
Description
The xdg-desktop-icon program can be used to install an application launcher or
other file on the desktop of the current user.
An application launcher is represented by a *.desktop file. Desktop files are
defined by the freedesktop.org Desktop Entry Specification. The most important
aspects of *.desktop files are summarized below.
Commands
install
Installs FILE to the desktop of the current user. FILE can be a *.desktop
file or any other type of file.
uninstall
Removes FILE from the desktop of the current user.
Options
--novendor
Normally, xdg-desktop-icon checks to ensure that a *.desktop file to be
installed has a vendor prefix. This option can be used to disable that
check.
A vendor prefix consists of alpha characters ([a-zA-Z]) and is terminated
with a dash ("-"). Companies and organizations are encouraged to use a word
or phrase, preferably the organizations name, for which they hold a
trademark as their vendor prefix. The purpose of the vendor prefix is to
prevent name conflicts.
--help
Show command synopsis.
--manual
Show this manualpage.
--version
Show the xdg-utils version information.
Desktop Files
An application launcher can be added to the desktop by installing a *.desktop
file. A *.desktop file consists of a [Desktop Entry] header followed by several
Key=Value lines.
A *.desktop file can provide a name and description for an application in
several different languages. This is done by adding a language code as used by
LC_MESSAGES in square brackets behind the Key. This way one can specify
different values for the same Key depending on the currently selected language.
The following keys are often used:
Value=1.0
This is a mandatory field to indicate that the *.desktop file follows the
1.0 version of the specification.
Type=Application
This is a mandatory field that indicates that the *.desktop file describes
an application launcher.
Name=Application Name
The name of the application. For example Mozilla
GenericName=Generic Name
A generic description of the application. For example Web Browser
Comment=Comment
Optional field to specify a tooltip for the application. For example Visit
websites on the Internet
Icon=Icon File
The icon to use for the application. This can either be an absolute path to
an image file or an icon-name. If an icon-name is provided an image lookup
by name is done in the user's current icon theme. The xdg-icon-resource
command can be used to install image files into icon themes. The advantage
of using an icon-name instead of an absolute path is that with an icon-name
the application icon can be provided in several different sizes as well as
in several differently themed styles.
Exec=Command Line
The command line to start the application. If the application can open
files the %f placeholder should be specified. When a file is dropped on the
application launcher the %f is replaced with the file path of the dropped
file. If multiple files can be specified on the command line the %F
placeholder should be used instead of %f. If the application is able to
open URLs in addition to local files then %u or %U can be used instead of
%f or %F.
For a complete oveview of the *.desktop file format please visit http://
www.freedesktop.org/wiki/Standards/desktop-entry-spec
Environment Variables
xdg-desktop-icon honours the following environment variables:
XDG_UTILS_DEBUG_LEVEL
Setting this environment variable to a non-zero numerical value makes
xdg-desktop-icon do more verbose reporting on stderr. Setting a higher
value increases the verbosity.
Exit Codes
An exit code of 0 indicates success while a non-zero exit code indicates
failure. The following failure codes can be returned:
1
Error in command line syntax.
2
One of the files passed on the command line did not exist.
3
A required tool could not be found.
4
The action failed.
5
No permission to read one of the files passed on the command line.
See Also
xdg-icon-resource(1)
Examples
The company ShinyThings Inc. has developed an application named "WebMirror" and
would like to add a launcher for for on the desktop. The company will use
"shinythings" as its vendor id. In order to add the application to the desktop
there needs to be a .desktop file for the application:
shinythings-webmirror.desktop:
[Desktop Entry]
Encoding=UTF-8
Type=Application
Exec=webmirror
Icon=shinythings-webmirror
Name=WebMirror
Name[nl]=WebSpiegel
Now the xdg-desktop-icon tool can be used to add the webmirror.desktop file to
the desktop:
xdg-desktop-icon install ./shinythings-webmirror.desktop
To add a README file to the desktop as well, the following command can be used:
xdg-desktop-icon install ./shinythings-README
_MANUALPAGE
}
#@xdg-utils-common@
#----------------------------------------------------------------------------
# Common utility functions included in all XDG wrapper scripts
#----------------------------------------------------------------------------
DEBUG()
{
[ -z "${XDG_UTILS_DEBUG_LEVEL}" ] && return 0;
[ ${XDG_UTILS_DEBUG_LEVEL} -lt $1 ] && return 0;
shift
echo "$@" >&2
}
#-------------------------------------------------------------
# Exit script on successfully completing the desired operation
exit_success()
{
if [ $# -gt 0 ]; then
echo "$@"
echo
fi
exit 0
}
#-----------------------------------------
# Exit script on malformed arguments, not enough arguments
# or missing required option.
# prints usage information
exit_failure_syntax()
{
if [ $# -gt 0 ]; then
echo "xdg-desktop-icon: $@" >&2
echo "Try 'xdg-desktop-icon --help' for more information." >&2
else
usage
echo "Use 'man xdg-desktop-icon' or 'xdg-desktop-icon --manual' for additional info."
fi
exit 1
}
#-------------------------------------------------------------
# Exit script on missing file specified on command line
exit_failure_file_missing()
{
if [ $# -gt 0 ]; then
echo "xdg-desktop-icon: $@" >&2
fi
exit 2
}
#-------------------------------------------------------------
# Exit script on failure to locate necessary tool applications
exit_failure_operation_impossible()
{
if [ $# -gt 0 ]; then
echo "xdg-desktop-icon: $@" >&2
fi
exit 3
}
#-------------------------------------------------------------
# Exit script on failure returned by a tool application
exit_failure_operation_failed()
{
if [ $# -gt 0 ]; then
echo "xdg-desktop-icon: $@" >&2
fi
exit 4
}
#------------------------------------------------------------
# Exit script on insufficient permission to read a specified file
exit_failure_file_permission_read()
{
if [ $# -gt 0 ]; then
echo "xdg-desktop-icon: $@" >&2
fi
exit 5
}
#------------------------------------------------------------
# Exit script on insufficient permission to read a specified file
exit_failure_file_permission_write()
{
if [ $# -gt 0 ]; then
echo "xdg-desktop-icon: $@" >&2
fi
exit 6
}
check_input_file()
{
if [ ! -e "$1" ]; then
exit_failure_file_missing "file '$1' does not exist"
fi
if [ ! -r "$1" ]; then
exit_failure_file_permission_read "no permission to read file '$1'"
fi
}
check_vendor_prefix()
{
file_label="$2"
[ -n "$file_label" ] || file_label="filename"
file=`basename "$1"`
case "$file" in
[a-zA-Z]*-*)
return
;;
esac
echo "xdg-desktop-icon: $file_label '$file' does not have a proper vendor prefix" >&2
echo 'A vendor prefix consists of alpha characters ([a-zA-Z]) and is terminated' >&2
echo 'with a dash ("-"). An example '"$file_label"' is '"'example-$file'" >&2
echo "Use --novendor to override or 'xdg-desktop-icon --manual' for additional info." >&2
exit 1
}
check_output_file()
{
# if the file exists, check if it is writeable
# if it does not exists, check if we are allowed to write on the directory
if [ -e "$1" ]; then
if [ ! -w "$1" ]; then
exit_failure_file_permission_write "no permission to write to file '$1'"
fi
else
DIR=`dirname "$1"`
if [ ! -w "$DIR" -o ! -x "$DIR" ]; then
exit_failure_file_permission_write "no permission to create file '$1'"
fi
fi
}
#----------------------------------------
# Checks for shared commands, e.g. --help
check_common_commands()
{
while [ $# -gt 0 ] ; do
parm="$1"
shift
case "$parm" in
--help)
usage
echo "Use 'man xdg-desktop-icon' or 'xdg-desktop-icon --manual' for additional info."
exit_success
;;
--manual)
manualpage
exit_success
;;
--version)
echo "xdg-desktop-icon 1.0.1"
exit_success
;;
esac
done
}
check_common_commands "$@"
[ -z "${XDG_UTILS_DEBUG_LEVEL}" ] && unset XDG_UTILS_DEBUG_LEVEL;
if [ ${XDG_UTILS_DEBUG_LEVEL-0} -lt 1 ]; then
# Be silent
xdg_redirect_output=" > /dev/null 2> /dev/null"
else
# All output to stderr
xdg_redirect_output=" >&2"
fi
#--------------------------------------
# Checks for known desktop environments
# set variable DE to the desktop environments name, lowercase
detectDE()
{
if [ x"$KDE_FULL_SESSION" = x"true" ]; then DE=kde;
elif [ x"$GNOME_DESKTOP_SESSION_ID" != x"" ]; then DE=gnome;
elif xprop -root _DT_SAVE_MODE | grep ' = \"xfce4\"$' >/dev/null 2>&1; then DE=xfce;
fi
}
#----------------------------------------------------------------------------
# kfmclient exec/openURL can give bogus exit value in KDE <= 3.5.4
# It also always returns 1 in KDE 3.4 and earlier
# Simply return 0 in such case
kfmclient_fix_exit_code()
{
version=`kde-config --version 2>/dev/null | grep KDE`
major=`echo $version | sed 's/KDE: \([0-9]\).*/\1/'`
minor=`echo $version | sed 's/KDE: [0-9]*\.\([0-9]\).*/\1/'`
release=`echo $version | sed 's/KDE: [0-9]*\.[0-9]*\.\([0-9]\).*/\1/'`
test "$major" -gt 3 && return $1
test "$minor" -gt 5 && return $1
test "$release" -gt 4 && return $1
return 0
}
[ x"$1" != x"" ] || exit_failure_syntax
action=
desktop_file=
case $1 in
install)
action=install
;;
uninstall)
action=uninstall
;;
*)
exit_failure_syntax "unknown command '$1'"
;;
esac
shift
vendor=true
while [ $# -gt 0 ] ; do
parm=$1
shift
case $parm in
--novendor)
vendor=false
;;
-*)
exit_failure_syntax "unexpected option '$parm'"
;;
*)
if [ -n "$desktop_file" ] ; then
exit_failure_syntax "unexpected argument '$parm'"
fi
if [ "$action" = "install" ] ; then
check_input_file "$parm"
fi
desktop_file=$parm
;;
esac
done
# Shouldn't happen
if [ -z "$action" ] ; then
exit_failure_syntax "command argument missing"
fi
if [ -z "$desktop_file" ] ; then
exit_failure_syntax "FILE argument missing"
fi
filetype=
case $desktop_file in
*.desktop)
filetype=desktop
if [ "$vendor" = "true" -a "$action" = "install" ] ; then
check_vendor_prefix "$desktop_file"
fi
;;
*)
filetype=other
;;
esac
my_umask=077
desktop_dir="$HOME/Desktop"
desktop_dir_kde=`kde-config --userpath desktop 2> /dev/null`
if gconftool-2 -g /apps/nautilus/preferences/desktop_is_home_dir 2> /dev/null | grep true > /dev/null; then
desktop_dir_gnome="$HOME"
# Don't create $HOME/Desktop if it doesn't exist
[ -w $desktop_dir ] || desktop_dir=
fi
if [ -n "$desktop_dir_kde" ]; then
if [ ! -d "$desktop_dir_kde" ]; then
save_umask=`umask`
umask $my_umask
mkdir -p $desktop_dir_kde
umask $save_umask
fi
# Is the KDE desktop dir != $HOME/Desktop ?
if [ x`readlink -f "$desktop_dir"` != x`readlink -f "$desktop_dir_kde"` ]; then
# If so, don't create $HOME/Desktop if it doesn't exist
[ -w $desktop_dir ] || desktop_dir=
else
desktop_dir_kde=
fi
fi
desktop_dir="$desktop_dir $desktop_dir_kde $desktop_dir_gnome"
basefile=`basename $desktop_file`
DEBUG 1 "$action $desktop_file in $desktop_dir"
case $action in
install)
save_umask=`umask`
umask $my_umask
for x in $desktop_dir ; do
mkdir -p $x
eval 'cp $desktop_file $x/$basefile'$xdg_redirect_output
done
umask $save_umask
;;
uninstall)
for x in $desktop_dir ; do
rm -f $x/$basefile
done
;;
esac
exit_success

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,837 @@
#!/bin/sh
#---------------------------------------------
# xdg-icon-resource
#
# Utility script to install icons on a Linux desktop.
#
# Refer to the usage() function below for usage.
#
# Copyright 2006, Kevin Krammer <kevin.krammer@gmx.at>
# Copyright 2006, Jeremy White <jwhite@codeweavers.com>
#
# LICENSE:
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
#
#---------------------------------------------
manualpage()
{
cat << _MANUALPAGE
Name
xdg-icon-resource - command line tool for (un)installing icon resources
Synopsis
xdg-icon-resource install [--noupdate] [--novendor] [--theme theme] [--context
context] [--mode mode] --size size icon-file [icon-name]
xdg-icon-resource uninstall [--noupdate] [--theme theme] [--context context]
[--mode mode] --size size icon-name
xdg-icon-resource forceupdate [--theme theme] [--mode mode]
xdg-icon-resource { --help | --manual | --version }
Description
The xdg-icon-resource program can be used to install icon resources into the
desktop icon system in order to illustrate menu entries, to depict desktop
icons or to graphically represent file types.
The desktop icon system identifies icons by name. Depending on the required
size, the choice of icon theme and the context in which the icon is used, the
desktop icon system locates an appropriate icon resource to depict an icon.
Icon resources can be XPM files, PNG files or SVG files.
The desktop icon system works according to the XDG Icon Theme Specification at
http://www.freedesktop.org/Standards/icon-theme-spec
Commands
install
Installs the icon file indicated by icon-file to the desktop icon system
under the name icon-name. Icon names do not have an extension. If icon-name
is not provided the name is derived from icon-file. The icon file must have
.png or .xpm as extension. If a corresponding .icon file exists in the same
location as icon-file it will be installed as well.
uninstall
Removes the icon indicated by icon-name from the desktop icon system. Note
that icon names do not have an extension.
forceupdate
Force an update of the desktop icon system. This is only useful if the last
call to xdg-icon-resource included the --noupdate option.
Options
--noupdate
Postpone updating the desktop icon system. If multiple icons are added in
sequence this flag can be used to indicate that additional changes will
follow and that it is not necassery to update the desktop icon system right
away.
--novendor
Normally, xdg-icon-resource checks to ensure that an icon file to be
installed in the apps context has a proper vendor prefix. This option can
be used to disable that check.
A vendor prefix consists of alpha characters ([a-zA-Z]) and is terminated
with a dash ("-"). Companies and organizations are encouraged to use a word
or phrase, preferably the organizations name, for which they hold a
trademark as their vendor prefix. The purpose of the vendor prefix is to
prevent name conflicts.
--theme theme
Installs or removes the icon file as part of theme. If no theme is
specified the icons will be installed as part of the default hicolor theme.
Applications may install icons under multiple themes but should at least
install icons for the default hicolor theme.
--context context
Specifies the context for the icon. Icons to be used in the application
menu and as desktop icon should use apps as context which is the default
context. Icons to be used as file icons should use mimetypes as context.
Other common contexts are actions, devices, emblems, filesystems and stock.
--size size
Specifies the size of the icon. All icons must be square. Common sizes for
icons in the apps context are: 16, 22, 32, 48, 64 and 128. Common sizes for
icons in the mimetypes context are: 16, 22, 32, 48, 64 and 128
--mode mode
mode can be user or system. In user mode the file is (un)installed for the
current user only. In system mode the file is (un)installed for all users
on the system. Usually only root is allowed to install in system mode.
The default is to use system mode when called by root and to use user mode
when called by a non-root user.
--help
Show command synopsis.
--manual
Show this manualpage.
--version
Show the xdg-utils version information.
Environment Variables
xdg-icon-resource honours the following environment variables:
XDG_UTILS_DEBUG_LEVEL
Setting this environment variable to a non-zero numerical value makes
xdg-icon-resource do more verbose reporting on stderr. Setting a higher
value increases the verbosity.
XDG_UTILS_INSTALL_MODE
This environment variable can be used by the user or administrator to
override the installation mode. Valid values are user and system.
Exit Codes
An exit code of 0 indicates success while a non-zero exit code indicates
failure. The following failure codes can be returned:
1
Error in command line syntax.
2
One of the files passed on the command line did not exist.
3
A required tool could not be found.
4
The action failed.
5
No permission to read one of the files passed on the command line.
See Also
xdg-desktop-icon(1), xdg-desktop-menu(1), xdg-mime(1)
Examples
To install an icon resource to depict a launcher for the application myfoobar,
the company ShinyThings Inc. can use:
xdg-icon-resource install --size 64 shinythings-myfoobar.png
To install an icon for a new application/x-foobar file type one can use:
xdg-icon-resource install --context mimetypes --size 48 ./mime-foobar-48.png application-x-foobar
xdg-icon-resource install --context mimetypes --size 64 ./mime-foobar-64.png application-x-foobar
This will install two icons with the name application-x-foobar but with
different sizes.
_MANUALPAGE
}
usage()
{
cat << _USAGE
xdg-icon-resource - command line tool for (un)installing icon resources
Synopsis
xdg-icon-resource install [--noupdate] [--novendor] [--theme theme] [--context
context] [--mode mode] --size size icon-file [icon-name]
xdg-icon-resource uninstall [--noupdate] [--theme theme] [--context context]
[--mode mode] --size size icon-name
xdg-icon-resource forceupdate [--theme theme] [--mode mode]
xdg-icon-resource { --help | --manual | --version }
_USAGE
}
#@xdg-utils-common@
#----------------------------------------------------------------------------
# Common utility functions included in all XDG wrapper scripts
#----------------------------------------------------------------------------
DEBUG()
{
[ -z "${XDG_UTILS_DEBUG_LEVEL}" ] && return 0;
[ ${XDG_UTILS_DEBUG_LEVEL} -lt $1 ] && return 0;
shift
echo "$@" >&2
}
#-------------------------------------------------------------
# Exit script on successfully completing the desired operation
exit_success()
{
if [ $# -gt 0 ]; then
echo "$@"
echo
fi
exit 0
}
#-----------------------------------------
# Exit script on malformed arguments, not enough arguments
# or missing required option.
# prints usage information
exit_failure_syntax()
{
if [ $# -gt 0 ]; then
echo "xdg-icon-resource: $@" >&2
echo "Try 'xdg-icon-resource --help' for more information." >&2
else
usage
echo "Use 'man xdg-icon-resource' or 'xdg-icon-resource --manual' for additional info."
fi
exit 1
}
#-------------------------------------------------------------
# Exit script on missing file specified on command line
exit_failure_file_missing()
{
if [ $# -gt 0 ]; then
echo "xdg-icon-resource: $@" >&2
fi
exit 2
}
#-------------------------------------------------------------
# Exit script on failure to locate necessary tool applications
exit_failure_operation_impossible()
{
if [ $# -gt 0 ]; then
echo "xdg-icon-resource: $@" >&2
fi
exit 3
}
#-------------------------------------------------------------
# Exit script on failure returned by a tool application
exit_failure_operation_failed()
{
if [ $# -gt 0 ]; then
echo "xdg-icon-resource: $@" >&2
fi
exit 4
}
#------------------------------------------------------------
# Exit script on insufficient permission to read a specified file
exit_failure_file_permission_read()
{
if [ $# -gt 0 ]; then
echo "xdg-icon-resource: $@" >&2
fi
exit 5
}
#------------------------------------------------------------
# Exit script on insufficient permission to read a specified file
exit_failure_file_permission_write()
{
if [ $# -gt 0 ]; then
echo "xdg-icon-resource: $@" >&2
fi
exit 6
}
check_input_file()
{
if [ ! -e "$1" ]; then
exit_failure_file_missing "file '$1' does not exist"
fi
if [ ! -r "$1" ]; then
exit_failure_file_permission_read "no permission to read file '$1'"
fi
}
check_vendor_prefix()
{
file_label="$2"
[ -n "$file_label" ] || file_label="filename"
file=`basename "$1"`
case "$file" in
[a-zA-Z]*-*)
return
;;
esac
echo "xdg-icon-resource: $file_label '$file' does not have a proper vendor prefix" >&2
echo 'A vendor prefix consists of alpha characters ([a-zA-Z]) and is terminated' >&2
echo 'with a dash ("-"). An example '"$file_label"' is '"'example-$file'" >&2
echo "Use --novendor to override or 'xdg-icon-resource --manual' for additional info." >&2
exit 1
}
check_output_file()
{
# if the file exists, check if it is writeable
# if it does not exists, check if we are allowed to write on the directory
if [ -e "$1" ]; then
if [ ! -w "$1" ]; then
exit_failure_file_permission_write "no permission to write to file '$1'"
fi
else
DIR=`dirname "$1"`
if [ ! -w "$DIR" -o ! -x "$DIR" ]; then
exit_failure_file_permission_write "no permission to create file '$1'"
fi
fi
}
#----------------------------------------
# Checks for shared commands, e.g. --help
check_common_commands()
{
while [ $# -gt 0 ] ; do
parm="$1"
shift
case "$parm" in
--help)
usage
echo "Use 'man xdg-icon-resource' or 'xdg-icon-resource --manual' for additional info."
exit_success
;;
--manual)
manualpage
exit_success
;;
--version)
echo "xdg-icon-resource 1.0.1"
exit_success
;;
esac
done
}
check_common_commands "$@"
[ -z "${XDG_UTILS_DEBUG_LEVEL}" ] && unset XDG_UTILS_DEBUG_LEVEL;
if [ ${XDG_UTILS_DEBUG_LEVEL-0} -lt 1 ]; then
# Be silent
xdg_redirect_output=" > /dev/null 2> /dev/null"
else
# All output to stderr
xdg_redirect_output=" >&2"
fi
#--------------------------------------
# Checks for known desktop environments
# set variable DE to the desktop environments name, lowercase
detectDE()
{
if [ x"$KDE_FULL_SESSION" = x"true" ]; then DE=kde;
elif [ x"$GNOME_DESKTOP_SESSION_ID" != x"" ]; then DE=gnome;
elif xprop -root _DT_SAVE_MODE | grep ' = \"xfce4\"$' >/dev/null 2>&1; then DE=xfce;
fi
}
#----------------------------------------------------------------------------
# kfmclient exec/openURL can give bogus exit value in KDE <= 3.5.4
# It also always returns 1 in KDE 3.4 and earlier
# Simply return 0 in such case
kfmclient_fix_exit_code()
{
version=`kde-config --version 2>/dev/null | grep KDE`
major=`echo $version | sed 's/KDE: \([0-9]\).*/\1/'`
minor=`echo $version | sed 's/KDE: [0-9]*\.\([0-9]\).*/\1/'`
release=`echo $version | sed 's/KDE: [0-9]*\.[0-9]*\.\([0-9]\).*/\1/'`
test "$major" -gt 3 && return $1
test "$minor" -gt 5 && return $1
test "$release" -gt 4 && return $1
return 0
}
# Set GTK_UPDATE_ICON_CACHE to gtk-update-icon-cache executable path or
# to "-" if not found.
GTK_UPDATE_ICON_CACHE=
find_gtk_update_icon_cache()
{
[ -n "$GTK_UPDATE_ICON_CACHE" ] && return;
GTK_UPDATE_ICON_CACHE="-"
for x in `echo "$PATH:/opt/gnome/bin" | sed 's/:/ /g'`; do
DEBUG 3 "Checking $x for gtk-update-icon-cache"
if [ -x "$x/gtk-update-icon-cache" ] ; then
DEBUG 1 "Found $x/gtk-update-icon-cache"
GTK_UPDATE_ICON_CACHE="$x/gtk-update-icon-cache"
return
fi
done
}
# Start GNOME legacy workaround section
need_dot_icon_path()
{
# GTK < 2.6 uses ~/.icons but not XDG_DATA_HOME/icons
# The availability of gtk-update-icon-cache is used as indication
# of whether the system is using GTK 2.6 or later
find_gtk_update_icon_cache
[ "$GTK_UPDATE_ICON_CACHE" != "-" ] && return 1;
return 0;
}
update_icon_database()
{
# Touch me, I'm dirty
touch "$1/.xdg-icon-resource-dummy"
rm -f "$1/.xdg-icon-resource-dummy"
# Don't create a cache if there wan't one already
if [ -f "$1/icon-theme.cache" ] ; then
find_gtk_update_icon_cache
if [ "$GTK_UPDATE_ICON_CACHE" != "-" ] ; then
DEBUG 1 "Running $GTK_UPDATE_ICON_CACHE -f -t \"$1\""
eval '$GTK_UPDATE_ICON_CACHE -f -t "$1"'$xdg_redirect_output
return
fi
fi
}
[ x"$1" != x"" ] || exit_failure_syntax
mode=
action=
update=yes
size=
theme=hicolor
context=apps
icon_file=
icon_name=
case $1 in
install)
action=install
;;
uninstall)
action=uninstall
;;
forceupdate)
action=forceupdate
;;
*)
exit_failure_syntax "unknown command '$1'"
;;
esac
shift
vendor=true
while [ $# -gt 0 ] ; do
parm="$1"
shift
case $parm in
--noupdate)
update=no
;;
--mode)
if [ -z "$1" ] ; then
exit_failure_syntax "mode argument missing for --mode"
fi
case "$1" in
user)
mode="user"
;;
system)
mode="system"
;;
*)
exit_failure_syntax "unknown mode '$1'"
;;
esac
shift
;;
--theme)
if [ -z "$1" ] ; then
exit_failure_syntax "theme argument missing for --theme"
fi
theme="$1"
shift
;;
--size)
if [ -z "$1" ] ; then
exit_failure_syntax "size argument missing for --size"
fi
if echo "$1" | grep '[^0-9]' > /dev/null 2> /dev/null; then
exit_failure_syntax "size argument must be numeric"
fi
size="$1"
shift
;;
--context)
if [ -z "$1" ] ; then
exit_failure_syntax "context argument missing for --context"
fi
context="$1"
shift
;;
--novendor)
vendor=false
;;
-*)
exit_failure_syntax "unexpected option '$parm'"
;;
*)
if [ -n "$icon_name" ] ; then
exit_failure_syntax "unexpected argument '$parm'"
elif [ -n "$icon_file" ] ; then
icon_name="$parm"
else
if [ "$action" = "install" ] ; then
check_input_file "$parm"
fi
icon_file="$parm"
fi
;;
esac
done
# Shouldn't happen
if [ -z "$action" ] ; then
exit_failure_syntax "command argument missing"
fi
# Shouldn't happen
if [ -z "$context" ] ; then
exit_failure_syntax "context argument missing"
fi
if [ -n "$XDG_UTILS_INSTALL_MODE" ] ; then
if [ "$XDG_UTILS_INSTALL_MODE" = "system" ] ; then
mode="system"
elif [ "$XDG_UTILS_INSTALL_MODE" = "user" ] ; then
mode="user"
fi
fi
if [ -z "$mode" ] ; then
if [ `whoami` = "root" ] ; then
mode="system"
else
mode="user"
fi
fi
xdg_dir_name="icons/$theme"
xdg_user_dir="$XDG_DATA_HOME"
[ -n "$xdg_user_dir" ] || xdg_user_dir="$HOME/.local/share"
xdg_user_prefix="$xdg_user_dir/icons"
xdg_user_dir="$xdg_user_dir/$xdg_dir_name"
xdg_global_dir=
xdg_global_prefix=
xdg_system_dirs="$XDG_DATA_DIRS"
[ -n "$xdg_system_dirs" ] || xdg_system_dirs="/usr/local/share/:/usr/share/"
for x in `echo "$xdg_system_dirs" | sed 's/:/ /g'`; do
if [ -w $x/$xdg_dir_name ] ; then
xdg_global_prefix="$x/icons"
xdg_global_dir="$x/$xdg_dir_name"
break
fi
done
[ -w $xdg_global_dir ] || xdg_global_dir=
dot_icon_dir=
dot_base_dir=
if [ x"$mode" = x"user" ] ; then
xdg_base_dir="$xdg_user_dir"
#Gnome 2.8 supports ~/.icons but not XDG_DATA_HOME
if need_dot_icon_path ; then
dot_icon_dir="$HOME/.icons"
dot_base_dir="$dot_icon_dir/$theme"
fi
else
xdg_base_dir="$xdg_global_dir"
if [ -z "$xdg_base_dir" ] ; then
exit_failure_operation_impossible "No writable system icon directory found."
fi
fi
if [ x"$action" = x"forceupdate" ] ; then
if [ -n "$icon_file" ] ; then
exit_failure_syntax "unexpected argument '$icon_file'"
fi
update_icon_database $xdg_base_dir
if [ -n "$dot_icon_dir" ] ; then
if [ -d "$dot_icon_dir/" -a ! -L "$dot_icon_dir" ] ; then
update_icon_database $dot_base_dir
fi
fi
exit_success
fi
if [ -z "$icon_file" ] ; then
if [ x"$action" = x"install" ] ; then
exit_failure_syntax "icon-file argument missing"
else
exit_failure_syntax "icon-name argument missing"
fi
fi
xdg_size_name=
extension=
if [ -z "$size" ] ; then
exit_failure_syntax "the icon size must be specified with --size"
fi
xdg_size_name="${size}x${size}"
if [ x"$action" = x"install" ] ; then
case $icon_file in
*.xpm)
extension="xpm"
;;
*.png)
extension="png"
;;
*)
exit_failure_syntax "icon file to install must be a *.png or *.xpm file"
;;
esac
fi
if [ -n "$icon_name" ] ; then
case $icon_name in
*.png)
exit_failure_syntax "icon name should not include an extension"
;;
*.xpm)
exit_failure_syntax "icon name should not include an extension"
;;
esac
fi
# Start KDE legacy workaround section
need_kde_icon_path()
{
local path
path=`readlink -f "$1" 2> /dev/null` # Normalize path
DEBUG 2 "need_kde_icon_path $path"
if [ -z "$path" ] ; then
DEBUG 2 "need_kde_icon_path RETURN 1 (not needed, no xdg icon dir)"
return 1; # Not needed
fi
# if kde-config not found... return 0
kde_icon_dirs=`kde-config --path icon 2> /dev/null |sed 's/:/ /g'`
DEBUG 3 "kde_icon_dirs: $kde_icon_dirs"
if [ -z "$kde_icon_dirs" ] ; then
DEBUG 3 "no result from kde-config --path icon"
DEBUG 2 "need_kde_icon_path RETURN 1 (not needed, no kde icon path)"
return 1; # Not needed
fi
needed=0 # Needed
for y in $kde_icon_dirs ; do
x=`readlink -f "$y"` # Normalize path
DEBUG 3 "Normalize $y --> $x"
if [ -n "$x" ] ; then
if [ "$x" = "$path" ] ; then
needed=1 # Not needed
fi
if [ -w "$x" ] ; then
kde_global_prefix="$x"
# Take last writable dir
fi
fi
done
DEBUG 2 "kde_global_prefix: $kde_global_prefix"
[ $needed -eq "1" ] && DEBUG 2 "need_kde_icon_path RETURN $needed (not needed)"
[ $needed -eq "0" ] && DEBUG 2 "need_kde_icon_path RETURN $needed (needed)"
return $needed
}
kde_dir=
if [ x"$mode" = x"user" ] ; then
xdg_dir="$xdg_base_dir/$xdg_size_name/$context"
#KDE 3.x doesn't support XDG_DATA_HOME for icons
#Check if xdg_dir prefix is listed by kde-config --path icon
#If not, install additional symlink to kdedir
if need_kde_icon_path "$xdg_user_prefix" ; then
kde_user_dir="$HOME/.kde/share/icons/$theme"
kde_dir="$kde_user_dir/$xdg_size_name/$context"
fi
#Gnome 2.8 supports ~/.icons but not XDG_DATA_HOME
if [ -n "$dot_icon_dir" ] ; then
if [ -L "$dot_icon_dir" ] ; then
# Don't do anything
dot_icon_dir=
elif [ ! -d "$dot_icon_dir/" ] ; then
# Symlink if it doesn't exist
eval 'ln -s ".local/share/icons" "$dot_icon_dir"'$xdg_redirect_output
dot_icon_dir=
else
dot_icon_dir="$dot_icon_dir/$theme/$xdg_size_name/$context"
fi
fi
my_umask=077
else
xdg_dir="$xdg_base_dir/$xdg_size_name/$context"
#KDE 3.x doesn't support XDG_DATA_DIRS for icons
#Check if xdg_dir prefix is listed by kde-config --path icon
#If not, install additional symlink to kdedir
if need_kde_icon_path "$xdg_global_prefix" ; then
kde_global_dir="$kde_global_prefix/$theme"
kde_dir="$kde_global_dir/$xdg_size_name/$context"
fi
my_umask=022
fi
# End KDE legacy workaround section
# Start GNOME legacy workaround section
need_gnome_mime=
[ $context = "mimetypes" ] && need_gnome_mime=true
# End GNOME legacy workaround section
[ -n "$icon_name" ] || icon_name=`basename $icon_file | sed 's/\.[a-z][a-z][a-z]$//'`
if [ "$vendor" = "true" -a "$action" = "install" -a "$context" = "apps" ] ; then
check_vendor_prefix "$icon_name" "icon name"
fi
icon_icon_file=`echo "$icon_file" | sed 's/\.[a-z][a-z][a-z]$/.icon/'`
icon_icon_name="$icon_name.icon"
DEBUG 1 "$action icon in $xdg_dir"
[ $action = "install" -a -f $icon_icon_file ] && DEBUG 1 "install $icon_icon_name meta file in $xdg_dir"
[ -n "$kde_dir" ] && DEBUG 1 "$action symlink in $kde_dir (KDE 3.x support)"
[ -n "$need_gnome_mime" ] && DEBUG 1 "$action gnome-mime-$icon_name symlink (GNOME 2.x support)"
[ $action = "install" -a -n "$dot_icon_dir" ] && DEBUG 1 "$action ~/.icons symlink (GNOME 2.8 support)"
case $action in
install)
save_umask=`umask`
umask $my_umask
for icon_dir in $xdg_dir $dot_icon_dir; do
mkdir -p $icon_dir
eval 'cp "$icon_file" "$icon_dir/$icon_name.$extension"'$xdg_redirect_output
if [ -f "$icon_icon_file" ] ; then
eval 'cp "$icon_icon_file" "$icon_dir/$icon_icon_name"'$xdg_redirect_output
fi
if [ -n "$need_gnome_mime" ] ; then
eval 'ln -s "$icon_name.$extension" "$icon_dir/gnome-mime-$icon_name.$extension"'$xdg_redirect_output
fi
done
if [ -n "$kde_dir" ] ; then
mkdir -p $kde_dir
eval 'ln -s "$xdg_dir/$icon_name.$extension" "$kde_dir/$icon_name.$extension"'$xdg_redirect_output
fi
umask $save_umask
;;
uninstall)
for icon_dir in $xdg_dir $dot_icon_dir; do
rm -f "$icon_dir/$icon_name.xpm" "$icon_dir/$icon_name.png"
rm -f "$icon_dir/$icon_icon_name"
if [ -n "$need_gnome_mime" ] ; then
rm -f "$icon_dir/gnome-mime-$icon_name.xpm"
rm -f "$icon_dir/gnome-mime-$icon_name.png"
fi
done
if [ -n "$kde_dir" ] ; then
rm -f "$kde_dir/$icon_name.xpm" "$kde_dir/$icon_name.png"
fi
;;
esac
if [ x"$update" = x"yes" ] ; then
update_icon_database "$xdg_base_dir"
if [ -n "$dot_icon_dir" ] ; then
if [ -d "$dot_icon_dir/" -a ! -L "$dot_icon_dir" ] ; then
update_icon_database $dot_base_dir
fi
fi
fi
exit_success

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,187 @@
See below for the German version. Deutsche Version siehe unten.
* Renoise Licensing Agreement *
Preamble
In his capacity as legal proprietor, Eduard Mueller, Wallensteinstr. 39A, 10318 Berlin, (hereafter "the licensor") grants the licensee of the "Renoise" computer programme, including all integral parts thereof pursuant to Paragraph 1, No. 1 of this agreement (hereafter "software"), the right to use the software. The licensee may use this software solely in accordance with the following conditions.
§ 1 Purpose
1. The purpose of this agreement is:
a. when acquiring the full version: the current version of the computer programme intended for sale at the time of purchase, including all parts, in particular the operating instructions;
b. when testing the demo version: the version of the computer programme in each licensee's possession intended for testing and limited in its range of functions, including all parts, in particular the operating instructions.
2. The licensor has all the rights to the software. In this agreement, the licensor grants the licensee the right to use the software.
§ 2 Scope of the Rights of Use
1. The licensor hereby gives the licensee a simple, non-exclusive, permanent, worldwide, non-sub-licensable right to the software which is linked to the licensee's person (hereafter "the licence"). All those rights not expressly transferred, in particular rights to publish, reproduce, process and patent rights, remain with the licensor. This agreement governs the precise content of this licence.
2. If the licensee acquires the software on a data carrier put into circulation by the licensor, it will only acquire ownership to the data carrier, not the software itself. Rights to the software will be oriented exclusively to this agreement.
§ 3 Content of the Licence
1. The licensee may install the software on as many computers as it wishes for its own use. The licensee may reproduce the installed software permanently or temporarily, wholly or partially, if and as long as the loading, running, transferring or storing the computer programme requires reproducing.
2. The licensee is required to ensure that, at no time, anyone other than he himself works with an installation of the software. Installation in networks is also permissible under this condition. Simultaneous use of several installations of the software by the licensee personally is permitted.
3. Apart from installation, the licensee may make copies of the software for backup purposes to the required and usual extent.
§ 4 Transferability of the Licence
1. The transfer of the licence to third parties is only permitted if the third party agrees to be bound by all rights and duties arising from this licensing agreement. In this case the licensee is required to inform the licensor of the transfer of the licence; the licensor will then supply the third party with a personalised original of the software.
2. The licensee will then be required to hand over the complete original software and destroy immediately all copies in his possession. Installed and electronically stored copies are to be deleted in such a way that they cannot be recreated.
§ 5 Copyright
1. The software is protected by copyright. All copyright remains with the licensor.
2. Copyright notes and registration numbers may be removed neither from the software itself nor from any back-up copies.
§ 6 Express Forbidden Uses
1. The licensee is expressly forbidden to:
a. alter, translate, reverse engineer, decompile or disassemble the software. This also applies in deviation from Section 69d, Subsection 1, of the German Copyright Act for correcting errors;
b. translate, process, arrange or rework the software, including its component parts;
c. create derivative works of the software, including its component parts.
d. copy, reproduce or disseminate the software, partially or wholly, in its original or altered form unless this agreement specifically permits something else. This also expressly includes dissemination included in other software or mixed with other software and wired or wireless public broadcasting of, or permitting access to, the software.
e. reformat, mix, filter, re-synthesize, edit or alter the sound samples and other musical content connected to the software for use in any kind of commercial sampling product/package or software, without the express written consent of the licensor.
2. The provision in Paragraph 2 No. 1 of this agreement remains unaffected.
§ 7 Breach of Licence, Forfeiture
1. If the licensee breaches the conditions of this licensing agreement, all rights of use granted will expire. In this case he will be required to immediately destroy the original software and any back-up copies or, if requested, return them to the licensor. Installations and electronically stored copies are to be deleted in such a way that they cannot be recreated.
2. The licensee is liable to the licensor for all damage arising from breaches of this agreement.
§ 8 Liability of the Licensor
1. The licensor is liable in cases of intent and gross negligence as provided by law. He is also liable in case of negligent breaches of duty whose fulfilment makes possible the due performance of this agreement at all, the breach of which endangers the achieving of the purpose of the agreement and on whose observation the acquirer regularly relies. In the case or negligent breach of such duties, liability is limited to the foreseeable damage typical in agreements of this type.
2. The licensor is not liable in cases of minor breaches of other duties.
3. The above liability exemptions do not apply in cases of death, injury or illness.
§ 9 Ancillary Agreements, Choice of Law, Prorogation, Saving Clause
1. No oral agreements have been made. Amendments, including to this provision, must be in writing.
2. The laws of the Federal Republic of Germany apply to the exclusion of the provisions of the UN Convention on the International Sale of Goods. The language of the agreement is German.
3. This agreement has been translated into several other languages. In the case of contradictions, matters of interpretation and lack of clarity, the German version will take precedence over the other versions.
4. If the parties are either merchants or legal entities in public law, the sole legal venue for all disputes arising from this agreement is Berlin, Federal Republic of Germany.
5. The legal validity of a provision will not affect the legal validity of the other provisions. The parties undertake to replace a legally invalid provision with a legally valid provision which comes as close as possible to the desired effect of the legally invalid provision and which best corresponds to the purpose of the agreement.
* Renoise Lizenzvertrag *
Präambel
Eduard Müller, Wallensteinstr. 39A, 10318 Berlin (im Folgenden „Lizenzgeber“) als Rechtsinhaber gewährt dem Lizenznehmer des Computerprogrammes „Renoise“ einschließlich sämtlicher Bestandteile gem. § 1 Ziff. 1 dieser Vereinbarung (im Folgenden „Software“) ein Nutzungsrecht an der Software. Die Benutzung der Software durch den Lizenznehmer erfolgt ausschließlich zu den nachfolgenden Bedingungen.
§ 1 Gegenstand
1. Gegenstand dieser Vereinbarung ist
a. Bei einem Erwerb der Vollversion: das Computerprogramm in der zum Zeitpunkt des Erwerbs aktuellen, für den Vertrieb vorgesehenen Version einschließlich sämtlicher Bestandteile, insbesondere der Bedienungsanleitung.
b. Bei einem Test der Demoversion: das Computerprogramm in der jeweils dem Lizenznehmer vorliegenden, für den Test vorgesehenen und im Funktionsumfang eingeschränkten Version einschließlich sämtlicher Bestandteile, insbesondere der Bedienungsanleitung.
2. Der Lizenzgeber ist Inhaber sämtlicher Nutzungsrechte an der Software. Mit dieser Vereinbarung gewährt der Lizenzgeber dem Lizenznehmer Nutzungsrechte an der Software.
§ 2 Umfang des Nutzungsrechts
1. Der Lizenzgeber erteilt dem Lizenznehmer hiermit ein einfaches, nicht ausschließliches, dauerhaftes, weltweites, nicht unterlizenzierbares und an die Person des Lizenznehmers gebundenes Nutzungsrecht an der Software (im Folgenden „Lizenz“). Sämtliche nicht ausdrücklich übertragenen Rechte, insbesondere Veröffentlichungs-, Vervielfältigungs-, Bearbeitungs- und Verwertungsrechte, verbleiben beim Lizenzgeber. Den genauen Inhalt der Lizenz regelt diese Vereinbarung.
2. Soweit der Lizenznehmer die Software auf einem vom Lizenzgeber in den Verkehr gebrachten Datenträger erwirbt, erlangt er durch den Erwerb lediglich Eigentum an dem Datenträger, nicht jedoch irgendwelche Rechte an der Software selbst. Rechte an der Software richten sich ausschließlich nach dieser Vereinbarung.
§ 3 Inhalt der Lizenz
1. Der Lizenznehmer darf die Software auf beliebig vielen Computern zu seiner eigenen Verwendung installieren. Der Lizenznehmer darf die installierte Software dauerhaft oder vorübergehend ganz oder teilweise Vervielfältigen, soweit und solange das Laden, Anzeigen, Ablaufen, Übertragen oder Speichern des Computerprogramms eine Vervielfältigung erfordert.
2. Der Lizenznehmer hat sicherzustellen, dass zu keiner Zeit jemand anderes als er selber mit einer Installation der Software arbeitet. Unter dieser Voraussetzung ist auch eine Installation in Netzwerken zulässig. Eine gleichzeitige Nutzung mehrerer Installationen der Software durch den Lizenznehmer persönlich ist gestattet.
3. Zu Sicherungszwecken darf der Lizenznehmer unabhängig von einer Installation Kopien von der Software im erforderlichen und üblichen Umfang erstellen.
§ 4 Übertragbarkeit der Lizenz
1. Eine Übertragung der Lizenz auf Dritte ist nur zulässig, wenn die dritte Partei der Übernahme sämtlicher Rechte und Pflichten aus diesem Lizenzvertrag zustimmt. Der Lizenznehmer hat in diesem Fall dem Lizenzgeber die Übertragung der Lizenz mitzuteilen; der Lizenzgeber stellt dann dem Dritten ein auf diesen personalisiertes Original der Software zur Verfügung.
2. Der Lizenznehmer hat die vollständige Originalsoftware zu übergeben und unverzüglich sämtliche noch in seinem Besitz befindlichen Kopien zu vernichten. Installationen und elektronisch gespeicherte Kopien sind in einer die Wiederherstellung ausschließenden Weise zu löschen.
§ 5 Urheberrecht
1. Die Software ist urheberrechtlich geschützt. Sämtliche Urheberrechte liegen bei dem Lizenzgeber.
2. Urheberrechtsvermerke und Registriernummern dürfen weder in der Software selbst noch in eventuell erstellten Sicherungskopien entfernt werden.
§ 6 Ausdrückliche Verwendungsverbote
1. Dem Lizenznehmer ist es ausdrücklich untersagt:
a. Die Software abzuändern, zu übersetzen, zurückzuentwickeln, zu decompilieren oder zu disassemblieren. Dies gilt abweichend von § 69d Abs. 1 UrhG auch für die Fehlerberichtigung.
b. Die Software einschließlich ihrer Bestandteile zu übersetzen, zu bearbeiten, zu arrangieren oder umzuarbeiten.
c. Abgeleitete Werke aus der Software einschließlich ihrer Bestandteile zu erstellen.
d. Die Software ganz oder teilweise in ursprünglicher oder abgeänderter Form zu kopieren, zu vervielfältigen oder zu verbreiten, soweit nicht diese Vereinbarung etwas anderes konkret gestattet. Dies schließt ausdrücklich auch die Verbreitung eingeschlossen in andere Software oder vermischt mit anderer Software sowie die drahtgebundene oder drahtlose öffentliche Wiedergabe oder Zugänglichmachung der Software ein.
e. Die Klänge und andere musikalische Bestandteile der Software ohne ausdrückliche Genehmigung des Lizenzgebers in ursprünglicher oder auch abgeänderter Form in einem anderen kommerziellen Sampler Produkt oder Software zu verwenden.
2. Die Regelung des § 2 Ziff. 1 dieser Vereinbarung bleibt unberührt.
§ 7 Lizenzverstoß, Verwirkung
1. Verstößt der Lizenznehmer gegen die Bedingungen dieses Lizenzertrages, erlöschen sämtliche eingeräumten Nutzungsrechte. In diesem Fall hat er unverzüglich die Originalsoftware und eventuelle Sicherungskopien zu vernichten oder auf Anforderung dem Lizenzgeber zu übergeben. Installationen und elektronisch gespeicherte Kopien sind in einer die Wiederherstellung ausschließenden Weise zu löschen.
2. Der Lizenznehmer haftet dem Lizenzgeber für sämtliche aus Vertragsverletzungen entstehende Schäden.
§ 8 Haftung des Lizenzgebers
1. Der Lizenzgeber haftet bei Vorsatz und grober Fahrlässigkeit nach den gesetzlichen Regeln. Er haftet ferner bei der fahrlässigen Verletzung von Pflichten, deren Erfüllung die ordnungsgemäße Durchführung des Vertrages überhaupt erst ermöglicht, deren Verletzung die Erreichung des Vertragszwecks gefährdet und auf deren Einhaltung der Erwerber regelmäßig vertraut. Bei einer fahrlässigen Verletzung derartiger Pflichten ist die Haftung auf den vorhersehbaren, vertragstypischen Schaden begrenzt.
2. Der Lizenzgeber haftet nicht bei leicht fahrlässiger Verletzung anderer Pflichten.
3. Die vorstehenden Haftungsausschlüsse gelten nicht bei Verletzung von Leben, Körper und Gesundheit.
§ 9 Nebenabreden, Rechtswahl, Prorogation, Salvatorische Klausel
1. Mündliche Nebenabreden sind nicht getroffen. Änderungen, auch dieser Regelung, und Ergänzungen dieser Vereinbarung bedürfen der Schriftform.
2. Es gilt das Recht der Bundesrepublik Deutschland unter Ausschluss des UN-Kaufrechts. Vertragssprache ist Deutsch.
3. Dieser Vertrag wird mehrsprachig ausgefertigt. Bei Widersprüchen, Auslegungsfragen und anderen Unklarheiten geht die deutsche Fassung den übrigen Fassungen vor.
4. Sind die Parteien jeweils entweder Kaufmann oder eine juristische Person des öffentlichen Rechts, ist ausschließlicher Gerichtsstand für alle Streitigkeiten aus diesem Vertrag Berlin, Bundesrepublik Deutschland.
5. Die Rechtsunwirksamkeit einer Bestimmung dieser Vereinbarung berührt die Rechtswirksamkeit der übrigen Teile nicht. Die Parteien verpflichten sich, eine unwirksame Bestimmung durch eine wirksame Regelung zu ersetzen, die der unwirksamen im Ergebnis am nächsten kommt und dem Vertragszweck am besten entspricht.

View File

@@ -0,0 +1,49 @@
Renoise - https://www.renoise.com/products/renoise
Always visit https://www.renoise.com for the latest releases (other sites may
have obsolete versions and/or outdated links).
_:__________:_ _:__________:_
__ | | | | __
.____\/____|_ _|________________________________|_ pzk+BM _|____\/____.
| \/ | | | | \/ |
| | | _________________ | | |
| : | ._\ /_. : | |
: _________ _______ : ____|____. | ___. _______ : _______ :
._\ ._ /._\ ___/__.___\ | |_\__|_\ __/__._\ ___/__.
| |/ _/_| _/ | \ | _. | | \___ | _/ |
| \ | \ | \ | \| | | |/ | \ |
'----/_____|----/_____|---/________| |____|----/_____|----/_____|
: . . |_ _| . . .
| | | /________________\ | | |
| __ | | | | __ |
|____\/____|_ _|________________________________|_ _|____\/____|
\/ | | | | \/
_|__________|_ _|__________|_
: : : :
Beginners:
---------
Please read the online tutorials at https://tutorials.renoise.com.
Also try out the demo songs that are accessible in the help window menus in
Renoise. There you will also find some tutorial songs, which show some abilities
of Renoise. Just listen to them and have a closer look what's happening there.
Please report any bug that you find to bug@renoise.com or at the
bug report forum at https://forum.renoise.com
Registered users:
-----------------
Registered versions can be downloaded at https://backstage.renoise.com
Please contact support@renoise.com if you have troubles logging into
the private area, or have questions about the releases, website.
Please note that when upgrading Renoise, any third party tools you might have
installed will also need updating.

View File

@@ -0,0 +1,9 @@
[Desktop Entry]
Encoding=UTF-8
Name=Renoise Linux FAQ
Type=Link
URL=http://tutorials.renoise.com/wiki/Linux_FAQ
Icon=gnome-fs-bookmark
Name[en_US]=Renoise Linux FAQ

View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2018 最萌小汐
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,85 @@
local main, exec
local i = 1
while arg[i] do
if arg[i] == '-E' then
elseif arg[i] == '-e' then
i = i + 1
local expr = assert(arg[i], "'-e' needs argument")
assert(load(expr, "=(command line)"))()
-- exit after the executing
exec = true
elseif not main and arg[i]:sub(1, 1) ~= '-' then
main = i
elseif arg[i]:sub(1, 2) == '--' then
break
end
i = i + 1
end
if exec and not main then
return
end
if main then
for i = -1, -999, -1 do
if not arg[i] then
for j = i + 1, -1 do
arg[j - main + 1] = arg[j]
end
break
end
end
for j = 1, #arg do
arg[j - main] = arg[j]
end
for j = #arg - main + 1, #arg do
arg[j] = nil
end
end
local root
do
if main then
local fs = require 'bee.filesystem'
local mainPath = fs.path(arg[0])
root = mainPath:parent_path():string()
if root == '' then
root = '.'
end
else
local sep = package.config:sub(1, 1)
if sep == '\\' then
sep = '/\\'
end
local pattern = "[" .. sep .. "]+[^" .. sep .. "]+"
root = package.cpath:match("([^;]+)" .. pattern .. pattern .. "$")
arg[0] = root .. package.config:sub(1, 1) .. 'main.lua'
end
root = root:gsub('[/\\]', package.config:sub(1, 1))
end
package.path = table.concat({
root .. "/script/?.lua",
root .. "/script/?/init.lua",
}, ";"):gsub('/', package.config:sub(1, 1))
package.searchers[2] = function (name)
local filename, err = package.searchpath(name, package.path)
if not filename then
return err
end
local f = io.open(filename)
if not f then
return 'cannot open file:' .. filename
end
local buf = f:read '*a'
f:close()
local relative = filename:sub(1, #root) == root and filename:sub(#root + 2) or filename
local init, err = load(buf, '@' .. relative)
if not init then
return err
end
return init, filename
end
assert(loadfile(arg[0]))(table.unpack(arg))

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,66 @@
if not DEVELOP then
return
end
local fs = require 'bee.filesystem'
local luaDebugs = {}
local home = os.getenv 'USERPROFILE' or os.getenv 'HOME'
if not home then
log.error('Cannot find home directory')
return
end
for _, vscodePath in ipairs { '.vscode', '.vscode-insiders', '.vscode-server-insiders' } do
local extensionPath = fs.path(home) / vscodePath / 'extensions'
log.debug('Search extensions at:', extensionPath:string())
if fs.exists(extensionPath) then
for path in fs.pairs(extensionPath) do
if fs.is_directory(path) then
local name = path:filename():string()
if name:find('actboy168.lua-debug-', 1, true) then
luaDebugs[#luaDebugs+1] = path:string()
end
end
end
end
end
if #luaDebugs == 0 then
log.debug('Cant find "actboy168.lua-debug"')
return
end
local function getVer(filename)
local a, b, c = filename:match('actboy168%.lua%-debug%-(%d+)%.(%d+)%.(%d+)')
if not a then
return 0
end
return a * 1000000 + b * 1000 + c
end
table.sort(luaDebugs, function (a, b)
return getVer(a) > getVer(b)
end)
local debugPath = luaDebugs[1]
local cpath = "/runtime/win64/lua54/?.dll;/runtime/win64/lua54/?.so"
local path = "/script/?.lua"
local function tryDebugger()
local entry = assert(package.searchpath('debugger', debugPath .. path))
local root = debugPath
local addr = ("127.0.0.1:%d"):format(DBGPORT)
local dbg = loadfile(entry)(entry)
dbg:start {
address = addr,
}
log.debug('Debugger startup, listen port:', DBGPORT)
log.debug('Debugger args:', addr, root, path, cpath)
if DBGWAIT then
dbg:event('wait')
end
return dbg
end
xpcall(tryDebugger, log.debug)

View File

@@ -0,0 +1,764 @@
---@diagnostic disable: undefined-global, lowercase-global
arg =
'Command-line arguments of Lua Standalone.'
assert =
'Raises an error if the value of its argument v is false (i.e., `nil` or `false`); otherwise, returns all its arguments. In case of error, `message` is the error object; when absent, it defaults to `"assertion failed!"`'
cgopt.collect =
'Performs a full garbage-collection cycle.'
cgopt.stop =
'Stops automatic execution.'
cgopt.restart =
'Restarts automatic execution.'
cgopt.count =
'Returns the total memory in Kbytes.'
cgopt.step =
'Performs a garbage-collection step.'
cgopt.setpause =
'Set `pause`.'
cgopt.setstepmul =
'Set `step multiplier`.'
cgopt.incremental =
'Change the collector mode to incremental.'
cgopt.generational =
'Change the collector mode to generational.'
cgopt.isrunning =
'Returns whether the collector is running.'
collectgarbage =
'This function is a generic interface to the garbage collector. It performs different functions according to its first argument, `opt`.'
dofile =
'Opens the named file and executes its content as a Lua chunk. When called without arguments, `dofile` executes the content of the standard input (`stdin`). Returns all values returned by the chunk. In case of errors, `dofile` propagates the error to its caller. (That is, `dofile` does not run in protected mode.)'
error =
[[
Terminates the last protected function called and returns message as the error object.
Usually, `error` adds some information about the error position at the beginning of the message, if the message is a string.
]]
_G =
'A global variable (not a function) that holds the global environment (see §2.2). Lua itself does not use this variable; changing its value does not affect any environment, nor vice versa.'
getfenv =
'Returns the current environment in use by the function. `f` can be a Lua function or a number that specifies the function at that stack level.'
getmetatable =
'If object does not have a metatable, returns nil. Otherwise, if the object\'s metatable has a __metatable field, returns the associated value. Otherwise, returns the metatable of the given object.'
ipairs =
[[
Returns three values (an iterator function, the table `t`, and `0`) so that the construction
```lua
for i,v in ipairs(t) do body end
```
will iterate over the keyvalue pairs `(1,t[1]), (2,t[2]), ...`, up to the first absent index.
]]
loadmode.b =
'Only binary chunks.'
loadmode.t =
'Only text chunks.'
loadmode.bt =
'Both binary and text.'
load['<5.1'] =
'Loads a chunk using function `func` to get its pieces. Each call to `func` must return a string that concatenates with previous results.'
load['>5.2'] =
[[
Loads a chunk.
If `chunk` is a string, the chunk is this string. If `chunk` is a function, `load` calls it repeatedly to get the chunk pieces. Each call to `chunk` must return a string that concatenates with previous results. A return of an empty string, `nil`, or no value signals the end of the chunk.
]]
loadfile =
'Loads a chunk from file `filename` or from the standard input, if no file name is given.'
loadstring =
'Loads a chunk from the given string.'
module =
'Creates a module.'
next =
[[
Allows a program to traverse all fields of a table. Its first argument is a table and its second argument is an index in this table. A call to `next` returns the next index of the table and its associated value. When called with `nil` as its second argument, `next` returns an initial index and its associated value. When called with the last index, or with `nil` in an empty table, `next` returns `nil`. If the second argument is absent, then it is interpreted as `nil`. In particular, you can use `next(t)` to check whether a table is empty.
The order in which the indices are enumerated is not specified, *even for numeric indices*. (To traverse a table in numerical order, use a numerical `for`.)
The behavior of `next` is undefined if, during the traversal, you assign any value to a non-existent field in the table. You may however modify existing fields. In particular, you may set existing fields to nil.
]]
pairs =
[[
If `t` has a metamethod `__pairs`, calls it with t as argument and returns the first three results from the call.
Otherwise, returns three values: the $next function, the table `t`, and `nil`, so that the construction
```lua
for k,v in pairs(t) do body end
```
will iterate over all keyvalue pairs of table `t`.
See function $next for the caveats of modifying the table during its traversal.
]]
pcall =
[[
Calls the function `f` with the given arguments in *protected mode*. This means that any error inside `f` is not propagated; instead, `pcall` catches the error and returns a status code. Its first result is the status code (a boolean), which is true if the call succeeds without errors. In such case, `pcall` also returns all results from the call, after this first result. In case of any error, `pcall` returns `false` plus the error object.
]]
print =
[[
Receives any number of arguments and prints their values to `stdout`, converting each argument to a string following the same rules of $tostring.
The function print is not intended for formatted output, but only as a quick way to show a value, for instance for debugging. For complete control over the output, use $string.format and $io.write.
]]
rawequal =
'Checks whether v1 is equal to v2, without invoking the `__eq` metamethod.'
rawget =
'Gets the real value of `table[index]`, without invoking the `__index` metamethod.'
rawlen =
'Returns the length of the object `v`, without invoking the `__len` metamethod.'
rawset =
[[
Sets the real value of `table[index]` to `value`, without using the `__newindex` metavalue. `table` must be a table, `index` any value different from `nil` and `NaN`, and `value` any Lua value.
This function returns `table`.
]]
select =
'If `index` is a number, returns all arguments after argument number `index`; a negative number indexes from the end (`-1` is the last argument). Otherwise, `index` must be the string `"#"`, and `select` returns the total number of extra arguments it received.'
setfenv =
'Sets the environment to be used by the given function.'
setmetatable =
[[
Sets the metatable for the given table. If `metatable` is `nil`, removes the metatable of the given table. If the original metatable has a `__metatable` field, raises an error.
This function returns `table`.
To change the metatable of other types from Lua code, you must use the debug library (§6.10).
]]
tonumber =
[[
When called with no `base`, `tonumber` tries to convert its argument to a number. If the argument is already a number or a string convertible to a number, then `tonumber` returns this number; otherwise, it returns `fail`.
The conversion of strings can result in integers or floats, according to the lexical conventions of Lua (see §3.1). The string may have leading and trailing spaces and a sign.
]]
tostring =
[[
Receives a value of any type and converts it to a string in a human-readable format.
If the metatable of `v` has a `__tostring` field, then `tostring` calls the corresponding value with `v` as argument, and uses the result of the call as its result. Otherwise, if the metatable of `v` has a `__name` field with a string value, `tostring` may use that string in its final result.
For complete control of how numbers are converted, use $string.format.
]]
type =
[[
Returns the type of its only argument, coded as a string. The possible results of this function are `"nil"` (a string, not the value `nil`), `"number"`, `"string"`, `"boolean"`, `"table"`, `"function"`, `"thread"`, and `"userdata"`.
]]
_VERSION =
'A global variable (not a function) that holds a string containing the running Lua version.'
warn =
'Emits a warning with a message composed by the concatenation of all its arguments (which should be strings).'
xpcall['=5.1'] =
'Calls function `f` with the given arguments in protected mode with a new message handler.'
xpcall['>5.2'] =
'Calls function `f` with the given arguments in protected mode with a new message handler.'
unpack =
[[
Returns the elements from the given `list`. This function is equivalent to
```lua
return list[i], list[i+1], ···, list[j]
```
]]
bit32 =
''
bit32.arshift =
[[
Returns the number `x` shifted `disp` bits to the right. Negative displacements shift to the left.
This shift operation is what is called arithmetic shift. Vacant bits on the left are filled with copies of the higher bit of `x`; vacant bits on the right are filled with zeros.
]]
bit32.band =
'Returns the bitwise *and* of its operands.'
bit32.bnot =
[[
Returns the bitwise negation of `x`.
```lua
assert(bit32.bnot(x) ==
(-1 - x) % 2^32)
```
]]
bit32.bor =
'Returns the bitwise *or* of its operands.'
bit32.btest =
'Returns a boolean signaling whether the bitwise *and* of its operands is different from zero.'
bit32.bxor =
'Returns the bitwise *exclusive or* of its operands.'
bit32.extract =
'Returns the unsigned number formed by the bits `field` to `field + width - 1` from `n`.'
bit32.replace =
'Returns a copy of `n` with the bits `field` to `field + width - 1` replaced by the value `v` .'
bit32.lrotate =
'Returns the number `x` rotated `disp` bits to the left. Negative displacements rotate to the right.'
bit32.lshift =
[[
Returns the number `x` shifted `disp` bits to the left. Negative displacements shift to the right. In any direction, vacant bits are filled with zeros.
```lua
assert(bit32.lshift(b, disp) ==
(b * 2^disp) % 2^32)
```
]]
bit32.rrotate =
'Returns the number `x` rotated `disp` bits to the right. Negative displacements rotate to the left.'
bit32.rshift =
[[
Returns the number `x` shifted `disp` bits to the right. Negative displacements shift to the left. In any direction, vacant bits are filled with zeros.
```lua
assert(bit32.rshift(b, disp) ==
math.floor(b % 2^32 / 2^disp))
```
]]
coroutine =
''
coroutine.create =
'Creates a new coroutine, with body `f`. `f` must be a function. Returns this new coroutine, an object with type `"thread"`.'
coroutine.isyieldable =
'Returns true when the running coroutine can yield.'
coroutine.isyieldable['>5.4']=
'Returns true when the coroutine `co` can yield. The default for `co` is the running coroutine.'
coroutine.close =
'Closes coroutine `co` , closing all its pending to-be-closed variables and putting the coroutine in a dead state.'
coroutine.resume =
'Starts or continues the execution of coroutine `co`.'
coroutine.running =
'Returns the running coroutine plus a boolean, true when the running coroutine is the main one.'
coroutine.status =
'Returns the status of coroutine `co`.'
coroutine.wrap =
'Creates a new coroutine, with body `f`; `f` must be a function. Returns a function that resumes the coroutine each time it is called.'
coroutine.yield =
'Suspends the execution of the calling coroutine.'
costatus.running =
'Is running.'
costatus.suspended =
'Is suspended or not started.'
costatus.normal =
'Is active but not running.'
costatus.dead =
'Has finished or stopped with an error.'
debug =
''
debug.debug =
'Enters an interactive mode with the user, running each string that the user enters.'
debug.getfenv =
'Returns the environment of object `o` .'
debug.gethook =
'Returns the current hook settings of the thread.'
debug.getinfo =
'Returns a table with information about a function.'
debug.getlocal['<5.1'] =
'Returns the name and the value of the local variable with index `local` of the function at level `level` of the stack.'
debug.getlocal['>5.2'] =
'Returns the name and the value of the local variable with index `local` of the function at level `f` of the stack.'
debug.getmetatable =
'Returns the metatable of the given value.'
debug.getregistry =
'Returns the registry table.'
debug.getupvalue =
'Returns the name and the value of the upvalue with index `up` of the function.'
debug.getuservalue['<5.3'] =
'Returns the Lua value associated to u.'
debug.getuservalue['>5.4'] =
[[
Returns the `n`-th user value associated
to the userdata `u` plus a boolean,
`false` if the userdata does not have that value.
]]
debug.setcstacklimit =
[[
### **Deprecated in `Lua 5.4.2`**
Sets a new limit for the C stack. This limit controls how deeply nested calls can go in Lua, with the intent of avoiding a stack overflow.
In case of success, this function returns the old limit. In case of error, it returns `false`.
]]
debug.setfenv =
'Sets the environment of the given `object` to the given `table` .'
debug.sethook =
'Sets the given function as a hook.'
debug.setlocal =
'Assigns the `value` to the local variable with index `local` of the function at `level` of the stack.'
debug.setmetatable =
'Sets the metatable for the given value to the given table (which can be `nil`).'
debug.setupvalue =
'Assigns the `value` to the upvalue with index `up` of the function.'
debug.setuservalue['<5.3'] =
'Sets the given value as the Lua value associated to the given udata.'
debug.setuservalue['>5.4'] =
[[
Sets the given `value` as
the `n`-th user value associated to the given `udata`.
`udata` must be a full userdata.
]]
debug.traceback =
'Returns a string with a traceback of the call stack. The optional message string is appended at the beginning of the traceback.'
debug.upvalueid =
'Returns a unique identifier (as a light userdata) for the upvalue numbered `n` from the given function.'
debug.upvaluejoin =
'Make the `n1`-th upvalue of the Lua closure `f1` refer to the `n2`-th upvalue of the Lua closure `f2`.'
infowhat.n =
'`name` and `namewhat`'
infowhat.S =
'`source`, `short_src`, `linedefined`, `lastlinedefined`, and `what`'
infowhat.l =
'`currentline`'
infowhat.t =
'`istailcall`'
infowhat.u['<5.1'] =
'`nups`'
infowhat.u['>5.2'] =
'`nups`, `nparams`, and `isvararg`'
infowhat.f =
'`func`'
infowhat.r =
'`ftransfer` and `ntransfer`'
infowhat.L =
'`activelines`'
hookmask.c =
'Calls hook when Lua calls a function.'
hookmask.r =
'Calls hook when Lua returns from a function.'
hookmask.l =
'Calls hook when Lua enters a new line of code.'
file =
''
file[':close'] =
'Close `file`.'
file[':flush'] =
'Saves any written data to `file`.'
file[':lines'] =
[[
------
```lua
for c in file:lines(...) do
body
end
```
]]
file[':read'] =
'Reads the `file`, according to the given formats, which specify what to read.'
file[':seek'] =
'Sets and gets the file position, measured from the beginning of the file.'
file[':setvbuf'] =
'Sets the buffering mode for an output file.'
file[':write'] =
'Writes the value of each of its arguments to `file`.'
readmode.n =
'Reads a numeral and returns it as number.'
readmode.a =
'Reads the whole file.'
readmode.l =
'Reads the next line skipping the end of line.'
readmode.L =
'Reads the next line keeping the end of line.'
seekwhence.set =
'Base is beginning of the file.'
seekwhence.cur =
'Base is current position.'
seekwhence['.end'] =
'Base is end of file.'
vbuf.no =
'Output operation appears immediately.'
vbuf.full =
'Performed only when the buffer is full.'
vbuf.line =
'Buffered until a newline is output.'
io =
''
io.stdin =
'standard input.'
io.stdout =
'standard output.'
io.stderr =
'standard error.'
io.close =
'Close `file` or default output file.'
io.flush =
'Saves any written data to default output file.'
io.input =
'Sets `file` as the default input file.'
io.lines =
[[
------
```lua
for c in io.lines(filename, ...) do
body
end
```
]]
io.open =
'Opens a file, in the mode specified in the string `mode`.'
io.output =
'Sets `file` as the default output file.'
io.popen =
'Starts program prog in a separated process.'
io.read =
'Reads the `file`, according to the given formats, which specify what to read.'
io.tmpfile =
'In case of success, returns a handle for a temporary file.'
io.type =
'Checks whether `obj` is a valid file handle.'
io.write =
'Writes the value of each of its arguments to default output file.'
openmode.r =
'Read mode.'
openmode.w =
'Write mode.'
openmode.a =
'Append mode.'
openmode['.r+'] =
'Update mode, all previous data is preserved.'
openmode['.w+'] =
'Update mode, all previous data is erased.'
openmode['.a+'] =
'Append update mode, previous data is preserved, writing is only allowed at the end of file.'
openmode.rb =
'Read mode. (in binary mode.)'
openmode.wb =
'Write mode. (in binary mode.)'
openmode.ab =
'Append mode. (in binary mode.)'
openmode['.r+b'] =
'Update mode, all previous data is preserved. (in binary mode.)'
openmode['.w+b'] =
'Update mode, all previous data is erased. (in binary mode.)'
openmode['.a+b'] =
'Append update mode, previous data is preserved, writing is only allowed at the end of file. (in binary mode.)'
popenmode.r =
'Read data from this program by `file`.'
popenmode.w =
'Write data to this program by `file`.'
filetype.file =
'Is an open file handle.'
filetype['.closed file'] =
'Is a closed file handle.'
filetype['.nil'] =
'Is not a file handle.'
math =
''
math.abs =
'Returns the absolute value of `x`.'
math.acos =
'Returns the arc cosine of `x` (in radians).'
math.asin =
'Returns the arc sine of `x` (in radians).'
math.atan['<5.2'] =
'Returns the arc tangent of `x` (in radians).'
math.atan['>5.3'] =
'Returns the arc tangent of `y/x` (in radians).'
math.atan2 =
'Returns the arc tangent of `y/x` (in radians).'
math.ceil =
'Returns the smallest integral value larger than or equal to `x`.'
math.cos =
'Returns the cosine of `x` (assumed to be in radians).'
math.cosh =
'Returns the hyperbolic cosine of `x` (assumed to be in radians).'
math.deg =
'Converts the angle `x` from radians to degrees.'
math.exp =
'Returns the value `e^x` (where `e` is the base of natural logarithms).'
math.floor =
'Returns the largest integral value smaller than or equal to `x`.'
math.fmod =
'Returns the remainder of the division of `x` by `y` that rounds the quotient towards zero.'
math.frexp =
'Decompose `x` into tails and exponents. Returns `m` and `e` such that `x = m * (2 ^ e)`, `e` is an integer and the absolute value of `m` is in the range [0.5, 1) (or zero when `x` is zero).'
math.huge =
'A value larger than any other numeric value.'
math.ldexp =
'Returns `m * (2 ^ e)` .'
math.log['<5.1'] =
'Returns the natural logarithm of `x` .'
math.log['>5.2'] =
'Returns the logarithm of `x` in the given base.'
math.log10 =
'Returns the base-10 logarithm of x.'
math.max =
'Returns the argument with the maximum value, according to the Lua operator `<`.'
math.maxinteger['>5.3'] =
'An integer with the maximum value for an integer.'
math.min =
'Returns the argument with the minimum value, according to the Lua operator `<`.'
math.mininteger['>5.3'] =
'An integer with the minimum value for an integer.'
math.modf =
'Returns the integral part of `x` and the fractional part of `x`.'
math.pi =
'The value of *π*.'
math.pow =
'Returns `x ^ y` .'
math.rad =
'Converts the angle `x` from degrees to radians.'
math.random =
[[
* `math.random()`: Returns a float in the range [0,1).
* `math.random(n)`: Returns a integer in the range [1, n].
* `math.random(m, n)`: Returns a integer in the range [m, n].
]]
math.randomseed['<5.3'] =
'Sets `x` as the "seed" for the pseudo-random generator.'
math.randomseed['>5.4'] =
[[
* `math.randomseed(x, y)`: Concatenate `x` and `y` into a 128-bit `seed` to reinitialize the pseudo-random generator.
* `math.randomseed(x)`: Equate to `math.randomseed(x, 0)` .
* `math.randomseed()`: Generates a seed with a weak attempt for randomness.
]]
math.sin =
'Returns the sine of `x` (assumed to be in radians).'
math.sinh =
'Returns the hyperbolic sine of `x` (assumed to be in radians).'
math.sqrt =
'Returns the square root of `x`.'
math.tan =
'Returns the tangent of `x` (assumed to be in radians).'
math.tanh =
'Returns the hyperbolic tangent of `x` (assumed to be in radians).'
math.tointeger['>5.3'] =
'If the value `x` is convertible to an integer, returns that integer.'
math.type['>5.3'] =
'Returns `"integer"` if `x` is an integer, `"float"` if it is a float, or `nil` if `x` is not a number.'
math.ult['>5.3'] =
'Returns `true` if and only if `m` is below `n` when they are compared as unsigned integers.'
os =
''
os.clock =
'Returns an approximation of the amount in seconds of CPU time used by the program.'
os.date =
'Returns a string or a table containing date and time, formatted according to the given string `format`.'
os.difftime =
'Returns the difference, in seconds, from time `t1` to time `t2`.'
os.execute =
'Passes `command` to be executed by an operating system shell.'
os.exit['<5.1'] =
'Calls the C function `exit` to terminate the host program.'
os.exit['>5.2'] =
'Calls the ISO C function `exit` to terminate the host program.'
os.getenv =
'Returns the value of the process environment variable `varname`.'
os.remove =
'Deletes the file with the given name.'
os.rename =
'Renames the file or directory named `oldname` to `newname`.'
os.setlocale =
'Sets the current locale of the program.'
os.time =
'Returns the current time when called without arguments, or a time representing the local date and time specified by the given table.'
os.tmpname =
'Returns a string with a file name that can be used for a temporary file.'
osdate.year =
'four digits'
osdate.month =
'1-12'
osdate.day =
'1-31'
osdate.hour =
'0-23'
osdate.min =
'0-59'
osdate.sec =
'0-61'
osdate.wday =
'weekday, 17, Sunday is 1'
osdate.yday =
'day of the year, 1366'
osdate.isdst =
'daylight saving flag, a boolean'
package =
''
require['<5.3'] =
'Loads the given module, returns any value returned by the given module(`true` when `nil`).'
require['>5.4'] =
'Loads the given module, returns any value returned by the searcher(`true` when `nil`). Besides that value, also returns as a second result the loader data returned by the searcher, which indicates how `require` found the module. (For instance, if the module came from a file, this loader data is the file path.)'
package.config =
'A string describing some compile-time configurations for packages.'
package.cpath =
'The path used by `require` to search for a C loader.'
package.loaded =
'A table used by `require` to control which modules are already loaded.'
package.loaders =
'A table used by `require` to control how to load modules.'
package.loadlib =
'Dynamically links the host program with the C library `libname`.'
package.path =
'The path used by `require` to search for a Lua loader.'
package.preload =
'A table to store loaders for specific modules.'
package.searchers =
'A table used by `require` to control how to load modules.'
package.searchpath =
'Searches for the given `name` in the given `path`.'
package.seeall =
'Sets a metatable for `module` with its `__index` field referring to the global environment, so that this module inherits values from the global environment. To be used as an option to function `module` .'
string =
''
string.byte =
'Returns the internal numeric codes of the characters `s[i], s[i+1], ..., s[j]`.'
string.char =
'Returns a string with length equal to the number of arguments, in which each character has the internal numeric code equal to its corresponding argument.'
string.dump =
'Returns a string containing a binary representation (a *binary chunk*) of the given function.'
string.find =
'Looks for the first match of `pattern` (see §6.4.1) in the string.'
string.format =
'Returns a formatted version of its variable number of arguments following the description given in its first argument.'
string.gmatch =
[[
Returns an iterator function that, each time it is called, returns the next captures from `pattern` (see §6.4.1) over the string s.
As an example, the following loop will iterate over all the words from string s, printing one per line:
```lua
s =
"hello world from Lua"
for w in string.gmatch(s, "%a+") do
print(w)
end
```
]]
string.gsub =
'Returns a copy of s in which all (or the first `n`, if given) occurrences of the `pattern` (see §6.4.1) have been replaced by a replacement string specified by `repl`.'
string.len =
'Returns its length.'
string.lower =
'Returns a copy of this string with all uppercase letters changed to lowercase.'
string.match =
'Looks for the first match of `pattern` (see §6.4.1) in the string.'
string.pack =
'Returns a binary string containing the values `v1`, `v2`, etc. packed (that is, serialized in binary form) according to the format string `fmt` (see §6.4.2) .'
string.packsize =
'Returns the size of a string resulting from `string.pack` with the given format string `fmt` (see §6.4.2) .'
string.rep['>5.2'] =
'Returns a string that is the concatenation of `n` copies of the string `s` separated by the string `sep`.'
string.rep['<5.1'] =
'Returns a string that is the concatenation of `n` copies of the string `s` .'
string.reverse =
'Returns a string that is the string `s` reversed.'
string.sub =
'Returns the substring of the string that starts at `i` and continues until `j`.'
string.unpack =
'Returns the values packed in string according to the format string `fmt` (see §6.4.2) .'
string.upper =
'Returns a copy of this string with all lowercase letters changed to uppercase.'
table =
''
table.concat =
'Given a list where all elements are strings or numbers, returns the string `list[i]..sep..list[i+1] ··· sep..list[j]`.'
table.insert =
'Inserts element `value` at position `pos` in `list`.'
table.maxn =
'Returns the largest positive numerical index of the given table, or zero if the table has no positive numerical indices.'
table.move =
[[
Moves elements from table `a1` to table `a2`.
```lua
a2[t],··· =
a1[f],···,a1[e]
return a2
```
]]
table.pack =
'Returns a new table with all arguments stored into keys `1`, `2`, etc. and with a field `"n"` with the total number of arguments.'
table.remove =
'Removes from `list` the element at position `pos`, returning the value of the removed element.'
table.sort =
'Sorts list elements in a given order, *in-place*, from `list[1]` to `list[#list]`.'
table.unpack =
[[
Returns the elements from the given list. This function is equivalent to
```lua
return list[i], list[i+1], ···, list[j]
```
By default, `i` is `1` and `j` is `#list`.
]]
table.foreach =
'Executes the given f over all elements of table. For each element, f is called with the index and respective value as arguments. If f returns a non-nil value, then the loop is broken, and this value is returned as the final value of foreach.'
table.foreachi =
'Executes the given f over the numerical indices of table. For each index, f is called with the index and respective value as arguments. Indices are visited in sequential order, from 1 to n, where n is the size of the table. If f returns a non-nil value, then the loop is broken and this value is returned as the result of foreachi.'
table.getn =
'Returns the number of elements in the table. This function is equivalent to `#list`.'
table.new =
[[This creates a pre-sized table, just like the C API equivalent `lua_createtable()`. This is useful for big tables if the final table size is known and automatic table resizing is too expensive. `narray` parameter specifies the number of array-like items, and `nhash` parameter specifies the number of hash-like items. The function needs to be required before use.
```lua
require("table.new")
```
]]
table.clear =
[[This clears all keys and values from a table, but preserves the allocated array/hash sizes. This is useful when a table, which is linked from multiple places, needs to be cleared and/or when recycling a table for use by the same context. This avoids managing backlinks, saves an allocation and the overhead of incremental array/hash part growth. The function needs to be required before use.
```lua
require("table.clear").
```
Please note this function is meant for very specific situations. In most cases it's better to replace the (usually single) link with a new table and let the GC do its work.
]]
utf8 =
''
utf8.char =
'Receives zero or more integers, converts each one to its corresponding UTF-8 byte sequence and returns a string with the concatenation of all these sequences.'
utf8.charpattern =
'The pattern which matches exactly one UTF-8 byte sequence, assuming that the subject is a valid UTF-8 string.'
utf8.codes =
[[
Returns values so that the construction
```lua
for p, c in utf8.codes(s) do
body
end
```
will iterate over all UTF-8 characters in string s, with p being the position (in bytes) and c the code point of each character. It raises an error if it meets any invalid byte sequence.
]]
utf8.codepoint =
'Returns the codepoints (as integers) from all characters in `s` that start between byte position `i` and `j` (both included).'
utf8.len =
'Returns the number of UTF-8 characters in string `s` that start between positions `i` and `j` (both inclusive).'
utf8.offset =
'Returns the position (in bytes) where the encoding of the `n`-th character of `s` (counting from position `i`) starts.'

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,436 @@
---@diagnostic disable: undefined-global
config.addonManager.enable =
"Whether the addon manager is enabled or not."
config.runtime.version =
"Lua runtime version."
config.runtime.path =
[[
When using `require`, how to find the file based on the input name.
Setting this config to `?/init.lua` means that when you enter `require 'myfile'`, `${workspace}/myfile/init.lua` will be searched from the loaded files.
if `runtime.pathStrict` is `false`, `${workspace}/**/myfile/init.lua` will also be searched.
If you want to load files outside the workspace, you need to set `Lua.workspace.library` first.
]]
config.runtime.pathStrict =
'When enabled, `runtime.path` will only search the first level of directories, see the description of `runtime.path`.'
config.runtime.special =
[[The custom global variables are regarded as some special built-in variables, and the language server will provide special support
The following example shows that 'include' is treated as' require '.
```json
"Lua.runtime.special" : {
"include" : "require"
}
```
]]
config.runtime.unicodeName =
"Allows Unicode characters in name."
config.runtime.nonstandardSymbol =
"Supports non-standard symbols. Make sure that your runtime environment supports these symbols."
config.runtime.plugin =
"Plugin path. Please read [wiki](https://luals.github.io/wiki/plugins) to learn more."
config.runtime.pluginArgs =
"Additional arguments for the plugin."
config.runtime.fileEncoding =
"File encoding. The `ansi` option is only available under the `Windows` platform."
config.runtime.builtin =
[[
Adjust the enabled state of the built-in library. You can disable (or redefine) the non-existent library according to the actual runtime environment.
* `default`: Indicates that the library will be enabled or disabled according to the runtime version
* `enable`: always enable
* `disable`: always disable
]]
config.runtime.meta =
'Format of the directory name of the meta files.'
config.diagnostics.enable =
"Enable diagnostics."
config.diagnostics.disable =
"Disabled diagnostic (Use code in hover brackets)."
config.diagnostics.globals =
"Defined global variables."
config.diagnostics.severity =
[[
Modify the diagnostic severity.
End with `!` means override the group setting `diagnostics.groupSeverity`.
]]
config.diagnostics.neededFileStatus =
[[
* Opened: only diagnose opened files
* Any: diagnose all files
* None: disable this diagnostic
End with `!` means override the group setting `diagnostics.groupFileStatus`.
]]
config.diagnostics.groupSeverity =
[[
Modify the diagnostic severity in a group.
`Fallback` means that diagnostics in this group are controlled by `diagnostics.severity` separately.
Other settings will override individual settings without end of `!`.
]]
config.diagnostics.groupFileStatus =
[[
Modify the diagnostic needed file status in a group.
* Opened: only diagnose opened files
* Any: diagnose all files
* None: disable this diagnostic
`Fallback` means that diagnostics in this group are controlled by `diagnostics.neededFileStatus` separately.
Other settings will override individual settings without end of `!`.
]]
config.diagnostics.workspaceEvent =
"Set the time to trigger workspace diagnostics."
config.diagnostics.workspaceEvent.OnChange =
"Trigger workspace diagnostics when the file is changed."
config.diagnostics.workspaceEvent.OnSave =
"Trigger workspace diagnostics when the file is saved."
config.diagnostics.workspaceEvent.None =
"Disable workspace diagnostics."
config.diagnostics.workspaceDelay =
"Latency (milliseconds) for workspace diagnostics."
config.diagnostics.workspaceRate =
"Workspace diagnostics run rate (%). Decreasing this value reduces CPU usage, but also reduces the speed of workspace diagnostics. The diagnosis of the file you are currently editing is always done at full speed and is not affected by this setting."
config.diagnostics.libraryFiles =
"How to diagnose files loaded via `Lua.workspace.library`."
config.diagnostics.libraryFiles.Enable =
"Always diagnose these files."
config.diagnostics.libraryFiles.Opened =
"Only when these files are opened will it be diagnosed."
config.diagnostics.libraryFiles.Disable =
"These files are not diagnosed."
config.diagnostics.ignoredFiles =
"How to diagnose ignored files."
config.diagnostics.ignoredFiles.Enable =
"Always diagnose these files."
config.diagnostics.ignoredFiles.Opened =
"Only when these files are opened will it be diagnosed."
config.diagnostics.ignoredFiles.Disable =
"These files are not diagnosed."
config.diagnostics.disableScheme =
'Do not diagnose Lua files that use the following scheme.'
config.diagnostics.unusedLocalExclude =
'Do not diagnose `unused-local` when the variable name matches the following pattern.'
config.workspace.ignoreDir =
"Ignored files and directories (Use `.gitignore` grammar)."-- .. example.ignoreDir,
config.workspace.ignoreSubmodules =
"Ignore submodules."
config.workspace.useGitIgnore =
"Ignore files list in `.gitignore` ."
config.workspace.maxPreload =
"Max preloaded files."
config.workspace.preloadFileSize =
"Skip files larger than this value (KB) when preloading."
config.workspace.library =
"In addition to the current workspace, which directories will load files from. The files in these directories will be treated as externally provided code libraries, and some features (such as renaming fields) will not modify these files."
config.workspace.checkThirdParty =
[[
Automatic detection and adaptation of third-party libraries, currently supported libraries are:
* OpenResty
* Cocos4.0
* LÖVE
* LÖVR
* skynet
* Jass
]]
config.workspace.userThirdParty =
'Add private third-party library configuration file paths here, please refer to the built-in [configuration file path](https://github.com/LuaLS/lua-language-server/tree/master/meta/3rd)'
config.workspace.supportScheme =
'Provide language server for the Lua files of the following scheme.'
config.completion.enable =
'Enable completion.'
config.completion.callSnippet =
'Shows function call snippets.'
config.completion.callSnippet.Disable =
"Only shows `function name`."
config.completion.callSnippet.Both =
"Shows `function name` and `call snippet`."
config.completion.callSnippet.Replace =
"Only shows `call snippet.`"
config.completion.keywordSnippet =
'Shows keyword syntax snippets.'
config.completion.keywordSnippet.Disable =
"Only shows `keyword`."
config.completion.keywordSnippet.Both =
"Shows `keyword` and `syntax snippet`."
config.completion.keywordSnippet.Replace =
"Only shows `syntax snippet`."
config.completion.displayContext =
"Previewing the relevant code snippet of the suggestion may help you understand the usage of the suggestion. The number set indicates the number of intercepted lines in the code fragment. If it is set to `0`, this feature can be disabled."
config.completion.workspaceWord =
"Whether the displayed context word contains the content of other files in the workspace."
config.completion.showWord =
"Show contextual words in suggestions."
config.completion.showWord.Enable =
"Always show context words in suggestions."
config.completion.showWord.Fallback =
"Contextual words are only displayed when suggestions based on semantics cannot be provided."
config.completion.showWord.Disable =
"Do not display context words."
config.completion.autoRequire =
"When the input looks like a file name, automatically `require` this file."
config.completion.showParams =
"Display parameters in completion list. When the function has multiple definitions, they will be displayed separately."
config.completion.requireSeparator =
"The separator used when `require`."
config.completion.postfix =
"The symbol used to trigger the postfix suggestion."
config.color.mode =
"Color mode."
config.color.mode.Semantic =
"Semantic color. You may need to set `editor.semanticHighlighting.enabled` to `true` to take effect."
config.color.mode.SemanticEnhanced =
"Enhanced semantic color. Like `Semantic`, but with additional analysis which might be more computationally expensive."
config.color.mode.Grammar =
"Grammar color."
config.semantic.enable =
"Enable semantic color. You may need to set `editor.semanticHighlighting.enabled` to `true` to take effect."
config.semantic.variable =
"Semantic coloring of variables/fields/parameters."
config.semantic.annotation =
"Semantic coloring of type annotations."
config.semantic.keyword =
"Semantic coloring of keywords/literals/operators. You only need to enable this feature if your editor cannot do syntax coloring."
config.signatureHelp.enable =
"Enable signature help."
config.hover.enable =
"Enable hover."
config.hover.viewString =
"Hover to view the contents of a string (only if the literal contains an escape character)."
config.hover.viewStringMax =
"The maximum length of a hover to view the contents of a string."
config.hover.viewNumber =
"Hover to view numeric content (only if literal is not decimal)."
config.hover.fieldInfer =
"When hovering to view a table, type infer will be performed for each field. When the accumulated time of type infer reaches the set value (MS), the type infer of subsequent fields will be skipped."
config.hover.previewFields =
"When hovering to view a table, limits the maximum number of previews for fields."
config.hover.enumsLimit =
"When the value corresponds to multiple types, limit the number of types displaying."
config.hover.expandAlias =
[[
Whether to expand the alias. For example, expands `---@alias myType boolean|number` appears as `boolean|number`, otherwise it appears as `myType'.
]]
config.develop.enable =
'Developer mode. Do not enable, performance will be affected.'
config.develop.debuggerPort =
'Listen port of debugger.'
config.develop.debuggerWait =
'Suspend before debugger connects.'
config.intelliSense.searchDepth =
'Set the search depth for IntelliSense. Increasing this value increases accuracy, but decreases performance. Different workspace have different tolerance for this setting. Please adjust it to the appropriate value.'
config.intelliSense.fastGlobal =
'In the global variable completion, and view `_G` suspension prompt. This will slightly reduce the accuracy of type speculation, but it will have a significant performance improvement for projects that use a lot of global variables.'
config.window.statusBar =
'Show extension status in status bar.'
config.window.progressBar =
'Show progress bar in status bar.'
config.hint.enable =
'Enable inlay hint.'
config.hint.paramType =
'Show type hints at the parameter of the function.'
config.hint.setType =
'Show hints of type at assignment operation.'
config.hint.paramName =
'Show hints of parameter name at the function call.'
config.hint.paramName.All =
'All types of parameters are shown.'
config.hint.paramName.Literal =
'Only literal type parameters are shown.'
config.hint.paramName.Disable =
'Disable parameter hints.'
config.hint.arrayIndex =
'Show hints of array index when constructing a table.'
config.hint.arrayIndex.Enable =
'Show hints in all tables.'
config.hint.arrayIndex.Auto =
'Show hints only when the table is greater than 3 items, or the table is a mixed table.'
config.hint.arrayIndex.Disable =
'Disable hints of array index.'
config.hint.await =
'If the called function is marked `---@async`, prompt `await` at the call.'
config.hint.semicolon =
'If there is no semicolon at the end of the statement, display a virtual semicolon.'
config.hint.semicolon.All =
'All statements display virtual semicolons.'
config.hint.semicolon.SameLine =
'When two statements are on the same line, display a semicolon between them.'
config.hint.semicolon.Disable =
'Disable virtual semicolons.'
config.codeLens.enable =
'Enable code lens.'
config.format.enable =
'Enable code formatter.'
config.format.defaultConfig =
[[
The default format configuration. Has a lower priority than `.editorconfig` file in the workspace.
Read [formatter docs](https://github.com/CppCXY/EmmyLuaCodeStyle/tree/master/docs) to learn usage.
]]
config.spell.dict =
'Custom words for spell checking.'
config.nameStyle.config =
'Set name style config'
config.telemetry.enable =
[[
Enable telemetry to send your editor information and error logs over the network. Read our privacy policy [here](https://luals.github.io/privacy/#language-server).
]]
config.misc.parameters =
'[Command line parameters](https://github.com/LuaLS/lua-telemetry-server/tree/master/method) when starting the language server in VSCode.'
config.misc.executablePath =
'Specify the executable path in VSCode.'
config.type.castNumberToInteger =
'Allowed to assign the `number` type to the `integer` type.'
config.type.weakUnionCheck =
[[
Once one subtype of a union type meets the condition, the union type also meets the condition.
When this setting is `false`, the `number|boolean` type cannot be assigned to the `number` type. It can be with `true`.
]]
config.type.weakNilCheck =
[[
When checking the type of union type, ignore the `nil` in it.
When this setting is `false`, the `number|nil` type cannot be assigned to the `number` type. It can be with `true`.
]]
config.doc.privateName =
'Treat specific field names as private, e.g. `m_*` means `XXX.m_id` and `XXX.m_type` are private, witch can only be accessed in the class where the definition is located.'
config.doc.protectedName =
'Treat specific field names as protected, e.g. `m_*` means `XXX.m_id` and `XXX.m_type` are protected, witch can only be accessed in the class where the definition is located and its subclasses.'
config.doc.packageName =
'Treat specific field names as package, e.g. `m_*` means `XXX.m_id` and `XXX.m_type` are package, witch can only be accessed in the file where the definition is located.'
config.diagnostics['unused-local'] =
'Enable unused local variable diagnostics.'
config.diagnostics['unused-function'] =
'Enable unused function diagnostics.'
config.diagnostics['undefined-global'] =
'Enable undefined global variable diagnostics.'
config.diagnostics['global-in-nil-env'] =
'Enable cannot use global variables `_ENV` is set to `nil` diagnostics.'
config.diagnostics['unused-label'] =
'Enable unused label diagnostics.'
config.diagnostics['unused-vararg'] =
'Enable unused vararg diagnostics.'
config.diagnostics['trailing-space'] =
'Enable trailing space diagnostics.'
config.diagnostics['redefined-local'] =
'Enable redefined local variable diagnostics.'
config.diagnostics['newline-call'] =
'Enable newline call diagnostics. Is\'s raised when a line starting with `(` is encountered, which is syntactically parsed as a function call on the previous line.'
config.diagnostics['newfield-call'] =
'Enable newfield call diagnostics. It is raised when the parenthesis of a function call appear on the following line when defining a field in a table.'
config.diagnostics['redundant-parameter'] =
'Enable redundant function parameter diagnostics.'
config.diagnostics['ambiguity-1'] =
'Enable ambiguous operator precedence diagnostics. For example, the `num or 0 + 1` expression will be suggested `(num or 0) + 1` instead.'
config.diagnostics['lowercase-global'] =
'Enable lowercase global variable definition diagnostics.'
config.diagnostics['undefined-env-child'] =
'Enable undefined environment variable diagnostics. It\'s raised when `_ENV` table is set to a new literal table, but the used global variable is no longer present in the global environment.'
config.diagnostics['duplicate-index'] =
'Enable duplicate table index diagnostics.'
config.diagnostics['empty-block'] =
'Enable empty code block diagnostics.'
config.diagnostics['redundant-value'] =
'Enable the redundant values assigned diagnostics. It\'s raised during assignment operation, when the number of values is higher than the number of objects being assigned.'
config.diagnostics['assign-type-mismatch'] =
'Enable diagnostics for assignments in which the value\'s type does not match the type of the assigned variable.'
config.diagnostics['await-in-sync'] =
'Enable diagnostics for calls of asynchronous functions within a synchronous function.'
config.diagnostics['cast-local-type'] =
'Enable diagnostics for casts of local variables where the target type does not match the defined type.'
config.diagnostics['cast-type-mismatch'] =
'Enable diagnostics for casts where the target type does not match the initial type.'
config.diagnostics['circular-doc-class'] =
'Enable diagnostics for two classes inheriting from each other introducing a circular relation.'
config.diagnostics['close-non-object'] =
'Enable diagnostics for attempts to close a variable with a non-object.'
config.diagnostics['code-after-break'] =
'Enable diagnostics for code placed after a break statement in a loop.'
config.diagnostics['codestyle-check'] =
'Enable diagnostics for incorrectly styled lines.'
config.diagnostics['count-down-loop'] =
'Enable diagnostics for `for` loops which will never reach their max/limit because the loop is incrementing instead of decrementing.'
config.diagnostics['deprecated'] =
'Enable diagnostics to highlight deprecated API.'
config.diagnostics['different-requires'] =
'Enable diagnostics for files which are required by two different paths.'
config.diagnostics['discard-returns'] =
'Enable diagnostics for calls of functions annotated with `---@nodiscard` where the return values are ignored.'
config.diagnostics['doc-field-no-class'] =
'Enable diagnostics to highlight a field annotation without a defining class annotation.'
config.diagnostics['duplicate-doc-alias'] =
'Enable diagnostics for a duplicated alias annotation name.'
config.diagnostics['duplicate-doc-field'] =
'Enable diagnostics for a duplicated field annotation name.'
config.diagnostics['duplicate-doc-param'] =
'Enable diagnostics for a duplicated param annotation name.'
config.diagnostics['duplicate-set-field'] =
'Enable diagnostics for setting the same field in a class more than once.'
config.diagnostics['incomplete-signature-doc'] =
'Incomplete @param or @return annotations for functions.'
config.diagnostics['invisible'] =
'Enable diagnostics for accesses to fields which are invisible.'
config.diagnostics['missing-global-doc'] =
'Missing annotations for globals! Global functions must have a comment and annotations for all parameters and return values.'
config.diagnostics['missing-local-export-doc'] =
'Missing annotations for exported locals! Exported local functions must have a comment and annotations for all parameters and return values.'
config.diagnostics['missing-parameter'] =
'Enable diagnostics for function calls where the number of arguments is less than the number of annotated function parameters.'
config.diagnostics['missing-return'] =
'Enable diagnostics for functions with return annotations which have no return statement.'
config.diagnostics['missing-return-value'] =
'Enable diagnostics for return statements without values although the containing function declares returns.'
config.diagnostics['need-check-nil'] =
'Enable diagnostics for variable usages if `nil` or an optional (potentially `nil`) value was assigned to the variable before.'
config.diagnostics['no-unknown'] =
'Enable diagnostics for cases in which the type cannot be inferred.'
config.diagnostics['not-yieldable'] =
'Enable diagnostics for calls to `coroutine.yield()` when it is not permitted.'
config.diagnostics['param-type-mismatch'] =
'Enable diagnostics for function calls where the type of a provided parameter does not match the type of the annotated function definition.'
config.diagnostics['redundant-return'] =
'Enable diagnostics for return statements which are not needed because the function would exit on its own.'
config.diagnostics['redundant-return-value']=
'Enable diagnostics for return statements which return an extra value which is not specified by a return annotation.'
config.diagnostics['return-type-mismatch'] =
'Enable diagnostics for return values whose type does not match the type declared in the corresponding return annotation.'
config.diagnostics['spell-check'] =
'Enable diagnostics for typos in strings.'
config.diagnostics['name-style-check'] =
'Enable diagnostics for name style.'
config.diagnostics['unbalanced-assignments']=
'Enable diagnostics on multiple assignments if not all variables obtain a value (e.g., `local x,y = 1`).'
config.diagnostics['undefined-doc-class'] =
'Enable diagnostics for class annotations in which an undefined class is referenced.'
config.diagnostics['undefined-doc-name'] =
'Enable diagnostics for type annotations referencing an undefined type or alias.'
config.diagnostics['undefined-doc-param'] =
'Enable diagnostics for cases in which a parameter annotation is given without declaring the parameter in the function definition.'
config.diagnostics['undefined-field'] =
'Enable diagnostics for cases in which an undefined field of a variable is read.'
config.diagnostics['unknown-cast-variable'] =
'Enable diagnostics for casts of undefined variables.'
config.diagnostics['unknown-diag-code'] =
'Enable diagnostics in cases in which an unknown diagnostics code is entered.'
config.diagnostics['unknown-operator'] =
'Enable diagnostics for unknown operators.'
config.diagnostics['unreachable-code'] =
'Enable diagnostics for unreachable code.'
config.diagnostics['global-element'] =
'Enable diagnostics to warn about global elements.'
config.typeFormat.config =
'Configures the formatting behavior while typing Lua code.'
config.typeFormat.config.auto_complete_end =
'Controls if `end` is automatically completed at suitable positions.'
config.typeFormat.config.auto_complete_table_sep =
'Controls if a separator is automatically appended at the end of a table declaration.'
config.typeFormat.config.format_line =
'Controls if a line is formatted at all.'
command.exportDocument =
'Lua: Export Document ...'
command.addon_manager.open =
'Lua: Open Addon Manager ...'
command.reloadFFIMeta =
'Lua: Reload luajit ffi meta'

View File

@@ -0,0 +1,83 @@
PUSH [===[]===]
if not JIT then DISABLE() end
PUSH [===[
---@meta bit
---@version JIT
---@class bitlib
bit = {}
---@param x integer
---@return integer y
---@nodiscard
function bit.tobit(x) end
---@param x integer
---@param n? integer
---@return integer y
---@nodiscard
function bit.tohex(x, n) end
---@param x integer
---@return integer y
---@nodiscard
function bit.bnot(x) end
---@param x integer
---@param x2 integer
---@param ... integer
---@return integer y
---@nodiscard
function bit.bor(x, x2, ...) end
---@param x integer
---@param x2 integer
---@param ... integer
---@return integer y
---@nodiscard
function bit.band(x, x2, ...) end
---@param x integer
---@param x2 integer
---@param ... integer
---@return integer y
---@nodiscard
function bit.bxor(x, x2, ...) end
---@param x integer
---@param n integer
---@return integer y
---@nodiscard
function bit.lshift(x, n) end
---@param x integer
---@param n integer
---@return integer y
---@nodiscard
function bit.rshift(x, n) end
---@param x integer
---@param n integer
---@return integer y
---@nodiscard
function bit.arshift(x, n) end
---@param x integer
---@param n integer
---@return integer y
---@nodiscard
function bit.rol(x, n) end
---@param x integer
---@param n integer
---@return integer y
---@nodiscard
function bit.ror(x, n) end
---@param x integer
---@return integer y
---@nodiscard
function bit.bswap(x) end
return bit
]===]

View File

@@ -0,0 +1,80 @@
local fs = require 'bee.filesystem'
local util = require 'utility'
local version = require 'version'
local function getValue(value)
if value == 'true' or value == nil then
value = true
elseif value == 'false' then
value = false
elseif tonumber(value) then
value = tonumber(value)
elseif value:sub(1, 1) == '"' and value:sub(-1, -1) == '"' then
value = value:sub(2, -2)
end
return value
end
local function loadArgs()
---@type string?
local lastKey
for _, v in ipairs(arg) do
---@type string?
local key, tail = v:match '^%-%-([%w_]+)(.*)$'
local value
if key then
value = tail:match '=(.+)'
lastKey = nil
if not value then
lastKey = key
end
else
if lastKey then
key = lastKey
value = v
lastKey = nil
end
end
if key then
_G[key:upper():gsub('-', '_')] = getValue(value)
end
end
end
loadArgs()
local currentPath = debug.getinfo(1, 'S').source:sub(2)
local rootPath = currentPath:gsub('[/\\]*[^/\\]-$', '')
rootPath = (rootPath == '' and '.' or rootPath)
ROOT = fs.path(util.expandPath(rootPath))
LOGPATH = LOGPATH and util.expandPath(LOGPATH) or (ROOT:string() .. '/log')
METAPATH = METAPATH and util.expandPath(METAPATH) or (ROOT:string() .. '/meta')
---@diagnostic disable-next-line: deprecated
debug.setcstacklimit(200)
collectgarbage('generational', 10, 50)
--collectgarbage('incremental', 120, 120, 0)
---@diagnostic disable-next-line: lowercase-global
log = require 'log'
log.init(ROOT, fs.path(LOGPATH) / 'service.log')
if LOGLEVEL then
log.level = tostring(LOGLEVEL):lower()
end
log.info('Lua Lsp startup, root: ', ROOT)
log.info('ROOT:', ROOT:string())
log.info('LOGPATH:', LOGPATH)
log.info('METAPATH:', METAPATH)
log.info('VERSION:', version.getVersion())
require 'tracy'
xpcall(dofile, log.debug, (ROOT / 'debugger.lua'):string())
require 'cli'
local _, service = xpcall(require, log.error, 'service')
service.start()

View File

@@ -0,0 +1,22 @@
{
// if not set, the folder name will be used
"name" : "Example",
// list of matched words
"words" : ["thisIsAnExampleWord%.ifItExistsInFile%.thenTryLoadThisLibrary"],
// list or matched file names. `.lua`, `.dll` and `.so` only
"files" : ["thisIsAnExampleFile%.ifItExistsInWorkSpace%.thenTryLoadThisLibrary%.lua"],
// lsit of settings to be changed
"settings" : {
"Lua.runtime.version" : "LuaJIT",
"Lua.diagnostics.globals" : [
"global1",
"global2"
],
"Lua.runtime.special" : {
"include" : "require"
},
"Lua.runtime.builtin" : {
"io" : "disable"
}
}
}

View File

@@ -0,0 +1,8 @@
---@meta
local m = {}
function m.thisIsAnExampleLibrary()
end
return m

View File

@@ -0,0 +1,16 @@
-- if this file exists, then change setting `Lua.runtime.plugin`
-- see https://luals.github.io/wiki/plugins
function OnSetText(uri, text)
local diffs = {}
for start, finish in text:gmatch '()pairs()' do
diffs[#diffs+1] = {
start = start,
finish = finish - 1,
text = 'safepairs'
}
end
return diffs
end

View File

@@ -0,0 +1,3 @@
{
"words" : [ "require[%s%(\"']+luassert[%)\"']" ]
}

View File

@@ -0,0 +1,441 @@
---@meta
---@class luassert.internal
local internal = {}
---@class luassert:luassert.internal
local luassert = {}
--#region Assertions
---Assert that `value == true`.
---@param value any The value to confirm is `true`.
function internal.True(value) end
internal.is_true = internal.True
internal.is_not_true = internal.True
---Assert that `value == false`.
---@param value any The value to confirm is `false`.
function internal.False(value) end
internal.is_false = internal.False
internal.is_not_false = internal.False
---Assert that `type(value) == "boolean"`.
---@param value any The value to confirm is of type `boolean`.
function internal.Boolean(value) end
internal.boolean = internal.Boolean
internal.is_boolean = internal.Boolean
internal.is_not_boolean = internal.Boolean
---Assert that `type(value) == "number"`.
---@param value any The value to confirm is of type `number`.
function internal.Number(value) end
internal.number = internal.Number
internal.is_number = internal.Number
internal.is_not_number = internal.Number
---Assert that `type(value) == "string"`.
---@param value any The value to confirm is of type `string`.
function internal.String(value) end
internal.string = internal.String
internal.is_string = internal.String
internal.is_not_string = internal.String
---Assert that `type(value) == "table"`.
---@param value any The value to confirm is of type `table`.
function internal.Table(value) end
internal.table = internal.Table
internal.is_table = internal.Table
internal.is_not_table = internal.Table
---Assert that `type(value) == "nil"`.
---@param value any The value to confirm is of type `nil`.
function internal.Nil(value) end
internal.is_nil = internal.Nil
internal.is_not_nil = internal.Nil
---Assert that `type(value) == "userdata"`.
---@param value any The value to confirm is of type `userdata`.
function internal.Userdata(value) end
internal.userdata = internal.Userdata
internal.is_userdata = internal.Userdata
internal.is_not_userdata = internal.Userdata
---Assert that `type(value) == "function"`.
---@param value any The value to confirm is of type `function`.
function internal.Function(value) end
internal.is_function = internal.Function
internal.is_not_function = internal.Function
---Assert that `type(value) == "thread"`.
---@param value any The value to confirm is of type `thread`.
function internal.Thread(value) end
internal.thread = internal.Thread
internal.is_thread = internal.Thread
internal.is_not_thread = internal.Thread
---Assert that a value is truthy.
---@param value any The value to confirm is truthy.
function internal.truthy(value) end
internal.Truthy = internal.truthy
internal.is_truthy = internal.truthy
internal.is_not_truthy = internal.truthy
---Assert that a value is falsy.
---@param value any The value to confirm is falsy.
function internal.falsy(value) end
internal.Falsy = internal.falsy
internal.is_falsy = internal.falsy
internal.is_not_falsy = internal.falsy
---Assert that a callback throws an error.
---@param callback function A callback function that should error
---@param error? string The specific error message that will be asserted
function internal.error(callback, error) end
internal.Error = internal.error
internal.has_error = internal.error
internal.no_error = internal.error
internal.no_has_error = internal.error
internal.has_no_error = internal.error
--- the api is the same as string.find
---@param pattern string
---@param actual string
---@param init? integer
---@param plain? boolean
---## Example
--[[
```lua
it("Checks matches() assertion does string matching", function()
assert.is.error(function() assert.matches('.*') end) -- minimum 2 arguments
assert.is.error(function() assert.matches(nil, 's') end) -- arg1 must be a string
assert.is.error(function() assert.matches('s', {}) end) -- arg2 must be convertable to string
assert.is.error(function() assert.matches('s', 's', 's', 's') end) -- arg3 or arg4 must be a number or nil
assert.matches("%w+", "test")
assert.has.match("%w+", "test")
assert.has_no.match("%d+", "derp")
assert.has.match("test", "test", nil, true)
assert.has_no.match("%w+", "test", nil, true)
assert.has.match("^test", "123 test", 5)
assert.has_no.match("%d+", "123 test", '4')
end)
```
]]
function internal.matches(pattern, actual, init, plain) end
internal.is_matches = internal.matches
internal.is_not_matches = internal.matches
internal.match = internal.matches
internal.is_match = internal.matches
internal.is_not_match = internal.matches
---Assert that two values are near (equal to within a tolerance).
---@param expected number The expected value
---@param actual number The actual value
---@param tolerance number The tolerable difference between the two values
---## Example
--[[
```lua
it("Checks near() assertion handles tolerances", function()
assert.is.error(function() assert.near(0) end) -- minimum 3 arguments
assert.is.error(function() assert.near(0, 0) end) -- minimum 3 arguments
assert.is.error(function() assert.near('a', 0, 0) end) -- arg1 must be convertable to number
assert.is.error(function() assert.near(0, 'a', 0) end) -- arg2 must be convertable to number
assert.is.error(function() assert.near(0, 0, 'a') end) -- arg3 must be convertable to number
assert.is.near(1.5, 2.0, 0.5)
assert.is.near('1.5', '2.0', '0.5')
assert.is_not.near(1.5, 2.0, 0.499)
assert.is_not.near('1.5', '2.0', '0.499')
end)
```
]]
function internal.near(expected, actual, tolerance) end
internal.Near = internal.near
internal.is_near = internal.near
internal.is_not_near = internal.near
---Check that two or more items are equal.
---
---When comparing tables, a reference check will be used.
---@param expected any The expected value
---@param ... any Values to check the equality of
function internal.equal(expected, ...) end
internal.Equal = internal.equal
internal.are_equal = internal.equal
internal.are_not_equal = internal.equal
---Check that two or more items that are considered the "same".
---
---When comparing tables, a deep compare will be performed.
---@param expected any The expected value
---@param ... any Values to check
function internal.same(expected, ...) end
internal.Same = internal.same
internal.are_same = internal.same
internal.are_not_same = internal.same
--- Number of return values of function
---@param argument_number integer
---@param func fun()
function internal.returned_arguments(argument_number, func) end
internal.not_returned_arguments = internal.returned_arguments
--- check error message by string.match/string.find(`plain`=true)
---@param func function
---@param pattern string
---@param init? integer
---@param plain? boolean
---##Example
--[[
```lua
it("Checks error_matches to accept only callable arguments", function()
local t_ok = setmetatable( {}, { __call = function() end } )
local t_nok = setmetatable( {}, { __call = function() error("some error") end } )
local f_ok = function() end
local f_nok = function() error("some error") end
assert.error_matches(f_nok, ".*")
assert.no_error_matches(f_ok, ".*")
assert.error_matches(t_nok, ".*")
assert.no_error_matches(t_ok, ".*")
end)
```
]]
function internal.error_matches(func, pattern, init, plain) end
internal.no_error_matches = internal.error_matches
internal.error_match = internal.error_matches
internal.no_error_match = internal.error_matches
internal.matches_error = internal.error_matches
internal.no_matches_error = internal.error_matches
internal.match_error = internal.error_matches
internal.no_match_error = internal.error_matches
--#endregion
--[[ Helpers ]]
--#region
---Assert that all numbers in two arrays are within a specified tolerance of
---each other.
---@param expected number[] The expected values
---@param actual number[] The actual values
---@param tolerance number The tolerable difference between the values in the two arrays
function internal.all_near(expected, actual, tolerance) end
internal.are_all_near = internal.all_near
internal.are_not_all_near = internal.all_near
--- array is uniqued
---@param arr any[]
---## Example
---```lua
---it("Checks to see if table1 only contains unique elements", function()
--- local table2 = { derp = false}
--- local table3 = { derp = true }
--- local table1 = {table2,table3}
--- local tablenotunique = {table2,table2}
--- assert.is.unique(table1)
--- assert.is_not.unique(tablenotunique)
--- end)
---```
function internal.unique(arr) end
internal.is_unique = internal.unique
internal.is_not_unique = internal.unique
--#endregion
--#region Spies
---Perform an assertion on a spy object. This will allow you to call further
---functions to perform an assertion.
---@param spy luassert.spy The spy object to begin asserting
---@return luassert.spy.assert spyAssert A new object that has further assert function options
function internal.spy(spy) end
---Perform an assertion on a stub object. This will allow you to call further
---functions to perform an assertion.
---@param stub luassert.spy The stub object to begin asserting
---@return luassert.spy.assert stubAssert A new object that has further assert function options
function internal.stub(stub) end
--#endregion
--#region Array
---Perform an assertion on an array object. This will allow you to call further
---function to perform an assertion.
---@param object table<integer, any> The array object to begin asserting
---@return luassert.array arrayAssert A new object that has further assert function options
function internal.array(object) end
--#endregion
--#region test apis
--- register custom assertions
---@param namespace 'assertion' | 'matcher' | 'modifier' | string
---@param name string
---@param callback function
---@param positive_message string
---@param negative_message string
---## Example
--[[
```lua
it("Checks register creates custom assertions", function()
local say = require("say")
local function has_property(state, arguments)
local property = arguments[1]
local table = arguments[2]
for key, value in pairs(table) do
if key == property then
return true
end
end
return false
end
say:set_namespace("en")
say:set("assertion.has_property.positive", "Expected property %s in:\n%s")
say:set("assertion.has_property.negative", "Expected property %s to not be in:\n%s")
assert:register("assertion", "has_property", has_property, "assertion.has_property.positive", "assertion.has_property.negative")
assert.has_property("name", { name = "jack" })
assert.has.property("name", { name = "jack" })
assert.not_has_property("surname", { name = "jack" })
assert.Not.has.property("surname", { name = "jack" })
assert.has_error(function() assert.has_property("surname", { name = "jack" }) end)
assert.has_error(function() assert.has.property("surname", { name = "jack" }) end)
assert.has_error(function() assert.no_has_property("name", { name = "jack" }) end)
assert.has_error(function() assert.no.has.property("name", { name = "jack" }) end)
end)
```
]]
function luassert:register(namespace, name, callback, positive_message, negative_message) end
--[[
### Customized formatters
The formatters are functions taking a single argument that needs to be converted to a string representation. The formatter should examine the value provided, if it can format the value, it should return the formatted string, otherwise it should return `nil`.
Formatters can be added through `assert:add_formatter(formatter_func)`, and removed by calling `assert:remove_formatter(formatter_func)`.
Example using the included binary string formatter:
```lua
local binstring = require("luassert.formatters.binarystring")
describe("Tests using a binary string formatter", function()
setup(function()
assert:add_formatter(binstring)
end)
teardown(function()
assert:remove_formatter(binstring)
end)
it("tests a string comparison with binary formatting", function()
local s1, s2 = "", ""
for n = 65,88 do
s1 = s1 .. string.char(n)
s2 = string.char(n) .. s2
end
assert.are.same(s1, s2)
end)
end)
```
Because this formatter formats string values, and is added last, it will take precedence over the regular string formatter. The results will be:
```
Failure: ...ua projects\busted\formatter\spec\formatter_spec.lua @ 13
tests a string comparison with binary formatting
...ua projects\busted\formatter\spec\formatter_spec.lua:19: Expected objects to be the same. Passed in:
Binary string length; 24 bytes
58 57 56 55 54 53 52 51 50 4f 4e 4d 4c 4b 4a 49 XWVUTSRQ PONMLKJI
48 47 46 45 44 43 42 41 HGFEDCBA
Expected:
Binary string length; 24 bytes
41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 ABCDEFGH IJKLMNOP
51 52 53 54 55 56 57 58 QRSTUVWX
```
]]
---@param callback fun(obj:any):string|nil
function luassert:add_formatter(callback) end
---@param fmtr function
function luassert:remove_formatter(fmtr) end
--- To register state information 'parameters' can be used. The parameter is included in a snapshot and can hence be restored in between tests. For an example see `Configuring table depth display` below.
---@param name any
---@param value any
---## Example
--[[
```lua
assert:set_parameter("my_param_name", 1)
local s = assert:snapshot()
assert:set_parameter("my_param_name", 2)
s:revert()
assert.are.equal(1, assert:get_parameter("my_param_name"))
```
]]
function luassert:set_parameter(name, value) end
--- get current snapshot parameter
---@param name any
---@return any value
function luassert:get_parameter(name) end
---To be able to revert changes created by tests, inserting spies and stubs for example, luassert supports 'snapshots'. A snapshot includes the following;
---@return {revert:fun()}
function luassert:snapshot() end
--#endregion
--- unregister custom assertions
---@param namespace 'assertion' | 'matcher' | 'modifier' | string
---@param name string
function luassert:unregister(namespace, name) end
--#region modifier namespace
internal.are = internal
internal.is = internal
internal.has = internal
internal.does = internal
internal.is_not = internal
internal.are_not = internal
internal.has_no = internal
internal.no_has = internal
internal.does_not = internal
internal.no = internal
internal.Not = internal
--#endregion
return luassert

View File

@@ -0,0 +1,15 @@
---@meta
---@class luassert.array
local array = {}
---Assert that an array has holes in it
---@param length? integer The expected length of the array
---@return integer|nil holeIndex The index of the first found hole or `nil` if there was no hole.
function array.holes(length) end
array.has = array
array.no = array
return array

View File

@@ -0,0 +1,413 @@
---@meta
---Matchers are used to provide flexible argument matching for `called_with` and
---`returned_with` asserts for spies. Just like with asserts, you can chain a
---modifier value using `is` or `is_not`, followed by the matcher you wish to use.
---@class luassert.match
match = {}
---Match a value from a spy
match.is = {}
---Match inverse values from a spy
match.is_not = {}
--- Wildcard match, matches anything.
--
---## Example
---```
---it("tests wildcard matcher", function()
--- local s = spy.new(function() end)
--- local _ = match._
---
--- s("foo")
---
--- assert.spy(s).was_called_with(_) -- matches any argument
--- assert.spy(s).was_not_called_with(_, _) -- does not match two arguments
---end)
---```
match._ = {}
--[[ Modifiers ]]
--#region
---If you're creating a spy for functions that mutate any properties on a table
---(like `self`) and you want to use `was_called_with`, you should use
---`match.is_ref(obj)`.
---
---## Example
---```lua
---describe("combine matchers", function()
--- local match = require("luassert.match")
---
--- it("tests ref matchers for passed in table", function()
--- local t = { count = 0, }
--- function t.incrby(t, i) t.count = t.count + i end
---
--- local s = spy.on(t, "incrby")
---
--- s(t, 2)
---
--- assert.spy(s).was_called_with(match.is_ref(t), 2)
--- end)
---
--- it("tests ref matchers for self", function()
--- local t = { count = 0, }
--- function t:incrby(i) self.count = self.count + i end
---
--- local s = spy.on(t, "incrby")
---
--- t:incrby(2)
---
--- assert.spy(s).was_called_with(match.is_ref(t), 2)
--- end)
---end)
---```
---@param obj any
function match.Ref(obj) end
match.ref = match.Ref
match.is.Ref = match.Ref
match.is.ref = match.Ref
match.is_ref = match.Ref
---Combine matchers, matching all provided matchers.
---@param ... table|function
---```lua
---describe("combine matchers", function()
--- local match = require("luassert.match")
---
--- it("tests composite matchers", function()
--- local s = spy.new(function() end)
---
--- s("foo")
---
--- assert.spy(s).was_called_with(match.is_all_of(
--- match.is_not_nil(),
--- match.is_not_number()
--- ))
--- end)
---end)
---```
function match.all_of(...) end
match.is_all_of = match.all_of
match.is.all_of = match.all_of
---Combine matchers, matching at least one provided matcher.
---@param ... table|function
---```lua
---describe("combine matchers", function()
--- local match = require("luassert.match")
---
--- it("tests composite matchers", function()
--- local s = spy.new(function() end)
---
--- s("foo")
---
--- assert.spy(s).was_called_with(match.is_any_of(
--- match.is_number(),
--- match.is_string(),
--- match.is_boolean()
--- ))
--- end)
---end)
---```
function match.any_of(...) end
match.is_any_of = match.any_of
match.is.any_of = match.any_of
---Combine matchers, matching none of the provided matchers.
---@param ... table|function
---```lua
---describe("combine matchers", function()
--- local match = require("luassert.match")
---
--- it("tests composite matchers", function()
--- local s = spy.new(function() end)
---
--- s("foo")
---
--- assert.spy(s).was_called_with(match.is_none_of(
--- match.is_number(),
--- match.is_table(),
--- match.is_boolean()
--- ))
--- end)
---end)
---```
function match.none_of(...) end
match.is_none_of = match.none_of
match.is.none_of = match.none_of
--#endregion
--[[ Matchers ]]
--#region
---Check that the value is `true`.
---@return boolean isTrue
function match.True() end
match.is.True = match.True
match.is_true = match.True
---Check that the value is `false`.
---@return boolean isFalse
function match.False() end
match.is.True = match.False
match.is_false = match.False
---Check that the value is `nil`.
---@return boolean isNil
function match.Nil() end
match.is.Nil = match.Nil
match.is_nil = match.Nil
---Check that the value is of type `boolean`.
---@return boolean isBoolean
function match.Boolean() end
match.boolean = match.Boolean
match.is.Boolean = match.Boolean
match.is.boolean = match.Boolean
match.is_boolean = match.Boolean
---Check that the value is of type `number`.
---@return boolean isNumber
function match.Number() end
match.number = match.Number
match.is.Number = match.Number
match.is.number = match.Number
match.is_number = match.Number
---Check that the value is of type `string`.
---@return boolean isString
function match.String() end
match.string = match.String
match.is.String = match.String
match.is.string = match.String
match.is_string = match.String
---Check that the value is of type `table`.
---@return boolean isTable
function match.Table() end
match.table = match.Table
match.is.Table = match.Table
match.is.table = match.Table
match.is_table = match.Table
---Check that the value is of type `function`.
---@return boolean isFunction
function match.Function() end
match.is.Function = match.Function
match.is_function = match.Function
---Check that the value is of type `userdata`.
---@return boolean isUserdata
function match.Userdata() end
match.userdata = match.Userdata
match.is.Userdata = match.Userdata
match.is.userdata = match.Userdata
match.is_userdata = match.Userdata
---Check that the value is of type `thread`.
---@return boolean isThread
function match.Thread() end
match.thread = match.Thread
match.is.thread = match.Thread
match.is.Thread = match.Thread
match.is_thread = match.Thread
---Check that the value is truthy.
---@return boolean isTruthy
function match.truthy() end
match.Truthy = match.truthy
match.is.truthy = match.truthy
match.is.Truthy = match.truthy
match.is_truthy = match.truthy
---Check that the value is falsy.
---@return boolean isFalsy
function match.falsy() end
match.Falsy = match.falsy
match.is.falsy = match.falsy
match.is.Falsy = match.falsy
match.is_falsy = match.falsy
---Check that the two values are equal.
---
---When comparing tables, a reference check will be used.
---@param value any The target value
---@return boolean isEqual
function match.Equals(value) end
match.equals = match.Equals
match.is.equals = match.Equals
match.is.equals = match.Equals
match.is_equals = match.Equals
---Check that the two values are considered the "same".
---
---When comparing tables, a deep compare will be performed.
---@param value any The target value
---@return boolean isSame
function match.Same(value) end
match.same = match.Same
match.is.same = match.Same
match.is.same = match.Same
match.is_same = match.Same
---Match a table with unique values. Will pass if no values are duplicates.
---@param deep boolean If a deep check should be performed or just the first level
---@return boolean isUnique
function match.Unique(deep) end
match.unique = match.Unique
match.is.unique = match.Unique
match.is.unique = match.Unique
match.is_unique = match.Unique
---Match a certain numerical value with a specified +/- tolerance.
---@param value number The target value
---@param tolerance number The amount that the true value can be off by (inclusive)
---@return boolean isNear
function match.Near(value, tolerance) end
match.near = match.Near
match.is.near = match.Near
match.is.near = match.Near
match.is_near = match.Near
---Perform a `string.find()` match.
---@param pattern string String match pattern
---@param init integer Index of character to start searching for a match at
---@param plain boolean If the `pattern` should be treated as plain text instead of a pattern
---@return boolean matches
function match.Matches(pattern, init, plain) end
match.matches = match.Matches
match.is.matches = match.Matches
match.is.matches = match.Matches
match.is_matches = match.Matches
match.match = match.Matches
match.Match = match.matches
match.is.match = match.Matches
match.is.Matches = match.Matches
match.is_match = match.Matches
--#endregion
--[[ Inverse Matchers ]]
--#region
---Check that the value is **NOT** `true`.
---@return boolean isTrue
function match.is_not.True() end
match.is_not_true = match.is_not.True
---Check that the value is **NOT** `false`.
---@return boolean isFalse
function match.is_not.False() end
match.is_not_false = match.is_not.False
---Check that the value is **NOT** `nil`.
---@return boolean isNil
function match.is_not.Nil() end
match.is_not_nil = match.is_not.Nil
---Check that the value is **NOT** of type `boolean`.
---@return boolean isBoolean
function match.is_not.Boolean() end
match.is_not.boolean = match.is_not.Boolean
match.is_not_boolean = match.is_not.Boolean
---Check that the value is **NOT** of type `number`.
---@return boolean isNumber
function match.is_not.Number() end
match.is_not.number = match.is_not.Number
match.is_not_number = match.is_not.Number
---Check that the value is **NOT** of type `string`.
---@return boolean isString
function match.is_not.String() end
match.is_not.string = match.is_not.String
match.is_not_string = match.is_not.String
---Check that the value is **NOT** of type `table`.
---@return boolean isTable
function match.is_not.Table() end
match.is_not.table = match.is_not.Table
match.is_not_table = match.is_not.Table
---Check that the value is **NOT** of type `function`.
---@return boolean isFunction
function match.is_not.Function() end
match.is_not_function = match.is_not.Function
---Check that the value is **NOT** of type `userdata`.
---@return boolean isUserdata
function match.is_not.Userdata() end
match.is_not.userdata = match.is_not.Userdata
match.is_not_userdata = match.is_not.Userdata
---Check that the value is **NOT** of type `thread`.
---@return boolean isThread
function match.is_not.Thread() end
match.is_not.Thread = match.is_not.Thread
match.is_not_thread = match.is_not.Thread
---Check that the value is **NOT** truthy.
---@return boolean isTruthy
function match.is_not.truthy() end
match.is_not.Truthy = match.is_not.truthy
match.is_not_truthy = match.is_not.truthy
---Check that the value is **NOT** falsy.
---@return boolean isFalsy
function match.is_not.falsy() end
match.is_not.Falsy = match.is_not.falsy
match.is_not_falsy = match.is_not.falsy
---Check that the two values are **NOT** equal.
---
---When comparing tables, a reference check will be used.
---@param value any The target value
---@return boolean isEqual
function match.is_not.Equals(value) end
match.is_not.equals = match.is_not.Equals
match.is_not_equals = match.is_not.Equals
---Check that the two values are **NOT** considered the "same".
---
---When comparing tables, a deep compare will be performed.
---@param value any The target value
---@return boolean isSame
function match.is_not.Same(value) end
match.is_not.same = match.is_not.Same
match.is_not_same = match.is_not.Same
---Match a table with **NOT** unique values. Will pass if at least one duplicate is found.
---@param deep boolean If a deep check should be performed or just the first level
---@return boolean isUnique
function match.is_not.Unique(deep) end
match.is_not.unique = match.is_not.Unique
match.is_not_unique = match.is_not.Unique
---Match a certain numerical value outside a specified +/- tolerance.
---@param value number The target value
---@param tolerance number The amount that the true value must be off by (inclusive)
---@return boolean isNear
function match.is_not.Near(value, tolerance) end
match.is_not.near = match.is_not.Near
match.is_not_near = match.is_not.Near
---Perform a `string.find()` match to find a value that does **NOT** match.
---@param pattern string String match pattern
---@param init integer Index of character to start searching for a match at
---@param plain boolean If the `pattern` should be treated as plain text instead of a pattern
---@return boolean matches
function match.is_not.Matches(pattern, init, plain) end
match.is_not.matches = match.is_not.Matches
match.is_not_matches = match.is_not.Matches
match.is_not.match = match.is_not.Matches
match.is_not_match = match.is_not.Matches
--#endregion
return match

View File

@@ -0,0 +1,28 @@
---@meta
---@alias luassert.mockeds table<string, luassert.mockeds | luassert.spy>
---A mock wraps an entire table's functions in spies or mocks
---@class luassert.mock : luassert.spy.factory
local mock = {}
---@generic T
---Create a new mock from a table, wrapping all of it's functions in spies or mocks.
---@param object T The table to wrap
---@param doStubs? boolean If the table should be wrapped with stubs instead of spies
---@param func? function Callback function used for stubs
---@param self? table Table to replace with a spy
---@param key? string The key of the method to replace in `self`
---@return luassert.mockeds
function mock(object, doStubs, func, self, key) end
---@generic T
---Create a new mock from a table, wrapping all of it's functions in spies or mocks.
---@param object T The table to wrap
---@param doStubs? boolean If the table should be wrapped with stubs instead of spies
---@param func? function Callback function used for stubs
---@param self? table Table to replace with a spy
---@param key? string The key of the method to replace in `self`
---@return luassert.mockeds
function mock.new(object, doStubs, func, self, key) end
return mock

View File

@@ -0,0 +1,100 @@
---@meta
--[[ Instance ]]
--#region
---An instance of a spy.
---@class luassert.spy
local spy = {}
---Revert the spied on function to its state before being spied on.
---
---Effectively removes spy from spied-on function.
function spy:revert() end
---Clear the call history for this spy.
function spy:clear() end
---Check how many times this spy has been called.
---@param times integer The expected number of calls
---@param compare? fun(callCount, expected): any A compare function, whose result will be returned as the first return value
---@return any result By default, `true` if the spy was called `times` times. Will be the result of `compare` if given
---@return integer calls Number of times called
function spy:called(times, compare) end
---Check that the spy was called with the provided arguments.
---@param args any[] An array of arguments that are expected to have been passed to this spy
---@return boolean was If this spy was called with the provided arguments
---@return any[] arguments If `was == false`, this will be an array of the arguments *last* given to this spy. If `was == true`, this will be an array of the arguments given to the matching call of this spy.
function spy:called_with(args) end
---Check that the spy returned the provided values
---@pasram ... any An array of values that are expected to have been returned by this spy
---@return boolean did If this spy did return the provided values.
---@return any[] returns If `did == false`, this will be an array of the values *last* returned by this spy. If `did == true`, this will be an array of the values returned by the matching call of this spy.
function spy:returned_with(...) end
--#endregion
--[[ Spy Assertion ]]
--#region
---The result of asserting a spy.
---
---Includes functions for performing assertions on a spy.
---@class luassert.spy.assert
local spy_assert = {}
---Assert that the function being spied on was called.
---@param times integer Assert the number of times the function was called
function spy_assert.called(times) end
---Assert that the function being spied on was called with the provided
---parameters.
---@param ... any The parameters that the function is expected to have been called with
function spy_assert.called_with(...) end
---Assert that the function being spied on was **NOT** called with the provided
---parameters.
---@param ... any The parameters that the function is expected to **NOT** have been called with
function spy_assert.not_called_with(...) end
---Assert that the function being spied on was called at **least** a specified
---number of times.
---@param times integer The minimum number of times that the spied-on function should have been called
function spy_assert.called_at_least(times) end
---Assert that the function being spied on was called at **most** a specified
---number of times.
---@param times integer The maximum number of times that the spied-on function should have been called
function spy_assert.called_at_most(times) end
---Assert that the function being spied on was called **more** than the
---specified number of times.
---@param times integer The number of times that the spied-on function should have been called more than
function spy_assert.called_more_than(times) end
---Assert that the function being spied on was called **less** than the
---specified number of times.
---@param times integer The number of times that the spied-on function should have been called less than
function spy_assert.called_less_than(times) end
---Check that the spy returned the provided values
---@param ... any An array of values that are expected to have been returned by this spy
---@return boolean did If this spy did return the provided values.
---@return any[] returns If `did == false`, this will be an array of the values *last* returned by this spy. If `did == true`, this will be an array of the values returned by the matching call of this spy.
function spy_assert.returned_with(...) end
spy_assert.was = {
called = spy_assert.called,
called_with = spy_assert.called_with,
not_called_with = spy_assert.not_called_with,
called_at_least = spy_assert.called_at_least,
called_at_most = spy_assert.called_at_most,
called_more_than = spy_assert.called_more_than,
called_less_than = spy_assert.called_less_than,
returned_with = spy_assert.returned_with,
}
--#endregion

View File

@@ -0,0 +1,81 @@
---@meta
---Spies allow you to wrap a function in order to track how that function was
---called.
---@class luassert.spy.factory
---## Example
---```
---describe("New Spy", function()
--- it("Registers a new function to spy on", function()
--- local s = spy.new(function() end)
---
--- s(1, 2, 3)
--- s(4, 5, 6)
---
--- assert.spy(s).was.called()
--- assert.spy(s).was.called(2)
--- assert.spy(s).was.called_with(1, 2, 3)
--- end)
---```
---@overload fun(target:function):luassert.spy
local spy_factory = {}
--#region
---Register a new function to spy on.
---@param target function The function to spy on
---@return luassert.spy spy A spy object that can be used to perform assertions
---
---## Example
---```
---describe("New Spy", function()
--- it("Registers a new function to spy on", function()
--- local s = spy.new(function() end)
---
--- s(1, 2, 3)
--- s(4, 5, 6)
---
--- assert.spy(s).was.called()
--- assert.spy(s).was.called(2)
--- assert.spy(s).was.called_with(1, 2, 3)
--- end)
---```
function spy_factory.new(target) end
---Create a new spy that replaces a method in a table in place.
---@param table table The table that the method is a part of
---@param methodName string The method to spy on
---@return luassert.spy spy A spy object that can be used to perform assertions
---
---## Example
---```
---describe("Spy On", function()
--- it("Replaces a method in a table", function()
--- local t = {
--- greet = function(msg) print(msg) end
--- }
---
--- local s = spy.on(t, "greet")
---
--- t.greet("Hey!") -- prints 'Hey!'
--- assert.spy(t.greet).was_called_with("Hey!")
---
--- t.greet:clear() -- clears the call history
--- assert.spy(s).was_not_called_with("Hey!")
---
--- t.greet:revert() -- reverts the stub
--- t.greet("Hello!") -- prints 'Hello!', will not pass through the spy
--- assert.spy(s).was_not_called_with("Hello!")
--- end)
---end)
---```
function spy_factory.on(table, methodName) end
---Check that the provided object is a spy.
---@param object any The object to confirm is a spy
---@return boolean isSpy If the object is a spy or not
function spy_factory.is_spy(object) end
--#endregion
return spy_factory

View File

@@ -0,0 +1,50 @@
---@meta
---Function similarly to spies, except that stubs do not call the function that they replace.
---@class luassert.stub
local stub = {}
---Creates a new stub that replaces a method in a table in place.
---@param object table The object that the method is in
---@param key string The key of the method in the `object` to replace
---@param ... any A function that operates on the remaining passed in values and returns more values or just values to return
---@return luassert.spy stub A stub object that can be used to perform assertions
---@return any ... Values returned by a passed in function or just the values passed in
function stub(object, key, ...) end
---Creates a new stub that replaces a method in a table in place.
---@param object table The object that the method is in
---@param key string The key of the method in the `object` to replace
---@param ... any A function that operates on the remaining passed in values and returns more values or just values to return
---@return luassert.spy stub A stub object that can be used to perform assertions
---@return any ... Values returned by a passed in function or just the values passed in
---
---## Example
---```
---describe("Stubs", function()
--- local t = {
--- lottery = function(...)
--- print("Your numbers: " .. table.concat({ ... }, ","))
--- end,
--- }
---
--- it("Tests stubs", function()
--- local myStub = stub.new(t, "lottery")
---
--- t.lottery(1, 2, 3) -- does not print
--- t.lottery(4, 5, 6) -- does not print
---
--- assert.stub(myStub).called_with(1, 2, 3)
--- assert.stub(myStub).called_with(4, 5, 6)
--- assert.stub(myStub).called(2)
--- assert.stub(myStub).called_less_than(3)
---
--- myStub:revert()
---
--- t.lottery(10, 11, 12) -- prints
--- end)
---end)
---```
function stub.new(object, key, ...) end
return stub

View File

@@ -0,0 +1,438 @@
---@meta _
---
---Command-line arguments of Lua Standalone.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-arg)
---
---@type string[]
arg = {}
---
---Raises an error if the value of its argument v is false (i.e., `nil` or `false`); otherwise, returns all its arguments. In case of error, `message` is the error object; when absent, it defaults to `"assertion failed!"`
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-assert)
---
---@generic T
---@param v? T
---@param message? any
---@param ... any
---@return T
---@return any ...
function assert(v, message, ...) end
---@alias gcoptions
---|>"collect" # Performs a full garbage-collection cycle.
---| "stop" # Stops automatic execution.
---| "restart" # Restarts automatic execution.
---| "count" # Returns the total memory in Kbytes.
---| "step" # Performs a garbage-collection step.
---| "isrunning" # Returns whether the collector is running.
---| "setpause" # Set `pause`.
---| "setstepmul" # Set `step multiplier`.
---
---This function is a generic interface to the garbage collector. It performs different functions according to its first argument, `opt`.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-collectgarbage)
---
---@param opt? gcoptions
---@param arg? integer
---@return any
function collectgarbage(opt, arg) end
---
---Opens the named file and executes its content as a Lua chunk. When called without arguments, `dofile` executes the content of the standard input (`stdin`). Returns all values returned by the chunk. In case of errors, `dofile` propagates the error to its caller. (That is, `dofile` does not run in protected mode.)
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-dofile)
---
---@param filename? string
---@return any ...
function dofile(filename) end
---
---Terminates the last protected function called and returns message as the error object.
---
---Usually, `error` adds some information about the error position at the beginning of the message, if the message is a string.
---
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-error)
---
---@param message any
---@param level? integer
function error(message, level) end
---
---A global variable (not a function) that holds the global environment (see [§2.2](http://www.lua.org/manual/5.1/manual.html#2.2)). Lua itself does not use this variable; changing its value does not affect any environment, nor vice versa.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-_G)
---
---@class _G
_G = {}
---@version 5.1
---
---Returns the current environment in use by the function. `f` can be a Lua function or a number that specifies the function at that stack level.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-getfenv)
---
---@param f? integer|async fun(...):...
---@return table
---@nodiscard
function getfenv(f) end
---
---If object does not have a metatable, returns nil. Otherwise, if the object's metatable has a __metatable field, returns the associated value. Otherwise, returns the metatable of the given object.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-getmetatable)
---
---@param object any
---@return table metatable
---@nodiscard
function getmetatable(object) end
---
---Returns three values (an iterator function, the table `t`, and `0`) so that the construction
---```lua
--- for i,v in ipairs(t) do body end
---```
---will iterate over the keyvalue pairs `(1,t[1]), (2,t[2]), ...`, up to the first absent index.
---
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-ipairs)
---
---@generic T: table, V
---@param t T
---@return fun(table: V[], i?: integer):integer, V
---@return T
---@return integer i
function ipairs(t) end
---@alias loadmode
---| "b" # Only binary chunks.
---| "t" # Only text chunks.
---|>"bt" # Both binary and text.
---
---Loads a chunk.
---
---If `chunk` is a string, the chunk is this string. If `chunk` is a function, `load` calls it repeatedly to get the chunk pieces. Each call to `chunk` must return a string that concatenates with previous results. A return of an empty string, `nil`, or no value signals the end of the chunk.
---
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-load)
---
---@param chunk string|function
---@param chunkname? string
---@param mode? loadmode
---@param env? table
---@return function?
---@return string? error_message
---@nodiscard
function load(chunk, chunkname, mode, env) end
---
---Loads a chunk from file `filename` or from the standard input, if no file name is given.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-loadfile)
---
---@param filename? string
---@param mode? loadmode
---@param env? table
---@return function?
---@return string? error_message
---@nodiscard
function loadfile(filename, mode, env) end
---@version 5.1
---
---Loads a chunk from the given string.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-loadstring)
---
---@param text string
---@param chunkname? string
---@return function?
---@return string? error_message
---@nodiscard
function loadstring(text, chunkname) end
---@version 5.1
---@param proxy boolean|table|userdata
---@return userdata
---@nodiscard
function newproxy(proxy) end
---@version 5.1
---
---Creates a module.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-module)
---
---@param name string
---@param ... any
function module(name, ...) end
---
---Allows a program to traverse all fields of a table. Its first argument is a table and its second argument is an index in this table. A call to `next` returns the next index of the table and its associated value. When called with `nil` as its second argument, `next` returns an initial index and its associated value. When called with the last index, or with `nil` in an empty table, `next` returns `nil`. If the second argument is absent, then it is interpreted as `nil`. In particular, you can use `next(t)` to check whether a table is empty.
---
---The order in which the indices are enumerated is not specified, *even for numeric indices*. (To traverse a table in numerical order, use a numerical `for`.)
---
---The behavior of `next` is undefined if, during the traversal, you assign any value to a non-existent field in the table. You may however modify existing fields. In particular, you may set existing fields to nil.
---
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-next)
---
---@generic K, V
---@param table table<K, V>
---@param index? K
---@return K?
---@return V?
---@nodiscard
function next(table, index) end
---
---If `t` has a metamethod `__pairs`, calls it with t as argument and returns the first three results from the call.
---
---Otherwise, returns three values: the [next](http://www.lua.org/manual/5.1/manual.html#pdf-next) function, the table `t`, and `nil`, so that the construction
---```lua
--- for k,v in pairs(t) do body end
---```
---will iterate over all keyvalue pairs of table `t`.
---
---See function [next](http://www.lua.org/manual/5.1/manual.html#pdf-next) for the caveats of modifying the table during its traversal.
---
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-pairs)
---
---@generic T: table, K, V
---@param t T
---@return fun(table: table<K, V>, index?: K):K, V
---@return T
function pairs(t) end
---
---Calls the function `f` with the given arguments in *protected mode*. This means that any error inside `f` is not propagated; instead, `pcall` catches the error and returns a status code. Its first result is the status code (a boolean), which is true if the call succeeds without errors. In such case, `pcall` also returns all results from the call, after this first result. In case of any error, `pcall` returns `false` plus the error object.
---
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-pcall)
---
---@param f async fun(...):...
---@param arg1? any
---@param ... any
---@return boolean success
---@return any result
---@return any ...
function pcall(f, arg1, ...) end
---
---Receives any number of arguments and prints their values to `stdout`, converting each argument to a string following the same rules of [tostring](http://www.lua.org/manual/5.1/manual.html#pdf-tostring).
---The function print is not intended for formatted output, but only as a quick way to show a value, for instance for debugging. For complete control over the output, use [string.format](http://www.lua.org/manual/5.1/manual.html#pdf-string.format) and [io.write](http://www.lua.org/manual/5.1/manual.html#pdf-io.write).
---
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-print)
---
---@param ... any
function print(...) end
---
---Checks whether v1 is equal to v2, without invoking the `__eq` metamethod.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-rawequal)
---
---@param v1 any
---@param v2 any
---@return boolean
---@nodiscard
function rawequal(v1, v2) end
---
---Gets the real value of `table[index]`, without invoking the `__index` metamethod.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-rawget)
---
---@param table table
---@param index any
---@return any
---@nodiscard
function rawget(table, index) end
---
---Returns the length of the object `v`, without invoking the `__len` metamethod.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-rawlen)
---
---@param v table|string
---@return integer len
---@nodiscard
function rawlen(v) end
---
---Sets the real value of `table[index]` to `value`, without using the `__newindex` metavalue. `table` must be a table, `index` any value different from `nil` and `NaN`, and `value` any Lua value.
---This function returns `table`.
---
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-rawset)
---
---@param table table
---@param index any
---@param value any
---@return table
function rawset(table, index, value) end
---
---If `index` is a number, returns all arguments after argument number `index`; a negative number indexes from the end (`-1` is the last argument). Otherwise, `index` must be the string `"#"`, and `select` returns the total number of extra arguments it received.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-select)
---
---@param index integer|"#"
---@param ... any
---@return any
---@nodiscard
function select(index, ...) end
---@version 5.1
---
---Sets the environment to be used by the given function.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-setfenv)
---
---@param f async fun(...):...|integer
---@param table table
---@return function
function setfenv(f, table) end
---@class metatable
---@field __mode 'v'|'k'|'kv'|nil
---@field __metatable any|nil
---@field __tostring (fun(t):string)|nil
---@field __gc fun(t)|nil
---@field __add (fun(t1,t2):any)|nil
---@field __sub (fun(t1,t2):any)|nil
---@field __mul (fun(t1,t2):any)|nil
---@field __div (fun(t1,t2):any)|nil
---@field __mod (fun(t1,t2):any)|nil
---@field __pow (fun(t1,t2):any)|nil
---@field __unm (fun(t):any)|nil
---@field __concat (fun(t1,t2):any)|nil
---@field __len (fun(t):integer)|nil
---@field __eq (fun(t1,t2):boolean)|nil
---@field __lt (fun(t1,t2):boolean)|nil
---@field __le (fun(t1,t2):boolean)|nil
---@field __index table|(fun(t,k):any)|nil
---@field __newindex table|fun(t,k,v)|nil
---@field __call (fun(t,...):...)|nil
---
---Sets the metatable for the given table. If `metatable` is `nil`, removes the metatable of the given table. If the original metatable has a `__metatable` field, raises an error.
---
---This function returns `table`.
---
---To change the metatable of other types from Lua code, you must use the debug library ([§6.10](http://www.lua.org/manual/5.1/manual.html#6.10)).
---
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-setmetatable)
---
---@param table table
---@param metatable? metatable|table
---@return table
function setmetatable(table, metatable) end
---
---When called with no `base`, `tonumber` tries to convert its argument to a number. If the argument is already a number or a string convertible to a number, then `tonumber` returns this number; otherwise, it returns `fail`.
---
---The conversion of strings can result in integers or floats, according to the lexical conventions of Lua (see [§3.1](http://www.lua.org/manual/5.1/manual.html#3.1)). The string may have leading and trailing spaces and a sign.
---
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-tonumber)
---
---@overload fun(e: string, base: integer):integer
---@param e any
---@return number?
---@nodiscard
function tonumber(e) end
---
---Receives a value of any type and converts it to a string in a human-readable format.
---
---If the metatable of `v` has a `__tostring` field, then `tostring` calls the corresponding value with `v` as argument, and uses the result of the call as its result. Otherwise, if the metatable of `v` has a `__name` field with a string value, `tostring` may use that string in its final result.
---
---For complete control of how numbers are converted, use [string.format](http://www.lua.org/manual/5.1/manual.html#pdf-string.format).
---
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-tostring)
---
---@param v any
---@return string
---@nodiscard
function tostring(v) end
---@alias type
---| "nil"
---| "number"
---| "string"
---| "boolean"
---| "table"
---| "function"
---| "thread"
---| "userdata"
---
---Returns the type of its only argument, coded as a string. The possible results of this function are `"nil"` (a string, not the value `nil`), `"number"`, `"string"`, `"boolean"`, `"table"`, `"function"`, `"thread"`, and `"userdata"`.
---
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-type)
---
---@param v any
---@return type type
---@nodiscard
function type(v) end
---
---A global variable (not a function) that holds a string containing the running Lua version.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-_VERSION)
---
_VERSION = "Lua 5.1"
---@version >5.4
---
---Emits a warning with a message composed by the concatenation of all its arguments (which should be strings).
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-warn)
---
---@param message string
---@param ... any
function warn(message, ...) end
---
---Calls function `f` with the given arguments in protected mode with a new message handler.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-xpcall)
---
---@param f async fun(...):...
---@param msgh function
---@param arg1? any
---@param ... any
---@return boolean success
---@return any result
---@return any ...
function xpcall(f, msgh, arg1, ...) end
---@version 5.1
---
---Returns the elements from the given `list`. This function is equivalent to
---```lua
--- return list[i], list[i+1], ···, list[j]
---```
---
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-unpack)
---
---@generic T
---@param list T[]
---@param i? integer
---@param j? integer
---@return T ...
---@nodiscard
function unpack(list, i, j) end

View File

@@ -0,0 +1,79 @@
---@meta bit
---@version JIT
---@class bitlib
bit = {}
---@param x integer
---@return integer y
---@nodiscard
function bit.tobit(x) end
---@param x integer
---@param n? integer
---@return integer y
---@nodiscard
function bit.tohex(x, n) end
---@param x integer
---@return integer y
---@nodiscard
function bit.bnot(x) end
---@param x integer
---@param x2 integer
---@param ... integer
---@return integer y
---@nodiscard
function bit.bor(x, x2, ...) end
---@param x integer
---@param x2 integer
---@param ... integer
---@return integer y
---@nodiscard
function bit.band(x, x2, ...) end
---@param x integer
---@param x2 integer
---@param ... integer
---@return integer y
---@nodiscard
function bit.bxor(x, x2, ...) end
---@param x integer
---@param n integer
---@return integer y
---@nodiscard
function bit.lshift(x, n) end
---@param x integer
---@param n integer
---@return integer y
---@nodiscard
function bit.rshift(x, n) end
---@param x integer
---@param n integer
---@return integer y
---@nodiscard
function bit.arshift(x, n) end
---@param x integer
---@param n integer
---@return integer y
---@nodiscard
function bit.rol(x, n) end
---@param x integer
---@param n integer
---@return integer y
---@nodiscard
function bit.ror(x, n) end
---@param x integer
---@return integer y
---@nodiscard
function bit.bswap(x) end
return bit

View File

@@ -0,0 +1,158 @@
---@meta bit32
---@version 5.2
---
---
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-bit32)
---
---@class bit32lib
bit32 = {}
---
---Returns the number `x` shifted `disp` bits to the right. Negative displacements shift to the left.
---
---This shift operation is what is called arithmetic shift. Vacant bits on the left are filled with copies of the higher bit of `x`; vacant bits on the right are filled with zeros.
---
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-bit32.arshift)
---
---@param x integer
---@param disp integer
---@return integer
---@nodiscard
function bit32.arshift(x, disp) end
---
---Returns the bitwise *and* of its operands.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-bit32.band)
---
---@return integer
---@nodiscard
function bit32.band(...) end
---
---Returns the bitwise negation of `x`.
---
---```lua
---assert(bit32.bnot(x) ==
---(-1 - x) % 2^32)
---```
---
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-bit32.bnot)
---
---@param x integer
---@return integer
---@nodiscard
function bit32.bnot(x) end
---
---Returns the bitwise *or* of its operands.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-bit32.bor)
---
---@return integer
---@nodiscard
function bit32.bor(...) end
---
---Returns a boolean signaling whether the bitwise *and* of its operands is different from zero.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-bit32.btest)
---
---@return boolean
---@nodiscard
function bit32.btest(...) end
---
---Returns the bitwise *exclusive or* of its operands.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-bit32.bxor)
---
---@return integer
---@nodiscard
function bit32.bxor(...) end
---
---Returns the unsigned number formed by the bits `field` to `field + width - 1` from `n`.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-bit32.extract)
---
---@param n integer
---@param field integer
---@param width? integer
---@return integer
---@nodiscard
function bit32.extract(n, field, width) end
---
---Returns a copy of `n` with the bits `field` to `field + width - 1` replaced by the value `v` .
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-bit32.replace)
---
---@param n integer
---@param v integer
---@param field integer
---@param width? integer
---@nodiscard
function bit32.replace(n, v, field, width) end
---
---Returns the number `x` rotated `disp` bits to the left. Negative displacements rotate to the right.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-bit32.lrotate)
---
---@param x integer
---@param distp integer
---@return integer
---@nodiscard
function bit32.lrotate(x, distp) end
---
---Returns the number `x` shifted `disp` bits to the left. Negative displacements shift to the right. In any direction, vacant bits are filled with zeros.
---
---```lua
---assert(bit32.lshift(b, disp) ==
---(b * 2^disp) % 2^32)
---```
---
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-bit32.lshift)
---
---@param x integer
---@param distp integer
---@return integer
---@nodiscard
function bit32.lshift(x, distp) end
---
---Returns the number `x` rotated `disp` bits to the right. Negative displacements rotate to the left.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-bit32.rrotate)
---
---@param x integer
---@param distp integer
---@return integer
---@nodiscard
function bit32.rrotate(x, distp) end
---
---Returns the number `x` shifted `disp` bits to the right. Negative displacements shift to the left. In any direction, vacant bits are filled with zeros.
---
---```lua
---assert(bit32.rshift(b, disp) ==
---math.floor(b % 2^32 / 2^disp))
---```
---
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-bit32.rshift)
---
---@param x integer
---@param distp integer
---@return integer
---@nodiscard
function bit32.rshift(x, distp) end
return bit32

View File

@@ -0,0 +1,16 @@
---@meta _
---@class unknown
---@class any
---@class nil
---@class boolean
---@class true: boolean
---@class false: boolean
---@class number
---@class integer: number
---@class thread
---@class table<K, V>: { [K]: V }
---@class string: stringlib
---@class userdata
---@class lightuserdata
---@class function

View File

@@ -0,0 +1,96 @@
---@meta coroutine
---
---
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-coroutine)
---
---@class coroutinelib
coroutine = {}
---
---Creates a new coroutine, with body `f`. `f` must be a function. Returns this new coroutine, an object with type `"thread"`.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-coroutine.create)
---
---@param f async fun(...):...
---@return thread
---@nodiscard
function coroutine.create(f) end
---@version >5.2
---
---Returns true when the running coroutine can yield.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-coroutine.isyieldable)
---
---@return boolean
---@nodiscard
function coroutine.isyieldable() end
---@version >5.4
---
---Closes coroutine `co` , closing all its pending to-be-closed variables and putting the coroutine in a dead state.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-coroutine.close)
---
---@param co thread
---@return boolean noerror
---@return any errorobject
function coroutine.close(co) end
---
---Starts or continues the execution of coroutine `co`.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-coroutine.resume)
---
---@param co thread
---@param val1? any
---@return boolean success
---@return any ...
function coroutine.resume(co, val1, ...) end
---
---Returns the running coroutine plus a boolean, true when the running coroutine is the main one.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-coroutine.running)
---
---@return thread running
---@return boolean ismain
---@nodiscard
function coroutine.running() end
---
---Returns the status of coroutine `co`.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-coroutine.status)
---
---@param co thread
---@return
---| '"running"' # Is running.
---| '"suspended"' # Is suspended or not started.
---| '"normal"' # Is active but not running.
---| '"dead"' # Has finished or stopped with an error.
---@nodiscard
function coroutine.status(co) end
---
---Creates a new coroutine, with body `f`; `f` must be a function. Returns a function that resumes the coroutine each time it is called.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-coroutine.wrap)
---
---@param f async fun(...):...
---@return fun(...):...
---@nodiscard
function coroutine.wrap(f) end
---
---Suspends the execution of the calling coroutine.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-coroutine.yield)
---
---@async
---@return any ...
function coroutine.yield(...) end
return coroutine

View File

@@ -0,0 +1,262 @@
---@meta debug
---
---
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-debug)
---
---@class debuglib
debug = {}
---@class debuginfo
---@field name string
---@field namewhat string
---@field source string
---@field short_src string
---@field linedefined integer
---@field lastlinedefined integer
---@field what string
---@field currentline integer
---@field istailcall boolean
---@field nups integer
---@field nparams integer
---@field isvararg boolean
---@field func function
---@field activelines table
---
---Enters an interactive mode with the user, running each string that the user enters.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-debug.debug)
---
function debug.debug() end
---@version 5.1
---
---Returns the environment of object `o` .
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-debug.getfenv)
---
---@param o any
---@return table
---@nodiscard
function debug.getfenv(o) end
---
---Returns the current hook settings of the thread.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-debug.gethook)
---
---@param co? thread
---@return function hook
---@return string mask
---@return integer count
---@nodiscard
function debug.gethook(co) end
---@alias infowhat string
---|+"n" # `name` and `namewhat`
---|+"S" # `source`, `short_src`, `linedefined`, `lastlinedefined`, and `what`
---|+"l" # `currentline`
---|+"t" # `istailcall`
---|+"u" # `nups`, `nparams`, and `isvararg`
---|+"f" # `func`
---|+"L" # `activelines`
---
---Returns a table with information about a function.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-debug.getinfo)
---
---@overload fun(f: integer|function, what?: infowhat):debuginfo
---@param thread thread
---@param f integer|async fun(...):...
---@param what? infowhat
---@return debuginfo
---@nodiscard
function debug.getinfo(thread, f, what) end
---
---Returns the name and the value of the local variable with index `local` of the function at level `f` of the stack.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-debug.getlocal)
---
---@overload fun(f: integer|async fun(...):..., index: integer):string, any
---@param thread thread
---@param f integer|async fun(...):...
---@param index integer
---@return string name
---@return any value
---@nodiscard
function debug.getlocal(thread, f, index) end
---
---Returns the metatable of the given value.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-debug.getmetatable)
---
---@param object any
---@return table metatable
---@nodiscard
function debug.getmetatable(object) end
---
---Returns the registry table.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-debug.getregistry)
---
---@return table
---@nodiscard
function debug.getregistry() end
---
---Returns the name and the value of the upvalue with index `up` of the function.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-debug.getupvalue)
---
---@param f async fun(...):...
---@param up integer
---@return string name
---@return any value
---@nodiscard
function debug.getupvalue(f, up) end
---
---Returns the Lua value associated to u.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-debug.getuservalue)
---
---@param u userdata
---@return any
---@nodiscard
function debug.getuservalue(u) end
---
---### **Deprecated in `Lua 5.4.2`**
---
---Sets a new limit for the C stack. This limit controls how deeply nested calls can go in Lua, with the intent of avoiding a stack overflow.
---
---In case of success, this function returns the old limit. In case of error, it returns `false`.
---
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-debug.setcstacklimit)
---
---@deprecated
---@param limit integer
---@return integer|boolean
function debug.setcstacklimit(limit) end
---
---Sets the environment of the given `object` to the given `table` .
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-debug.setfenv)
---
---@version 5.1
---@generic T
---@param object T
---@param env table
---@return T object
function debug.setfenv(object, env) end
---@alias hookmask string
---|+"c" # Calls hook when Lua calls a function.
---|+"r" # Calls hook when Lua returns from a function.
---|+"l" # Calls hook when Lua enters a new line of code.
---
---Sets the given function as a hook.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-debug.sethook)
---
---@overload fun(hook: (async fun(...):...), mask: hookmask, count?: integer)
---@overload fun(thread: thread):...
---@overload fun(...):...
---@param thread thread
---@param hook async fun(...):...
---@param mask hookmask
---@param count? integer
function debug.sethook(thread, hook, mask, count) end
---
---Assigns the `value` to the local variable with index `local` of the function at `level` of the stack.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-debug.setlocal)
---
---@overload fun(level: integer, index: integer, value: any):string
---@param thread thread
---@param level integer
---@param index integer
---@param value any
---@return string name
function debug.setlocal(thread, level, index, value) end
---
---Sets the metatable for the given value to the given table (which can be `nil`).
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-debug.setmetatable)
---
---@generic T
---@param value T
---@param meta? table
---@return T value
function debug.setmetatable(value, meta) end
---
---Assigns the `value` to the upvalue with index `up` of the function.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-debug.setupvalue)
---
---@param f async fun(...):...
---@param up integer
---@param value any
---@return string name
function debug.setupvalue(f, up, value) end
---
---Sets the given value as the Lua value associated to the given udata.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-debug.setuservalue)
---
---@param udata userdata
---@param value any
---@return userdata udata
function debug.setuservalue(udata, value) end
---
---Returns a string with a traceback of the call stack. The optional message string is appended at the beginning of the traceback.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-debug.traceback)
---
---@overload fun(message?: any, level?: integer): string
---@param thread thread
---@param message? any
---@param level? integer
---@return string message
---@nodiscard
function debug.traceback(thread, message, level) end
---@version >5.2, JIT
---
---Returns a unique identifier (as a light userdata) for the upvalue numbered `n` from the given function.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-debug.upvalueid)
---
---@param f async fun(...):...
---@param n integer
---@return lightuserdata id
---@nodiscard
function debug.upvalueid(f, n) end
---@version >5.2, JIT
---
---Make the `n1`-th upvalue of the Lua closure `f1` refer to the `n2`-th upvalue of the Lua closure `f2`.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-debug.upvaluejoin)
---
---@param f1 async fun(...):...
---@param n1 integer
---@param f2 async fun(...):...
---@param n2 integer
function debug.upvaluejoin(f1, n1, f2, n2) end
return debug

View File

@@ -0,0 +1,121 @@
---@meta ffi
---@class ffi.namespace*: table
---@field [string] function
---@class ffi.ctype*: userdata
---@overload fun(init?: any, ...): ffi.cdata*
---@overload fun(nelem?: integer, init?: any, ...): ffi.cdata*
local ctype
---@class ffi.cdecl*: string
---@class ffi.cdata*: userdata
---@alias ffi.ct* ffi.ctype*|ffi.cdecl*|ffi.cdata*
---@class ffi.cb*: ffi.cdata*
local cb
---@class ffi.VLA*: userdata
---@class ffi.VLS*: userdata
---@version JIT
---@class ffilib
---@field C ffi.namespace*
---@field os string
---@field arch string
local ffi = {}
---@param def string
---@param params? any
function ffi.cdef(def, params, ...) end
---@param name string
---@param global? boolean
---@return ffi.namespace* clib
---@nodiscard
function ffi.load(name, global) end
---@overload fun(ct: ffi.ct*, init: any, ...)
---@param ct ffi.ct*
---@param nelem? integer
---@param init? any
---@return ffi.cdata* cdata
---@nodiscard
function ffi.new(ct, nelem, init, ...) end
---@param ct ffi.ct*
---@param params? any
---@return ffi.ctype* ctype
---@nodiscard
function ffi.typeof(ct, params, ...) end
---@param ct ffi.ct*
---@param init any
---@return ffi.cdata* cdata
---@nodiscard
function ffi.cast(ct, init) end
---@param ct ffi.ct*
---@param metatable table
---@return ffi.ctype* ctype
function ffi.metatype(ct, metatable) end
---@param cdata ffi.cdata*
---@param finalizer? function
---@return ffi.cdata* cdata
function ffi.gc(cdata, finalizer) end
---@param ct ffi.ct*
---@param nelem? integer
---@return integer|nil size
---@nodiscard
function ffi.sizeof(ct, nelem) end
---@param ct ffi.ct*
---@return integer align
---@nodiscard
function ffi.alignof(ct) end
---@param ct ffi.ct*
---@param field string
---@return integer ofs
---@return integer? bpos
---@return integer? bsize
---@nodiscard
function ffi.offsetof(ct, field) end
---@param ct ffi.ct*
---@param obj any
---@return boolean status
---@nodiscard
function ffi.istype(ct, obj) end
---@param newerr? integer
---@return integer err
---@nodiscard
function ffi.errno(newerr) end
---@param ptr any
---@param len? integer
---@return string str
function ffi.string(ptr, len) end
---@overload fun(dst: any, str: string)
---@param dst any
---@param src any
---@param len integer
function ffi.copy(dst, src, len) end
---@param dst any
---@param len integer
---@param c? any
function ffi.fill(dst, len, c) end
---@param param string
---@return boolean status
function ffi.abi(param) end
function cb:free() end
---@param func function
function cb:set(func) end
return ffi

View File

@@ -0,0 +1,265 @@
---@meta io
---
---
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-io)
---
---@class iolib
---
---standard input.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-io.stdin)
---
---@field stdin file*
---
---standard output.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-io.stdout)
---
---@field stdout file*
---
---standard error.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-io.stderr)
---
---@field stderr file*
io = {}
---@alias openmode
---|>"r" # Read mode.
---| "w" # Write mode.
---| "a" # Append mode.
---| "r+" # Update mode, all previous data is preserved.
---| "w+" # Update mode, all previous data is erased.
---| "a+" # Append update mode, previous data is preserved, writing is only allowed at the end of file.
---| "rb" # Read mode. (in binary mode.)
---| "wb" # Write mode. (in binary mode.)
---| "ab" # Append mode. (in binary mode.)
---| "r+b" # Update mode, all previous data is preserved. (in binary mode.)
---| "w+b" # Update mode, all previous data is erased. (in binary mode.)
---| "a+b" # Append update mode, previous data is preserved, writing is only allowed at the end of file. (in binary mode.)
---
---Close `file` or default output file.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-io.close)
---
---@param file? file*
---@return boolean? suc
---@return exitcode? exitcode
---@return integer? code
function io.close(file) end
---
---Saves any written data to default output file.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-io.flush)
---
function io.flush() end
---
---Sets `file` as the default input file.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-io.input)
---
---@overload fun():file*
---@param file string|file*
function io.input(file) end
---
---------
---```lua
---for c in io.lines(filename, ...) do
--- body
---end
---```
---
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-io.lines)
---
---@param filename string?
---@param ... readmode
---@return fun():any, ...
function io.lines(filename, ...) end
---
---Opens a file, in the mode specified in the string `mode`.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-io.open)
---
---@param filename string
---@param mode? openmode
---@return file*?
---@return string? errmsg
---@nodiscard
function io.open(filename, mode) end
---
---Sets `file` as the default output file.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-io.output)
---
---@overload fun():file*
---@param file string|file*
function io.output(file) end
---@alias popenmode
---| "r" # Read data from this program by `file`.
---| "w" # Write data to this program by `file`.
---
---Starts program prog in a separated process.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-io.popen)
---
---@param prog string
---@param mode? popenmode
---@return file*?
---@return string? errmsg
function io.popen(prog, mode) end
---
---Reads the `file`, according to the given formats, which specify what to read.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-io.read)
---
---@param ... readmode
---@return any
---@return any ...
---@nodiscard
function io.read(...) end
---
---In case of success, returns a handle for a temporary file.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-io.tmpfile)
---
---@return file*
---@nodiscard
function io.tmpfile() end
---@alias filetype
---| "file" # Is an open file handle.
---| "closed file" # Is a closed file handle.
---| `nil` # Is not a file handle.
---
---Checks whether `obj` is a valid file handle.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-io.type)
---
---@param file file*
---@return filetype
---@nodiscard
function io.type(file) end
---
---Writes the value of each of its arguments to default output file.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-io.write)
---
---@return file*
---@return string? errmsg
function io.write(...) end
---
---
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-file)
---
---@class file*
local file = {}
---@alias readmode integer|string
---| "*n" # Reads a numeral and returns it as number.
---| "*a" # Reads the whole file.
---|>"*l" # Reads the next line skipping the end of line.
---| "*L" # Reads the next line keeping the end of line.
---@alias exitcode "exit"|"signal"
---
---Close `file`.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-file:close)
---
---@return boolean? suc
---@return exitcode? exitcode
---@return integer? code
function file:close() end
---
---Saves any written data to `file`.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-file:flush)
---
function file:flush() end
---
---------
---```lua
---for c in file:lines(...) do
--- body
---end
---```
---
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-file:lines)
---
---@param ... readmode
---@return fun():any, ...
function file:lines(...) end
---
---Reads the `file`, according to the given formats, which specify what to read.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-file:read)
---
---@param ... readmode
---@return any
---@return any ...
---@nodiscard
function file:read(...) end
---@alias seekwhence
---| "set" # Base is beginning of the file.
---|>"cur" # Base is current position.
---| "end" # Base is end of file.
---
---Sets and gets the file position, measured from the beginning of the file.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-file:seek)
---
---@param whence? seekwhence
---@param offset? integer
---@return integer offset
---@return string? errmsg
function file:seek(whence, offset) end
---@alias vbuf
---| "no" # Output operation appears immediately.
---| "full" # Performed only when the buffer is full.
---| "line" # Buffered until a newline is output.
---
---Sets the buffering mode for an output file.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-file:setvbuf)
---
---@param mode vbuf
---@param size? integer
function file:setvbuf(mode, size) end
---
---Writes the value of each of its arguments to `file`.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-file:write)
---
---@param ... string|number
---@return file*?
---@return string? errmsg
function file:write(...) end
return io

View File

@@ -0,0 +1,42 @@
---@meta jit
---@version JIT
---@class jitlib
---@field version string
---@field version_num number
---@field os 'Windows'|'Linux'|'OSX'|'BSD'|'POSIX'|'Other'
---@field arch 'x86'|'x64'|'arm'|'arm64'|'arm64be'|'ppc'|'ppc64'|'ppc64le'|'mips'|'mipsel'|'mips64'|'mips64el'|string
jit = {}
---@overload fun(...):...
---@param func function|boolean
---@param recursive? boolean
function jit.on(func, recursive)
end
---@overload fun(...):...
---@param func function|boolean
---@param recursive? boolean
function jit.off(func, recursive)
end
---@overload fun(...):...
---@overload fun(tr: number)
---@param func function|boolean
---@param recursive? boolean
function jit.flush(func, recursive)
end
---@return boolean status
---@return string ...
---@nodiscard
function jit.status()
end
jit.opt = {}
---@param ... any flags
function jit.opt.start(...)
end
return jit

View File

@@ -0,0 +1,19 @@
---@meta jit.profile
local profile = {}
---@param mode string
---@param func fun(L: thread, samples: integer, vmst: string)
function profile.start(mode, func)
end
function profile.stop()
end
---@overload fun(th: thread, fmt: string, depth: integer)
---@param fmt string
---@param depth integer
function profile.dumpstack(fmt, depth)
end
return profile

View File

@@ -0,0 +1,119 @@
---@meta jit.util
---@class Trace
---@class Proto
local util = {}
---@class jit.funcinfo.lua
local funcinfo = {
linedefined = 0,
lastlinedefined = 0,
stackslots = 0,
params = 0,
bytecodes = 0,
gcconsts = 0,
nconsts = 0,
upvalues = 0,
currentline = 0,
isvararg = false,
children = false,
source = "",
loc = "",
---@type Proto[]
proto = {}
}
---@class jit.funcinfo.c
---@field ffid integer|nil
local funcinfo2 = {
addr = 0,
upvalues = 0,
}
---@param func function
---@param pc? integer
---@return jit.funcinfo.c|jit.funcinfo.lua info
function util.funcinfo(func, pc)
end
---@param func function
---@param pc integer
---@return integer? ins
---@return integer? m
function util.funcbc(func, pc)
end
---@param func function
---@param idx integer
---@return any? k
function util.funck(func, idx)
end
---@param func function
---@param idx integer
---@return string? name
function util.funcuvname(func, idx)
end
---@class jit.traceinfo
local traceinfo = {
nins = 0,
nk = 0,
link = 0,
nexit = 0,
linktype = ""
}
---@param tr Trace
---@return jit.traceinfo? info
function util.traceinfo(tr)
end
---@param tr Trace
---@param ref integer
---@return integer? m
---@return integer? ot
---@return integer? op1
---@return integer? op2
---@return integer? prev
function util.traceir(tr, ref)
end
---@param tr Trace
---@param idx integer
---@return any? k
---@return integer? t
---@return integer? slot
function util.tracek(tr, idx)
end
---@class jit.snap : integer[]
---@param tr Trace
---@param sn integer
---@return jit.snap? snap
function util.tracesnap(tr, sn)
end
---@param tr Trace
---@return string? mcode
---@return integer? addr
---@return integer? loop
function util.tracemc(tr)
end
---@overload fun(exitno: integer): integer
---@param tr Trace
---@param exitno integer
---@return integer? addr
function util.traceexitstub(tr, exitno)
end
---@param idx integer
---@return integer? addr
function util.ircalladdr(idx)
end
return util

View File

@@ -0,0 +1,362 @@
---@meta math
---
---
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-math)
---
---@class mathlib
---
---A value larger than any other numeric value.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-math.huge)
---
---@field huge number
---
---The value of *π*.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-math.pi)
---
---@field pi number
math = {}
---
---Returns the absolute value of `x`.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-math.abs)
---
---@generic Number: number
---@param x Number
---@return Number
---@nodiscard
function math.abs(x) end
---
---Returns the arc cosine of `x` (in radians).
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-math.acos)
---
---@param x number
---@return number
---@nodiscard
function math.acos(x) end
---
---Returns the arc sine of `x` (in radians).
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-math.asin)
---
---@param x number
---@return number
---@nodiscard
function math.asin(x) end
---
---Returns the arc tangent of `x` (in radians).
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-math.atan)
---
---@param y number
---@return number
---@nodiscard
function math.atan(y) end
---@version <5.2
---
---Returns the arc tangent of `y/x` (in radians).
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-math.atan2)
---
---@param y number
---@param x number
---@return number
---@nodiscard
function math.atan2(y, x) end
---
---Returns the smallest integral value larger than or equal to `x`.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-math.ceil)
---
---@param x number
---@return integer
---@nodiscard
function math.ceil(x) end
---
---Returns the cosine of `x` (assumed to be in radians).
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-math.cos)
---
---@param x number
---@return number
---@nodiscard
function math.cos(x) end
---@version <5.2
---
---Returns the hyperbolic cosine of `x` (assumed to be in radians).
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-math.cosh)
---
---@param x number
---@return number
---@nodiscard
function math.cosh(x) end
---
---Converts the angle `x` from radians to degrees.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-math.deg)
---
---@param x number
---@return number
---@nodiscard
function math.deg(x) end
---
---Returns the value `e^x` (where `e` is the base of natural logarithms).
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-math.exp)
---
---@param x number
---@return number
---@nodiscard
function math.exp(x) end
---
---Returns the largest integral value smaller than or equal to `x`.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-math.floor)
---
---@param x number
---@return integer
---@nodiscard
function math.floor(x) end
---
---Returns the remainder of the division of `x` by `y` that rounds the quotient towards zero.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-math.fmod)
---
---@param x number
---@param y number
---@return number
---@nodiscard
function math.fmod(x, y) end
---@version <5.2
---
---Decompose `x` into tails and exponents. Returns `m` and `e` such that `x = m * (2 ^ e)`, `e` is an integer and the absolute value of `m` is in the range [0.5, 1) (or zero when `x` is zero).
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-math.frexp)
---
---@param x number
---@return number m
---@return number e
---@nodiscard
function math.frexp(x) end
---@version <5.2
---
---Returns `m * (2 ^ e)` .
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-math.ldexp)
---
---@param m number
---@param e number
---@return number
---@nodiscard
function math.ldexp(m, e) end
---
---Returns the logarithm of `x` in the given base.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-math.log)
---
---@param x number
---@param base? integer
---@return number
---@nodiscard
function math.log(x, base) end
---@version <5.1
---
---Returns the base-10 logarithm of x.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-math.log10)
---
---@param x number
---@return number
---@nodiscard
function math.log10(x) end
---
---Returns the argument with the maximum value, according to the Lua operator `<`.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-math.max)
---
---@generic Number: number
---@param x Number
---@param ... Number
---@return Number
---@nodiscard
function math.max(x, ...) end
---
---Returns the argument with the minimum value, according to the Lua operator `<`.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-math.min)
---
---@generic Number: number
---@param x Number
---@param ... Number
---@return Number
---@nodiscard
function math.min(x, ...) end
---
---Returns the integral part of `x` and the fractional part of `x`.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-math.modf)
---
---@param x number
---@return integer
---@return number
---@nodiscard
function math.modf(x) end
---@version <5.2
---
---Returns `x ^ y` .
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-math.pow)
---
---@param x number
---@param y number
---@return number
---@nodiscard
function math.pow(x, y) end
---
---Converts the angle `x` from degrees to radians.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-math.rad)
---
---@param x number
---@return number
---@nodiscard
function math.rad(x) end
---
---* `math.random()`: Returns a float in the range [0,1).
---* `math.random(n)`: Returns a integer in the range [1, n].
---* `math.random(m, n)`: Returns a integer in the range [m, n].
---
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-math.random)
---
---@overload fun():number
---@overload fun(m: integer):integer
---@param m integer
---@param n integer
---@return integer
---@nodiscard
function math.random(m, n) end
---
---Sets `x` as the "seed" for the pseudo-random generator.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-math.randomseed)
---
---@param x integer
function math.randomseed(x) end
---
---Returns the sine of `x` (assumed to be in radians).
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-math.sin)
---
---@param x number
---@return number
---@nodiscard
function math.sin(x) end
---@version <5.2
---
---Returns the hyperbolic sine of `x` (assumed to be in radians).
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-math.sinh)
---
---@param x number
---@return number
---@nodiscard
function math.sinh(x) end
---
---Returns the square root of `x`.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-math.sqrt)
---
---@param x number
---@return number
---@nodiscard
function math.sqrt(x) end
---
---Returns the tangent of `x` (assumed to be in radians).
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-math.tan)
---
---@param x number
---@return number
---@nodiscard
function math.tan(x) end
---@version <5.2
---
---Returns the hyperbolic tangent of `x` (assumed to be in radians).
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-math.tanh)
---
---@param x number
---@return number
---@nodiscard
function math.tanh(x) end
---@version >5.3
---
---Miss locale <math.tointeger>
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-math.tointeger)
---
---@param x any
---@return integer?
---@nodiscard
function math.tointeger(x) end
---
---Miss locale <math.type>
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-math.type)
---
---@param x any
---@return
---| '"integer"'
---| '"float"'
---| 'nil'
---@nodiscard
function math.type(x) end
---
---Miss locale <math.ult>
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-math.ult)
---
---@param m integer
---@param n integer
---@return boolean
---@nodiscard
function math.ult(m, n) end
return math

View File

@@ -0,0 +1,242 @@
---@meta os
---
---
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-os)
---
---@class oslib
os = {}
---
---Returns an approximation of the amount in seconds of CPU time used by the program.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-os.clock)
---
---@return number
---@nodiscard
function os.clock() end
---@class osdate
---
---four digits
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-osdate.year)
---
---@field year integer|string
---
---1-12
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-osdate.month)
---
---@field month integer|string
---
---1-31
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-osdate.day)
---
---@field day integer|string
---
---0-23
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-osdate.hour)
---
---@field hour integer|string
---
---0-59
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-osdate.min)
---
---@field min integer|string
---
---0-61
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-osdate.sec)
---
---@field sec integer|string
---
---weekday, 17, Sunday is 1
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-osdate.wday)
---
---@field wday integer|string
---
---day of the year, 1366
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-osdate.yday)
---
---@field yday integer|string
---
---daylight saving flag, a boolean
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-osdate.isdst)
---
---@field isdst boolean
---
---Returns a string or a table containing date and time, formatted according to the given string `format`.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-os.date)
---
---@param format? string
---@param time? integer
---@return string|osdate
---@nodiscard
function os.date(format, time) end
---
---Returns the difference, in seconds, from time `t1` to time `t2`.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-os.difftime)
---
---@param t2 integer
---@param t1 integer
---@return integer
---@nodiscard
function os.difftime(t2, t1) end
---
---Passes `command` to be executed by an operating system shell.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-os.execute)
---
---@param command? string
---@return boolean? suc
---@return exitcode? exitcode
---@return integer? code
function os.execute(command) end
---
---Calls the ISO C function `exit` to terminate the host program.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-os.exit)
---
---@param code? boolean|integer
---@param close? boolean
function os.exit(code, close) end
---
---Returns the value of the process environment variable `varname`.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-os.getenv)
---
---@param varname string
---@return string?
---@nodiscard
function os.getenv(varname) end
---
---Deletes the file with the given name.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-os.remove)
---
---@param filename string
---@return boolean suc
---@return string? errmsg
function os.remove(filename) end
---
---Renames the file or directory named `oldname` to `newname`.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-os.rename)
---
---@param oldname string
---@param newname string
---@return boolean suc
---@return string? errmsg
function os.rename(oldname, newname) end
---@alias localecategory
---|>"all"
---| "collate"
---| "ctype"
---| "monetary"
---| "numeric"
---| "time"
---
---Sets the current locale of the program.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-os.setlocale)
---
---@param locale string|nil
---@param category? localecategory
---@return string localecategory
function os.setlocale(locale, category) end
---@class osdateparam
---
---four digits
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-osdate.year)
---
---@field year integer|string
---
---1-12
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-osdate.month)
---
---@field month integer|string
---
---1-31
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-osdate.day)
---
---@field day integer|string
---
---0-23
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-osdate.hour)
---
---@field hour (integer|string)?
---
---0-59
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-osdate.min)
---
---@field min (integer|string)?
---
---0-61
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-osdate.sec)
---
---@field sec (integer|string)?
---
---weekday, 17, Sunday is 1
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-osdate.wday)
---
---@field wday (integer|string)?
---
---day of the year, 1366
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-osdate.yday)
---
---@field yday (integer|string)?
---
---daylight saving flag, a boolean
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-osdate.isdst)
---
---@field isdst boolean?
---
---Returns the current time when called without arguments, or a time representing the local date and time specified by the given table.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-os.time)
---
---@param date? osdateparam
---@return integer
---@nodiscard
function os.time(date) end
---
---Returns a string with a file name that can be used for a temporary file.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-os.tmpname)
---
---@return string
---@nodiscard
function os.tmpname() end
return os

View File

@@ -0,0 +1,106 @@
---@meta package
---
---Loads the given module, returns any value returned by the given module(`true` when `nil`).
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-require)
---
---@param modname string
---@return unknown
function require(modname) end
---
---
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-package)
---
---@class packagelib
---
---The path used by `require` to search for a C loader.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-package.cpath)
---
---@field cpath string
---
---A table used by `require` to control which modules are already loaded.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-package.loaded)
---
---@field loaded table
---
---The path used by `require` to search for a Lua loader.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-package.path)
---
---@field path string
---
---A table to store loaders for specific modules.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-package.preload)
---
---@field preload table
package = {}
---
---A string describing some compile-time configurations for packages.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-package.config)
---
package.config = [[
/
;
?
!
-]]
---@version <5.1
---
---A table used by `require` to control how to load modules.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-package.loaders)
---
package.loaders = {}
---
---Dynamically links the host program with the C library `libname`.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-package.loadlib)
---
---@param libname string
---@param funcname string
---@return any
function package.loadlib(libname, funcname) end
---
---A table used by `require` to control how to load modules.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-package.searchers)
---
---@version >5.2
package.searchers = {}
---
---Searches for the given `name` in the given `path`.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-package.searchpath)
---
---@version >5.2,JIT
---@param name string
---@param path string
---@param sep? string
---@param rep? string
---@return string? filename
---@return string? errmsg
---@nodiscard
function package.searchpath(name, path, sep, rep) end
---
---Sets a metatable for `module` with its `__index` field referring to the global environment, so that this module inherits values from the global environment. To be used as an option to function `module` .
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-package.seeall)
---
---@version <5.1
---@param module table
function package.seeall(module) end
return package

View File

@@ -0,0 +1,221 @@
---@meta string
---
---
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-string)
---
---@class stringlib
string = {}
---
---Returns the internal numeric codes of the characters `s[i], s[i+1], ..., s[j]`.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-string.byte)
---
---@param s string|number
---@param i? integer
---@param j? integer
---@return integer ...
---@nodiscard
function string.byte(s, i, j) end
---
---Returns a string with length equal to the number of arguments, in which each character has the internal numeric code equal to its corresponding argument.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-string.char)
---
---@param byte integer
---@param ... integer
---@return string
---@nodiscard
function string.char(byte, ...) end
---
---Returns a string containing a binary representation (a *binary chunk*) of the given function.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-string.dump)
---
---@param f async fun(...):...
---@param strip? boolean
---@return string
---@nodiscard
function string.dump(f, strip) end
---
---Looks for the first match of `pattern` (see [§6.4.1](http://www.lua.org/manual/5.1/manual.html#6.4.1)) in the string.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-string.find)
---
---@param s string|number
---@param pattern string|number
---@param init? integer
---@param plain? boolean
---@return integer|nil start
---@return integer|nil end
---@return any|nil ... captured
---@nodiscard
function string.find(s, pattern, init, plain) end
---
---Returns a formatted version of its variable number of arguments following the description given in its first argument.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-string.format)
---
---@param s string|number
---@param ... any
---@return string
---@nodiscard
function string.format(s, ...) end
---
---Returns an iterator function that, each time it is called, returns the next captures from `pattern` (see [§6.4.1](http://www.lua.org/manual/5.1/manual.html#6.4.1)) over the string s.
---
---As an example, the following loop will iterate over all the words from string s, printing one per line:
---```lua
--- s =
---"hello world from Lua"
--- for w in string.gmatch(s, "%a+") do
--- print(w)
--- end
---```
---
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-string.gmatch)
---
---@param s string|number
---@param pattern string|number
---@return fun():string, ...
---@nodiscard
function string.gmatch(s, pattern) end
---
---Returns a copy of s in which all (or the first `n`, if given) occurrences of the `pattern` (see [§6.4.1](http://www.lua.org/manual/5.1/manual.html#6.4.1)) have been replaced by a replacement string specified by `repl`.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-string.gsub)
---
---@param s string|number
---@param pattern string|number
---@param repl string|number|table|function
---@param n? integer
---@return string
---@return integer count
---@nodiscard
function string.gsub(s, pattern, repl, n) end
---
---Returns its length.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-string.len)
---
---@param s string|number
---@return integer
---@nodiscard
function string.len(s) end
---
---Returns a copy of this string with all uppercase letters changed to lowercase.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-string.lower)
---
---@param s string|number
---@return string
---@nodiscard
function string.lower(s) end
---
---Looks for the first match of `pattern` (see [§6.4.1](http://www.lua.org/manual/5.1/manual.html#6.4.1)) in the string.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-string.match)
---
---@param s string|number
---@param pattern string|number
---@param init? integer
---@return any ...
---@nodiscard
function string.match(s, pattern, init) end
---@version >5.3
---
---Returns a binary string containing the values `v1`, `v2`, etc. packed (that is, serialized in binary form) according to the format string `fmt` (see [§6.4.2](http://www.lua.org/manual/5.1/manual.html#6.4.2)) .
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-string.pack)
---
---@param fmt string
---@param v1 string|number
---@param v2? string|number
---@param ... string|number
---@return string binary
---@nodiscard
function string.pack(fmt, v1, v2, ...) end
---@version >5.3
---
---Returns the size of a string resulting from `string.pack` with the given format string `fmt` (see [§6.4.2](http://www.lua.org/manual/5.1/manual.html#6.4.2)) .
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-string.packsize)
---
---@param fmt string
---@return integer
---@nodiscard
function string.packsize(fmt) end
---
---Returns a string that is the concatenation of `n` copies of the string `s` separated by the string `sep`.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-string.rep)
---
---@param s string|number
---@param n integer
---@param sep? string|number
---@return string
---@nodiscard
function string.rep(s, n, sep) end
---
---Returns a string that is the string `s` reversed.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-string.reverse)
---
---@param s string|number
---@return string
---@nodiscard
function string.reverse(s) end
---
---Returns the substring of the string that starts at `i` and continues until `j`.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-string.sub)
---
---@param s string|number
---@param i integer
---@param j? integer
---@return string
---@nodiscard
function string.sub(s, i, j) end
---@version >5.3
---
---Returns the values packed in string according to the format string `fmt` (see [§6.4.2](http://www.lua.org/manual/5.1/manual.html#6.4.2)) .
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-string.unpack)
---
---@param fmt string
---@param s string
---@param pos? integer
---@return any ...
---@return integer offset
---@nodiscard
function string.unpack(fmt, s, pos) end
---
---Returns a copy of this string with all lowercase letters changed to uppercase.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-string.upper)
---
---@param s string|number
---@return string
---@nodiscard
function string.upper(s) end
return string

View File

@@ -0,0 +1,353 @@
---@meta string.buffer
---@version JIT
--- The string buffer library allows high-performance manipulation of string-like data.
---
--- Unlike Lua strings, which are constants, string buffers are mutable sequences of 8-bit (binary-transparent) characters. Data can be stored, formatted and encoded into a string buffer and later converted, extracted or decoded.
---
--- The convenient string buffer API simplifies common string manipulation tasks, that would otherwise require creating many intermediate strings. String buffers improve performance by eliminating redundant memory copies, object creation, string interning and garbage collection overhead. In conjunction with the FFI library, they allow zero-copy operations.
---
--- The string buffer libary also includes a high-performance serializer for Lua objects.
---
---
--- ## Streaming Serialization
---
--- In some contexts, it's desirable to do piecewise serialization of large datasets, also known as streaming.
---
--- This serialization format can be safely concatenated and supports streaming. Multiple encodings can simply be appended to a buffer and later decoded individually:
---
--- ```lua
--- local buf = buffer.new()
--- buf:encode(obj1)
--- buf:encode(obj2)
--- local copy1 = buf:decode()
--- local copy2 = buf:decode()
--- ```
---
--- Here's how to iterate over a stream:
---
--- ```lua
--- while #buf ~= 0 do
--- local obj = buf:decode()
--- -- Do something with obj.
--- end
--- ```
---
--- Since the serialization format doesn't prepend a length to its encoding, network applications may need to transmit the length, too.
--- Serialization Format Specification
---
--- This serialization format is designed for internal use by LuaJIT applications. Serialized data is upwards-compatible and portable across all supported LuaJIT platforms.
---
--- It's an 8-bit binary format and not human-readable. It uses e.g. embedded zeroes and stores embedded Lua string objects unmodified, which are 8-bit-clean, too. Encoded data can be safely concatenated for streaming and later decoded one top-level object at a time.
---
--- The encoding is reasonably compact, but tuned for maximum performance, not for minimum space usage. It compresses well with any of the common byte-oriented data compression algorithms.
---
--- Although documented here for reference, this format is explicitly not intended to be a 'public standard' for structured data interchange across computer languages (like JSON or MessagePack). Please do not use it as such.
---
--- The specification is given below as a context-free grammar with a top-level object as the starting point. Alternatives are separated by the | symbol and * indicates repeats. Grouping is implicit or indicated by {…}. Terminals are either plain hex numbers, encoded as bytes, or have a .format suffix.
---
--- ```
--- object → nil | false | true
--- | null | lightud32 | lightud64
--- | int | num | tab | tab_mt
--- | int64 | uint64 | complex
--- | string
---
--- nil → 0x00
--- false → 0x01
--- true → 0x02
---
--- null → 0x03 // NULL lightuserdata
--- lightud32 → 0x04 data.I // 32 bit lightuserdata
--- lightud64 → 0x05 data.L // 64 bit lightuserdata
---
--- int → 0x06 int.I // int32_t
--- num → 0x07 double.L
---
--- tab → 0x08 // Empty table
--- | 0x09 h.U h*{object object} // Key/value hash
--- | 0x0a a.U a*object // 0-based array
--- | 0x0b a.U a*object h.U h*{object object} // Mixed
--- | 0x0c a.U (a-1)*object // 1-based array
--- | 0x0d a.U (a-1)*object h.U h*{object object} // Mixed
--- tab_mt → 0x0e (index-1).U tab // Metatable dict entry
---
--- int64 → 0x10 int.L // FFI int64_t
--- uint64 → 0x11 uint.L // FFI uint64_t
--- complex → 0x12 re.L im.L // FFI complex
---
--- string → (0x20+len).U len*char.B
--- | 0x0f (index-1).U // String dict entry
---
--- .B = 8 bit
--- .I = 32 bit little-endian
--- .L = 64 bit little-endian
--- .U = prefix-encoded 32 bit unsigned number n:
--- 0x00..0xdf → n.B
--- 0xe0..0x1fdf → (0xe0|(((n-0xe0)>>8)&0x1f)).B ((n-0xe0)&0xff).B
--- 0x1fe0.. → 0xff n.I
--- ```
---
--- ## Error handling
---
--- Many of the buffer methods can throw an error. Out-of-memory or usage errors are best caught with an outer wrapper for larger parts of code. There's not much one can do after that, anyway.
---
--- OTOH you may want to catch some errors individually. Buffer methods need to receive the buffer object as the first argument. The Lua colon-syntax `obj:method()` does that implicitly. But to wrap a method with `pcall()`, the arguments need to be passed like this:
---
--- ```lua
--- local ok, err = pcall(buf.encode, buf, obj)
--- if not ok then
--- -- Handle error in err.
--- end
--- ```
---
--- ## FFI caveats
---
--- The string buffer library has been designed to work well together with the FFI library. But due to the low-level nature of the FFI library, some care needs to be taken:
---
--- First, please remember that FFI pointers are zero-indexed. The space returned by `buf:reserve()` and `buf:ref()` starts at the returned pointer and ends before len bytes after that.
---
--- I.e. the first valid index is `ptr[0]` and the last valid index is `ptr[len-1]`. If the returned length is zero, there's no valid index at all. The returned pointer may even be `NULL`.
---
--- The space pointed to by the returned pointer is only valid as long as the buffer is not modified in any way (neither append, nor consume, nor reset, etc.). The pointer is also not a GC anchor for the buffer object itself.
---
--- Buffer data is only guaranteed to be byte-aligned. Casting the returned pointer to a data type with higher alignment may cause unaligned accesses. It depends on the CPU architecture whether this is allowed or not (it's always OK on x86/x64 and mostly OK on other modern architectures).
---
--- FFI pointers or references do not count as GC anchors for an underlying object. E.g. an array allocated with `ffi.new()` is anchored by `buf:set(array, len)`, but not by `buf:set(array+offset, len)`. The addition of the offset creates a new pointer, even when the offset is zero. In this case, you need to make sure there's still a reference to the original array as long as its contents are in use by the buffer.
---
--- Even though each LuaJIT VM instance is single-threaded (but you can create multiple VMs), FFI data structures can be accessed concurrently. Be careful when reading/writing FFI cdata from/to buffers to avoid concurrent accesses or modifications. In particular, the memory referenced by `buf:set(cdata, len)` must not be modified while buffer readers are working on it. Shared, but read-only memory mappings of files are OK, but only if the file does not change.
local buffer = {}
--- A buffer object is a garbage-collected Lua object. After creation with `buffer.new()`, it can (and should) be reused for many operations. When the last reference to a buffer object is gone, it will eventually be freed by the garbage collector, along with the allocated buffer space.
---
--- Buffers operate like a FIFO (first-in first-out) data structure. Data can be appended (written) to the end of the buffer and consumed (read) from the front of the buffer. These operations may be freely mixed.
---
--- The buffer space that holds the characters is managed automatically — it grows as needed and already consumed space is recycled. Use `buffer.new(size)` and `buf:free()`, if you need more control.
---
--- The maximum size of a single buffer is the same as the maximum size of a Lua string, which is slightly below two gigabytes. For huge data sizes, neither strings nor buffers are the right data structure — use the FFI library to directly map memory or files up to the virtual memory limit of your OS.
---
---@version JIT
---@class string.buffer : table
local buf = {}
--- A string, number, or any object obj with a __tostring metamethod to the buffer.
---
---@alias string.buffer.data string|number|table
--- Appends a string str, a number num or any object obj with a `__tostring` metamethod to the buffer. Multiple arguments are appended in the given order.
---
--- Appending a buffer to a buffer is possible and short-circuited internally. But it still involves a copy. Better combine the buffer writes to use a single buffer.
---
---@param data string.buffer.data
---@param ...? string.buffer.data
---@return string.buffer
function buf:put(data, ...) end
--- Appends the formatted arguments to the buffer. The format string supports the same options as string.format().
---
---@param format string
---@param ... string.buffer.data
---@return string.buffer
function buf:putf(format, ...) end
--- Appends the given len number of bytes from the memory pointed to by the FFI cdata object to the buffer. The object needs to be convertible to a (constant) pointer.
---
---@param cdata ffi.cdata*
---@param len integer
---@return string.buffer
function buf:putcdata(cdata, len) end
--- This method allows zero-copy consumption of a string or an FFI cdata object as a buffer. It stores a reference to the passed string str or the FFI cdata object in the buffer. Any buffer space originally allocated is freed. This is not an append operation, unlike the `buf:put*()` methods.
---
--- After calling this method, the buffer behaves as if `buf:free():put(str)` or `buf:free():put(cdata, len)` had been called. However, the data is only referenced and not copied, as long as the buffer is only consumed.
---
--- In case the buffer is written to later on, the referenced data is copied and the object reference is removed (copy-on-write semantics).
---
--- The stored reference is an anchor for the garbage collector and keeps the originally passed string or FFI cdata object alive.
---
---@param str string.buffer.data
---@return string.buffer
---@overload fun(self:string.buffer, cdata:ffi.cdata*, len:integer):string.buffer
function buf:set(str) end
--- Reset (empty) the buffer. The allocated buffer space is not freed and may be reused.
---@return string.buffer
function buf:reset() end
--- The buffer space of the buffer object is freed. The object itself remains intact, empty and may be reused.
---
--- Note: you normally don't need to use this method. The garbage collector automatically frees the buffer space, when the buffer object is collected. Use this method, if you need to free the associated memory immediately.
function buf:free() end
--- The reserve method reserves at least size bytes of write space in the buffer. It returns an uint8_t * FFI cdata pointer ptr that points to this space.
---
--- The available length in bytes is returned in len. This is at least size bytes, but may be more to facilitate efficient buffer growth. You can either make use of the additional space or ignore len and only use size bytes.
---
--- This, along with `buf:commit()` allow zero-copy use of C read-style APIs:
---
--- ```lua
--- local MIN_SIZE = 65536
--- repeat
--- local ptr, len = buf:reserve(MIN_SIZE)
--- local n = C.read(fd, ptr, len)
--- if n == 0 then break end -- EOF.
--- if n < 0 then error("read error") end
--- buf:commit(n)
--- until false
--- ```
---
--- The reserved write space is not initialized. At least the used bytes must be written to before calling the commit method. There's no need to call the commit method, if nothing is added to the buffer (e.g. on error).
---@param size integer
---@return ffi.cdata* ptr # an uint8_t * FFI cdata pointer that points to this space
---@return integer len # available length (bytes)
function buf:reserve(size) end
--- Appends the used bytes of the previously returned write space to the buffer data.
---@param used integer
---@return string.buffer
function buf:commit(used) end
--- Skips (consumes) len bytes from the buffer up to the current length of the buffer data.
---@param len integer
---@return string.buffer
function buf:skip(len) end
--- Consumes the buffer data and returns one or more strings. If called without arguments, the whole buffer data is consumed. If called with a number, up to `len` bytes are consumed. A `nil` argument consumes the remaining buffer space (this only makes sense as the last argument). Multiple arguments consume the buffer data in the given order.
---
--- Note: a zero length or no remaining buffer data returns an empty string and not `nil`.
---
---@param len? integer
---@param ... integer|nil
---@return string ...
function buf:get(len, ...) end
--- Creates a string from the buffer data, but doesn't consume it. The buffer remains unchanged.
---
--- Buffer objects also define a `__tostring metamethod`. This means buffers can be passed to the global `tostring()` function and many other functions that accept this in place of strings. The important internal uses in functions like `io.write()` are short-circuited to avoid the creation of an intermediate string object.
---@return string
function buf:tostring() end
--- Returns an uint8_t * FFI cdata pointer ptr that points to the buffer data. The length of the buffer data in bytes is returned in len.
---
--- The returned pointer can be directly passed to C functions that expect a buffer and a length. You can also do bytewise reads (`local x = ptr[i]`) or writes (`ptr[i] = 0x40`) of the buffer data.
---
--- In conjunction with the `buf:skip()` method, this allows zero-copy use of C write-style APIs:
---
--- ```lua
--- repeat
--- local ptr, len = buf:ref()
--- if len == 0 then break end
--- local n = C.write(fd, ptr, len)
--- if n < 0 then error("write error") end
--- buf:skip(n)
--- until n >= len
--- ```
---
--- Unlike Lua strings, buffer data is not implicitly zero-terminated. It's not safe to pass ptr to C functions that expect zero-terminated strings. If you're not using len, then you're doing something wrong.
---
---@return ffi.cdata* ptr # an uint8_t * FFI cdata pointer that points to the buffer data.
---@return integer len # length of the buffer data in bytes
function buf:ref() end
--- Serializes (encodes) the Lua object to the buffer
---
--- This function may throw an error when attempting to serialize unsupported object types, circular references or deeply nested tables.
---@param obj string.buffer.data
---@return string.buffer
function buf:encode(obj) end
--- De-serializes one object from the buffer.
---
--- The returned object may be any of the supported Lua types — even `nil`.
---
--- This function may throw an error when fed with malformed or incomplete encoded data.
---
--- Leaves any left-over data in the buffer.
---
--- Attempting to de-serialize an FFI type will throw an error, if the FFI library is not built-in or has not been loaded, yet.
---
---@return string.buffer.data|nil obj
function buf:decode() end
--- Serializes (encodes) the Lua object obj
---
--- This function may throw an error when attempting to serialize unsupported object types, circular references or deeply nested tables.
---@param obj string.buffer.data
---@return string
function buffer.encode(obj) end
--- De-serializes (decodes) the string to a Lua object
---
--- The returned object may be any of the supported Lua types — even `nil`.
---
--- Throws an error when fed with malformed or incomplete encoded data.
--- Throws an error when there's left-over data after decoding a single top-level object.
---
--- Attempting to de-serialize an FFI type will throw an error, if the FFI library is not built-in or has not been loaded, yet.
---
---@param str string
---@return string.buffer.data|nil obj
function buffer.decode(str) end
--- Creates a new buffer object.
---
--- The optional size argument ensures a minimum initial buffer size. This is strictly an optimization when the required buffer size is known beforehand. The buffer space will grow as needed, in any case.
---
--- The optional table options sets various serialization options.
---
---@param size? integer
---@param options? string.buffer.serialization.opts
---@return string.buffer
function buffer.new(size, options) end
--- Serialization Options
---
--- The options table passed to buffer.new() may contain the following members (all optional):
---
--- * `dict` is a Lua table holding a dictionary of strings that commonly occur as table keys of objects you are serializing. These keys are compactly encoded as indexes during serialization. A well chosen dictionary saves space and improves serialization performance.
---
--- * `metatable` is a Lua table holding a dictionary of metatables for the table objects you are serializing.
---
--- dict needs to be an array of strings and metatable needs to be an array of tables. Both starting at index 1 and without holes (no nil inbetween). The tables are anchored in the buffer object and internally modified into a two-way index (don't do this yourself, just pass a plain array). The tables must not be modified after they have been passed to buffer.new().
---
--- The dict and metatable tables used by the encoder and decoder must be the same. Put the most common entries at the front. Extend at the end to ensure backwards-compatibility — older encodings can then still be read. You may also set some indexes to false to explicitly drop backwards-compatibility. Old encodings that use these indexes will throw an error when decoded.
---
--- Metatables that are not found in the metatable dictionary are ignored when encoding. Decoding returns a table with a nil metatable.
---
--- Note: parsing and preparation of the options table is somewhat expensive. Create a buffer object only once and recycle it for multiple uses. Avoid mixing encoder and decoder buffers, since the buf:set() method frees the already allocated buffer space:
---
--- ```lua
--- local options = {
--- dict = { "commonly", "used", "string", "keys" },
--- }
--- local buf_enc = buffer.new(options)
--- local buf_dec = buffer.new(options)
---
--- local function encode(obj)
--- return buf_enc:reset():encode(obj):get()
--- end
---
--- local function decode(str)
--- return buf_dec:set(str):decode()
--- end
--- ```
---@class string.buffer.serialization.opts
---@field dict string[]
---@field metatable table[]
return buffer

View File

@@ -0,0 +1,154 @@
---@meta table
---
---
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-table)
---
---@class tablelib
table = {}
---
---Given a list where all elements are strings or numbers, returns the string `list[i]..sep..list[i+1] ··· sep..list[j]`.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-table.concat)
---
---@param list table
---@param sep? string
---@param i? integer
---@param j? integer
---@return string
---@nodiscard
function table.concat(list, sep, i, j) end
---
---Inserts element `value` at position `pos` in `list`.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-table.insert)
---
---@overload fun(list: table, value: any)
---@param list table
---@param pos integer
---@param value any
function table.insert(list, pos, value) end
---@version <5.1
---
---Returns the largest positive numerical index of the given table, or zero if the table has no positive numerical indices.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-table.maxn)
---
---@param table table
---@return integer
---@nodiscard
function table.maxn(table) end
---@version >5.3
---
---Moves elements from table `a1` to table `a2`.
---```lua
---a2[t],··· =
---a1[f],···,a1[e]
---return a2
---```
---
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-table.move)
---
---@param a1 table
---@param f integer
---@param e integer
---@param t integer
---@param a2? table
---@return table a2
function table.move(a1, f, e, t, a2) end
---@version >5.2, JIT
---
---Returns a new table with all arguments stored into keys `1`, `2`, etc. and with a field `"n"` with the total number of arguments.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-table.pack)
---
---@return table
---@nodiscard
function table.pack(...) end
---
---Removes from `list` the element at position `pos`, returning the value of the removed element.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-table.remove)
---
---@param list table
---@param pos? integer
---@return any
function table.remove(list, pos) end
---
---Sorts list elements in a given order, *in-place*, from `list[1]` to `list[#list]`.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-table.sort)
---
---@generic T
---@param list T[]
---@param comp? fun(a: T, b: T):boolean
function table.sort(list, comp) end
---@version >5.2, JIT
---
---Returns the elements from the given list. This function is equivalent to
---```lua
--- return list[i], list[i+1], ···, list[j]
---```
---By default, `i` is `1` and `j` is `#list`.
---
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-table.unpack)
---
---@generic T
---@param list T[]
---@param i? integer
---@param j? integer
---@return T ...
---@nodiscard
function table.unpack(list, i, j) end
---@version <5.1, JIT
---
---Executes the given f over all elements of table. For each element, f is called with the index and respective value as arguments. If f returns a non-nil value, then the loop is broken, and this value is returned as the final value of foreach.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-table.foreach)
---
---@generic T
---@param list any
---@param callback fun(key: string, value: any):T|nil
---@return T|nil
---@deprecated
function table.foreach(list, callback) end
---@version <5.1, JIT
---
---Executes the given f over the numerical indices of table. For each index, f is called with the index and respective value as arguments. Indices are visited in sequential order, from 1 to n, where n is the size of the table. If f returns a non-nil value, then the loop is broken and this value is returned as the result of foreachi.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-table.foreachi)
---
---@generic T
---@param list any
---@param callback fun(key: string, value: any):T|nil
---@return T|nil
---@deprecated
function table.foreachi(list, callback) end
---@version <5.1, JIT
---
---Returns the number of elements in the table. This function is equivalent to `#list`.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-table.getn)
---
---@generic T
---@param list T[]
---@return integer
---@nodiscard
---@deprecated
function table.getn(list) end
return table

View File

@@ -0,0 +1,17 @@
---@meta table.clear
---@version JIT
---
---This clears all keys and values from a table, but preserves the allocated array/hash sizes. This is useful when a table, which is linked from multiple places, needs to be cleared and/or when recycling a table for use by the same context. This avoids managing backlinks, saves an allocation and the overhead of incremental array/hash part growth. The function needs to be required before use.
---```lua
--- require("table.clear").
---```
---Please note this function is meant for very specific situations. In most cases it's better to replace the (usually single) link with a new table and let the GC do its work.
---
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-table.clear)
---
---@param tab table
local function clear(tab) end
return clear

View File

@@ -0,0 +1,18 @@
---@meta table.new
---@version JIT
---
---This creates a pre-sized table, just like the C API equivalent `lua_createtable()`. This is useful for big tables if the final table size is known and automatic table resizing is too expensive. `narray` parameter specifies the number of array-like items, and `nhash` parameter specifies the number of hash-like items. The function needs to be required before use.
---```lua
--- require("table.new")
---```
---
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-table.new)
---
---@param narray integer
---@param nhash integer
---@return table
local function new(narray, nhash) end
return new

View File

@@ -0,0 +1,83 @@
---@meta utf8
---@version >5.3
---
---
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-utf8)
---
---@class utf8lib
---
---The pattern which matches exactly one UTF-8 byte sequence, assuming that the subject is a valid UTF-8 string.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-utf8.charpattern)
---
---@field charpattern string
utf8 = {}
---
---Receives zero or more integers, converts each one to its corresponding UTF-8 byte sequence and returns a string with the concatenation of all these sequences.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-utf8.char)
---
---@param code integer
---@param ... integer
---@return string
---@nodiscard
function utf8.char(code, ...) end
---
---Returns values so that the construction
---```lua
---for p, c in utf8.codes(s) do
--- body
---end
---```
---will iterate over all UTF-8 characters in string s, with p being the position (in bytes) and c the code point of each character. It raises an error if it meets any invalid byte sequence.
---
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-utf8.codes)
---
---@param s string
---@return fun(s: string, p: integer):integer, integer
function utf8.codes(s) end
---
---Returns the codepoints (as integers) from all characters in `s` that start between byte position `i` and `j` (both included).
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-utf8.codepoint)
---
---@param s string
---@param i? integer
---@param j? integer
---@return integer code
---@return integer ...
---@nodiscard
function utf8.codepoint(s, i, j) end
---
---Returns the number of UTF-8 characters in string `s` that start between positions `i` and `j` (both inclusive).
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-utf8.len)
---
---@param s string
---@param i? integer
---@param j? integer
---@return integer?
---@return integer? errpos
---@nodiscard
function utf8.len(s, i, j) end
---
---Returns the position (in bytes) where the encoding of the `n`-th character of `s` (counting from position `i`) starts.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-utf8.offset)
---
---@param s string
---@param n integer
---@param i? integer
---@return integer p
---@nodiscard
function utf8.offset(s, n, i) end
return utf8

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,230 @@
config
configs
assert
collectgarbage
dofile
error
getmetatable
ipairs
load
loadfile
next
pairs
pcall
print
rawequal
rawget
rawlen
rawset
require
select
setmetatable
tonumber
tostring
type
warn
xpcall
close
create
isyieldable
resume
running
status
wrap
yield
debug
gethook
getinfo
getlocal
getmetatable
getregistry
getupvalue
getuservalue
sethook
setlocal
setmetatable
setupvalue
setuservalue
traceback
upvalueid
upvaluejoin
close
flush
input
lines
open
output
popen
read
stderr
stdin
stdout
tmpfile
type
write
close
flush
lines
read
seek
setvbuf
write
abs
acos
asin
atan
ceil
cos
deg
exp
floor
fmod
huge
log
max
maxinteger
min
mininteger
modf
pi
rad
random
randomseed
sin
sqrt
tan
tointeger
type
ult
clock
date
difftime
execute
exit
getenv
remove
rename
setlocale
time
tmpname
config
cpath
loaded
loadlib
path
preload
searchers
searchpath
byte
char
dump
find
format
gmatch
gsub
len
lower
match
pack
packsize
rep
reverse
sub
unpack
upper
concat
insert
move
pack
remove
sort
unpack
char
charpattern
codepoint
codes
len
offset
add
band
bnot
bor
bxor
call
close
concat
div
eq
gc
idiv
index
le
len
lt
metatable
mod
mode
mul
name
newindex
pairs
pow
shl
shr
sub
tostring
unm
lua
luajit
jit
decl
unlua
xlua
tolua
slua
async
await
coroutine
IDE
editorconfig
docs
http
https
url
uri
hub
vscode
github
udp
tcp
ast
ctor
init
util
json
jsonrpc
meta
debugger
debug
encoder
glob
proto
inlay
params
wakeup
none
nil
formatting
formatter
env
math
suc
const
param
params
func
funcs
enum
enums
substring
globals

View File

@@ -0,0 +1,341 @@
---@meta _
---#DES 'arg'
---@type string[]
arg = {}
---#DES 'assert'
---@generic T
---@param v? T
---@param message? any
---@param ... any
---@return T
---@return any ...
function assert(v, message, ...) end
---@alias gcoptions
---|>"collect" # ---#DESTAIL 'cgopt.collect'
---| "stop" # ---#DESTAIL 'cgopt.stop'
---| "restart" # ---#DESTAIL 'cgopt.restart'
---| "count" # ---#DESTAIL 'cgopt.count'
---| "step" # ---#DESTAIL 'cgopt.step'
---| "isrunning" # ---#DESTAIL 'cgopt.isrunning'
---#if VERSION >= 5.4 then
---| "incremental" # ---#DESTAIL 'cgopt.incremental'
---| "generational" # ---#DESTAIL 'cgopt.generational'
---#else
---| "setpause" # ---#DESTAIL 'cgopt.setpause'
---| "setstepmul" # ---#DESTAIL 'cgopt.setstepmul'
---#end
---#if VERSION >= 5.4 then
---#DES 'collectgarbage'
---@param opt? gcoptions
---@param ... any
---@return any
function collectgarbage(opt, ...) end
---#else
---#DES 'collectgarbage'
---@param opt? gcoptions
---@param arg? integer
---@return any
function collectgarbage(opt, arg) end
---#end
---#DES 'dofile'
---@param filename? string
---@return any ...
function dofile(filename) end
---#DES 'error'
---@param message any
---@param level? integer
function error(message, level) end
---#DES '_G'
---@class _G
_G = {}
---@version 5.1
---#DES 'getfenv'
---@param f? integer|async fun(...):...
---@return table
---@nodiscard
function getfenv(f) end
---#DES 'getmetatable'
---@param object any
---@return table metatable
---@nodiscard
function getmetatable(object) end
---#DES 'ipairs'
---@generic T: table, V
---@param t T
---@return fun(table: V[], i?: integer):integer, V
---@return T
---@return integer i
function ipairs(t) end
---@alias loadmode
---| "b" # ---#DESTAIL 'loadmode.b'
---| "t" # ---#DESTAIL 'loadmode.t'
---|>"bt" # ---#DESTAIL 'loadmode.bt'
---#if VERSION <= 5.1 and not JIT then
---#DES 'load<5.1'
---@param func function
---@param chunkname? string
---@return function?
---@return string? error_message
---@nodiscard
function load(func, chunkname) end
---#else
---#DES 'load>5.2'
---@param chunk string|function
---@param chunkname? string
---@param mode? loadmode
---@param env? table
---@return function?
---@return string? error_message
---@nodiscard
function load(chunk, chunkname, mode, env) end
---#end
---#if VERSION <= 5.1 and not JIT then
---#DES 'loadfile'
---@param filename? string
---@return function?
---@return string? error_message
---@nodiscard
function loadfile(filename) end
---#else
---#DES 'loadfile'
---@param filename? string
---@param mode? loadmode
---@param env? table
---@return function?
---@return string? error_message
---@nodiscard
function loadfile(filename, mode, env) end
---#end
---@version 5.1
---#DES 'loadstring'
---@param text string
---@param chunkname? string
---@return function?
---@return string? error_message
---@nodiscard
function loadstring(text, chunkname) end
---@version 5.1
---@param proxy boolean|table|userdata
---@return userdata
---@nodiscard
function newproxy(proxy) end
---@version 5.1
---#DES 'module'
---@param name string
---@param ... any
function module(name, ...) end
---#DES 'next'
---@generic K, V
---@param table table<K, V>
---@param index? K
---@return K?
---@return V?
---@nodiscard
function next(table, index) end
---#DES 'pairs'
---@generic T: table, K, V
---@param t T
---@return fun(table: table<K, V>, index?: K):K, V
---@return T
function pairs(t) end
---#DES 'pcall'
---#if VERSION == 5.1 and not JIT then
---@param f function
---#else
---@param f async fun(...):...
---#end
---@param arg1? any
---@param ... any
---@return boolean success
---@return any result
---@return any ...
function pcall(f, arg1, ...) end
---#DES 'print'
---@param ... any
function print(...) end
---#DES 'rawequal'
---@param v1 any
---@param v2 any
---@return boolean
---@nodiscard
function rawequal(v1, v2) end
---#DES 'rawget'
---@param table table
---@param index any
---@return any
---@nodiscard
function rawget(table, index) end
---#DES 'rawlen'
---@param v table|string
---@return integer len
---@nodiscard
function rawlen(v) end
---#DES 'rawset'
---@param table table
---@param index any
---@param value any
---@return table
function rawset(table, index, value) end
---#DES 'select'
---@param index integer|"#"
---@param ... any
---@return any
---@nodiscard
function select(index, ...) end
---@version 5.1
---#DES 'setfenv'
---@param f async fun(...):...|integer
---@param table table
---@return function
function setfenv(f, table) end
---@class metatable
---@field __mode 'v'|'k'|'kv'|nil
---@field __metatable any|nil
---@field __tostring (fun(t):string)|nil
---@field __gc fun(t)|nil
---@field __add (fun(t1,t2):any)|nil
---@field __sub (fun(t1,t2):any)|nil
---@field __mul (fun(t1,t2):any)|nil
---@field __div (fun(t1,t2):any)|nil
---@field __mod (fun(t1,t2):any)|nil
---@field __pow (fun(t1,t2):any)|nil
---@field __unm (fun(t):any)|nil
---#if VERSION >= 5.3 then
---@field __idiv (fun(t1,t2):any)|nil
---@field __band (fun(t1,t2):any)|nil
---@field __bor (fun(t1,t2):any)|nil
---@field __bxor (fun(t1,t2):any)|nil
---@field __bnot (fun(t):any)|nil
---@field __shl (fun(t1,t2):any)|nil
---@field __shr (fun(t1,t2):any)|nil
---#end
---@field __concat (fun(t1,t2):any)|nil
---@field __len (fun(t):integer)|nil
---@field __eq (fun(t1,t2):boolean)|nil
---@field __lt (fun(t1,t2):boolean)|nil
---@field __le (fun(t1,t2):boolean)|nil
---@field __index table|(fun(t,k):any)|nil
---@field __newindex table|fun(t,k,v)|nil
---@field __call (fun(t,...):...)|nil
---#if VERSION > 5.1 or VERSION == JIT then
---@field __pairs (fun(t):(fun(t,k,v):any,any))|nil
---#end
---#if VERSION == JIT or VERSION == 5.2 then
---@field __ipairs (fun(t):(fun(t,k,v):(integer|nil),any))|nil
---#end
---#if VERSION >= 5.4 then
---@field __close (fun(t,errobj):any)|nil
---#end
---#DES 'setmetatable'
---@param table table
---@param metatable? metatable|table
---@return table
function setmetatable(table, metatable) end
---#DES 'tonumber'
---@overload fun(e: string, base: integer):integer
---@param e any
---@return number?
---@nodiscard
function tonumber(e) end
---#DES 'tostring'
---@param v any
---@return string
---@nodiscard
function tostring(v) end
---@alias type
---| "nil"
---| "number"
---| "string"
---| "boolean"
---| "table"
---| "function"
---| "thread"
---| "userdata"
---#if VERSION == JIT then
---| "cdata"
---#end
---#DES 'type'
---@param v any
---@return type type
---@nodiscard
function type(v) end
---#DES '_VERSION'
---#if VERSION == 5.1 then
_VERSION = "Lua 5.1"
---#elseif VERSION == 5.2 then
_VERSION = "Lua 5.2"
---#elseif VERSION == 5.3 then
_VERSION = "Lua 5.3"
---#elseif VERSION == 5.4 then
_VERSION = "Lua 5.4"
---#end
---@version >5.4
---#DES 'warn'
---@param message string
---@param ... any
function warn(message, ...) end
---#if VERSION == 5.1 and not JIT then
---#DES 'xpcall=5.1'
---@param f function
---@param err function
---@return boolean success
---@return any result
---@return any ...
function xpcall(f, err) end
---#else
---#DES 'xpcall>5.2'
---@param f async fun(...):...
---@param msgh function
---@param arg1? any
---@param ... any
---@return boolean success
---@return any result
---@return any ...
function xpcall(f, msgh, arg1, ...) end
---#end
---@version 5.1
---#DES 'unpack'
---@generic T
---@param list T[]
---@param i? integer
---@param j? integer
---@return T ...
---@nodiscard
function unpack(list, i, j) end

View File

@@ -0,0 +1,80 @@
---#if not JIT then DISABLE() end
---@meta bit
---@version JIT
---@class bitlib
bit = {}
---@param x integer
---@return integer y
---@nodiscard
function bit.tobit(x) end
---@param x integer
---@param n? integer
---@return integer y
---@nodiscard
function bit.tohex(x, n) end
---@param x integer
---@return integer y
---@nodiscard
function bit.bnot(x) end
---@param x integer
---@param x2 integer
---@param ... integer
---@return integer y
---@nodiscard
function bit.bor(x, x2, ...) end
---@param x integer
---@param x2 integer
---@param ... integer
---@return integer y
---@nodiscard
function bit.band(x, x2, ...) end
---@param x integer
---@param x2 integer
---@param ... integer
---@return integer y
---@nodiscard
function bit.bxor(x, x2, ...) end
---@param x integer
---@param n integer
---@return integer y
---@nodiscard
function bit.lshift(x, n) end
---@param x integer
---@param n integer
---@return integer y
---@nodiscard
function bit.rshift(x, n) end
---@param x integer
---@param n integer
---@return integer y
---@nodiscard
function bit.arshift(x, n) end
---@param x integer
---@param n integer
---@return integer y
---@nodiscard
function bit.rol(x, n) end
---@param x integer
---@param n integer
---@return integer y
---@nodiscard
function bit.ror(x, n) end
---@param x integer
---@return integer y
---@nodiscard
function bit.bswap(x) end
return bit

View File

@@ -0,0 +1,86 @@
---#if VERSION ~= 5.2 then DISABLE() end
---@meta bit32
---@version 5.2
---#DES 'bit32'
---@class bit32lib
bit32 = {}
---#DES 'bit32.arshift'
---@param x integer
---@param disp integer
---@return integer
---@nodiscard
function bit32.arshift(x, disp) end
---#DES 'bit32.band'
---@return integer
---@nodiscard
function bit32.band(...) end
---#DES 'bit32.bnot'
---@param x integer
---@return integer
---@nodiscard
function bit32.bnot(x) end
---#DES 'bit32.bor'
---@return integer
---@nodiscard
function bit32.bor(...) end
---#DES 'bit32.btest'
---@return boolean
---@nodiscard
function bit32.btest(...) end
---#DES 'bit32.bxor'
---@return integer
---@nodiscard
function bit32.bxor(...) end
---#DES 'bit32.extract'
---@param n integer
---@param field integer
---@param width? integer
---@return integer
---@nodiscard
function bit32.extract(n, field, width) end
---#DES 'bit32.replace'
---@param n integer
---@param v integer
---@param field integer
---@param width? integer
---@nodiscard
function bit32.replace(n, v, field, width) end
---#DES 'bit32.lrotate'
---@param x integer
---@param distp integer
---@return integer
---@nodiscard
function bit32.lrotate(x, distp) end
---#DES 'bit32.lshift'
---@param x integer
---@param distp integer
---@return integer
---@nodiscard
function bit32.lshift(x, distp) end
---#DES 'bit32.rrotate'
---@param x integer
---@param distp integer
---@return integer
---@nodiscard
function bit32.rrotate(x, distp) end
---#DES 'bit32.rshift'
---@param x integer
---@param distp integer
---@return integer
---@nodiscard
function bit32.rshift(x, distp) end
return bit32

View File

@@ -0,0 +1,16 @@
---@meta _
---@class unknown
---@class any
---@class nil
---@class boolean
---@class true: boolean
---@class false: boolean
---@class number
---@class integer: number
---@class thread
---@class table<K, V>: { [K]: V }
---@class string: stringlib
---@class userdata
---@class lightuserdata
---@class function

View File

@@ -0,0 +1,68 @@
---@meta coroutine
---#DES 'coroutine'
---@class coroutinelib
coroutine = {}
---#DES 'coroutine.create'
---@param f async fun(...):...
---@return thread
---@nodiscard
function coroutine.create(f) end
---#if VERSION >= 5.4 then
---#DES 'coroutine.isyieldable>5.4'
---@param co? thread
---@return boolean
---@nodiscard
function coroutine.isyieldable(co) end
---#else
---@version >5.2
---#DES 'coroutine.isyieldable'
---@return boolean
---@nodiscard
function coroutine.isyieldable() end
---#end
---@version >5.4
---#DES 'coroutine.close'
---@param co thread
---@return boolean noerror
---@return any errorobject
function coroutine.close(co) end
---#DES 'coroutine.resume'
---@param co thread
---@param val1? any
---@return boolean success
---@return any ...
function coroutine.resume(co, val1, ...) end
---#DES 'coroutine.running'
---@return thread running
---@return boolean ismain
---@nodiscard
function coroutine.running() end
---#DES 'coroutine.status'
---@param co thread
---@return
---| '"running"' # ---#DESTAIL 'costatus.running'
---| '"suspended"' # ---#DESTAIL 'costatus.suspended'
---| '"normal"' # ---#DESTAIL 'costatus.normal'
---| '"dead"' # ---#DESTAIL 'costatus.dead'
---@nodiscard
function coroutine.status(co) end
---#DES 'coroutine.wrap'
---@param f async fun(...):...
---@return fun(...):...
---@nodiscard
function coroutine.wrap(f) end
---#DES 'coroutine.yield'
---@async
---@return any ...
function coroutine.yield(...) end
return coroutine

View File

@@ -0,0 +1,221 @@
---@meta debug
---#DES 'debug'
---@class debuglib
debug = {}
---@class debuginfo
---@field name string
---@field namewhat string
---@field source string
---@field short_src string
---@field linedefined integer
---@field lastlinedefined integer
---@field what string
---@field currentline integer
---@field istailcall boolean
---@field nups integer
---#if VERSION >= 5.2 or JIT then
---@field nparams integer
---@field isvararg boolean
---#end
---@field func function
---#if VERSION >= 5.4 then
---@field ftransfer integer
---@field ntransfer integer
---#end
---@field activelines table
---#DES 'debug.debug'
function debug.debug() end
---@version 5.1
---#DES 'debug.getfenv'
---@param o any
---@return table
---@nodiscard
function debug.getfenv(o) end
---#DES 'debug.gethook'
---@param co? thread
---@return function hook
---@return string mask
---@return integer count
---@nodiscard
function debug.gethook(co) end
---@alias infowhat string
---|+"n" # ---#DESTAIL 'infowhat.n'
---|+"S" # ---#DESTAIL 'infowhat.S'
---|+"l" # ---#DESTAIL 'infowhat.l'
---|+"t" # ---#DESTAIL 'infowhat.t'
---#if VERSION <= 5.1 and not JIT then
---|+"u" # ---#DESTAIL 'infowhat.u<5.1'
---#else
---|+"u" # ---#DESTAIL 'infowhat.u>5.2'
---#end
---|+"f" # ---#DESTAIL 'infowhat.f'
---#if VERSION >= 5.4 then
---|+"r" # ---#DESTAIL 'infowhat.r'
---#end
---|+"L" # ---#DESTAIL 'infowhat.L'
---#DES 'debug.getinfo'
---@overload fun(f: integer|function, what?: infowhat):debuginfo
---@param thread thread
---@param f integer|async fun(...):...
---@param what? infowhat
---@return debuginfo
---@nodiscard
function debug.getinfo(thread, f, what) end
---#if VERSION <= 5.1 and not JIT then
---#DES 'debug.getlocal<5.1'
---@overload fun(level: integer, index: integer):string, any
---@param thread thread
---@param level integer
---@param index integer
---@return string name
---@return any value
---@nodiscard
function debug.getlocal(thread, level, index) end
---#else
---#DES 'debug.getlocal>5.2'
---@overload fun(f: integer|async fun(...):..., index: integer):string, any
---@param thread thread
---@param f integer|async fun(...):...
---@param index integer
---@return string name
---@return any value
---@nodiscard
function debug.getlocal(thread, f, index) end
---#end
---#DES 'debug.getmetatable'
---@param object any
---@return table metatable
---@nodiscard
function debug.getmetatable(object) end
---#DES 'debug.getregistry'
---@return table
---@nodiscard
function debug.getregistry() end
---#DES 'debug.getupvalue'
---@param f async fun(...):...
---@param up integer
---@return string name
---@return any value
---@nodiscard
function debug.getupvalue(f, up) end
---#if VERSION >= 5.4 then
---#DES 'debug.getuservalue>5.4'
---@param u userdata
---@param n? integer
---@return any
---@return boolean
---@nodiscard
function debug.getuservalue(u, n) end
---#elseif VERSION >= 5.2 or JIT then
---#DES 'debug.getuservalue<5.3'
---@param u userdata
---@return any
---@nodiscard
function debug.getuservalue(u) end
---#end
---#DES 'debug.setcstacklimit'
---@deprecated
---@param limit integer
---@return integer|boolean
function debug.setcstacklimit(limit) end
---#DES 'debug.setfenv'
---@version 5.1
---@generic T
---@param object T
---@param env table
---@return T object
function debug.setfenv(object, env) end
---@alias hookmask string
---|+"c" # ---#DESTAIL 'hookmask.c'
---|+"r" # ---#DESTAIL 'hookmask.r'
---|+"l" # ---#DESTAIL 'hookmask.l'
---#DES 'debug.sethook'
---@overload fun(hook: (async fun(...):...), mask: hookmask, count?: integer)
---@overload fun(thread: thread):...
---@overload fun(...):...
---@param thread thread
---@param hook async fun(...):...
---@param mask hookmask
---@param count? integer
function debug.sethook(thread, hook, mask, count) end
---#DES 'debug.setlocal'
---@overload fun(level: integer, index: integer, value: any):string
---@param thread thread
---@param level integer
---@param index integer
---@param value any
---@return string name
function debug.setlocal(thread, level, index, value) end
---#DES 'debug.setmetatable'
---@generic T
---@param value T
---@param meta? table
---@return T value
function debug.setmetatable(value, meta) end
---#DES 'debug.setupvalue'
---@param f async fun(...):...
---@param up integer
---@param value any
---@return string name
function debug.setupvalue(f, up, value) end
---#if VERSION >= 5.4 then
---#DES 'debug.setuservalue>5.4'
---@param udata userdata
---@param value any
---@param n? integer
---@return userdata udata
function debug.setuservalue(udata, value, n) end
---#elseif VERSION >= 5.2 or JIT then
---#DES 'debug.setuservalue<5.3'
---@param udata userdata
---@param value any
---@return userdata udata
function debug.setuservalue(udata, value) end
---#end
---#DES 'debug.traceback'
---@overload fun(message?: any, level?: integer): string
---@param thread thread
---@param message? any
---@param level? integer
---@return string message
---@nodiscard
function debug.traceback(thread, message, level) end
---@version >5.2, JIT
---#DES 'debug.upvalueid'
---@param f async fun(...):...
---@param n integer
---@return lightuserdata id
---@nodiscard
function debug.upvalueid(f, n) end
---@version >5.2, JIT
---#DES 'debug.upvaluejoin'
---@param f1 async fun(...):...
---@param n1 integer
---@param f2 async fun(...):...
---@param n2 integer
function debug.upvaluejoin(f1, n1, f2, n2) end
return debug

View File

@@ -0,0 +1,122 @@
---#if not JIT then DISABLE() end
---@meta ffi
---@class ffi.namespace*: table
---@field [string] function
---@class ffi.ctype*: userdata
---@overload fun(init?: any, ...): ffi.cdata*
---@overload fun(nelem?: integer, init?: any, ...): ffi.cdata*
local ctype
---@class ffi.cdecl*: string
---@class ffi.cdata*: userdata
---@alias ffi.ct* ffi.ctype*|ffi.cdecl*|ffi.cdata*
---@class ffi.cb*: ffi.cdata*
local cb
---@class ffi.VLA*: userdata
---@class ffi.VLS*: userdata
---@version JIT
---@class ffilib
---@field C ffi.namespace*
---@field os string
---@field arch string
local ffi = {}
---@param def string
---@param params? any
function ffi.cdef(def, params, ...) end
---@param name string
---@param global? boolean
---@return ffi.namespace* clib
---@nodiscard
function ffi.load(name, global) end
---@overload fun(ct: ffi.ct*, init: any, ...)
---@param ct ffi.ct*
---@param nelem? integer
---@param init? any
---@return ffi.cdata* cdata
---@nodiscard
function ffi.new(ct, nelem, init, ...) end
---@param ct ffi.ct*
---@param params? any
---@return ffi.ctype* ctype
---@nodiscard
function ffi.typeof(ct, params, ...) end
---@param ct ffi.ct*
---@param init any
---@return ffi.cdata* cdata
---@nodiscard
function ffi.cast(ct, init) end
---@param ct ffi.ct*
---@param metatable table
---@return ffi.ctype* ctype
function ffi.metatype(ct, metatable) end
---@param cdata ffi.cdata*
---@param finalizer? function
---@return ffi.cdata* cdata
function ffi.gc(cdata, finalizer) end
---@param ct ffi.ct*
---@param nelem? integer
---@return integer|nil size
---@nodiscard
function ffi.sizeof(ct, nelem) end
---@param ct ffi.ct*
---@return integer align
---@nodiscard
function ffi.alignof(ct) end
---@param ct ffi.ct*
---@param field string
---@return integer ofs
---@return integer? bpos
---@return integer? bsize
---@nodiscard
function ffi.offsetof(ct, field) end
---@param ct ffi.ct*
---@param obj any
---@return boolean status
---@nodiscard
function ffi.istype(ct, obj) end
---@param newerr? integer
---@return integer err
---@nodiscard
function ffi.errno(newerr) end
---@param ptr any
---@param len? integer
---@return string str
function ffi.string(ptr, len) end
---@overload fun(dst: any, str: string)
---@param dst any
---@param src any
---@param len integer
function ffi.copy(dst, src, len) end
---@param dst any
---@param len integer
---@param c? any
function ffi.fill(dst, len, c) end
---@param param string
---@return boolean status
function ffi.abi(param) end
function cb:free() end
---@param func function
function cb:set(func) end
return ffi

View File

@@ -0,0 +1,170 @@
---@meta io
---#DES 'io'
---@class iolib
---#DES 'io.stdin'
---@field stdin file*
---#DES 'io.stdout'
---@field stdout file*
---#DES 'io.stderr'
---@field stderr file*
io = {}
---@alias openmode
---|>"r" # ---#DESTAIL 'openmode.r'
---| "w" # ---#DESTAIL 'openmode.w'
---| "a" # ---#DESTAIL 'openmode.a'
---| "r+" # ---#DESTAIL 'openmode.r+'
---| "w+" # ---#DESTAIL 'openmode.w+'
---| "a+" # ---#DESTAIL 'openmode.a+'
---| "rb" # ---#DESTAIL 'openmode.rb'
---| "wb" # ---#DESTAIL 'openmode.wb'
---| "ab" # ---#DESTAIL 'openmode.ab'
---| "r+b" # ---#DESTAIL 'openmode.r+b'
---| "w+b" # ---#DESTAIL 'openmode.w+b'
---| "a+b" # ---#DESTAIL 'openmode.a+b'
---#DES 'io.close'
---@param file? file*
---@return boolean? suc
---@return exitcode? exitcode
---@return integer? code
function io.close(file) end
---#DES 'io.flush'
function io.flush() end
---#DES 'io.input'
---@overload fun():file*
---@param file string|file*
function io.input(file) end
---#DES 'io.lines'
---@param filename string?
---@param ... readmode
---@return fun():any, ...
function io.lines(filename, ...) end
---#DES 'io.open'
---@param filename string
---@param mode? openmode
---@return file*?
---@return string? errmsg
---@nodiscard
function io.open(filename, mode) end
---#DES 'io.output'
---@overload fun():file*
---@param file string|file*
function io.output(file) end
---@alias popenmode
---| "r" # ---#DESTAIL 'popenmode.r'
---| "w" # ---#DESTAIL 'popenmode.w'
---#DES 'io.popen'
---@param prog string
---@param mode? popenmode
---@return file*?
---@return string? errmsg
function io.popen(prog, mode) end
---#DES 'io.read'
---@param ... readmode
---@return any
---@return any ...
---@nodiscard
function io.read(...) end
---#DES 'io.tmpfile'
---@return file*
---@nodiscard
function io.tmpfile() end
---@alias filetype
---| "file" # ---#DESTAIL 'filetype.file'
---| "closed file" # ---#DESTAIL 'filetype.closed file'
---| `nil` # ---#DESTAIL 'filetype.nil'
---#DES 'io.type'
---@param file file*
---@return filetype
---@nodiscard
function io.type(file) end
---#DES 'io.write'
---@return file*
---@return string? errmsg
function io.write(...) end
---#DES 'file'
---@class file*
local file = {}
---@alias readmode integer|string
---#if VERSION >= 5.3 then
---| "n" # ---#DESTAIL 'readmode.n'
---| "a" # ---#DESTAIL 'readmode.a'
---|>"l" # ---#DESTAIL 'readmode.l'
---| "L" # ---#DESTAIL 'readmode.L'
---#else
---| "*n" # ---#DESTAIL 'readmode.n'
---| "*a" # ---#DESTAIL 'readmode.a'
---|>"*l" # ---#DESTAIL 'readmode.l'
---#if JIT then
---| "*L" # ---#DESTAIL 'readmode.L'
---#end
---#end
---@alias exitcode "exit"|"signal"
---#DES 'file:close'
---@return boolean? suc
---@return exitcode? exitcode
---@return integer? code
function file:close() end
---#DES 'file:flush'
function file:flush() end
---#DES 'file:lines'
---@param ... readmode
---@return fun():any, ...
function file:lines(...) end
---#DES 'file:read'
---@param ... readmode
---@return any
---@return any ...
---@nodiscard
function file:read(...) end
---@alias seekwhence
---| "set" # ---#DESTAIL 'seekwhence.set'
---|>"cur" # ---#DESTAIL 'seekwhence.cur'
---| "end" # ---#DESTAIL 'seekwhence.end'
---#DES 'file:seek'
---@param whence? seekwhence
---@param offset? integer
---@return integer offset
---@return string? errmsg
function file:seek(whence, offset) end
---@alias vbuf
---| "no" # ---#DESTAIL 'vbuf.no'
---| "full" # ---#DESTAIL 'vbuf.full'
---| "line" # ---#DESTAIL 'vbuf.line'
---#DES 'file:setvbuf'
---@param mode vbuf
---@param size? integer
function file:setvbuf(mode, size) end
---#DES 'file:write'
---@param ... string|number
---@return file*?
---@return string? errmsg
function file:write(...) end
return io

View File

@@ -0,0 +1,43 @@
---#if not JIT then DISABLE() end
---@meta jit
---@version JIT
---@class jitlib
---@field version string
---@field version_num number
---@field os 'Windows'|'Linux'|'OSX'|'BSD'|'POSIX'|'Other'
---@field arch 'x86'|'x64'|'arm'|'arm64'|'arm64be'|'ppc'|'ppc64'|'ppc64le'|'mips'|'mipsel'|'mips64'|'mips64el'|string
jit = {}
---@overload fun(...):...
---@param func function|boolean
---@param recursive? boolean
function jit.on(func, recursive)
end
---@overload fun(...):...
---@param func function|boolean
---@param recursive? boolean
function jit.off(func, recursive)
end
---@overload fun(...):...
---@overload fun(tr: number)
---@param func function|boolean
---@param recursive? boolean
function jit.flush(func, recursive)
end
---@return boolean status
---@return string ...
---@nodiscard
function jit.status()
end
jit.opt = {}
---@param ... any flags
function jit.opt.start(...)
end
return jit

View File

@@ -0,0 +1,20 @@
---#if not JIT then DISABLE() end
---@meta jit.profile
local profile = {}
---@param mode string
---@param func fun(L: thread, samples: integer, vmst: string)
function profile.start(mode, func)
end
function profile.stop()
end
---@overload fun(th: thread, fmt: string, depth: integer)
---@param fmt string
---@param depth integer
function profile.dumpstack(fmt, depth)
end
return profile

View File

@@ -0,0 +1,120 @@
---#if not JIT then DISABLE() end
---@meta jit.util
---@class Trace
---@class Proto
local util = {}
---@class jit.funcinfo.lua
local funcinfo = {
linedefined = 0,
lastlinedefined = 0,
stackslots = 0,
params = 0,
bytecodes = 0,
gcconsts = 0,
nconsts = 0,
upvalues = 0,
currentline = 0,
isvararg = false,
children = false,
source = "",
loc = "",
---@type Proto[]
proto = {}
}
---@class jit.funcinfo.c
---@field ffid integer|nil
local funcinfo2 = {
addr = 0,
upvalues = 0,
}
---@param func function
---@param pc? integer
---@return jit.funcinfo.c|jit.funcinfo.lua info
function util.funcinfo(func, pc)
end
---@param func function
---@param pc integer
---@return integer? ins
---@return integer? m
function util.funcbc(func, pc)
end
---@param func function
---@param idx integer
---@return any? k
function util.funck(func, idx)
end
---@param func function
---@param idx integer
---@return string? name
function util.funcuvname(func, idx)
end
---@class jit.traceinfo
local traceinfo = {
nins = 0,
nk = 0,
link = 0,
nexit = 0,
linktype = ""
}
---@param tr Trace
---@return jit.traceinfo? info
function util.traceinfo(tr)
end
---@param tr Trace
---@param ref integer
---@return integer? m
---@return integer? ot
---@return integer? op1
---@return integer? op2
---@return integer? prev
function util.traceir(tr, ref)
end
---@param tr Trace
---@param idx integer
---@return any? k
---@return integer? t
---@return integer? slot
function util.tracek(tr, idx)
end
---@class jit.snap : integer[]
---@param tr Trace
---@param sn integer
---@return jit.snap? snap
function util.tracesnap(tr, sn)
end
---@param tr Trace
---@return string? mcode
---@return integer? addr
---@return integer? loop
function util.tracemc(tr)
end
---@overload fun(exitno: integer): integer
---@param tr Trace
---@param exitno integer
---@return integer? addr
function util.traceexitstub(tr, exitno)
end
---@param idx integer
---@return integer? addr
function util.ircalladdr(idx)
end
return util

View File

@@ -0,0 +1,253 @@
---@meta math
---#DES 'math'
---@class mathlib
---#DES 'math.huge'
---@field huge number
---#if VERSION >= 5.3 then
---#DES 'math.maxinteger'
---@field maxinteger integer
---#DES 'math.mininteger'
---@field mininteger integer
---#end
---#DES 'math.pi'
---@field pi number
math = {}
---#DES 'math.abs'
---@generic Number: number
---@param x Number
---@return Number
---@nodiscard
function math.abs(x) end
---#DES 'math.acos'
---@param x number
---@return number
---@nodiscard
function math.acos(x) end
---#DES 'math.asin'
---@param x number
---@return number
---@nodiscard
function math.asin(x) end
---#if VERSION <= 5.2 then
---#DES 'math.atan<5.2'
---@param y number
---@return number
---@nodiscard
function math.atan(y) end
---#else
---#DES 'math.atan>5.3'
---@param y number
---@param x? number
---@return number
---@nodiscard
function math.atan(y, x) end
---#end
---@version <5.2
---#DES 'math.atan2'
---@param y number
---@param x number
---@return number
---@nodiscard
function math.atan2(y, x) end
---#DES 'math.ceil'
---@param x number
---@return integer
---@nodiscard
function math.ceil(x) end
---#DES 'math.cos'
---@param x number
---@return number
---@nodiscard
function math.cos(x) end
---@version <5.2
---#DES 'math.cosh'
---@param x number
---@return number
---@nodiscard
function math.cosh(x) end
---#DES 'math.deg'
---@param x number
---@return number
---@nodiscard
function math.deg(x) end
---#DES 'math.exp'
---@param x number
---@return number
---@nodiscard
function math.exp(x) end
---#DES 'math.floor'
---@param x number
---@return integer
---@nodiscard
function math.floor(x) end
---#DES 'math.fmod'
---@param x number
---@param y number
---@return number
---@nodiscard
function math.fmod(x, y) end
---@version <5.2
---#DES 'math.frexp'
---@param x number
---@return number m
---@return number e
---@nodiscard
function math.frexp(x) end
---@version <5.2
---#DES 'math.ldexp'
---@param m number
---@param e number
---@return number
---@nodiscard
function math.ldexp(m, e) end
---#if VERSION <= 5.1 and not JIT then
---#DES 'math.log<5.1'
---@param x number
---@return number
---@nodiscard
function math.log(x) end
---#else
---#DES 'math.log>5.2'
---@param x number
---@param base? integer
---@return number
---@nodiscard
function math.log(x, base) end
---#end
---@version <5.1
---#DES 'math.log10'
---@param x number
---@return number
---@nodiscard
function math.log10(x) end
---#DES 'math.max'
---@generic Number: number
---@param x Number
---@param ... Number
---@return Number
---@nodiscard
function math.max(x, ...) end
---#DES 'math.min'
---@generic Number: number
---@param x Number
---@param ... Number
---@return Number
---@nodiscard
function math.min(x, ...) end
---#DES 'math.modf'
---@param x number
---@return integer
---@return number
---@nodiscard
function math.modf(x) end
---@version <5.2
---#DES 'math.pow'
---@param x number
---@param y number
---@return number
---@nodiscard
function math.pow(x, y) end
---#DES 'math.rad'
---@param x number
---@return number
---@nodiscard
function math.rad(x) end
---#DES 'math.random'
---@overload fun():number
---@overload fun(m: integer):integer
---@param m integer
---@param n integer
---@return integer
---@nodiscard
function math.random(m, n) end
---#if VERSION >= 5.4 then
---#DES 'math.randomseed>5.4'
---@param x? integer
---@param y? integer
function math.randomseed(x, y) end
---#else
---#DES 'math.randomseed<5.3'
---@param x integer
function math.randomseed(x) end
---#end
---#DES 'math.sin'
---@param x number
---@return number
---@nodiscard
function math.sin(x) end
---@version <5.2
---#DES 'math.sinh'
---@param x number
---@return number
---@nodiscard
function math.sinh(x) end
---#DES 'math.sqrt'
---@param x number
---@return number
---@nodiscard
function math.sqrt(x) end
---#DES 'math.tan'
---@param x number
---@return number
---@nodiscard
function math.tan(x) end
---@version <5.2
---#DES 'math.tanh'
---@param x number
---@return number
---@nodiscard
function math.tanh(x) end
---@version >5.3
---#DES 'math.tointeger'
---@param x any
---@return integer?
---@nodiscard
function math.tointeger(x) end
---#DES 'math.type'
---@param x any
---@return
---| '"integer"'
---| '"float"'
---| 'nil'
---@nodiscard
function math.type(x) end
---#DES 'math.ult'
---@param m integer
---@param n integer
---@return boolean
---@nodiscard
function math.ult(m, n) end
return math

View File

@@ -0,0 +1,134 @@
---@meta os
---#DES 'os'
---@class oslib
os = {}
---#DES 'os.clock'
---@return number
---@nodiscard
function os.clock() end
---@class osdate
---#DES 'osdate.year'
---@field year integer|string
---#DES 'osdate.month'
---@field month integer|string
---#DES 'osdate.day'
---@field day integer|string
---#DES 'osdate.hour'
---@field hour integer|string
---#DES 'osdate.min'
---@field min integer|string
---#DES 'osdate.sec'
---@field sec integer|string
---#DES 'osdate.wday'
---@field wday integer|string
---#DES 'osdate.yday'
---@field yday integer|string
---#DES 'osdate.isdst'
---@field isdst boolean
---#DES 'os.date'
---@param format? string
---@param time? integer
---@return string|osdate
---@nodiscard
function os.date(format, time) end
---#DES 'os.difftime'
---@param t2 integer
---@param t1 integer
---@return integer
---@nodiscard
function os.difftime(t2, t1) end
---#DES 'os.execute'
---#if VERSION <= 5.1 and not JIT then
---@param command? string
---@return integer code
function os.execute(command) end
---#else
---@param command? string
---@return boolean? suc
---@return exitcode? exitcode
---@return integer? code
function os.execute(command) end
---#end
---#if VERSION <= 5.1 and not JIT then
---#DES 'os.exit<5.1'
---@param code? integer
function os.exit(code, close) end
---#else
---#DES 'os.exit>5.2'
---@param code? boolean|integer
---@param close? boolean
function os.exit(code, close) end
---#end
---#DES 'os.getenv'
---@param varname string
---@return string?
---@nodiscard
function os.getenv(varname) end
---#DES 'os.remove'
---@param filename string
---@return boolean suc
---@return string? errmsg
function os.remove(filename) end
---#DES 'os.rename'
---@param oldname string
---@param newname string
---@return boolean suc
---@return string? errmsg
function os.rename(oldname, newname) end
---@alias localecategory
---|>"all"
---| "collate"
---| "ctype"
---| "monetary"
---| "numeric"
---| "time"
---#DES 'os.setlocale'
---@param locale string|nil
---@param category? localecategory
---@return string localecategory
function os.setlocale(locale, category) end
---@class osdateparam
---#DES 'osdate.year'
---@field year integer|string
---#DES 'osdate.month'
---@field month integer|string
---#DES 'osdate.day'
---@field day integer|string
---#DES 'osdate.hour'
---@field hour (integer|string)?
---#DES 'osdate.min'
---@field min (integer|string)?
---#DES 'osdate.sec'
---@field sec (integer|string)?
---#DES 'osdate.wday'
---@field wday (integer|string)?
---#DES 'osdate.yday'
---@field yday (integer|string)?
---#DES 'osdate.isdst'
---@field isdst boolean?
---#DES 'os.time'
---@param date? osdateparam
---@return integer
---@nodiscard
function os.time(date) end
---#DES 'os.tmpname'
---@return string
---@nodiscard
function os.tmpname() end
return os

View File

@@ -0,0 +1,66 @@
---@meta package
---#if VERSION >=5.4 then
---#DES 'require>5.4'
---@param modname string
---@return unknown
---@return unknown loaderdata
function require(modname) end
---#else
---#DES 'require<5.3'
---@param modname string
---@return unknown
function require(modname) end
---#end
---#DES 'package'
---@class packagelib
---#DES 'package.cpath'
---@field cpath string
---#DES 'package.loaded'
---@field loaded table
---#DES 'package.path'
---@field path string
---#DES 'package.preload'
---@field preload table
package = {}
---#DES 'package.config'
package.config = [[
/
;
?
!
-]]
---@version <5.1
---#DES 'package.loaders'
package.loaders = {}
---#DES 'package.loadlib'
---@param libname string
---@param funcname string
---@return any
function package.loadlib(libname, funcname) end
---#DES 'package.searchers'
---@version >5.2
package.searchers = {}
---#DES 'package.searchpath'
---@version >5.2,JIT
---@param name string
---@param path string
---@param sep? string
---@param rep? string
---@return string? filename
---@return string? errmsg
---@nodiscard
function package.searchpath(name, path, sep, rep) end
---#DES 'package.seeall'
---@version <5.1
---@param module table
function package.seeall(module) end
return package

View File

@@ -0,0 +1,354 @@
---#if not JIT then DISABLE() end
---@meta string.buffer
---@version JIT
--- The string buffer library allows high-performance manipulation of string-like data.
---
--- Unlike Lua strings, which are constants, string buffers are mutable sequences of 8-bit (binary-transparent) characters. Data can be stored, formatted and encoded into a string buffer and later converted, extracted or decoded.
---
--- The convenient string buffer API simplifies common string manipulation tasks, that would otherwise require creating many intermediate strings. String buffers improve performance by eliminating redundant memory copies, object creation, string interning and garbage collection overhead. In conjunction with the FFI library, they allow zero-copy operations.
---
--- The string buffer libary also includes a high-performance serializer for Lua objects.
---
---
--- ## Streaming Serialization
---
--- In some contexts, it's desirable to do piecewise serialization of large datasets, also known as streaming.
---
--- This serialization format can be safely concatenated and supports streaming. Multiple encodings can simply be appended to a buffer and later decoded individually:
---
--- ```lua
--- local buf = buffer.new()
--- buf:encode(obj1)
--- buf:encode(obj2)
--- local copy1 = buf:decode()
--- local copy2 = buf:decode()
--- ```
---
--- Here's how to iterate over a stream:
---
--- ```lua
--- while #buf ~= 0 do
--- local obj = buf:decode()
--- -- Do something with obj.
--- end
--- ```
---
--- Since the serialization format doesn't prepend a length to its encoding, network applications may need to transmit the length, too.
--- Serialization Format Specification
---
--- This serialization format is designed for internal use by LuaJIT applications. Serialized data is upwards-compatible and portable across all supported LuaJIT platforms.
---
--- It's an 8-bit binary format and not human-readable. It uses e.g. embedded zeroes and stores embedded Lua string objects unmodified, which are 8-bit-clean, too. Encoded data can be safely concatenated for streaming and later decoded one top-level object at a time.
---
--- The encoding is reasonably compact, but tuned for maximum performance, not for minimum space usage. It compresses well with any of the common byte-oriented data compression algorithms.
---
--- Although documented here for reference, this format is explicitly not intended to be a 'public standard' for structured data interchange across computer languages (like JSON or MessagePack). Please do not use it as such.
---
--- The specification is given below as a context-free grammar with a top-level object as the starting point. Alternatives are separated by the | symbol and * indicates repeats. Grouping is implicit or indicated by {…}. Terminals are either plain hex numbers, encoded as bytes, or have a .format suffix.
---
--- ```
--- object → nil | false | true
--- | null | lightud32 | lightud64
--- | int | num | tab | tab_mt
--- | int64 | uint64 | complex
--- | string
---
--- nil → 0x00
--- false → 0x01
--- true → 0x02
---
--- null → 0x03 // NULL lightuserdata
--- lightud32 → 0x04 data.I // 32 bit lightuserdata
--- lightud64 → 0x05 data.L // 64 bit lightuserdata
---
--- int → 0x06 int.I // int32_t
--- num → 0x07 double.L
---
--- tab → 0x08 // Empty table
--- | 0x09 h.U h*{object object} // Key/value hash
--- | 0x0a a.U a*object // 0-based array
--- | 0x0b a.U a*object h.U h*{object object} // Mixed
--- | 0x0c a.U (a-1)*object // 1-based array
--- | 0x0d a.U (a-1)*object h.U h*{object object} // Mixed
--- tab_mt → 0x0e (index-1).U tab // Metatable dict entry
---
--- int64 → 0x10 int.L // FFI int64_t
--- uint64 → 0x11 uint.L // FFI uint64_t
--- complex → 0x12 re.L im.L // FFI complex
---
--- string → (0x20+len).U len*char.B
--- | 0x0f (index-1).U // String dict entry
---
--- .B = 8 bit
--- .I = 32 bit little-endian
--- .L = 64 bit little-endian
--- .U = prefix-encoded 32 bit unsigned number n:
--- 0x00..0xdf → n.B
--- 0xe0..0x1fdf → (0xe0|(((n-0xe0)>>8)&0x1f)).B ((n-0xe0)&0xff).B
--- 0x1fe0.. → 0xff n.I
--- ```
---
--- ## Error handling
---
--- Many of the buffer methods can throw an error. Out-of-memory or usage errors are best caught with an outer wrapper for larger parts of code. There's not much one can do after that, anyway.
---
--- OTOH you may want to catch some errors individually. Buffer methods need to receive the buffer object as the first argument. The Lua colon-syntax `obj:method()` does that implicitly. But to wrap a method with `pcall()`, the arguments need to be passed like this:
---
--- ```lua
--- local ok, err = pcall(buf.encode, buf, obj)
--- if not ok then
--- -- Handle error in err.
--- end
--- ```
---
--- ## FFI caveats
---
--- The string buffer library has been designed to work well together with the FFI library. But due to the low-level nature of the FFI library, some care needs to be taken:
---
--- First, please remember that FFI pointers are zero-indexed. The space returned by `buf:reserve()` and `buf:ref()` starts at the returned pointer and ends before len bytes after that.
---
--- I.e. the first valid index is `ptr[0]` and the last valid index is `ptr[len-1]`. If the returned length is zero, there's no valid index at all. The returned pointer may even be `NULL`.
---
--- The space pointed to by the returned pointer is only valid as long as the buffer is not modified in any way (neither append, nor consume, nor reset, etc.). The pointer is also not a GC anchor for the buffer object itself.
---
--- Buffer data is only guaranteed to be byte-aligned. Casting the returned pointer to a data type with higher alignment may cause unaligned accesses. It depends on the CPU architecture whether this is allowed or not (it's always OK on x86/x64 and mostly OK on other modern architectures).
---
--- FFI pointers or references do not count as GC anchors for an underlying object. E.g. an array allocated with `ffi.new()` is anchored by `buf:set(array, len)`, but not by `buf:set(array+offset, len)`. The addition of the offset creates a new pointer, even when the offset is zero. In this case, you need to make sure there's still a reference to the original array as long as its contents are in use by the buffer.
---
--- Even though each LuaJIT VM instance is single-threaded (but you can create multiple VMs), FFI data structures can be accessed concurrently. Be careful when reading/writing FFI cdata from/to buffers to avoid concurrent accesses or modifications. In particular, the memory referenced by `buf:set(cdata, len)` must not be modified while buffer readers are working on it. Shared, but read-only memory mappings of files are OK, but only if the file does not change.
local buffer = {}
--- A buffer object is a garbage-collected Lua object. After creation with `buffer.new()`, it can (and should) be reused for many operations. When the last reference to a buffer object is gone, it will eventually be freed by the garbage collector, along with the allocated buffer space.
---
--- Buffers operate like a FIFO (first-in first-out) data structure. Data can be appended (written) to the end of the buffer and consumed (read) from the front of the buffer. These operations may be freely mixed.
---
--- The buffer space that holds the characters is managed automatically — it grows as needed and already consumed space is recycled. Use `buffer.new(size)` and `buf:free()`, if you need more control.
---
--- The maximum size of a single buffer is the same as the maximum size of a Lua string, which is slightly below two gigabytes. For huge data sizes, neither strings nor buffers are the right data structure — use the FFI library to directly map memory or files up to the virtual memory limit of your OS.
---
---@version JIT
---@class string.buffer : table
local buf = {}
--- A string, number, or any object obj with a __tostring metamethod to the buffer.
---
---@alias string.buffer.data string|number|table
--- Appends a string str, a number num or any object obj with a `__tostring` metamethod to the buffer. Multiple arguments are appended in the given order.
---
--- Appending a buffer to a buffer is possible and short-circuited internally. But it still involves a copy. Better combine the buffer writes to use a single buffer.
---
---@param data string.buffer.data
---@param ...? string.buffer.data
---@return string.buffer
function buf:put(data, ...) end
--- Appends the formatted arguments to the buffer. The format string supports the same options as string.format().
---
---@param format string
---@param ... string.buffer.data
---@return string.buffer
function buf:putf(format, ...) end
--- Appends the given len number of bytes from the memory pointed to by the FFI cdata object to the buffer. The object needs to be convertible to a (constant) pointer.
---
---@param cdata ffi.cdata*
---@param len integer
---@return string.buffer
function buf:putcdata(cdata, len) end
--- This method allows zero-copy consumption of a string or an FFI cdata object as a buffer. It stores a reference to the passed string str or the FFI cdata object in the buffer. Any buffer space originally allocated is freed. This is not an append operation, unlike the `buf:put*()` methods.
---
--- After calling this method, the buffer behaves as if `buf:free():put(str)` or `buf:free():put(cdata, len)` had been called. However, the data is only referenced and not copied, as long as the buffer is only consumed.
---
--- In case the buffer is written to later on, the referenced data is copied and the object reference is removed (copy-on-write semantics).
---
--- The stored reference is an anchor for the garbage collector and keeps the originally passed string or FFI cdata object alive.
---
---@param str string.buffer.data
---@return string.buffer
---@overload fun(self:string.buffer, cdata:ffi.cdata*, len:integer):string.buffer
function buf:set(str) end
--- Reset (empty) the buffer. The allocated buffer space is not freed and may be reused.
---@return string.buffer
function buf:reset() end
--- The buffer space of the buffer object is freed. The object itself remains intact, empty and may be reused.
---
--- Note: you normally don't need to use this method. The garbage collector automatically frees the buffer space, when the buffer object is collected. Use this method, if you need to free the associated memory immediately.
function buf:free() end
--- The reserve method reserves at least size bytes of write space in the buffer. It returns an uint8_t * FFI cdata pointer ptr that points to this space.
---
--- The available length in bytes is returned in len. This is at least size bytes, but may be more to facilitate efficient buffer growth. You can either make use of the additional space or ignore len and only use size bytes.
---
--- This, along with `buf:commit()` allow zero-copy use of C read-style APIs:
---
--- ```lua
--- local MIN_SIZE = 65536
--- repeat
--- local ptr, len = buf:reserve(MIN_SIZE)
--- local n = C.read(fd, ptr, len)
--- if n == 0 then break end -- EOF.
--- if n < 0 then error("read error") end
--- buf:commit(n)
--- until false
--- ```
---
--- The reserved write space is not initialized. At least the used bytes must be written to before calling the commit method. There's no need to call the commit method, if nothing is added to the buffer (e.g. on error).
---@param size integer
---@return ffi.cdata* ptr # an uint8_t * FFI cdata pointer that points to this space
---@return integer len # available length (bytes)
function buf:reserve(size) end
--- Appends the used bytes of the previously returned write space to the buffer data.
---@param used integer
---@return string.buffer
function buf:commit(used) end
--- Skips (consumes) len bytes from the buffer up to the current length of the buffer data.
---@param len integer
---@return string.buffer
function buf:skip(len) end
--- Consumes the buffer data and returns one or more strings. If called without arguments, the whole buffer data is consumed. If called with a number, up to `len` bytes are consumed. A `nil` argument consumes the remaining buffer space (this only makes sense as the last argument). Multiple arguments consume the buffer data in the given order.
---
--- Note: a zero length or no remaining buffer data returns an empty string and not `nil`.
---
---@param len? integer
---@param ... integer|nil
---@return string ...
function buf:get(len, ...) end
--- Creates a string from the buffer data, but doesn't consume it. The buffer remains unchanged.
---
--- Buffer objects also define a `__tostring metamethod`. This means buffers can be passed to the global `tostring()` function and many other functions that accept this in place of strings. The important internal uses in functions like `io.write()` are short-circuited to avoid the creation of an intermediate string object.
---@return string
function buf:tostring() end
--- Returns an uint8_t * FFI cdata pointer ptr that points to the buffer data. The length of the buffer data in bytes is returned in len.
---
--- The returned pointer can be directly passed to C functions that expect a buffer and a length. You can also do bytewise reads (`local x = ptr[i]`) or writes (`ptr[i] = 0x40`) of the buffer data.
---
--- In conjunction with the `buf:skip()` method, this allows zero-copy use of C write-style APIs:
---
--- ```lua
--- repeat
--- local ptr, len = buf:ref()
--- if len == 0 then break end
--- local n = C.write(fd, ptr, len)
--- if n < 0 then error("write error") end
--- buf:skip(n)
--- until n >= len
--- ```
---
--- Unlike Lua strings, buffer data is not implicitly zero-terminated. It's not safe to pass ptr to C functions that expect zero-terminated strings. If you're not using len, then you're doing something wrong.
---
---@return ffi.cdata* ptr # an uint8_t * FFI cdata pointer that points to the buffer data.
---@return integer len # length of the buffer data in bytes
function buf:ref() end
--- Serializes (encodes) the Lua object to the buffer
---
--- This function may throw an error when attempting to serialize unsupported object types, circular references or deeply nested tables.
---@param obj string.buffer.data
---@return string.buffer
function buf:encode(obj) end
--- De-serializes one object from the buffer.
---
--- The returned object may be any of the supported Lua types — even `nil`.
---
--- This function may throw an error when fed with malformed or incomplete encoded data.
---
--- Leaves any left-over data in the buffer.
---
--- Attempting to de-serialize an FFI type will throw an error, if the FFI library is not built-in or has not been loaded, yet.
---
---@return string.buffer.data|nil obj
function buf:decode() end
--- Serializes (encodes) the Lua object obj
---
--- This function may throw an error when attempting to serialize unsupported object types, circular references or deeply nested tables.
---@param obj string.buffer.data
---@return string
function buffer.encode(obj) end
--- De-serializes (decodes) the string to a Lua object
---
--- The returned object may be any of the supported Lua types — even `nil`.
---
--- Throws an error when fed with malformed or incomplete encoded data.
--- Throws an error when there's left-over data after decoding a single top-level object.
---
--- Attempting to de-serialize an FFI type will throw an error, if the FFI library is not built-in or has not been loaded, yet.
---
---@param str string
---@return string.buffer.data|nil obj
function buffer.decode(str) end
--- Creates a new buffer object.
---
--- The optional size argument ensures a minimum initial buffer size. This is strictly an optimization when the required buffer size is known beforehand. The buffer space will grow as needed, in any case.
---
--- The optional table options sets various serialization options.
---
---@param size? integer
---@param options? string.buffer.serialization.opts
---@return string.buffer
function buffer.new(size, options) end
--- Serialization Options
---
--- The options table passed to buffer.new() may contain the following members (all optional):
---
--- * `dict` is a Lua table holding a dictionary of strings that commonly occur as table keys of objects you are serializing. These keys are compactly encoded as indexes during serialization. A well chosen dictionary saves space and improves serialization performance.
---
--- * `metatable` is a Lua table holding a dictionary of metatables for the table objects you are serializing.
---
--- dict needs to be an array of strings and metatable needs to be an array of tables. Both starting at index 1 and without holes (no nil inbetween). The tables are anchored in the buffer object and internally modified into a two-way index (don't do this yourself, just pass a plain array). The tables must not be modified after they have been passed to buffer.new().
---
--- The dict and metatable tables used by the encoder and decoder must be the same. Put the most common entries at the front. Extend at the end to ensure backwards-compatibility — older encodings can then still be read. You may also set some indexes to false to explicitly drop backwards-compatibility. Old encodings that use these indexes will throw an error when decoded.
---
--- Metatables that are not found in the metatable dictionary are ignored when encoding. Decoding returns a table with a nil metatable.
---
--- Note: parsing and preparation of the options table is somewhat expensive. Create a buffer object only once and recycle it for multiple uses. Avoid mixing encoder and decoder buffers, since the buf:set() method frees the already allocated buffer space:
---
--- ```lua
--- local options = {
--- dict = { "commonly", "used", "string", "keys" },
--- }
--- local buf_enc = buffer.new(options)
--- local buf_dec = buffer.new(options)
---
--- local function encode(obj)
--- return buf_enc:reset():encode(obj):get()
--- end
---
--- local function decode(str)
--- return buf_dec:set(str):decode()
--- end
--- ```
---@class string.buffer.serialization.opts
---@field dict string[]
---@field metatable table[]
return buffer

View File

@@ -0,0 +1,163 @@
---@meta string
---#DES 'string'
---@class stringlib
string = {}
---#DES 'string.byte'
---@param s string|number
---@param i? integer
---@param j? integer
---@return integer ...
---@nodiscard
function string.byte(s, i, j) end
---#DES 'string.char'
---@param byte integer
---@param ... integer
---@return string
---@nodiscard
function string.char(byte, ...) end
---#DES 'string.dump'
---#if VERSION >= 5.3 or JIT then
---@param f async fun(...):...
---@param strip? boolean
---@return string
---@nodiscard
function string.dump(f, strip) end
---#else
---@param f async fun(...):...
---@return string
---@nodiscard
function string.dump(f) end
---#end
---#DES 'string.find'
---@param s string|number
---@param pattern string|number
---@param init? integer
---@param plain? boolean
---@return integer|nil start
---@return integer|nil end
---@return any|nil ... captured
---@nodiscard
function string.find(s, pattern, init, plain) end
---#DES 'string.format'
---@param s string|number
---@param ... any
---@return string
---@nodiscard
function string.format(s, ...) end
---#DES 'string.gmatch'
---#if VERSION <= 5.3 then
---@param s string|number
---@param pattern string|number
---@return fun():string, ...
---@nodiscard
function string.gmatch(s, pattern) end
---#else
---@param s string|number
---@param pattern string|number
---@param init? integer
---@return fun():string, ...
function string.gmatch(s, pattern, init) end
---#end
---#DES 'string.gsub'
---@param s string|number
---@param pattern string|number
---@param repl string|number|table|function
---@param n? integer
---@return string
---@return integer count
---@nodiscard
function string.gsub(s, pattern, repl, n) end
---#DES 'string.len'
---@param s string|number
---@return integer
---@nodiscard
function string.len(s) end
---#DES 'string.lower'
---@param s string|number
---@return string
---@nodiscard
function string.lower(s) end
---#DES 'string.match'
---@param s string|number
---@param pattern string|number
---@param init? integer
---@return any ...
---@nodiscard
function string.match(s, pattern, init) end
---@version >5.3
---#DES 'string.pack'
---@param fmt string
---@param v1 string|number
---@param v2? string|number
---@param ... string|number
---@return string binary
---@nodiscard
function string.pack(fmt, v1, v2, ...) end
---@version >5.3
---#DES 'string.packsize'
---@param fmt string
---@return integer
---@nodiscard
function string.packsize(fmt) end
---#if VERSION <= 5.1 and not JIT then
---#DES 'string.rep<5.1'
---@param s string|number
---@param n integer
---@return string
---@nodiscard
function string.rep(s, n) end
---#else
---#DES 'string.rep>5.2'
---@param s string|number
---@param n integer
---@param sep? string|number
---@return string
---@nodiscard
function string.rep(s, n, sep) end
---#end
---#DES 'string.reverse'
---@param s string|number
---@return string
---@nodiscard
function string.reverse(s) end
---#DES 'string.sub'
---@param s string|number
---@param i integer
---@param j? integer
---@return string
---@nodiscard
function string.sub(s, i, j) end
---@version >5.3
---#DES 'string.unpack'
---@param fmt string
---@param s string
---@param pos? integer
---@return any ...
---@return integer offset
---@nodiscard
function string.unpack(fmt, s, pos) end
---#DES 'string.upper'
---@param s string|number
---@return string
---@nodiscard
function string.upper(s) end
return string

View File

@@ -0,0 +1,9 @@
---#if not JIT then DISABLE() end
---@meta table.clear
---@version JIT
---#DES 'table.clear'
---@param tab table
local function clear(tab) end
return clear

View File

@@ -0,0 +1,95 @@
---@meta table
---#DES 'table'
---@class tablelib
table = {}
---#DES 'table.concat'
---@param list table
---@param sep? string
---@param i? integer
---@param j? integer
---@return string
---@nodiscard
function table.concat(list, sep, i, j) end
---#DES 'table.insert'
---@overload fun(list: table, value: any)
---@param list table
---@param pos integer
---@param value any
function table.insert(list, pos, value) end
---@version <5.1
---#DES 'table.maxn'
---@param table table
---@return integer
---@nodiscard
function table.maxn(table) end
---@version >5.3
---#DES 'table.move'
---@param a1 table
---@param f integer
---@param e integer
---@param t integer
---@param a2? table
---@return table a2
function table.move(a1, f, e, t, a2) end
---@version >5.2, JIT
---#DES 'table.pack'
---@return table
---@nodiscard
function table.pack(...) end
---#DES 'table.remove'
---@param list table
---@param pos? integer
---@return any
function table.remove(list, pos) end
---#DES 'table.sort'
---@generic T
---@param list T[]
---@param comp? fun(a: T, b: T):boolean
function table.sort(list, comp) end
---@version >5.2, JIT
---#DES 'table.unpack'
---@generic T
---@param list T[]
---@param i? integer
---@param j? integer
---@return T ...
---@nodiscard
function table.unpack(list, i, j) end
---@version <5.1, JIT
---#DES 'table.foreach'
---@generic T
---@param list any
---@param callback fun(key: string, value: any):T|nil
---@return T|nil
---@deprecated
function table.foreach(list, callback) end
---@version <5.1, JIT
---#DES 'table.foreachi'
---@generic T
---@param list any
---@param callback fun(key: string, value: any):T|nil
---@return T|nil
---@deprecated
function table.foreachi(list, callback) end
---@version <5.1, JIT
---#DES 'table.getn'
---@generic T
---@param list T[]
---@return integer
---@nodiscard
---@deprecated
function table.getn(list) end
return table

View File

@@ -0,0 +1,11 @@
---#if not JIT then DISABLE() end
---@meta table.new
---@version JIT
---#DES 'table.new'
---@param narray integer
---@param nhash integer
---@return table
local function new(narray, nhash) end
return new

View File

@@ -0,0 +1,78 @@
---#if VERSION <= 5.2 then DISABLE() end
---@meta utf8
---@version >5.3
---#DES 'utf8'
---@class utf8lib
---#DES 'utf8.charpattern'
---@field charpattern string
utf8 = {}
---#DES 'utf8.char'
---@param code integer
---@param ... integer
---@return string
---@nodiscard
function utf8.char(code, ...) end
---#DES 'utf8.codes'
---#if VERSION <= 5.3 then
---@param s string
---@return fun(s: string, p: integer):integer, integer
function utf8.codes(s) end
---#else
---@param s string
---@param lax? boolean
---@return fun(s: string, p: integer):integer, integer
function utf8.codes(s, lax) end
---#end
---#DES 'utf8.codepoint'
---#if VERSION <= 5.3 then
---@param s string
---@param i? integer
---@param j? integer
---@return integer code
---@return integer ...
---@nodiscard
function utf8.codepoint(s, i, j) end
---#else
---@param s string
---@param i? integer
---@param j? integer
---@param lax? boolean
---@return integer code
---@return integer ...
---@nodiscard
function utf8.codepoint(s, i, j, lax) end
---#end
---#DES 'utf8.len'
---#if VERSION <= 5.3 then
---@param s string
---@param i? integer
---@param j? integer
---@return integer?
---@return integer? errpos
---@nodiscard
function utf8.len(s, i, j) end
---#else
---@param s string
---@param i? integer
---@param j? integer
---@param lax? boolean
---@return integer?
---@return integer? errpos
---@nodiscard
function utf8.len(s, i, j, lax) end
---#end
---#DES 'utf8.offset'
---@param s string
---@param n integer
---@param i? integer
---@return integer p
---@nodiscard
function utf8.offset(s, n, i) end
return utf8

View File

@@ -0,0 +1,50 @@
---@meta _
---#DES 'arg'
---@type string[]
arg = {}
---#DES 'assert'
---@generic T
---@param v? T
---@param message? any
---@param ... any
---@return T
---@return any ... => args[reti + 1]
---@throw => args[1].isFalsy
---@narrow v => args[1].truly
function assert(v, message, ...) end
--[[@@@
---@overload fun(opt: 'collect') # ---#DESTAIL 'cgopt.collect'
---@overload fun(opt: 'stop') # ---#DESTAIL 'cgopt.stop'
---@overload fun(opt: 'restart') # ---#DESTAIL 'cgopt.restart'
---@overload fun(opt: 'count'): integer # ---#DESTAIL 'cgopt.count'
---@overload fun(opt: 'step'): boolean # ---#DESTAIL 'cgopt.step'
---@overload fun(opt: 'isrunning'): boolean # ---#DESTAIL 'cgopt.isrunning'
---#if VERSION >= 5.4 then
---@overload fun(opt: 'incremental'
, pause?: integer
, stepmul?: integer
, stepsize?: integer) # ---#DESTAIL 'cgopt.incremental'
---@overload fun(opt: 'generational'
, minor?: integer
, major?: integer) # ---#DESTAIL 'cgopt.generational'
---#end
---@overload fun(opt: 'setpause', arg: integer) # ---#DESTAIL 'cgopt.setpause'
---@overload fun(opt: 'setstepmul', arg: integer) # ---#DESTAIL 'cgopt.setstepmul'
---@prototype
]]
function collectgarbage(...) end
---#DES 'dofile'
---@param filename? string
---@return any
---@custom dofile
function dofile(filename) end
---#DES 'error'
---@param message any
---@param level? integer
---@throw
function error(message, level) end

View File

@@ -0,0 +1,18 @@
---@meta _
---@class nil
---@class never
---@class true
---@class false
---@class any: { [unknown]: any }
---@class truly: { [unknown]: any }
---@class unknown: truly | false
---@class boolean
---@class number
---@class thread
---@class table: { [unknown]: any }
---@class table<K, V>: { [K]: V }
---@class string: stringlib
---@class userdata: { [unknown]: any }
---@class lightuserdata
---@class function: fun(...): ...

View File

@@ -0,0 +1,128 @@
local cat
cat.rule.default = function (self)
self.isTruly = true
self.truly = self
self.falsy = cat.class 'never'
self.view = self.name
end
cat.rule.never = function (self)
self.isTruly = nil
end
cat.rule.any = function (self)
self.isTruly = nil
self.truly = cat.class 'truly'
self.falsy = cat.boolean(false) | cat.class 'nil'
end
cat.rule['nil'] = function (self)
self.isTruly = false
self.truly = cat.class 'never'
self.falsy = self
end
cat.rule.boolean = function (self)
if self.value == true then
self.isTruly = true
self.truly = self
self.falsy = cat.class 'never'
elseif self.value == false then
self.isTruly = false
self.truly = cat.class 'never'
self.falsy = self
else
self.isTruly = nil
self.truly = cat.boolean(true)
self.falsy = cat.boolean(false)
end
end
cat.rule.number = function (self)
self.isTruly = true
self.truly = self
self.falsy = cat.class 'never'
self.view = tostring(self.value)
end
cat.rule.integer = function (self)
self.isTruly = true
self.truly = self
self.falsy = cat.class 'never'
self.view = tostring(self.value)
end
cat.rule.string = function (self)
self.isTruly = true
self.truly = self
self.falsy = cat.class 'never'
self.view = cat.util.viewString(self.value, self.quotation)
end
cat.rule.union = function (self)
self.isTruly = function (union)
local isTruly = union.subs[1].isTruly
if isTruly == nil then
return nil
end
if isTruly == true then
for i = 2, #union.subs do
if union.subs[i].isTruly ~= true then
return nil
end
end
return true
else
for i = 2, #union.subs do
if union.subs[i].isTruly ~= false then
return nil
end
end
return false
end
return nil
end
self.truly = function (union)
local new = cat.union()
for i = 1, #union.subs do
new:add(union.subs[i].truly)
end
if new:len() == 0 then
return cat.class 'never'
end
if new:len() == 1 then
return new[1]
end
return new
end
self.falsy = function (union)
local new = cat.union()
for i = 1, #union.subs do
new:add(union.subs[i].falsy)
end
if new:len() == 0 then
return cat.class 'never'
end
if new:len() == 1 then
return new[1]
end
return new
end
self.view = function (union)
local views = {}
for i = 1, #union.subs do
views[i] = union.subs[i].view
end
if #views == 0 then
return 'never'
end
return table.concat(views, '|')
end
end
cat.custom.dofile.onReturn = function (context)
local filename = context.args[1].asString
local file = cat.files[filename]
return file.returns[1]
end

View File

@@ -0,0 +1,60 @@
local byte = string.byte
local max = 0x7fffffff
---@class SDBMHash
local mt = {}
mt.__index = mt
mt.cache = nil
---@param str string
---@return integer
function mt:rawHash(str)
local id = 0
for i = 1, #str do
local b = byte(str, i, i)
id = id * 65599 + b
end
return id & max
end
---@param str string
---@return integer
function mt:hash(str)
local id = self:rawHash(str)
local other = self.cache[id]
if other == nil or str == other then
self.cache[id] = str
self.cache[str] = id
return id
else
log.warn(('哈希碰撞:[%s] -> [%s]: [%d]'):format(str, other, id))
for i = 1, max do
local newId = (id + i) % max
if not self.cache[newId] then
self.cache[newId] = str
self.cache[str] = newId
return newId
end
end
error(('哈希碰撞解决失败:[%s] -> [%s]: [%d]'):format(str, other, id))
end
end
function mt:setCache(t)
self.cache = t
end
function mt:getCache()
return self.cache
end
mt.__call = mt.hash
---@return SDBMHash
return function ()
local self = setmetatable({
cache = {}
}, mt)
return self
end

View File

@@ -0,0 +1,245 @@
local timer = require 'timer'
local wkmt = { __mode = 'k' }
---@class await
local m = {}
m.type = 'await'
m.coMap = setmetatable({}, wkmt)
m.idMap = {}
m.delayQueue = {}
m.delayQueueIndex = 1
m.needClose = {}
m._enable = true
local function setID(id, co, callback)
if not coroutine.isyieldable(co) then
return
end
if not m.idMap[id] then
m.idMap[id] = setmetatable({}, wkmt)
end
m.idMap[id][co] = callback or true
end
--- 设置错误处理器
---@param errHandle function # 当有错误发生时,会以错误堆栈为参数调用该函数
function m.setErrorHandle(errHandle)
m.errorHandle = errHandle
end
function m.checkResult(co, ...)
local suc, err = ...
if not suc and m.errorHandle then
m.errorHandle(debug.traceback(co, err))
end
return ...
end
--- 创建一个任务
---@param callback async fun()
function m.call(callback, ...)
local co = coroutine.create(callback)
local closers = {}
m.coMap[co] = {
closers = closers,
priority = false,
}
for i = 1, select('#', ...) do
local id = select(i, ...)
if not id then
break
end
setID(id, co)
end
local currentCo = coroutine.running()
local current = m.coMap[currentCo]
if current then
for closer in pairs(current.closers) do
closers[closer] = true
closer(co)
end
end
return m.checkResult(co, coroutine.resume(co))
end
--- 创建一个任务,并挂起当前线程,当任务完成后再延续当前线程/若任务被关闭则返回nil
---@async
function m.await(callback, ...)
if not coroutine.isyieldable() then
return callback(...)
end
return m.wait(function (resume, ...)
m.call(function ()
local returnNil <close> = resume
resume(callback())
end, ...)
end, ...)
end
--- 设置一个id用于批量关闭任务
function m.setID(id, callback)
local co = coroutine.running()
setID(id, co, callback)
end
--- 根据id批量关闭任务
function m.close(id)
local map = m.idMap[id]
if not map then
return
end
m.idMap[id] = nil
for co, callback in pairs(map) do
if coroutine.status(co) == 'suspended' then
map[co] = nil
if type(callback) == 'function' then
xpcall(callback, log.error)
end
coroutine.close(co)
end
end
end
function m.hasID(id, co)
co = co or coroutine.running()
return m.idMap[id] and m.idMap[id][co] ~= nil
end
function m.unique(id, callback)
m.close(id)
m.setID(id, callback)
end
--- 休眠一段时间
---@param time number
---@async
function m.sleep(time)
if not coroutine.isyieldable() then
if m.errorHandle then
m.errorHandle(debug.traceback('Cannot yield'))
end
return
end
local co = coroutine.running()
timer.wait(time, function ()
if coroutine.status(co) ~= 'suspended' then
return
end
return m.checkResult(co, coroutine.resume(co))
end)
return coroutine.yield()
end
--- 等待直到唤醒
---@param callback function
---@async
function m.wait(callback, ...)
local co = coroutine.running()
local resumed
callback(function (...)
if resumed then
return
end
resumed = true
if coroutine.status(co) ~= 'suspended' then
return
end
return m.checkResult(co, coroutine.resume(co, ...))
end, ...)
return coroutine.yield()
end
--- 延迟
---@async
function m.delay()
if not m._enable then
return
end
if not coroutine.isyieldable() then
return
end
local co = coroutine.running()
local current = m.coMap[co]
-- TODO
if current.priority then
return
end
m.delayQueue[#m.delayQueue+1] = function ()
if coroutine.status(co) ~= 'suspended' then
return
end
return m.checkResult(co, coroutine.resume(co))
end
return coroutine.yield()
end
--- stop then close
---@async
function m.stop()
if not coroutine.isyieldable() then
return
end
m.needClose[#m.needClose+1] = coroutine.running()
coroutine.yield()
end
local function warnStepTime(passed, waker)
if passed < 2 then
log.warn(('Await step takes [%.3f] sec.'):format(passed))
return
end
for i = 1, 100 do
local name, v = debug.getupvalue(waker, i)
if not name then
return
end
if name == 'co' then
log.warn(debug.traceback(v, ('[fire]Await step takes [%.3f] sec.'):format(passed)))
return
end
end
end
--- 步进
function m.step()
for i = #m.needClose, 1, -1 do
coroutine.close(m.needClose[i])
m.needClose[i] = nil
end
local resume = m.delayQueue[m.delayQueueIndex]
if resume then
m.delayQueue[m.delayQueueIndex] = false
m.delayQueueIndex = m.delayQueueIndex + 1
local clock = os.clock()
resume()
local passed = os.clock() - clock
if passed > 0.5 then
warnStepTime(passed, resume)
end
return true
else
for i = 1, #m.delayQueue do
m.delayQueue[i] = nil
end
m.delayQueueIndex = 1
return false
end
end
function m.setPriority(n)
m.coMap[coroutine.running()].priority = true
end
function m.enable()
m._enable = true
end
function m.disable()
m._enable = false
end
return m

View File

@@ -0,0 +1,68 @@
local thread = require 'bee.thread'
local taskPad = thread.channel('taskpad')
local waiter = thread.channel('waiter')
---@class pub_brave
local m = {}
m.type = 'brave'
m.ability = {}
m.queue = {}
--- 注册成为勇者
function m.register(id, privatePad)
m.id = id
if #m.queue > 0 then
for _, info in ipairs(m.queue) do
waiter:push(m.id, info.name, info.params)
end
end
m.queue = nil
m.start(privatePad)
end
--- 注册能力
function m.on(name, callback)
m.ability[name] = callback
end
--- 报告
function m.push(name, params)
if m.id then
waiter:push(m.id, name, params)
else
m.queue[#m.queue+1] = {
name = name,
params = params,
}
end
end
--- 开始找工作
function m.start(privatePad)
local reqPad = privatePad and thread.channel('req:' .. privatePad) or taskPad
local resPad = privatePad and thread.channel('res:' .. privatePad) or waiter
m.push('mem', collectgarbage 'count')
while true do
local name, id, params = reqPad:bpop()
local ability = m.ability[name]
-- TODO
if not ability then
resPad:push(m.id, id)
log.error('Brave can not handle this work: ' .. name)
goto CONTINUE
end
local ok, res = xpcall(ability, log.error, params)
if ok then
resPad:push(m.id, id, res)
else
resPad:push(m.id, id)
end
m.push('mem', collectgarbage 'count')
::CONTINUE::
end
end
return m

View File

@@ -0,0 +1,4 @@
local brave = require 'brave.brave'
require 'brave.work'
return brave

View File

@@ -0,0 +1,55 @@
local brave = require 'brave'
local time = require 'bee.time'
local tablePack = table.pack
local tostring = tostring
local tableConcat = table.concat
local debugTraceBack = debug.traceback
local debugGetInfo = debug.getinfo
local monotonic = time.monotonic
_ENV = nil
local function pushLog(level, ...)
local t = tablePack(...)
for i = 1, t.n do
t[i] = tostring(t[i])
end
local str = tableConcat(t, '\t', 1, t.n)
if level == 'error' then
str = str .. '\n' .. debugTraceBack(nil, 3)
end
local info = debugGetInfo(3, 'Sl')
brave.push('log', {
level = level,
msg = str,
src = info.source,
line = info.currentline,
clock = monotonic(),
})
return str
end
local m = {}
function m.info(...)
pushLog('info', ...)
end
function m.debug(...)
pushLog('debug', ...)
end
function m.trace(...)
pushLog('trace', ...)
end
function m.warn(...)
pushLog('warn', ...)
end
function m.error(...)
pushLog('error', ...)
end
return m

Some files were not shown because too many files have changed in this diff Show More