Browse Source

Merge branch 'master' into strconv_docs

Jon Lipstate 2 năm trước cách đây
mục cha
commit
41ff7a6010
74 tập tin đã thay đổi với 10816 bổ sung420 xóa
  1. 7 0
      .github/workflows/ci.yml
  2. 2 0
      core/crypto/util/util.odin
  3. 2 1
      core/encoding/json/tokenizer.odin
  4. 5 4
      core/strings/ascii_set.odin
  5. 133 91
      core/strings/builder.odin
  6. 58 38
      core/strings/conversion.odin
  7. 11 8
      core/strings/intern.odin
  8. 34 27
      core/strings/reader.odin
  9. 187 129
      core/strings/strings.odin
  10. 2 2
      core/sys/windows/advapi32.odin
  11. 81 1
      core/sys/windows/kernel32.odin
  12. 25 31
      core/sys/windows/types.odin
  13. 2 2
      core/sys/windows/util.odin
  14. 161 0
      core/sys/windows/winmm.odin
  15. 94 3
      core/sys/windows/ws2_32.odin
  16. 100 0
      core/text/table/doc.odin
  17. 384 0
      core/text/table/table.odin
  18. 13 0
      core/text/table/utility.odin
  19. 14 5
      examples/all/all_vendor.odin
  20. 56 0
      misc/remove_libraries_for_other_platforms.sh
  21. 16 0
      src/build_settings.cpp
  22. 5 5
      src/error.cpp
  23. 31 5
      src/main.cpp
  24. 5 3
      src/parser.cpp
  25. 19 24
      tests/core/build.bat
  26. 7 0
      tests/core/compress/test_core_compress.odin
  27. 13 0
      tests/documentation/build.bat
  28. 421 0
      tests/documentation/documentation_tester.odin
  29. 1 1
      tests/internal/build.bat
  30. 4 9
      tests/issues/run.bat
  31. 2 2
      tests/vendor/build.bat
  32. 174 0
      vendor/lua/5.1/include/lauxlib.h
  33. 388 0
      vendor/lua/5.1/include/lua.h
  34. 9 0
      vendor/lua/5.1/include/lua.hpp
  35. 766 0
      vendor/lua/5.1/include/luaconf.h
  36. 53 0
      vendor/lua/5.1/include/lualib.h
  37. BIN
      vendor/lua/5.1/linux/liblua5.1.a
  38. BIN
      vendor/lua/5.1/linux/liblua5.1.so
  39. 659 0
      vendor/lua/5.1/lua.odin
  40. BIN
      vendor/lua/5.1/windows/lua5.1.dll
  41. BIN
      vendor/lua/5.1/windows/lua5.1.dll.lib
  42. 212 0
      vendor/lua/5.2/include/lauxlib.h
  43. 444 0
      vendor/lua/5.2/include/lua.h
  44. 9 0
      vendor/lua/5.2/include/lua.hpp
  45. 553 0
      vendor/lua/5.2/include/luaconf.h
  46. 55 0
      vendor/lua/5.2/include/lualib.h
  47. BIN
      vendor/lua/5.2/linux/liblua52.a
  48. BIN
      vendor/lua/5.2/linux/liblua52.so
  49. 728 0
      vendor/lua/5.2/lua.odin
  50. BIN
      vendor/lua/5.2/windows/lua52.dll
  51. BIN
      vendor/lua/5.2/windows/lua52dll.lib
  52. 264 0
      vendor/lua/5.3/include/lauxlib.h
  53. 485 0
      vendor/lua/5.3/include/lua.h
  54. 9 0
      vendor/lua/5.3/include/lua.hpp
  55. 792 0
      vendor/lua/5.3/include/luaconf.h
  56. 61 0
      vendor/lua/5.3/include/lualib.h
  57. BIN
      vendor/lua/5.3/linux/liblua53.a
  58. BIN
      vendor/lua/5.3/linux/liblua53.so
  59. 759 0
      vendor/lua/5.3/lua.odin
  60. BIN
      vendor/lua/5.3/windows/lua53.dll
  61. BIN
      vendor/lua/5.3/windows/lua53dll.lib
  62. 276 0
      vendor/lua/5.4/include/lauxlib.h
  63. 517 0
      vendor/lua/5.4/include/lua.h
  64. 9 0
      vendor/lua/5.4/include/lua.hpp
  65. 763 0
      vendor/lua/5.4/include/luaconf.h
  66. 58 0
      vendor/lua/5.4/include/lualib.h
  67. BIN
      vendor/lua/5.4/linux/liblua54.a
  68. BIN
      vendor/lua/5.4/linux/liblua54.so
  69. 826 0
      vendor/lua/5.4/lua.odin
  70. BIN
      vendor/lua/5.4/windows/lua54.dll
  71. BIN
      vendor/lua/5.4/windows/lua54dll.lib
  72. 6 0
      vendor/lua/LICENSE
  73. 12 0
      vendor/lua/README.md
  74. 34 29
      vendor/zlib/zlib.odin

+ 7 - 0
.github/workflows/ci.yml

@@ -163,6 +163,13 @@ jobs:
           cd tests\internal
           call build.bat
         timeout-minutes: 10
+      - name: Odin documentation tests
+        shell: cmd
+        run: |
+          call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat
+          cd tests\documentation
+          call build.bat
+        timeout-minutes: 10
       - name: core:math/big tests
         shell: cmd
         run: |

+ 2 - 0
core/crypto/util/util.odin

@@ -11,6 +11,8 @@ package util
 */
 
 import "core:mem"
+// Keep vet happy
+_ :: mem
 
 // @note(bp): this can replace the other two
 cast_slice :: #force_inline proc "contextless" ($D: typeid/[]$DE, src: $S/[]$SE) -> D {

+ 2 - 1
core/encoding/json/tokenizer.odin

@@ -163,8 +163,9 @@ get_token :: proc(t: ^Tokenizer) -> (token: Token, err: Error) {
 
 	skip_alphanum :: proc(t: ^Tokenizer) {
 		for t.offset < len(t.data) {
-			switch next_rune(t) {
+			switch t.r {
 			case 'A'..='Z', 'a'..='z', '0'..='9', '_':
+				next_rune(t)
 				continue
 			}
 

+ 5 - 4
core/strings/ascii_set.odin

@@ -12,10 +12,10 @@ Ascii_Set :: distinct [8]u32
 /*
 Creates an Ascii_Set with unique characters from the input string.
 
-**Inputs**  
+Inputs:
 - chars: A string containing characters to include in the Ascii_Set.
 
-**Returns**  
+Returns:
 - as: An Ascii_Set with unique characters from the input string.
 - ok: false if any character in the input string is not a valid ASCII character.
 */
@@ -33,11 +33,12 @@ ascii_set_make :: proc(chars: string) -> (as: Ascii_Set, ok: bool) #no_bounds_ch
 /*
 Determines if a given char is contained within an Ascii_Set.
 
-**Inputs**  
+Inputs:
 - as: The Ascii_Set to search.
 - c: The char to check for in the Ascii_Set.
 
-**Returns**  A boolean indicating if the byte is contained in the Ascii_Set (true) or not (false).
+Returns:
+A boolean indicating if the byte is contained in the Ascii_Set (true) or not (false).
 */
 ascii_set_contains :: proc(as: Ascii_Set, c: byte) -> bool #no_bounds_check {
 	return as[c>>5] & (1<<(c&31)) != 0

+ 133 - 91
core/strings/builder.odin

@@ -7,10 +7,11 @@ import "core:io"
 /*
 Type definition for a procedure that flushes a Builder
 
-**Inputs**  
+Inputs:
 - b: A pointer to the Builder
 
-**Returns**  A boolean indicating whether the Builder should be reset
+Returns:
+A boolean indicating whether the Builder should be reset
 */
 Builder_Flush_Proc :: #type proc(b: ^Builder) -> (do_reset: bool)
 /*
@@ -26,10 +27,11 @@ Produces a Builder with a default length of 0 and cap of 16
 
 *Allocates Using Provided Allocator*
 
-**Inputs**  
+Inputs:
 - allocator: (default is context.allocator)
 
-**Returns**  A new Builder
+Returns:
+A new Builder
 */
 builder_make_none :: proc(allocator := context.allocator) -> Builder {
 	return Builder{buf=make([dynamic]byte, allocator)}
@@ -39,11 +41,12 @@ Produces a Builder with a specified length and cap of max(16,len) byte buffer
 
 *Allocates Using Provided Allocator*
 
-**Inputs**  
+Inputs:
 - len: The desired length of the Builder's buffer
 - allocator: (default is context.allocator)
 
-**Returns**  A new Builder
+Returns:
+A new Builder
 */
 builder_make_len :: proc(len: int, allocator := context.allocator) -> Builder {
 	return Builder{buf=make([dynamic]byte, len, allocator)}
@@ -53,12 +56,13 @@ Produces a Builder with a specified length and cap
 
 *Allocates Using Provided Allocator*
 
-**Inputs**  
+Inputs:
 - len: The desired length of the Builder's buffer
 - cap: The desired capacity of the Builder's buffer, cap is max(cap, len)
 - allocator: (default is context.allocator)
 
-**Returns**  A new Builder
+Returns:
+A new Builder
 */
 builder_make_len_cap :: proc(len, cap: int, allocator := context.allocator) -> Builder {
 	return Builder{buf=make([dynamic]byte, len, cap, allocator)}
@@ -75,11 +79,12 @@ It replaces the existing `buf`
 
 *Allocates Using Provided Allocator*
 
-**Inputs**  
+Inputs:
 - b: A pointer to the Builder
 - allocator: (default is context.allocator)
 
-**Returns**  initialized ^Builder
+Returns:
+initialized ^Builder
 */
 builder_init_none :: proc(b: ^Builder, allocator := context.allocator) -> ^Builder {
 	b.buf = make([dynamic]byte, allocator)
@@ -91,12 +96,13 @@ It replaces the existing `buf`
 
 *Allocates Using Provided Allocator*
 
-**Inputs**  
+Inputs:
 - b: A pointer to the Builder
 - len: The desired length of the Builder's buffer
 - allocator: (default is context.allocator)
 
-**Returns**  Initialized ^Builder
+Returns:
+Initialized ^Builder
 */
 builder_init_len :: proc(b: ^Builder, len: int, allocator := context.allocator) -> ^Builder {
 	b.buf = make([dynamic]byte, len, allocator)
@@ -106,13 +112,14 @@ builder_init_len :: proc(b: ^Builder, len: int, allocator := context.allocator)
 Initializes a Builder with a specified length and cap
 It replaces the existing `buf`
 
-**Inputs**  
+Inputs:
 - b: A pointer to the Builder
 - len: The desired length of the Builder's buffer
 - cap: The desired capacity of the Builder's buffer, actual max(len,cap)
 - allocator: (default is context.allocator)
 
-**Returns**  A pointer to the initialized Builder
+Returns:
+A pointer to the initialized Builder
 */
 builder_init_len_cap :: proc(b: ^Builder, len, cap: int, allocator := context.allocator) -> ^Builder {
 	b.buf = make([dynamic]byte, len, cap, allocator)
@@ -158,10 +165,11 @@ _builder_stream_vtable := &_builder_stream_vtable_obj
 /*
 Returns an io.Stream from a Builder
 
-**Inputs**  
+Inputs:
 - b: A pointer to the Builder
 
-**Returns**  An io.Stream
+Returns:
+An io.Stream
 */
 to_stream :: proc(b: ^Builder) -> io.Stream {
 	return io.Stream{stream_vtable=_builder_stream_vtable, stream_data=b}
@@ -169,10 +177,11 @@ to_stream :: proc(b: ^Builder) -> io.Stream {
 /*
 Returns an io.Writer from a Builder
 
-**Inputs**  
+Inputs:
 - b: A pointer to the Builder
 
-**Returns**   An io.Writer
+Returns: 
+An io.Writer
 */
 to_writer :: proc(b: ^Builder) -> io.Writer {
 	return io.to_writer(to_stream(b))
@@ -180,7 +189,7 @@ to_writer :: proc(b: ^Builder) -> io.Writer {
 /*
 Deletes the Builder byte buffer content
 
-**Inputs**  
+Inputs:
 - b: A pointer to the Builder
 */
 builder_destroy :: proc(b: ^Builder) {
@@ -190,7 +199,7 @@ builder_destroy :: proc(b: ^Builder) {
 /*
 Reserves the Builder byte buffer to a specific capacity, when it's higher than before
 
-**Inputs**  
+Inputs:
 - b: A pointer to the Builder
 - cap: The desired capacity for the Builder's buffer
 */
@@ -200,7 +209,7 @@ builder_grow :: proc(b: ^Builder, cap: int) {
 /*
 Clears the Builder byte buffer content (sets len to zero)
 
-**Inputs**  
+Inputs:
 - b: A pointer to the Builder
 */
 builder_reset :: proc(b: ^Builder) {
@@ -211,18 +220,23 @@ Creates a Builder from a slice of bytes with the same slice length as its capaci
 
 *Uses Nil Allocator - Does NOT allocate*
 
-**Inputs**  
+Inputs:
 - backing: A slice of bytes to be used as the backing buffer
 
+Returns:
+A new Builder
+
 Example:
 
 	import "core:fmt"
 	import "core:strings"
-	strings_builder_from_bytes_example :: proc() {
+	builder_from_bytes_example :: proc() {
 		bytes: [8]byte // <-- gets filled
 		builder := strings.builder_from_bytes(bytes[:])
-		fmt.println(strings.write_byte(&builder, 'a')) // -> "a"
-		fmt.println(strings.write_byte(&builder, 'b')) // -> "ab"
+		strings.write_byte(&builder, 'a')
+		fmt.println(strings.to_string(builder)) // -> "a"
+		strings.write_byte(&builder, 'b')
+		fmt.println(strings.to_string(builder)) // -> "ab"
 	}
 
 Output:
@@ -230,7 +244,6 @@ Output:
 	a
 	ab
 
-**Returns**  A new Builder
 */
 builder_from_bytes :: proc(backing: []byte) -> Builder {
 	s := transmute(runtime.Raw_Slice)backing
@@ -249,10 +262,11 @@ builder_from_slice :: builder_from_bytes
 /*
 Casts the Builder byte buffer to a string and returns it
 
-**Inputs**  
+Inputs:
 - b: A Builder
 
-**Returns**  The contents of the Builder's buffer, as a string
+Returns:
+The contents of the Builder's buffer, as a string
 */
 to_string :: proc(b: Builder) -> string {
 	return string(b.buf[:])
@@ -260,10 +274,11 @@ to_string :: proc(b: Builder) -> string {
 /*
 Returns the length of the Builder's buffer, in bytes
 
-**Inputs**  
+Inputs:
 - b: A Builder
 
-**Returns**  The length of the Builder's buffer
+Returns:
+The length of the Builder's buffer
 */
 builder_len :: proc(b: Builder) -> int {
 	return len(b.buf)
@@ -271,10 +286,11 @@ builder_len :: proc(b: Builder) -> int {
 /*
 Returns the capacity of the Builder's buffer, in bytes
 
-**Inputs**  
+Inputs:
 - b: A Builder
 
-**Returns**  The capacity of the Builder's buffer
+Returns:
+The capacity of the Builder's buffer
 */
 builder_cap :: proc(b: Builder) -> int {
 	return cap(b.buf)
@@ -282,10 +298,11 @@ builder_cap :: proc(b: Builder) -> int {
 /*
 The free space left in the Builder's buffer, in bytes
 
-**Inputs**  
+Inputs:
 - b: A Builder
 
-**Returns**  The available space left in the Builder's buffer
+Returns:
+The available space left in the Builder's buffer
 */
 builder_space :: proc(b: Builder) -> int {
 	return cap(b.buf) - len(b.buf)
@@ -293,16 +310,21 @@ builder_space :: proc(b: Builder) -> int {
 /*
 Appends a byte to the Builder and returns the number of bytes appended
 
-**Inputs**  
+Inputs:
 - b: A pointer to the Builder
 - x: The byte to be appended
 
+Returns:
+The number of bytes appended
+
+NOTE: The backing dynamic array may be fixed in capacity or fail to resize, `n` states the number actually written.
+
 Example:
 
 	import "core:fmt"
 	import "core:strings"
 
-	strings_write_byte_example :: proc() {
+	write_byte_example :: proc() {
 		builder := strings.builder_make()
 		strings.write_byte(&builder, 'a')        // 1
 		strings.write_byte(&builder, 'b')        // 1
@@ -313,9 +335,6 @@ Output:
 
 	ab
 
-NOTE: The backing dynamic array may be fixed in capacity or fail to resize, `n` states the number actually written.
-
-**Returns**  The number of bytes appended
 */
 write_byte :: proc(b: ^Builder, x: byte) -> (n: int) {
 	n0 := len(b.buf)
@@ -326,7 +345,7 @@ write_byte :: proc(b: ^Builder, x: byte) -> (n: int) {
 /*
 Appends a slice of bytes to the Builder and returns the number of bytes appended
 
-**Inputs**  
+Inputs:
 - b: A pointer to the Builder
 - x: The slice of bytes to be appended
 
@@ -335,7 +354,7 @@ Example:
 	import "core:fmt"
 	import "core:strings"
 
-	strings_write_bytes_example :: proc() {
+	write_bytes_example :: proc() {
 		builder := strings.builder_make()
 		bytes := [?]byte { 'a', 'b', 'c' }
 		strings.write_bytes(&builder, bytes[:]) // 3
@@ -344,7 +363,8 @@ Example:
 
 NOTE: The backing dynamic array may be fixed in capacity or fail to resize, `n` states the number actually written.
 
-**Returns**  The number of bytes appended
+Returns:
+The number of bytes appended
 */
 write_bytes :: proc(b: ^Builder, x: []byte) -> (n: int) {
 	n0 := len(b.buf)
@@ -355,16 +375,21 @@ write_bytes :: proc(b: ^Builder, x: []byte) -> (n: int) {
 /*
 Appends a single rune to the Builder and returns the number of bytes written and an `io.Error`
 
-**Inputs**  
+Inputs:
 - b: A pointer to the Builder
 - r: The rune to be appended
 
+Returns:
+The number of bytes written and an io.Error (if any)
+
+NOTE: The backing dynamic array may be fixed in capacity or fail to resize, `n` states the number actually written.
+
 Example:
 
 	import "core:fmt"
 	import "core:strings"
 
-	strings_write_rune_example :: proc() {
+	write_rune_example :: proc() {
 		builder := strings.builder_make()
 		strings.write_rune(&builder, 'ä')     // 2 None
 		strings.write_rune(&builder, 'b')       // 1 None
@@ -375,9 +400,6 @@ Output:
 
 	äb
 
-NOTE: The backing dynamic array may be fixed in capacity or fail to resize, `n` states the number actually written.
-
-**Returns**  The number of bytes written and an io.Error (if any)
 */
 write_rune :: proc(b: ^Builder, r: rune) -> (int, io.Error) {
 	return io.write_rune(to_writer(b), r)
@@ -385,16 +407,21 @@ write_rune :: proc(b: ^Builder, r: rune) -> (int, io.Error) {
 /*
 Appends a quoted rune to the Builder and returns the number of bytes written
 
-**Inputs**  
+Inputs:
 - b: A pointer to the Builder
 - r: The rune to be appended
 
+Returns:
+The number of bytes written
+
+NOTE: The backing dynamic array may be fixed in capacity or fail to resize, `n` states the number actually written.
+
 Example:
 
 	import "core:fmt"
 	import "core:strings"
 
-	strings_write_quoted_rune_example :: proc() {
+	write_quoted_rune_example :: proc() {
 		builder := strings.builder_make()
 		strings.write_string(&builder, "abc")      // 3
 		strings.write_quoted_rune(&builder, 'ä') // 4
@@ -406,9 +433,6 @@ Output:
 
 	abc'ä'abc
 
-NOTE: The backing dynamic array may be fixed in capacity or fail to resize, `n` states the number actually written.
-
-**Returns**  The number of bytes written
 */
 write_quoted_rune :: proc(b: ^Builder, r: rune) -> (n: int) {
 	return io.write_quoted_rune(to_writer(b), r)
@@ -416,16 +440,21 @@ write_quoted_rune :: proc(b: ^Builder, r: rune) -> (n: int) {
 /*
 Appends a string to the Builder and returns the number of bytes written
 
-**Inputs**  
+Inputs:
 - b: A pointer to the Builder
 - s: The string to be appended
 
+Returns:
+The number of bytes written
+
+NOTE: The backing dynamic array may be fixed in capacity or fail to resize, `n` states the number actually written.
+
 Example:
 
 	import "core:fmt"
 	import "core:strings"
 
-	strings_write_string_example :: proc() {
+	write_string_example :: proc() {
 		builder := strings.builder_make()
 		strings.write_string(&builder, "a")     // 1
 		strings.write_string(&builder, "bc")    // 2
@@ -436,9 +465,6 @@ Output:
 
 	abc
 
-NOTE: The backing dynamic array may be fixed in capacity or fail to resize, `n` states the number actually written.
-
-**Returns**  The number of bytes written
 */
 write_string :: proc(b: ^Builder, s: string) -> (n: int) {
 	n0 := len(b.buf)
@@ -449,10 +475,11 @@ write_string :: proc(b: ^Builder, s: string) -> (n: int) {
 /*
 Pops and returns the last byte in the Builder or 0 when the Builder is empty
 
-**Inputs**  
+Inputs:
 - b: A pointer to the Builder
 
-**Returns**  The last byte in the Builder or 0 if empty
+Returns:
+The last byte in the Builder or 0 if empty
 */
 pop_byte :: proc(b: ^Builder) -> (r: byte) {
 	if len(b.buf) == 0 {
@@ -467,10 +494,11 @@ pop_byte :: proc(b: ^Builder) -> (r: byte) {
 /*
 Pops the last rune in the Builder and returns the popped rune and its rune width or (0, 0) if empty
 
-**Inputs**  
+Inputs:
 - b: A pointer to the Builder
 
-**Returns**  The popped rune and its rune width or (0, 0) if empty
+Returns:
+The popped rune and its rune width or (0, 0) if empty
 */
 pop_rune :: proc(b: ^Builder) -> (r: rune, width: int) {
 	if len(b.buf) == 0 {
@@ -485,17 +513,22 @@ pop_rune :: proc(b: ^Builder) -> (r: rune, width: int) {
 @(private)
 DIGITS_LOWER := "0123456789abcdefx"
 /*
-**Inputs**  
+Inputs:
 - b: A pointer to the Builder
 - str: The string to be quoted and appended
 - quote: The optional quote character (default is double quotes)
 
+Returns:
+The number of bytes written
+
+NOTE: The backing dynamic array may be fixed in capacity or fail to resize, `n` states the number actually written.
+
 Example:
 
 	import "core:fmt"
 	import "core:strings"
 
-	strings_write_quoted_string_example :: proc() {
+	write_quoted_string_example :: proc() {
 		builder := strings.builder_make()
 		strings.write_quoted_string(&builder, "a")        // 3
 		strings.write_quoted_string(&builder, "bc", '\'') // 4
@@ -507,9 +540,6 @@ Output:
 
 	"a"'bc'"xyz"
 
-NOTE: The backing dynamic array may be fixed in capacity or fail to resize, `n` states the number actually written.
-
-**Returns**  The number of bytes written
 */
 write_quoted_string :: proc(b: ^Builder, str: string, quote: byte = '"') -> (n: int) {
 	n, _ = io.write_quoted_string(to_writer(b), str, quote)
@@ -518,11 +548,16 @@ write_quoted_string :: proc(b: ^Builder, str: string, quote: byte = '"') -> (n:
 /*
 Appends a rune to the Builder and returns the number of bytes written
 
-**Inputs**  
+Inputs:
 - b: A pointer to the Builder
 - r: The rune to be appended
 - write_quote: Optional boolean flag to wrap in single-quotes (') (default is true)
 
+Returns:
+The number of bytes written
+
+NOTE: The backing dynamic array may be fixed in capacity or fail to resize, `n` states the number actually written.
+
 Example:
 
 	import "core:fmt"
@@ -540,9 +575,6 @@ Output:
 
 	a'"'x
 
-NOTE: The backing dynamic array may be fixed in capacity or fail to resize, `n` states the number actually written.
-
-**Returns**  The number of bytes written
 */
 write_encoded_rune :: proc(b: ^Builder, r: rune, write_quote := true) -> (n: int) {
 	n, _ = io.write_encoded_rune(to_writer(b), r, write_quote)
@@ -552,7 +584,7 @@ write_encoded_rune :: proc(b: ^Builder, r: rune, write_quote := true) -> (n: int
 /*
 Appends an escaped rune to the Builder and returns the number of bytes written
 
-**Inputs**  
+Inputs:
 - b: A pointer to the Builder
 - r: The rune to be appended
 - quote: The quote character
@@ -565,7 +597,8 @@ Appends an escaped rune to the Builder and returns the number of bytes written
 
 NOTE: The backing dynamic array may be fixed in capacity or fail to resize, `n` states the number actually written.
 
-**Returns**  The number of bytes written
+Returns:
+The number of bytes written
 */
 write_escaped_rune :: proc(b: ^Builder, r: rune, quote: byte, html_safe := false) -> (n: int) {
 	n, _ = io.write_escaped_rune(to_writer(b), r, quote, html_safe)
@@ -574,7 +607,7 @@ write_escaped_rune :: proc(b: ^Builder, r: rune, quote: byte, html_safe := false
 /*
 Writes a f64 value to the Builder and returns the number of characters written
 
-**Inputs**  
+Inputs:
 - b: A pointer to the Builder
 - f: The f64 value to be appended
 - fmt: The format byte
@@ -584,7 +617,8 @@ Writes a f64 value to the Builder and returns the number of characters written
 
 NOTE: The backing dynamic array may be fixed in capacity or fail to resize, `n` states the number actually written.
 
-**Returns**  The number of characters written
+Returns:
+The number of characters written
 */
 write_float :: proc(b: ^Builder, f: f64, fmt: byte, prec, bit_size: int, always_signed := false) -> (n: int) {
 	buf: [384]byte
@@ -599,7 +633,7 @@ write_float :: proc(b: ^Builder, f: f64, fmt: byte, prec, bit_size: int, always_
 /*
 Writes a f16 value to the Builder and returns the number of characters written
 
-**Inputs**  
+Inputs:
 - b: A pointer to the Builder
 - f: The f16 value to be appended
 - fmt: The format byte
@@ -607,7 +641,8 @@ Writes a f16 value to the Builder and returns the number of characters written
 
 NOTE: The backing dynamic array may be fixed in capacity or fail to resize, `n` states the number actually written.
 
-**Returns**  The number of characters written
+Returns:
+The number of characters written
 */
 write_f16 :: proc(b: ^Builder, f: f16, fmt: byte, always_signed := false) -> (n: int) {
 	buf: [384]byte
@@ -620,18 +655,23 @@ write_f16 :: proc(b: ^Builder, f: f16, fmt: byte, always_signed := false) -> (n:
 /*
 Writes a f32 value to the Builder and returns the number of characters written
 
-**Inputs**  
+Inputs:
 - b: A pointer to the Builder
 - f: The f32 value to be appended
 - fmt: The format byte
 - always_signed: Optional boolean flag to always include the sign
 
+Returns:
+The number of characters written
+
+NOTE: The backing dynamic array may be fixed in capacity or fail to resize, `n` states the number actually written.
+
 Example:
 
 	import "core:fmt"
 	import "core:strings"
 
-	strings_write_f32_example :: proc() {
+	write_f32_example :: proc() {
 		builder := strings.builder_make()
 		strings.write_f32(&builder, 3.14159, 'f') // 6
 		strings.write_string(&builder, " - ")     // 3
@@ -643,9 +683,6 @@ Output:
 
 	3.14159012 - -1.23000003e-01
 
-NOTE: The backing dynamic array may be fixed in capacity or fail to resize, `n` states the number actually written.
-
-**Returns**  The number of characters written
 */
 write_f32 :: proc(b: ^Builder, f: f32, fmt: byte, always_signed := false) -> (n: int) {
 	buf: [384]byte
@@ -658,7 +695,7 @@ write_f32 :: proc(b: ^Builder, f: f32, fmt: byte, always_signed := false) -> (n:
 /*
 Writes a f32 value to the Builder and returns the number of characters written
 
-**Inputs**  
+Inputs:
 - b: A pointer to the Builder
 - f: The f32 value to be appended
 - fmt: The format byte
@@ -666,7 +703,8 @@ Writes a f32 value to the Builder and returns the number of characters written
 
 NOTE: The backing dynamic array may be fixed in capacity or fail to resize, `n` states the number actually written.
 
-**Returns**  The number of characters written
+Returns:
+The number of characters written
 */
 write_f64 :: proc(b: ^Builder, f: f64, fmt: byte, always_signed := false) -> (n: int) {
 	buf: [384]byte
@@ -679,14 +717,15 @@ write_f64 :: proc(b: ^Builder, f: f64, fmt: byte, always_signed := false) -> (n:
 /*
 Writes a u64 value to the Builder and returns the number of characters written
 
-**Inputs**  
+Inputs:
 - b: A pointer to the Builder
 - i: The u64 value to be appended
 - base: The optional base for the numeric representation
 
 NOTE: The backing dynamic array may be fixed in capacity or fail to resize, `n` states the number actually written.
 
-**Returns**  The number of characters written
+Returns:
+The number of characters written
 */
 write_u64 :: proc(b: ^Builder, i: u64, base: int = 10) -> (n: int) {
 	buf: [32]byte
@@ -696,14 +735,15 @@ write_u64 :: proc(b: ^Builder, i: u64, base: int = 10) -> (n: int) {
 /*
 Writes a i64 value to the Builder and returns the number of characters written
 
-**Inputs**  
+Inputs:
 - b: A pointer to the Builder
 - i: The i64 value to be appended
 - base: The optional base for the numeric representation
 
 NOTE: The backing dynamic array may be fixed in capacity or fail to resize, `n` states the number actually written.
 
-**Returns**  The number of characters written
+Returns:
+The number of characters written
 */
 write_i64 :: proc(b: ^Builder, i: i64, base: int = 10) -> (n: int) {
 	buf: [32]byte
@@ -713,14 +753,15 @@ write_i64 :: proc(b: ^Builder, i: i64, base: int = 10) -> (n: int) {
 /*
 Writes a uint value to the Builder and returns the number of characters written
 
-**Inputs**  
+Inputs:
 - b: A pointer to the Builder
 - i: The uint value to be appended
 - base: The optional base for the numeric representation
 
 NOTE: The backing dynamic array may be fixed in capacity or fail to resize, `n` states the number actually written.
 
-**Returns**  The number of characters written
+Returns:
+The number of characters written
 */
 write_uint :: proc(b: ^Builder, i: uint, base: int = 10) -> (n: int) {
 	return write_u64(b, u64(i), base)
@@ -728,14 +769,15 @@ write_uint :: proc(b: ^Builder, i: uint, base: int = 10) -> (n: int) {
 /*
 Writes a int value to the Builder and returns the number of characters written
 
-**Inputs**  
+Inputs:
 - b: A pointer to the Builder
 - i: The int value to be appended
 - base: The optional base for the numeric representation
 
 NOTE: The backing dynamic array may be fixed in capacity or fail to resize, `n` states the number actually written.
 
-**Returns**  The number of characters written
+Returns:
+The number of characters written
 */
 write_int :: proc(b: ^Builder, i: int, base: int = 10) -> (n: int) {
 	return write_i64(b, i64(i), base)

+ 58 - 38
core/strings/conversion.odin

@@ -9,14 +9,15 @@ Converts invalid UTF-8 sequences in the input string `s` to the `replacement` st
 
 *Allocates Using Provided Allocator*
 
-**Inputs**  
+Inputs:
 - s: Input string that may contain invalid UTF-8 sequences.
 - replacement: String to replace invalid UTF-8 sequences with.
 - allocator: (default: context.allocator).
 
 WARNING: Allocation does not occur when len(s) == 0
 
-**Returns**  A valid UTF-8 string with invalid sequences replaced by `replacement`.
+Returns:
+A valid UTF-8 string with invalid sequences replaced by `replacement`.
 */
 to_valid_utf8 :: proc(s, replacement: string, allocator := context.allocator) -> string {
 	if len(s) == 0 {
@@ -76,16 +77,19 @@ Converts the input string `s` to all lowercase characters.
 
 *Allocates Using Provided Allocator*
 
-**Inputs**  
+Inputs:
 - s: Input string to be converted.
 - allocator: (default: context.allocator).
 
+Returns:
+A new string with all characters converted to lowercase.
+
 Example:
 
 	import "core:fmt"
 	import "core:strings"
 
-	strings_to_lower_example :: proc() {
+	to_lower_example :: proc() {
 		fmt.println(strings.to_lower("TeST"))
 	}
 
@@ -93,7 +97,6 @@ Output:
 
 	test
 
-**Returns**  A new string with all characters converted to lowercase.
 */
 to_lower :: proc(s: string, allocator := context.allocator) -> string {
 	b: Builder
@@ -108,16 +111,19 @@ Converts the input string `s` to all uppercase characters.
 
 *Allocates Using Provided Allocator*
 
-**Inputs**  
+Inputs:
 - s: Input string to be converted.
 - allocator: (default: context.allocator).
 
+Returns:
+A new string with all characters converted to uppercase.
+
 Example:
 
 	import "core:fmt"
 	import "core:strings"
 
-	strings_to_upper_example :: proc() {
+	to_upper_example :: proc() {
 		fmt.println(strings.to_upper("Test"))
 	}
 
@@ -125,7 +131,6 @@ Output:
 
 	TEST
 
-**Returns**  A new string with all characters converted to uppercase.
 */
 to_upper :: proc(s: string, allocator := context.allocator) -> string {
 	b: Builder
@@ -138,10 +143,11 @@ to_upper :: proc(s: string, allocator := context.allocator) -> string {
 /*
 Checks if the rune `r` is a delimiter (' ', '-', or '_').
 
-**Inputs**  
+Inputs:
 - r: Rune to check for delimiter status.
 
-**Returns**  True if `r` is a delimiter, false otherwise.
+Returns:
+True if `r` is a delimiter, false otherwise.
 */
 is_delimiter :: proc(r: rune) -> bool {
 	return r == '-' || r == '_' || is_space(r)
@@ -149,10 +155,11 @@ is_delimiter :: proc(r: rune) -> bool {
 /*
 Checks if the rune `r` is a non-alphanumeric or space character.
 
-**Inputs**  
+Inputs:
 - r: Rune to check for separator status.
 
-**Returns**  True if `r` is a non-alpha or `unicode.is_space` rune.
+Returns:
+True if `r` is a non-alpha or `unicode.is_space` rune.
 */
 is_separator :: proc(r: rune) -> bool {
 	if r <= 0x7f {
@@ -179,7 +186,7 @@ is_separator :: proc(r: rune) -> bool {
 /*
 Iterates over a string, calling a callback for each rune with the previous, current, and next runes as arguments.
 
-**Inputs**  
+Inputs:
 - w: An io.Writer to be used by the callback for writing output.
 - s: The input string to be iterated over.
 - callback: A procedure to be called for each rune in the string, with arguments (w: io.Writer, prev, curr, next: rune).
@@ -191,7 +198,7 @@ Example:
 	import "core:strings"
 	import "core:io"
 
-	strings_string_case_iterator_example :: proc() {
+	string_case_iterator_example :: proc() {
 		my_callback :: proc(w: io.Writer, prev, curr, next: rune) {
 			fmt.println("my_callback", curr) // <-- Custom logic here
 		}
@@ -241,11 +248,12 @@ Converts the input string `s` to "lowerCamelCase".
 
 *Allocates Using Provided Allocator*
 
-**Inputs**  
+Inputs:
 - s: Input string to be converted.
 - allocator: (default: context.allocator).
 
-**Returns**  A "lowerCamelCase" formatted string.
+Returns:
+A "lowerCamelCase" formatted string.
 */
 to_camel_case :: proc(s: string, allocator := context.allocator) -> string {
 	s := s
@@ -275,11 +283,12 @@ Converts the input string `s` to "UpperCamelCase" (PascalCase).
 
 *Allocates Using Provided Allocator*
 
-**Inputs**  
+Inputs:
 - s: Input string to be converted.
 - allocator: (default: context.allocator).
 
-**Returns**  A "PascalCase" formatted string.
+Returns:
+A "PascalCase" formatted string.
 */
 to_pascal_case :: proc(s: string, allocator := context.allocator) -> string {
 	s := s
@@ -307,18 +316,21 @@ Returns a string converted to a delimiter-separated case with configurable casin
 
 *Allocates Using Provided Allocator*
 
-**Inputs**  
+Inputs:
 - s: The input string to be converted
 - delimiter: The rune to be used as the delimiter between words
 - all_upper_case: A boolean indicating if the output should be all uppercased (true) or lowercased (false)
 - allocator: (default: context.allocator).
 
+Returns:
+The converted string
+
 Example:
 
 	import "core:fmt"
 	import "core:strings"
 
-	strings_to_delimiter_case_example :: proc() {
+	to_delimiter_case_example :: proc() {
 		fmt.println(strings.to_delimiter_case("Hello World", '_', false))
 		fmt.println(strings.to_delimiter_case("Hello World", ' ', true))
 		fmt.println(strings.to_delimiter_case("aBC", '_', false))
@@ -328,9 +340,8 @@ Output:
 
 	hello_world
 	HELLO WORLD
-	a_b_c
+	a_bc
 
-**Returns**  The converted string
 */
 to_delimiter_case :: proc(
 	s: string,
@@ -380,16 +391,19 @@ Converts a string to "snake_case" with all runes lowercased
 
 *Allocates Using Provided Allocator*
 
-**Inputs**  
+Inputs:
 - s: The input string to be converted
 - allocator: (default: context.allocator).
 
+Returns:
+The converted string
+
 Example:
 
 	import "core:fmt"
 	import "core:strings"
 
-	strings_to_snake_case_example :: proc() {
+	to_snake_case_example :: proc() {
 		fmt.println(strings.to_snake_case("HelloWorld"))
 		fmt.println(strings.to_snake_case("Hello World"))
 	}
@@ -399,8 +413,6 @@ Output:
 	hello_world
 	hello_world
 
-```
-**Returns**  The converted string
 */
 to_snake_case :: proc(s: string, allocator := context.allocator) -> string {
 	return to_delimiter_case(s, '_', false, allocator)
@@ -412,16 +424,19 @@ Converts a string to "SNAKE_CASE" with all runes uppercased
 
 *Allocates Using Provided Allocator*
 
-**Inputs**  
+Inputs:
 - s: The input string to be converted
 - allocator: (default: context.allocator).
 
+Returns:
+The converted string
+
 Example:
 
 	import "core:fmt"
 	import "core:strings"
 
-	strings_to_upper_snake_case_example :: proc() {
+	to_upper_snake_case_example :: proc() {
 		fmt.println(strings.to_upper_snake_case("HelloWorld"))
 	}
 
@@ -429,7 +444,6 @@ Output:
 
 	HELLO_WORLD
 
-**Returns**  The converted string
 */
 to_upper_snake_case :: proc(s: string, allocator := context.allocator) -> string {
 	return to_delimiter_case(s, '_', true, allocator)
@@ -439,16 +453,19 @@ Converts a string to "kebab-case" with all runes lowercased
 
 *Allocates Using Provided Allocator*
 
-**Inputs**  
+Inputs:
 - s: The input string to be converted
 - allocator: (default: context.allocator).
 
+Returns:
+The converted string
+
 Example:
 
 	import "core:fmt"
 	import "core:strings"
 
-	strings_to_kebab_case_example :: proc() {
+	to_kebab_case_example :: proc() {
 		fmt.println(strings.to_kebab_case("HelloWorld"))
 	}
 
@@ -456,7 +473,6 @@ Output:
 
 	hello-world
 
-**Returns**  The converted string
 */
 to_kebab_case :: proc(s: string, allocator := context.allocator) -> string {
 	return to_delimiter_case(s, '-', false, allocator)
@@ -466,16 +482,19 @@ Converts a string to "KEBAB-CASE" with all runes uppercased
 
 *Allocates Using Provided Allocator*
 
-**Inputs**  
+Inputs:
 - s: The input string to be converted
 - allocator: (default: context.allocator).
 
+Returns:
+The converted string
+
 Example:
 
 	import "core:fmt"
 	import "core:strings"
 
-	strings_to_upper_kebab_case_example :: proc() {
+	to_upper_kebab_case_example :: proc() {
 		fmt.println(strings.to_upper_kebab_case("HelloWorld"))
 	}
 
@@ -483,7 +502,6 @@ Output:
 
 	HELLO-WORLD
 
-**Returns**  The converted string
 */
 to_upper_kebab_case :: proc(s: string, allocator := context.allocator) -> string {
 	return to_delimiter_case(s, '-', true, allocator)
@@ -493,16 +511,19 @@ Converts a string to "Ada_Case"
 
 *Allocates Using Provided Allocator*
 
-**Inputs**  
+Inputs:
 - s: The input string to be converted
 - allocator: (default: context.allocator).
 
+Returns:
+The converted string
+
 Example:
 
 	import "core:fmt"
 	import "core:strings"
 
-	strings_to_upper_kebab_case_example :: proc() {
+	to_ada_case_example :: proc() {
 		fmt.println(strings.to_ada_case("HelloWorld"))
 	}
 
@@ -510,7 +531,6 @@ Output:
 
 	Hello_World
 
-**Returns**  The converted string
 */
 to_ada_case :: proc(s: string, allocator := context.allocator) -> string {
 	s := s

+ 11 - 8
core/strings/intern.odin

@@ -25,7 +25,7 @@ Initializes the entries map and sets the allocator for the string entries
 
 *Allocates Using Provided Allocators*
 
-**Inputs**  
+Inputs:
 - m: A pointer to the Intern struct to be initialized
 - allocator: The allocator for the Intern_Entry strings (Default: context.allocator)
 - map_allocator: The allocator for the map of entries (Default: context.allocator)
@@ -37,7 +37,7 @@ intern_init :: proc(m: ^Intern, allocator := context.allocator, map_allocator :=
 /*
 Frees the map and all its content allocated using the `.allocator`.
 
-**Inputs**  
+Inputs:
 - m: A pointer to the Intern struct to be destroyed
 */
 intern_destroy :: proc(m: ^Intern) {
@@ -51,13 +51,14 @@ Returns an interned copy of the given text, adding it to the map if not already
 
 *Allocate using the Intern's Allocator (First time string is seen only)*
 
-**Inputs**  
+Inputs:
 - m: A pointer to the Intern struct
 - text: The string to be interned
 
 NOTE: The returned string lives as long as the map entry lives.
 
-**Returns**  The interned string and an allocator error if any
+Returns:
+The interned string and an allocator error if any
 */
 intern_get :: proc(m: ^Intern, text: string) -> (str: string, err: runtime.Allocator_Error) {
 	entry := _intern_get_entry(m, text) or_return
@@ -68,13 +69,14 @@ Returns an interned copy of the given text as a cstring, adding it to the map if
 
 *Allocate using the Intern's Allocator  (First time string is seen only)*
 
-**Inputs**  
+Inputs:
 - m: A pointer to the Intern struct
 - text: The string to be interned
 
 NOTE: The returned cstring lives as long as the map entry lives
 
-**Returns**  The interned cstring and an allocator error if any
+Returns:
+The interned cstring and an allocator error if any
 */
 intern_get_cstring :: proc(m: ^Intern, text: string) -> (str: cstring, err: runtime.Allocator_Error) {
 	entry := _intern_get_entry(m, text) or_return
@@ -86,11 +88,12 @@ Sets and allocates the entry if it wasn't set yet
 
 *Allocate using the Intern's Allocator  (First time string is seen only)*
 
-**Inputs**  
+Inputs:
 - m: A pointer to the Intern struct
 - text: The string to be looked up or interned
 
-**Returns**  The new or existing interned entry and an allocator error if any
+Returns:
+The new or existing interned entry and an allocator error if any
 */
 _intern_get_entry :: proc(m: ^Intern, text: string) -> (new_entry: ^Intern_Entry, err: runtime.Allocator_Error) #no_bounds_check {
 	if prev, ok := m.entries[text]; ok {

+ 34 - 27
core/strings/reader.odin

@@ -16,7 +16,7 @@ Reader :: struct {
 /*
 Initializes a string Reader with the provided string
 
-**Inputs**  
+Inputs:
 - r: A pointer to a Reader struct
 - s: The input string to be read
 */
@@ -28,10 +28,11 @@ reader_init :: proc(r: ^Reader, s: string) {
 /*
 Converts a Reader into an `io.Stream`
 
-**Inputs**  
+Inputs:
 - r: A pointer to a Reader struct
 
-**Returns**  An io.Stream for the given Reader
+Returns:
+An io.Stream for the given Reader
 */
 reader_to_stream :: proc(r: ^Reader) -> (s: io.Stream) {
 	s.stream_data = r
@@ -41,11 +42,12 @@ reader_to_stream :: proc(r: ^Reader) -> (s: io.Stream) {
 /*
 Initializes a string Reader and returns an `io.Reader` for the given string
 
-**Inputs**  
+Inputs:
 - r: A pointer to a Reader struct
 - s: The input string to be read
 
-**Returns**  An io.Reader for the given string
+Returns:
+An io.Reader for the given string
 */
 to_reader :: proc(r: ^Reader, s: string) -> io.Reader {
 	reader_init(r, s)
@@ -55,11 +57,12 @@ to_reader :: proc(r: ^Reader, s: string) -> io.Reader {
 /*
 Initializes a string Reader and returns an `io.Reader_At` for the given string
 
-**Inputs**  
+Inputs:
 - r: A pointer to a Reader struct
 - s: The input string to be read
 
-**Returns**  An `io.Reader_At` for the given string
+Returns:
+An `io.Reader_At` for the given string
 */
 to_reader_at :: proc(r: ^Reader, s: string) -> io.Reader_At {
 	reader_init(r, s)
@@ -69,10 +72,11 @@ to_reader_at :: proc(r: ^Reader, s: string) -> io.Reader_At {
 /*
 Returns the remaining length of the Reader
 
-**Inputs**  
+Inputs:
 - r: A pointer to a Reader struct
 
-**Returns**  The remaining length of the Reader
+Returns:
+The remaining length of the Reader
 */
 reader_length :: proc(r: ^Reader) -> int {
 	if r.i >= i64(len(r.s)) {
@@ -83,10 +87,11 @@ reader_length :: proc(r: ^Reader) -> int {
 /*
 Returns the length of the string stored in the Reader
 
-**Inputs**  
+Inputs:
 - r: A pointer to a Reader struct
 
-**Returns**  The length of the string stored in the Reader
+Returns:
+The length of the string stored in the Reader
 */
 reader_size :: proc(r: ^Reader) -> i64 {
 	return i64(len(r.s))
@@ -94,11 +99,11 @@ reader_size :: proc(r: ^Reader) -> i64 {
 /*
 Reads len(p) bytes from the Reader's string and copies into the provided slice.
 
-**Inputs**  
+Inputs:
 - r: A pointer to a Reader struct
 - p: A byte slice to copy data into
 
-**Returns**  
+Returns:
 - n: The number of bytes read
 - err: An `io.Error` if an error occurs while reading, including `.EOF`, otherwise `nil` denotes success.
 */
@@ -114,12 +119,12 @@ reader_read :: proc(r: ^Reader, p: []byte) -> (n: int, err: io.Error) {
 /*
 Reads len(p) bytes from the Reader's string and copies into the provided slice, at the specified offset from the current index.
 
-**Inputs**  
+Inputs:
 - r: A pointer to a Reader struct
 - p: A byte slice to copy data into
 - off: The offset from which to read
 
-**Returns**  
+Returns:
 - n: The number of bytes read
 - err: An `io.Error` if an error occurs while reading, including `.EOF`, otherwise `nil` denotes success.
 */
@@ -139,10 +144,10 @@ reader_read_at :: proc(r: ^Reader, p: []byte, off: i64) -> (n: int, err: io.Erro
 /*
 Reads and returns a single byte from the Reader's string
 
-**Inputs**  
+Inputs:
 - r: A pointer to a Reader struct
 
-**Returns**  
+Returns:
 - The byte read from the Reader
 - err: An `io.Error` if an error occurs while reading, including `.EOF`, otherwise `nil` denotes success.
 */
@@ -158,10 +163,11 @@ reader_read_byte :: proc(r: ^Reader) -> (byte, io.Error) {
 /*
 Decrements the Reader's index (i) by 1
 
-**Inputs**  
+Inputs:
 - r: A pointer to a Reader struct
 
-**Returns**  An `io.Error` if `r.i <= 0` (`.Invalid_Unread`), otherwise `nil` denotes success.
+Returns:
+An `io.Error` if `r.i <= 0` (`.Invalid_Unread`), otherwise `nil` denotes success.
 */
 reader_unread_byte :: proc(r: ^Reader) -> io.Error {
 	if r.i <= 0 {
@@ -174,10 +180,10 @@ reader_unread_byte :: proc(r: ^Reader) -> io.Error {
 /*
 Reads and returns a single rune and its `size` from the Reader's string
 
-**Inputs**  
+Inputs:
 - r: A pointer to a Reader struct
 
-**Returns**  
+Returns:
 - rr: The rune read from the Reader
 - size: The size of the rune in bytes
 - err: An `io.Error` if an error occurs while reading
@@ -199,12 +205,13 @@ reader_read_rune :: proc(r: ^Reader) -> (rr: rune, size: int, err: io.Error) {
 /*
 Decrements the Reader's index (i) by the size of the last read rune
 
-**Inputs**  
+Inputs:
 - r: A pointer to a Reader struct
 
 WARNING: May only be used once and after a valid `read_rune` call
 
-**Returns**  An `io.Error` if an error occurs while unreading (`.Invalid_Unread`), else `nil` denotes success.
+Returns:
+An `io.Error` if an error occurs while unreading (`.Invalid_Unread`), else `nil` denotes success.
 */
 reader_unread_rune :: proc(r: ^Reader) -> io.Error {
 	if r.i <= 0 {
@@ -220,12 +227,12 @@ reader_unread_rune :: proc(r: ^Reader) -> io.Error {
 /*
 Seeks the Reader's index to a new position
 
-**Inputs**  
+Inputs:
 - r: A pointer to a Reader struct
 - offset: The new offset position
 - whence: The reference point for the new position (`.Start`, `.Current`, or `.End`)
 
-**Returns**  
+Returns:
 - The absolute offset after seeking
 - err: An `io.Error` if an error occurs while seeking (`.Invalid_Whence`, `.Invalid_Offset`)
 */
@@ -252,13 +259,13 @@ reader_seek :: proc(r: ^Reader, offset: i64, whence: io.Seek_From) -> (i64, io.E
 /*
 Writes the remaining content of the Reader's string into the provided `io.Writer`
 
-**Inputs**  
+Inputs:
 - r: A pointer to a Reader struct
 - w: The io.Writer to write the remaining content into
 
 WARNING: Panics if writer writes more bytes than remainig length of string.
 
-**Returns**  
+Returns:
 - n: The number of bytes written
 - err: An io.Error if an error occurs while writing (`.Short_Write`)
 */

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 187 - 129
core/strings/strings.odin


+ 2 - 2
core/sys/windows/advapi32.odin

@@ -52,7 +52,7 @@ foreign advapi32 {
 		dwCreationFlags: DWORD,
 		lpEnvironment: LPVOID,
 		lpCurrentDirectory: wstring,
-		lpStartupInfo: LPSTARTUPINFO,
+		lpStartupInfo: LPSTARTUPINFOW,
 		lpProcessInformation: LPPROCESS_INFORMATION,
 	) -> BOOL ---
 
@@ -67,7 +67,7 @@ foreign advapi32 {
 		dwCreationFlags: DWORD,
 		lpEnvironment: LPVOID,
 		lpCurrentDirectory: wstring,
-		lpStartupInfo: LPSTARTUPINFO,
+		lpStartupInfo: LPSTARTUPINFOW,
 		lpProcessInformation: LPPROCESS_INFORMATION,
 	) -> BOOL ---
 

+ 81 - 1
core/sys/windows/kernel32.odin

@@ -193,9 +193,10 @@ foreign kernel32 {
 		dwCreationFlags: DWORD,
 		lpEnvironment: LPVOID,
 		lpCurrentDirectory: LPCWSTR,
-		lpStartupInfo: LPSTARTUPINFO,
+		lpStartupInfo: LPSTARTUPINFOW,
 		lpProcessInformation: LPPROCESS_INFORMATION,
 	) -> BOOL ---
+	GetStartupInfoW :: proc(lpStartupInfo: LPSTARTUPINFOW) ---
 	GetEnvironmentVariableW :: proc(n: LPCWSTR, v: LPWSTR, nsize: DWORD) -> DWORD ---
 	SetEnvironmentVariableW :: proc(n: LPCWSTR, v: LPCWSTR) -> BOOL ---
 	GetEnvironmentStringsW :: proc() -> LPWCH ---
@@ -404,8 +405,87 @@ foreign kernel32 {
 	) -> BOOL ---
 
 	GetLogicalProcessorInformation :: proc(buffer: ^SYSTEM_LOGICAL_PROCESSOR_INFORMATION, returnedLength: PDWORD) -> BOOL ---
+
+	// [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-setfilecompletionnotificationmodes)
+	SetFileCompletionNotificationModes :: proc(FileHandle: HANDLE, Flags: u8) -> BOOL ---
+	// [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/ioapiset/nf-ioapiset-createiocompletionport)
+	CreateIoCompletionPort :: proc(FileHandle: HANDLE, ExistingCompletionPort: HANDLE, CompletionKey: uintptr, NumberOfConcurrentThreads: DWORD) -> HANDLE ---
+	//[MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/ioapiset/nf-ioapiset-getqueuedcompletionstatus)
+	GetQueuedCompletionStatus :: proc(CompletionPort: HANDLE, lpNumberOfBytesTransferred: ^DWORD, lpCompletionKey: uintptr, lpOverlapped: ^^OVERLAPPED, dwMilliseconds: DWORD) -> BOOL ---
+	// [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/ioapiset/nf-ioapiset-getqueuedcompletionstatusex)
+	GetQueuedCompletionStatusEx :: proc(CompletionPort: HANDLE, lpCompletionPortEntries: ^OVERLAPPED_ENTRY, ulCount: c_ulong, ulNumEntriesRemoved: ^c_ulong, dwMilliseconds: DWORD, fAlertable: BOOL) -> BOOL ---
+	// [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/ioapiset/nf-ioapiset-postqueuedcompletionstatus)
+	PostQueuedCompletionStatus :: proc(CompletionPort: HANDLE, dwNumberOfBytesTransferred: DWORD, dwCompletionKey: c_ulong, lpOverlapped: ^OVERLAPPED) -> BOOL ---
+	// [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/handleapi/nf-handleapi-gethandleinformation)
+	GetHandleInformation :: proc(hObject: HANDLE, lpdwFlags: ^DWORD) -> BOOL ---
 }
 
+DEBUG_PROCESS                    :: 0x00000001
+DEBUG_ONLY_THIS_PROCESS          :: 0x00000002
+CREATE_SUSPENDED                 :: 0x00000004
+DETACHED_PROCESS                 :: 0x00000008
+CREATE_NEW_CONSOLE               :: 0x00000010
+NORMAL_PRIORITY_CLASS            :: 0x00000020
+IDLE_PRIORITY_CLASS              :: 0x00000040
+HIGH_PRIORITY_CLASS              :: 0x00000080
+REALTIME_PRIORITY_CLASS          :: 0x00000100
+CREATE_NEW_PROCESS_GROUP         :: 0x00000200
+CREATE_UNICODE_ENVIRONMENT       :: 0x00000400
+CREATE_SEPARATE_WOW_VDM          :: 0x00000800
+CREATE_SHARED_WOW_VDM            :: 0x00001000
+CREATE_FORCEDOS                  :: 0x00002000
+BELOW_NORMAL_PRIORITY_CLASS      :: 0x00004000
+ABOVE_NORMAL_PRIORITY_CLASS      :: 0x00008000
+INHERIT_PARENT_AFFINITY          :: 0x00010000
+INHERIT_CALLER_PRIORITY          :: 0x00020000    // Deprecated
+CREATE_PROTECTED_PROCESS         :: 0x00040000
+EXTENDED_STARTUPINFO_PRESENT     :: 0x00080000
+PROCESS_MODE_BACKGROUND_BEGIN    :: 0x00100000
+PROCESS_MODE_BACKGROUND_END      :: 0x00200000
+CREATE_SECURE_PROCESS            :: 0x00400000
+CREATE_BREAKAWAY_FROM_JOB        :: 0x01000000
+CREATE_PRESERVE_CODE_AUTHZ_LEVEL :: 0x02000000
+CREATE_DEFAULT_ERROR_MODE        :: 0x04000000
+CREATE_NO_WINDOW                 :: 0x08000000
+PROFILE_USER                     :: 0x10000000
+PROFILE_KERNEL                   :: 0x20000000
+PROFILE_SERVER                   :: 0x40000000
+CREATE_IGNORE_SYSTEM_DEFAULT     :: 0x80000000
+
+THREAD_BASE_PRIORITY_LOWRT :: 15    // value that gets a thread to LowRealtime-1
+THREAD_BASE_PRIORITY_MAX   :: 2     // maximum thread base priority boost
+THREAD_BASE_PRIORITY_MIN   :: (-2)  // minimum thread base priority boost
+THREAD_BASE_PRIORITY_IDLE  :: (-15) // value that gets a thread to idle
+
+THREAD_PRIORITY_LOWEST        :: THREAD_BASE_PRIORITY_MIN
+THREAD_PRIORITY_BELOW_NORMAL  :: (THREAD_PRIORITY_LOWEST+1)
+THREAD_PRIORITY_NORMAL        :: 0
+THREAD_PRIORITY_HIGHEST       :: THREAD_BASE_PRIORITY_MAX
+THREAD_PRIORITY_ABOVE_NORMAL  :: (THREAD_PRIORITY_HIGHEST-1)
+THREAD_PRIORITY_ERROR_RETURN  :: (MAXLONG)
+THREAD_PRIORITY_TIME_CRITICAL :: THREAD_BASE_PRIORITY_LOWRT
+THREAD_PRIORITY_IDLE          :: THREAD_BASE_PRIORITY_IDLE
+THREAD_MODE_BACKGROUND_BEGIN  :: 0x00010000
+THREAD_MODE_BACKGROUND_END    :: 0x00020000
+
+COPY_FILE_FAIL_IF_EXISTS              :: 0x00000001
+COPY_FILE_RESTARTABLE                 :: 0x00000002
+COPY_FILE_OPEN_SOURCE_FOR_WRITE       :: 0x00000004
+COPY_FILE_ALLOW_DECRYPTED_DESTINATION :: 0x00000008
+COPY_FILE_COPY_SYMLINK                :: 0x00000800
+COPY_FILE_NO_BUFFERING                :: 0x00001000
+COPY_FILE_REQUEST_SECURITY_PRIVILEGES :: 0x00002000
+COPY_FILE_RESUME_FROM_PAUSE           :: 0x00004000
+COPY_FILE_NO_OFFLOAD                  :: 0x00040000
+COPY_FILE_IGNORE_EDP_BLOCK            :: 0x00400000
+COPY_FILE_IGNORE_SOURCE_ENCRYPTION    :: 0x00800000
+COPY_FILE_DONT_REQUEST_DEST_WRITE_DAC :: 0x02000000
+COPY_FILE_REQUEST_COMPRESSED_TRAFFIC  :: 0x10000000
+COPY_FILE_OPEN_AND_COPY_REPARSE_POINT :: 0x00200000
+COPY_FILE_DIRECTORY                   :: 0x00000080
+COPY_FILE_SKIP_ALTERNATE_STREAMS      :: 0x00008000
+COPY_FILE_DISABLE_PRE_ALLOCATION      :: 0x04000000
+COPY_FILE_ENABLE_LOW_FREE_SPACE_MODE  :: 0x08000000
 
 SECTION_QUERY                :: DWORD(0x0001)
 SECTION_MAP_WRITE            :: DWORD(0x0002)

+ 25 - 31
core/sys/windows/types.odin

@@ -111,7 +111,7 @@ LPOVERLAPPED :: ^OVERLAPPED
 LPPROCESS_INFORMATION :: ^PROCESS_INFORMATION
 PSECURITY_ATTRIBUTES :: ^SECURITY_ATTRIBUTES
 LPSECURITY_ATTRIBUTES :: ^SECURITY_ATTRIBUTES
-LPSTARTUPINFO :: ^STARTUPINFO
+LPSTARTUPINFOW :: ^STARTUPINFOW
 LPTRACKMOUSEEVENT :: ^TRACKMOUSEEVENT
 VOID :: rawptr
 PVOID :: rawptr
@@ -145,8 +145,6 @@ PCONDITION_VARIABLE :: ^CONDITION_VARIABLE
 PLARGE_INTEGER :: ^LARGE_INTEGER
 PSRWLOCK :: ^SRWLOCK
 
-MMRESULT :: UINT
-
 CREATE_WAITABLE_TIMER_MANUAL_RESET    :: 0x00000001
 CREATE_WAITABLE_TIMER_HIGH_RESOLUTION :: 0x00000002
 
@@ -164,6 +162,8 @@ SIZE :: struct {
 PSIZE  :: ^SIZE
 LPSIZE :: ^SIZE
 
+MAXLONG :: 0x7fffffff
+
 FILE_ATTRIBUTE_READONLY: DWORD : 0x00000001
 FILE_ATTRIBUTE_HIDDEN: DWORD : 0x00000002
 FILE_ATTRIBUTE_SYSTEM: DWORD : 0x00000004
@@ -261,26 +261,6 @@ GET_FILEEX_INFO_LEVELS :: distinct i32
 GetFileExInfoStandard: GET_FILEEX_INFO_LEVELS : 0
 GetFileExMaxInfoLevel: GET_FILEEX_INFO_LEVELS : 1
 
-// String resource number bases (internal use)
-
-MMSYSERR_BASE :: 0
-WAVERR_BASE   :: 32
-MIDIERR_BASE  :: 64
-TIMERR_BASE   :: 96
-JOYERR_BASE   :: 160
-MCIERR_BASE   :: 256
-MIXERR_BASE   :: 1024
-
-MCI_STRING_OFFSET :: 512
-MCI_VD_OFFSET     :: 1024
-MCI_CD_OFFSET     :: 1088
-MCI_WAVE_OFFSET   :: 1152
-MCI_SEQ_OFFSET    :: 1216
-
-// timer error return values
-TIMERR_NOERROR :: 0                // no error
-TIMERR_NOCANDO :: TIMERR_BASE + 1  // request not completed
-TIMERR_STRUCT  :: TIMERR_BASE + 33 // time struct size
 
 DIAGNOSTIC_REASON_VERSION :: 0
 
@@ -2064,7 +2044,6 @@ TLS_OUT_OF_INDEXES: DWORD : 0xFFFFFFFF
 
 DLL_THREAD_DETACH: DWORD : 3
 DLL_PROCESS_DETACH: DWORD : 0
-CREATE_SUSPENDED :: DWORD(0x00000004)
 
 INFINITE :: ~DWORD(0)
 
@@ -2073,11 +2052,6 @@ DUPLICATE_SAME_ACCESS: DWORD : 0x00000002
 CONDITION_VARIABLE_INIT :: CONDITION_VARIABLE{}
 SRWLOCK_INIT :: SRWLOCK{}
 
-DETACHED_PROCESS: DWORD : 0x00000008
-CREATE_NEW_CONSOLE: DWORD : 0x00000010
-CREATE_NO_WINDOW: DWORD : 0x08000000
-CREATE_NEW_PROCESS_GROUP: DWORD : 0x00000200
-CREATE_UNICODE_ENVIRONMENT: DWORD : 0x00000400
 STARTF_USESTDHANDLES: DWORD : 0x00000100
 
 VOLUME_NAME_DOS: DWORD : 0x0
@@ -2440,8 +2414,7 @@ PROCESS_INFORMATION :: struct {
 	dwThreadId: DWORD,
 }
 
-// FYI: This is STARTUPINFOW, not STARTUPINFOA
-STARTUPINFO :: struct {
+STARTUPINFOW :: struct {
 	cb: DWORD,
 	lpReserved: LPWSTR,
 	lpDesktop: LPWSTR,
@@ -2472,6 +2445,20 @@ FILETIME_as_unix_nanoseconds :: proc "contextless" (ft: FILETIME) -> i64 {
 	return (t - 116444736000000000) * 100
 }
 
+OBJECT_ATTRIBUTES :: struct {
+	Length:                   c_ulong,
+	RootDirectory:            HANDLE,
+	ObjectName:               ^UNICODE_STRING,
+	Attributes:               c_ulong,
+	SecurityDescriptor:       rawptr,
+	SecurityQualityOfService: rawptr,
+}
+
+UNICODE_STRING :: struct {
+	Length:        u16,
+	MaximumLength: u16,
+	Buffer:        ^u16,
+}
 
 OVERLAPPED :: struct {
 	Internal: ^c_ulong,
@@ -2481,6 +2468,13 @@ OVERLAPPED :: struct {
 	hEvent: HANDLE,
 }
 
+OVERLAPPED_ENTRY :: struct {
+	lpCompletionKey:            c_ulong,
+	lpOverlapped:               ^OVERLAPPED,
+	Internal:                   c_ulong,
+	dwNumberOfBytesTransferred: DWORD,
+}
+
 LPOVERLAPPED_COMPLETION_ROUTINE :: #type proc "stdcall" (
 	dwErrorCode: DWORD,
 	dwNumberOfBytesTransfered: DWORD,

+ 2 - 2
core/sys/windows/util.odin

@@ -457,8 +457,8 @@ run_as_user :: proc(username, password, application, commandline: string, pi: ^P
 		// err := GetLastError();
 		// fmt.printf("GetLastError: %v\n", err);
 	}
-	si := STARTUPINFO{}
-	si.cb = size_of(STARTUPINFO)
+	si := STARTUPINFOW{}
+	si.cb = size_of(STARTUPINFOW)
 	pi := pi
 
 	ok = bool(CreateProcessAsUserW(

+ 161 - 0
core/sys/windows/winmm.odin

@@ -3,9 +3,170 @@ package sys_windows
 
 foreign import winmm "system:Winmm.lib"
 
+MMRESULT :: UINT
+
 @(default_calling_convention="stdcall")
 foreign winmm {
+	timeGetDevCaps  :: proc(ptc: LPTIMECAPS, cbtc: UINT) -> MMRESULT ---
 	timeBeginPeriod :: proc(uPeriod: UINT) -> MMRESULT ---
 	timeEndPeriod   :: proc(uPeriod: UINT) -> MMRESULT ---
 	timeGetTime     :: proc() -> DWORD ---
 }
+
+LPTIMECAPS :: ^TIMECAPS
+TIMECAPS :: struct {
+	wPeriodMin: UINT,
+	wPeriodMax: UINT,
+}
+
+// String resource number bases (internal use)
+MMSYSERR_BASE :: 0
+WAVERR_BASE   :: 32
+MIDIERR_BASE  :: 64
+TIMERR_BASE   :: 96
+JOYERR_BASE   :: 160
+MCIERR_BASE   :: 256
+MIXERR_BASE   :: 1024
+
+MCI_STRING_OFFSET :: 512
+MCI_VD_OFFSET     :: 1024
+MCI_CD_OFFSET     :: 1088
+MCI_WAVE_OFFSET   :: 1152
+MCI_SEQ_OFFSET    :: 1216
+
+/* general error return values */
+MMSYSERR_NOERROR      :: 0                  /* no error */
+MMSYSERR_ERROR        :: MMSYSERR_BASE + 1  /* unspecified error */
+MMSYSERR_BADDEVICEID  :: MMSYSERR_BASE + 2  /* device ID out of range */
+MMSYSERR_NOTENABLED   :: MMSYSERR_BASE + 3  /* driver failed enable */
+MMSYSERR_ALLOCATED    :: MMSYSERR_BASE + 4  /* device already allocated */
+MMSYSERR_INVALHANDLE  :: MMSYSERR_BASE + 5  /* device handle is invalid */
+MMSYSERR_NODRIVER     :: MMSYSERR_BASE + 6  /* no device driver present */
+MMSYSERR_NOMEM        :: MMSYSERR_BASE + 7  /* memory allocation error */
+MMSYSERR_NOTSUPPORTED :: MMSYSERR_BASE + 8  /* function isn't supported */
+MMSYSERR_BADERRNUM    :: MMSYSERR_BASE + 9  /* error value out of range */
+MMSYSERR_INVALFLAG    :: MMSYSERR_BASE + 10 /* invalid flag passed */
+MMSYSERR_INVALPARAM   :: MMSYSERR_BASE + 11 /* invalid parameter passed */
+MMSYSERR_HANDLEBUSY   :: MMSYSERR_BASE + 12 /* handle being used simultaneously on another thread (eg callback) */
+MMSYSERR_INVALIDALIAS :: MMSYSERR_BASE + 13 /* specified alias not found */
+MMSYSERR_BADDB        :: MMSYSERR_BASE + 14 /* bad registry database */
+MMSYSERR_KEYNOTFOUND  :: MMSYSERR_BASE + 15 /* registry key not found */
+MMSYSERR_READERROR    :: MMSYSERR_BASE + 16 /* registry read error */
+MMSYSERR_WRITEERROR   :: MMSYSERR_BASE + 17 /* registry write error */
+MMSYSERR_DELETEERROR  :: MMSYSERR_BASE + 18 /* registry delete error */
+MMSYSERR_VALNOTFOUND  :: MMSYSERR_BASE + 19 /* registry value not found */
+MMSYSERR_NODRIVERCB   :: MMSYSERR_BASE + 20 /* driver does not call DriverCallback */
+MMSYSERR_MOREDATA     :: MMSYSERR_BASE + 21 /* more data to be returned */
+MMSYSERR_LASTERROR    :: MMSYSERR_BASE + 21 /* last error in range */
+
+/* waveform audio error return values */
+WAVERR_BADFORMAT    :: WAVERR_BASE + 0 /* unsupported wave format */
+WAVERR_STILLPLAYING :: WAVERR_BASE + 1 /* still something playing */
+WAVERR_UNPREPARED   :: WAVERR_BASE + 2 /* header not prepared */
+WAVERR_SYNC         :: WAVERR_BASE + 3 /* device is synchronous */
+WAVERR_LASTERROR    :: WAVERR_BASE + 3 /* last error in range */
+
+/* MIDI error return values */
+MIDIERR_UNPREPARED    :: MIDIERR_BASE + 0 /* header not prepared */
+MIDIERR_STILLPLAYING  :: MIDIERR_BASE + 1 /* still something playing */
+MIDIERR_NOMAP         :: MIDIERR_BASE + 2 /* no configured instruments */
+MIDIERR_NOTREADY      :: MIDIERR_BASE + 3 /* hardware is still busy */
+MIDIERR_NODEVICE      :: MIDIERR_BASE + 4 /* port no longer connected */
+MIDIERR_INVALIDSETUP  :: MIDIERR_BASE + 5 /* invalid MIF */
+MIDIERR_BADOPENMODE   :: MIDIERR_BASE + 6 /* operation unsupported w/ open mode */
+MIDIERR_DONT_CONTINUE :: MIDIERR_BASE + 7 /* thru device 'eating' a message */
+MIDIERR_LASTERROR     :: MIDIERR_BASE + 7 /* last error in range */
+
+/* timer error return values */
+TIMERR_NOERROR :: 0                /* no error */
+TIMERR_NOCANDO :: TIMERR_BASE + 1  /* request not completed */
+TIMERR_STRUCT  :: TIMERR_BASE + 33 /* time struct size */
+
+/* joystick error return values */
+JOYERR_NOERROR   :: 0               /* no error */
+JOYERR_PARMS     :: JOYERR_BASE + 5 /* bad parameters */
+JOYERR_NOCANDO   :: JOYERR_BASE + 6 /* request not completed */
+JOYERR_UNPLUGGED :: JOYERR_BASE + 7 /* joystick is unplugged */
+
+/* MCI error return values */
+MCIERR_INVALID_DEVICE_ID        :: MCIERR_BASE + 1
+MCIERR_UNRECOGNIZED_KEYWORD     :: MCIERR_BASE + 3
+MCIERR_UNRECOGNIZED_COMMAND     :: MCIERR_BASE + 5
+MCIERR_HARDWARE                 :: MCIERR_BASE + 6
+MCIERR_INVALID_DEVICE_NAME      :: MCIERR_BASE + 7
+MCIERR_OUT_OF_MEMORY            :: MCIERR_BASE + 8
+MCIERR_DEVICE_OPEN              :: MCIERR_BASE + 9
+MCIERR_CANNOT_LOAD_DRIVER       :: MCIERR_BASE + 10
+MCIERR_MISSING_COMMAND_STRING   :: MCIERR_BASE + 11
+MCIERR_PARAM_OVERFLOW           :: MCIERR_BASE + 12
+MCIERR_MISSING_STRING_ARGUMENT  :: MCIERR_BASE + 13
+MCIERR_BAD_INTEGER              :: MCIERR_BASE + 14
+MCIERR_PARSER_INTERNAL          :: MCIERR_BASE + 15
+MCIERR_DRIVER_INTERNAL          :: MCIERR_BASE + 16
+MCIERR_MISSING_PARAMETER        :: MCIERR_BASE + 17
+MCIERR_UNSUPPORTED_FUNCTION     :: MCIERR_BASE + 18
+MCIERR_FILE_NOT_FOUND           :: MCIERR_BASE + 19
+MCIERR_DEVICE_NOT_READY         :: MCIERR_BASE + 20
+MCIERR_INTERNAL                 :: MCIERR_BASE + 21
+MCIERR_DRIVER                   :: MCIERR_BASE + 22
+MCIERR_CANNOT_USE_ALL           :: MCIERR_BASE + 23
+MCIERR_MULTIPLE                 :: MCIERR_BASE + 24
+MCIERR_EXTENSION_NOT_FOUND      :: MCIERR_BASE + 25
+MCIERR_OUTOFRANGE               :: MCIERR_BASE + 26
+MCIERR_FLAGS_NOT_COMPATIBLE     :: MCIERR_BASE + 28
+MCIERR_FILE_NOT_SAVED           :: MCIERR_BASE + 30
+MCIERR_DEVICE_TYPE_REQUIRED     :: MCIERR_BASE + 31
+MCIERR_DEVICE_LOCKED            :: MCIERR_BASE + 32
+MCIERR_DUPLICATE_ALIAS          :: MCIERR_BASE + 33
+MCIERR_BAD_CONSTANT             :: MCIERR_BASE + 34
+MCIERR_MUST_USE_SHAREABLE       :: MCIERR_BASE + 35
+MCIERR_MISSING_DEVICE_NAME      :: MCIERR_BASE + 36
+MCIERR_BAD_TIME_FORMAT          :: MCIERR_BASE + 37
+MCIERR_NO_CLOSING_QUOTE         :: MCIERR_BASE + 38
+MCIERR_DUPLICATE_FLAGS          :: MCIERR_BASE + 39
+MCIERR_INVALID_FILE             :: MCIERR_BASE + 40
+MCIERR_NULL_PARAMETER_BLOCK     :: MCIERR_BASE + 41
+MCIERR_UNNAMED_RESOURCE         :: MCIERR_BASE + 42
+MCIERR_NEW_REQUIRES_ALIAS       :: MCIERR_BASE + 43
+MCIERR_NOTIFY_ON_AUTO_OPEN      :: MCIERR_BASE + 44
+MCIERR_NO_ELEMENT_ALLOWED       :: MCIERR_BASE + 45
+MCIERR_NONAPPLICABLE_FUNCTION   :: MCIERR_BASE + 46
+MCIERR_ILLEGAL_FOR_AUTO_OPEN    :: MCIERR_BASE + 47
+MCIERR_FILENAME_REQUIRED        :: MCIERR_BASE + 48
+MCIERR_EXTRA_CHARACTERS         :: MCIERR_BASE + 49
+MCIERR_DEVICE_NOT_INSTALLED     :: MCIERR_BASE + 50
+MCIERR_GET_CD                   :: MCIERR_BASE + 51
+MCIERR_SET_CD                   :: MCIERR_BASE + 52
+MCIERR_SET_DRIVE                :: MCIERR_BASE + 53
+MCIERR_DEVICE_LENGTH            :: MCIERR_BASE + 54
+MCIERR_DEVICE_ORD_LENGTH        :: MCIERR_BASE + 55
+MCIERR_NO_INTEGER               :: MCIERR_BASE + 56
+MCIERR_WAVE_OUTPUTSINUSE        :: MCIERR_BASE + 64
+MCIERR_WAVE_SETOUTPUTINUSE      :: MCIERR_BASE + 65
+MCIERR_WAVE_INPUTSINUSE         :: MCIERR_BASE + 66
+MCIERR_WAVE_SETINPUTINUSE       :: MCIERR_BASE + 67
+MCIERR_WAVE_OUTPUTUNSPECIFIED   :: MCIERR_BASE + 68
+MCIERR_WAVE_INPUTUNSPECIFIED    :: MCIERR_BASE + 69
+MCIERR_WAVE_OUTPUTSUNSUITABLE   :: MCIERR_BASE + 70
+MCIERR_WAVE_SETOUTPUTUNSUITABLE :: MCIERR_BASE + 71
+MCIERR_WAVE_INPUTSUNSUITABLE    :: MCIERR_BASE + 72
+MCIERR_WAVE_SETINPUTUNSUITABLE  :: MCIERR_BASE + 73
+MCIERR_SEQ_DIV_INCOMPATIBLE     :: MCIERR_BASE + 80
+MCIERR_SEQ_PORT_INUSE           :: MCIERR_BASE + 81
+MCIERR_SEQ_PORT_NONEXISTENT     :: MCIERR_BASE + 82
+MCIERR_SEQ_PORT_MAPNODEVICE     :: MCIERR_BASE + 83
+MCIERR_SEQ_PORT_MISCERROR       :: MCIERR_BASE + 84
+MCIERR_SEQ_TIMER                :: MCIERR_BASE + 85
+MCIERR_SEQ_PORTUNSPECIFIED      :: MCIERR_BASE + 86
+MCIERR_SEQ_NOMIDIPRESENT        :: MCIERR_BASE + 87
+MCIERR_NO_WINDOW                :: MCIERR_BASE + 90
+MCIERR_CREATEWINDOW             :: MCIERR_BASE + 91
+MCIERR_FILE_READ                :: MCIERR_BASE + 92
+MCIERR_FILE_WRITE               :: MCIERR_BASE + 93
+MCIERR_NO_IDENTITY              :: MCIERR_BASE + 94
+
+/*  MMRESULT error return values specific to the mixer API */
+MIXERR_INVALLINE    :: (MIXERR_BASE + 0)
+MIXERR_INVALCONTROL :: (MIXERR_BASE + 1)
+MIXERR_INVALVALUE   :: (MIXERR_BASE + 2)
+MIXERR_LASTERROR    :: (MIXERR_BASE + 2)

+ 94 - 3
core/sys/windows/ws2_32.odin

@@ -1,18 +1,78 @@
 // +build windows
 package sys_windows
 
-foreign import ws2_32 "system:Ws2_32.lib"
+// Define flags to be used with the WSAAsyncSelect() call.
+FD_READ :: 0x01
+FD_WRITE :: 0x02
+FD_OOB :: 0x04
+FD_ACCEPT :: 0x08
+FD_CONNECT :: 0x10
+FD_CLOSE :: 0x20
+FD_MAX_EVENTS :: 10
+
+INADDR_LOOPBACK :: 0x7f000001
+
+// Event flag definitions for WSAPoll().
+POLLRDNORM :: 0x0100
+POLLRDBAND :: 0x0200
+POLLIN     :: (POLLRDNORM | POLLRDBAND)
+POLLPRI    :: 0x0400
+POLLWRNORM :: 0x0010
+POLLOUT    :: (POLLWRNORM)
+POLLWRBAND :: 0x0020
+POLLERR    :: 0x0001
+POLLHUP    :: 0x0002
+POLLNVAL   :: 0x0004
+
+WSA_POLLFD::struct{
+	fd:SOCKET,
+	events:c_short,
+	revents:c_short,
+}
+
+WSANETWORKEVENTS :: struct {
+	lNetworkEvents: c_long,
+	iErrorCode:     [FD_MAX_EVENTS]c_int,
+}
+
+WSAEVENT :: HANDLE
+
+WSAID_ACCEPTEX :: GUID{0xb5367df1, 0xcbac, 0x11cf, {0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92}}
+WSAID_GETACCEPTEXSOCKADDRS :: GUID{0xb5367df2, 0xcbac, 0x11cf, {0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92}}
+SIO_GET_EXTENSION_FUNCTION_POINTER :: IOC_INOUT | IOC_WS2 | 6
+IOC_OUT :: 0x40000000
+IOC_IN :: 0x80000000
+IOC_INOUT :: (IOC_IN | IOC_OUT)
+IOC_WS2 :: 0x08000000
+/*
+Example Load:
+	load_accept_ex :: proc(listener: SOCKET, fn_acceptex: rawptr) {
+		bytes: u32
+		guid_accept_ex := WSAID_ACCEPTEX
+		rc := WSAIoctl(listener, SIO_GET_EXTENSION_FUNCTION_POINTER, &guid_accept_ex, size_of(guid_accept_ex),
+			fn_acceptex, size_of(fn_acceptex), &bytes, nil,	nil,)
+		assert(rc != windows.SOCKET_ERROR)
+	}
+*/
 
+foreign import ws2_32 "system:Ws2_32.lib"
 @(default_calling_convention="stdcall")
 foreign ws2_32 {
+	// [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsastartup)
 	WSAStartup :: proc(wVersionRequested: WORD, lpWSAData: LPWSADATA) -> c_int ---
+	// [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsacleanup)
 	WSACleanup :: proc() -> c_int ---
+	// [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsagetlasterror)
 	WSAGetLastError :: proc() -> c_int ---
+	// [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsapoll)
+	WSAPoll :: proc(fdArray: ^WSA_POLLFD, fds: c_ulong, timeout: c_int) -> c_int ---
+	// [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsaduplicatesocketw)
 	WSADuplicateSocketW :: proc(
 		s: SOCKET,
 		dwProcessId: DWORD,
 		lpProtocolInfo: LPWSAPROTOCOL_INFO,
 	) -> c_int ---
+	// [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsasend)
 	WSASend :: proc(
 		s: SOCKET,
 		lpBuffers: LPWSABUF,
@@ -22,6 +82,7 @@ foreign ws2_32 {
 		lpOverlapped: LPWSAOVERLAPPED,
 		lpCompletionRoutine: LPWSAOVERLAPPED_COMPLETION_ROUTINE,
 	) -> c_int ---
+	// [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsarecv)
 	WSARecv :: proc(
 		s: SOCKET,
 		lpBuffers: LPWSABUF,
@@ -31,6 +92,7 @@ foreign ws2_32 {
 		lpOverlapped: LPWSAOVERLAPPED,
 		lpCompletionRoutine: LPWSAOVERLAPPED_COMPLETION_ROUTINE,
 	) -> c_int ---
+	// [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsasocketw)
 	WSASocketW :: proc(
 		af: c_int,
 		kind: c_int,
@@ -39,16 +101,32 @@ foreign ws2_32 {
 		g: GROUP,
 		dwFlags: DWORD,
 	) -> SOCKET ---
+	// [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsaioctl)
+	WSAIoctl :: proc(s: SOCKET, dwIoControlCode: DWORD, lpvInBuffer: rawptr, cbInBuffer: DWORD, lpvOutBuffer: rawptr, cbOutBuffer: DWORD, lpcbBytesReturned: ^DWORD, lpOverlapped: ^OVERLAPPED, lpCompletionRoutine: LPWSAOVERLAPPED_COMPLETION_ROUTINE) -> c_int ---
+	// [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsaeventselect)
+	WSAEventSelect :: proc(s: SOCKET, hEventObject: WSAEVENT, lNetworkEvents: i32) -> c_int ---
+	// [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsawaitformultipleevents)
+	WSAWaitForMultipleEvents :: proc(cEvents: DWORD, lphEvents: ^WSAEVENT, fWaitAll: BOOL, dwTimeout: DWORD, fAlertable: BOOL) -> DWORD ---
+	// [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsaenumnetworkevents)
+	WSAEnumNetworkEvents :: proc(s: SOCKET, hEventObject: WSAEVENT, lpNetworkEvents: ^WSANETWORKEVENTS) -> c_int ---
+	//[MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsagetoverlappedresult)
+	WSAGetOverlappedResult :: proc(s: SOCKET, lpOverlapped: ^OVERLAPPED, lpcbTransfer: ^DWORD, fWait: BOOL, lpdwFlags: ^DWORD) -> BOOL ---
+	// [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-socket)
 	socket :: proc(
 		af: c_int,
 		type: c_int,
 		protocol: c_int,
 	) -> SOCKET ---
 
+	// [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-ioctlsocket)
 	ioctlsocket :: proc(s: SOCKET, cmd: c_long, argp: ^c_ulong) -> c_int ---
+	// [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-closesocket)
 	closesocket :: proc(socket: SOCKET) -> c_int ---
+	// [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-recv)
 	recv :: proc(socket: SOCKET, buf: rawptr, len: c_int, flags: c_int) -> c_int ---
+	// [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-send)
 	send :: proc(socket: SOCKET, buf: rawptr, len: c_int, flags: c_int) -> c_int ---
+	// [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-recvfrom)
 	recvfrom :: proc(
 		socket: SOCKET,
 		buf: rawptr,
@@ -57,6 +135,7 @@ foreign ws2_32 {
 		addr: ^SOCKADDR_STORAGE_LH,
 		addrlen: ^c_int,
 	) -> c_int ---
+	// [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-sendto)
 	sendto :: proc(
 		socket: SOCKET,
 		buf: rawptr,
@@ -65,9 +144,12 @@ foreign ws2_32 {
 		addr: ^SOCKADDR_STORAGE_LH,
 		addrlen: c_int,
 	) -> c_int ---
+	// [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-shutdown)
 	shutdown :: proc(socket: SOCKET, how: c_int) -> c_int ---
+	// [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-accept)
 	accept :: proc(socket: SOCKET, address: ^SOCKADDR_STORAGE_LH, address_len: ^c_int) -> SOCKET ---
 
+	// [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-setsockopt)
 	setsockopt :: proc(
 		s: SOCKET,
 		level: c_int,
@@ -75,19 +157,28 @@ foreign ws2_32 {
 		optval: rawptr,
 		optlen: c_int,
 	) -> c_int ---
+	// [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-getsockname)
 	getsockname :: proc(socket: SOCKET, address: ^SOCKADDR_STORAGE_LH, address_len: ^c_int) -> c_int ---
+	// [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-getpeername)
 	getpeername :: proc(socket: SOCKET, address: ^SOCKADDR_STORAGE_LH, address_len: ^c_int) -> c_int ---
+	// [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-bind)
 	bind :: proc(socket: SOCKET, address: ^SOCKADDR_STORAGE_LH, address_len: socklen_t) -> c_int ---
+	// [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-listen)
 	listen :: proc(socket: SOCKET, backlog: c_int) -> c_int ---
+	// [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-connect)
 	connect :: proc(socket: SOCKET, address: ^SOCKADDR_STORAGE_LH, len: c_int) -> c_int ---
+	// [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/ws2tcpip/nf-ws2tcpip-getaddrinfo)
 	getaddrinfo :: proc(
 		node: cstring,
 		service: cstring,
 		hints: ^ADDRINFOA,
 		res: ^^ADDRINFOA,
 	) -> c_int ---
+	// [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/ws2tcpip/nf-ws2tcpip-freeaddrinfo)
 	freeaddrinfo :: proc(res: ^ADDRINFOA) ---
+	// [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/ws2tcpip/nf-ws2tcpip-freeaddrinfoexw)
 	FreeAddrInfoExW :: proc(pAddrInfoEx: PADDRINFOEXW) ---
+	// [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/ws2tcpip/nf-ws2tcpip-getaddrinfoexw)
 	GetAddrInfoExW :: proc(
 		pName:               PCWSTR,
 		pServiceName:        PCWSTR,
@@ -99,7 +190,7 @@ foreign ws2_32 {
 		lpOverlapped:        LPOVERLAPPED,
 		lpCompletionRoutine: LPLOOKUPSERVICE_COMPLETION_ROUTINE,
 		lpHandle:            LPHANDLE) -> INT ---
-
+	// [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-select)
 	select :: proc(
 		nfds: c_int,
 		readfds: ^fd_set,
@@ -107,6 +198,7 @@ foreign ws2_32 {
 		exceptfds: ^fd_set,
 		timeout: ^timeval,
 	) -> c_int ---
+	// [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-getsockopt)
 	getsockopt :: proc(
 		s: SOCKET,
 		level: c_int,
@@ -114,5 +206,4 @@ foreign ws2_32 {
 		optval: ^c_char,
 		optlen: ^c_int,
 	) -> c_int ---
-
 }

+ 100 - 0
core/text/table/doc.odin

@@ -0,0 +1,100 @@
+/*
+	package table implements ascii/markdown/html/custom rendering of tables.
+
+	---
+
+	Custom rendering example:
+
+	```odin
+	tbl := init(&Table{})
+	padding(tbl, 0, 1)
+	row(tbl, "A_LONG_ENUM", "= 54,", "// A comment about A_LONG_ENUM")
+	row(tbl, "AN_EVEN_LONGER_ENUM", "= 1,", "// A comment about AN_EVEN_LONGER_ENUM")
+	build(tbl)
+	for row in 0..<tbl.nr_rows {
+		for col in 0..<tbl.nr_cols {
+			write_table_cell(stdio_writer(), tbl, row, col)
+		}
+		io.write_byte(stdio_writer(), '\n')
+	}
+	```
+
+	This outputs:
+	```
+	A_LONG_ENUM         = 54, // A comment about A_LONG_ENUM
+	AN_EVEN_LONGER_ENUM = 1,  // A comment about AN_EVEN_LONGER_ENUM
+	```
+
+	---
+
+	ASCII rendering example:
+
+	```odin
+	tbl := init(&Table{})
+	defer destroy(tbl)
+
+	caption(tbl, "This is a table caption and it is very long")
+
+	padding(tbl, 1, 1) // Left/right padding of cells
+
+	header(tbl, "AAAAAAAAA", "B")
+	header(tbl, "C") // Appends to previous header row. Same as if done header("AAAAAAAAA", "B", "C") from start.
+
+	// Create a row with two values. Since there are three columns the third
+	// value will become the empty string.
+	//
+	// NOTE: header() is not allowed anymore after this.
+	row(tbl, 123, "foo")
+
+	// Use `format()` if you need custom formatting. This will allocate into
+	// the arena specified at init.
+	row(tbl,
+	    format(tbl, "%09d", 5),
+	    format(tbl, "%.6f", 6.28318530717958647692528676655900576))
+
+	// A row with zero values is allowed as long as a previous row or header
+	// exist. The value and alignment of each cell can then be set
+	// individually.
+	row(tbl)
+		set_cell_value_and_alignment(tbl, last_row(tbl), 0, "a", .Center)
+		set_cell_value(tbl, last_row(tbl), 1, "bbb")
+		set_cell_value(tbl, last_row(tbl), 2, "c")
+
+	// Headers are regular cells, too. Use header_row() as row index to modify
+	// header cells.
+	set_cell_alignment(tbl, header_row(tbl), 1, .Center) // Sets alignment of 'B' column to Center.
+	set_cell_alignment(tbl, header_row(tbl), 2, .Right) // Sets alignment of 'C' column to Right.
+
+	build(tbl)
+
+	write_ascii_table(stdio_writer(), tbl)
+	write_markdown_table(stdio_writer(), tbl)
+	```
+
+	This outputs:
+	```
+	+-----------------------------------------------+
+	|  This is a table caption and it is very long  |
+	+------------------+-----------------+----------+
+	| AAAAAAAAA        |        B        |        C |
+	+------------------+-----------------+----------+
+	| 123              | foo             |          |
+	| 000000005        | 6.283185        |          |
+	|        a         | bbb             | c        |
+	+------------------+-----------------+----------+
+	```
+
+	and
+
+	```
+	|    AAAAAAAAA     |        B        |    C     |
+	|:-----------------|:---------------:|---------:|
+	| 123              | foo             |          |
+	| 000000005        | 6.283185        |          |
+	| a                | bbb             | c        |
+	```
+
+	respectively.
+*/
+
+package text_table

+ 384 - 0
core/text/table/table.odin

@@ -0,0 +1,384 @@
+/*
+	Copyright 2023 oskarnp <[email protected]>
+	Made available under Odin's BSD-3 license.
+
+	List of contributors:
+		oskarnp: Initial implementation.
+*/
+
+package text_table
+
+import "core:io"
+import "core:os"
+import "core:fmt"
+import "core:mem"
+import "core:mem/virtual"
+import "core:runtime"
+import "core:strings"
+
+Cell :: struct {
+	text: string,
+	alignment: Cell_Alignment,
+}
+
+Cell_Alignment :: enum {
+	Left,
+	Center,
+	Right,
+}
+
+Table :: struct {
+	lpad, rpad: int, // Cell padding (left/right)
+	cells: [dynamic]Cell,
+	caption: string,
+	nr_rows, nr_cols: int,
+	has_header_row: bool,
+	table_allocator: runtime.Allocator,  // Used for allocating cells/colw
+	format_allocator: runtime.Allocator, // Used for allocating Cell.text when applicable
+
+	dirty: bool, // True if build() needs to be called before rendering
+
+	// The following are computed on build()
+	colw: [dynamic]int, // Width of each column (including padding, excluding borders)
+	tblw: int,          // Width of entire table (including padding, excluding borders)
+}
+
+init :: proc{init_with_allocator, init_with_virtual_arena, init_with_mem_arena}
+
+init_with_allocator :: proc(tbl: ^Table, format_allocator := context.temp_allocator, table_allocator := context.allocator) -> ^Table {
+	tbl.table_allocator = table_allocator
+	tbl.cells = make([dynamic]Cell, tbl.table_allocator)
+	tbl.colw = make([dynamic]int, tbl.table_allocator)
+	tbl.format_allocator = format_allocator
+	return tbl
+}
+init_with_virtual_arena :: proc(tbl: ^Table, format_arena: ^virtual.Arena, table_allocator := context.allocator) -> ^Table {
+	return init_with_allocator(tbl, virtual.arena_allocator(format_arena), table_allocator)
+}
+init_with_mem_arena :: proc(tbl: ^Table, format_arena: ^mem.Arena, table_allocator := context.allocator) -> ^Table {
+	return init_with_allocator(tbl, mem.arena_allocator(format_arena), table_allocator)
+}
+
+destroy :: proc(tbl: ^Table) {
+	free_all(tbl.format_allocator)
+	delete(tbl.cells)
+	delete(tbl.colw)
+}
+
+caption :: proc(tbl: ^Table, value: string) {
+	tbl.caption = value
+	tbl.dirty = true
+}
+
+padding :: proc(tbl: ^Table, lpad, rpad: int) {
+	tbl.lpad = lpad
+	tbl.rpad = rpad
+	tbl.dirty = true
+}
+
+get_cell :: proc(tbl: ^Table, row, col: int, loc := #caller_location) -> ^Cell {
+	assert(col >= 0 && col < tbl.nr_cols, "cell column out of range", loc)
+	assert(row >= 0 && row < tbl.nr_rows, "cell row out of range", loc)
+	resize(&tbl.cells, tbl.nr_cols * tbl.nr_rows)
+	return &tbl.cells[row*tbl.nr_cols + col]
+}
+
+set_cell_value_and_alignment :: proc(tbl: ^Table, row, col: int, value: string, alignment: Cell_Alignment) {
+	cell := get_cell(tbl, row, col)
+	cell.text = format(tbl, "%v", value)
+	cell.alignment = alignment
+	tbl.dirty = true
+}
+
+set_cell_value :: proc(tbl: ^Table, row, col: int, value: any, loc := #caller_location) {
+	cell := get_cell(tbl, row, col, loc)
+	switch val in value {
+	case nil:
+		cell.text = ""
+	case string:
+		cell.text = string(val)
+	case cstring:
+		cell.text = string(val)
+	case:
+		cell.text = format(tbl, "%v", val)
+		if cell.text == "" {
+			fmt.eprintf("{} text/table: format() resulted in empty string (arena out of memory?)\n", loc)
+		}
+	}
+	tbl.dirty = true
+}
+
+set_cell_alignment :: proc(tbl: ^Table, row, col: int, alignment: Cell_Alignment, loc := #caller_location) {
+	cell := get_cell(tbl, row, col, loc)
+	cell.alignment = alignment
+	tbl.dirty = true
+}
+
+format :: proc(tbl: ^Table, _fmt: string, args: ..any, loc := #caller_location) -> string {
+	context.allocator = tbl.format_allocator
+	return fmt.aprintf(fmt = _fmt, args = args)
+}
+
+header :: proc(tbl: ^Table, values: ..any, loc := #caller_location) {
+	if (tbl.has_header_row && tbl.nr_rows != 1) || (!tbl.has_header_row && tbl.nr_rows != 0) {
+		panic("Cannot add headers after rows have been added", loc)
+	}
+
+	if tbl.nr_rows == 0 {
+		tbl.nr_rows += 1
+		tbl.has_header_row = true
+	}
+
+	col := tbl.nr_cols
+	tbl.nr_cols += len(values)
+	for val in values {
+		set_cell_value(tbl, header_row(tbl), col, val, loc)
+		col += 1
+	}
+
+	tbl.dirty = true
+}
+
+row :: proc(tbl: ^Table, values: ..any, loc := #caller_location) {
+	if tbl.nr_cols == 0 {
+		if len(values) == 0 {
+			panic("Cannot create row without values unless knowing amount of columns in advance")
+		} else {
+			tbl.nr_cols = len(values)
+		}
+	}
+	tbl.nr_rows += 1
+	for col in 0..<tbl.nr_cols {
+		val := values[col] if col < len(values) else nil
+		set_cell_value(tbl, last_row(tbl), col, val)
+	}
+	tbl.dirty = true
+}
+
+last_row :: proc(tbl: ^Table) -> int {
+	return tbl.nr_rows - 1
+}
+
+header_row :: proc(tbl: ^Table) -> int {
+	return 0 if tbl.has_header_row else -1
+}
+
+first_row :: proc(tbl: ^Table) -> int {
+	return header_row(tbl)+1 if tbl.has_header_row else 0
+}
+
+build :: proc(tbl: ^Table) {
+	tbl.dirty = false
+
+	resize(&tbl.colw, tbl.nr_cols)
+	mem.zero_slice(tbl.colw[:])
+
+	for row in 0..<tbl.nr_rows {
+		for col in 0..<tbl.nr_cols {
+			cell := get_cell(tbl, row, col)
+			if w := len(cell.text) + tbl.lpad + tbl.rpad; w > tbl.colw[col] {
+				tbl.colw[col] = w
+			}
+		}
+	}
+
+	colw_sum := 0
+	for v in tbl.colw {
+		colw_sum += v
+	}
+
+	tbl.tblw = max(colw_sum, len(tbl.caption) + tbl.lpad + tbl.rpad)
+
+	// Resize columns to match total width of table
+	remain := tbl.tblw-colw_sum
+	for col := 0; remain > 0; col = (col + 1) % tbl.nr_cols {
+		tbl.colw[col] += 1
+		remain -= 1
+	}
+
+	return
+}
+
+write_html_table :: proc(w: io.Writer, tbl: ^Table) {
+	if tbl.dirty {
+		build(tbl)
+	}
+
+	io.write_string(w, "<table>\n")
+	if tbl.caption != "" {
+		io.write_string(w, "<caption>")
+		io.write_string(w, tbl.caption)
+		io.write_string(w, "</caption>\n")
+	}
+
+	align_attribute :: proc(cell: ^Cell) -> string {
+		switch cell.alignment {
+		case .Left:   return ` align="left"`
+		case .Center: return ` align="center"`
+		case .Right:  return ` align="right"`
+		}
+		unreachable()
+	}
+
+	if tbl.has_header_row {
+		io.write_string(w, "<thead>\n")
+		io.write_string(w, "  <tr>\n")
+		for col in 0..<tbl.nr_cols {
+			cell := get_cell(tbl, header_row(tbl), col)
+			io.write_string(w, "    <th")
+			io.write_string(w, align_attribute(cell))
+			io.write_string(w, ">")
+			io.write_string(w, cell.text)
+			io.write_string(w, "</th>\n")
+		}
+		io.write_string(w, "  </tr>\n")
+		io.write_string(w, "</thead>\n")
+	}
+
+	io.write_string(w, "<tbody>\n")
+	for row in 0..<tbl.nr_rows {
+		if tbl.has_header_row && row == header_row(tbl) {
+			continue
+		}
+		io.write_string(w, "  <tr>\n")
+		for col in 0..<tbl.nr_cols {
+			cell := get_cell(tbl, row, col)
+			io.write_string(w, "    <td")
+			io.write_string(w, align_attribute(cell))
+			io.write_string(w, ">")
+			io.write_string(w, cell.text)
+			io.write_string(w, "</td>\n")
+		}
+		io.write_string(w, "  </tr>\n")
+	}
+	io.write_string(w, "  </tbody>\n")
+
+	io.write_string(w, "</table>\n")
+}
+
+write_ascii_table :: proc(w: io.Writer, tbl: ^Table) {
+	if tbl.dirty {
+		build(tbl)
+	}
+
+	write_caption_separator :: proc(w: io.Writer, tbl: ^Table) {
+		io.write_byte(w, '+')
+		write_byte_repeat(w, tbl.tblw + tbl.nr_cols - 1, '-')
+		io.write_byte(w, '+')
+		io.write_byte(w, '\n')
+	}
+
+	write_table_separator :: proc(w: io.Writer, tbl: ^Table) {
+		for col in 0..<tbl.nr_cols {
+			if col == 0 {
+				io.write_byte(w, '+')
+			}
+			write_byte_repeat(w, tbl.colw[col], '-')
+			io.write_byte(w, '+')
+		}
+		io.write_byte(w, '\n')
+	}
+
+	if tbl.caption != "" {
+		write_caption_separator(w, tbl)
+		io.write_byte(w, '|')
+		write_text_align(w, tbl.tblw -  tbl.lpad - tbl.rpad + tbl.nr_cols - 1,
+		                 tbl.lpad, tbl.rpad, tbl.caption, .Center)
+		io.write_byte(w, '|')
+		io.write_byte(w, '\n')
+	}
+
+	write_table_separator(w, tbl)
+	for row in 0..<tbl.nr_rows {
+		for col in 0..<tbl.nr_cols {
+			if col == 0 {
+				io.write_byte(w, '|')
+			}
+			write_table_cell(w, tbl, row, col)
+			io.write_byte(w, '|')
+		}
+		io.write_byte(w, '\n')
+		if tbl.has_header_row && row == header_row(tbl) {
+			write_table_separator(w, tbl)
+		}
+	}
+	write_table_separator(w, tbl)
+}
+
+// Renders table according to GitHub Flavored Markdown (GFM) specification
+write_markdown_table :: proc(w: io.Writer, tbl: ^Table) {
+	// NOTE(oskar): Captions or colspans are not supported by GFM as far as I can tell.
+
+	if tbl.dirty {
+		build(tbl)
+	}
+
+	for row in 0..<tbl.nr_rows {
+		for col in 0..<tbl.nr_cols {
+			cell := get_cell(tbl, row, col)
+			if col == 0 {
+				io.write_byte(w, '|')
+			}
+			write_text_align(w, tbl.colw[col] - tbl.lpad - tbl.rpad, tbl.lpad, tbl.rpad, cell.text,
+			                 .Center if tbl.has_header_row && row == header_row(tbl) else .Left)
+			io.write_string(w, "|")
+		}
+		io.write_byte(w, '\n')
+
+		if tbl.has_header_row && row == header_row(tbl) {
+			for col in 0..<tbl.nr_cols {
+				cell := get_cell(tbl, row, col)
+				if col == 0 {
+					io.write_byte(w, '|')
+				}
+				switch cell.alignment {
+				case .Left:
+					io.write_byte(w, ':')
+					write_byte_repeat(w, max(1, tbl.colw[col]-1), '-')
+				case .Center:
+					io.write_byte(w, ':')
+					write_byte_repeat(w, max(1, tbl.colw[col]-2), '-')
+					io.write_byte(w, ':')
+				case .Right:
+					write_byte_repeat(w, max(1, tbl.colw[col]-1), '-')
+					io.write_byte(w, ':')
+				}
+				io.write_byte(w, '|')
+			}
+			io.write_byte(w, '\n')
+		}
+	}
+}
+
+write_byte_repeat :: proc(w: io.Writer, n: int, b: byte) {
+	for _ in 0..<n {
+		io.write_byte(w, b)
+	}
+}
+
+write_table_cell :: proc(w: io.Writer, tbl: ^Table, row, col: int) {
+	if tbl.dirty {
+		build(tbl)
+	}
+	cell := get_cell(tbl, row, col)
+	write_text_align(w, tbl.colw[col]-tbl.lpad-tbl.rpad, tbl.lpad, tbl.rpad, cell.text, cell.alignment)
+}
+
+write_text_align :: proc(w: io.Writer, colw, lpad, rpad: int, text: string, alignment: Cell_Alignment) {
+	write_byte_repeat(w, lpad, ' ')
+	switch alignment {
+	case .Left:
+		io.write_string(w, text)
+		write_byte_repeat(w, colw - len(text), ' ')
+	case .Center:
+		pad := colw - len(text)
+		odd := pad & 1 != 0
+		write_byte_repeat(w, pad/2, ' ')
+		io.write_string(w, text)
+		write_byte_repeat(w, pad/2 + 1 if odd else pad/2, ' ')
+	case .Right:
+		write_byte_repeat(w, colw - len(text), ' ')
+		io.write_string(w, text)
+	}
+	write_byte_repeat(w, rpad, ' ')
+}

+ 13 - 0
core/text/table/utility.odin

@@ -0,0 +1,13 @@
+package text_table
+
+import "core:io"
+import "core:os"
+import "core:strings"
+
+stdio_writer :: proc() -> io.Writer {
+	return io.to_writer(os.stream_from_handle(os.stdout))
+}
+
+strings_builder_writer :: proc(b: ^strings.Builder) -> io.Writer {
+	return strings.to_writer(b)
+}

+ 14 - 5
examples/all/all_vendor.odin

@@ -1,7 +1,10 @@
 package all
 
 import botan      "vendor:botan"
+import cgltf      "vendor:cgltf"
+// import commonmark "vendor:commonmark"
 import ENet       "vendor:ENet"
+import exr        "vendor:OpenEXRCore"
 import ggpo       "vendor:ggpo"
 import gl         "vendor:OpenGL"
 import glfw       "vendor:glfw"
@@ -9,8 +12,7 @@ import microui    "vendor:microui"
 import miniaudio  "vendor:miniaudio"
 import PM         "vendor:portmidi"
 import rl         "vendor:raylib"
-import exr        "vendor:OpenEXRCore"
-import cgltf      "vendor:cgltf"
+import zlib       "vendor:zlib"
 
 import SDL        "vendor:sdl2"
 import SDLNet     "vendor:sdl2/net"
@@ -24,8 +26,14 @@ import NS         "vendor:darwin/Foundation"
 import MTL        "vendor:darwin/Metal"
 import CA         "vendor:darwin/QuartzCore"
 
+// NOTE(bill): only one can be checked at a time
+import lua_5_4    "vendor:lua/5.4"
+
 _ :: botan
+_ :: cgltf
+// _ :: commonmark
 _ :: ENet
+_ :: exr
 _ :: ggpo
 _ :: gl
 _ :: glfw
@@ -33,8 +41,7 @@ _ :: microui
 _ :: miniaudio
 _ :: PM
 _ :: rl
-_ :: exr
-_ :: cgltf
+_ :: zlib
 
 _ :: SDL
 _ :: SDLNet
@@ -46,4 +53,6 @@ _ :: vk
 
 _ :: NS
 _ :: MTL
-_ :: CA
+_ :: CA
+
+_ :: lua_5_4

+ 56 - 0
misc/remove_libraries_for_other_platforms.sh

@@ -0,0 +1,56 @@
+#!/bin/bash
+OS=$(uname)
+
+panic() {
+	printf "%s\n" "$1"
+	exit 1
+}
+
+assert_vendor() {
+	if [ $(basename $(pwd)) != 'vendor' ]; then
+		panic "Not in vendor directory!"
+	fi
+}
+
+remove_windows_libraries() {
+	find . -type f -name '*.dll' | xargs rm -f 
+	find . -type f -name '*.lib' | xargs rm -f
+	find . -type d -name 'windows' | xargs rm -rf
+}
+
+remove_macos_libraries() {
+	find . -type f -name '*.dylib' | xargs rm -f 
+	find . -type d -name '*macos*' | xargs rm -rf
+}
+
+remove_linux_libraries() {
+	find . -type f -name '*.so' | xargs rm -f 
+	find . -type d -name 'linux' | xargs rm -rf
+}
+
+case $OS in
+	Linux)
+		assert_vendor
+		remove_windows_libraries
+		remove_macos_libraries
+		;;
+	Darwin)
+		assert_vendor
+		remove_windows_libraries
+		remove_linux_libraries
+		;;
+	OpenBSD)
+		assert_vendor
+		remove_windows_libraries
+		remove_macos_libraries
+		remove_linux_libraries
+		;;
+	FreeBSD)
+		assert_vendor
+		remove_windows_libraries
+		remove_macos_libraries
+		remove_linux_libraries
+		;;
+*)
+	panic "Platform unsupported!"
+esac

+ 16 - 0
src/build_settings.cpp

@@ -7,6 +7,8 @@
 // #define DEFAULT_TO_THREADED_CHECKER
 // #endif
 
+#define DEFAULT_MAX_ERROR_COLLECTOR_COUNT (36)
+
 enum TargetOsKind : u16 {
 	TargetOs_Invalid,
 
@@ -313,6 +315,8 @@ struct BuildContext {
 	RelocMode reloc_mode;
 	bool   disable_red_zone;
 
+	isize max_error_count;
+
 
 	u32 cmd_doc_flags;
 	Array<String> extra_packages;
@@ -344,6 +348,14 @@ gb_internal bool global_ignore_warnings(void) {
 	return build_context.ignore_warnings;
 }
 
+gb_internal isize MAX_ERROR_COLLECTOR_COUNT(void) {
+	if (build_context.max_error_count <= 0) {
+		return DEFAULT_MAX_ERROR_COLLECTOR_COUNT;
+	}
+	return build_context.max_error_count;
+}
+
+
 
 gb_global TargetMetrics target_windows_i386 = {
 	TargetOs_windows,
@@ -1081,6 +1093,10 @@ gb_internal void init_build_context(TargetMetrics *cross_target) {
 	bc->ODIN_VERSION = ODIN_VERSION;
 	bc->ODIN_ROOT    = odin_root_dir();
 
+	if (bc->max_error_count <= 0) {
+		bc->max_error_count = DEFAULT_MAX_ERROR_COLLECTOR_COUNT;
+	}
+
 	{
 		char const *found = gb_get_env("ODIN_ERROR_POS_STYLE", permanent_allocator());
 		if (found) {

+ 5 - 5
src/error.cpp

@@ -14,8 +14,6 @@ struct ErrorCollector {
 
 gb_global ErrorCollector global_error_collector;
 
-#define MAX_ERROR_COLLECTOR_COUNT (36)
-
 
 gb_internal bool any_errors(void) {
 	return global_error_collector.count.load() != 0;
@@ -28,6 +26,8 @@ gb_internal void init_global_error_collector(void) {
 	array_init(&global_files,             heap_allocator(), 1, 4096);
 }
 
+gb_internal isize MAX_ERROR_COLLECTOR_COUNT(void);
+
 
 // temporary
 // defined in build_settings.cpp
@@ -356,7 +356,7 @@ gb_internal void error_va(TokenPos const &pos, TokenPos end, char const *fmt, va
 		show_error_on_line(pos, end);
 	}
 	mutex_unlock(&global_error_collector.mutex);
-	if (global_error_collector.count > MAX_ERROR_COLLECTOR_COUNT) {
+	if (global_error_collector.count > MAX_ERROR_COLLECTOR_COUNT()) {
 		gb_exit(1);
 	}
 }
@@ -407,7 +407,7 @@ gb_internal void error_no_newline_va(TokenPos const &pos, char const *fmt, va_li
 		error_out_va(fmt, va);
 	}
 	mutex_unlock(&global_error_collector.mutex);
-	if (global_error_collector.count > MAX_ERROR_COLLECTOR_COUNT) {
+	if (global_error_collector.count > MAX_ERROR_COLLECTOR_COUNT()) {
 		gb_exit(1);
 	}
 }
@@ -431,7 +431,7 @@ gb_internal void syntax_error_va(TokenPos const &pos, TokenPos end, char const *
 	}
 
 	mutex_unlock(&global_error_collector.mutex);
-	if (global_error_collector.count > MAX_ERROR_COLLECTOR_COUNT) {
+	if (global_error_collector.count > MAX_ERROR_COLLECTOR_COUNT()) {
 		gb_exit(1);
 	}
 }

+ 31 - 5
src/main.cpp

@@ -594,13 +594,13 @@ gb_internal Array<String> setup_args(int argc, char const **argv) {
 
 gb_internal void print_usage_line(i32 indent, char const *fmt, ...) {
 	while (indent --> 0) {
-		gb_printf_err("\t");
+		gb_printf("\t");
 	}
 	va_list va;
 	va_start(va, fmt);
-	gb_printf_err_va(fmt, va);
+	gb_printf_va(fmt, va);
 	va_end(va);
-	gb_printf_err("\n");
+	gb_printf("\n");
 }
 
 gb_internal void usage(String argv0) {
@@ -691,6 +691,7 @@ enum BuildFlagKind {
 	BuildFlag_TerseErrors,
 	BuildFlag_VerboseErrors,
 	BuildFlag_ErrorPosStyle,
+	BuildFlag_MaxErrorCount,
 
 	// internal use only
 	BuildFlag_InternalIgnoreLazy,
@@ -866,6 +867,7 @@ gb_internal bool parse_build_flags(Array<String> args) {
 	add_flag(&build_flags, BuildFlag_TerseErrors,             str_lit("terse-errors"),              BuildFlagParam_None,    Command_all);
 	add_flag(&build_flags, BuildFlag_VerboseErrors,           str_lit("verbose-errors"),            BuildFlagParam_None,    Command_all);
 	add_flag(&build_flags, BuildFlag_ErrorPosStyle,           str_lit("error-pos-style"),           BuildFlagParam_String,  Command_all);
+	add_flag(&build_flags, BuildFlag_MaxErrorCount,           str_lit("max-error-count"),           BuildFlagParam_Integer, Command_all);
 
 	add_flag(&build_flags, BuildFlag_InternalIgnoreLazy,      str_lit("internal-ignore-lazy"),      BuildFlagParam_None,    Command_all);
 	add_flag(&build_flags, BuildFlag_InternalIgnoreLLVMBuild, str_lit("internal-ignore-llvm-build"),BuildFlagParam_None,    Command_all);
@@ -1522,6 +1524,17 @@ gb_internal bool parse_build_flags(Array<String> args) {
 							}
 							break;
 
+						case BuildFlag_MaxErrorCount: {
+							i64 count = big_int_to_i64(&value.value_integer);
+							if (count <= 0) {
+								gb_printf_err("-%.*s must be greater than 0", LIT(bf.name));
+								bad_flags = true;
+							} else {
+								build_context.max_error_count = cast(isize)count;
+							}
+							break;
+						}
+
 						case BuildFlag_InternalIgnoreLazy:
 							build_context.ignore_lazy = true;
 							break;
@@ -2212,8 +2225,21 @@ gb_internal void print_show_help(String const arg0, String const &command) {
 		print_usage_line(2, "Treats warning messages as error messages");
 		print_usage_line(0, "");
 
-		print_usage_line(1, "-verbose-errors");
-		print_usage_line(2, "Prints verbose error messages showing the code on that line and the location in that line");
+		print_usage_line(1, "-terse-errors");
+		print_usage_line(2, "Prints a terse error message without showing the code on that line and the location in that line");
+		print_usage_line(0, "");
+
+		print_usage_line(1, "-error-pos-style:<string>");
+		print_usage_line(2, "Options are 'unix', 'odin' and 'default' (odin)");
+		print_usage_line(2, "'odin'    file/path(45:3)");
+		print_usage_line(2, "'unix'    file/path:45:3:");
+		print_usage_line(0, "");
+
+
+		print_usage_line(1, "-max-error-count:<integer>");
+		print_usage_line(2, "Set the maximum number of errors that can be displayed before the compiler terminates");
+		print_usage_line(2, "Must be an integer >0");
+		print_usage_line(2, "If not set, the default max error count is %d", DEFAULT_MAX_ERROR_COLLECTOR_COUNT);
 		print_usage_line(0, "");
 
 		print_usage_line(1, "-foreign-error-procedures");

+ 5 - 3
src/parser.cpp

@@ -3693,9 +3693,11 @@ gb_internal bool allow_field_separator(AstFile *f) {
 	if (allow_token(f, Token_Comma)) {
 		return true;
 	}
-	if (ALLOW_NEWLINE && token.kind == Token_Semicolon && !token_is_newline(token)) {
-		String p = token_to_string(token);
-		syntax_error(token_end_of_line(f, f->prev_token), "Expected a comma, got a %.*s", LIT(p));
+	if (ALLOW_NEWLINE && token.kind == Token_Semicolon) {
+		if (!token_is_newline(token)) {
+			String p = token_to_string(token);
+			syntax_error(token_end_of_line(f, f->prev_token), "Expected a comma, got a %.*s", LIT(p));
+		}
 		advance_token(f);
 		return true;
 	}

+ 19 - 24
tests/core/build.bat

@@ -6,87 +6,82 @@ python3 download_assets.py
 echo ---
 echo Running core:image tests
 echo ---
-%PATH_TO_ODIN% run image    %COMMON% -out:test_core_image.exe
+%PATH_TO_ODIN% run image    %COMMON% -out:test_core_image.exe || exit /b
 
 echo ---
 echo Running core:compress tests
 echo ---
-%PATH_TO_ODIN% run compress %COMMON% -out:test_core_compress.exe
+%PATH_TO_ODIN% run compress %COMMON% -out:test_core_compress.exe || exit /b
 
 echo ---
 echo Running core:strings tests
 echo ---
-%PATH_TO_ODIN% run strings %COMMON% -out:test_core_strings.exe
+%PATH_TO_ODIN% run strings %COMMON% -out:test_core_strings.exe || exit /b
 
 echo ---
 echo Running core:hash tests
 echo ---
-%PATH_TO_ODIN% run hash %COMMON% -o:size -out:test_core_hash.exe
+%PATH_TO_ODIN% run hash %COMMON% -o:size -out:test_core_hash.exe || exit /b
 
 echo ---
 echo Running core:odin tests
 echo ---
-%PATH_TO_ODIN% run odin %COMMON% -o:size -out:test_core_odin.exe
+%PATH_TO_ODIN% run odin %COMMON% -o:size -out:test_core_odin.exe || exit /b
 
 echo ---
 echo Running core:crypto hash tests
 echo ---
-%PATH_TO_ODIN% run crypto %COMMON% -out:test_crypto_hash.exe
+%PATH_TO_ODIN% run crypto %COMMON% -out:test_crypto_hash.exe || exit /b
 
 echo ---
 echo Running core:encoding tests
 echo ---
-%PATH_TO_ODIN% run encoding/hxa    %COMMON% %COLLECTION% -out:test_hxa.exe
-%PATH_TO_ODIN% run encoding/json   %COMMON% -out:test_json.exe
-%PATH_TO_ODIN% run encoding/varint %COMMON% -out:test_varint.exe
-%PATH_TO_ODIN% run encoding/xml    %COMMON% -out:test_xml.exe
+%PATH_TO_ODIN% run encoding/hxa    %COMMON% %COLLECTION% -out:test_hxa.exe || exit /b
+%PATH_TO_ODIN% run encoding/json   %COMMON% -out:test_json.exe || exit /b
+%PATH_TO_ODIN% run encoding/varint %COMMON% -out:test_varint.exe || exit /b
+%PATH_TO_ODIN% run encoding/xml    %COMMON% -out:test_xml.exe || exit /b
 
 echo ---
 echo Running core:math/noise tests
 echo ---
-%PATH_TO_ODIN% run math/noise %COMMON% -out:test_noise.exe
+%PATH_TO_ODIN% run math/noise %COMMON% -out:test_noise.exe || exit /b
 
 echo ---
 echo Running core:math tests
 echo ---
-%PATH_TO_ODIN% run math %COMMON% %COLLECTION% -out:test_core_math.exe
+%PATH_TO_ODIN% run math %COMMON% %COLLECTION% -out:test_core_math.exe || exit /b
 
 echo ---
 echo Running core:math/linalg/glsl tests
 echo ---
-%PATH_TO_ODIN% run math/linalg/glsl %COMMON% %COLLECTION% -out:test_linalg_glsl.exe
+%PATH_TO_ODIN% run math/linalg/glsl %COMMON% %COLLECTION% -out:test_linalg_glsl.exe || exit /b
 
 echo ---
 echo Running core:path/filepath tests
 echo ---
-%PATH_TO_ODIN% run path/filepath %COMMON% %COLLECTION% -out:test_core_filepath.exe
+%PATH_TO_ODIN% run path/filepath %COMMON% %COLLECTION% -out:test_core_filepath.exe || exit /b
 
 echo ---
 echo Running core:reflect tests
 echo ---
-%PATH_TO_ODIN% run reflect %COMMON% %COLLECTION% -out:test_core_reflect.exe
+%PATH_TO_ODIN% run reflect %COMMON% %COLLECTION% -out:test_core_reflect.exe || exit /b
 
 echo ---
 echo Running core:text/i18n tests
 echo ---
-%PATH_TO_ODIN% run text\i18n %COMMON% -out:test_core_i18n.exe
+%PATH_TO_ODIN% run text\i18n %COMMON% -out:test_core_i18n.exe || exit /b
 
 echo ---
 echo Running core:net
 echo ---
-%PATH_TO_ODIN% run net %COMMON% -out:test_core_net.exe
-
-echo ---
-echo Running core:text/lua tests
-echo ---
-%PATH_TO_ODIN% run text\lua %COMMON% -out:test_core_lua_strlib.exe
+%PATH_TO_ODIN% run net %COMMON% -out:test_core_net.exe || exit /b
 
 echo ---
 echo Running core:slice tests
 echo ---
-%PATH_TO_ODIN% run slice %COMMON% -out:test_core_slice.exe
+%PATH_TO_ODIN% run slice %COMMON% -out:test_core_slice.exe || exit /b
 
 echo ---
 echo Running core:container tests
 echo ---
-%PATH_TO_ODIN% run container %COMMON% %COLLECTION% -out:test_core_container.exe
+%PATH_TO_ODIN% run container %COMMON% %COLLECTION% -out:test_core_container.exe || exit /b

+ 7 - 0
tests/core/compress/test_core_compress.odin

@@ -151,6 +151,13 @@ shoco_test :: proc(t: ^testing.T) {
 	}
 
 	for v in Shoco_Tests {
+		when ODIN_OS == .Windows {
+			v := v
+			// Compressed source files are not encoded with carriage returns but git replaces raw files lf with crlf on commit (on windows only)
+			// So replace crlf with lf on windows
+			v.raw, _ = bytes.replace_all(v.raw, { 0xD, 0xA }, { 0xA })
+		}
+
 		expected_raw        := len(v.raw)
 		expected_compressed := len(v.compressed)
 

+ 13 - 0
tests/documentation/build.bat

@@ -0,0 +1,13 @@
+@echo off
+set PATH_TO_ODIN==..\..\odin
+
+echo ---
+echo Building Documentation File
+echo ---
+%PATH_TO_ODIN% doc ..\..\examples\all -all-packages -doc-format || exit /b
+
+
+echo ---
+echo Running Documentation Tester
+echo ---
+%PATH_TO_ODIN% run documentation_tester.odin -file -vet -strict-style -- %PATH_TO_ODIN% || exit /b

+ 421 - 0
tests/documentation/documentation_tester.odin

@@ -0,0 +1,421 @@
+package documentation_tester
+
+import "core:os"
+import "core:io"
+import "core:fmt"
+import "core:strings"
+import "core:odin/ast"
+import "core:odin/parser"
+import "core:c/libc"
+import doc "core:odin/doc-format"
+
+Example_Test :: struct {
+	entity_name: string,
+	package_name: string,
+	example_code: []string,
+	expected_output: []string,
+}
+
+g_header:   ^doc.Header
+g_bad_doc: bool
+g_examples_to_verify: [dynamic]Example_Test
+g_path_to_odin: string
+
+array :: proc(a: $A/doc.Array($T)) -> []T {
+	return doc.from_array(g_header, a)
+}
+
+str :: proc(s: $A/doc.String) -> string {
+	return doc.from_string(g_header, s)
+}
+
+common_prefix :: proc(strs: []string) -> string {
+	if len(strs) == 0 {
+		return ""
+	}
+	n := max(int)
+	for str in strs {
+		n = min(n, len(str))
+	}
+
+	prefix := strs[0][:n]
+	for str in strs[1:] {
+		for len(prefix) != 0 && str[:len(prefix)] != prefix {
+			prefix = prefix[:len(prefix)-1]
+		}
+		if len(prefix) == 0 {
+			break
+		}
+	}
+	return prefix
+}
+
+errorf :: proc(format: string, args: ..any) -> ! {
+	fmt.eprintf("%s ", os.args[0])
+	fmt.eprintf(format, ..args)
+	fmt.eprintln()
+	os.exit(1)
+}
+
+main :: proc() {
+	if len(os.args) != 2 {
+		errorf("expected path to odin executable")
+	}
+	g_path_to_odin = os.args[1]
+	data, ok := os.read_entire_file("all.odin-doc")
+	if !ok {
+		errorf("unable to read file: all.odin-doc")
+	}
+	err: doc.Reader_Error
+	g_header, err = doc.read_from_bytes(data)
+	switch err {
+	case .None:
+	case .Header_Too_Small:
+		errorf("file is too small for the file format")
+	case .Invalid_Magic:
+		errorf("invalid magic for the file format")
+	case .Data_Too_Small:
+		errorf("data is too small for the file format")
+	case .Invalid_Version:
+		errorf("invalid file format version")
+	}
+	pkgs     := array(g_header.pkgs)
+	entities := array(g_header.entities)
+
+	path_prefix: string
+	{
+		fullpaths: [dynamic]string
+		defer delete(fullpaths)
+
+		for pkg in pkgs[1:] {
+			append(&fullpaths, str(pkg.fullpath))
+		}
+		path_prefix = common_prefix(fullpaths[:])
+	}
+
+	for pkg in pkgs[1:] {
+		entries_array := array(pkg.entries)
+		fullpath := str(pkg.fullpath)
+		path := strings.trim_prefix(fullpath, path_prefix)
+		if ! strings.has_prefix(path, "core/") {
+			continue
+		}
+		trimmed_path := strings.trim_prefix(path, "core/")
+		if strings.has_prefix(trimmed_path, "sys") {
+			continue
+		}
+		if strings.contains(trimmed_path, "/_") {
+			continue
+		}
+		for entry in entries_array {
+			entity := entities[entry.entity]
+			find_and_add_examples(
+				docs = str(entity.docs),
+				package_name = str(pkg.name),
+				entity_name = str(entity.name),
+			)
+		}
+	}
+	write_test_suite(g_examples_to_verify[:])
+	if g_bad_doc {
+		errorf("We created bad documentation!")
+	}
+
+	if ! run_test_suite() {
+		errorf("Test suite failed!")
+	}
+	fmt.println("Examples verified")
+}
+
+// NOTE: this is a pretty close copy paste from the website pkg documentation on parsing the docs
+find_and_add_examples :: proc(docs: string, package_name: string, entity_name: string) {
+	if docs == "" {
+		return
+	}
+	Block_Kind :: enum {
+		Other,
+		Example,
+		Output,
+	}
+	Block :: struct {
+		kind: Block_Kind,
+		lines: []string,
+	}
+	lines := strings.split_lines(docs)
+	curr_block_kind := Block_Kind.Other
+	start := 0
+
+	example_block: Block // when set the kind should be Example
+	output_block: Block // when set the kind should be Output
+	// rely on zii that the kinds have not been set
+	assert(example_block.kind != .Example)
+	assert(output_block.kind != .Output)
+
+	insert_block :: proc(block: Block, example: ^Block, output: ^Block, name: string) {
+		switch block.kind {
+		case .Other:
+		case .Example:
+			if example.kind == .Example {
+				fmt.eprintf("The documentation for %q has multiple examples which is not allowed\n", name)
+				g_bad_doc = true
+			}
+			example^ = block
+		case .Output: output^ = block
+			if example.kind == .Output {
+				fmt.eprintf("The documentation for %q has multiple output which is not allowed\n", name)
+				g_bad_doc = true
+			}
+			output^ = block
+		}
+	}
+
+	for line, i in lines {
+		text := strings.trim_space(line)
+		next_block_kind := curr_block_kind
+
+		switch curr_block_kind {
+		case .Other:
+			switch {
+			case strings.has_prefix(line, "Example:"): next_block_kind = .Example
+			case strings.has_prefix(line, "Output:"): next_block_kind = .Output
+			}
+		case .Example:
+			switch {
+			case strings.has_prefix(line, "Output:"): next_block_kind = .Output
+			case ! (text == "" || strings.has_prefix(line, "\t")): next_block_kind = .Other
+			}
+		case .Output:
+			switch {
+			case strings.has_prefix(line, "Example:"): next_block_kind = .Example
+			case ! (text == "" || strings.has_prefix(line, "\t")): next_block_kind = .Other
+			}
+		}
+
+		if i-start > 0 && (curr_block_kind != next_block_kind) {
+			insert_block(Block{curr_block_kind, lines[start:i]}, &example_block, &output_block, entity_name)
+			curr_block_kind, start = next_block_kind, i
+		}
+	}
+
+	if start < len(lines) {
+		insert_block(Block{curr_block_kind, lines[start:]}, &example_block, &output_block, entity_name)
+	}
+
+	if output_block.kind == .Output && example_block.kind != .Example {
+		fmt.eprintf("The documentation for %q has an output block but no example\n", entity_name)
+		g_bad_doc = true
+	}
+
+	// Write example and output block if they're both present
+	if example_block.kind == .Example && output_block.kind == .Output {
+		{
+			// Example block starts with
+			// `Example:` and a number of white spaces,
+			lines := &example_block.lines
+			for len(lines) > 0 && (strings.trim_space(lines[0]) == "" || strings.has_prefix(lines[0], "Example:")) {
+				lines^ = lines[1:]
+			}
+		}
+		{
+			// Output block starts with
+			// `Output:` and a number of white spaces,
+			lines := &output_block.lines
+			for len(lines) > 0 && (strings.trim_space(lines[0]) == "" || strings.has_prefix(lines[0], "Output:")) {
+				lines^ = lines[1:]
+			}
+			// Additionally we need to strip all empty lines at the end of output to not include those in the expected output
+			for len(lines) > 0 && (strings.trim_space(lines[len(lines) - 1]) == "") {
+				lines^ = lines[:len(lines) - 1]
+			}
+		}
+		// Remove first layer of tabs which are always present
+		for line in &example_block.lines {
+			line = strings.trim_prefix(line, "\t")
+		}
+		for line in &output_block.lines {
+			line = strings.trim_prefix(line, "\t")
+		}
+		append(&g_examples_to_verify, Example_Test {
+			entity_name = entity_name,
+			package_name = package_name,
+			example_code = example_block.lines,
+			expected_output = output_block.lines,
+		})
+	}
+}
+
+
+write_test_suite :: proc(example_tests: []Example_Test) {
+	TEST_SUITE_DIRECTORY :: "verify"
+	os.remove_directory(TEST_SUITE_DIRECTORY)
+	os.make_directory(TEST_SUITE_DIRECTORY)
+
+	example_build := strings.builder_make()
+	test_runner := strings.builder_make()
+
+	strings.write_string(&test_runner,
+`//+private
+package documentation_verification
+
+import "core:os"
+import "core:mem"
+import "core:io"
+import "core:fmt"
+import "core:thread"
+import "core:sync"
+import "core:intrinsics"
+
+@(private="file")
+_read_pipe: os.Handle
+@(private="file")
+_write_pipe: os.Handle
+@(private="file")
+_pipe_reader_semaphore: sync.Sema
+@(private="file")
+_out_data: string
+@(private="file")
+_out_buffer: [mem.Megabyte]byte
+@(private="file")
+_bad_test_found: bool
+
+@(private="file")
+_spawn_pipe_reader :: proc() {
+	thread.create_and_start(proc(^thread.Thread) {
+		stream := os.stream_from_handle(_read_pipe)
+		reader := io.to_reader(stream)
+		sync.post(&_pipe_reader_semaphore) // notify thread is ready
+		for {
+			n_read := 0
+			read_to_null_byte := 0
+			finished_reading := false
+			for ! finished_reading {
+				just_read, err := io.read(reader, _out_buffer[n_read:], &n_read); if err != .None {
+					panic("We got an IO error!")
+				}
+				for b in _out_buffer[n_read - just_read: n_read] {
+					if b == 0 {
+						finished_reading = true
+						break
+					}
+				read_to_null_byte += 1
+				}
+			}
+			intrinsics.volatile_store(&_out_data, transmute(string)_out_buffer[:read_to_null_byte])
+			sync.post(&_pipe_reader_semaphore) // notify we read the null byte
+		}
+	})
+
+	sync.wait(&_pipe_reader_semaphore) // wait for thread to be ready
+}
+
+@(private="file")
+_check :: proc(test_name: string, expected: string) {
+	null_byte: [1]byte
+	os.write(_write_pipe, null_byte[:])
+	os.flush(_write_pipe)
+	sync.wait(&_pipe_reader_semaphore)
+	output := intrinsics.volatile_load(&_out_data) // wait for thread to read null byte
+	if expected != output {
+		fmt.eprintf("Test %q got unexpected output:\n%q\n", test_name, output)
+		fmt.eprintf("Expected:\n%q\n", expected)
+		_bad_test_found = true
+	}
+}
+
+main :: proc() {
+	_read_pipe, _write_pipe, _ = os.pipe()
+	os.stdout = _write_pipe
+	_spawn_pipe_reader()
+`)
+	for test in example_tests {
+		strings.builder_reset(&example_build)
+		strings.write_string(&example_build, "package documentation_verification\n\n")
+		for line in test.example_code {
+			strings.write_string(&example_build, line)
+			strings.write_byte(&example_build, '\n')
+		}
+
+		code_string := strings.to_string(example_build)
+
+		example_ast := ast.File { src = code_string }
+		odin_parser := parser.default_parser()
+
+		if ! parser.parse_file(&odin_parser, &example_ast) {
+			g_bad_doc = true
+			continue
+		}
+		if odin_parser.error_count > 0 {
+			fmt.eprintf("Errors on the following code generated for %q:\n%v\n", test.entity_name, code_string)
+			g_bad_doc = true
+			continue
+		}
+
+		enforced_name := fmt.tprintf("%v_example", test.entity_name)
+		index_of_proc_name: int
+		code_test_name: string
+
+		for d in example_ast.decls {
+			value_decl, is_value := d.derived.(^ast.Value_Decl); if ! is_value {
+				continue
+			}
+			if len(value_decl.values) != 1 {
+				continue
+			}
+			proc_lit, is_proc_lit := value_decl.values[0].derived_expr.(^ast.Proc_Lit); if ! is_proc_lit {
+				continue
+			}
+			if len(proc_lit.type.params.list) > 0 {
+				continue
+			}
+			this_procedure_name := code_string[value_decl.names[0].pos.offset:value_decl.names[0].end.offset]
+			if this_procedure_name != enforced_name {
+				continue
+			}
+			index_of_proc_name = value_decl.names[0].pos.offset
+			code_test_name = this_procedure_name
+			break
+		}
+
+		if code_test_name == "" {
+			fmt.eprintf("We could not any find procedure literals with no arguments with the identifier %q for the example for %q\n", enforced_name, test.entity_name)
+			g_bad_doc = true
+			continue
+		}
+
+		fmt.sbprintf(&test_runner, "\t%v_%v()\n", test.package_name, code_test_name)
+		fmt.sbprintf(&test_runner, "\t_check(%q, `", code_test_name)
+		for line in test.expected_output {
+			strings.write_string(&test_runner, line)
+			strings.write_string(&test_runner, "\n")
+		}
+		strings.write_string(&test_runner, "`)\n")
+		save_path := fmt.tprintf("verify/test_%v_%v.odin", test.package_name, code_test_name)
+
+		test_file_handle, err := os.open(save_path, os.O_WRONLY | os.O_CREATE); if err != 0 {
+			fmt.eprintf("We could not open the file to the path %q for writing\n", save_path)
+			g_bad_doc = true
+			continue
+		}
+		defer os.close(test_file_handle)
+		stream := os.stream_from_handle(test_file_handle)
+		writer, ok := io.to_writer(stream); if ! ok {
+			fmt.eprintf("We could not make the writer for the path %q\n", save_path)
+			g_bad_doc = true
+			continue
+		}
+		fmt.wprintf(writer, "%v%v_%v", code_string[:index_of_proc_name], test.package_name, code_string[index_of_proc_name:])
+	}
+
+	strings.write_string(&test_runner,
+`
+	if _bad_test_found {
+		fmt.eprintln("One or more tests failed")
+		os.exit(1)
+	}
+}`)
+	os.write_entire_file("verify/main.odin", transmute([]byte)strings.to_string(test_runner))
+}
+
+run_test_suite :: proc() -> bool {
+	return libc.system(fmt.caprintf("%v run verify", g_path_to_odin)) == 0
+}

+ 1 - 1
tests/internal/build.bat

@@ -1,4 +1,4 @@
 @echo off
 set PATH_TO_ODIN==..\..\odin
-%PATH_TO_ODIN% run test_map.odin -file -vet -strict-style -o:minimal
+%PATH_TO_ODIN% run test_map.odin -file -vet -strict-style -o:minimal || exit /b
 rem -define:SEED=42

+ 4 - 9
tests/issues/run.bat

@@ -5,19 +5,14 @@ pushd build
 
 set COMMON=-collection:tests=..\..
 
-set ERROR_DID_OCCUR=0
-
 @echo on
 
-..\..\..\odin test ..\test_issue_829.odin %COMMON% -file
-..\..\..\odin test ..\test_issue_1592.odin %COMMON% -file
-..\..\..\odin test ..\test_issue_2087.odin %COMMON% -file
-..\..\..\odin build ..\test_issue_2113.odin %COMMON% -file -debug
+..\..\..\odin test ..\test_issue_829.odin %COMMON% -file || exit /b
+..\..\..\odin test ..\test_issue_1592.odin %COMMON% -file || exit /b
+..\..\..\odin test ..\test_issue_2087.odin %COMMON% -file || exit /b
+..\..\..\odin build ..\test_issue_2113.odin %COMMON% -file -debug || exit /b
 
 @echo off
 
-if %ERRORLEVEL% NEQ 0 set ERROR_DID_OCCUR=1
-
 popd
 rmdir /S /Q build
-if %ERROR_DID_OCCUR% NEQ 0 EXIT /B 1

+ 2 - 2
tests/vendor/build.bat

@@ -5,9 +5,9 @@ set PATH_TO_ODIN==..\..\odin
 echo ---
 echo Running vendor:botan tests
 echo ---
-%PATH_TO_ODIN% run botan %COMMON% -out:vendor_botan.exe
+%PATH_TO_ODIN% run botan %COMMON% -out:vendor_botan.exe || exit /b
 
 echo ---
 echo Running vendor:glfw tests
 echo ---
-%PATH_TO_ODIN% run glfw %COMMON% -out:vendor_glfw.exe
+%PATH_TO_ODIN% run glfw %COMMON% -out:vendor_glfw.exe || exit /b

+ 174 - 0
vendor/lua/5.1/include/lauxlib.h

@@ -0,0 +1,174 @@
+/*
+** $Id: lauxlib.h,v 1.88.1.1 2007/12/27 13:02:25 roberto Exp $
+** Auxiliary functions for building Lua libraries
+** See Copyright Notice in lua.h
+*/
+
+
+#ifndef lauxlib_h
+#define lauxlib_h
+
+
+#include <stddef.h>
+#include <stdio.h>
+
+#include "lua.h"
+
+
+#if defined(LUA_COMPAT_GETN)
+LUALIB_API int (luaL_getn) (lua_State *L, int t);
+LUALIB_API void (luaL_setn) (lua_State *L, int t, int n);
+#else
+#define luaL_getn(L,i)          ((int)lua_objlen(L, i))
+#define luaL_setn(L,i,j)        ((void)0)  /* no op! */
+#endif
+
+#if defined(LUA_COMPAT_OPENLIB)
+#define luaI_openlib	luaL_openlib
+#endif
+
+
+/* extra error code for `luaL_load' */
+#define LUA_ERRFILE     (LUA_ERRERR+1)
+
+
+typedef struct luaL_Reg {
+  const char *name;
+  lua_CFunction func;
+} luaL_Reg;
+
+
+
+LUALIB_API void (luaI_openlib) (lua_State *L, const char *libname,
+                                const luaL_Reg *l, int nup);
+LUALIB_API void (luaL_register) (lua_State *L, const char *libname,
+                                const luaL_Reg *l);
+LUALIB_API int (luaL_getmetafield) (lua_State *L, int obj, const char *e);
+LUALIB_API int (luaL_callmeta) (lua_State *L, int obj, const char *e);
+LUALIB_API int (luaL_typerror) (lua_State *L, int narg, const char *tname);
+LUALIB_API int (luaL_argerror) (lua_State *L, int numarg, const char *extramsg);
+LUALIB_API const char *(luaL_checklstring) (lua_State *L, int numArg,
+                                                          size_t *l);
+LUALIB_API const char *(luaL_optlstring) (lua_State *L, int numArg,
+                                          const char *def, size_t *l);
+LUALIB_API lua_Number (luaL_checknumber) (lua_State *L, int numArg);
+LUALIB_API lua_Number (luaL_optnumber) (lua_State *L, int nArg, lua_Number def);
+
+LUALIB_API lua_Integer (luaL_checkinteger) (lua_State *L, int numArg);
+LUALIB_API lua_Integer (luaL_optinteger) (lua_State *L, int nArg,
+                                          lua_Integer def);
+
+LUALIB_API void (luaL_checkstack) (lua_State *L, int sz, const char *msg);
+LUALIB_API void (luaL_checktype) (lua_State *L, int narg, int t);
+LUALIB_API void (luaL_checkany) (lua_State *L, int narg);
+
+LUALIB_API int   (luaL_newmetatable) (lua_State *L, const char *tname);
+LUALIB_API void *(luaL_checkudata) (lua_State *L, int ud, const char *tname);
+
+LUALIB_API void (luaL_where) (lua_State *L, int lvl);
+LUALIB_API int (luaL_error) (lua_State *L, const char *fmt, ...);
+
+LUALIB_API int (luaL_checkoption) (lua_State *L, int narg, const char *def,
+                                   const char *const lst[]);
+
+LUALIB_API int (luaL_ref) (lua_State *L, int t);
+LUALIB_API void (luaL_unref) (lua_State *L, int t, int ref);
+
+LUALIB_API int (luaL_loadfile) (lua_State *L, const char *filename);
+LUALIB_API int (luaL_loadbuffer) (lua_State *L, const char *buff, size_t sz,
+                                  const char *name);
+LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s);
+
+LUALIB_API lua_State *(luaL_newstate) (void);
+
+
+LUALIB_API const char *(luaL_gsub) (lua_State *L, const char *s, const char *p,
+                                                  const char *r);
+
+LUALIB_API const char *(luaL_findtable) (lua_State *L, int idx,
+                                         const char *fname, int szhint);
+
+
+
+
+/*
+** ===============================================================
+** some useful macros
+** ===============================================================
+*/
+
+#define luaL_argcheck(L, cond,numarg,extramsg)	\
+		((void)((cond) || luaL_argerror(L, (numarg), (extramsg))))
+#define luaL_checkstring(L,n)	(luaL_checklstring(L, (n), NULL))
+#define luaL_optstring(L,n,d)	(luaL_optlstring(L, (n), (d), NULL))
+#define luaL_checkint(L,n)	((int)luaL_checkinteger(L, (n)))
+#define luaL_optint(L,n,d)	((int)luaL_optinteger(L, (n), (d)))
+#define luaL_checklong(L,n)	((long)luaL_checkinteger(L, (n)))
+#define luaL_optlong(L,n,d)	((long)luaL_optinteger(L, (n), (d)))
+
+#define luaL_typename(L,i)	lua_typename(L, lua_type(L,(i)))
+
+#define luaL_dofile(L, fn) \
+	(luaL_loadfile(L, fn) || lua_pcall(L, 0, LUA_MULTRET, 0))
+
+#define luaL_dostring(L, s) \
+	(luaL_loadstring(L, s) || lua_pcall(L, 0, LUA_MULTRET, 0))
+
+#define luaL_getmetatable(L,n)	(lua_getfield(L, LUA_REGISTRYINDEX, (n)))
+
+#define luaL_opt(L,f,n,d)	(lua_isnoneornil(L,(n)) ? (d) : f(L,(n)))
+
+/*
+** {======================================================
+** Generic Buffer manipulation
+** =======================================================
+*/
+
+
+
+typedef struct luaL_Buffer {
+  char *p;			/* current position in buffer */
+  int lvl;  /* number of strings in the stack (level) */
+  lua_State *L;
+  char buffer[LUAL_BUFFERSIZE];
+} luaL_Buffer;
+
+#define luaL_addchar(B,c) \
+  ((void)((B)->p < ((B)->buffer+LUAL_BUFFERSIZE) || luaL_prepbuffer(B)), \
+   (*(B)->p++ = (char)(c)))
+
+/* compatibility only */
+#define luaL_putchar(B,c)	luaL_addchar(B,c)
+
+#define luaL_addsize(B,n)	((B)->p += (n))
+
+LUALIB_API void (luaL_buffinit) (lua_State *L, luaL_Buffer *B);
+LUALIB_API char *(luaL_prepbuffer) (luaL_Buffer *B);
+LUALIB_API void (luaL_addlstring) (luaL_Buffer *B, const char *s, size_t l);
+LUALIB_API void (luaL_addstring) (luaL_Buffer *B, const char *s);
+LUALIB_API void (luaL_addvalue) (luaL_Buffer *B);
+LUALIB_API void (luaL_pushresult) (luaL_Buffer *B);
+
+
+/* }====================================================== */
+
+
+/* compatibility with ref system */
+
+/* pre-defined references */
+#define LUA_NOREF       (-2)
+#define LUA_REFNIL      (-1)
+
+#define lua_ref(L,lock) ((lock) ? luaL_ref(L, LUA_REGISTRYINDEX) : \
+      (lua_pushstring(L, "unlocked references are obsolete"), lua_error(L), 0))
+
+#define lua_unref(L,ref)        luaL_unref(L, LUA_REGISTRYINDEX, (ref))
+
+#define lua_getref(L,ref)       lua_rawgeti(L, LUA_REGISTRYINDEX, (ref))
+
+
+#define luaL_reg	luaL_Reg
+
+#endif
+
+

+ 388 - 0
vendor/lua/5.1/include/lua.h

@@ -0,0 +1,388 @@
+/*
+** $Id: lua.h,v 1.218.1.7 2012/01/13 20:36:20 roberto Exp $
+** Lua - An Extensible Extension Language
+** Lua.org, PUC-Rio, Brazil (http://www.lua.org)
+** See Copyright Notice at the end of this file
+*/
+
+
+#ifndef lua_h
+#define lua_h
+
+#include <stdarg.h>
+#include <stddef.h>
+
+
+#include "luaconf.h"
+
+
+#define LUA_VERSION	"Lua 5.1"
+#define LUA_RELEASE	"Lua 5.1.5"
+#define LUA_VERSION_NUM	501
+#define LUA_COPYRIGHT	"Copyright (C) 1994-2012 Lua.org, PUC-Rio"
+#define LUA_AUTHORS 	"R. Ierusalimschy, L. H. de Figueiredo & W. Celes"
+
+
+/* mark for precompiled code (`<esc>Lua') */
+#define	LUA_SIGNATURE	"\033Lua"
+
+/* option for multiple returns in `lua_pcall' and `lua_call' */
+#define LUA_MULTRET	(-1)
+
+
+/*
+** pseudo-indices
+*/
+#define LUA_REGISTRYINDEX	(-10000)
+#define LUA_ENVIRONINDEX	(-10001)
+#define LUA_GLOBALSINDEX	(-10002)
+#define lua_upvalueindex(i)	(LUA_GLOBALSINDEX-(i))
+
+
+/* thread status; 0 is OK */
+#define LUA_YIELD	1
+#define LUA_ERRRUN	2
+#define LUA_ERRSYNTAX	3
+#define LUA_ERRMEM	4
+#define LUA_ERRERR	5
+
+
+typedef struct lua_State lua_State;
+
+typedef int (*lua_CFunction) (lua_State *L);
+
+
+/*
+** functions that read/write blocks when loading/dumping Lua chunks
+*/
+typedef const char * (*lua_Reader) (lua_State *L, void *ud, size_t *sz);
+
+typedef int (*lua_Writer) (lua_State *L, const void* p, size_t sz, void* ud);
+
+
+/*
+** prototype for memory-allocation functions
+*/
+typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize);
+
+
+/*
+** basic types
+*/
+#define LUA_TNONE		(-1)
+
+#define LUA_TNIL		0
+#define LUA_TBOOLEAN		1
+#define LUA_TLIGHTUSERDATA	2
+#define LUA_TNUMBER		3
+#define LUA_TSTRING		4
+#define LUA_TTABLE		5
+#define LUA_TFUNCTION		6
+#define LUA_TUSERDATA		7
+#define LUA_TTHREAD		8
+
+
+
+/* minimum Lua stack available to a C function */
+#define LUA_MINSTACK	20
+
+
+/*
+** generic extra include file
+*/
+#if defined(LUA_USER_H)
+#include LUA_USER_H
+#endif
+
+
+/* type of numbers in Lua */
+typedef LUA_NUMBER lua_Number;
+
+
+/* type for integer functions */
+typedef LUA_INTEGER lua_Integer;
+
+
+
+/*
+** state manipulation
+*/
+LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud);
+LUA_API void       (lua_close) (lua_State *L);
+LUA_API lua_State *(lua_newthread) (lua_State *L);
+
+LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf);
+
+
+/*
+** basic stack manipulation
+*/
+LUA_API int   (lua_gettop) (lua_State *L);
+LUA_API void  (lua_settop) (lua_State *L, int idx);
+LUA_API void  (lua_pushvalue) (lua_State *L, int idx);
+LUA_API void  (lua_remove) (lua_State *L, int idx);
+LUA_API void  (lua_insert) (lua_State *L, int idx);
+LUA_API void  (lua_replace) (lua_State *L, int idx);
+LUA_API int   (lua_checkstack) (lua_State *L, int sz);
+
+LUA_API void  (lua_xmove) (lua_State *from, lua_State *to, int n);
+
+
+/*
+** access functions (stack -> C)
+*/
+
+LUA_API int             (lua_isnumber) (lua_State *L, int idx);
+LUA_API int             (lua_isstring) (lua_State *L, int idx);
+LUA_API int             (lua_iscfunction) (lua_State *L, int idx);
+LUA_API int             (lua_isuserdata) (lua_State *L, int idx);
+LUA_API int             (lua_type) (lua_State *L, int idx);
+LUA_API const char     *(lua_typename) (lua_State *L, int tp);
+
+LUA_API int            (lua_equal) (lua_State *L, int idx1, int idx2);
+LUA_API int            (lua_rawequal) (lua_State *L, int idx1, int idx2);
+LUA_API int            (lua_lessthan) (lua_State *L, int idx1, int idx2);
+
+LUA_API lua_Number      (lua_tonumber) (lua_State *L, int idx);
+LUA_API lua_Integer     (lua_tointeger) (lua_State *L, int idx);
+LUA_API int             (lua_toboolean) (lua_State *L, int idx);
+LUA_API const char     *(lua_tolstring) (lua_State *L, int idx, size_t *len);
+LUA_API size_t          (lua_objlen) (lua_State *L, int idx);
+LUA_API lua_CFunction   (lua_tocfunction) (lua_State *L, int idx);
+LUA_API void	       *(lua_touserdata) (lua_State *L, int idx);
+LUA_API lua_State      *(lua_tothread) (lua_State *L, int idx);
+LUA_API const void     *(lua_topointer) (lua_State *L, int idx);
+
+
+/*
+** push functions (C -> stack)
+*/
+LUA_API void  (lua_pushnil) (lua_State *L);
+LUA_API void  (lua_pushnumber) (lua_State *L, lua_Number n);
+LUA_API void  (lua_pushinteger) (lua_State *L, lua_Integer n);
+LUA_API void  (lua_pushlstring) (lua_State *L, const char *s, size_t l);
+LUA_API void  (lua_pushstring) (lua_State *L, const char *s);
+LUA_API const char *(lua_pushvfstring) (lua_State *L, const char *fmt,
+                                                      va_list argp);
+LUA_API const char *(lua_pushfstring) (lua_State *L, const char *fmt, ...);
+LUA_API void  (lua_pushcclosure) (lua_State *L, lua_CFunction fn, int n);
+LUA_API void  (lua_pushboolean) (lua_State *L, int b);
+LUA_API void  (lua_pushlightuserdata) (lua_State *L, void *p);
+LUA_API int   (lua_pushthread) (lua_State *L);
+
+
+/*
+** get functions (Lua -> stack)
+*/
+LUA_API void  (lua_gettable) (lua_State *L, int idx);
+LUA_API void  (lua_getfield) (lua_State *L, int idx, const char *k);
+LUA_API void  (lua_rawget) (lua_State *L, int idx);
+LUA_API void  (lua_rawgeti) (lua_State *L, int idx, int n);
+LUA_API void  (lua_createtable) (lua_State *L, int narr, int nrec);
+LUA_API void *(lua_newuserdata) (lua_State *L, size_t sz);
+LUA_API int   (lua_getmetatable) (lua_State *L, int objindex);
+LUA_API void  (lua_getfenv) (lua_State *L, int idx);
+
+
+/*
+** set functions (stack -> Lua)
+*/
+LUA_API void  (lua_settable) (lua_State *L, int idx);
+LUA_API void  (lua_setfield) (lua_State *L, int idx, const char *k);
+LUA_API void  (lua_rawset) (lua_State *L, int idx);
+LUA_API void  (lua_rawseti) (lua_State *L, int idx, int n);
+LUA_API int   (lua_setmetatable) (lua_State *L, int objindex);
+LUA_API int   (lua_setfenv) (lua_State *L, int idx);
+
+
+/*
+** `load' and `call' functions (load and run Lua code)
+*/
+LUA_API void  (lua_call) (lua_State *L, int nargs, int nresults);
+LUA_API int   (lua_pcall) (lua_State *L, int nargs, int nresults, int errfunc);
+LUA_API int   (lua_cpcall) (lua_State *L, lua_CFunction func, void *ud);
+LUA_API int   (lua_load) (lua_State *L, lua_Reader reader, void *dt,
+                                        const char *chunkname);
+
+LUA_API int (lua_dump) (lua_State *L, lua_Writer writer, void *data);
+
+
+/*
+** coroutine functions
+*/
+LUA_API int  (lua_yield) (lua_State *L, int nresults);
+LUA_API int  (lua_resume) (lua_State *L, int narg);
+LUA_API int  (lua_status) (lua_State *L);
+
+/*
+** garbage-collection function and options
+*/
+
+#define LUA_GCSTOP		0
+#define LUA_GCRESTART		1
+#define LUA_GCCOLLECT		2
+#define LUA_GCCOUNT		3
+#define LUA_GCCOUNTB		4
+#define LUA_GCSTEP		5
+#define LUA_GCSETPAUSE		6
+#define LUA_GCSETSTEPMUL	7
+
+LUA_API int (lua_gc) (lua_State *L, int what, int data);
+
+
+/*
+** miscellaneous functions
+*/
+
+LUA_API int   (lua_error) (lua_State *L);
+
+LUA_API int   (lua_next) (lua_State *L, int idx);
+
+LUA_API void  (lua_concat) (lua_State *L, int n);
+
+LUA_API lua_Alloc (lua_getallocf) (lua_State *L, void **ud);
+LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud);
+
+
+
+/* 
+** ===============================================================
+** some useful macros
+** ===============================================================
+*/
+
+#define lua_pop(L,n)		lua_settop(L, -(n)-1)
+
+#define lua_newtable(L)		lua_createtable(L, 0, 0)
+
+#define lua_register(L,n,f) (lua_pushcfunction(L, (f)), lua_setglobal(L, (n)))
+
+#define lua_pushcfunction(L,f)	lua_pushcclosure(L, (f), 0)
+
+#define lua_strlen(L,i)		lua_objlen(L, (i))
+
+#define lua_isfunction(L,n)	(lua_type(L, (n)) == LUA_TFUNCTION)
+#define lua_istable(L,n)	(lua_type(L, (n)) == LUA_TTABLE)
+#define lua_islightuserdata(L,n)	(lua_type(L, (n)) == LUA_TLIGHTUSERDATA)
+#define lua_isnil(L,n)		(lua_type(L, (n)) == LUA_TNIL)
+#define lua_isboolean(L,n)	(lua_type(L, (n)) == LUA_TBOOLEAN)
+#define lua_isthread(L,n)	(lua_type(L, (n)) == LUA_TTHREAD)
+#define lua_isnone(L,n)		(lua_type(L, (n)) == LUA_TNONE)
+#define lua_isnoneornil(L, n)	(lua_type(L, (n)) <= 0)
+
+#define lua_pushliteral(L, s)	\
+	lua_pushlstring(L, "" s, (sizeof(s)/sizeof(char))-1)
+
+#define lua_setglobal(L,s)	lua_setfield(L, LUA_GLOBALSINDEX, (s))
+#define lua_getglobal(L,s)	lua_getfield(L, LUA_GLOBALSINDEX, (s))
+
+#define lua_tostring(L,i)	lua_tolstring(L, (i), NULL)
+
+
+
+/*
+** compatibility macros and functions
+*/
+
+#define lua_open()	luaL_newstate()
+
+#define lua_getregistry(L)	lua_pushvalue(L, LUA_REGISTRYINDEX)
+
+#define lua_getgccount(L)	lua_gc(L, LUA_GCCOUNT, 0)
+
+#define lua_Chunkreader		lua_Reader
+#define lua_Chunkwriter		lua_Writer
+
+
+/* hack */
+LUA_API void lua_setlevel	(lua_State *from, lua_State *to);
+
+
+/*
+** {======================================================================
+** Debug API
+** =======================================================================
+*/
+
+
+/*
+** Event codes
+*/
+#define LUA_HOOKCALL	0
+#define LUA_HOOKRET	1
+#define LUA_HOOKLINE	2
+#define LUA_HOOKCOUNT	3
+#define LUA_HOOKTAILRET 4
+
+
+/*
+** Event masks
+*/
+#define LUA_MASKCALL	(1 << LUA_HOOKCALL)
+#define LUA_MASKRET	(1 << LUA_HOOKRET)
+#define LUA_MASKLINE	(1 << LUA_HOOKLINE)
+#define LUA_MASKCOUNT	(1 << LUA_HOOKCOUNT)
+
+typedef struct lua_Debug lua_Debug;  /* activation record */
+
+
+/* Functions to be called by the debuger in specific events */
+typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar);
+
+
+LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar);
+LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar);
+LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n);
+LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n);
+LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n);
+LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n);
+
+LUA_API int lua_sethook (lua_State *L, lua_Hook func, int mask, int count);
+LUA_API lua_Hook lua_gethook (lua_State *L);
+LUA_API int lua_gethookmask (lua_State *L);
+LUA_API int lua_gethookcount (lua_State *L);
+
+
+struct lua_Debug {
+  int event;
+  const char *name;	/* (n) */
+  const char *namewhat;	/* (n) `global', `local', `field', `method' */
+  const char *what;	/* (S) `Lua', `C', `main', `tail' */
+  const char *source;	/* (S) */
+  int currentline;	/* (l) */
+  int nups;		/* (u) number of upvalues */
+  int linedefined;	/* (S) */
+  int lastlinedefined;	/* (S) */
+  char short_src[LUA_IDSIZE]; /* (S) */
+  /* private part */
+  int i_ci;  /* active function */
+};
+
+/* }====================================================================== */
+
+
+/******************************************************************************
+* Copyright (C) 1994-2012 Lua.org, PUC-Rio.  All rights reserved.
+*
+* 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.
+******************************************************************************/
+
+
+#endif

+ 9 - 0
vendor/lua/5.1/include/lua.hpp

@@ -0,0 +1,9 @@
+// lua.hpp
+// Lua header files for C++
+// <<extern "C">> not supplied automatically because Lua also compiles as C++
+
+extern "C" {
+#include "lua.h"
+#include "lualib.h"
+#include "lauxlib.h"
+}

+ 766 - 0
vendor/lua/5.1/include/luaconf.h

@@ -0,0 +1,766 @@
+/*
+** $Id: luaconf.h,v 1.82.1.7 2008/02/11 16:25:08 roberto Exp $
+** Configuration file for Lua
+** See Copyright Notice in lua.h
+*/
+
+
+#ifndef lconfig_h
+#define lconfig_h
+
+#include <limits.h>
+#include <stddef.h>
+
+
+/*
+** ==================================================================
+** Search for "@@" to find all configurable definitions.
+** ===================================================================
+*/
+
+
+/*
+@@ LUA_ANSI controls the use of non-ansi features.
+** CHANGE it (define it) if you want Lua to avoid the use of any
+** non-ansi feature or library.
+*/
+#if defined(__STRICT_ANSI__)
+#define LUA_ANSI
+#endif
+
+
+#if !defined(LUA_ANSI) && defined(_WIN32)
+#define LUA_WIN
+#endif
+
+#if defined(LUA_USE_LINUX)
+#define LUA_USE_POSIX
+#define LUA_USE_DLOPEN		/* needs an extra library: -ldl */
+#define LUA_USE_READLINE	/* needs some extra libraries */
+#endif
+
+#if defined(LUA_USE_MACOSX)
+#define LUA_USE_POSIX
+#define LUA_DL_DYLD		/* does not need extra library */
+#endif
+
+
+
+/*
+@@ LUA_USE_POSIX includes all functionallity listed as X/Open System
+@* Interfaces Extension (XSI).
+** CHANGE it (define it) if your system is XSI compatible.
+*/
+#if defined(LUA_USE_POSIX)
+#define LUA_USE_MKSTEMP
+#define LUA_USE_ISATTY
+#define LUA_USE_POPEN
+#define LUA_USE_ULONGJMP
+#endif
+
+
+/*
+@@ LUA_PATH and LUA_CPATH are the names of the environment variables that
+@* Lua check to set its paths.
+@@ LUA_INIT is the name of the environment variable that Lua
+@* checks for initialization code.
+** CHANGE them if you want different names.
+*/
+#define LUA_PATH        "LUA_PATH"
+#define LUA_CPATH       "LUA_CPATH"
+#define LUA_INIT	"LUA_INIT"
+
+
+/*
+@@ LUA_PATH_DEFAULT is the default path that Lua uses to look for
+@* Lua libraries.
+@@ LUA_CPATH_DEFAULT is the default path that Lua uses to look for
+@* C libraries.
+** CHANGE them if your machine has a non-conventional directory
+** hierarchy or if you want to install your libraries in
+** non-conventional directories.
+*/
+#if defined(_WIN32)
+/*
+** In Windows, any exclamation mark ('!') in the path is replaced by the
+** path of the directory of the executable file of the current process.
+*/
+#define LUA_LDIR	"!\\lua\\"
+#define LUA_CDIR	"!\\"
+#define LUA_PATH_DEFAULT  \
+		".\\?.lua;"  LUA_LDIR"?.lua;"  LUA_LDIR"?\\init.lua;" \
+		             LUA_CDIR"?.lua;"  LUA_CDIR"?\\init.lua"
+#define LUA_CPATH_DEFAULT \
+		".\\?.dll;"  LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll;" \
+		LUA_CDIR"clibs\\?.dll;" LUA_CDIR"clibs\\loadall.dll;" \
+		".\\?51.dll;"  LUA_CDIR"?51.dll;" LUA_CDIR"clibs\\?51.dll" 
+
+#else
+#define LUA_ROOT	"/usr/local/"
+#define LUA_LDIR	LUA_ROOT "share/lua/5.1/"
+#define LUA_CDIR	LUA_ROOT "lib/lua/5.1/"
+#define LUA_PATH_DEFAULT  \
+		"./?.lua;"  LUA_LDIR"?.lua;"  LUA_LDIR"?/init.lua;" \
+		            LUA_CDIR"?.lua;"  LUA_CDIR"?/init.lua"
+#define LUA_CPATH_DEFAULT \
+		"./?.so;"  LUA_CDIR"?.so;" LUA_CDIR"loadall.so;" \
+		"./lib?51.so;" LUA_CDIR"lib?51.so"
+#endif
+
+
+/*
+@@ LUA_DIRSEP is the directory separator (for submodules).
+** CHANGE it if your machine does not use "/" as the directory separator
+** and is not Windows. (On Windows Lua automatically uses "\".)
+*/
+#if defined(_WIN32)
+#define LUA_DIRSEP	"\\"
+#else
+#define LUA_DIRSEP	"/"
+#endif
+
+
+/*
+@@ LUA_PATHSEP is the character that separates templates in a path.
+@@ LUA_PATH_MARK is the string that marks the substitution points in a
+@* template.
+@@ LUA_EXECDIR in a Windows path is replaced by the executable's
+@* directory.
+@@ LUA_IGMARK is a mark to ignore all before it when bulding the
+@* luaopen_ function name.
+** CHANGE them if for some reason your system cannot use those
+** characters. (E.g., if one of those characters is a common character
+** in file/directory names.) Probably you do not need to change them.
+*/
+#define LUA_PATHSEP	";"
+#define LUA_PATH_MARK	"?"
+#define LUA_EXECDIR	"!"
+#define LUA_IGMARK	"-"
+
+
+/*
+@@ LUA_INTEGER is the integral type used by lua_pushinteger/lua_tointeger.
+** CHANGE that if ptrdiff_t is not adequate on your machine. (On most
+** machines, ptrdiff_t gives a good choice between int or long.)
+*/
+#define LUA_INTEGER	ptrdiff_t
+
+
+/*
+@@ LUA_API is a mark for all core API functions.
+@@ LUALIB_API is a mark for all standard library functions.
+** CHANGE them if you need to define those functions in some special way.
+** For instance, if you want to create one Windows DLL with the core and
+** the libraries, you may want to use the following definition (define
+** LUA_BUILD_AS_DLL to get it).
+*/
+#if defined(LUA_BUILD_AS_DLL)
+
+#if defined(LUA_CORE) || defined(LUA_LIB)
+#define LUA_API __declspec(dllexport)
+#else
+#define LUA_API __declspec(dllimport)
+#endif
+
+#else
+
+#define LUA_API		extern
+
+#endif
+
+/* more often than not the libs go together with the core */
+#define LUALIB_API	LUA_API
+
+
+/*
+@@ LUAI_FUNC is a mark for all extern functions that are not to be
+@* exported to outside modules.
+@@ LUAI_DATA is a mark for all extern (const) variables that are not to
+@* be exported to outside modules.
+** CHANGE them if you need to mark them in some special way. Elf/gcc
+** (versions 3.2 and later) mark them as "hidden" to optimize access
+** when Lua is compiled as a shared library.
+*/
+#if defined(luaall_c)
+#define LUAI_FUNC	static
+#define LUAI_DATA	/* empty */
+
+#elif defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \
+      defined(__ELF__)
+#define LUAI_FUNC	__attribute__((visibility("hidden"))) extern
+#define LUAI_DATA	LUAI_FUNC
+
+#else
+#define LUAI_FUNC	extern
+#define LUAI_DATA	extern
+#endif
+
+
+
+/*
+@@ LUA_QL describes how error messages quote program elements.
+** CHANGE it if you want a different appearance.
+*/
+#define LUA_QL(x)	"'" x "'"
+#define LUA_QS		LUA_QL("%s")
+
+
+/*
+@@ LUA_IDSIZE gives the maximum size for the description of the source
+@* of a function in debug information.
+** CHANGE it if you want a different size.
+*/
+#define LUA_IDSIZE	60
+
+
+/*
+** {==================================================================
+** Stand-alone configuration
+** ===================================================================
+*/
+
+#if defined(lua_c) || defined(luaall_c)
+
+/*
+@@ lua_stdin_is_tty detects whether the standard input is a 'tty' (that
+@* is, whether we're running lua interactively).
+** CHANGE it if you have a better definition for non-POSIX/non-Windows
+** systems.
+*/
+#if defined(LUA_USE_ISATTY)
+#include <unistd.h>
+#define lua_stdin_is_tty()	isatty(0)
+#elif defined(LUA_WIN)
+#include <io.h>
+#include <stdio.h>
+#define lua_stdin_is_tty()	_isatty(_fileno(stdin))
+#else
+#define lua_stdin_is_tty()	1  /* assume stdin is a tty */
+#endif
+
+
+/*
+@@ LUA_PROMPT is the default prompt used by stand-alone Lua.
+@@ LUA_PROMPT2 is the default continuation prompt used by stand-alone Lua.
+** CHANGE them if you want different prompts. (You can also change the
+** prompts dynamically, assigning to globals _PROMPT/_PROMPT2.)
+*/
+#define LUA_PROMPT		"> "
+#define LUA_PROMPT2		">> "
+
+
+/*
+@@ LUA_PROGNAME is the default name for the stand-alone Lua program.
+** CHANGE it if your stand-alone interpreter has a different name and
+** your system is not able to detect that name automatically.
+*/
+#define LUA_PROGNAME		"lua"
+
+
+/*
+@@ LUA_MAXINPUT is the maximum length for an input line in the
+@* stand-alone interpreter.
+** CHANGE it if you need longer lines.
+*/
+#define LUA_MAXINPUT	512
+
+
+/*
+@@ lua_readline defines how to show a prompt and then read a line from
+@* the standard input.
+@@ lua_saveline defines how to "save" a read line in a "history".
+@@ lua_freeline defines how to free a line read by lua_readline.
+** CHANGE them if you want to improve this functionality (e.g., by using
+** GNU readline and history facilities).
+*/
+#if defined(LUA_USE_READLINE)
+#include <stdio.h>
+#include <readline/readline.h>
+#include <readline/history.h>
+#define lua_readline(L,b,p)	((void)L, ((b)=readline(p)) != NULL)
+#define lua_saveline(L,idx) \
+	if (lua_strlen(L,idx) > 0)  /* non-empty line? */ \
+	  add_history(lua_tostring(L, idx));  /* add it to history */
+#define lua_freeline(L,b)	((void)L, free(b))
+#else
+#define lua_readline(L,b,p)	\
+	((void)L, fputs(p, stdout), fflush(stdout),  /* show prompt */ \
+	fgets(b, LUA_MAXINPUT, stdin) != NULL)  /* get line */
+#define lua_saveline(L,idx)	{ (void)L; (void)idx; }
+#define lua_freeline(L,b)	{ (void)L; (void)b; }
+#endif
+
+#endif
+
+/* }================================================================== */
+
+
+/*
+@@ LUAI_GCPAUSE defines the default pause between garbage-collector cycles
+@* as a percentage.
+** CHANGE it if you want the GC to run faster or slower (higher values
+** mean larger pauses which mean slower collection.) You can also change
+** this value dynamically.
+*/
+#define LUAI_GCPAUSE	200  /* 200% (wait memory to double before next GC) */
+
+
+/*
+@@ LUAI_GCMUL defines the default speed of garbage collection relative to
+@* memory allocation as a percentage.
+** CHANGE it if you want to change the granularity of the garbage
+** collection. (Higher values mean coarser collections. 0 represents
+** infinity, where each step performs a full collection.) You can also
+** change this value dynamically.
+*/
+#define LUAI_GCMUL	200 /* GC runs 'twice the speed' of memory allocation */
+
+
+
+/*
+@@ LUA_COMPAT_GETN controls compatibility with old getn behavior.
+** CHANGE it (define it) if you want exact compatibility with the
+** behavior of setn/getn in Lua 5.0.
+*/
+#undef LUA_COMPAT_GETN
+
+/*
+@@ LUA_COMPAT_LOADLIB controls compatibility about global loadlib.
+** CHANGE it to undefined as soon as you do not need a global 'loadlib'
+** function (the function is still available as 'package.loadlib').
+*/
+#undef LUA_COMPAT_LOADLIB
+
+/*
+@@ LUA_COMPAT_VARARG controls compatibility with old vararg feature.
+** CHANGE it to undefined as soon as your programs use only '...' to
+** access vararg parameters (instead of the old 'arg' table).
+*/
+#define LUA_COMPAT_VARARG
+
+/*
+@@ LUA_COMPAT_MOD controls compatibility with old math.mod function.
+** CHANGE it to undefined as soon as your programs use 'math.fmod' or
+** the new '%' operator instead of 'math.mod'.
+*/
+#define LUA_COMPAT_MOD
+
+/*
+@@ LUA_COMPAT_LSTR controls compatibility with old long string nesting
+@* facility.
+** CHANGE it to 2 if you want the old behaviour, or undefine it to turn
+** off the advisory error when nesting [[...]].
+*/
+#define LUA_COMPAT_LSTR		1
+
+/*
+@@ LUA_COMPAT_GFIND controls compatibility with old 'string.gfind' name.
+** CHANGE it to undefined as soon as you rename 'string.gfind' to
+** 'string.gmatch'.
+*/
+#define LUA_COMPAT_GFIND
+
+/*
+@@ LUA_COMPAT_OPENLIB controls compatibility with old 'luaL_openlib'
+@* behavior.
+** CHANGE it to undefined as soon as you replace to 'luaL_register'
+** your uses of 'luaL_openlib'
+*/
+#define LUA_COMPAT_OPENLIB
+
+
+
+/*
+@@ luai_apicheck is the assert macro used by the Lua-C API.
+** CHANGE luai_apicheck if you want Lua to perform some checks in the
+** parameters it gets from API calls. This may slow down the interpreter
+** a bit, but may be quite useful when debugging C code that interfaces
+** with Lua. A useful redefinition is to use assert.h.
+*/
+#if defined(LUA_USE_APICHECK)
+#include <assert.h>
+#define luai_apicheck(L,o)	{ (void)L; assert(o); }
+#else
+#define luai_apicheck(L,o)	{ (void)L; }
+#endif
+
+
+/*
+@@ LUAI_BITSINT defines the number of bits in an int.
+** CHANGE here if Lua cannot automatically detect the number of bits of
+** your machine. Probably you do not need to change this.
+*/
+/* avoid overflows in comparison */
+#if INT_MAX-20 < 32760
+#define LUAI_BITSINT	16
+#elif INT_MAX > 2147483640L
+/* int has at least 32 bits */
+#define LUAI_BITSINT	32
+#else
+#error "you must define LUA_BITSINT with number of bits in an integer"
+#endif
+
+
+/*
+@@ LUAI_UINT32 is an unsigned integer with at least 32 bits.
+@@ LUAI_INT32 is an signed integer with at least 32 bits.
+@@ LUAI_UMEM is an unsigned integer big enough to count the total
+@* memory used by Lua.
+@@ LUAI_MEM is a signed integer big enough to count the total memory
+@* used by Lua.
+** CHANGE here if for some weird reason the default definitions are not
+** good enough for your machine. (The definitions in the 'else'
+** part always works, but may waste space on machines with 64-bit
+** longs.) Probably you do not need to change this.
+*/
+#if LUAI_BITSINT >= 32
+#define LUAI_UINT32	unsigned int
+#define LUAI_INT32	int
+#define LUAI_MAXINT32	INT_MAX
+#define LUAI_UMEM	size_t
+#define LUAI_MEM	ptrdiff_t
+#else
+/* 16-bit ints */
+#define LUAI_UINT32	unsigned long
+#define LUAI_INT32	long
+#define LUAI_MAXINT32	LONG_MAX
+#define LUAI_UMEM	unsigned long
+#define LUAI_MEM	long
+#endif
+
+
+/*
+@@ LUAI_MAXCALLS limits the number of nested calls.
+** CHANGE it if you need really deep recursive calls. This limit is
+** arbitrary; its only purpose is to stop infinite recursion before
+** exhausting memory.
+*/
+#define LUAI_MAXCALLS	20000
+
+
+/*
+@@ LUAI_MAXCSTACK limits the number of Lua stack slots that a C function
+@* can use.
+** CHANGE it if you need lots of (Lua) stack space for your C
+** functions. This limit is arbitrary; its only purpose is to stop C
+** functions to consume unlimited stack space. (must be smaller than
+** -LUA_REGISTRYINDEX)
+*/
+#define LUAI_MAXCSTACK	8000
+
+
+
+/*
+** {==================================================================
+** CHANGE (to smaller values) the following definitions if your system
+** has a small C stack. (Or you may want to change them to larger
+** values if your system has a large C stack and these limits are
+** too rigid for you.) Some of these constants control the size of
+** stack-allocated arrays used by the compiler or the interpreter, while
+** others limit the maximum number of recursive calls that the compiler
+** or the interpreter can perform. Values too large may cause a C stack
+** overflow for some forms of deep constructs.
+** ===================================================================
+*/
+
+
+/*
+@@ LUAI_MAXCCALLS is the maximum depth for nested C calls (short) and
+@* syntactical nested non-terminals in a program.
+*/
+#define LUAI_MAXCCALLS		200
+
+
+/*
+@@ LUAI_MAXVARS is the maximum number of local variables per function
+@* (must be smaller than 250).
+*/
+#define LUAI_MAXVARS		200
+
+
+/*
+@@ LUAI_MAXUPVALUES is the maximum number of upvalues per function
+@* (must be smaller than 250).
+*/
+#define LUAI_MAXUPVALUES	60
+
+
+/*
+@@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system.
+*/
+#define LUAL_BUFFERSIZE		BUFSIZ
+
+/* }================================================================== */
+
+
+
+
+/*
+** {==================================================================
+@@ LUA_NUMBER is the type of numbers in Lua.
+** CHANGE the following definitions only if you want to build Lua
+** with a number type different from double. You may also need to
+** change lua_number2int & lua_number2integer.
+** ===================================================================
+*/
+
+#define LUA_NUMBER_DOUBLE
+#define LUA_NUMBER	double
+
+/*
+@@ LUAI_UACNUMBER is the result of an 'usual argument conversion'
+@* over a number.
+*/
+#define LUAI_UACNUMBER	double
+
+
+/*
+@@ LUA_NUMBER_SCAN is the format for reading numbers.
+@@ LUA_NUMBER_FMT is the format for writing numbers.
+@@ lua_number2str converts a number to a string.
+@@ LUAI_MAXNUMBER2STR is maximum size of previous conversion.
+@@ lua_str2number converts a string to a number.
+*/
+#define LUA_NUMBER_SCAN		"%lf"
+#define LUA_NUMBER_FMT		"%.14g"
+#define lua_number2str(s,n)	sprintf((s), LUA_NUMBER_FMT, (n))
+#define LUAI_MAXNUMBER2STR	32 /* 16 digits, sign, point, and \0 */
+#define lua_str2number(s,p)	strtod((s), (p))
+
+
+/*
+@@ The luai_num* macros define the primitive operations over numbers.
+*/
+#if defined(LUA_CORE)
+#include <math.h>
+#define luai_numadd(a,b)	((a)+(b))
+#define luai_numsub(a,b)	((a)-(b))
+#define luai_nummul(a,b)	((a)*(b))
+#define luai_numdiv(a,b)	((a)/(b))
+#define luai_nummod(a,b)	((a) - floor((a)/(b))*(b))
+#define luai_numpow(a,b)	(pow(a,b))
+#define luai_numunm(a)		(-(a))
+#define luai_numeq(a,b)		((a)==(b))
+#define luai_numlt(a,b)		((a)<(b))
+#define luai_numle(a,b)		((a)<=(b))
+#define luai_numisnan(a)	(!luai_numeq((a), (a)))
+#endif
+
+
+/*
+@@ lua_number2int is a macro to convert lua_Number to int.
+@@ lua_number2integer is a macro to convert lua_Number to lua_Integer.
+** CHANGE them if you know a faster way to convert a lua_Number to
+** int (with any rounding method and without throwing errors) in your
+** system. In Pentium machines, a naive typecast from double to int
+** in C is extremely slow, so any alternative is worth trying.
+*/
+
+/* On a Pentium, resort to a trick */
+#if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) && !defined(__SSE2__) && \
+    (defined(__i386) || defined (_M_IX86) || defined(__i386__))
+
+/* On a Microsoft compiler, use assembler */
+#if defined(_MSC_VER)
+
+#define lua_number2int(i,d)   __asm fld d   __asm fistp i
+#define lua_number2integer(i,n)		lua_number2int(i, n)
+
+/* the next trick should work on any Pentium, but sometimes clashes
+   with a DirectX idiosyncrasy */
+#else
+
+union luai_Cast { double l_d; long l_l; };
+#define lua_number2int(i,d) \
+  { volatile union luai_Cast u; u.l_d = (d) + 6755399441055744.0; (i) = u.l_l; }
+#define lua_number2integer(i,n)		lua_number2int(i, n)
+
+#endif
+
+
+/* this option always works, but may be slow */
+#else
+#define lua_number2int(i,d)	((i)=(int)(d))
+#define lua_number2integer(i,d)	((i)=(lua_Integer)(d))
+
+#endif
+
+/* }================================================================== */
+
+
+/*
+@@ LUAI_USER_ALIGNMENT_T is a type that requires maximum alignment.
+** CHANGE it if your system requires alignments larger than double. (For
+** instance, if your system supports long doubles and they must be
+** aligned in 16-byte boundaries, then you should add long double in the
+** union.) Probably you do not need to change this.
+*/
+#define LUAI_USER_ALIGNMENT_T	union { double u; void *s; long l; }
+
+
+/*
+@@ LUAI_THROW/LUAI_TRY define how Lua does exception handling.
+** CHANGE them if you prefer to use longjmp/setjmp even with C++
+** or if want/don't to use _longjmp/_setjmp instead of regular
+** longjmp/setjmp. By default, Lua handles errors with exceptions when
+** compiling as C++ code, with _longjmp/_setjmp when asked to use them,
+** and with longjmp/setjmp otherwise.
+*/
+#if defined(__cplusplus)
+/* C++ exceptions */
+#define LUAI_THROW(L,c)	throw(c)
+#define LUAI_TRY(L,c,a)	try { a } catch(...) \
+	{ if ((c)->status == 0) (c)->status = -1; }
+#define luai_jmpbuf	int  /* dummy variable */
+
+#elif defined(LUA_USE_ULONGJMP)
+/* in Unix, try _longjmp/_setjmp (more efficient) */
+#define LUAI_THROW(L,c)	_longjmp((c)->b, 1)
+#define LUAI_TRY(L,c,a)	if (_setjmp((c)->b) == 0) { a }
+#define luai_jmpbuf	jmp_buf
+
+#else
+/* default handling with long jumps */
+#define LUAI_THROW(L,c)	longjmp((c)->b, 1)
+#define LUAI_TRY(L,c,a)	if (setjmp((c)->b) == 0) { a }
+#define luai_jmpbuf	jmp_buf
+
+#endif
+
+
+/*
+@@ LUA_MAXCAPTURES is the maximum number of captures that a pattern
+@* can do during pattern-matching.
+** CHANGE it if you need more captures. This limit is arbitrary.
+*/
+#define LUA_MAXCAPTURES		32
+
+
+/*
+@@ lua_tmpnam is the function that the OS library uses to create a
+@* temporary name.
+@@ LUA_TMPNAMBUFSIZE is the maximum size of a name created by lua_tmpnam.
+** CHANGE them if you have an alternative to tmpnam (which is considered
+** insecure) or if you want the original tmpnam anyway.  By default, Lua
+** uses tmpnam except when POSIX is available, where it uses mkstemp.
+*/
+#if defined(loslib_c) || defined(luaall_c)
+
+#if defined(LUA_USE_MKSTEMP)
+#include <unistd.h>
+#define LUA_TMPNAMBUFSIZE	32
+#define lua_tmpnam(b,e)	{ \
+	strcpy(b, "/tmp/lua_XXXXXX"); \
+	e = mkstemp(b); \
+	if (e != -1) close(e); \
+	e = (e == -1); }
+
+#else
+#define LUA_TMPNAMBUFSIZE	L_tmpnam
+#define lua_tmpnam(b,e)		{ e = (tmpnam(b) == NULL); }
+#endif
+
+#endif
+
+
+/*
+@@ lua_popen spawns a new process connected to the current one through
+@* the file streams.
+** CHANGE it if you have a way to implement it in your system.
+*/
+#if defined(LUA_USE_POPEN)
+
+#define lua_popen(L,c,m)	((void)L, fflush(NULL), popen(c,m))
+#define lua_pclose(L,file)	((void)L, (pclose(file) != -1))
+
+#elif defined(LUA_WIN)
+
+#define lua_popen(L,c,m)	((void)L, _popen(c,m))
+#define lua_pclose(L,file)	((void)L, (_pclose(file) != -1))
+
+#else
+
+#define lua_popen(L,c,m)	((void)((void)c, m),  \
+		luaL_error(L, LUA_QL("popen") " not supported"), (FILE*)0)
+#define lua_pclose(L,file)		((void)((void)L, file), 0)
+
+#endif
+
+/*
+@@ LUA_DL_* define which dynamic-library system Lua should use.
+** CHANGE here if Lua has problems choosing the appropriate
+** dynamic-library system for your platform (either Windows' DLL, Mac's
+** dyld, or Unix's dlopen). If your system is some kind of Unix, there
+** is a good chance that it has dlopen, so LUA_DL_DLOPEN will work for
+** it.  To use dlopen you also need to adapt the src/Makefile (probably
+** adding -ldl to the linker options), so Lua does not select it
+** automatically.  (When you change the makefile to add -ldl, you must
+** also add -DLUA_USE_DLOPEN.)
+** If you do not want any kind of dynamic library, undefine all these
+** options.
+** By default, _WIN32 gets LUA_DL_DLL and MAC OS X gets LUA_DL_DYLD.
+*/
+#if defined(LUA_USE_DLOPEN)
+#define LUA_DL_DLOPEN
+#endif
+
+#if defined(LUA_WIN)
+#define LUA_DL_DLL
+#endif
+
+
+/*
+@@ LUAI_EXTRASPACE allows you to add user-specific data in a lua_State
+@* (the data goes just *before* the lua_State pointer).
+** CHANGE (define) this if you really need that. This value must be
+** a multiple of the maximum alignment required for your machine.
+*/
+#define LUAI_EXTRASPACE		0
+
+
+/*
+@@ luai_userstate* allow user-specific actions on threads.
+** CHANGE them if you defined LUAI_EXTRASPACE and need to do something
+** extra when a thread is created/deleted/resumed/yielded.
+*/
+#define luai_userstateopen(L)		((void)L)
+#define luai_userstateclose(L)		((void)L)
+#define luai_userstatethread(L,L1)	((void)L)
+#define luai_userstatefree(L)		((void)L)
+#define luai_userstateresume(L,n)	((void)L)
+#define luai_userstateyield(L,n)	((void)L)
+
+
+/*
+@@ LUA_INTFRMLEN is the length modifier for integer conversions
+@* in 'string.format'.
+@@ LUA_INTFRM_T is the integer type correspoding to the previous length
+@* modifier.
+** CHANGE them if your system supports long long or does not support long.
+*/
+
+#if defined(LUA_USELONGLONG)
+
+#define LUA_INTFRMLEN		"ll"
+#define LUA_INTFRM_T		long long
+
+#else
+
+#define LUA_INTFRMLEN		"l"
+#define LUA_INTFRM_T		long
+
+#endif
+
+
+
+/* =================================================================== */
+
+/*
+** Local configuration. You can use this space to add your redefinitions
+** without modifying the main part of the file.
+*/
+
+
+
+#endif
+

+ 53 - 0
vendor/lua/5.1/include/lualib.h

@@ -0,0 +1,53 @@
+/*
+** $Id: lualib.h,v 1.36.1.1 2007/12/27 13:02:25 roberto Exp $
+** Lua standard libraries
+** See Copyright Notice in lua.h
+*/
+
+
+#ifndef lualib_h
+#define lualib_h
+
+#include "lua.h"
+
+
+/* Key to file-handle type */
+#define LUA_FILEHANDLE		"FILE*"
+
+
+#define LUA_COLIBNAME	"coroutine"
+LUALIB_API int (luaopen_base) (lua_State *L);
+
+#define LUA_TABLIBNAME	"table"
+LUALIB_API int (luaopen_table) (lua_State *L);
+
+#define LUA_IOLIBNAME	"io"
+LUALIB_API int (luaopen_io) (lua_State *L);
+
+#define LUA_OSLIBNAME	"os"
+LUALIB_API int (luaopen_os) (lua_State *L);
+
+#define LUA_STRLIBNAME	"string"
+LUALIB_API int (luaopen_string) (lua_State *L);
+
+#define LUA_MATHLIBNAME	"math"
+LUALIB_API int (luaopen_math) (lua_State *L);
+
+#define LUA_DBLIBNAME	"debug"
+LUALIB_API int (luaopen_debug) (lua_State *L);
+
+#define LUA_LOADLIBNAME	"package"
+LUALIB_API int (luaopen_package) (lua_State *L);
+
+
+/* open all previous libraries */
+LUALIB_API void (luaL_openlibs) (lua_State *L); 
+
+
+
+#ifndef lua_assert
+#define lua_assert(x)	((void)0)
+#endif
+
+
+#endif

BIN
vendor/lua/5.1/linux/liblua5.1.a


BIN
vendor/lua/5.1/linux/liblua5.1.so


+ 659 - 0
vendor/lua/5.1/lua.odin

@@ -0,0 +1,659 @@
+package lua_5_1
+
+import "core:intrinsics"
+import "core:builtin"
+
+import c "core:c/libc"
+
+#assert(size_of(c.int) == size_of(b32))
+
+when ODIN_OS == .Windows {
+	foreign import lib "windows/lua5.1.dll.lib"
+} else when ODIN_OS == .Linux {
+	foreign import lib "linux/liblua5.1.a"
+} else {
+	foreign import lib "system:liblua5.1.a"
+}
+
+VERSION	        :: "Lua 5.1"
+RELEASE	        :: "Lua 5.1.5"
+VERSION_NUM	:: 501
+COPYRIGHT	:: "Copyright (C) 1994-2012 Lua.org, PUC-Rio"
+AUTHORS         :: "R. Ierusalimschy, L. H. de Figueiredo & W. Celes"
+
+/* mark for precompiled code ('<esc>Lua') */
+SIGNATURE :: "\x1bLua"
+
+/* option for multiple returns in 'lua_pcall' and 'lua_call' */
+MULTRET :: -1
+
+REGISTRYINDEX :: -10000
+ENVIRONINDEX  :: -10001
+GLOBALSINDEX  :: -10002
+
+/*
+@@ LUAI_MAXSTACK limits the size of the Lua stack.
+** CHANGE it if you need a different limit. This limit is arbitrary;
+** its only purpose is to stop Lua from consuming unlimited stack
+** space (and to reserve some numbers for pseudo-indices).
+** (It must fit into max(size_t)/32.)
+*/
+MAXSTACK :: 1000000 when size_of(rawptr) == 4 else 15000
+
+
+/*
+@@ LUA_EXTRASPACE defines the size of a raw memory area associated with
+** a Lua state with very fast access.
+** CHANGE it if you need a different size.
+*/
+EXTRASPACE :: size_of(rawptr)
+
+
+
+/*
+@@ LUA_IDSIZE gives the maximum size for the description of the source
+@@ of a function in debug information.
+** CHANGE it if you want a different size.
+*/
+IDSIZE :: 60
+
+
+/*
+@@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system.
+*/
+L_BUFFERSIZE :: c.int(16 * size_of(rawptr) * size_of(Number))
+
+
+MAXALIGNVAL :: max(align_of(Number), align_of(f64), align_of(rawptr), align_of(Integer), align_of(c.long))
+
+
+Status :: enum c.int {
+	OK        = 0,
+	YIELD     = 1,
+	ERRRUN    = 2,
+	ERRSYNTAX = 3,
+	ERRMEM    = 4,
+	ERRERR    = 5,
+	ERRFILE   = 6,
+}
+
+/* thread status */
+OK        :: Status.OK
+YIELD     :: Status.YIELD
+ERRRUN    :: Status.ERRRUN
+ERRSYNTAX :: Status.ERRSYNTAX
+ERRMEM    :: Status.ERRMEM
+ERRERR    :: Status.ERRERR
+ERRFILE   :: Status.ERRFILE
+
+/*
+** basic types
+*/
+
+
+Type :: enum c.int {
+	NONE          = -1,
+
+	NIL           = 0,
+	BOOLEAN       = 1,
+	LIGHTUSERDATA = 2,
+	NUMBER        = 3,
+	STRING        = 4,
+	TABLE         = 5,
+	FUNCTION      = 6,
+	USERDATA      = 7,
+	THREAD        = 8,
+}
+
+TNONE          :: Type.NONE
+TNIL           :: Type.NIL
+TBOOLEAN       :: Type.BOOLEAN
+TLIGHTUSERDATA :: Type.LIGHTUSERDATA
+TNUMBER        :: Type.NUMBER
+TSTRING        :: Type.STRING
+TTABLE         :: Type.TABLE
+TFUNCTION      :: Type.FUNCTION
+TUSERDATA      :: Type.USERDATA
+TTHREAD        :: Type.THREAD
+NUMTYPES :: 9
+
+
+CompareOp :: enum c.int {
+	EQ = 0,
+	LT = 1,
+	LE = 2,
+}
+
+OPEQ :: CompareOp.EQ
+OPLT :: CompareOp.LT
+OPLE :: CompareOp.LE
+
+
+/* minimum Lua stack available to a C function */
+MINSTACK :: 20
+
+
+/* type of numbers in Lua */
+Number :: distinct (f32 when size_of(uintptr) == 4 else f64)
+
+
+/* type for integer functions */
+Integer :: distinct (i32 when size_of(uintptr) == 4 else i64)
+
+
+/*
+** Type for C functions registered with Lua
+*/
+CFunction :: #type proc "c" (L: ^State) -> c.int
+
+
+
+/*
+** Type for functions that read/write blocks when loading/dumping Lua chunks
+*/
+Reader :: #type proc "c" (L: ^State, ud: rawptr, sz: ^c.size_t) -> cstring
+Writer :: #type proc "c" (L: ^State, p: rawptr, sz: ^c.size_t, ud: rawptr) -> c.int
+
+
+/*
+** Type for memory-allocation functions
+*/
+Alloc :: #type proc "c" (ud: rawptr, ptr: rawptr, osize, nsize: c.size_t) -> rawptr
+
+
+GCWhat :: enum c.int {
+	STOP        = 0,
+	RESTART     = 1,
+	COLLECT     = 2,
+	COUNT       = 3,
+	COUNTB      = 4,
+	STEP        = 5,
+	SETPAUSE    = 6,
+	SETSTEPMUL  = 7,
+}
+GCSTOP        :: GCWhat.STOP
+GCRESTART     :: GCWhat.RESTART
+GCCOLLECT     :: GCWhat.COLLECT
+GCCOUNT       :: GCWhat.COUNT
+GCCOUNTB      :: GCWhat.COUNTB
+GCSTEP        :: GCWhat.STEP
+GCSETPAUSE    :: GCWhat.SETPAUSE
+GCSETSTEPMUL  :: GCWhat.SETSTEPMUL
+
+
+/*
+** Event codes
+*/
+
+HookEvent :: enum c.int {
+	CALL     = 0,
+	RET      = 1,
+	LINE     = 2,
+	COUNT    = 3,
+	TAILRET  = 4,
+}
+HOOKCALL    :: HookEvent.CALL
+HOOKRET     :: HookEvent.RET
+HOOKLINE    :: HookEvent.LINE
+HOOKCOUNT   :: HookEvent.COUNT
+HOOKTAILRET :: HookEvent.TAILRET
+
+
+/*
+** Event masks
+*/
+HookMask :: distinct bit_set[HookEvent; c.int]
+MASKCALL  :: HookMask{.CALL}
+MASKRET   :: HookMask{.RET}
+MASKLINE  :: HookMask{.LINE}
+MASKCOUNT :: HookMask{.COUNT}
+
+/* activation record */
+Debug :: struct {
+	event:           HookEvent,
+	name:            cstring,              /* (n) */
+	namewhat:        cstring,              /* (n) 'global', 'local', 'field', 'method' */
+	what:            cstring,              /* (S) 'Lua', 'C', 'main', 'tail' */
+	source:          cstring,              /* (S) */
+	currentline:     c.int,                /* (l) */
+	nups:            c.int,                /* (u) number of upvalues */
+	linedefined:     c.int,                /* (S) */
+	lastlinedefined: c.int,                /* (S) */
+	short_src:       [IDSIZE]u8 `fmt:"s"`, /* (S) */
+	/* private part */
+	i_ci:            c.int,                /* active function */
+}
+
+
+/* Functions to be called by the debugger in specific events */
+Hook :: #type proc "c" (L: ^State, ar: ^Debug)
+
+
+State :: struct {} // opaque data type
+
+
+@(link_prefix="lua_")
+@(default_calling_convention="c")
+foreign lib {
+	/*
+	** RCS ident string
+	*/
+
+	ident: [^]u8 // TODO(bill): is this correct?
+
+
+	/*
+	** state manipulation
+	*/
+
+	newstate  :: proc(f: Alloc, ud: rawptr) -> ^State ---
+	close     :: proc(L: ^State) ---
+	newthread :: proc(L: ^State) -> ^State ---
+
+	atpanic :: proc(L: ^State, panicf: CFunction) -> CFunction ---
+
+
+	/*
+	** basic stack manipulation
+	*/
+
+	gettop     :: proc (L: ^State) -> c.int ---
+	settop     :: proc (L: ^State, idx: c.int) ---
+	pushvalue  :: proc (L: ^State, idx: c.int) ---
+	remove     :: proc (L: ^State, idx: c.int) ---
+	insert     :: proc (L: ^State, idx: c.int) ---
+	replace    :: proc (L: ^State, idx: c.int) ---
+	checkstack :: proc (L: ^State, sz: c.int) -> c.int ---
+
+	xmove :: proc(from, to: ^State, n: c.int) ---
+
+
+	/*
+	** access functions (stack -> C)
+	*/
+
+	isnumber    :: proc(L: ^State, idx: c.int) -> b32 ---
+	isstring    :: proc(L: ^State, idx: c.int) -> b32 ---
+	iscfunction :: proc(L: ^State, idx: c.int) -> b32 ---
+	isinteger   :: proc(L: ^State, idx: c.int) -> b32 ---
+	isuserdata  :: proc(L: ^State, idx: c.int) -> b32 ---
+	type        :: proc(L: ^State, idx: c.int) -> Type ---
+	typename    :: proc(L: ^State, tp: Type) -> cstring ---
+
+	equal    :: proc(L: ^State, idx1, idx2: c.int) -> b32 ---
+	rawequal :: proc(L: ^State, idx1, idx2: c.int) -> b32 ---
+	lessthan :: proc(L: ^State, idx1, idx2: c.int) -> b32 ---
+
+	toboolean   :: proc(L: ^State, idx: c.int) -> b32 ---
+	tolstring   :: proc(L: ^State, idx: c.int, len: ^c.size_t) -> cstring ---
+	objlen      :: proc(L: ^State, idx: c.int) -> c.size_t ---
+	tocfunction :: proc(L: ^State, idx: c.int) -> CFunction ---
+	touserdata  :: proc(L: ^State, idx: c.int) -> rawptr ---
+	tothread    :: proc(L: ^State, idx: c.int) -> ^State ---
+	topointer   :: proc(L: ^State, idx: c.int) -> rawptr ---
+
+	/*
+	** push functions (C -> stack)
+	*/
+
+	pushnil      :: proc(L: ^State) ---
+	pushnumber   :: proc(L: ^State, n: Number) ---
+	pushinteger  :: proc(L: ^State, n: Integer) ---
+	pushlstring  :: proc(L: ^State, s: cstring, l: c.size_t) ---
+	pushstring   :: proc(L: ^State, s: cstring) ---
+	pushvfstring :: proc(L: ^State, fmt: cstring, argp: c.va_list) -> cstring ---
+	pushfstring       :: proc(L: ^State, fmt: cstring, #c_vararg args: ..any) -> cstring ---
+	pushcclosure      :: proc(L: ^State, fn: CFunction, n: c.int) ---
+	pushboolean       :: proc(L: ^State, b: b32) ---
+	pushlightuserdata :: proc(L: ^State, p: rawptr) ---
+	pushthread        :: proc(L: ^State) -> Status ---
+
+	/*
+	** get functions (Lua -> stack)
+	*/
+
+	gettable  :: proc(L: ^State, idx: c.int) ---
+	getfield  :: proc(L: ^State, idx: c.int, k: cstring) ---
+	geti      :: proc(L: ^State, idx: c.int, n: Integer) ---
+	rawget    :: proc(L: ^State, idx: c.int) ---
+	rawgeti   :: proc(L: ^State, idx: c.int, n: Integer) ---
+	rawgetp   :: proc(L: ^State, idx: c.int, p: rawptr) ---
+
+	createtable  :: proc(L: ^State, narr, nrec: c.int) ---
+	newuserdata  :: proc(L: ^State, sz: c.size_t) -> rawptr ---
+	getmetatable :: proc(L: ^State, objindex: c.int) -> c.int ---
+	getfenv      :: proc(L: ^State, idx: c.int) ---
+
+
+	/*
+	** set functions (stack -> Lua)
+	*/
+
+	settable     :: proc(L: ^State, idx: c.int) ---
+	setfield     :: proc(L: ^State, idx: c.int, k: cstring) ---
+	rawset       :: proc(L: ^State, idx: c.int) ---
+	rawseti      :: proc(L: ^State, idx: c.int, n: c.int) ---
+	rawsetp      :: proc(L: ^State, idx: c.int, p: rawptr) ---
+	setmetatable :: proc(L: ^State, objindex: c.int) -> c.int ---
+	setfenv      :: proc(L: ^State, idx: c.int) -> c.int ---
+
+
+	/*
+	** 'load' and 'call' functions (load and run Lua code)
+	*/
+
+	call :: proc(L: ^State, nargs, nresults: c.int) ---
+
+	getctx :: proc(L: ^State, ctx: ^c.int) -> c.int ---
+
+	pcall :: proc(L: ^State, nargs, nresults: c.int, errfunc: c.int) -> c.int ---
+	cpcall :: proc(L: ^State, func: CFunction, ud: rawptr) -> c.int ---
+
+	load :: proc(L: ^State, reader: Reader, dt: rawptr,
+	             chunkname: cstring) -> Status ---
+
+	dump :: proc(L: ^State, writer: Writer, data: rawptr) -> Status ---
+
+
+	/*
+	** coroutine functions
+	*/
+
+	yield       :: proc(L: ^State, nresults: c.int) -> Status ---
+	resume      :: proc(L: ^State, narg: c.int) -> Status ---
+	status      :: proc(L: ^State) -> Status ---
+
+
+	/*
+	** garbage-collection function and options
+	*/
+
+
+
+	gc :: proc(L: ^State, what: GCWhat, data: c.int) -> c.int ---
+
+
+	/*
+	** miscellaneous functions
+	*/
+
+	error :: proc(L: ^State) -> Status ---
+
+	next :: proc(L: ^State, idx: c.int) -> c.int ---
+
+	concat :: proc(L: ^State, n: c.int) ---
+	len    :: proc(L: ^State, idx: c.int) ---
+
+	getallocf :: proc(L: State, ud: ^rawptr) -> Alloc ---
+	setallocf :: proc(L: ^State, f: Alloc, ud: rawptr) ---
+
+	/*
+	** {======================================================================
+	** Debug API
+	** =======================================================================
+	*/
+
+	getstack   :: proc(L: ^State, level: c.int, ar: ^Debug) -> c.int ---
+	getinfo    :: proc(L: ^State, what: cstring, ar: ^Debug) -> c.int ---
+	getlocal   :: proc(L: ^State, ar: ^Debug, n: c.int) -> cstring ---
+	setlocal   :: proc(L: ^State, ar: ^Debug, n: c.int) -> cstring ---
+	getupvalue :: proc(L: ^State, funcindex: c.int, n: c.int) -> cstring ---
+	setupvalue :: proc(L: ^State, funcindex: c.int, n: c.int) -> cstring ---
+
+	sethook :: proc(L: ^State, func: Hook, mask: HookMask, count: c.int) -> c.int ---
+	gethook :: proc(L: ^State) -> Hook ---
+	gethookmask  :: proc(L: ^State) -> HookMask ---
+	gethookcount :: proc(L: ^State) -> c.int ---
+
+	/* }============================================================== */
+}
+
+
+
+COLIBNAME   :: "coroutine"
+TABLIBNAME  :: "table"
+IOLIBNAME   :: "io"
+OSLIBNAME   :: "os"
+STRLIBNAME  :: "string"
+UTF8LIBNAME :: "utf8"
+MATHLIBNAME :: "math"
+DBLIBNAME   :: "debug"
+LOADLIBNAME :: "package"
+
+@(link_prefix="lua")
+@(default_calling_convention="c")
+foreign lib {
+	open_base      :: proc(L: ^State) -> c.int ---
+	open_table     :: proc(L: ^State) -> c.int ---
+	open_io        :: proc(L: ^State) -> c.int ---
+	open_os        :: proc(L: ^State) -> c.int ---
+	open_string    :: proc(L: ^State) -> c.int ---
+	open_utf8      :: proc(L: ^State) -> c.int ---
+	open_math      :: proc(L: ^State) -> c.int ---
+	open_debug     :: proc(L: ^State) -> c.int ---
+	open_package   :: proc(L: ^State) -> c.int ---
+
+	/* open all previous libraries */
+
+	L_openlibs :: proc(L: ^State) ---
+}
+
+
+
+GNAME :: "_G"
+
+L_Reg :: struct {
+	name: cstring,
+  	func: CFunction,
+}
+
+/* predefined references */
+NOREF  :: -2
+REFNIL :: -1
+
+@(link_prefix="lua")
+@(default_calling_convention="c")
+foreign lib {
+	L_openlib      :: proc(L: ^State, libname: cstring, l: [^]L_Reg, nup: c.int) ---
+	L_register     :: proc(L: ^State, libname: cstring, l: ^L_Reg) ---
+	L_getmetafield :: proc(L: ^State, obj: c.int, e: cstring) -> c.int ---
+	L_callmeta     :: proc(L: ^State, obj: c.int, e: cstring) -> c.int ---
+	L_typeerror    :: proc(L: ^State, narg: c.int, tname: cstring) -> c.int ---
+	L_argerror     :: proc(L: ^State, numarg: c.int, extramsg: cstring) -> c.int ---
+	@(link_name="luaL_checklstring")
+	L_checkstring  :: proc(L: ^State, numArg: c.int, l: ^c.size_t = nil) -> cstring ---
+	@(link_name="luaL_optlstring")
+	L_optstring    :: proc(L: ^State, numArg: c.int, def: cstring, l: ^c.size_t = nil) -> cstring ---
+	L_checknumber  :: proc(L: ^State, numArg: c.int) -> Number ---
+	L_optnumber    :: proc(L: ^State, nArg: c.int, def: Number) -> Number ---
+
+	L_checkinteger  :: proc(L: ^State, numArg: c.int) -> Integer ---
+	L_optinteger    :: proc(L: ^State, nArg: c.int, def: Integer) -> Integer ---
+
+
+	L_checkstack :: proc(L: ^State, sz: c.int, msg: cstring) ---
+	L_checktype  :: proc(L: ^State, narg: c.int, t: c.int) ---
+	L_checkany   :: proc(L: ^State, narg: c.int) ---
+
+	L_newmetatable :: proc(L: ^State, tname: cstring) -> c.int ---
+	L_checkudata   :: proc(L: ^State, ud: c.int, tname: cstring) -> rawptr ---
+
+	L_where :: proc(L: ^State, lvl: c.int) ---
+	L_error :: proc(L: ^State, fmt: cstring, #c_vararg args: ..any) -> Status ---
+
+	L_checkoption :: proc(L: ^State, narg: c.int, def: cstring, lst: [^]cstring) -> c.int ---
+
+
+	L_ref   :: proc(L: ^State, t: c.int) -> c.int ---
+	L_unref :: proc(L: ^State, t: c.int, ref: c.int) ---
+
+	L_loadfile :: proc (L: ^State, filename: cstring) -> Status ---
+
+	L_loadbuffer :: proc(L: ^State, buff: [^]byte, sz: c.size_t, name: cstring) -> Status ---
+	L_loadstring  :: proc(L: ^State, s: cstring) -> Status ---
+
+	L_newstate :: proc() -> ^State ---
+
+	L_gsub :: proc(L: ^State, s, p, r: cstring) -> cstring ---
+
+	L_findtable :: proc(L: ^State, idx: c.int, fname: cstring, szhint: c.int) -> cstring ---
+}
+/*
+** {======================================================
+** Generic Buffer manipulation
+** =======================================================
+*/
+
+
+L_Buffer :: struct {
+	p:    [^]byte,  /* buffer address */
+	lvl:  c.int,    /* number of strings in the stack (level) */
+	L:    ^State,
+	buffer: [L_BUFFERSIZE]byte,  /* initial buffer */
+}
+
+L_addchar :: #force_inline proc "c" (B: ^L_Buffer, c: byte) {
+	end := ([^]byte)(&B.buffer)[L_BUFFERSIZE:]
+	if B.p < end {
+		L_prepbuffer(B)
+	}
+	B.p[0] = c
+	B.p = B.p[1:]
+}
+L_putchar :: L_addchar
+
+L_addsize :: #force_inline proc "c" (B: ^L_Buffer, s: c.size_t) -> [^]byte {
+	B.p = B.p[s:]
+	return B.p
+}
+
+
+@(link_prefix="lua")
+@(default_calling_convention="c")
+foreign lib {
+	L_buffinit       :: proc(L: ^State, B: ^L_Buffer) ---
+	L_prepbuffer     :: proc(B: ^L_Buffer) -> [^]byte ---
+	L_addlstring     :: proc(B: ^L_Buffer, s: cstring, l: c.size_t) ---
+	L_addstring      :: proc(B: ^L_Buffer, s: cstring) ---
+	L_addvalue       :: proc(B: ^L_Buffer) ---
+	L_pushresult     :: proc(B: ^L_Buffer) ---
+	L_pushresultsize :: proc(B: ^L_Buffer, sz: c.size_t) ---
+	L_buffinitsize   :: proc(L: ^State, B: ^L_Buffer, sz: c.size_t) -> [^]byte ---
+}
+
+@(link_prefix="lua_")
+@(default_calling_convention="c")
+foreign lib {
+	/* hack */
+	setlevel :: proc(from, to: ^State) ---
+}
+
+
+/* }====================================================== */
+
+
+
+
+/*
+** {==============================================================
+** some useful macros
+** ===============================================================
+*/
+
+pop :: #force_inline proc "c" (L: ^State, n: c.int) {
+	settop(L, -n-1)
+}
+newtable :: #force_inline proc "c" (L: ^State) {
+	createtable(L, 0, 0)
+}
+register :: #force_inline proc "c" (L: ^State, n: cstring, f: CFunction) {
+	pushcfunction(L, f)
+	setglobal(L, n)
+}
+
+pushcfunction :: #force_inline proc "c" (L: ^State, f: CFunction) {
+	pushcclosure(L, f, 0)
+}
+
+strlen :: #force_inline proc "c" (L: ^State, i: c.int) -> c.size_t {
+	return objlen(L, i)
+}
+
+
+isfunction      :: #force_inline proc "c" (L: ^State, n: c.int) -> bool { return type(L, n) == .FUNCTION      }
+istable         :: #force_inline proc "c" (L: ^State, n: c.int) -> bool { return type(L, n) == .TABLE         }
+islightuserdata :: #force_inline proc "c" (L: ^State, n: c.int) -> bool { return type(L, n) == .LIGHTUSERDATA }
+isnil           :: #force_inline proc "c" (L: ^State, n: c.int) -> bool { return type(L, n) == .NIL           }
+isboolean       :: #force_inline proc "c" (L: ^State, n: c.int) -> bool { return type(L, n) == .BOOLEAN       }
+isthread        :: #force_inline proc "c" (L: ^State, n: c.int) -> bool { return type(L, n) == .THREAD        }
+isnone          :: #force_inline proc "c" (L: ^State, n: c.int) -> bool { return type(L, n) == .NONE          }
+isnoneornil     :: #force_inline proc "c" (L: ^State, n: c.int) -> bool { return type(L, n) <= .NIL           }
+
+
+pushliteral :: pushstring
+setglobal :: #force_inline proc "c" (L: ^State, s: cstring) {
+	setfield(L, GLOBALSINDEX, s)
+}
+getglobal :: #force_inline proc "c" (L: ^State, s: cstring) {
+	getfield(L, GLOBALSINDEX, s)
+}
+tostring :: #force_inline proc "c" (L: ^State, i: c.int) -> cstring {
+	return tolstring(L, i, nil)
+}
+
+open :: newstate
+getregistry :: #force_inline proc "c" (L: ^State) {
+	pushvalue(L, REGISTRYINDEX)
+}
+
+getgccount :: #force_inline proc "c" (L: ^State) -> c.int {
+	return gc(L, .COUNT, 0)
+}
+
+Chunkreader :: Reader
+Chunkwriter :: Writer
+
+
+L_argcheck :: #force_inline proc "c" (L: ^State, cond: bool, numarg: c.int, extramsg: cstring) {
+	if cond {
+		L_argerror(L, numarg, extramsg)
+	}
+}
+
+L_typename :: #force_inline proc "c" (L: ^State, i: c.int) -> cstring {
+	return typename(L, type(L, i))
+}
+L_dofile :: #force_inline proc "c" (L: ^State, s: cstring) -> c.int {
+	err := L_loadfile(L, s)
+	return pcall(L, 0, MULTRET, 0) if err == nil else c.int(err)
+}
+L_dostring :: #force_inline proc "c" (L: ^State, s: cstring) -> c.int {
+	err := L_loadstring(L, s)
+	return pcall(L, 0, MULTRET, 0) if err == nil else c.int(err)
+}
+L_getmetatable :: #force_inline proc "c" (L: ^State, n: cstring) {
+	getfield(L, REGISTRYINDEX, n)
+}
+L_opt :: #force_inline proc "c" (L: ^State, f: $F, n: c.int, d: $T) -> T where intrinsics.type_is_proc(F) {
+	return d if isnoneornil(L, n) else f(L, n)
+}
+
+
+
+ref :: #force_inline proc "c" (L: ^State, lock: bool) -> c.int {
+	if lock {
+		return L_ref(L, REGISTRYINDEX)
+	}
+	pushstring(L, "unlocked references are obsolete")
+	error(L)
+	return 0
+}
+unref :: #force_inline proc "c" (L: ^State, ref: c.int) {
+	L_unref(L,REGISTRYINDEX, ref)
+}
+getref :: #force_inline proc "c" (L: ^State, ref: Integer) {
+	rawgeti(L, REGISTRYINDEX, ref)
+}
+
+
+/* }============================================================== */

BIN
vendor/lua/5.1/windows/lua5.1.dll


BIN
vendor/lua/5.1/windows/lua5.1.dll.lib


+ 212 - 0
vendor/lua/5.2/include/lauxlib.h

@@ -0,0 +1,212 @@
+/*
+** $Id: lauxlib.h,v 1.120.1.1 2013/04/12 18:48:47 roberto Exp $
+** Auxiliary functions for building Lua libraries
+** See Copyright Notice in lua.h
+*/
+
+
+#ifndef lauxlib_h
+#define lauxlib_h
+
+
+#include <stddef.h>
+#include <stdio.h>
+
+#include "lua.h"
+
+
+
+/* extra error code for `luaL_load' */
+#define LUA_ERRFILE     (LUA_ERRERR+1)
+
+
+typedef struct luaL_Reg {
+  const char *name;
+  lua_CFunction func;
+} luaL_Reg;
+
+
+LUALIB_API void (luaL_checkversion_) (lua_State *L, lua_Number ver);
+#define luaL_checkversion(L)	luaL_checkversion_(L, LUA_VERSION_NUM)
+
+LUALIB_API int (luaL_getmetafield) (lua_State *L, int obj, const char *e);
+LUALIB_API int (luaL_callmeta) (lua_State *L, int obj, const char *e);
+LUALIB_API const char *(luaL_tolstring) (lua_State *L, int idx, size_t *len);
+LUALIB_API int (luaL_argerror) (lua_State *L, int numarg, const char *extramsg);
+LUALIB_API const char *(luaL_checklstring) (lua_State *L, int numArg,
+                                                          size_t *l);
+LUALIB_API const char *(luaL_optlstring) (lua_State *L, int numArg,
+                                          const char *def, size_t *l);
+LUALIB_API lua_Number (luaL_checknumber) (lua_State *L, int numArg);
+LUALIB_API lua_Number (luaL_optnumber) (lua_State *L, int nArg, lua_Number def);
+
+LUALIB_API lua_Integer (luaL_checkinteger) (lua_State *L, int numArg);
+LUALIB_API lua_Integer (luaL_optinteger) (lua_State *L, int nArg,
+                                          lua_Integer def);
+LUALIB_API lua_Unsigned (luaL_checkunsigned) (lua_State *L, int numArg);
+LUALIB_API lua_Unsigned (luaL_optunsigned) (lua_State *L, int numArg,
+                                            lua_Unsigned def);
+
+LUALIB_API void (luaL_checkstack) (lua_State *L, int sz, const char *msg);
+LUALIB_API void (luaL_checktype) (lua_State *L, int narg, int t);
+LUALIB_API void (luaL_checkany) (lua_State *L, int narg);
+
+LUALIB_API int   (luaL_newmetatable) (lua_State *L, const char *tname);
+LUALIB_API void  (luaL_setmetatable) (lua_State *L, const char *tname);
+LUALIB_API void *(luaL_testudata) (lua_State *L, int ud, const char *tname);
+LUALIB_API void *(luaL_checkudata) (lua_State *L, int ud, const char *tname);
+
+LUALIB_API void (luaL_where) (lua_State *L, int lvl);
+LUALIB_API int (luaL_error) (lua_State *L, const char *fmt, ...);
+
+LUALIB_API int (luaL_checkoption) (lua_State *L, int narg, const char *def,
+                                   const char *const lst[]);
+
+LUALIB_API int (luaL_fileresult) (lua_State *L, int stat, const char *fname);
+LUALIB_API int (luaL_execresult) (lua_State *L, int stat);
+
+/* pre-defined references */
+#define LUA_NOREF       (-2)
+#define LUA_REFNIL      (-1)
+
+LUALIB_API int (luaL_ref) (lua_State *L, int t);
+LUALIB_API void (luaL_unref) (lua_State *L, int t, int ref);
+
+LUALIB_API int (luaL_loadfilex) (lua_State *L, const char *filename,
+                                               const char *mode);
+
+#define luaL_loadfile(L,f)	luaL_loadfilex(L,f,NULL)
+
+LUALIB_API int (luaL_loadbufferx) (lua_State *L, const char *buff, size_t sz,
+                                   const char *name, const char *mode);
+LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s);
+
+LUALIB_API lua_State *(luaL_newstate) (void);
+
+LUALIB_API int (luaL_len) (lua_State *L, int idx);
+
+LUALIB_API const char *(luaL_gsub) (lua_State *L, const char *s, const char *p,
+                                                  const char *r);
+
+LUALIB_API void (luaL_setfuncs) (lua_State *L, const luaL_Reg *l, int nup);
+
+LUALIB_API int (luaL_getsubtable) (lua_State *L, int idx, const char *fname);
+
+LUALIB_API void (luaL_traceback) (lua_State *L, lua_State *L1,
+                                  const char *msg, int level);
+
+LUALIB_API void (luaL_requiref) (lua_State *L, const char *modname,
+                                 lua_CFunction openf, int glb);
+
+/*
+** ===============================================================
+** some useful macros
+** ===============================================================
+*/
+
+
+#define luaL_newlibtable(L,l)	\
+  lua_createtable(L, 0, sizeof(l)/sizeof((l)[0]) - 1)
+
+#define luaL_newlib(L,l)	(luaL_newlibtable(L,l), luaL_setfuncs(L,l,0))
+
+#define luaL_argcheck(L, cond,numarg,extramsg)	\
+		((void)((cond) || luaL_argerror(L, (numarg), (extramsg))))
+#define luaL_checkstring(L,n)	(luaL_checklstring(L, (n), NULL))
+#define luaL_optstring(L,n,d)	(luaL_optlstring(L, (n), (d), NULL))
+#define luaL_checkint(L,n)	((int)luaL_checkinteger(L, (n)))
+#define luaL_optint(L,n,d)	((int)luaL_optinteger(L, (n), (d)))
+#define luaL_checklong(L,n)	((long)luaL_checkinteger(L, (n)))
+#define luaL_optlong(L,n,d)	((long)luaL_optinteger(L, (n), (d)))
+
+#define luaL_typename(L,i)	lua_typename(L, lua_type(L,(i)))
+
+#define luaL_dofile(L, fn) \
+	(luaL_loadfile(L, fn) || lua_pcall(L, 0, LUA_MULTRET, 0))
+
+#define luaL_dostring(L, s) \
+	(luaL_loadstring(L, s) || lua_pcall(L, 0, LUA_MULTRET, 0))
+
+#define luaL_getmetatable(L,n)	(lua_getfield(L, LUA_REGISTRYINDEX, (n)))
+
+#define luaL_opt(L,f,n,d)	(lua_isnoneornil(L,(n)) ? (d) : f(L,(n)))
+
+#define luaL_loadbuffer(L,s,sz,n)	luaL_loadbufferx(L,s,sz,n,NULL)
+
+
+/*
+** {======================================================
+** Generic Buffer manipulation
+** =======================================================
+*/
+
+typedef struct luaL_Buffer {
+  char *b;  /* buffer address */
+  size_t size;  /* buffer size */
+  size_t n;  /* number of characters in buffer */
+  lua_State *L;
+  char initb[LUAL_BUFFERSIZE];  /* initial buffer */
+} luaL_Buffer;
+
+
+#define luaL_addchar(B,c) \
+  ((void)((B)->n < (B)->size || luaL_prepbuffsize((B), 1)), \
+   ((B)->b[(B)->n++] = (c)))
+
+#define luaL_addsize(B,s)	((B)->n += (s))
+
+LUALIB_API void (luaL_buffinit) (lua_State *L, luaL_Buffer *B);
+LUALIB_API char *(luaL_prepbuffsize) (luaL_Buffer *B, size_t sz);
+LUALIB_API void (luaL_addlstring) (luaL_Buffer *B, const char *s, size_t l);
+LUALIB_API void (luaL_addstring) (luaL_Buffer *B, const char *s);
+LUALIB_API void (luaL_addvalue) (luaL_Buffer *B);
+LUALIB_API void (luaL_pushresult) (luaL_Buffer *B);
+LUALIB_API void (luaL_pushresultsize) (luaL_Buffer *B, size_t sz);
+LUALIB_API char *(luaL_buffinitsize) (lua_State *L, luaL_Buffer *B, size_t sz);
+
+#define luaL_prepbuffer(B)	luaL_prepbuffsize(B, LUAL_BUFFERSIZE)
+
+/* }====================================================== */
+
+
+
+/*
+** {======================================================
+** File handles for IO library
+** =======================================================
+*/
+
+/*
+** A file handle is a userdata with metatable 'LUA_FILEHANDLE' and
+** initial structure 'luaL_Stream' (it may contain other fields
+** after that initial structure).
+*/
+
+#define LUA_FILEHANDLE          "FILE*"
+
+
+typedef struct luaL_Stream {
+  FILE *f;  /* stream (NULL for incompletely created streams) */
+  lua_CFunction closef;  /* to close stream (NULL for closed streams) */
+} luaL_Stream;
+
+/* }====================================================== */
+
+
+
+/* compatibility with old module system */
+#if defined(LUA_COMPAT_MODULE)
+
+LUALIB_API void (luaL_pushmodule) (lua_State *L, const char *modname,
+                                   int sizehint);
+LUALIB_API void (luaL_openlib) (lua_State *L, const char *libname,
+                                const luaL_Reg *l, int nup);
+
+#define luaL_register(L,n,l)	(luaL_openlib(L,(n),(l),0))
+
+#endif
+
+
+#endif
+
+

+ 444 - 0
vendor/lua/5.2/include/lua.h

@@ -0,0 +1,444 @@
+/*
+** $Id: lua.h,v 1.285.1.4 2015/02/21 14:04:50 roberto Exp $
+** Lua - A Scripting Language
+** Lua.org, PUC-Rio, Brazil (http://www.lua.org)
+** See Copyright Notice at the end of this file
+*/
+
+
+#ifndef lua_h
+#define lua_h
+
+#include <stdarg.h>
+#include <stddef.h>
+
+
+#include "luaconf.h"
+
+
+#define LUA_VERSION_MAJOR	"5"
+#define LUA_VERSION_MINOR	"2"
+#define LUA_VERSION_NUM		502
+#define LUA_VERSION_RELEASE	"4"
+
+#define LUA_VERSION	"Lua " LUA_VERSION_MAJOR "." LUA_VERSION_MINOR
+#define LUA_RELEASE	LUA_VERSION "." LUA_VERSION_RELEASE
+#define LUA_COPYRIGHT	LUA_RELEASE "  Copyright (C) 1994-2015 Lua.org, PUC-Rio"
+#define LUA_AUTHORS	"R. Ierusalimschy, L. H. de Figueiredo, W. Celes"
+
+
+/* mark for precompiled code ('<esc>Lua') */
+#define LUA_SIGNATURE	"\033Lua"
+
+/* option for multiple returns in 'lua_pcall' and 'lua_call' */
+#define LUA_MULTRET	(-1)
+
+
+/*
+** pseudo-indices
+*/
+#define LUA_REGISTRYINDEX	LUAI_FIRSTPSEUDOIDX
+#define lua_upvalueindex(i)	(LUA_REGISTRYINDEX - (i))
+
+
+/* thread status */
+#define LUA_OK		0
+#define LUA_YIELD	1
+#define LUA_ERRRUN	2
+#define LUA_ERRSYNTAX	3
+#define LUA_ERRMEM	4
+#define LUA_ERRGCMM	5
+#define LUA_ERRERR	6
+
+
+typedef struct lua_State lua_State;
+
+typedef int (*lua_CFunction) (lua_State *L);
+
+
+/*
+** functions that read/write blocks when loading/dumping Lua chunks
+*/
+typedef const char * (*lua_Reader) (lua_State *L, void *ud, size_t *sz);
+
+typedef int (*lua_Writer) (lua_State *L, const void* p, size_t sz, void* ud);
+
+
+/*
+** prototype for memory-allocation functions
+*/
+typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize);
+
+
+/*
+** basic types
+*/
+#define LUA_TNONE		(-1)
+
+#define LUA_TNIL		0
+#define LUA_TBOOLEAN		1
+#define LUA_TLIGHTUSERDATA	2
+#define LUA_TNUMBER		3
+#define LUA_TSTRING		4
+#define LUA_TTABLE		5
+#define LUA_TFUNCTION		6
+#define LUA_TUSERDATA		7
+#define LUA_TTHREAD		8
+
+#define LUA_NUMTAGS		9
+
+
+
+/* minimum Lua stack available to a C function */
+#define LUA_MINSTACK	20
+
+
+/* predefined values in the registry */
+#define LUA_RIDX_MAINTHREAD	1
+#define LUA_RIDX_GLOBALS	2
+#define LUA_RIDX_LAST		LUA_RIDX_GLOBALS
+
+
+/* type of numbers in Lua */
+typedef LUA_NUMBER lua_Number;
+
+
+/* type for integer functions */
+typedef LUA_INTEGER lua_Integer;
+
+/* unsigned integer type */
+typedef LUA_UNSIGNED lua_Unsigned;
+
+
+
+/*
+** generic extra include file
+*/
+#if defined(LUA_USER_H)
+#include LUA_USER_H
+#endif
+
+
+/*
+** RCS ident string
+*/
+extern const char lua_ident[];
+
+
+/*
+** state manipulation
+*/
+LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud);
+LUA_API void       (lua_close) (lua_State *L);
+LUA_API lua_State *(lua_newthread) (lua_State *L);
+
+LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf);
+
+
+LUA_API const lua_Number *(lua_version) (lua_State *L);
+
+
+/*
+** basic stack manipulation
+*/
+LUA_API int   (lua_absindex) (lua_State *L, int idx);
+LUA_API int   (lua_gettop) (lua_State *L);
+LUA_API void  (lua_settop) (lua_State *L, int idx);
+LUA_API void  (lua_pushvalue) (lua_State *L, int idx);
+LUA_API void  (lua_remove) (lua_State *L, int idx);
+LUA_API void  (lua_insert) (lua_State *L, int idx);
+LUA_API void  (lua_replace) (lua_State *L, int idx);
+LUA_API void  (lua_copy) (lua_State *L, int fromidx, int toidx);
+LUA_API int   (lua_checkstack) (lua_State *L, int sz);
+
+LUA_API void  (lua_xmove) (lua_State *from, lua_State *to, int n);
+
+
+/*
+** access functions (stack -> C)
+*/
+
+LUA_API int             (lua_isnumber) (lua_State *L, int idx);
+LUA_API int             (lua_isstring) (lua_State *L, int idx);
+LUA_API int             (lua_iscfunction) (lua_State *L, int idx);
+LUA_API int             (lua_isuserdata) (lua_State *L, int idx);
+LUA_API int             (lua_type) (lua_State *L, int idx);
+LUA_API const char     *(lua_typename) (lua_State *L, int tp);
+
+LUA_API lua_Number      (lua_tonumberx) (lua_State *L, int idx, int *isnum);
+LUA_API lua_Integer     (lua_tointegerx) (lua_State *L, int idx, int *isnum);
+LUA_API lua_Unsigned    (lua_tounsignedx) (lua_State *L, int idx, int *isnum);
+LUA_API int             (lua_toboolean) (lua_State *L, int idx);
+LUA_API const char     *(lua_tolstring) (lua_State *L, int idx, size_t *len);
+LUA_API size_t          (lua_rawlen) (lua_State *L, int idx);
+LUA_API lua_CFunction   (lua_tocfunction) (lua_State *L, int idx);
+LUA_API void	       *(lua_touserdata) (lua_State *L, int idx);
+LUA_API lua_State      *(lua_tothread) (lua_State *L, int idx);
+LUA_API const void     *(lua_topointer) (lua_State *L, int idx);
+
+
+/*
+** Comparison and arithmetic functions
+*/
+
+#define LUA_OPADD	0	/* ORDER TM */
+#define LUA_OPSUB	1
+#define LUA_OPMUL	2
+#define LUA_OPDIV	3
+#define LUA_OPMOD	4
+#define LUA_OPPOW	5
+#define LUA_OPUNM	6
+
+LUA_API void  (lua_arith) (lua_State *L, int op);
+
+#define LUA_OPEQ	0
+#define LUA_OPLT	1
+#define LUA_OPLE	2
+
+LUA_API int   (lua_rawequal) (lua_State *L, int idx1, int idx2);
+LUA_API int   (lua_compare) (lua_State *L, int idx1, int idx2, int op);
+
+
+/*
+** push functions (C -> stack)
+*/
+LUA_API void        (lua_pushnil) (lua_State *L);
+LUA_API void        (lua_pushnumber) (lua_State *L, lua_Number n);
+LUA_API void        (lua_pushinteger) (lua_State *L, lua_Integer n);
+LUA_API void        (lua_pushunsigned) (lua_State *L, lua_Unsigned n);
+LUA_API const char *(lua_pushlstring) (lua_State *L, const char *s, size_t l);
+LUA_API const char *(lua_pushstring) (lua_State *L, const char *s);
+LUA_API const char *(lua_pushvfstring) (lua_State *L, const char *fmt,
+                                                      va_list argp);
+LUA_API const char *(lua_pushfstring) (lua_State *L, const char *fmt, ...);
+LUA_API void  (lua_pushcclosure) (lua_State *L, lua_CFunction fn, int n);
+LUA_API void  (lua_pushboolean) (lua_State *L, int b);
+LUA_API void  (lua_pushlightuserdata) (lua_State *L, void *p);
+LUA_API int   (lua_pushthread) (lua_State *L);
+
+
+/*
+** get functions (Lua -> stack)
+*/
+LUA_API void  (lua_getglobal) (lua_State *L, const char *var);
+LUA_API void  (lua_gettable) (lua_State *L, int idx);
+LUA_API void  (lua_getfield) (lua_State *L, int idx, const char *k);
+LUA_API void  (lua_rawget) (lua_State *L, int idx);
+LUA_API void  (lua_rawgeti) (lua_State *L, int idx, int n);
+LUA_API void  (lua_rawgetp) (lua_State *L, int idx, const void *p);
+LUA_API void  (lua_createtable) (lua_State *L, int narr, int nrec);
+LUA_API void *(lua_newuserdata) (lua_State *L, size_t sz);
+LUA_API int   (lua_getmetatable) (lua_State *L, int objindex);
+LUA_API void  (lua_getuservalue) (lua_State *L, int idx);
+
+
+/*
+** set functions (stack -> Lua)
+*/
+LUA_API void  (lua_setglobal) (lua_State *L, const char *var);
+LUA_API void  (lua_settable) (lua_State *L, int idx);
+LUA_API void  (lua_setfield) (lua_State *L, int idx, const char *k);
+LUA_API void  (lua_rawset) (lua_State *L, int idx);
+LUA_API void  (lua_rawseti) (lua_State *L, int idx, int n);
+LUA_API void  (lua_rawsetp) (lua_State *L, int idx, const void *p);
+LUA_API int   (lua_setmetatable) (lua_State *L, int objindex);
+LUA_API void  (lua_setuservalue) (lua_State *L, int idx);
+
+
+/*
+** 'load' and 'call' functions (load and run Lua code)
+*/
+LUA_API void  (lua_callk) (lua_State *L, int nargs, int nresults, int ctx,
+                           lua_CFunction k);
+#define lua_call(L,n,r)		lua_callk(L, (n), (r), 0, NULL)
+
+LUA_API int   (lua_getctx) (lua_State *L, int *ctx);
+
+LUA_API int   (lua_pcallk) (lua_State *L, int nargs, int nresults, int errfunc,
+                            int ctx, lua_CFunction k);
+#define lua_pcall(L,n,r,f)	lua_pcallk(L, (n), (r), (f), 0, NULL)
+
+LUA_API int   (lua_load) (lua_State *L, lua_Reader reader, void *dt,
+                                        const char *chunkname,
+                                        const char *mode);
+
+LUA_API int (lua_dump) (lua_State *L, lua_Writer writer, void *data);
+
+
+/*
+** coroutine functions
+*/
+LUA_API int  (lua_yieldk) (lua_State *L, int nresults, int ctx,
+                           lua_CFunction k);
+#define lua_yield(L,n)		lua_yieldk(L, (n), 0, NULL)
+LUA_API int  (lua_resume) (lua_State *L, lua_State *from, int narg);
+LUA_API int  (lua_status) (lua_State *L);
+
+/*
+** garbage-collection function and options
+*/
+
+#define LUA_GCSTOP		0
+#define LUA_GCRESTART		1
+#define LUA_GCCOLLECT		2
+#define LUA_GCCOUNT		3
+#define LUA_GCCOUNTB		4
+#define LUA_GCSTEP		5
+#define LUA_GCSETPAUSE		6
+#define LUA_GCSETSTEPMUL	7
+#define LUA_GCSETMAJORINC	8
+#define LUA_GCISRUNNING		9
+#define LUA_GCGEN		10
+#define LUA_GCINC		11
+
+LUA_API int (lua_gc) (lua_State *L, int what, int data);
+
+
+/*
+** miscellaneous functions
+*/
+
+LUA_API int   (lua_error) (lua_State *L);
+
+LUA_API int   (lua_next) (lua_State *L, int idx);
+
+LUA_API void  (lua_concat) (lua_State *L, int n);
+LUA_API void  (lua_len)    (lua_State *L, int idx);
+
+LUA_API lua_Alloc (lua_getallocf) (lua_State *L, void **ud);
+LUA_API void      (lua_setallocf) (lua_State *L, lua_Alloc f, void *ud);
+
+
+
+/*
+** ===============================================================
+** some useful macros
+** ===============================================================
+*/
+
+#define lua_tonumber(L,i)	lua_tonumberx(L,i,NULL)
+#define lua_tointeger(L,i)	lua_tointegerx(L,i,NULL)
+#define lua_tounsigned(L,i)	lua_tounsignedx(L,i,NULL)
+
+#define lua_pop(L,n)		lua_settop(L, -(n)-1)
+
+#define lua_newtable(L)		lua_createtable(L, 0, 0)
+
+#define lua_register(L,n,f) (lua_pushcfunction(L, (f)), lua_setglobal(L, (n)))
+
+#define lua_pushcfunction(L,f)	lua_pushcclosure(L, (f), 0)
+
+#define lua_isfunction(L,n)	(lua_type(L, (n)) == LUA_TFUNCTION)
+#define lua_istable(L,n)	(lua_type(L, (n)) == LUA_TTABLE)
+#define lua_islightuserdata(L,n)	(lua_type(L, (n)) == LUA_TLIGHTUSERDATA)
+#define lua_isnil(L,n)		(lua_type(L, (n)) == LUA_TNIL)
+#define lua_isboolean(L,n)	(lua_type(L, (n)) == LUA_TBOOLEAN)
+#define lua_isthread(L,n)	(lua_type(L, (n)) == LUA_TTHREAD)
+#define lua_isnone(L,n)		(lua_type(L, (n)) == LUA_TNONE)
+#define lua_isnoneornil(L, n)	(lua_type(L, (n)) <= 0)
+
+#define lua_pushliteral(L, s)	\
+	lua_pushlstring(L, "" s, (sizeof(s)/sizeof(char))-1)
+
+#define lua_pushglobaltable(L)  \
+	lua_rawgeti(L, LUA_REGISTRYINDEX, LUA_RIDX_GLOBALS)
+
+#define lua_tostring(L,i)	lua_tolstring(L, (i), NULL)
+
+
+
+/*
+** {======================================================================
+** Debug API
+** =======================================================================
+*/
+
+
+/*
+** Event codes
+*/
+#define LUA_HOOKCALL	0
+#define LUA_HOOKRET	1
+#define LUA_HOOKLINE	2
+#define LUA_HOOKCOUNT	3
+#define LUA_HOOKTAILCALL 4
+
+
+/*
+** Event masks
+*/
+#define LUA_MASKCALL	(1 << LUA_HOOKCALL)
+#define LUA_MASKRET	(1 << LUA_HOOKRET)
+#define LUA_MASKLINE	(1 << LUA_HOOKLINE)
+#define LUA_MASKCOUNT	(1 << LUA_HOOKCOUNT)
+
+typedef struct lua_Debug lua_Debug;  /* activation record */
+
+
+/* Functions to be called by the debugger in specific events */
+typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar);
+
+
+LUA_API int (lua_getstack) (lua_State *L, int level, lua_Debug *ar);
+LUA_API int (lua_getinfo) (lua_State *L, const char *what, lua_Debug *ar);
+LUA_API const char *(lua_getlocal) (lua_State *L, const lua_Debug *ar, int n);
+LUA_API const char *(lua_setlocal) (lua_State *L, const lua_Debug *ar, int n);
+LUA_API const char *(lua_getupvalue) (lua_State *L, int funcindex, int n);
+LUA_API const char *(lua_setupvalue) (lua_State *L, int funcindex, int n);
+
+LUA_API void *(lua_upvalueid) (lua_State *L, int fidx, int n);
+LUA_API void  (lua_upvaluejoin) (lua_State *L, int fidx1, int n1,
+                                               int fidx2, int n2);
+
+LUA_API int (lua_sethook) (lua_State *L, lua_Hook func, int mask, int count);
+LUA_API lua_Hook (lua_gethook) (lua_State *L);
+LUA_API int (lua_gethookmask) (lua_State *L);
+LUA_API int (lua_gethookcount) (lua_State *L);
+
+
+struct lua_Debug {
+  int event;
+  const char *name;	/* (n) */
+  const char *namewhat;	/* (n) 'global', 'local', 'field', 'method' */
+  const char *what;	/* (S) 'Lua', 'C', 'main', 'tail' */
+  const char *source;	/* (S) */
+  int currentline;	/* (l) */
+  int linedefined;	/* (S) */
+  int lastlinedefined;	/* (S) */
+  unsigned char nups;	/* (u) number of upvalues */
+  unsigned char nparams;/* (u) number of parameters */
+  char isvararg;        /* (u) */
+  char istailcall;	/* (t) */
+  char short_src[LUA_IDSIZE]; /* (S) */
+  /* private part */
+  struct CallInfo *i_ci;  /* active function */
+};
+
+/* }====================================================================== */
+
+
+/******************************************************************************
+* Copyright (C) 1994-2015 Lua.org, PUC-Rio.
+*
+* 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.
+******************************************************************************/
+
+
+#endif

+ 9 - 0
vendor/lua/5.2/include/lua.hpp

@@ -0,0 +1,9 @@
+// lua.hpp
+// Lua header files for C++
+// <<extern "C">> not supplied automatically because Lua also compiles as C++
+
+extern "C" {
+#include "lua.h"
+#include "lualib.h"
+#include "lauxlib.h"
+}

+ 553 - 0
vendor/lua/5.2/include/luaconf.h

@@ -0,0 +1,553 @@
+/*
+** $Id: luaconf.h,v 1.176.1.2 2013/11/21 17:26:16 roberto Exp $
+** Configuration file for Lua
+** See Copyright Notice in lua.h
+*/
+
+
+#ifndef lconfig_h
+#define lconfig_h
+
+#include <limits.h>
+#include <stddef.h>
+
+
+/*
+** ==================================================================
+** Search for "@@" to find all configurable definitions.
+** ===================================================================
+*/
+
+
+/*
+@@ LUA_ANSI controls the use of non-ansi features.
+** CHANGE it (define it) if you want Lua to avoid the use of any
+** non-ansi feature or library.
+*/
+#if !defined(LUA_ANSI) && defined(__STRICT_ANSI__)
+#define LUA_ANSI
+#endif
+
+
+#if !defined(LUA_ANSI) && defined(_WIN32) && !defined(_WIN32_WCE)
+#define LUA_WIN		/* enable goodies for regular Windows platforms */
+#endif
+
+#if defined(LUA_WIN)
+#define LUA_DL_DLL
+#define LUA_USE_AFORMAT		/* assume 'printf' handles 'aA' specifiers */
+#endif
+
+
+
+#if defined(LUA_USE_LINUX)
+#define LUA_USE_POSIX
+#define LUA_USE_DLOPEN		/* needs an extra library: -ldl */
+#define LUA_USE_READLINE	/* needs some extra libraries */
+#define LUA_USE_STRTODHEX	/* assume 'strtod' handles hex formats */
+#define LUA_USE_AFORMAT		/* assume 'printf' handles 'aA' specifiers */
+#define LUA_USE_LONGLONG	/* assume support for long long */
+#endif
+
+#if defined(LUA_USE_MACOSX)
+#define LUA_USE_POSIX
+#define LUA_USE_DLOPEN		/* does not need -ldl */
+#define LUA_USE_READLINE	/* needs an extra library: -lreadline */
+#define LUA_USE_STRTODHEX	/* assume 'strtod' handles hex formats */
+#define LUA_USE_AFORMAT		/* assume 'printf' handles 'aA' specifiers */
+#define LUA_USE_LONGLONG	/* assume support for long long */
+#endif
+
+
+
+/*
+@@ LUA_USE_POSIX includes all functionality listed as X/Open System
+@* Interfaces Extension (XSI).
+** CHANGE it (define it) if your system is XSI compatible.
+*/
+#if defined(LUA_USE_POSIX)
+#define LUA_USE_MKSTEMP
+#define LUA_USE_ISATTY
+#define LUA_USE_POPEN
+#define LUA_USE_ULONGJMP
+#define LUA_USE_GMTIME_R
+#endif
+
+
+
+/*
+@@ LUA_PATH_DEFAULT is the default path that Lua uses to look for
+@* Lua libraries.
+@@ LUA_CPATH_DEFAULT is the default path that Lua uses to look for
+@* C libraries.
+** CHANGE them if your machine has a non-conventional directory
+** hierarchy or if you want to install your libraries in
+** non-conventional directories.
+*/
+#if defined(_WIN32)	/* { */
+/*
+** In Windows, any exclamation mark ('!') in the path is replaced by the
+** path of the directory of the executable file of the current process.
+*/
+#define LUA_LDIR	"!\\lua\\"
+#define LUA_CDIR	"!\\"
+#define LUA_PATH_DEFAULT  \
+		LUA_LDIR"?.lua;"  LUA_LDIR"?\\init.lua;" \
+		LUA_CDIR"?.lua;"  LUA_CDIR"?\\init.lua;" ".\\?.lua"
+#define LUA_CPATH_DEFAULT \
+		LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll;" ".\\?.dll;" \
+    LUA_CDIR"?52.dll;" ".\\?52.dll"
+
+#else			/* }{ */
+
+#define LUA_VDIR	LUA_VERSION_MAJOR "." LUA_VERSION_MINOR "/"
+#define LUA_ROOT	"/usr/local/"
+#define LUA_LDIR	LUA_ROOT "share/lua/" LUA_VDIR
+#define LUA_CDIR	LUA_ROOT "lib/lua/" LUA_VDIR
+#define LUA_PATH_DEFAULT  \
+		LUA_LDIR"?.lua;"  LUA_LDIR"?/init.lua;" \
+		LUA_CDIR"?.lua;"  LUA_CDIR"?/init.lua;" "./?.lua"
+#define LUA_CPATH_DEFAULT \
+		LUA_CDIR"?.so;" LUA_CDIR"loadall.so;" "./?.so;" \
+    LUA_CDIR"lib?52.so;" "./lib?52.so"
+#endif			/* } */
+
+
+/*
+@@ LUA_DIRSEP is the directory separator (for submodules).
+** CHANGE it if your machine does not use "/" as the directory separator
+** and is not Windows. (On Windows Lua automatically uses "\".)
+*/
+#if defined(_WIN32)
+#define LUA_DIRSEP	"\\"
+#else
+#define LUA_DIRSEP	"/"
+#endif
+
+
+/*
+@@ LUA_ENV is the name of the variable that holds the current
+@@ environment, used to access global names.
+** CHANGE it if you do not like this name.
+*/
+#define LUA_ENV		"_ENV"
+
+
+/*
+@@ LUA_API is a mark for all core API functions.
+@@ LUALIB_API is a mark for all auxiliary library functions.
+@@ LUAMOD_API is a mark for all standard library opening functions.
+** CHANGE them if you need to define those functions in some special way.
+** For instance, if you want to create one Windows DLL with the core and
+** the libraries, you may want to use the following definition (define
+** LUA_BUILD_AS_DLL to get it).
+*/
+#if defined(LUA_BUILD_AS_DLL)	/* { */
+
+#if defined(LUA_CORE) || defined(LUA_LIB)	/* { */
+#define LUA_API __declspec(dllexport)
+#else						/* }{ */
+#define LUA_API __declspec(dllimport)
+#endif						/* } */
+
+#else				/* }{ */
+
+#define LUA_API		extern
+
+#endif				/* } */
+
+
+/* more often than not the libs go together with the core */
+#define LUALIB_API	LUA_API
+#define LUAMOD_API	LUALIB_API
+
+
+/*
+@@ LUAI_FUNC is a mark for all extern functions that are not to be
+@* exported to outside modules.
+@@ LUAI_DDEF and LUAI_DDEC are marks for all extern (const) variables
+@* that are not to be exported to outside modules (LUAI_DDEF for
+@* definitions and LUAI_DDEC for declarations).
+** CHANGE them if you need to mark them in some special way. Elf/gcc
+** (versions 3.2 and later) mark them as "hidden" to optimize access
+** when Lua is compiled as a shared library. Not all elf targets support
+** this attribute. Unfortunately, gcc does not offer a way to check
+** whether the target offers that support, and those without support
+** give a warning about it. To avoid these warnings, change to the
+** default definition.
+*/
+#if defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \
+    defined(__ELF__)		/* { */
+#define LUAI_FUNC	__attribute__((visibility("hidden"))) extern
+#define LUAI_DDEC	LUAI_FUNC
+#define LUAI_DDEF	/* empty */
+
+#else				/* }{ */
+#define LUAI_FUNC	extern
+#define LUAI_DDEC	extern
+#define LUAI_DDEF	/* empty */
+#endif				/* } */
+
+
+
+/*
+@@ LUA_QL describes how error messages quote program elements.
+** CHANGE it if you want a different appearance.
+*/
+#define LUA_QL(x)	"'" x "'"
+#define LUA_QS		LUA_QL("%s")
+
+
+/*
+@@ LUA_IDSIZE gives the maximum size for the description of the source
+@* of a function in debug information.
+** CHANGE it if you want a different size.
+*/
+#define LUA_IDSIZE	60
+
+
+/*
+@@ luai_writestring/luai_writeline define how 'print' prints its results.
+** They are only used in libraries and the stand-alone program. (The #if
+** avoids including 'stdio.h' everywhere.)
+*/
+#if defined(LUA_LIB) || defined(lua_c)
+#include <stdio.h>
+#define luai_writestring(s,l)	fwrite((s), sizeof(char), (l), stdout)
+#define luai_writeline()	(luai_writestring("\n", 1), fflush(stdout))
+#endif
+
+/*
+@@ luai_writestringerror defines how to print error messages.
+** (A format string with one argument is enough for Lua...)
+*/
+#define luai_writestringerror(s,p) \
+	(fprintf(stderr, (s), (p)), fflush(stderr))
+
+
+/*
+@@ LUAI_MAXSHORTLEN is the maximum length for short strings, that is,
+** strings that are internalized. (Cannot be smaller than reserved words
+** or tags for metamethods, as these strings must be internalized;
+** #("function") = 8, #("__newindex") = 10.)
+*/
+#define LUAI_MAXSHORTLEN        40
+
+
+
+/*
+** {==================================================================
+** Compatibility with previous versions
+** ===================================================================
+*/
+
+/*
+@@ LUA_COMPAT_ALL controls all compatibility options.
+** You can define it to get all options, or change specific options
+** to fit your specific needs.
+*/
+#if defined(LUA_COMPAT_ALL)	/* { */
+
+/*
+@@ LUA_COMPAT_UNPACK controls the presence of global 'unpack'.
+** You can replace it with 'table.unpack'.
+*/
+#define LUA_COMPAT_UNPACK
+
+/*
+@@ LUA_COMPAT_LOADERS controls the presence of table 'package.loaders'.
+** You can replace it with 'package.searchers'.
+*/
+#define LUA_COMPAT_LOADERS
+
+/*
+@@ macro 'lua_cpcall' emulates deprecated function lua_cpcall.
+** You can call your C function directly (with light C functions).
+*/
+#define lua_cpcall(L,f,u)  \
+	(lua_pushcfunction(L, (f)), \
+	 lua_pushlightuserdata(L,(u)), \
+	 lua_pcall(L,1,0,0))
+
+
+/*
+@@ LUA_COMPAT_LOG10 defines the function 'log10' in the math library.
+** You can rewrite 'log10(x)' as 'log(x, 10)'.
+*/
+#define LUA_COMPAT_LOG10
+
+/*
+@@ LUA_COMPAT_LOADSTRING defines the function 'loadstring' in the base
+** library. You can rewrite 'loadstring(s)' as 'load(s)'.
+*/
+#define LUA_COMPAT_LOADSTRING
+
+/*
+@@ LUA_COMPAT_MAXN defines the function 'maxn' in the table library.
+*/
+#define LUA_COMPAT_MAXN
+
+/*
+@@ The following macros supply trivial compatibility for some
+** changes in the API. The macros themselves document how to
+** change your code to avoid using them.
+*/
+#define lua_strlen(L,i)		lua_rawlen(L, (i))
+
+#define lua_objlen(L,i)		lua_rawlen(L, (i))
+
+#define lua_equal(L,idx1,idx2)		lua_compare(L,(idx1),(idx2),LUA_OPEQ)
+#define lua_lessthan(L,idx1,idx2)	lua_compare(L,(idx1),(idx2),LUA_OPLT)
+
+/*
+@@ LUA_COMPAT_MODULE controls compatibility with previous
+** module functions 'module' (Lua) and 'luaL_register' (C).
+*/
+#define LUA_COMPAT_MODULE
+
+#endif				/* } */
+
+/* }================================================================== */
+
+
+
+/*
+@@ LUAI_BITSINT defines the number of bits in an int.
+** CHANGE here if Lua cannot automatically detect the number of bits of
+** your machine. Probably you do not need to change this.
+*/
+/* avoid overflows in comparison */
+#if INT_MAX-20 < 32760		/* { */
+#define LUAI_BITSINT	16
+#elif INT_MAX > 2147483640L	/* }{ */
+/* int has at least 32 bits */
+#define LUAI_BITSINT	32
+#else				/* }{ */
+#error "you must define LUA_BITSINT with number of bits in an integer"
+#endif				/* } */
+
+
+/*
+@@ LUA_INT32 is a signed integer with exactly 32 bits.
+@@ LUAI_UMEM is an unsigned integer big enough to count the total
+@* memory used by Lua.
+@@ LUAI_MEM is a signed integer big enough to count the total memory
+@* used by Lua.
+** CHANGE here if for some weird reason the default definitions are not
+** good enough for your machine. Probably you do not need to change
+** this.
+*/
+#if LUAI_BITSINT >= 32		/* { */
+#define LUA_INT32	int
+#define LUAI_UMEM	size_t
+#define LUAI_MEM	ptrdiff_t
+#else				/* }{ */
+/* 16-bit ints */
+#define LUA_INT32	long
+#define LUAI_UMEM	unsigned long
+#define LUAI_MEM	long
+#endif				/* } */
+
+
+/*
+@@ LUAI_MAXSTACK limits the size of the Lua stack.
+** CHANGE it if you need a different limit. This limit is arbitrary;
+** its only purpose is to stop Lua from consuming unlimited stack
+** space (and to reserve some numbers for pseudo-indices).
+*/
+#if LUAI_BITSINT >= 32
+#define LUAI_MAXSTACK		1000000
+#else
+#define LUAI_MAXSTACK		15000
+#endif
+
+/* reserve some space for error handling */
+#define LUAI_FIRSTPSEUDOIDX	(-LUAI_MAXSTACK - 1000)
+
+
+
+
+/*
+@@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system.
+** CHANGE it if it uses too much C-stack space.
+*/
+#define LUAL_BUFFERSIZE		BUFSIZ
+
+
+
+
+/*
+** {==================================================================
+@@ LUA_NUMBER is the type of numbers in Lua.
+** CHANGE the following definitions only if you want to build Lua
+** with a number type different from double. You may also need to
+** change lua_number2int & lua_number2integer.
+** ===================================================================
+*/
+
+#define LUA_NUMBER_DOUBLE
+#define LUA_NUMBER	double
+
+/*
+@@ LUAI_UACNUMBER is the result of an 'usual argument conversion'
+@* over a number.
+*/
+#define LUAI_UACNUMBER	double
+
+
+/*
+@@ LUA_NUMBER_SCAN is the format for reading numbers.
+@@ LUA_NUMBER_FMT is the format for writing numbers.
+@@ lua_number2str converts a number to a string.
+@@ LUAI_MAXNUMBER2STR is maximum size of previous conversion.
+*/
+#define LUA_NUMBER_SCAN		"%lf"
+#define LUA_NUMBER_FMT		"%.14g"
+#define lua_number2str(s,n)	sprintf((s), LUA_NUMBER_FMT, (n))
+#define LUAI_MAXNUMBER2STR	32 /* 16 digits, sign, point, and \0 */
+
+
+/*
+@@ l_mathop allows the addition of an 'l' or 'f' to all math operations
+*/
+#define l_mathop(x)		(x)
+
+
+/*
+@@ lua_str2number converts a decimal numeric string to a number.
+@@ lua_strx2number converts an hexadecimal numeric string to a number.
+** In C99, 'strtod' does both conversions. C89, however, has no function
+** to convert floating hexadecimal strings to numbers. For these
+** systems, you can leave 'lua_strx2number' undefined and Lua will
+** provide its own implementation.
+*/
+#define lua_str2number(s,p)	strtod((s), (p))
+
+#if defined(LUA_USE_STRTODHEX)
+#define lua_strx2number(s,p)	strtod((s), (p))
+#endif
+
+
+/*
+@@ The luai_num* macros define the primitive operations over numbers.
+*/
+
+/* the following operations need the math library */
+#if defined(lobject_c) || defined(lvm_c)
+#include <math.h>
+#define luai_nummod(L,a,b)	((a) - l_mathop(floor)((a)/(b))*(b))
+#define luai_numpow(L,a,b)	(l_mathop(pow)(a,b))
+#endif
+
+/* these are quite standard operations */
+#if defined(LUA_CORE)
+#define luai_numadd(L,a,b)	((a)+(b))
+#define luai_numsub(L,a,b)	((a)-(b))
+#define luai_nummul(L,a,b)	((a)*(b))
+#define luai_numdiv(L,a,b)	((a)/(b))
+#define luai_numunm(L,a)	(-(a))
+#define luai_numeq(a,b)		((a)==(b))
+#define luai_numlt(L,a,b)	((a)<(b))
+#define luai_numle(L,a,b)	((a)<=(b))
+#define luai_numisnan(L,a)	(!luai_numeq((a), (a)))
+#endif
+
+
+
+/*
+@@ LUA_INTEGER is the integral type used by lua_pushinteger/lua_tointeger.
+** CHANGE that if ptrdiff_t is not adequate on your machine. (On most
+** machines, ptrdiff_t gives a good choice between int or long.)
+*/
+#define LUA_INTEGER	ptrdiff_t
+
+/*
+@@ LUA_UNSIGNED is the integral type used by lua_pushunsigned/lua_tounsigned.
+** It must have at least 32 bits.
+*/
+#define LUA_UNSIGNED	unsigned LUA_INT32
+
+
+
+/*
+** Some tricks with doubles
+*/
+
+#if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI)	/* { */
+/*
+** The next definitions activate some tricks to speed up the
+** conversion from doubles to integer types, mainly to LUA_UNSIGNED.
+**
+@@ LUA_MSASMTRICK uses Microsoft assembler to avoid clashes with a
+** DirectX idiosyncrasy.
+**
+@@ LUA_IEEE754TRICK uses a trick that should work on any machine
+** using IEEE754 with a 32-bit integer type.
+**
+@@ LUA_IEEELL extends the trick to LUA_INTEGER; should only be
+** defined when LUA_INTEGER is a 32-bit integer.
+**
+@@ LUA_IEEEENDIAN is the endianness of doubles in your machine
+** (0 for little endian, 1 for big endian); if not defined, Lua will
+** check it dynamically for LUA_IEEE754TRICK (but not for LUA_NANTRICK).
+**
+@@ LUA_NANTRICK controls the use of a trick to pack all types into
+** a single double value, using NaN values to represent non-number
+** values. The trick only works on 32-bit machines (ints and pointers
+** are 32-bit values) with numbers represented as IEEE 754-2008 doubles
+** with conventional endianess (12345678 or 87654321), in CPUs that do
+** not produce signaling NaN values (all NaNs are quiet).
+*/
+
+/* Microsoft compiler on a Pentium (32 bit) ? */
+#if defined(LUA_WIN) && defined(_MSC_VER) && defined(_M_IX86)	/* { */
+
+#define LUA_MSASMTRICK
+#define LUA_IEEEENDIAN		0
+#define LUA_NANTRICK
+
+
+/* pentium 32 bits? */
+#elif defined(__i386__) || defined(__i386) || defined(__X86__) /* }{ */
+
+#define LUA_IEEE754TRICK
+#define LUA_IEEELL
+#define LUA_IEEEENDIAN		0
+#define LUA_NANTRICK
+
+/* pentium 64 bits? */
+#elif defined(__x86_64)						/* }{ */
+
+#define LUA_IEEE754TRICK
+#define LUA_IEEEENDIAN		0
+
+#elif defined(__POWERPC__) || defined(__ppc__)			/* }{ */
+
+#define LUA_IEEE754TRICK
+#define LUA_IEEEENDIAN		1
+
+#else								/* }{ */
+
+/* assume IEEE754 and a 32-bit integer type */
+#define LUA_IEEE754TRICK
+
+#endif								/* } */
+
+#endif							/* } */
+
+/* }================================================================== */
+
+
+
+
+/* =================================================================== */
+
+/*
+** Local configuration. You can use this space to add your redefinitions
+** without modifying the main part of the file.
+*/
+
+
+
+#endif
+

+ 55 - 0
vendor/lua/5.2/include/lualib.h

@@ -0,0 +1,55 @@
+/*
+** $Id: lualib.h,v 1.43.1.1 2013/04/12 18:48:47 roberto Exp $
+** Lua standard libraries
+** See Copyright Notice in lua.h
+*/
+
+
+#ifndef lualib_h
+#define lualib_h
+
+#include "lua.h"
+
+
+
+LUAMOD_API int (luaopen_base) (lua_State *L);
+
+#define LUA_COLIBNAME	"coroutine"
+LUAMOD_API int (luaopen_coroutine) (lua_State *L);
+
+#define LUA_TABLIBNAME	"table"
+LUAMOD_API int (luaopen_table) (lua_State *L);
+
+#define LUA_IOLIBNAME	"io"
+LUAMOD_API int (luaopen_io) (lua_State *L);
+
+#define LUA_OSLIBNAME	"os"
+LUAMOD_API int (luaopen_os) (lua_State *L);
+
+#define LUA_STRLIBNAME	"string"
+LUAMOD_API int (luaopen_string) (lua_State *L);
+
+#define LUA_BITLIBNAME	"bit32"
+LUAMOD_API int (luaopen_bit32) (lua_State *L);
+
+#define LUA_MATHLIBNAME	"math"
+LUAMOD_API int (luaopen_math) (lua_State *L);
+
+#define LUA_DBLIBNAME	"debug"
+LUAMOD_API int (luaopen_debug) (lua_State *L);
+
+#define LUA_LOADLIBNAME	"package"
+LUAMOD_API int (luaopen_package) (lua_State *L);
+
+
+/* open all previous libraries */
+LUALIB_API void (luaL_openlibs) (lua_State *L);
+
+
+
+#if !defined(lua_assert)
+#define lua_assert(x)	((void)0)
+#endif
+
+
+#endif

BIN
vendor/lua/5.2/linux/liblua52.a


BIN
vendor/lua/5.2/linux/liblua52.so


+ 728 - 0
vendor/lua/5.2/lua.odin

@@ -0,0 +1,728 @@
+package lua_5_2
+
+import "core:intrinsics"
+import "core:builtin"
+
+import c "core:c/libc"
+
+#assert(size_of(c.int) == size_of(b32))
+
+when ODIN_OS == .Windows {
+	foreign import lib "windows/lua52dll.lib"
+} else when ODIN_OS == .Linux {
+	foreign import lib "linux/liblua52.a"
+} else {
+	foreign import lib "system:liblua52.a"
+}
+
+VERSION_MAJOR       :: "5"
+VERSION_MINOR       :: "2"
+VERSION_NUM         :: 502
+VERSION_RELEASE     :: "4"
+
+VERSION             :: "Lua " + VERSION_MAJOR + "." + VERSION_MINOR
+RELEASE             :: VERSION + "." + VERSION_RELEASE
+COPYRIGHT           :: RELEASE + "  Copyright (C) 1994-2015 Lua.org, PUC-Rio"
+AUTHORS             :: "R. Ierusalimschy, L. H. de Figueiredo, W. Celes"
+
+
+/* mark for precompiled code ('<esc>Lua') */
+SIGNATURE :: "\x1bLua"
+
+/* option for multiple returns in 'lua_pcall' and 'lua_call' */
+MULTRET :: -1
+
+FIRSTPSEUDOIDX :: -MAXSTACK - 1000
+
+REGISTRYINDEX :: -FIRSTPSEUDOIDX
+
+
+/*
+@@ LUAI_MAXSTACK limits the size of the Lua stack.
+** CHANGE it if you need a different limit. This limit is arbitrary;
+** its only purpose is to stop Lua from consuming unlimited stack
+** space (and to reserve some numbers for pseudo-indices).
+** (It must fit into max(size_t)/32.)
+*/
+MAXSTACK :: 1000000 when size_of(rawptr) == 4 else 15000
+
+
+/*
+@@ LUA_EXTRASPACE defines the size of a raw memory area associated with
+** a Lua state with very fast access.
+** CHANGE it if you need a different size.
+*/
+EXTRASPACE :: size_of(rawptr)
+
+
+
+/*
+@@ LUA_IDSIZE gives the maximum size for the description of the source
+@@ of a function in debug information.
+** CHANGE it if you want a different size.
+*/
+IDSIZE :: 60
+
+
+/*
+@@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system.
+*/
+L_BUFFERSIZE :: c.int(16 * size_of(rawptr) * size_of(Number))
+
+
+MAXALIGNVAL :: max(align_of(Number), align_of(f64), align_of(rawptr), align_of(Integer), align_of(c.long))
+
+
+Status :: enum c.int {
+	OK        = 0,
+	YIELD     = 1,
+	ERRRUN    = 2,
+	ERRSYNTAX = 3,
+	ERRMEM    = 4,
+	ERRERR    = 5,
+	ERRGCMM   = 6,
+	ERRFILE   = 7,
+}
+
+/* thread status */
+OK        :: Status.OK
+YIELD     :: Status.YIELD
+ERRRUN    :: Status.ERRRUN
+ERRSYNTAX :: Status.ERRSYNTAX
+ERRMEM    :: Status.ERRMEM
+ERRERR    :: Status.ERRERR
+ERRFILE   :: Status.ERRFILE
+
+/*
+** basic types
+*/
+
+
+Type :: enum c.int {
+	NONE          = -1,
+
+	NIL           = 0,
+	BOOLEAN       = 1,
+	LIGHTUSERDATA = 2,
+	NUMBER        = 3,
+	STRING        = 4,
+	TABLE         = 5,
+	FUNCTION      = 6,
+	USERDATA      = 7,
+	THREAD        = 8,
+}
+
+TNONE          :: Type.NONE
+TNIL           :: Type.NIL
+TBOOLEAN       :: Type.BOOLEAN
+TLIGHTUSERDATA :: Type.LIGHTUSERDATA
+TNUMBER        :: Type.NUMBER
+TSTRING        :: Type.STRING
+TTABLE         :: Type.TABLE
+TFUNCTION      :: Type.FUNCTION
+TUSERDATA      :: Type.USERDATA
+TTHREAD        :: Type.THREAD
+NUMTYPES :: 9
+
+
+
+ArithOp :: enum c.int {
+	ADD  = 0,	/* ORDER TM, ORDER OP */
+	SUB  = 1,
+	MUL  = 2,
+	DIV  = 3,
+	MOD  = 4,
+	POW  = 5,
+	UNM  = 6,
+}
+
+CompareOp :: enum c.int {
+	EQ = 0,
+	LT = 1,
+	LE = 2,
+}
+
+OPADD :: ArithOp.ADD
+OPSUB :: ArithOp.SUB
+OPMUL :: ArithOp.MUL
+OPDIV :: ArithOp.DIV
+OPMOD :: ArithOp.MOD
+OPPOW :: ArithOp.POW
+OPUNM :: ArithOp.UNM
+
+OPEQ :: CompareOp.EQ
+OPLT :: CompareOp.LT
+OPLE :: CompareOp.LE
+
+
+/* minimum Lua stack available to a C function */
+MINSTACK :: 20
+
+
+/* predefined values in the registry */
+RIDX_MAINTHREAD :: 1
+RIDX_GLOBALS    :: 2
+RIDX_LAST       :: RIDX_GLOBALS
+
+
+/* type of numbers in Lua */
+Number :: distinct (f32 when size_of(uintptr) == 4 else f64)
+
+
+/* type for integer functions */
+Integer :: distinct (i32 when size_of(uintptr) == 4 else i64)
+
+/* unsigned integer type */
+Unsigned :: distinct (u32 when size_of(uintptr) == 4 else u64)
+
+
+/*
+** Type for C functions registered with Lua
+*/
+CFunction :: #type proc "c" (L: ^State) -> c.int
+
+
+
+/*
+** Type for functions that read/write blocks when loading/dumping Lua chunks
+*/
+Reader :: #type proc "c" (L: ^State, ud: rawptr, sz: ^c.size_t) -> cstring
+Writer :: #type proc "c" (L: ^State, p: rawptr, sz: ^c.size_t, ud: rawptr) -> c.int
+
+
+/*
+** Type for memory-allocation functions
+*/
+Alloc :: #type proc "c" (ud: rawptr, ptr: rawptr, osize, nsize: c.size_t) -> rawptr
+
+
+GCWhat :: enum c.int {
+	STOP        = 0,
+	RESTART     = 1,
+	COLLECT     = 2,
+	COUNT       = 3,
+	COUNTB      = 4,
+	STEP        = 5,
+	SETPAUSE    = 6,
+	SETSTEPMUL  = 7,
+	SETMAJORINC = 8,
+	ISRUNNING   = 9,
+	GEN         = 10,
+	INC         = 11,
+}
+GCSTOP        :: GCWhat.STOP
+GCRESTART     :: GCWhat.RESTART
+GCCOLLECT     :: GCWhat.COLLECT
+GCCOUNT       :: GCWhat.COUNT
+GCCOUNTB      :: GCWhat.COUNTB
+GCSTEP        :: GCWhat.STEP
+GCSETPAUSE    :: GCWhat.SETPAUSE
+GCSETSTEPMUL  :: GCWhat.SETSTEPMUL
+GCSETMAJORINC :: GCWhat.SETMAJORINC
+GCISRUNNING   :: GCWhat.ISRUNNING
+GCGEN         :: GCWhat.GEN
+GCINC         :: GCWhat.INC
+
+
+
+/*
+** Event codes
+*/
+
+HookEvent :: enum c.int {
+	CALL     = 0,
+	RET      = 1,
+	LINE     = 2,
+	COUNT    = 3,
+	TAILCALL = 4,
+}
+HOOKCALL     :: HookEvent.CALL
+HOOKRET      :: HookEvent.RET
+HOOKLINE     :: HookEvent.LINE
+HOOKCOUNT    :: HookEvent.COUNT
+HOOKTAILCALL :: HookEvent.TAILCALL
+
+
+/*
+** Event masks
+*/
+HookMask :: distinct bit_set[HookEvent; c.int]
+MASKCALL  :: HookMask{.CALL}
+MASKRET   :: HookMask{.RET}
+MASKLINE  :: HookMask{.LINE}
+MASKCOUNT :: HookMask{.COUNT}
+
+/* activation record */
+Debug :: struct {
+	event:           HookEvent,
+	name:            cstring,                  /* (n) */
+	namewhat:        cstring,                  /* (n) 'global', 'local', 'field', 'method' */
+	what:            cstring,                  /* (S) 'Lua', 'C', 'main', 'tail' */
+	source:          cstring,                  /* (S) */
+	currentline:     c.int,                    /* (l) */
+	linedefined:     c.int,                    /* (S) */
+	lastlinedefined: c.int,                    /* (S) */
+	nups:            u8,                       /* (u) number of upvalues */
+	nparams:         u8,                       /* (u) number of parameters */
+	isvararg:        bool,                     /* (u) */
+	istailcall:      bool,                     /* (t) */
+	short_src:       [IDSIZE]u8 `fmt:"s"`, /* (S) */
+	/* private part */
+	i_ci:            rawptr,                   /* active function */
+}
+
+
+/* Functions to be called by the debugger in specific events */
+Hook :: #type proc "c" (L: ^State, ar: ^Debug)
+
+
+State :: struct {} // opaque data type
+
+
+@(link_prefix="lua_")
+@(default_calling_convention="c")
+foreign lib {
+	/*
+	** RCS ident string
+	*/
+
+	ident: [^]u8 // TODO(bill): is this correct?
+
+
+	/*
+	** state manipulation
+	*/
+
+	newstate  :: proc(f: Alloc, ud: rawptr) -> ^State ---
+	close     :: proc(L: ^State) ---
+	newthread :: proc(L: ^State) -> ^State ---
+
+	atpanic :: proc(L: ^State, panicf: CFunction) -> CFunction ---
+
+	version :: proc(L: ^State) -> ^Number ---
+
+
+	/*
+	** basic stack manipulation
+	*/
+
+	absindex   :: proc (L: ^State, idx: c.int) -> c.int ---
+	gettop     :: proc (L: ^State) -> c.int ---
+	settop     :: proc (L: ^State, idx: c.int) ---
+	pushvalue  :: proc (L: ^State, idx: c.int) ---
+	remove     :: proc (L: ^State, idx: c.int) ---
+	insert     :: proc (L: ^State, idx: c.int) ---
+	replace    :: proc (L: ^State, idx: c.int) ---
+	copy       :: proc (L: ^State, fromidx, toidx: c.int) ---
+	checkstack :: proc (L: ^State, sz: c.int) -> c.int ---
+
+	xmove :: proc(from, to: ^State, n: c.int) ---
+
+
+	/*
+	** access functions (stack -> C)
+	*/
+
+	isnumber    :: proc(L: ^State, idx: c.int) -> b32 ---
+	isstring    :: proc(L: ^State, idx: c.int) -> b32 ---
+	iscfunction :: proc(L: ^State, idx: c.int) -> b32 ---
+	isinteger   :: proc(L: ^State, idx: c.int) -> b32 ---
+	isuserdata  :: proc(L: ^State, idx: c.int) -> b32 ---
+	type        :: proc(L: ^State, idx: c.int) -> Type ---
+	typename    :: proc(L: ^State, tp: Type) -> cstring ---
+
+	@(link_name="lua_tonumberx")
+	tonumber    :: proc(L: ^State, idx: c.int, isnum: ^b32 = nil) -> Number ---
+	@(link_name="lua_tointegerx")
+	tointeger   :: proc(L: ^State, idx: c.int, isnum: ^b32 = nil) -> Integer ---
+	@(link_name="lua_tounsignedx")
+	tounsigned  :: proc(L: ^State, idx: c.int, isnum: ^b32 = nil) -> Unsigned ---
+	toboolean   :: proc(L: ^State, idx: c.int) -> b32 ---
+	tolstring   :: proc(L: ^State, idx: c.int, len: ^c.size_t) -> cstring ---
+	rawlen      :: proc(L: ^State, idx: c.int) -> c.size_t ---
+	tocfunction :: proc(L: ^State, idx: c.int) -> CFunction ---
+	touserdata  :: proc(L: ^State, idx: c.int) -> rawptr ---
+	tothread    :: proc(L: ^State, idx: c.int) -> ^State ---
+	topointer   :: proc(L: ^State, idx: c.int) -> rawptr ---
+
+	/*
+	** Comparison and arithmetic functions
+	*/
+
+	arith    :: proc(L: ^State, op: ArithOp) ---
+	rawequal :: proc(L: ^State, idx1, idx2: c.int) -> b32 ---
+	compare  :: proc(L: ^State, idx1, idx2: c.int, op: CompareOp) -> b32 ---
+
+	/*
+	** push functions (C -> stack)
+	*/
+
+	pushnil      :: proc(L: ^State) ---
+	pushnumber   :: proc(L: ^State, n: Number) ---
+	pushinteger  :: proc(L: ^State, n: Integer) ---
+	pushunsigned :: proc(L: ^State, n: Unsigned) ---
+	pushlstring  :: proc(L: ^State, s: cstring, l: c.size_t) -> cstring ---
+	pushstring   :: proc(L: ^State, s: cstring) -> cstring ---
+	pushvfstring :: proc(L: ^State, fmt: cstring, argp: c.va_list) -> cstring ---
+	pushfstring       :: proc(L: ^State, fmt: cstring, #c_vararg args: ..any) -> cstring ---
+	pushcclosure      :: proc(L: ^State, fn: CFunction, n: c.int) ---
+	pushboolean       :: proc(L: ^State, b: b32) ---
+	pushlightuserdata :: proc(L: ^State, p: rawptr) ---
+	pushthread        :: proc(L: ^State) -> Status ---
+
+	/*
+	** get functions (Lua -> stack)
+	*/
+
+	getglobal :: proc(L: ^State, name: cstring) ---
+	gettable  :: proc(L: ^State, idx: c.int) ---
+	getfield  :: proc(L: ^State, idx: c.int, k: cstring) ---
+	geti      :: proc(L: ^State, idx: c.int, n: Integer) ---
+	rawget    :: proc(L: ^State, idx: c.int) ---
+	rawgeti   :: proc(L: ^State, idx: c.int, n: Integer) ---
+	rawgetp   :: proc(L: ^State, idx: c.int, p: rawptr) ---
+
+	createtable  :: proc(L: ^State, narr, nrec: c.int) ---
+	newuserdata  :: proc(L: ^State, sz: c.size_t) -> rawptr ---
+	getmetatable :: proc(L: ^State, objindex: c.int) -> c.int ---
+	getuservalue :: proc(L: ^State, idx: c.int) ---
+
+
+	/*
+	** set functions (stack -> Lua)
+	*/
+
+	setglobal    :: proc(L: ^State, var: cstring) ---
+	settable     :: proc(L: ^State, idx: c.int) ---
+	setfield     :: proc(L: ^State, idx: c.int, k: cstring) ---
+	rawset       :: proc(L: ^State, idx: c.int) ---
+	rawseti      :: proc(L: ^State, idx: c.int, n: c.int) ---
+	rawsetp      :: proc(L: ^State, idx: c.int, p: rawptr) ---
+	setmetatable :: proc(L: ^State, objindex: c.int) -> c.int ---
+	setuservalue :: proc(L: ^State, idx: c.int) -> c.int ---
+
+
+	/*
+	** 'load' and 'call' functions (load and run Lua code)
+	*/
+
+	@(link_name="lua_callk")
+	call :: proc(L: ^State, nargs, nresults: c.int, ctx: c.int = 0,
+	             k: CFunction = nil) ---
+
+	getctx :: proc(L: ^State, ctx: ^c.int) -> c.int ---
+
+	@(link_name="lua_pcallk")
+	pcall :: proc(L: ^State, nargs, nresults: c.int, errfunc: c.int,
+	              ctx: c.int = 0, k: CFunction = nil) -> c.int ---
+
+	load :: proc(L: ^State, reader: Reader, dt: rawptr,
+	             chunkname, mode: cstring) -> Status ---
+
+	dump :: proc(L: ^State, writer: Writer, data: rawptr) -> Status ---
+
+
+	/*
+	** coroutine functions
+	*/
+
+	@(link_name="lua_yieldk")
+	yield       :: proc(L: ^State, nresults: c.int, ctx: c.int = 0, k: CFunction = nil) -> Status ---
+	resume      :: proc(L: ^State, from: ^State, narg: c.int) -> Status ---
+	status      :: proc(L: ^State) -> Status ---
+
+
+	/*
+	** garbage-collection function and options
+	*/
+
+
+
+	gc :: proc(L: ^State, what: GCWhat, data: c.int) -> c.int ---
+
+
+	/*
+	** miscellaneous functions
+	*/
+
+	error :: proc(L: ^State) -> Status ---
+
+	next :: proc(L: ^State, idx: c.int) -> c.int ---
+
+	concat :: proc(L: ^State, n: c.int) ---
+	len    :: proc(L: ^State, idx: c.int) ---
+
+	getallocf :: proc(L: State, ud: ^rawptr) -> Alloc ---
+	setallocf :: proc(L: ^State, f: Alloc, ud: rawptr) ---
+
+	/*
+	** {======================================================================
+	** Debug API
+	** =======================================================================
+	*/
+
+	getstack   :: proc(L: ^State, level: c.int, ar: ^Debug) -> c.int ---
+	getinfo    :: proc(L: ^State, what: cstring, ar: ^Debug) -> c.int ---
+	getlocal   :: proc(L: ^State, ar: ^Debug, n: c.int) -> cstring ---
+	setlocal   :: proc(L: ^State, ar: ^Debug, n: c.int) -> cstring ---
+	getupvalue :: proc(L: ^State, funcindex: c.int, n: c.int) -> cstring ---
+	setupvalue :: proc(L: ^State, funcindex: c.int, n: c.int) -> cstring ---
+
+	upvalueid   :: proc(L: ^State, fidx, n: c.int) -> rawptr ---
+	upvaluejoin :: proc(L: ^State, fidx1, n1, fidx2, n2: c.int) ---
+
+	sethook :: proc(L: ^State, func: Hook, mask: HookMask, count: c.int) -> c.int ---
+	gethook :: proc(L: ^State) -> Hook ---
+	gethookmask  :: proc(L: ^State) -> HookMask ---
+	gethookcount :: proc(L: ^State) -> c.int ---
+
+	/* }============================================================== */
+}
+
+
+
+/* version suffix for environment variable names */
+VERSUFFIX :: "_" + VERSION_MAJOR + "_" + VERSION_MINOR
+
+COLIBNAME   :: "coroutine"
+TABLIBNAME  :: "table"
+IOLIBNAME   :: "io"
+OSLIBNAME   :: "os"
+STRLIBNAME  :: "string"
+UTF8LIBNAME :: "utf8"
+BITLIBNAME  :: "bit32"
+MATHLIBNAME :: "math"
+DBLIBNAME   :: "debug"
+LOADLIBNAME :: "package"
+
+@(link_prefix="lua")
+@(default_calling_convention="c")
+foreign lib {
+	open_base      :: proc(L: ^State) -> c.int ---
+	open_coroutine :: proc(L: ^State) -> c.int ---
+	open_table     :: proc(L: ^State) -> c.int ---
+	open_io        :: proc(L: ^State) -> c.int ---
+	open_os        :: proc(L: ^State) -> c.int ---
+	open_string    :: proc(L: ^State) -> c.int ---
+	open_utf8      :: proc(L: ^State) -> c.int ---
+	open_bit32     :: proc(L: ^State) -> c.int ---
+	open_math      :: proc(L: ^State) -> c.int ---
+	open_debug     :: proc(L: ^State) -> c.int ---
+	open_package   :: proc(L: ^State) -> c.int ---
+
+	/* open all previous libraries */
+
+	L_openlibs :: proc(L: ^State) ---
+}
+
+
+
+GNAME :: "_G"
+
+L_Reg :: struct {
+	name: cstring,
+  	func: CFunction,
+}
+
+
+/* predefined references */
+NOREF  :: -2
+REFNIL :: -1
+
+
+@(link_prefix="lua")
+@(default_calling_convention="c")
+foreign lib {
+	@(link_name="luaL_checkversion_")
+	L_checkversion :: proc(L: ^State, ver: Number = VERSION_NUM) ---
+
+
+	L_getmetafield :: proc(L: ^State, obj: c.int, e: cstring) -> c.int ---
+	L_callmeta     :: proc(L: ^State, obj: c.int, e: cstring) -> c.int ---
+	@(link_name="luaL_tolstring")
+	L_tostring     :: proc(L: ^State, idx: c.int, len: ^c.size_t = nil) -> cstring ---
+	L_argerror     :: proc(L: ^State, numarg: c.int, extramsg: cstring) -> c.int ---
+	@(link_name="luaL_checklstring")
+	L_checkstring  :: proc(L: ^State, numArg: c.int, l: ^c.size_t = nil) -> cstring ---
+	@(link_name="luaL_optlstring")
+	L_optstring    :: proc(L: ^State, numArg: c.int, def: cstring, l: ^c.size_t = nil) -> cstring ---
+	L_checknumber  :: proc(L: ^State, numArg: c.int) -> Number ---
+	L_optnumber    :: proc(L: ^State, nArg: c.int, def: Number) -> Number ---
+
+	L_checkinteger  :: proc(L: ^State, numArg: c.int) -> Integer ---
+	L_optinteger    :: proc(L: ^State, nArg: c.int, def: Integer) -> Integer ---
+	L_checkunsigned :: proc(L: ^State, numArg: c.int) -> Unsigned ---
+	L_optunsigned   :: proc(L: ^State, nArg: c.int, def: Unsigned) -> Unsigned ---
+
+
+	L_checkstack :: proc(L: ^State, sz: c.int, msg: cstring) ---
+	L_checktype  :: proc(L: ^State, narg: c.int, t: c.int) ---
+	L_checkany   :: proc(L: ^State, narg: c.int) ---
+
+	L_newmetatable :: proc(L: ^State, tname: cstring) -> c.int ---
+	L_setmetatable :: proc(L: ^State, tname: cstring) ---
+	L_testudata    :: proc(L: ^State, ud: c.int, tname: cstring) -> rawptr ---
+	L_checkudata   :: proc(L: ^State, ud: c.int, tname: cstring) -> rawptr ---
+
+	L_where :: proc(L: ^State, lvl: c.int) ---
+	L_error :: proc(L: ^State, fmt: cstring, #c_vararg args: ..any) -> Status ---
+
+	L_checkoption :: proc(L: ^State, narg: c.int, def: cstring, lst: [^]cstring) -> c.int ---
+
+	L_fileresult :: proc(L: ^State, stat: c.int, fname: cstring) -> c.int ---
+	L_execresult :: proc(L: ^State, stat: c.int) -> c.int ---
+
+
+	L_ref   :: proc(L: ^State, t: c.int) -> c.int ---
+	L_unref :: proc(L: ^State, t: c.int, ref: c.int) ---
+
+	@(link_name="luaL_loadfilex")
+	L_loadfile :: proc (L: ^State, filename: cstring, mode: cstring = nil) -> Status ---
+
+	@(link_name="luaL_loadbufferx")
+	L_loadbuffer :: proc(L: ^State, buff: [^]byte, sz: c.size_t, name: cstring, mode: cstring = nil) -> Status ---
+	L_loadstring  :: proc(L: ^State, s: cstring) -> Status ---
+
+	L_newstate :: proc() -> ^State ---
+
+	L_len :: proc(L: ^State, idx: c.int) -> c.int ---
+
+	L_gsub :: proc(L: ^State, s, p, r: cstring) -> cstring ---
+
+	L_setfuncs :: proc(L: ^State, l: [^]L_Reg, nup: c.int) ---
+
+	L_getsubtable :: proc(L: ^State, idx: c.int, fname: cstring) -> c.int ---
+
+	L_traceback   :: proc(L: ^State, L1: ^State, msg: cstring, level: c.int) ---
+
+	L_requiref    :: proc(L: ^State, modname: cstring, openf: CFunction, glb: c.int) ---
+
+}
+/*
+** {======================================================
+** Generic Buffer manipulation
+** =======================================================
+*/
+
+
+L_Buffer :: struct {
+	b:    [^]byte,  /* buffer address */
+	size: c.size_t, /* buffer size */
+	n:    c.size_t, /* number of characters in buffer */
+	L:    ^State,
+	initb: [L_BUFFERSIZE]byte,  /* initial buffer */
+}
+
+L_addchar :: #force_inline proc "c" (B: ^L_Buffer, c: byte) {
+	if B.n < B.size {
+		L_prepbuffsize(B, 1)
+	}
+	B.b[B.n] = c
+	B.n += 1
+}
+
+L_addsize :: #force_inline proc "c" (B: ^L_Buffer, s: c.size_t) -> c.size_t {
+	B.n += s
+	return B.n
+}
+
+L_prepbuffer :: #force_inline proc "c" (B: ^L_Buffer) -> [^]byte {
+	return L_prepbuffsize(B, c.size_t(L_BUFFERSIZE))
+}
+
+
+@(link_prefix="lua")
+@(default_calling_convention="c")
+foreign lib {
+	L_buffinit       :: proc(L: ^State, B: ^L_Buffer) ---
+	L_prepbuffsize   :: proc(B: ^L_Buffer, sz: c.size_t) -> [^]byte ---
+	L_addlstring     :: proc(B: ^L_Buffer, s: cstring, l: c.size_t) ---
+	L_addstring      :: proc(B: ^L_Buffer, s: cstring) ---
+	L_addvalue       :: proc(B: ^L_Buffer) ---
+	L_pushresult     :: proc(B: ^L_Buffer) ---
+	L_pushresultsize :: proc(B: ^L_Buffer, sz: c.size_t) ---
+	L_buffinitsize   :: proc(L: ^State, B: ^L_Buffer, sz: c.size_t) -> [^]byte ---
+}
+
+
+/* }====================================================== */
+
+
+
+
+/*
+** {==============================================================
+** some useful macros
+** ===============================================================
+*/
+
+pop :: #force_inline proc "c" (L: ^State, n: c.int) {
+	settop(L, -n-1)
+}
+newtable :: #force_inline proc "c" (L: ^State) {
+	createtable(L, 0, 0)
+}
+register :: #force_inline proc "c" (L: ^State, n: cstring, f: CFunction) {
+	pushcfunction(L, f)
+	setglobal(L, n)
+}
+
+pushcfunction :: #force_inline proc "c" (L: ^State, f: CFunction) {
+	pushcclosure(L, f, 0)
+}
+
+
+isfunction      :: #force_inline proc "c" (L: ^State, n: c.int) -> bool { return type(L, n) == .FUNCTION      }
+istable         :: #force_inline proc "c" (L: ^State, n: c.int) -> bool { return type(L, n) == .TABLE         }
+islightuserdata :: #force_inline proc "c" (L: ^State, n: c.int) -> bool { return type(L, n) == .LIGHTUSERDATA }
+isnil           :: #force_inline proc "c" (L: ^State, n: c.int) -> bool { return type(L, n) == .NIL           }
+isboolean       :: #force_inline proc "c" (L: ^State, n: c.int) -> bool { return type(L, n) == .BOOLEAN       }
+isthread        :: #force_inline proc "c" (L: ^State, n: c.int) -> bool { return type(L, n) == .THREAD        }
+isnone          :: #force_inline proc "c" (L: ^State, n: c.int) -> bool { return type(L, n) == .NONE          }
+isnoneornil     :: #force_inline proc "c" (L: ^State, n: c.int) -> bool { return type(L, n) <= .NIL           }
+
+
+pushliteral :: pushstring
+pushglobaltable :: #force_inline proc "c" (L: ^State) {
+	rawgeti(L, REGISTRYINDEX, RIDX_GLOBALS)
+}
+tostring :: #force_inline proc "c" (L: ^State, i: c.int) -> cstring {
+	return tolstring(L, i, nil)
+}
+
+L_newlibtable :: #force_inline proc "c" (L: ^State, l: []L_Reg) {
+	createtable(L, 0, c.int(builtin.len(l) - 1))
+}
+
+L_newlib :: proc(L: ^State, l: []L_Reg) {
+	L_newlibtable(L, l)
+	L_setfuncs(L, raw_data(l), 0)
+}
+
+L_argcheck :: #force_inline proc "c" (L: ^State, cond: bool, numarg: c.int, extramsg: cstring) {
+	if cond {
+		L_argerror(L, numarg, extramsg)
+	}
+}
+
+L_typename :: #force_inline proc "c" (L: ^State, i: c.int) -> cstring {
+	return typename(L, type(L, i))
+}
+L_dofile :: #force_inline proc "c" (L: ^State, s: cstring) -> c.int {
+	err := L_loadfile(L, s)
+	return pcall(L, 0, MULTRET, 0) if err == nil else c.int(err)
+}
+L_dostring :: #force_inline proc "c" (L: ^State, s: cstring) -> c.int {
+	err := L_loadstring(L, s)
+	return pcall(L, 0, MULTRET, 0) if err == nil else c.int(err)
+}
+L_getmetatable :: #force_inline proc "c" (L: ^State, n: cstring) {
+	getfield(L, REGISTRYINDEX, n)
+}
+L_opt :: #force_inline proc "c" (L: ^State, f: $F, n: c.int, d: $T) -> T where intrinsics.type_is_proc(F) {
+	return d if isnoneornil(L, n) else f(L, n)
+}
+
+
+
+/* }============================================================== */

BIN
vendor/lua/5.2/windows/lua52.dll


BIN
vendor/lua/5.2/windows/lua52dll.lib


+ 264 - 0
vendor/lua/5.3/include/lauxlib.h

@@ -0,0 +1,264 @@
+/*
+** $Id: lauxlib.h,v 1.131.1.1 2017/04/19 17:20:42 roberto Exp $
+** Auxiliary functions for building Lua libraries
+** See Copyright Notice in lua.h
+*/
+
+
+#ifndef lauxlib_h
+#define lauxlib_h
+
+
+#include <stddef.h>
+#include <stdio.h>
+
+#include "lua.h"
+
+
+
+/* extra error code for 'luaL_loadfilex' */
+#define LUA_ERRFILE     (LUA_ERRERR+1)
+
+
+/* key, in the registry, for table of loaded modules */
+#define LUA_LOADED_TABLE	"_LOADED"
+
+
+/* key, in the registry, for table of preloaded loaders */
+#define LUA_PRELOAD_TABLE	"_PRELOAD"
+
+
+typedef struct luaL_Reg {
+  const char *name;
+  lua_CFunction func;
+} luaL_Reg;
+
+
+#define LUAL_NUMSIZES	(sizeof(lua_Integer)*16 + sizeof(lua_Number))
+
+LUALIB_API void (luaL_checkversion_) (lua_State *L, lua_Number ver, size_t sz);
+#define luaL_checkversion(L)  \
+	  luaL_checkversion_(L, LUA_VERSION_NUM, LUAL_NUMSIZES)
+
+LUALIB_API int (luaL_getmetafield) (lua_State *L, int obj, const char *e);
+LUALIB_API int (luaL_callmeta) (lua_State *L, int obj, const char *e);
+LUALIB_API const char *(luaL_tolstring) (lua_State *L, int idx, size_t *len);
+LUALIB_API int (luaL_argerror) (lua_State *L, int arg, const char *extramsg);
+LUALIB_API const char *(luaL_checklstring) (lua_State *L, int arg,
+                                                          size_t *l);
+LUALIB_API const char *(luaL_optlstring) (lua_State *L, int arg,
+                                          const char *def, size_t *l);
+LUALIB_API lua_Number (luaL_checknumber) (lua_State *L, int arg);
+LUALIB_API lua_Number (luaL_optnumber) (lua_State *L, int arg, lua_Number def);
+
+LUALIB_API lua_Integer (luaL_checkinteger) (lua_State *L, int arg);
+LUALIB_API lua_Integer (luaL_optinteger) (lua_State *L, int arg,
+                                          lua_Integer def);
+
+LUALIB_API void (luaL_checkstack) (lua_State *L, int sz, const char *msg);
+LUALIB_API void (luaL_checktype) (lua_State *L, int arg, int t);
+LUALIB_API void (luaL_checkany) (lua_State *L, int arg);
+
+LUALIB_API int   (luaL_newmetatable) (lua_State *L, const char *tname);
+LUALIB_API void  (luaL_setmetatable) (lua_State *L, const char *tname);
+LUALIB_API void *(luaL_testudata) (lua_State *L, int ud, const char *tname);
+LUALIB_API void *(luaL_checkudata) (lua_State *L, int ud, const char *tname);
+
+LUALIB_API void (luaL_where) (lua_State *L, int lvl);
+LUALIB_API int (luaL_error) (lua_State *L, const char *fmt, ...);
+
+LUALIB_API int (luaL_checkoption) (lua_State *L, int arg, const char *def,
+                                   const char *const lst[]);
+
+LUALIB_API int (luaL_fileresult) (lua_State *L, int stat, const char *fname);
+LUALIB_API int (luaL_execresult) (lua_State *L, int stat);
+
+/* predefined references */
+#define LUA_NOREF       (-2)
+#define LUA_REFNIL      (-1)
+
+LUALIB_API int (luaL_ref) (lua_State *L, int t);
+LUALIB_API void (luaL_unref) (lua_State *L, int t, int ref);
+
+LUALIB_API int (luaL_loadfilex) (lua_State *L, const char *filename,
+                                               const char *mode);
+
+#define luaL_loadfile(L,f)	luaL_loadfilex(L,f,NULL)
+
+LUALIB_API int (luaL_loadbufferx) (lua_State *L, const char *buff, size_t sz,
+                                   const char *name, const char *mode);
+LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s);
+
+LUALIB_API lua_State *(luaL_newstate) (void);
+
+LUALIB_API lua_Integer (luaL_len) (lua_State *L, int idx);
+
+LUALIB_API const char *(luaL_gsub) (lua_State *L, const char *s, const char *p,
+                                                  const char *r);
+
+LUALIB_API void (luaL_setfuncs) (lua_State *L, const luaL_Reg *l, int nup);
+
+LUALIB_API int (luaL_getsubtable) (lua_State *L, int idx, const char *fname);
+
+LUALIB_API void (luaL_traceback) (lua_State *L, lua_State *L1,
+                                  const char *msg, int level);
+
+LUALIB_API void (luaL_requiref) (lua_State *L, const char *modname,
+                                 lua_CFunction openf, int glb);
+
+/*
+** ===============================================================
+** some useful macros
+** ===============================================================
+*/
+
+
+#define luaL_newlibtable(L,l)	\
+  lua_createtable(L, 0, sizeof(l)/sizeof((l)[0]) - 1)
+
+#define luaL_newlib(L,l)  \
+  (luaL_checkversion(L), luaL_newlibtable(L,l), luaL_setfuncs(L,l,0))
+
+#define luaL_argcheck(L, cond,arg,extramsg)	\
+		((void)((cond) || luaL_argerror(L, (arg), (extramsg))))
+#define luaL_checkstring(L,n)	(luaL_checklstring(L, (n), NULL))
+#define luaL_optstring(L,n,d)	(luaL_optlstring(L, (n), (d), NULL))
+
+#define luaL_typename(L,i)	lua_typename(L, lua_type(L,(i)))
+
+#define luaL_dofile(L, fn) \
+	(luaL_loadfile(L, fn) || lua_pcall(L, 0, LUA_MULTRET, 0))
+
+#define luaL_dostring(L, s) \
+	(luaL_loadstring(L, s) || lua_pcall(L, 0, LUA_MULTRET, 0))
+
+#define luaL_getmetatable(L,n)	(lua_getfield(L, LUA_REGISTRYINDEX, (n)))
+
+#define luaL_opt(L,f,n,d)	(lua_isnoneornil(L,(n)) ? (d) : f(L,(n)))
+
+#define luaL_loadbuffer(L,s,sz,n)	luaL_loadbufferx(L,s,sz,n,NULL)
+
+
+/*
+** {======================================================
+** Generic Buffer manipulation
+** =======================================================
+*/
+
+typedef struct luaL_Buffer {
+  char *b;  /* buffer address */
+  size_t size;  /* buffer size */
+  size_t n;  /* number of characters in buffer */
+  lua_State *L;
+  char initb[LUAL_BUFFERSIZE];  /* initial buffer */
+} luaL_Buffer;
+
+
+#define luaL_addchar(B,c) \
+  ((void)((B)->n < (B)->size || luaL_prepbuffsize((B), 1)), \
+   ((B)->b[(B)->n++] = (c)))
+
+#define luaL_addsize(B,s)	((B)->n += (s))
+
+LUALIB_API void (luaL_buffinit) (lua_State *L, luaL_Buffer *B);
+LUALIB_API char *(luaL_prepbuffsize) (luaL_Buffer *B, size_t sz);
+LUALIB_API void (luaL_addlstring) (luaL_Buffer *B, const char *s, size_t l);
+LUALIB_API void (luaL_addstring) (luaL_Buffer *B, const char *s);
+LUALIB_API void (luaL_addvalue) (luaL_Buffer *B);
+LUALIB_API void (luaL_pushresult) (luaL_Buffer *B);
+LUALIB_API void (luaL_pushresultsize) (luaL_Buffer *B, size_t sz);
+LUALIB_API char *(luaL_buffinitsize) (lua_State *L, luaL_Buffer *B, size_t sz);
+
+#define luaL_prepbuffer(B)	luaL_prepbuffsize(B, LUAL_BUFFERSIZE)
+
+/* }====================================================== */
+
+
+
+/*
+** {======================================================
+** File handles for IO library
+** =======================================================
+*/
+
+/*
+** A file handle is a userdata with metatable 'LUA_FILEHANDLE' and
+** initial structure 'luaL_Stream' (it may contain other fields
+** after that initial structure).
+*/
+
+#define LUA_FILEHANDLE          "FILE*"
+
+
+typedef struct luaL_Stream {
+  FILE *f;  /* stream (NULL for incompletely created streams) */
+  lua_CFunction closef;  /* to close stream (NULL for closed streams) */
+} luaL_Stream;
+
+/* }====================================================== */
+
+
+
+/* compatibility with old module system */
+#if defined(LUA_COMPAT_MODULE)
+
+LUALIB_API void (luaL_pushmodule) (lua_State *L, const char *modname,
+                                   int sizehint);
+LUALIB_API void (luaL_openlib) (lua_State *L, const char *libname,
+                                const luaL_Reg *l, int nup);
+
+#define luaL_register(L,n,l)	(luaL_openlib(L,(n),(l),0))
+
+#endif
+
+
+/*
+** {==================================================================
+** "Abstraction Layer" for basic report of messages and errors
+** ===================================================================
+*/
+
+/* print a string */
+#if !defined(lua_writestring)
+#define lua_writestring(s,l)   fwrite((s), sizeof(char), (l), stdout)
+#endif
+
+/* print a newline and flush the output */
+#if !defined(lua_writeline)
+#define lua_writeline()        (lua_writestring("\n", 1), fflush(stdout))
+#endif
+
+/* print an error message */
+#if !defined(lua_writestringerror)
+#define lua_writestringerror(s,p) \
+        (fprintf(stderr, (s), (p)), fflush(stderr))
+#endif
+
+/* }================================================================== */
+
+
+/*
+** {============================================================
+** Compatibility with deprecated conversions
+** =============================================================
+*/
+#if defined(LUA_COMPAT_APIINTCASTS)
+
+#define luaL_checkunsigned(L,a)	((lua_Unsigned)luaL_checkinteger(L,a))
+#define luaL_optunsigned(L,a,d)	\
+	((lua_Unsigned)luaL_optinteger(L,a,(lua_Integer)(d)))
+
+#define luaL_checkint(L,n)	((int)luaL_checkinteger(L, (n)))
+#define luaL_optint(L,n,d)	((int)luaL_optinteger(L, (n), (d)))
+
+#define luaL_checklong(L,n)	((long)luaL_checkinteger(L, (n)))
+#define luaL_optlong(L,n,d)	((long)luaL_optinteger(L, (n), (d)))
+
+#endif
+/* }============================================================ */
+
+
+
+#endif
+
+

+ 485 - 0
vendor/lua/5.3/include/lua.h

@@ -0,0 +1,485 @@
+/*
+** Lua - A Scripting Language
+** Lua.org, PUC-Rio, Brazil (http://www.lua.org)
+** See Copyright Notice at the end of this file
+*/
+
+
+#ifndef lua_h
+#define lua_h
+
+#include <stdarg.h>
+#include <stddef.h>
+
+
+#include "luaconf.h"
+
+
+#define LUA_VERSION_MAJOR	"5"
+#define LUA_VERSION_MINOR	"3"
+#define LUA_VERSION_NUM		503
+#define LUA_VERSION_RELEASE	"6"
+
+#define LUA_VERSION	"Lua " LUA_VERSION_MAJOR "." LUA_VERSION_MINOR
+#define LUA_RELEASE	LUA_VERSION "." LUA_VERSION_RELEASE
+#define LUA_COPYRIGHT	LUA_RELEASE "  Copyright (C) 1994-2020 Lua.org, PUC-Rio"
+#define LUA_AUTHORS	"R. Ierusalimschy, L. H. de Figueiredo, W. Celes"
+
+
+/* mark for precompiled code ('<esc>Lua') */
+#define LUA_SIGNATURE	"\x1bLua"
+
+/* option for multiple returns in 'lua_pcall' and 'lua_call' */
+#define LUA_MULTRET	(-1)
+
+
+/*
+** Pseudo-indices
+** (-LUAI_MAXSTACK is the minimum valid index; we keep some free empty
+** space after that to help overflow detection)
+*/
+#define LUA_REGISTRYINDEX	(-LUAI_MAXSTACK - 1000)
+#define lua_upvalueindex(i)	(LUA_REGISTRYINDEX - (i))
+
+
+/* thread status */
+#define LUA_OK		0
+#define LUA_YIELD	1
+#define LUA_ERRRUN	2
+#define LUA_ERRSYNTAX	3
+#define LUA_ERRMEM	4
+#define LUA_ERRGCMM	5
+#define LUA_ERRERR	6
+
+
+typedef struct lua_State lua_State;
+
+
+/*
+** basic types
+*/
+#define LUA_TNONE		(-1)
+
+#define LUA_TNIL		0
+#define LUA_TBOOLEAN		1
+#define LUA_TLIGHTUSERDATA	2
+#define LUA_TNUMBER		3
+#define LUA_TSTRING		4
+#define LUA_TTABLE		5
+#define LUA_TFUNCTION		6
+#define LUA_TUSERDATA		7
+#define LUA_TTHREAD		8
+
+#define LUA_NUMTAGS		9
+
+
+
+/* minimum Lua stack available to a C function */
+#define LUA_MINSTACK	20
+
+
+/* predefined values in the registry */
+#define LUA_RIDX_MAINTHREAD	1
+#define LUA_RIDX_GLOBALS	2
+#define LUA_RIDX_LAST		LUA_RIDX_GLOBALS
+
+
+/* type of numbers in Lua */
+typedef LUA_NUMBER lua_Number;
+
+
+/* type for integer functions */
+typedef LUA_INTEGER lua_Integer;
+
+/* unsigned integer type */
+typedef LUA_UNSIGNED lua_Unsigned;
+
+/* type for continuation-function contexts */
+typedef LUA_KCONTEXT lua_KContext;
+
+
+/*
+** Type for C functions registered with Lua
+*/
+typedef int (*lua_CFunction) (lua_State *L);
+
+/*
+** Type for continuation functions
+*/
+typedef int (*lua_KFunction) (lua_State *L, int status, lua_KContext ctx);
+
+
+/*
+** Type for functions that read/write blocks when loading/dumping Lua chunks
+*/
+typedef const char * (*lua_Reader) (lua_State *L, void *ud, size_t *sz);
+
+typedef int (*lua_Writer) (lua_State *L, const void *p, size_t sz, void *ud);
+
+
+/*
+** Type for memory-allocation functions
+*/
+typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize);
+
+
+
+/*
+** generic extra include file
+*/
+#if defined(LUA_USER_H)
+#include LUA_USER_H
+#endif
+
+
+/*
+** RCS ident string
+*/
+extern const char lua_ident[];
+
+
+/*
+** state manipulation
+*/
+LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud);
+LUA_API void       (lua_close) (lua_State *L);
+LUA_API lua_State *(lua_newthread) (lua_State *L);
+
+LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf);
+
+
+LUA_API const lua_Number *(lua_version) (lua_State *L);
+
+
+/*
+** basic stack manipulation
+*/
+LUA_API int   (lua_absindex) (lua_State *L, int idx);
+LUA_API int   (lua_gettop) (lua_State *L);
+LUA_API void  (lua_settop) (lua_State *L, int idx);
+LUA_API void  (lua_pushvalue) (lua_State *L, int idx);
+LUA_API void  (lua_rotate) (lua_State *L, int idx, int n);
+LUA_API void  (lua_copy) (lua_State *L, int fromidx, int toidx);
+LUA_API int   (lua_checkstack) (lua_State *L, int n);
+
+LUA_API void  (lua_xmove) (lua_State *from, lua_State *to, int n);
+
+
+/*
+** access functions (stack -> C)
+*/
+
+LUA_API int             (lua_isnumber) (lua_State *L, int idx);
+LUA_API int             (lua_isstring) (lua_State *L, int idx);
+LUA_API int             (lua_iscfunction) (lua_State *L, int idx);
+LUA_API int             (lua_isinteger) (lua_State *L, int idx);
+LUA_API int             (lua_isuserdata) (lua_State *L, int idx);
+LUA_API int             (lua_type) (lua_State *L, int idx);
+LUA_API const char     *(lua_typename) (lua_State *L, int tp);
+
+LUA_API lua_Number      (lua_tonumberx) (lua_State *L, int idx, int *isnum);
+LUA_API lua_Integer     (lua_tointegerx) (lua_State *L, int idx, int *isnum);
+LUA_API int             (lua_toboolean) (lua_State *L, int idx);
+LUA_API const char     *(lua_tolstring) (lua_State *L, int idx, size_t *len);
+LUA_API size_t          (lua_rawlen) (lua_State *L, int idx);
+LUA_API lua_CFunction   (lua_tocfunction) (lua_State *L, int idx);
+LUA_API void	       *(lua_touserdata) (lua_State *L, int idx);
+LUA_API lua_State      *(lua_tothread) (lua_State *L, int idx);
+LUA_API const void     *(lua_topointer) (lua_State *L, int idx);
+
+
+/*
+** Comparison and arithmetic functions
+*/
+
+#define LUA_OPADD	0	/* ORDER TM, ORDER OP */
+#define LUA_OPSUB	1
+#define LUA_OPMUL	2
+#define LUA_OPMOD	3
+#define LUA_OPPOW	4
+#define LUA_OPDIV	5
+#define LUA_OPIDIV	6
+#define LUA_OPBAND	7
+#define LUA_OPBOR	8
+#define LUA_OPBXOR	9
+#define LUA_OPSHL	10
+#define LUA_OPSHR	11
+#define LUA_OPUNM	12
+#define LUA_OPBNOT	13
+
+LUA_API void  (lua_arith) (lua_State *L, int op);
+
+#define LUA_OPEQ	0
+#define LUA_OPLT	1
+#define LUA_OPLE	2
+
+LUA_API int   (lua_rawequal) (lua_State *L, int idx1, int idx2);
+LUA_API int   (lua_compare) (lua_State *L, int idx1, int idx2, int op);
+
+
+/*
+** push functions (C -> stack)
+*/
+LUA_API void        (lua_pushnil) (lua_State *L);
+LUA_API void        (lua_pushnumber) (lua_State *L, lua_Number n);
+LUA_API void        (lua_pushinteger) (lua_State *L, lua_Integer n);
+LUA_API const char *(lua_pushlstring) (lua_State *L, const char *s, size_t len);
+LUA_API const char *(lua_pushstring) (lua_State *L, const char *s);
+LUA_API const char *(lua_pushvfstring) (lua_State *L, const char *fmt,
+                                                      va_list argp);
+LUA_API const char *(lua_pushfstring) (lua_State *L, const char *fmt, ...);
+LUA_API void  (lua_pushcclosure) (lua_State *L, lua_CFunction fn, int n);
+LUA_API void  (lua_pushboolean) (lua_State *L, int b);
+LUA_API void  (lua_pushlightuserdata) (lua_State *L, void *p);
+LUA_API int   (lua_pushthread) (lua_State *L);
+
+
+/*
+** get functions (Lua -> stack)
+*/
+LUA_API int (lua_getglobal) (lua_State *L, const char *name);
+LUA_API int (lua_gettable) (lua_State *L, int idx);
+LUA_API int (lua_getfield) (lua_State *L, int idx, const char *k);
+LUA_API int (lua_geti) (lua_State *L, int idx, lua_Integer n);
+LUA_API int (lua_rawget) (lua_State *L, int idx);
+LUA_API int (lua_rawgeti) (lua_State *L, int idx, lua_Integer n);
+LUA_API int (lua_rawgetp) (lua_State *L, int idx, const void *p);
+
+LUA_API void  (lua_createtable) (lua_State *L, int narr, int nrec);
+LUA_API void *(lua_newuserdata) (lua_State *L, size_t sz);
+LUA_API int   (lua_getmetatable) (lua_State *L, int objindex);
+LUA_API int  (lua_getuservalue) (lua_State *L, int idx);
+
+
+/*
+** set functions (stack -> Lua)
+*/
+LUA_API void  (lua_setglobal) (lua_State *L, const char *name);
+LUA_API void  (lua_settable) (lua_State *L, int idx);
+LUA_API void  (lua_setfield) (lua_State *L, int idx, const char *k);
+LUA_API void  (lua_seti) (lua_State *L, int idx, lua_Integer n);
+LUA_API void  (lua_rawset) (lua_State *L, int idx);
+LUA_API void  (lua_rawseti) (lua_State *L, int idx, lua_Integer n);
+LUA_API void  (lua_rawsetp) (lua_State *L, int idx, const void *p);
+LUA_API int   (lua_setmetatable) (lua_State *L, int objindex);
+LUA_API void  (lua_setuservalue) (lua_State *L, int idx);
+
+
+/*
+** 'load' and 'call' functions (load and run Lua code)
+*/
+LUA_API void  (lua_callk) (lua_State *L, int nargs, int nresults,
+                           lua_KContext ctx, lua_KFunction k);
+#define lua_call(L,n,r)		lua_callk(L, (n), (r), 0, NULL)
+
+LUA_API int   (lua_pcallk) (lua_State *L, int nargs, int nresults, int errfunc,
+                            lua_KContext ctx, lua_KFunction k);
+#define lua_pcall(L,n,r,f)	lua_pcallk(L, (n), (r), (f), 0, NULL)
+
+LUA_API int   (lua_load) (lua_State *L, lua_Reader reader, void *dt,
+                          const char *chunkname, const char *mode);
+
+LUA_API int (lua_dump) (lua_State *L, lua_Writer writer, void *data, int strip);
+
+
+/*
+** coroutine functions
+*/
+LUA_API int  (lua_yieldk)     (lua_State *L, int nresults, lua_KContext ctx,
+                               lua_KFunction k);
+LUA_API int  (lua_resume)     (lua_State *L, lua_State *from, int narg);
+LUA_API int  (lua_status)     (lua_State *L);
+LUA_API int (lua_isyieldable) (lua_State *L);
+
+#define lua_yield(L,n)		lua_yieldk(L, (n), 0, NULL)
+
+
+/*
+** garbage-collection function and options
+*/
+
+#define LUA_GCSTOP		0
+#define LUA_GCRESTART		1
+#define LUA_GCCOLLECT		2
+#define LUA_GCCOUNT		3
+#define LUA_GCCOUNTB		4
+#define LUA_GCSTEP		5
+#define LUA_GCSETPAUSE		6
+#define LUA_GCSETSTEPMUL	7
+#define LUA_GCISRUNNING		9
+
+LUA_API int (lua_gc) (lua_State *L, int what, int data);
+
+
+/*
+** miscellaneous functions
+*/
+
+LUA_API int   (lua_error) (lua_State *L);
+
+LUA_API int   (lua_next) (lua_State *L, int idx);
+
+LUA_API void  (lua_concat) (lua_State *L, int n);
+LUA_API void  (lua_len)    (lua_State *L, int idx);
+
+LUA_API size_t   (lua_stringtonumber) (lua_State *L, const char *s);
+
+LUA_API lua_Alloc (lua_getallocf) (lua_State *L, void **ud);
+LUA_API void      (lua_setallocf) (lua_State *L, lua_Alloc f, void *ud);
+
+
+
+/*
+** {==============================================================
+** some useful macros
+** ===============================================================
+*/
+
+#define lua_getextraspace(L)	((void *)((char *)(L) - LUA_EXTRASPACE))
+
+#define lua_tonumber(L,i)	lua_tonumberx(L,(i),NULL)
+#define lua_tointeger(L,i)	lua_tointegerx(L,(i),NULL)
+
+#define lua_pop(L,n)		lua_settop(L, -(n)-1)
+
+#define lua_newtable(L)		lua_createtable(L, 0, 0)
+
+#define lua_register(L,n,f) (lua_pushcfunction(L, (f)), lua_setglobal(L, (n)))
+
+#define lua_pushcfunction(L,f)	lua_pushcclosure(L, (f), 0)
+
+#define lua_isfunction(L,n)	(lua_type(L, (n)) == LUA_TFUNCTION)
+#define lua_istable(L,n)	(lua_type(L, (n)) == LUA_TTABLE)
+#define lua_islightuserdata(L,n)	(lua_type(L, (n)) == LUA_TLIGHTUSERDATA)
+#define lua_isnil(L,n)		(lua_type(L, (n)) == LUA_TNIL)
+#define lua_isboolean(L,n)	(lua_type(L, (n)) == LUA_TBOOLEAN)
+#define lua_isthread(L,n)	(lua_type(L, (n)) == LUA_TTHREAD)
+#define lua_isnone(L,n)		(lua_type(L, (n)) == LUA_TNONE)
+#define lua_isnoneornil(L, n)	(lua_type(L, (n)) <= 0)
+
+#define lua_pushliteral(L, s)	lua_pushstring(L, "" s)
+
+#define lua_pushglobaltable(L)  \
+	((void)lua_rawgeti(L, LUA_REGISTRYINDEX, LUA_RIDX_GLOBALS))
+
+#define lua_tostring(L,i)	lua_tolstring(L, (i), NULL)
+
+
+#define lua_insert(L,idx)	lua_rotate(L, (idx), 1)
+
+#define lua_remove(L,idx)	(lua_rotate(L, (idx), -1), lua_pop(L, 1))
+
+#define lua_replace(L,idx)	(lua_copy(L, -1, (idx)), lua_pop(L, 1))
+
+/* }============================================================== */
+
+
+/*
+** {==============================================================
+** compatibility macros for unsigned conversions
+** ===============================================================
+*/
+#if defined(LUA_COMPAT_APIINTCASTS)
+
+#define lua_pushunsigned(L,n)	lua_pushinteger(L, (lua_Integer)(n))
+#define lua_tounsignedx(L,i,is)	((lua_Unsigned)lua_tointegerx(L,i,is))
+#define lua_tounsigned(L,i)	lua_tounsignedx(L,(i),NULL)
+
+#endif
+/* }============================================================== */
+
+/*
+** {======================================================================
+** Debug API
+** =======================================================================
+*/
+
+
+/*
+** Event codes
+*/
+#define LUA_HOOKCALL	0
+#define LUA_HOOKRET	1
+#define LUA_HOOKLINE	2
+#define LUA_HOOKCOUNT	3
+#define LUA_HOOKTAILCALL 4
+
+
+/*
+** Event masks
+*/
+#define LUA_MASKCALL	(1 << LUA_HOOKCALL)
+#define LUA_MASKRET	(1 << LUA_HOOKRET)
+#define LUA_MASKLINE	(1 << LUA_HOOKLINE)
+#define LUA_MASKCOUNT	(1 << LUA_HOOKCOUNT)
+
+typedef struct lua_Debug lua_Debug;  /* activation record */
+
+
+/* Functions to be called by the debugger in specific events */
+typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar);
+
+
+LUA_API int (lua_getstack) (lua_State *L, int level, lua_Debug *ar);
+LUA_API int (lua_getinfo) (lua_State *L, const char *what, lua_Debug *ar);
+LUA_API const char *(lua_getlocal) (lua_State *L, const lua_Debug *ar, int n);
+LUA_API const char *(lua_setlocal) (lua_State *L, const lua_Debug *ar, int n);
+LUA_API const char *(lua_getupvalue) (lua_State *L, int funcindex, int n);
+LUA_API const char *(lua_setupvalue) (lua_State *L, int funcindex, int n);
+
+LUA_API void *(lua_upvalueid) (lua_State *L, int fidx, int n);
+LUA_API void  (lua_upvaluejoin) (lua_State *L, int fidx1, int n1,
+                                               int fidx2, int n2);
+
+LUA_API void (lua_sethook) (lua_State *L, lua_Hook func, int mask, int count);
+LUA_API lua_Hook (lua_gethook) (lua_State *L);
+LUA_API int (lua_gethookmask) (lua_State *L);
+LUA_API int (lua_gethookcount) (lua_State *L);
+
+
+struct lua_Debug {
+  int event;
+  const char *name;	/* (n) */
+  const char *namewhat;	/* (n) 'global', 'local', 'field', 'method' */
+  const char *what;	/* (S) 'Lua', 'C', 'main', 'tail' */
+  const char *source;	/* (S) */
+  int currentline;	/* (l) */
+  int linedefined;	/* (S) */
+  int lastlinedefined;	/* (S) */
+  unsigned char nups;	/* (u) number of upvalues */
+  unsigned char nparams;/* (u) number of parameters */
+  char isvararg;        /* (u) */
+  char istailcall;	/* (t) */
+  char short_src[LUA_IDSIZE]; /* (S) */
+  /* private part */
+  struct CallInfo *i_ci;  /* active function */
+};
+
+/* }====================================================================== */
+
+
+/******************************************************************************
+* Copyright (C) 1994-2020 Lua.org, PUC-Rio.
+*
+* 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.
+******************************************************************************/
+
+
+#endif

+ 9 - 0
vendor/lua/5.3/include/lua.hpp

@@ -0,0 +1,9 @@
+// lua.hpp
+// Lua header files for C++
+// <<extern "C">> not supplied automatically because Lua also compiles as C++
+
+extern "C" {
+#include "lua.h"
+#include "lualib.h"
+#include "lauxlib.h"
+}

+ 792 - 0
vendor/lua/5.3/include/luaconf.h

@@ -0,0 +1,792 @@
+/*
+** $Id: luaconf.h,v 1.259.1.1 2017/04/19 17:29:57 roberto Exp $
+** Configuration file for Lua
+** See Copyright Notice in lua.h
+*/
+
+
+#ifndef luaconf_h
+#define luaconf_h
+
+#include <limits.h>
+#include <stddef.h>
+
+
+/*
+** ===================================================================
+** Search for "@@" to find all configurable definitions.
+** ===================================================================
+*/
+
+
+/*
+** {====================================================================
+** System Configuration: macros to adapt (if needed) Lua to some
+** particular platform, for instance compiling it with 32-bit numbers or
+** restricting it to C89.
+** =====================================================================
+*/
+
+/*
+@@ LUA_32BITS enables Lua with 32-bit integers and 32-bit floats. You
+** can also define LUA_32BITS in the make file, but changing here you
+** ensure that all software connected to Lua will be compiled with the
+** same configuration.
+*/
+/* #define LUA_32BITS */
+
+
+/*
+@@ LUA_USE_C89 controls the use of non-ISO-C89 features.
+** Define it if you want Lua to avoid the use of a few C99 features
+** or Windows-specific features on Windows.
+*/
+/* #define LUA_USE_C89 */
+
+
+/*
+** By default, Lua on Windows use (some) specific Windows features
+*/
+#if !defined(LUA_USE_C89) && defined(_WIN32) && !defined(_WIN32_WCE)
+#define LUA_USE_WINDOWS  /* enable goodies for regular Windows */
+#endif
+
+
+#if defined(LUA_USE_WINDOWS)
+#define LUA_DL_DLL	/* enable support for DLL */
+#define LUA_USE_C89	/* broadly, Windows is C89 */
+#endif
+
+
+#if defined(LUA_USE_LINUX)
+#define LUA_USE_POSIX
+#define LUA_USE_DLOPEN		/* needs an extra library: -ldl */
+#define LUA_USE_READLINE	/* needs some extra libraries */
+#endif
+
+
+#if defined(LUA_USE_MACOSX)
+#define LUA_USE_POSIX
+#define LUA_USE_DLOPEN		/* MacOS does not need -ldl */
+#define LUA_USE_READLINE	/* needs an extra library: -lreadline */
+#endif
+
+
+/*
+@@ LUA_C89_NUMBERS ensures that Lua uses the largest types available for
+** C89 ('long' and 'double'); Windows always has '__int64', so it does
+** not need to use this case.
+*/
+#if defined(LUA_USE_C89) && !defined(LUA_USE_WINDOWS)
+#define LUA_C89_NUMBERS
+#endif
+
+
+
+/*
+@@ LUAI_BITSINT defines the (minimum) number of bits in an 'int'.
+*/
+/* avoid undefined shifts */
+#if ((INT_MAX >> 15) >> 15) >= 1
+#define LUAI_BITSINT	32
+#else
+/* 'int' always must have at least 16 bits */
+#define LUAI_BITSINT	16
+#endif
+
+
+/*
+@@ LUA_INT_TYPE defines the type for Lua integers.
+@@ LUA_FLOAT_TYPE defines the type for Lua floats.
+** Lua should work fine with any mix of these options (if supported
+** by your C compiler). The usual configurations are 64-bit integers
+** and 'double' (the default), 32-bit integers and 'float' (for
+** restricted platforms), and 'long'/'double' (for C compilers not
+** compliant with C99, which may not have support for 'long long').
+*/
+
+/* predefined options for LUA_INT_TYPE */
+#define LUA_INT_INT		1
+#define LUA_INT_LONG		2
+#define LUA_INT_LONGLONG	3
+
+/* predefined options for LUA_FLOAT_TYPE */
+#define LUA_FLOAT_FLOAT		1
+#define LUA_FLOAT_DOUBLE	2
+#define LUA_FLOAT_LONGDOUBLE	3
+
+#if defined(LUA_32BITS)		/* { */
+/*
+** 32-bit integers and 'float'
+*/
+#if LUAI_BITSINT >= 32  /* use 'int' if big enough */
+#define LUA_INT_TYPE	LUA_INT_INT
+#else  /* otherwise use 'long' */
+#define LUA_INT_TYPE	LUA_INT_LONG
+#endif
+#define LUA_FLOAT_TYPE	LUA_FLOAT_FLOAT
+
+#elif defined(LUA_C89_NUMBERS)	/* }{ */
+/*
+** largest types available for C89 ('long' and 'double')
+*/
+#define LUA_INT_TYPE	LUA_INT_LONG
+#define LUA_FLOAT_TYPE	LUA_FLOAT_DOUBLE
+
+#endif				/* } */
+
+
+/*
+** default configuration for 64-bit Lua ('long long' and 'double')
+*/
+#if !defined(LUA_INT_TYPE)
+#define LUA_INT_TYPE	LUA_INT_LONGLONG
+#endif
+
+#if !defined(LUA_FLOAT_TYPE)
+#define LUA_FLOAT_TYPE	LUA_FLOAT_DOUBLE
+#endif
+
+/* }================================================================== */
+
+
+
+
+/*
+** {==================================================================
+** Configuration for Paths.
+** ===================================================================
+*/
+
+/*
+** LUA_PATH_SEP is the character that separates templates in a path.
+** LUA_PATH_MARK is the string that marks the substitution points in a
+** template.
+** LUA_EXEC_DIR in a Windows path is replaced by the executable's
+** directory.
+*/
+#define LUA_PATH_SEP            ";"
+#define LUA_PATH_MARK           "?"
+#define LUA_EXEC_DIR            "!"
+
+
+/*
+@@ LUA_PATH_DEFAULT is the default path that Lua uses to look for
+** Lua libraries.
+@@ LUA_CPATH_DEFAULT is the default path that Lua uses to look for
+** C libraries.
+** CHANGE them if your machine has a non-conventional directory
+** hierarchy or if you want to install your libraries in
+** non-conventional directories.
+*/
+#define LUA_VDIR	LUA_VERSION_MAJOR "." LUA_VERSION_MINOR
+#if defined(_WIN32)	/* { */
+/*
+** In Windows, any exclamation mark ('!') in the path is replaced by the
+** path of the directory of the executable file of the current process.
+*/
+#define LUA_LDIR	"!\\lua\\"
+#define LUA_CDIR	"!\\"
+#define LUA_SHRDIR	"!\\..\\share\\lua\\" LUA_VDIR "\\"
+#define LUA_PATH_DEFAULT  \
+		LUA_LDIR"?.lua;"  LUA_LDIR"?\\init.lua;" \
+		LUA_CDIR"?.lua;"  LUA_CDIR"?\\init.lua;" \
+		LUA_SHRDIR"?.lua;" LUA_SHRDIR"?\\init.lua;" \
+		".\\?.lua;" ".\\?\\init.lua"
+#define LUA_CPATH_DEFAULT \
+		LUA_CDIR"?.dll;" \
+		LUA_CDIR"..\\lib\\lua\\" LUA_VDIR "\\?.dll;" \
+		LUA_CDIR"loadall.dll;" ".\\?.dll;" \
+		LUA_CDIR"?53.dll;" ".\\?53.dll"
+
+#else			/* }{ */
+
+#define LUA_ROOT	"/usr/local/"
+#define LUA_LDIR	LUA_ROOT "share/lua/" LUA_VDIR "/"
+#define LUA_CDIR	LUA_ROOT "lib/lua/" LUA_VDIR "/"
+#define LUA_PATH_DEFAULT  \
+		LUA_LDIR"?.lua;"  LUA_LDIR"?/init.lua;" \
+		LUA_CDIR"?.lua;"  LUA_CDIR"?/init.lua;" \
+		"./?.lua;" "./?/init.lua"
+#define LUA_CPATH_DEFAULT \
+		LUA_CDIR"?.so;" LUA_CDIR"loadall.so;" "./?.so;" \
+		LUA_CDIR"lib?53.so;" "./lib?53.so"
+#endif			/* } */
+
+
+/*
+@@ LUA_DIRSEP is the directory separator (for submodules).
+** CHANGE it if your machine does not use "/" as the directory separator
+** and is not Windows. (On Windows Lua automatically uses "\".)
+*/
+#if defined(_WIN32)
+#define LUA_DIRSEP	"\\"
+#else
+#define LUA_DIRSEP	"/"
+#endif
+
+/* }================================================================== */
+
+
+/*
+** {==================================================================
+** Marks for exported symbols in the C code
+** ===================================================================
+*/
+
+/*
+@@ LUA_API is a mark for all core API functions.
+@@ LUALIB_API is a mark for all auxiliary library functions.
+@@ LUAMOD_API is a mark for all standard library opening functions.
+** CHANGE them if you need to define those functions in some special way.
+** For instance, if you want to create one Windows DLL with the core and
+** the libraries, you may want to use the following definition (define
+** LUA_BUILD_AS_DLL to get it).
+*/
+#if defined(LUA_BUILD_AS_DLL)	/* { */
+
+#if defined(LUA_CORE) || defined(LUA_LIB)	/* { */
+#define LUA_API __declspec(dllexport)
+#else						/* }{ */
+#define LUA_API __declspec(dllimport)
+#endif						/* } */
+
+#else				/* }{ */
+
+#define LUA_API		extern
+
+#endif				/* } */
+
+
+/* more often than not the libs go together with the core */
+#define LUALIB_API	LUA_API
+#define LUAMOD_API	LUALIB_API
+
+
+/*
+@@ LUAI_FUNC is a mark for all extern functions that are not to be
+** exported to outside modules.
+@@ LUAI_DDEF and LUAI_DDEC are marks for all extern (const) variables
+** that are not to be exported to outside modules (LUAI_DDEF for
+** definitions and LUAI_DDEC for declarations).
+** CHANGE them if you need to mark them in some special way. Elf/gcc
+** (versions 3.2 and later) mark them as "hidden" to optimize access
+** when Lua is compiled as a shared library. Not all elf targets support
+** this attribute. Unfortunately, gcc does not offer a way to check
+** whether the target offers that support, and those without support
+** give a warning about it. To avoid these warnings, change to the
+** default definition.
+*/
+#if defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \
+    defined(__ELF__)		/* { */
+#define LUAI_FUNC	__attribute__((visibility("hidden"))) extern
+#else				/* }{ */
+#define LUAI_FUNC	extern
+#endif				/* } */
+
+#define LUAI_DDEC	LUAI_FUNC
+#define LUAI_DDEF	/* empty */
+
+/* }================================================================== */
+
+
+/*
+** {==================================================================
+** Compatibility with previous versions
+** ===================================================================
+*/
+
+/*
+@@ LUA_COMPAT_5_2 controls other macros for compatibility with Lua 5.2.
+@@ LUA_COMPAT_5_1 controls other macros for compatibility with Lua 5.1.
+** You can define it to get all options, or change specific options
+** to fit your specific needs.
+*/
+#if defined(LUA_COMPAT_5_2)	/* { */
+
+/*
+@@ LUA_COMPAT_MATHLIB controls the presence of several deprecated
+** functions in the mathematical library.
+*/
+#define LUA_COMPAT_MATHLIB
+
+/*
+@@ LUA_COMPAT_BITLIB controls the presence of library 'bit32'.
+*/
+#define LUA_COMPAT_BITLIB
+
+/*
+@@ LUA_COMPAT_IPAIRS controls the effectiveness of the __ipairs metamethod.
+*/
+#define LUA_COMPAT_IPAIRS
+
+/*
+@@ LUA_COMPAT_APIINTCASTS controls the presence of macros for
+** manipulating other integer types (lua_pushunsigned, lua_tounsigned,
+** luaL_checkint, luaL_checklong, etc.)
+*/
+#define LUA_COMPAT_APIINTCASTS
+
+#endif				/* } */
+
+
+#if defined(LUA_COMPAT_5_1)	/* { */
+
+/* Incompatibilities from 5.2 -> 5.3 */
+#define LUA_COMPAT_MATHLIB
+#define LUA_COMPAT_APIINTCASTS
+
+/*
+@@ LUA_COMPAT_UNPACK controls the presence of global 'unpack'.
+** You can replace it with 'table.unpack'.
+*/
+#define LUA_COMPAT_UNPACK
+
+/*
+@@ LUA_COMPAT_LOADERS controls the presence of table 'package.loaders'.
+** You can replace it with 'package.searchers'.
+*/
+#define LUA_COMPAT_LOADERS
+
+/*
+@@ macro 'lua_cpcall' emulates deprecated function lua_cpcall.
+** You can call your C function directly (with light C functions).
+*/
+#define lua_cpcall(L,f,u)  \
+	(lua_pushcfunction(L, (f)), \
+	 lua_pushlightuserdata(L,(u)), \
+	 lua_pcall(L,1,0,0))
+
+
+/*
+@@ LUA_COMPAT_LOG10 defines the function 'log10' in the math library.
+** You can rewrite 'log10(x)' as 'log(x, 10)'.
+*/
+#define LUA_COMPAT_LOG10
+
+/*
+@@ LUA_COMPAT_LOADSTRING defines the function 'loadstring' in the base
+** library. You can rewrite 'loadstring(s)' as 'load(s)'.
+*/
+#define LUA_COMPAT_LOADSTRING
+
+/*
+@@ LUA_COMPAT_MAXN defines the function 'maxn' in the table library.
+*/
+#define LUA_COMPAT_MAXN
+
+/*
+@@ The following macros supply trivial compatibility for some
+** changes in the API. The macros themselves document how to
+** change your code to avoid using them.
+*/
+#define lua_strlen(L,i)		lua_rawlen(L, (i))
+
+#define lua_objlen(L,i)		lua_rawlen(L, (i))
+
+#define lua_equal(L,idx1,idx2)		lua_compare(L,(idx1),(idx2),LUA_OPEQ)
+#define lua_lessthan(L,idx1,idx2)	lua_compare(L,(idx1),(idx2),LUA_OPLT)
+
+/*
+@@ LUA_COMPAT_MODULE controls compatibility with previous
+** module functions 'module' (Lua) and 'luaL_register' (C).
+*/
+#define LUA_COMPAT_MODULE
+
+#endif				/* } */
+
+
+/*
+@@ LUA_COMPAT_FLOATSTRING makes Lua format integral floats without a
+@@ a float mark ('.0').
+** This macro is not on by default even in compatibility mode,
+** because this is not really an incompatibility.
+*/
+/* #define LUA_COMPAT_FLOATSTRING */
+
+/* }================================================================== */
+
+
+
+/*
+** {==================================================================
+** Configuration for Numbers.
+** Change these definitions if no predefined LUA_FLOAT_* / LUA_INT_*
+** satisfy your needs.
+** ===================================================================
+*/
+
+/*
+@@ LUA_NUMBER is the floating-point type used by Lua.
+@@ LUAI_UACNUMBER is the result of a 'default argument promotion'
+@@ over a floating number.
+@@ l_mathlim(x) corrects limit name 'x' to the proper float type
+** by prefixing it with one of FLT/DBL/LDBL.
+@@ LUA_NUMBER_FRMLEN is the length modifier for writing floats.
+@@ LUA_NUMBER_FMT is the format for writing floats.
+@@ lua_number2str converts a float to a string.
+@@ l_mathop allows the addition of an 'l' or 'f' to all math operations.
+@@ l_floor takes the floor of a float.
+@@ lua_str2number converts a decimal numeric string to a number.
+*/
+
+
+/* The following definitions are good for most cases here */
+
+#define l_floor(x)		(l_mathop(floor)(x))
+
+#define lua_number2str(s,sz,n)  \
+	l_sprintf((s), sz, LUA_NUMBER_FMT, (LUAI_UACNUMBER)(n))
+
+/*
+@@ lua_numbertointeger converts a float number to an integer, or
+** returns 0 if float is not within the range of a lua_Integer.
+** (The range comparisons are tricky because of rounding. The tests
+** here assume a two-complement representation, where MININTEGER always
+** has an exact representation as a float; MAXINTEGER may not have one,
+** and therefore its conversion to float may have an ill-defined value.)
+*/
+#define lua_numbertointeger(n,p) \
+  ((n) >= (LUA_NUMBER)(LUA_MININTEGER) && \
+   (n) < -(LUA_NUMBER)(LUA_MININTEGER) && \
+      (*(p) = (LUA_INTEGER)(n), 1))
+
+
+/* now the variable definitions */
+
+#if LUA_FLOAT_TYPE == LUA_FLOAT_FLOAT		/* { single float */
+
+#define LUA_NUMBER	float
+
+#define l_mathlim(n)		(FLT_##n)
+
+#define LUAI_UACNUMBER	double
+
+#define LUA_NUMBER_FRMLEN	""
+#define LUA_NUMBER_FMT		"%.7g"
+
+#define l_mathop(op)		op##f
+
+#define lua_str2number(s,p)	strtof((s), (p))
+
+
+#elif LUA_FLOAT_TYPE == LUA_FLOAT_LONGDOUBLE	/* }{ long double */
+
+#define LUA_NUMBER	long double
+
+#define l_mathlim(n)		(LDBL_##n)
+
+#define LUAI_UACNUMBER	long double
+
+#define LUA_NUMBER_FRMLEN	"L"
+#define LUA_NUMBER_FMT		"%.19Lg"
+
+#define l_mathop(op)		op##l
+
+#define lua_str2number(s,p)	strtold((s), (p))
+
+#elif LUA_FLOAT_TYPE == LUA_FLOAT_DOUBLE	/* }{ double */
+
+#define LUA_NUMBER	double
+
+#define l_mathlim(n)		(DBL_##n)
+
+#define LUAI_UACNUMBER	double
+
+#define LUA_NUMBER_FRMLEN	""
+#define LUA_NUMBER_FMT		"%.14g"
+
+#define l_mathop(op)		op
+
+#define lua_str2number(s,p)	strtod((s), (p))
+
+#else						/* }{ */
+
+#error "numeric float type not defined"
+
+#endif					/* } */
+
+
+
+/*
+@@ LUA_INTEGER is the integer type used by Lua.
+**
+@@ LUA_UNSIGNED is the unsigned version of LUA_INTEGER.
+**
+@@ LUAI_UACINT is the result of a 'default argument promotion'
+@@ over a lUA_INTEGER.
+@@ LUA_INTEGER_FRMLEN is the length modifier for reading/writing integers.
+@@ LUA_INTEGER_FMT is the format for writing integers.
+@@ LUA_MAXINTEGER is the maximum value for a LUA_INTEGER.
+@@ LUA_MININTEGER is the minimum value for a LUA_INTEGER.
+@@ lua_integer2str converts an integer to a string.
+*/
+
+
+/* The following definitions are good for most cases here */
+
+#define LUA_INTEGER_FMT		"%" LUA_INTEGER_FRMLEN "d"
+
+#define LUAI_UACINT		LUA_INTEGER
+
+#define lua_integer2str(s,sz,n)  \
+	l_sprintf((s), sz, LUA_INTEGER_FMT, (LUAI_UACINT)(n))
+
+/*
+** use LUAI_UACINT here to avoid problems with promotions (which
+** can turn a comparison between unsigneds into a signed comparison)
+*/
+#define LUA_UNSIGNED		unsigned LUAI_UACINT
+
+
+/* now the variable definitions */
+
+#if LUA_INT_TYPE == LUA_INT_INT		/* { int */
+
+#define LUA_INTEGER		int
+#define LUA_INTEGER_FRMLEN	""
+
+#define LUA_MAXINTEGER		INT_MAX
+#define LUA_MININTEGER		INT_MIN
+
+#elif LUA_INT_TYPE == LUA_INT_LONG	/* }{ long */
+
+#define LUA_INTEGER		long
+#define LUA_INTEGER_FRMLEN	"l"
+
+#define LUA_MAXINTEGER		LONG_MAX
+#define LUA_MININTEGER		LONG_MIN
+
+#elif LUA_INT_TYPE == LUA_INT_LONGLONG	/* }{ long long */
+
+/* use presence of macro LLONG_MAX as proxy for C99 compliance */
+#if defined(LLONG_MAX)		/* { */
+/* use ISO C99 stuff */
+
+#define LUA_INTEGER		long long
+#define LUA_INTEGER_FRMLEN	"ll"
+
+#define LUA_MAXINTEGER		LLONG_MAX
+#define LUA_MININTEGER		LLONG_MIN
+
+#elif defined(LUA_USE_WINDOWS) /* }{ */
+/* in Windows, can use specific Windows types */
+
+#define LUA_INTEGER		__int64
+#define LUA_INTEGER_FRMLEN	"I64"
+
+#define LUA_MAXINTEGER		_I64_MAX
+#define LUA_MININTEGER		_I64_MIN
+
+#else				/* }{ */
+
+#error "Compiler does not support 'long long'. Use option '-DLUA_32BITS' \
+  or '-DLUA_C89_NUMBERS' (see file 'luaconf.h' for details)"
+
+#endif				/* } */
+
+#else				/* }{ */
+
+#error "numeric integer type not defined"
+
+#endif				/* } */
+
+/* }================================================================== */
+
+
+/*
+** {==================================================================
+** Dependencies with C99 and other C details
+** ===================================================================
+*/
+
+/*
+@@ l_sprintf is equivalent to 'snprintf' or 'sprintf' in C89.
+** (All uses in Lua have only one format item.)
+*/
+#if !defined(LUA_USE_C89)
+#define l_sprintf(s,sz,f,i)	snprintf(s,sz,f,i)
+#else
+#define l_sprintf(s,sz,f,i)	((void)(sz), sprintf(s,f,i))
+#endif
+
+
+/*
+@@ lua_strx2number converts an hexadecimal numeric string to a number.
+** In C99, 'strtod' does that conversion. Otherwise, you can
+** leave 'lua_strx2number' undefined and Lua will provide its own
+** implementation.
+*/
+#if !defined(LUA_USE_C89)
+#define lua_strx2number(s,p)		lua_str2number(s,p)
+#endif
+
+
+/*
+@@ lua_pointer2str converts a pointer to a readable string in a
+** non-specified way.
+*/
+#define lua_pointer2str(buff,sz,p)	l_sprintf(buff,sz,"%p",p)
+
+
+/*
+@@ lua_number2strx converts a float to an hexadecimal numeric string.
+** In C99, 'sprintf' (with format specifiers '%a'/'%A') does that.
+** Otherwise, you can leave 'lua_number2strx' undefined and Lua will
+** provide its own implementation.
+*/
+#if !defined(LUA_USE_C89)
+#define lua_number2strx(L,b,sz,f,n)  \
+	((void)L, l_sprintf(b,sz,f,(LUAI_UACNUMBER)(n)))
+#endif
+
+
+/*
+** 'strtof' and 'opf' variants for math functions are not valid in
+** C89. Otherwise, the macro 'HUGE_VALF' is a good proxy for testing the
+** availability of these variants. ('math.h' is already included in
+** all files that use these macros.)
+*/
+#if defined(LUA_USE_C89) || (defined(HUGE_VAL) && !defined(HUGE_VALF))
+#undef l_mathop  /* variants not available */
+#undef lua_str2number
+#define l_mathop(op)		(lua_Number)op  /* no variant */
+#define lua_str2number(s,p)	((lua_Number)strtod((s), (p)))
+#endif
+
+
+/*
+@@ LUA_KCONTEXT is the type of the context ('ctx') for continuation
+** functions.  It must be a numerical type; Lua will use 'intptr_t' if
+** available, otherwise it will use 'ptrdiff_t' (the nearest thing to
+** 'intptr_t' in C89)
+*/
+#define LUA_KCONTEXT	ptrdiff_t
+
+#if !defined(LUA_USE_C89) && defined(__STDC_VERSION__) && \
+    __STDC_VERSION__ >= 199901L
+#include <stdint.h>
+#if defined(INTPTR_MAX)  /* even in C99 this type is optional */
+#undef LUA_KCONTEXT
+#define LUA_KCONTEXT	intptr_t
+#endif
+#endif
+
+
+/*
+@@ lua_getlocaledecpoint gets the locale "radix character" (decimal point).
+** Change that if you do not want to use C locales. (Code using this
+** macro must include header 'locale.h'.)
+*/
+#if !defined(lua_getlocaledecpoint)
+#define lua_getlocaledecpoint()		(localeconv()->decimal_point[0])
+#endif
+
+/* }================================================================== */
+
+
+/*
+** {==================================================================
+** Language Variations
+** =====================================================================
+*/
+
+/*
+@@ LUA_NOCVTN2S/LUA_NOCVTS2N control how Lua performs some
+** coercions. Define LUA_NOCVTN2S to turn off automatic coercion from
+** numbers to strings. Define LUA_NOCVTS2N to turn off automatic
+** coercion from strings to numbers.
+*/
+/* #define LUA_NOCVTN2S */
+/* #define LUA_NOCVTS2N */
+
+
+/*
+@@ LUA_USE_APICHECK turns on several consistency checks on the C API.
+** Define it as a help when debugging C code.
+*/
+#if defined(LUA_USE_APICHECK)
+#include <assert.h>
+#define luai_apicheck(l,e)	assert(e)
+#endif
+
+/* }================================================================== */
+
+
+/*
+** {==================================================================
+** Macros that affect the API and must be stable (that is, must be the
+** same when you compile Lua and when you compile code that links to
+** Lua). You probably do not want/need to change them.
+** =====================================================================
+*/
+
+/*
+@@ LUAI_MAXSTACK limits the size of the Lua stack.
+** CHANGE it if you need a different limit. This limit is arbitrary;
+** its only purpose is to stop Lua from consuming unlimited stack
+** space (and to reserve some numbers for pseudo-indices).
+*/
+#if LUAI_BITSINT >= 32
+#define LUAI_MAXSTACK		1000000
+#else
+#define LUAI_MAXSTACK		15000
+#endif
+
+
+/*
+@@ LUA_EXTRASPACE defines the size of a raw memory area associated with
+** a Lua state with very fast access.
+** CHANGE it if you need a different size.
+*/
+#define LUA_EXTRASPACE		(sizeof(void *))
+
+
+/*
+@@ LUA_IDSIZE gives the maximum size for the description of the source
+@@ of a function in debug information.
+** CHANGE it if you want a different size.
+*/
+#define LUA_IDSIZE	60
+
+
+/*
+@@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system.
+** CHANGE it if it uses too much C-stack space. (For long double,
+** 'string.format("%.99f", -1e4932)' needs 5034 bytes, so a
+** smaller buffer would force a memory allocation for each call to
+** 'string.format'.)
+*/
+#if LUA_FLOAT_TYPE == LUA_FLOAT_LONGDOUBLE
+#define LUAL_BUFFERSIZE		8192
+#else
+#define LUAL_BUFFERSIZE   ((int)(0x80 * sizeof(void*) * sizeof(lua_Integer)))
+#endif
+
+/* }================================================================== */
+
+
+/*
+@@ LUA_QL describes how error messages quote program elements.
+** Lua does not use these macros anymore; they are here for
+** compatibility only.
+*/
+#define LUA_QL(x)	"'" x "'"
+#define LUA_QS		LUA_QL("%s")
+
+
+
+
+/* =================================================================== */
+
+/*
+** Local configuration. You can use this space to add your redefinitions
+** without modifying the main part of the file.
+*/
+
+
+
+
+
+#endif
+

+ 61 - 0
vendor/lua/5.3/include/lualib.h

@@ -0,0 +1,61 @@
+/*
+** $Id: lualib.h,v 1.45.1.1 2017/04/19 17:20:42 roberto Exp $
+** Lua standard libraries
+** See Copyright Notice in lua.h
+*/
+
+
+#ifndef lualib_h
+#define lualib_h
+
+#include "lua.h"
+
+
+/* version suffix for environment variable names */
+#define LUA_VERSUFFIX          "_" LUA_VERSION_MAJOR "_" LUA_VERSION_MINOR
+
+
+LUAMOD_API int (luaopen_base) (lua_State *L);
+
+#define LUA_COLIBNAME	"coroutine"
+LUAMOD_API int (luaopen_coroutine) (lua_State *L);
+
+#define LUA_TABLIBNAME	"table"
+LUAMOD_API int (luaopen_table) (lua_State *L);
+
+#define LUA_IOLIBNAME	"io"
+LUAMOD_API int (luaopen_io) (lua_State *L);
+
+#define LUA_OSLIBNAME	"os"
+LUAMOD_API int (luaopen_os) (lua_State *L);
+
+#define LUA_STRLIBNAME	"string"
+LUAMOD_API int (luaopen_string) (lua_State *L);
+
+#define LUA_UTF8LIBNAME	"utf8"
+LUAMOD_API int (luaopen_utf8) (lua_State *L);
+
+#define LUA_BITLIBNAME	"bit32"
+LUAMOD_API int (luaopen_bit32) (lua_State *L);
+
+#define LUA_MATHLIBNAME	"math"
+LUAMOD_API int (luaopen_math) (lua_State *L);
+
+#define LUA_DBLIBNAME	"debug"
+LUAMOD_API int (luaopen_debug) (lua_State *L);
+
+#define LUA_LOADLIBNAME	"package"
+LUAMOD_API int (luaopen_package) (lua_State *L);
+
+
+/* open all previous libraries */
+LUALIB_API void (luaL_openlibs) (lua_State *L);
+
+
+
+#if !defined(lua_assert)
+#define lua_assert(x)	((void)0)
+#endif
+
+
+#endif

BIN
vendor/lua/5.3/linux/liblua53.a


BIN
vendor/lua/5.3/linux/liblua53.so


+ 759 - 0
vendor/lua/5.3/lua.odin

@@ -0,0 +1,759 @@
+package lua_5_3
+
+import "core:intrinsics"
+import "core:builtin"
+
+import c "core:c/libc"
+
+#assert(size_of(c.int) == size_of(b32))
+
+when ODIN_OS == .Windows {
+	foreign import lib "windows/lua53dll.lib"
+} else when ODIN_OS == .Linux {
+	foreign import lib "linux/liblua53.a"
+} else {
+	foreign import lib "system:liblua53.a"
+}
+
+VERSION_MAJOR       :: "5"
+VERSION_MINOR       :: "3"
+VERSION_NUM         :: 503
+VERSION_RELEASE     :: "6"
+
+VERSION             :: "Lua " + VERSION_MAJOR + "." + VERSION_MINOR
+RELEASE             :: VERSION + "." + VERSION_RELEASE
+COPYRIGHT           :: RELEASE + "  Copyright (C) 1994-2020 Lua.org, PUC-Rio"
+AUTHORS             :: "R. Ierusalimschy, L. H. de Figueiredo, W. Celes"
+
+
+/* mark for precompiled code ('<esc>Lua') */
+SIGNATURE :: "\x1bLua"
+
+/* option for multiple returns in 'lua_pcall' and 'lua_call' */
+MULTRET :: -1
+
+REGISTRYINDEX :: -MAXSTACK - 1000
+
+
+/*
+@@ LUAI_MAXSTACK limits the size of the Lua stack.
+** CHANGE it if you need a different limit. This limit is arbitrary;
+** its only purpose is to stop Lua from consuming unlimited stack
+** space (and to reserve some numbers for pseudo-indices).
+** (It must fit into max(size_t)/32.)
+*/
+MAXSTACK :: 1000000 when size_of(rawptr) == 4 else 15000
+
+
+/*
+@@ LUA_EXTRASPACE defines the size of a raw memory area associated with
+** a Lua state with very fast access.
+** CHANGE it if you need a different size.
+*/
+EXTRASPACE :: size_of(rawptr)
+
+
+
+/*
+@@ LUA_IDSIZE gives the maximum size for the description of the source
+@@ of a function in debug information.
+** CHANGE it if you want a different size.
+*/
+IDSIZE :: 60
+
+
+/*
+@@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system.
+*/
+L_BUFFERSIZE :: c.int(16 * size_of(rawptr) * size_of(Number))
+
+
+MAXALIGNVAL :: max(align_of(Number), align_of(f64), align_of(rawptr), align_of(Integer), align_of(c.long))
+
+
+Status :: enum c.int {
+	OK        = 0,
+	YIELD     = 1,
+	ERRRUN    = 2,
+	ERRSYNTAX = 3,
+	ERRMEM    = 4,
+	ERRERR    = 5,
+	ERRGCMM   = 6,
+	ERRFILE   = 7,
+}
+
+/* thread status */
+OK        :: Status.OK
+YIELD     :: Status.YIELD
+ERRRUN    :: Status.ERRRUN
+ERRSYNTAX :: Status.ERRSYNTAX
+ERRMEM    :: Status.ERRMEM
+ERRERR    :: Status.ERRERR
+ERRFILE   :: Status.ERRFILE
+
+/*
+** basic types
+*/
+
+
+Type :: enum c.int {
+	NONE          = -1,
+
+	NIL           = 0,
+	BOOLEAN       = 1,
+	LIGHTUSERDATA = 2,
+	NUMBER        = 3,
+	STRING        = 4,
+	TABLE         = 5,
+	FUNCTION      = 6,
+	USERDATA      = 7,
+	THREAD        = 8,
+}
+
+TNONE          :: Type.NONE
+TNIL           :: Type.NIL
+TBOOLEAN       :: Type.BOOLEAN
+TLIGHTUSERDATA :: Type.LIGHTUSERDATA
+TNUMBER        :: Type.NUMBER
+TSTRING        :: Type.STRING
+TTABLE         :: Type.TABLE
+TFUNCTION      :: Type.FUNCTION
+TUSERDATA      :: Type.USERDATA
+TTHREAD        :: Type.THREAD
+NUMTYPES :: 9
+
+
+
+ArithOp :: enum c.int {
+	ADD  = 0,	/* ORDER TM, ORDER OP */
+	SUB  = 1,
+	MUL  = 2,
+	MOD  = 3,
+	POW  = 4,
+	DIV  = 5,
+	IDIV = 6,
+	BAND = 7,
+	BOR  = 8,
+	BXOR = 9,
+	SHL  = 10,
+	SHR  = 11,
+	UNM  = 12,
+	BNOT = 13,
+}
+
+CompareOp :: enum c.int {
+	EQ = 0,
+	LT = 1,
+	LE = 2,
+}
+
+OPADD  :: ArithOp.ADD
+OPSUB  :: ArithOp.SUB
+OPMUL  :: ArithOp.MUL
+OPMOD  :: ArithOp.MOD
+OPPOW  :: ArithOp.POW
+OPDIV  :: ArithOp.DIV
+OPIDIV :: ArithOp.IDIV
+OPBAND :: ArithOp.BAND
+OPBOR  :: ArithOp.BOR
+OPBXOR :: ArithOp.BXOR
+OPSHL  :: ArithOp.SHL
+OPSHR  :: ArithOp.SHR
+OPUNM  :: ArithOp.UNM
+OPBNOT :: ArithOp.BNOT
+
+OPEQ :: CompareOp.EQ
+OPLT :: CompareOp.LT
+OPLE :: CompareOp.LE
+
+
+/* minimum Lua stack available to a C function */
+MINSTACK :: 20
+
+
+/* predefined values in the registry */
+RIDX_MAINTHREAD :: 1
+RIDX_GLOBALS    :: 2
+RIDX_LAST       :: RIDX_GLOBALS
+
+
+/* type of numbers in Lua */
+Number :: distinct (f32 when size_of(uintptr) == 4 else f64)
+
+
+/* type for integer functions */
+Integer :: distinct (i32 when size_of(uintptr) == 4 else i64)
+
+/* unsigned integer type */
+Unsigned :: distinct (u32 when size_of(uintptr) == 4 else u64)
+
+/* type for continuation-function contexts */
+KContext :: distinct int
+
+
+/*
+** Type for C functions registered with Lua
+*/
+CFunction :: #type proc "c" (L: ^State) -> c.int
+
+/*
+** Type for continuation functions
+*/
+KFunction :: #type proc "c" (L: ^State, status: c.int, ctx: KContext) -> c.int
+
+
+/*
+** Type for functions that read/write blocks when loading/dumping Lua chunks
+*/
+Reader :: #type proc "c" (L: ^State, ud: rawptr, sz: ^c.size_t) -> cstring
+Writer :: #type proc "c" (L: ^State, p: rawptr, sz: ^c.size_t, ud: rawptr) -> c.int
+
+
+/*
+** Type for memory-allocation functions
+*/
+Alloc :: #type proc "c" (ud: rawptr, ptr: rawptr, osize, nsize: c.size_t) -> rawptr
+
+
+GCWhat :: enum c.int {
+	STOP       = 0,
+	RESTART    = 1,
+	COLLECT    = 2,
+	COUNT      = 3,
+	COUNTB     = 4,
+	STEP       = 5,
+	SETPAUSE   = 6,
+	SETSTEPMUL = 7,
+	ISRUNNING  = 9,
+}
+GCSTOP       :: GCWhat.STOP
+GCRESTART    :: GCWhat.RESTART
+GCCOLLECT    :: GCWhat.COLLECT
+GCCOUNT      :: GCWhat.COUNT
+GCCOUNTB     :: GCWhat.COUNTB
+GCSTEP       :: GCWhat.STEP
+GCSETPAUSE   :: GCWhat.SETPAUSE
+GCSETSTEPMUL :: GCWhat.SETSTEPMUL
+GCISRUNNING  :: GCWhat.ISRUNNING
+
+
+
+/*
+** Event codes
+*/
+
+HookEvent :: enum c.int {
+	CALL     = 0,
+	RET      = 1,
+	LINE     = 2,
+	COUNT    = 3,
+	TAILCALL = 4,
+}
+HOOKCALL     :: HookEvent.CALL
+HOOKRET      :: HookEvent.RET
+HOOKLINE     :: HookEvent.LINE
+HOOKCOUNT    :: HookEvent.COUNT
+HOOKTAILCALL :: HookEvent.TAILCALL
+
+
+/*
+** Event masks
+*/
+HookMask :: distinct bit_set[HookEvent; c.int]
+MASKCALL  :: HookMask{.CALL}
+MASKRET   :: HookMask{.RET}
+MASKLINE  :: HookMask{.LINE}
+MASKCOUNT :: HookMask{.COUNT}
+
+/* activation record */
+Debug :: struct {
+	event:           HookEvent,
+	name:            cstring,                  /* (n) */
+	namewhat:        cstring,                  /* (n) 'global', 'local', 'field', 'method' */
+	what:            cstring,                  /* (S) 'Lua', 'C', 'main', 'tail' */
+	source:          cstring,                  /* (S) */
+	currentline:     c.int,                    /* (l) */
+	linedefined:     c.int,                    /* (S) */
+	lastlinedefined: c.int,                    /* (S) */
+	nups:            u8,                       /* (u) number of upvalues */
+	nparams:         u8,                       /* (u) number of parameters */
+	isvararg:        bool,                     /* (u) */
+	istailcall:      bool,                     /* (t) */
+	short_src:       [IDSIZE]u8 `fmt:"s"`, /* (S) */
+	/* private part */
+	i_ci:            rawptr,                   /* active function */
+}
+
+
+/* Functions to be called by the debugger in specific events */
+Hook :: #type proc "c" (L: ^State, ar: ^Debug)
+
+
+State :: struct {} // opaque data type
+
+
+@(link_prefix="lua_")
+@(default_calling_convention="c")
+foreign lib {
+	/*
+	** RCS ident string
+	*/
+
+	ident: [^]u8 // TODO(bill): is this correct?
+
+
+	/*
+	** state manipulation
+	*/
+
+	newstate  :: proc(f: Alloc, ud: rawptr) -> ^State ---
+	close     :: proc(L: ^State) ---
+	newthread :: proc(L: ^State) -> ^State ---
+
+	atpanic :: proc(L: ^State, panicf: CFunction) -> CFunction ---
+
+	version :: proc(L: ^State) -> ^Number ---
+
+
+	/*
+	** basic stack manipulation
+	*/
+
+	absindex   :: proc (L: ^State, idx: c.int) -> c.int ---
+	gettop     :: proc (L: ^State) -> c.int ---
+	settop     :: proc (L: ^State, idx: c.int) ---
+	pushvalue  :: proc (L: ^State, idx: c.int) ---
+	rotate     :: proc (L: ^State, idx: c.int, n: c.int) ---
+	copy       :: proc (L: ^State, fromidx, toidx: c.int) ---
+	checkstack :: proc (L: ^State, n: c.int) -> c.int ---
+
+	xmove :: proc(from, to: ^State, n: c.int) ---
+
+
+	/*
+	** access functions (stack -> C)
+	*/
+
+	isnumber    :: proc(L: ^State, idx: c.int) -> b32 ---
+	isstring    :: proc(L: ^State, idx: c.int) -> b32 ---
+	iscfunction :: proc(L: ^State, idx: c.int) -> b32 ---
+	isinteger   :: proc(L: ^State, idx: c.int) -> b32 ---
+	isuserdata  :: proc(L: ^State, idx: c.int) -> b32 ---
+	type        :: proc(L: ^State, idx: c.int) -> Type ---
+	typename    :: proc(L: ^State, tp: Type) -> cstring ---
+
+	@(link_name="lua_tonumberx")
+	tonumber    :: proc(L: ^State, idx: c.int, isnum: ^b32 = nil) -> Number ---
+	@(link_name="lua_tointegerx")
+	tointeger   :: proc(L: ^State, idx: c.int, isnum: ^b32 = nil) -> Integer ---
+	toboolean   :: proc(L: ^State, idx: c.int) -> b32 ---
+	tolstring   :: proc(L: ^State, idx: c.int, len: ^c.size_t) -> cstring ---
+	rawlen      :: proc(L: ^State, idx: c.int) -> c.size_t ---
+	tocfunction :: proc(L: ^State, idx: c.int) -> CFunction ---
+	touserdata  :: proc(L: ^State, idx: c.int) -> rawptr ---
+	tothread    :: proc(L: ^State, idx: c.int) -> ^State ---
+	topointer   :: proc(L: ^State, idx: c.int) -> rawptr ---
+
+	/*
+	** Comparison and arithmetic functions
+	*/
+
+	arith    :: proc(L: ^State, op: ArithOp) ---
+	rawequal :: proc(L: ^State, idx1, idx2: c.int) -> b32 ---
+	compare  :: proc(L: ^State, idx1, idx2: c.int, op: CompareOp) -> b32 ---
+
+	/*
+	** push functions (C -> stack)
+	*/
+
+	pushnil      :: proc(L: ^State) ---
+	pushnumber   :: proc(L: ^State, n: Number) ---
+	pushinteger  :: proc(L: ^State, n: Integer) ---
+	pushlstring  :: proc(L: ^State, s: cstring, len: c.size_t) -> cstring ---
+	pushstring   :: proc(L: ^State, s: cstring) -> cstring ---
+	pushvfstring :: proc(L: ^State, fmt: cstring, argp: c.va_list) -> cstring ---
+	pushfstring       :: proc(L: ^State, fmt: cstring, #c_vararg args: ..any) -> cstring ---
+	pushcclosure      :: proc(L: ^State, fn: CFunction, n: c.int) ---
+	pushboolean       :: proc(L: ^State, b: b32) ---
+	pushlightuserdata :: proc(L: ^State, p: rawptr) ---
+	pushthread        :: proc(L: ^State) -> Status ---
+
+	/*
+	** get functions (Lua -> stack)
+	*/
+
+	getglobal :: proc(L: ^State, name: cstring) -> c.int ---
+	gettable  :: proc(L: ^State, idx: c.int) -> c.int ---
+	getfield  :: proc(L: ^State, idx: c.int, k: cstring) -> c.int ---
+	geti      :: proc(L: ^State, idx: c.int, n: Integer) -> c.int ---
+	rawget    :: proc(L: ^State, idx: c.int) -> c.int ---
+	rawgeti   :: proc(L: ^State, idx: c.int, n: Integer) -> c.int ---
+	rawgetp   :: proc(L: ^State, idx: c.int, p: rawptr) -> c.int ---
+
+	createtable  :: proc(L: ^State, narr, nrec: c.int) ---
+	newuserdata  :: proc(L: ^State, sz: c.size_t) -> rawptr ---
+	getmetatable :: proc(L: ^State, objindex: c.int) -> c.int ---
+	getuservalue :: proc(L: ^State, idx: c.int) -> c.int ---
+
+
+	/*
+	** set functions (stack -> Lua)
+	*/
+
+	setglobal    :: proc(L: ^State, name: cstring) ---
+	settable     :: proc(L: ^State, idx: c.int) ---
+	setfield     :: proc(L: ^State, idx: c.int, k: cstring) ---
+	seti         :: proc(L: ^State, idx: c.int, n: Integer) ---
+	rawset       :: proc(L: ^State, idx: c.int) ---
+	rawseti      :: proc(L: ^State, idx: c.int, n: Integer) ---
+	rawsetp      :: proc(L: ^State, idx: c.int, p: rawptr) ---
+	setmetatable :: proc(L: ^State, objindex: c.int) -> c.int ---
+	setuservalue :: proc(L: ^State, idx: c.int) -> c.int ---
+
+
+	/*
+	** 'load' and 'call' functions (load and run Lua code)
+	*/
+
+	@(link_name="lua_callk")
+	call :: proc(L: ^State, nargs, nresults: c.int,
+	             ctx: KContext = 0, k: KFunction = nil) ---
+
+	@(link_name="lua_pcallk")
+	pcall :: proc(L: ^State, nargs, nresults: c.int, errfunc: c.int,
+	              ctx: KContext = 0, k: KFunction = nil) -> c.int ---
+
+	load :: proc(L: ^State, reader: Reader, dt: rawptr,
+	             chunkname, mode: cstring) -> Status ---
+
+	dump :: proc(L: ^State, writer: Writer, data: rawptr, strip: b32) -> Status ---
+
+
+	/*
+	** coroutine functions
+	*/
+
+	@(link_name="lua_yieldk")
+	yield       :: proc(L: ^State, nresults: c.int, ctx: KContext = 0, k: KFunction = nil) -> Status ---
+	resume      :: proc(L: ^State, from: ^State, narg: c.int) -> Status ---
+	status      :: proc(L: ^State) -> Status ---
+	isyieldable :: proc(L: ^State) -> b32 ---
+
+
+	/*
+	** garbage-collection function and options
+	*/
+
+
+
+	gc :: proc(L: ^State, what: GCWhat, data: c.int) -> c.int ---
+
+
+	/*
+	** miscellaneous functions
+	*/
+
+	error :: proc(L: ^State) -> Status ---
+
+	next :: proc(L: ^State, idx: c.int) -> c.int ---
+
+	concat :: proc(L: ^State, n: c.int) ---
+	len    :: proc(L: ^State, idx: c.int) ---
+
+	stringtonumber :: proc(L: ^State, s: cstring) -> c.size_t ---
+
+	getallocf :: proc(L: State, ud: ^rawptr) -> Alloc ---
+	setallocf :: proc(L: ^State, f: Alloc, ud: rawptr) ---
+
+	/*
+	** {======================================================================
+	** Debug API
+	** =======================================================================
+	*/
+
+	getstack   :: proc(L: ^State, level: c.int, ar: ^Debug) -> c.int ---
+	getinfo    :: proc(L: ^State, what: cstring, ar: ^Debug) -> c.int ---
+	getlocal   :: proc(L: ^State, ar: ^Debug, n: c.int) -> cstring ---
+	setlocal   :: proc(L: ^State, ar: ^Debug, n: c.int) -> cstring ---
+	getupvalue :: proc(L: ^State, funcindex: c.int, n: c.int) -> cstring ---
+	setupvalue :: proc(L: ^State, funcindex: c.int, n: c.int) -> cstring ---
+
+	upvalueid   :: proc(L: ^State, fidx, n: c.int) -> rawptr ---
+	upvaluejoin :: proc(L: ^State, fidx1, n1, fidx2, n2: c.int) ---
+
+	sethook :: proc(L: ^State, func: Hook, mask: HookMask, count: c.int) ---
+	gethook :: proc(L: ^State) -> Hook ---
+	gethookmask  :: proc(L: ^State) -> HookMask ---
+	gethookcount :: proc(L: ^State) -> c.int ---
+
+	/* }============================================================== */
+}
+
+
+
+/* version suffix for environment variable names */
+VERSUFFIX :: "_" + VERSION_MAJOR + "_" + VERSION_MINOR
+
+COLIBNAME   :: "coroutine"
+TABLIBNAME  :: "table"
+IOLIBNAME   :: "io"
+OSLIBNAME   :: "os"
+STRLIBNAME  :: "string"
+UTF8LIBNAME :: "utf8"
+BITLIBNAME  :: "bit32"
+MATHLIBNAME :: "math"
+DBLIBNAME   :: "debug"
+LOADLIBNAME :: "package"
+
+@(link_prefix="lua")
+@(default_calling_convention="c")
+foreign lib {
+	open_base      :: proc(L: ^State) -> c.int ---
+	open_coroutine :: proc(L: ^State) -> c.int ---
+	open_table     :: proc(L: ^State) -> c.int ---
+	open_io        :: proc(L: ^State) -> c.int ---
+	open_os        :: proc(L: ^State) -> c.int ---
+	open_string    :: proc(L: ^State) -> c.int ---
+	open_utf8      :: proc(L: ^State) -> c.int ---
+	open_bit32     :: proc(L: ^State) -> c.int ---
+	open_math      :: proc(L: ^State) -> c.int ---
+	open_debug     :: proc(L: ^State) -> c.int ---
+	open_package   :: proc(L: ^State) -> c.int ---
+
+	/* open all previous libraries */
+
+	L_openlibs :: proc(L: ^State) ---
+}
+
+
+
+GNAME :: "_G"
+
+/* key, in the registry, for table of loaded modules */
+LOADED_TABLE :: "_LOADED"
+
+
+/* key, in the registry, for table of preloaded loaders */
+PRELOAD_TABLE :: "_PRELOAD"
+
+L_Reg :: struct {
+	name: cstring,
+  	func: CFunction,
+}
+
+L_NUMSIZES :: size_of(Integer)*16 + size_of(Number)
+
+
+/* predefined references */
+NOREF  :: -2
+REFNIL :: -1
+
+
+@(link_prefix="lua")
+@(default_calling_convention="c")
+foreign lib {
+	@(link_name="luaL_checkversion_")
+	L_checkversion :: proc(L: ^State, ver: Number = VERSION_NUM, sz: c.size_t = L_NUMSIZES) ---
+
+
+	L_getmetafield :: proc(L: ^State, obj: c.int, e: cstring) -> c.int ---
+	L_callmeta     :: proc(L: ^State, obj: c.int, e: cstring) -> c.int ---
+	@(link_name="luaL_tolstring")
+	L_tostring     :: proc(L: ^State, idx: c.int, len: ^c.size_t = nil) -> cstring ---
+	L_argerror     :: proc(L: ^State, arg: c.int, extramsg: cstring) -> c.int ---
+	@(link_name="luaL_checklstring")
+	L_checkstring  :: proc(L: ^State, arg: c.int, l: ^c.size_t = nil) -> cstring ---
+	@(link_name="luaL_optlstring")
+	L_optstring    :: proc(L: ^State, arg: c.int, def: cstring, l: ^c.size_t = nil) -> cstring ---
+	L_checknumber  :: proc(L: ^State, arg: c.int) -> Number ---
+	L_optnumber    :: proc(L: ^State, arg: c.int, def: Number) -> Number ---
+
+	L_checkinteger :: proc(L: ^State, arg: c.int) -> Integer ---
+	L_optinteger   :: proc(L: ^State, arg: c.int, def: Integer) -> Integer ---
+
+	L_checkstack :: proc(L: ^State, sz: c.int, msg: cstring) ---
+	L_checktype  :: proc(L: ^State, arg: c.int, t: c.int) ---
+	L_checkany   :: proc(L: ^State, arg: c.int) ---
+
+	L_newmetatable :: proc(L: ^State, tname: cstring) -> c.int ---
+	L_setmetatable :: proc(L: ^State, tname: cstring) ---
+	L_testudata    :: proc(L: ^State, ud: c.int, tname: cstring) -> rawptr ---
+	L_checkudata   :: proc(L: ^State, ud: c.int, tname: cstring) -> rawptr ---
+
+	L_where :: proc(L: ^State, lvl: c.int) ---
+	L_error :: proc(L: ^State, fmt: cstring, #c_vararg args: ..any) -> Status ---
+
+	L_checkoption :: proc(L: ^State, arg: c.int, def: cstring, lst: [^]cstring) -> c.int ---
+
+	L_fileresult :: proc(L: ^State, stat: c.int, fname: cstring) -> c.int ---
+	L_execresult :: proc(L: ^State, stat: c.int) -> c.int ---
+
+
+	L_ref   :: proc(L: ^State, t: c.int) -> c.int ---
+	L_unref :: proc(L: ^State, t: c.int, ref: c.int) ---
+
+	@(link_name="luaL_loadfilex")
+	L_loadfile :: proc (L: ^State, filename: cstring, mode: cstring = nil) -> Status ---
+
+	@(link_name="luaL_loadbufferx")
+	L_loadbuffer :: proc(L: ^State, buff: [^]byte, sz: c.size_t, name: cstring, mode: cstring = nil) -> Status ---
+	L_loadstring  :: proc(L: ^State, s: cstring) -> Status ---
+
+	L_newstate :: proc() -> ^State ---
+
+	L_len :: proc(L: ^State, idx: c.int) -> Integer ---
+
+	L_gsub :: proc(L: ^State, s, p, r: cstring) -> cstring ---
+
+	L_setfuncs :: proc(L: ^State, l: [^]L_Reg, nup: c.int) ---
+
+	L_getsubtable :: proc(L: ^State, idx: c.int, fname: cstring) -> c.int ---
+
+	L_traceback   :: proc(L: ^State, L1: ^State, msg: cstring, level: c.int) ---
+
+	L_requiref    :: proc(L: ^State, modname: cstring, openf: CFunction, glb: c.int) ---
+
+}
+/*
+** {======================================================
+** Generic Buffer manipulation
+** =======================================================
+*/
+
+
+L_Buffer :: struct {
+	b:    [^]byte,  /* buffer address */
+	size: c.size_t, /* buffer size */
+	n:    c.size_t, /* number of characters in buffer */
+	L:    ^State,
+	initb: [L_BUFFERSIZE]byte,  /* initial buffer */
+}
+
+L_addchar :: #force_inline proc "c" (B: ^L_Buffer, c: byte) {
+	if B.n < B.size {
+		L_prepbuffsize(B, 1)
+	}
+	B.b[B.n] = c
+	B.n += 1
+}
+
+L_addsize :: #force_inline proc "c" (B: ^L_Buffer, s: c.size_t) -> c.size_t {
+	B.n += s
+	return B.n
+}
+
+L_prepbuffer :: #force_inline proc "c" (B: ^L_Buffer) -> [^]byte {
+	return L_prepbuffsize(B, c.size_t(L_BUFFERSIZE))
+}
+
+
+@(link_prefix="lua")
+@(default_calling_convention="c")
+foreign lib {
+	L_buffinit       :: proc(L: ^State, B: ^L_Buffer) ---
+	L_prepbuffsize   :: proc(B: ^L_Buffer, sz: c.size_t) -> [^]byte ---
+	L_addlstring     :: proc(B: ^L_Buffer, s: cstring, l: c.size_t) ---
+	L_addstring      :: proc(B: ^L_Buffer, s: cstring) ---
+	L_addvalue       :: proc(B: ^L_Buffer) ---
+	L_pushresult     :: proc(B: ^L_Buffer) ---
+	L_pushresultsize :: proc(B: ^L_Buffer, sz: c.size_t) ---
+	L_buffinitsize   :: proc(L: ^State, B: ^L_Buffer, sz: c.size_t) -> [^]byte ---
+}
+
+
+/* }====================================================== */
+
+
+
+
+/*
+** {==============================================================
+** some useful macros
+** ===============================================================
+*/
+
+getextraspace :: #force_inline proc "c" (L: ^State) -> rawptr {
+	return rawptr(([^]byte)(L)[-EXTRASPACE:])
+}
+pop :: #force_inline proc "c" (L: ^State, n: c.int) {
+	settop(L, -n-1)
+}
+newtable :: #force_inline proc "c" (L: ^State) {
+	createtable(L, 0, 0)
+}
+register :: #force_inline proc "c" (L: ^State, n: cstring, f: CFunction) {
+	pushcfunction(L, f)
+	setglobal(L, n)
+}
+
+pushcfunction :: #force_inline proc "c" (L: ^State, f: CFunction) {
+	pushcclosure(L, f, 0)
+}
+
+
+isfunction      :: #force_inline proc "c" (L: ^State, n: c.int) -> bool { return type(L, n) == .FUNCTION      }
+istable         :: #force_inline proc "c" (L: ^State, n: c.int) -> bool { return type(L, n) == .TABLE         }
+islightuserdata :: #force_inline proc "c" (L: ^State, n: c.int) -> bool { return type(L, n) == .LIGHTUSERDATA }
+isnil           :: #force_inline proc "c" (L: ^State, n: c.int) -> bool { return type(L, n) == .NIL           }
+isboolean       :: #force_inline proc "c" (L: ^State, n: c.int) -> bool { return type(L, n) == .BOOLEAN       }
+isthread        :: #force_inline proc "c" (L: ^State, n: c.int) -> bool { return type(L, n) == .THREAD        }
+isnone          :: #force_inline proc "c" (L: ^State, n: c.int) -> bool { return type(L, n) == .NONE          }
+isnoneornil     :: #force_inline proc "c" (L: ^State, n: c.int) -> bool { return type(L, n) <= .NIL           }
+
+
+pushliteral :: pushstring
+pushglobaltable :: #force_inline proc "c" (L: ^State) {
+	rawgeti(L, REGISTRYINDEX, RIDX_GLOBALS)
+}
+tostring :: #force_inline proc "c" (L: ^State, i: c.int) -> cstring {
+	return tolstring(L, i, nil)
+}
+insert :: #force_inline proc "c" (L: ^State, idx: c.int) {
+	rotate(L, idx, 1)
+}
+remove :: #force_inline proc "c" (L: ^State, idx: c.int) {
+	rotate(L, idx, -1)
+	pop(L, 1)
+}
+replace :: #force_inline proc "c" (L: ^State, idx: c.int) {
+	copy(L, -1, idx)
+	pop(L, 1)
+}
+
+L_newlibtable :: #force_inline proc "c" (L: ^State, l: []L_Reg) {
+	createtable(L, 0, c.int(builtin.len(l) - 1))
+}
+
+L_newlib :: proc(L: ^State, l: []L_Reg) {
+	L_checkversion(L)
+	L_newlibtable(L, l)
+	L_setfuncs(L, raw_data(l), 0)
+}
+
+L_argcheck :: #force_inline proc "c" (L: ^State, cond: bool, arg: c.int, extramsg: cstring) {
+	if cond {
+		L_argerror(L, arg, extramsg)
+	}
+}
+
+L_typename :: #force_inline proc "c" (L: ^State, i: c.int) -> cstring {
+	return typename(L, type(L, i))
+}
+L_dofile :: #force_inline proc "c" (L: ^State, s: cstring) -> c.int {
+	err := L_loadfile(L, s)
+	return pcall(L, 0, MULTRET, 0) if err == nil else c.int(err)
+}
+L_dostring :: #force_inline proc "c" (L: ^State, s: cstring) -> c.int {
+	err := L_loadstring(L, s)
+	return pcall(L, 0, MULTRET, 0) if err == nil else c.int(err)
+}
+L_getmetatable :: #force_inline proc "c" (L: ^State, n: cstring) -> c.int {
+	return getfield(L, REGISTRYINDEX, n)
+}
+L_opt :: #force_inline proc "c" (L: ^State, f: $F, n: c.int, d: $T) -> T where intrinsics.type_is_proc(F) {
+	return d if isnoneornil(L, n) else f(L, n)
+}
+
+
+
+/* }============================================================== */

BIN
vendor/lua/5.3/windows/lua53.dll


BIN
vendor/lua/5.3/windows/lua53dll.lib


+ 276 - 0
vendor/lua/5.4/include/lauxlib.h

@@ -0,0 +1,276 @@
+/*
+** $Id: lauxlib.h $
+** Auxiliary functions for building Lua libraries
+** See Copyright Notice in lua.h
+*/
+
+
+#ifndef lauxlib_h
+#define lauxlib_h
+
+
+#include <stddef.h>
+#include <stdio.h>
+
+#include "lua.h"
+
+
+/* global table */
+#define LUA_GNAME	"_G"
+
+
+typedef struct luaL_Buffer luaL_Buffer;
+
+
+/* extra error code for 'luaL_loadfilex' */
+#define LUA_ERRFILE     (LUA_ERRERR+1)
+
+
+/* key, in the registry, for table of loaded modules */
+#define LUA_LOADED_TABLE	"_LOADED"
+
+
+/* key, in the registry, for table of preloaded loaders */
+#define LUA_PRELOAD_TABLE	"_PRELOAD"
+
+
+typedef struct luaL_Reg {
+  const char *name;
+  lua_CFunction func;
+} luaL_Reg;
+
+
+#define LUAL_NUMSIZES	(sizeof(lua_Integer)*16 + sizeof(lua_Number))
+
+LUALIB_API void (luaL_checkversion_) (lua_State *L, lua_Number ver, size_t sz);
+#define luaL_checkversion(L)  \
+	  luaL_checkversion_(L, LUA_VERSION_NUM, LUAL_NUMSIZES)
+
+LUALIB_API int (luaL_getmetafield) (lua_State *L, int obj, const char *e);
+LUALIB_API int (luaL_callmeta) (lua_State *L, int obj, const char *e);
+LUALIB_API const char *(luaL_tolstring) (lua_State *L, int idx, size_t *len);
+LUALIB_API int (luaL_argerror) (lua_State *L, int arg, const char *extramsg);
+LUALIB_API int (luaL_typeerror) (lua_State *L, int arg, const char *tname);
+LUALIB_API const char *(luaL_checklstring) (lua_State *L, int arg,
+                                                          size_t *l);
+LUALIB_API const char *(luaL_optlstring) (lua_State *L, int arg,
+                                          const char *def, size_t *l);
+LUALIB_API lua_Number (luaL_checknumber) (lua_State *L, int arg);
+LUALIB_API lua_Number (luaL_optnumber) (lua_State *L, int arg, lua_Number def);
+
+LUALIB_API lua_Integer (luaL_checkinteger) (lua_State *L, int arg);
+LUALIB_API lua_Integer (luaL_optinteger) (lua_State *L, int arg,
+                                          lua_Integer def);
+
+LUALIB_API void (luaL_checkstack) (lua_State *L, int sz, const char *msg);
+LUALIB_API void (luaL_checktype) (lua_State *L, int arg, int t);
+LUALIB_API void (luaL_checkany) (lua_State *L, int arg);
+
+LUALIB_API int   (luaL_newmetatable) (lua_State *L, const char *tname);
+LUALIB_API void  (luaL_setmetatable) (lua_State *L, const char *tname);
+LUALIB_API void *(luaL_testudata) (lua_State *L, int ud, const char *tname);
+LUALIB_API void *(luaL_checkudata) (lua_State *L, int ud, const char *tname);
+
+LUALIB_API void (luaL_where) (lua_State *L, int lvl);
+LUALIB_API int (luaL_error) (lua_State *L, const char *fmt, ...);
+
+LUALIB_API int (luaL_checkoption) (lua_State *L, int arg, const char *def,
+                                   const char *const lst[]);
+
+LUALIB_API int (luaL_fileresult) (lua_State *L, int stat, const char *fname);
+LUALIB_API int (luaL_execresult) (lua_State *L, int stat);
+
+
+/* predefined references */
+#define LUA_NOREF       (-2)
+#define LUA_REFNIL      (-1)
+
+LUALIB_API int (luaL_ref) (lua_State *L, int t);
+LUALIB_API void (luaL_unref) (lua_State *L, int t, int ref);
+
+LUALIB_API int (luaL_loadfilex) (lua_State *L, const char *filename,
+                                               const char *mode);
+
+#define luaL_loadfile(L,f)	luaL_loadfilex(L,f,NULL)
+
+LUALIB_API int (luaL_loadbufferx) (lua_State *L, const char *buff, size_t sz,
+                                   const char *name, const char *mode);
+LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s);
+
+LUALIB_API lua_State *(luaL_newstate) (void);
+
+LUALIB_API lua_Integer (luaL_len) (lua_State *L, int idx);
+
+LUALIB_API void luaL_addgsub (luaL_Buffer *b, const char *s,
+                                     const char *p, const char *r);
+LUALIB_API const char *(luaL_gsub) (lua_State *L, const char *s,
+                                    const char *p, const char *r);
+
+LUALIB_API void (luaL_setfuncs) (lua_State *L, const luaL_Reg *l, int nup);
+
+LUALIB_API int (luaL_getsubtable) (lua_State *L, int idx, const char *fname);
+
+LUALIB_API void (luaL_traceback) (lua_State *L, lua_State *L1,
+                                  const char *msg, int level);
+
+LUALIB_API void (luaL_requiref) (lua_State *L, const char *modname,
+                                 lua_CFunction openf, int glb);
+
+/*
+** ===============================================================
+** some useful macros
+** ===============================================================
+*/
+
+
+#define luaL_newlibtable(L,l)	\
+  lua_createtable(L, 0, sizeof(l)/sizeof((l)[0]) - 1)
+
+#define luaL_newlib(L,l)  \
+  (luaL_checkversion(L), luaL_newlibtable(L,l), luaL_setfuncs(L,l,0))
+
+#define luaL_argcheck(L, cond,arg,extramsg)	\
+		((void)((cond) || luaL_argerror(L, (arg), (extramsg))))
+
+#define luaL_argexpected(L,cond,arg,tname)	\
+		((void)((cond) || luaL_typeerror(L, (arg), (tname))))
+
+#define luaL_checkstring(L,n)	(luaL_checklstring(L, (n), NULL))
+#define luaL_optstring(L,n,d)	(luaL_optlstring(L, (n), (d), NULL))
+
+#define luaL_typename(L,i)	lua_typename(L, lua_type(L,(i)))
+
+#define luaL_dofile(L, fn) \
+	(luaL_loadfile(L, fn) || lua_pcall(L, 0, LUA_MULTRET, 0))
+
+#define luaL_dostring(L, s) \
+	(luaL_loadstring(L, s) || lua_pcall(L, 0, LUA_MULTRET, 0))
+
+#define luaL_getmetatable(L,n)	(lua_getfield(L, LUA_REGISTRYINDEX, (n)))
+
+#define luaL_opt(L,f,n,d)	(lua_isnoneornil(L,(n)) ? (d) : f(L,(n)))
+
+#define luaL_loadbuffer(L,s,sz,n)	luaL_loadbufferx(L,s,sz,n,NULL)
+
+
+/* push the value used to represent failure/error */
+#define luaL_pushfail(L)	lua_pushnil(L)
+
+
+/*
+** {======================================================
+** Generic Buffer manipulation
+** =======================================================
+*/
+
+struct luaL_Buffer {
+  char *b;  /* buffer address */
+  size_t size;  /* buffer size */
+  size_t n;  /* number of characters in buffer */
+  lua_State *L;
+  union {
+    LUAI_MAXALIGN;  /* ensure maximum alignment for buffer */
+    char b[LUAL_BUFFERSIZE];  /* initial buffer */
+  } init;
+};
+
+
+#define luaL_bufflen(bf)	((bf)->n)
+#define luaL_buffaddr(bf)	((bf)->b)
+
+
+#define luaL_addchar(B,c) \
+  ((void)((B)->n < (B)->size || luaL_prepbuffsize((B), 1)), \
+   ((B)->b[(B)->n++] = (c)))
+
+#define luaL_addsize(B,s)	((B)->n += (s))
+
+#define luaL_buffsub(B,s)	((B)->n -= (s))
+
+LUALIB_API void (luaL_buffinit) (lua_State *L, luaL_Buffer *B);
+LUALIB_API char *(luaL_prepbuffsize) (luaL_Buffer *B, size_t sz);
+LUALIB_API void (luaL_addlstring) (luaL_Buffer *B, const char *s, size_t l);
+LUALIB_API void (luaL_addstring) (luaL_Buffer *B, const char *s);
+LUALIB_API void (luaL_addvalue) (luaL_Buffer *B);
+LUALIB_API void (luaL_pushresult) (luaL_Buffer *B);
+LUALIB_API void (luaL_pushresultsize) (luaL_Buffer *B, size_t sz);
+LUALIB_API char *(luaL_buffinitsize) (lua_State *L, luaL_Buffer *B, size_t sz);
+
+#define luaL_prepbuffer(B)	luaL_prepbuffsize(B, LUAL_BUFFERSIZE)
+
+/* }====================================================== */
+
+
+
+/*
+** {======================================================
+** File handles for IO library
+** =======================================================
+*/
+
+/*
+** A file handle is a userdata with metatable 'LUA_FILEHANDLE' and
+** initial structure 'luaL_Stream' (it may contain other fields
+** after that initial structure).
+*/
+
+#define LUA_FILEHANDLE          "FILE*"
+
+
+typedef struct luaL_Stream {
+  FILE *f;  /* stream (NULL for incompletely created streams) */
+  lua_CFunction closef;  /* to close stream (NULL for closed streams) */
+} luaL_Stream;
+
+/* }====================================================== */
+
+/*
+** {==================================================================
+** "Abstraction Layer" for basic report of messages and errors
+** ===================================================================
+*/
+
+/* print a string */
+#if !defined(lua_writestring)
+#define lua_writestring(s,l)   fwrite((s), sizeof(char), (l), stdout)
+#endif
+
+/* print a newline and flush the output */
+#if !defined(lua_writeline)
+#define lua_writeline()        (lua_writestring("\n", 1), fflush(stdout))
+#endif
+
+/* print an error message */
+#if !defined(lua_writestringerror)
+#define lua_writestringerror(s,p) \
+        (fprintf(stderr, (s), (p)), fflush(stderr))
+#endif
+
+/* }================================================================== */
+
+
+/*
+** {============================================================
+** Compatibility with deprecated conversions
+** =============================================================
+*/
+#if defined(LUA_COMPAT_APIINTCASTS)
+
+#define luaL_checkunsigned(L,a)	((lua_Unsigned)luaL_checkinteger(L,a))
+#define luaL_optunsigned(L,a,d)	\
+	((lua_Unsigned)luaL_optinteger(L,a,(lua_Integer)(d)))
+
+#define luaL_checkint(L,n)	((int)luaL_checkinteger(L, (n)))
+#define luaL_optint(L,n,d)	((int)luaL_optinteger(L, (n), (d)))
+
+#define luaL_checklong(L,n)	((long)luaL_checkinteger(L, (n)))
+#define luaL_optlong(L,n,d)	((long)luaL_optinteger(L, (n), (d)))
+
+#endif
+/* }============================================================ */
+
+
+
+#endif
+
+

+ 517 - 0
vendor/lua/5.4/include/lua.h

@@ -0,0 +1,517 @@
+/*
+** $Id: lua.h $
+** Lua - A Scripting Language
+** Lua.org, PUC-Rio, Brazil (http://www.lua.org)
+** See Copyright Notice at the end of this file
+*/
+
+
+#ifndef lua_h
+#define lua_h
+
+#include <stdarg.h>
+#include <stddef.h>
+
+
+#include "luaconf.h"
+
+
+#define LUA_VERSION_MAJOR	"5"
+#define LUA_VERSION_MINOR	"4"
+#define LUA_VERSION_RELEASE	"2"
+
+#define LUA_VERSION_NUM			504
+#define LUA_VERSION_RELEASE_NUM		(LUA_VERSION_NUM * 100 + 0)
+
+#define LUA_VERSION	"Lua " LUA_VERSION_MAJOR "." LUA_VERSION_MINOR
+#define LUA_RELEASE	LUA_VERSION "." LUA_VERSION_RELEASE
+#define LUA_COPYRIGHT	LUA_RELEASE "  Copyright (C) 1994-2020 Lua.org, PUC-Rio"
+#define LUA_AUTHORS	"R. Ierusalimschy, L. H. de Figueiredo, W. Celes"
+
+
+/* mark for precompiled code ('<esc>Lua') */
+#define LUA_SIGNATURE	"\x1bLua"
+
+/* option for multiple returns in 'lua_pcall' and 'lua_call' */
+#define LUA_MULTRET	(-1)
+
+
+/*
+** Pseudo-indices
+** (-LUAI_MAXSTACK is the minimum valid index; we keep some free empty
+** space after that to help overflow detection)
+*/
+#define LUA_REGISTRYINDEX	(-LUAI_MAXSTACK - 1000)
+#define lua_upvalueindex(i)	(LUA_REGISTRYINDEX - (i))
+
+
+/* thread status */
+#define LUA_OK		0
+#define LUA_YIELD	1
+#define LUA_ERRRUN	2
+#define LUA_ERRSYNTAX	3
+#define LUA_ERRMEM	4
+#define LUA_ERRERR	5
+
+
+typedef struct lua_State lua_State;
+
+
+/*
+** basic types
+*/
+#define LUA_TNONE		(-1)
+
+#define LUA_TNIL		0
+#define LUA_TBOOLEAN		1
+#define LUA_TLIGHTUSERDATA	2
+#define LUA_TNUMBER		3
+#define LUA_TSTRING		4
+#define LUA_TTABLE		5
+#define LUA_TFUNCTION		6
+#define LUA_TUSERDATA		7
+#define LUA_TTHREAD		8
+
+#define LUA_NUMTYPES		9
+
+
+
+/* minimum Lua stack available to a C function */
+#define LUA_MINSTACK	20
+
+
+/* predefined values in the registry */
+#define LUA_RIDX_MAINTHREAD	1
+#define LUA_RIDX_GLOBALS	2
+#define LUA_RIDX_LAST		LUA_RIDX_GLOBALS
+
+
+/* type of numbers in Lua */
+typedef LUA_NUMBER lua_Number;
+
+
+/* type for integer functions */
+typedef LUA_INTEGER lua_Integer;
+
+/* unsigned integer type */
+typedef LUA_UNSIGNED lua_Unsigned;
+
+/* type for continuation-function contexts */
+typedef LUA_KCONTEXT lua_KContext;
+
+
+/*
+** Type for C functions registered with Lua
+*/
+typedef int (*lua_CFunction) (lua_State *L);
+
+/*
+** Type for continuation functions
+*/
+typedef int (*lua_KFunction) (lua_State *L, int status, lua_KContext ctx);
+
+
+/*
+** Type for functions that read/write blocks when loading/dumping Lua chunks
+*/
+typedef const char * (*lua_Reader) (lua_State *L, void *ud, size_t *sz);
+
+typedef int (*lua_Writer) (lua_State *L, const void *p, size_t sz, void *ud);
+
+
+/*
+** Type for memory-allocation functions
+*/
+typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize);
+
+
+/*
+** Type for warning functions
+*/
+typedef void (*lua_WarnFunction) (void *ud, const char *msg, int tocont);
+
+
+
+
+/*
+** generic extra include file
+*/
+#if defined(LUA_USER_H)
+#include LUA_USER_H
+#endif
+
+
+/*
+** RCS ident string
+*/
+extern const char lua_ident[];
+
+
+/*
+** state manipulation
+*/
+LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud);
+LUA_API void       (lua_close) (lua_State *L);
+LUA_API lua_State *(lua_newthread) (lua_State *L);
+LUA_API int        (lua_resetthread) (lua_State *L);
+
+LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf);
+
+
+LUA_API lua_Number (lua_version) (lua_State *L);
+
+
+/*
+** basic stack manipulation
+*/
+LUA_API int   (lua_absindex) (lua_State *L, int idx);
+LUA_API int   (lua_gettop) (lua_State *L);
+LUA_API void  (lua_settop) (lua_State *L, int idx);
+LUA_API void  (lua_pushvalue) (lua_State *L, int idx);
+LUA_API void  (lua_rotate) (lua_State *L, int idx, int n);
+LUA_API void  (lua_copy) (lua_State *L, int fromidx, int toidx);
+LUA_API int   (lua_checkstack) (lua_State *L, int n);
+
+LUA_API void  (lua_xmove) (lua_State *from, lua_State *to, int n);
+
+
+/*
+** access functions (stack -> C)
+*/
+
+LUA_API int             (lua_isnumber) (lua_State *L, int idx);
+LUA_API int             (lua_isstring) (lua_State *L, int idx);
+LUA_API int             (lua_iscfunction) (lua_State *L, int idx);
+LUA_API int             (lua_isinteger) (lua_State *L, int idx);
+LUA_API int             (lua_isuserdata) (lua_State *L, int idx);
+LUA_API int             (lua_type) (lua_State *L, int idx);
+LUA_API const char     *(lua_typename) (lua_State *L, int tp);
+
+LUA_API lua_Number      (lua_tonumberx) (lua_State *L, int idx, int *isnum);
+LUA_API lua_Integer     (lua_tointegerx) (lua_State *L, int idx, int *isnum);
+LUA_API int             (lua_toboolean) (lua_State *L, int idx);
+LUA_API const char     *(lua_tolstring) (lua_State *L, int idx, size_t *len);
+LUA_API lua_Unsigned    (lua_rawlen) (lua_State *L, int idx);
+LUA_API lua_CFunction   (lua_tocfunction) (lua_State *L, int idx);
+LUA_API void	       *(lua_touserdata) (lua_State *L, int idx);
+LUA_API lua_State      *(lua_tothread) (lua_State *L, int idx);
+LUA_API const void     *(lua_topointer) (lua_State *L, int idx);
+
+
+/*
+** Comparison and arithmetic functions
+*/
+
+#define LUA_OPADD	0	/* ORDER TM, ORDER OP */
+#define LUA_OPSUB	1
+#define LUA_OPMUL	2
+#define LUA_OPMOD	3
+#define LUA_OPPOW	4
+#define LUA_OPDIV	5
+#define LUA_OPIDIV	6
+#define LUA_OPBAND	7
+#define LUA_OPBOR	8
+#define LUA_OPBXOR	9
+#define LUA_OPSHL	10
+#define LUA_OPSHR	11
+#define LUA_OPUNM	12
+#define LUA_OPBNOT	13
+
+LUA_API void  (lua_arith) (lua_State *L, int op);
+
+#define LUA_OPEQ	0
+#define LUA_OPLT	1
+#define LUA_OPLE	2
+
+LUA_API int   (lua_rawequal) (lua_State *L, int idx1, int idx2);
+LUA_API int   (lua_compare) (lua_State *L, int idx1, int idx2, int op);
+
+
+/*
+** push functions (C -> stack)
+*/
+LUA_API void        (lua_pushnil) (lua_State *L);
+LUA_API void        (lua_pushnumber) (lua_State *L, lua_Number n);
+LUA_API void        (lua_pushinteger) (lua_State *L, lua_Integer n);
+LUA_API const char *(lua_pushlstring) (lua_State *L, const char *s, size_t len);
+LUA_API const char *(lua_pushstring) (lua_State *L, const char *s);
+LUA_API const char *(lua_pushvfstring) (lua_State *L, const char *fmt,
+                                                      va_list argp);
+LUA_API const char *(lua_pushfstring) (lua_State *L, const char *fmt, ...);
+LUA_API void  (lua_pushcclosure) (lua_State *L, lua_CFunction fn, int n);
+LUA_API void  (lua_pushboolean) (lua_State *L, int b);
+LUA_API void  (lua_pushlightuserdata) (lua_State *L, void *p);
+LUA_API int   (lua_pushthread) (lua_State *L);
+
+
+/*
+** get functions (Lua -> stack)
+*/
+LUA_API int (lua_getglobal) (lua_State *L, const char *name);
+LUA_API int (lua_gettable) (lua_State *L, int idx);
+LUA_API int (lua_getfield) (lua_State *L, int idx, const char *k);
+LUA_API int (lua_geti) (lua_State *L, int idx, lua_Integer n);
+LUA_API int (lua_rawget) (lua_State *L, int idx);
+LUA_API int (lua_rawgeti) (lua_State *L, int idx, lua_Integer n);
+LUA_API int (lua_rawgetp) (lua_State *L, int idx, const void *p);
+
+LUA_API void  (lua_createtable) (lua_State *L, int narr, int nrec);
+LUA_API void *(lua_newuserdatauv) (lua_State *L, size_t sz, int nuvalue);
+LUA_API int   (lua_getmetatable) (lua_State *L, int objindex);
+LUA_API int  (lua_getiuservalue) (lua_State *L, int idx, int n);
+
+
+/*
+** set functions (stack -> Lua)
+*/
+LUA_API void  (lua_setglobal) (lua_State *L, const char *name);
+LUA_API void  (lua_settable) (lua_State *L, int idx);
+LUA_API void  (lua_setfield) (lua_State *L, int idx, const char *k);
+LUA_API void  (lua_seti) (lua_State *L, int idx, lua_Integer n);
+LUA_API void  (lua_rawset) (lua_State *L, int idx);
+LUA_API void  (lua_rawseti) (lua_State *L, int idx, lua_Integer n);
+LUA_API void  (lua_rawsetp) (lua_State *L, int idx, const void *p);
+LUA_API int   (lua_setmetatable) (lua_State *L, int objindex);
+LUA_API int   (lua_setiuservalue) (lua_State *L, int idx, int n);
+
+
+/*
+** 'load' and 'call' functions (load and run Lua code)
+*/
+LUA_API void  (lua_callk) (lua_State *L, int nargs, int nresults,
+                           lua_KContext ctx, lua_KFunction k);
+#define lua_call(L,n,r)		lua_callk(L, (n), (r), 0, NULL)
+
+LUA_API int   (lua_pcallk) (lua_State *L, int nargs, int nresults, int errfunc,
+                            lua_KContext ctx, lua_KFunction k);
+#define lua_pcall(L,n,r,f)	lua_pcallk(L, (n), (r), (f), 0, NULL)
+
+LUA_API int   (lua_load) (lua_State *L, lua_Reader reader, void *dt,
+                          const char *chunkname, const char *mode);
+
+LUA_API int (lua_dump) (lua_State *L, lua_Writer writer, void *data, int strip);
+
+
+/*
+** coroutine functions
+*/
+LUA_API int  (lua_yieldk)     (lua_State *L, int nresults, lua_KContext ctx,
+                               lua_KFunction k);
+LUA_API int  (lua_resume)     (lua_State *L, lua_State *from, int narg,
+                               int *nres);
+LUA_API int  (lua_status)     (lua_State *L);
+LUA_API int (lua_isyieldable) (lua_State *L);
+
+#define lua_yield(L,n)		lua_yieldk(L, (n), 0, NULL)
+
+
+/*
+** Warning-related functions
+*/
+LUA_API void (lua_setwarnf) (lua_State *L, lua_WarnFunction f, void *ud);
+LUA_API void (lua_warning)  (lua_State *L, const char *msg, int tocont);
+
+
+/*
+** garbage-collection function and options
+*/
+
+#define LUA_GCSTOP		0
+#define LUA_GCRESTART		1
+#define LUA_GCCOLLECT		2
+#define LUA_GCCOUNT		3
+#define LUA_GCCOUNTB		4
+#define LUA_GCSTEP		5
+#define LUA_GCSETPAUSE		6
+#define LUA_GCSETSTEPMUL	7
+#define LUA_GCISRUNNING		9
+#define LUA_GCGEN		10
+#define LUA_GCINC		11
+
+LUA_API int (lua_gc) (lua_State *L, int what, ...);
+
+
+/*
+** miscellaneous functions
+*/
+
+LUA_API int   (lua_error) (lua_State *L);
+
+LUA_API int   (lua_next) (lua_State *L, int idx);
+
+LUA_API void  (lua_concat) (lua_State *L, int n);
+LUA_API void  (lua_len)    (lua_State *L, int idx);
+
+LUA_API size_t   (lua_stringtonumber) (lua_State *L, const char *s);
+
+LUA_API lua_Alloc (lua_getallocf) (lua_State *L, void **ud);
+LUA_API void      (lua_setallocf) (lua_State *L, lua_Alloc f, void *ud);
+
+LUA_API void  (lua_toclose) (lua_State *L, int idx);
+
+
+/*
+** {==============================================================
+** some useful macros
+** ===============================================================
+*/
+
+#define lua_getextraspace(L)	((void *)((char *)(L) - LUA_EXTRASPACE))
+
+#define lua_tonumber(L,i)	lua_tonumberx(L,(i),NULL)
+#define lua_tointeger(L,i)	lua_tointegerx(L,(i),NULL)
+
+#define lua_pop(L,n)		lua_settop(L, -(n)-1)
+
+#define lua_newtable(L)		lua_createtable(L, 0, 0)
+
+#define lua_register(L,n,f) (lua_pushcfunction(L, (f)), lua_setglobal(L, (n)))
+
+#define lua_pushcfunction(L,f)	lua_pushcclosure(L, (f), 0)
+
+#define lua_isfunction(L,n)	(lua_type(L, (n)) == LUA_TFUNCTION)
+#define lua_istable(L,n)	(lua_type(L, (n)) == LUA_TTABLE)
+#define lua_islightuserdata(L,n)	(lua_type(L, (n)) == LUA_TLIGHTUSERDATA)
+#define lua_isnil(L,n)		(lua_type(L, (n)) == LUA_TNIL)
+#define lua_isboolean(L,n)	(lua_type(L, (n)) == LUA_TBOOLEAN)
+#define lua_isthread(L,n)	(lua_type(L, (n)) == LUA_TTHREAD)
+#define lua_isnone(L,n)		(lua_type(L, (n)) == LUA_TNONE)
+#define lua_isnoneornil(L, n)	(lua_type(L, (n)) <= 0)
+
+#define lua_pushliteral(L, s)	lua_pushstring(L, "" s)
+
+#define lua_pushglobaltable(L)  \
+	((void)lua_rawgeti(L, LUA_REGISTRYINDEX, LUA_RIDX_GLOBALS))
+
+#define lua_tostring(L,i)	lua_tolstring(L, (i), NULL)
+
+
+#define lua_insert(L,idx)	lua_rotate(L, (idx), 1)
+
+#define lua_remove(L,idx)	(lua_rotate(L, (idx), -1), lua_pop(L, 1))
+
+#define lua_replace(L,idx)	(lua_copy(L, -1, (idx)), lua_pop(L, 1))
+
+/* }============================================================== */
+
+
+/*
+** {==============================================================
+** compatibility macros
+** ===============================================================
+*/
+#if defined(LUA_COMPAT_APIINTCASTS)
+
+#define lua_pushunsigned(L,n)	lua_pushinteger(L, (lua_Integer)(n))
+#define lua_tounsignedx(L,i,is)	((lua_Unsigned)lua_tointegerx(L,i,is))
+#define lua_tounsigned(L,i)	lua_tounsignedx(L,(i),NULL)
+
+#endif
+
+#define lua_newuserdata(L,s)	lua_newuserdatauv(L,s,1)
+#define lua_getuservalue(L,idx)	lua_getiuservalue(L,idx,1)
+#define lua_setuservalue(L,idx)	lua_setiuservalue(L,idx,1)
+
+#define LUA_NUMTAGS		LUA_NUMTYPES
+
+/* }============================================================== */
+
+/*
+** {======================================================================
+** Debug API
+** =======================================================================
+*/
+
+
+/*
+** Event codes
+*/
+#define LUA_HOOKCALL	0
+#define LUA_HOOKRET	1
+#define LUA_HOOKLINE	2
+#define LUA_HOOKCOUNT	3
+#define LUA_HOOKTAILCALL 4
+
+
+/*
+** Event masks
+*/
+#define LUA_MASKCALL	(1 << LUA_HOOKCALL)
+#define LUA_MASKRET	(1 << LUA_HOOKRET)
+#define LUA_MASKLINE	(1 << LUA_HOOKLINE)
+#define LUA_MASKCOUNT	(1 << LUA_HOOKCOUNT)
+
+typedef struct lua_Debug lua_Debug;  /* activation record */
+
+
+/* Functions to be called by the debugger in specific events */
+typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar);
+
+
+LUA_API int (lua_getstack) (lua_State *L, int level, lua_Debug *ar);
+LUA_API int (lua_getinfo) (lua_State *L, const char *what, lua_Debug *ar);
+LUA_API const char *(lua_getlocal) (lua_State *L, const lua_Debug *ar, int n);
+LUA_API const char *(lua_setlocal) (lua_State *L, const lua_Debug *ar, int n);
+LUA_API const char *(lua_getupvalue) (lua_State *L, int funcindex, int n);
+LUA_API const char *(lua_setupvalue) (lua_State *L, int funcindex, int n);
+
+LUA_API void *(lua_upvalueid) (lua_State *L, int fidx, int n);
+LUA_API void  (lua_upvaluejoin) (lua_State *L, int fidx1, int n1,
+                                               int fidx2, int n2);
+
+LUA_API void (lua_sethook) (lua_State *L, lua_Hook func, int mask, int count);
+LUA_API lua_Hook (lua_gethook) (lua_State *L);
+LUA_API int (lua_gethookmask) (lua_State *L);
+LUA_API int (lua_gethookcount) (lua_State *L);
+
+LUA_API int (lua_setcstacklimit) (lua_State *L, unsigned int limit);
+
+struct lua_Debug {
+  int event;
+  const char *name;	/* (n) */
+  const char *namewhat;	/* (n) 'global', 'local', 'field', 'method' */
+  const char *what;	/* (S) 'Lua', 'C', 'main', 'tail' */
+  const char *source;	/* (S) */
+  size_t srclen;	/* (S) */
+  int currentline;	/* (l) */
+  int linedefined;	/* (S) */
+  int lastlinedefined;	/* (S) */
+  unsigned char nups;	/* (u) number of upvalues */
+  unsigned char nparams;/* (u) number of parameters */
+  char isvararg;        /* (u) */
+  char istailcall;	/* (t) */
+  unsigned short ftransfer;   /* (r) index of first value transferred */
+  unsigned short ntransfer;   /* (r) number of transferred values */
+  char short_src[LUA_IDSIZE]; /* (S) */
+  /* private part */
+  struct CallInfo *i_ci;  /* active function */
+};
+
+/* }====================================================================== */
+
+
+/******************************************************************************
+* Copyright (C) 1994-2020 Lua.org, PUC-Rio.
+*
+* 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.
+******************************************************************************/
+
+
+#endif

+ 9 - 0
vendor/lua/5.4/include/lua.hpp

@@ -0,0 +1,9 @@
+// lua.hpp
+// Lua header files for C++
+// <<extern "C">> not supplied automatically because Lua also compiles as C++
+
+extern "C" {
+#include "lua.h"
+#include "lualib.h"
+#include "lauxlib.h"
+}

+ 763 - 0
vendor/lua/5.4/include/luaconf.h

@@ -0,0 +1,763 @@
+/*
+** $Id: luaconf.h $
+** Configuration file for Lua
+** See Copyright Notice in lua.h
+*/
+
+
+#ifndef luaconf_h
+#define luaconf_h
+
+#include <limits.h>
+#include <stddef.h>
+
+
+/*
+** ===================================================================
+** General Configuration File for Lua
+**
+** Some definitions here can be changed externally, through the
+** compiler (e.g., with '-D' options). Those are protected by
+** '#if !defined' guards. However, several other definitions should
+** be changed directly here, either because they affect the Lua
+** ABI (by making the changes here, you ensure that all software
+** connected to Lua, such as C libraries, will be compiled with the
+** same configuration); or because they are seldom changed.
+**
+** Search for "@@" to find all configurable definitions.
+** ===================================================================
+*/
+
+
+/*
+** {====================================================================
+** System Configuration: macros to adapt (if needed) Lua to some
+** particular platform, for instance restricting it to C89.
+** =====================================================================
+*/
+
+/*
+@@ LUA_USE_C89 controls the use of non-ISO-C89 features.
+** Define it if you want Lua to avoid the use of a few C99 features
+** or Windows-specific features on Windows.
+*/
+/* #define LUA_USE_C89 */
+
+
+/*
+** By default, Lua on Windows use (some) specific Windows features
+*/
+#if !defined(LUA_USE_C89) && defined(_WIN32) && !defined(_WIN32_WCE)
+#define LUA_USE_WINDOWS  /* enable goodies for regular Windows */
+#endif
+
+
+#if defined(LUA_USE_WINDOWS)
+#define LUA_DL_DLL	/* enable support for DLL */
+#define LUA_USE_C89	/* broadly, Windows is C89 */
+#endif
+
+
+#if defined(LUA_USE_LINUX)
+#define LUA_USE_POSIX
+#define LUA_USE_DLOPEN		/* needs an extra library: -ldl */
+#endif
+
+
+#if defined(LUA_USE_MACOSX)
+#define LUA_USE_POSIX
+#define LUA_USE_DLOPEN		/* MacOS does not need -ldl */
+#endif
+
+
+/*
+@@ LUAI_IS32INT is true iff 'int' has (at least) 32 bits.
+*/
+#define LUAI_IS32INT	((UINT_MAX >> 30) >= 3)
+
+/* }================================================================== */
+
+
+
+/*
+** {==================================================================
+** Configuration for Number types.
+** ===================================================================
+*/
+
+/*
+@@ LUA_32BITS enables Lua with 32-bit integers and 32-bit floats.
+*/
+/* #define LUA_32BITS */
+
+
+/*
+@@ LUA_C89_NUMBERS ensures that Lua uses the largest types available for
+** C89 ('long' and 'double'); Windows always has '__int64', so it does
+** not need to use this case.
+*/
+#if defined(LUA_USE_C89) && !defined(LUA_USE_WINDOWS)
+#define LUA_C89_NUMBERS
+#endif
+
+
+/*
+@@ LUA_INT_TYPE defines the type for Lua integers.
+@@ LUA_FLOAT_TYPE defines the type for Lua floats.
+** Lua should work fine with any mix of these options supported
+** by your C compiler. The usual configurations are 64-bit integers
+** and 'double' (the default), 32-bit integers and 'float' (for
+** restricted platforms), and 'long'/'double' (for C compilers not
+** compliant with C99, which may not have support for 'long long').
+*/
+
+/* predefined options for LUA_INT_TYPE */
+#define LUA_INT_INT		1
+#define LUA_INT_LONG		2
+#define LUA_INT_LONGLONG	3
+
+/* predefined options for LUA_FLOAT_TYPE */
+#define LUA_FLOAT_FLOAT		1
+#define LUA_FLOAT_DOUBLE	2
+#define LUA_FLOAT_LONGDOUBLE	3
+
+#if defined(LUA_32BITS)		/* { */
+/*
+** 32-bit integers and 'float'
+*/
+#if LUAI_IS32INT  /* use 'int' if big enough */
+#define LUA_INT_TYPE	LUA_INT_INT
+#else  /* otherwise use 'long' */
+#define LUA_INT_TYPE	LUA_INT_LONG
+#endif
+#define LUA_FLOAT_TYPE	LUA_FLOAT_FLOAT
+
+#elif defined(LUA_C89_NUMBERS)	/* }{ */
+/*
+** largest types available for C89 ('long' and 'double')
+*/
+#define LUA_INT_TYPE	LUA_INT_LONG
+#define LUA_FLOAT_TYPE	LUA_FLOAT_DOUBLE
+
+#endif				/* } */
+
+
+/*
+** default configuration for 64-bit Lua ('long long' and 'double')
+*/
+#if !defined(LUA_INT_TYPE)
+#define LUA_INT_TYPE	LUA_INT_LONGLONG
+#endif
+
+#if !defined(LUA_FLOAT_TYPE)
+#define LUA_FLOAT_TYPE	LUA_FLOAT_DOUBLE
+#endif
+
+/* }================================================================== */
+
+
+
+/*
+** {==================================================================
+** Configuration for Paths.
+** ===================================================================
+*/
+
+/*
+** LUA_PATH_SEP is the character that separates templates in a path.
+** LUA_PATH_MARK is the string that marks the substitution points in a
+** template.
+** LUA_EXEC_DIR in a Windows path is replaced by the executable's
+** directory.
+*/
+#define LUA_PATH_SEP            ";"
+#define LUA_PATH_MARK           "?"
+#define LUA_EXEC_DIR            "!"
+
+
+/*
+@@ LUA_PATH_DEFAULT is the default path that Lua uses to look for
+** Lua libraries.
+@@ LUA_CPATH_DEFAULT is the default path that Lua uses to look for
+** C libraries.
+** CHANGE them if your machine has a non-conventional directory
+** hierarchy or if you want to install your libraries in
+** non-conventional directories.
+*/
+
+#define LUA_VDIR	LUA_VERSION_MAJOR "." LUA_VERSION_MINOR
+#if defined(_WIN32)	/* { */
+/*
+** In Windows, any exclamation mark ('!') in the path is replaced by the
+** path of the directory of the executable file of the current process.
+*/
+#define LUA_LDIR	"!\\lua\\"
+#define LUA_CDIR	"!\\"
+#define LUA_SHRDIR	"!\\..\\share\\lua\\" LUA_VDIR "\\"
+
+#if !defined(LUA_PATH_DEFAULT)
+#define LUA_PATH_DEFAULT  \
+		LUA_LDIR"?.lua;"  LUA_LDIR"?\\init.lua;" \
+		LUA_CDIR"?.lua;"  LUA_CDIR"?\\init.lua;" \
+		LUA_SHRDIR"?.lua;" LUA_SHRDIR"?\\init.lua;" \
+		".\\?.lua;" ".\\?\\init.lua"
+#endif
+
+#if !defined(LUA_CPATH_DEFAULT)
+#define LUA_CPATH_DEFAULT \
+		LUA_CDIR"?.dll;" \
+		LUA_CDIR"..\\lib\\lua\\" LUA_VDIR "\\?.dll;" \
+		LUA_CDIR"loadall.dll;" ".\\?.dll;" \
+		LUA_CDIR"?54.dll;" ".\\?54.dll"
+#endif
+
+#else			/* }{ */
+
+#define LUA_ROOT	"/usr/local/"
+#define LUA_LDIR	LUA_ROOT "share/lua/" LUA_VDIR "/"
+#define LUA_CDIR	LUA_ROOT "lib/lua/" LUA_VDIR "/"
+
+#if !defined(LUA_PATH_DEFAULT)
+#define LUA_PATH_DEFAULT  \
+		LUA_LDIR"?.lua;"  LUA_LDIR"?/init.lua;" \
+		LUA_CDIR"?.lua;"  LUA_CDIR"?/init.lua;" \
+		"./?.lua;" "./?/init.lua"
+#endif
+
+#if !defined(LUA_CPATH_DEFAULT)
+#define LUA_CPATH_DEFAULT \
+		LUA_CDIR"?.so;" LUA_CDIR"loadall.so;" "./?.so;" \
+		LUA_CDIR"lib?54.so;" "./lib?54.so"
+#endif
+
+#endif			/* } */
+
+
+/*
+@@ LUA_DIRSEP is the directory separator (for submodules).
+** CHANGE it if your machine does not use "/" as the directory separator
+** and is not Windows. (On Windows Lua automatically uses "\".)
+*/
+#if !defined(LUA_DIRSEP)
+
+#if defined(_WIN32)
+#define LUA_DIRSEP	"\\"
+#else
+#define LUA_DIRSEP	"/"
+#endif
+
+#endif
+
+/* }================================================================== */
+
+
+/*
+** {==================================================================
+** Marks for exported symbols in the C code
+** ===================================================================
+*/
+
+/*
+@@ LUA_API is a mark for all core API functions.
+@@ LUALIB_API is a mark for all auxiliary library functions.
+@@ LUAMOD_API is a mark for all standard library opening functions.
+** CHANGE them if you need to define those functions in some special way.
+** For instance, if you want to create one Windows DLL with the core and
+** the libraries, you may want to use the following definition (define
+** LUA_BUILD_AS_DLL to get it).
+*/
+#if defined(LUA_BUILD_AS_DLL)	/* { */
+
+#if defined(LUA_CORE) || defined(LUA_LIB)	/* { */
+#define LUA_API __declspec(dllexport)
+#else						/* }{ */
+#define LUA_API __declspec(dllimport)
+#endif						/* } */
+
+#else				/* }{ */
+
+#define LUA_API		extern
+
+#endif				/* } */
+
+
+/*
+** More often than not the libs go together with the core.
+*/
+#define LUALIB_API	LUA_API
+#define LUAMOD_API	LUA_API
+
+
+/*
+@@ LUAI_FUNC is a mark for all extern functions that are not to be
+** exported to outside modules.
+@@ LUAI_DDEF and LUAI_DDEC are marks for all extern (const) variables,
+** none of which to be exported to outside modules (LUAI_DDEF for
+** definitions and LUAI_DDEC for declarations).
+** CHANGE them if you need to mark them in some special way. Elf/gcc
+** (versions 3.2 and later) mark them as "hidden" to optimize access
+** when Lua is compiled as a shared library. Not all elf targets support
+** this attribute. Unfortunately, gcc does not offer a way to check
+** whether the target offers that support, and those without support
+** give a warning about it. To avoid these warnings, change to the
+** default definition.
+*/
+#if defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \
+    defined(__ELF__)		/* { */
+#define LUAI_FUNC	__attribute__((visibility("internal"))) extern
+#else				/* }{ */
+#define LUAI_FUNC	extern
+#endif				/* } */
+
+#define LUAI_DDEC(dec)	LUAI_FUNC dec
+#define LUAI_DDEF	/* empty */
+
+/* }================================================================== */
+
+
+/*
+** {==================================================================
+** Compatibility with previous versions
+** ===================================================================
+*/
+
+/*
+@@ LUA_COMPAT_5_3 controls other macros for compatibility with Lua 5.3.
+** You can define it to get all options, or change specific options
+** to fit your specific needs.
+*/
+#if defined(LUA_COMPAT_5_3)	/* { */
+
+/*
+@@ LUA_COMPAT_MATHLIB controls the presence of several deprecated
+** functions in the mathematical library.
+** (These functions were already officially removed in 5.3;
+** nevertheless they are still available here.)
+*/
+#define LUA_COMPAT_MATHLIB
+
+/*
+@@ LUA_COMPAT_APIINTCASTS controls the presence of macros for
+** manipulating other integer types (lua_pushunsigned, lua_tounsigned,
+** luaL_checkint, luaL_checklong, etc.)
+** (These macros were also officially removed in 5.3, but they are still
+** available here.)
+*/
+#define LUA_COMPAT_APIINTCASTS
+
+
+/*
+@@ LUA_COMPAT_LT_LE controls the emulation of the '__le' metamethod
+** using '__lt'.
+*/
+#define LUA_COMPAT_LT_LE
+
+
+/*
+@@ The following macros supply trivial compatibility for some
+** changes in the API. The macros themselves document how to
+** change your code to avoid using them.
+** (Once more, these macros were officially removed in 5.3, but they are
+** still available here.)
+*/
+#define lua_strlen(L,i)		lua_rawlen(L, (i))
+
+#define lua_objlen(L,i)		lua_rawlen(L, (i))
+
+#define lua_equal(L,idx1,idx2)		lua_compare(L,(idx1),(idx2),LUA_OPEQ)
+#define lua_lessthan(L,idx1,idx2)	lua_compare(L,(idx1),(idx2),LUA_OPLT)
+
+#endif				/* } */
+
+/* }================================================================== */
+
+
+
+/*
+** {==================================================================
+** Configuration for Numbers.
+** Change these definitions if no predefined LUA_FLOAT_* / LUA_INT_*
+** satisfy your needs.
+** ===================================================================
+*/
+
+/*
+@@ LUA_NUMBER is the floating-point type used by Lua.
+@@ LUAI_UACNUMBER is the result of a 'default argument promotion'
+@@ over a floating number.
+@@ l_floatatt(x) corrects float attribute 'x' to the proper float type
+** by prefixing it with one of FLT/DBL/LDBL.
+@@ LUA_NUMBER_FRMLEN is the length modifier for writing floats.
+@@ LUA_NUMBER_FMT is the format for writing floats.
+@@ lua_number2str converts a float to a string.
+@@ l_mathop allows the addition of an 'l' or 'f' to all math operations.
+@@ l_floor takes the floor of a float.
+@@ lua_str2number converts a decimal numeral to a number.
+*/
+
+
+/* The following definitions are good for most cases here */
+
+#define l_floor(x)		(l_mathop(floor)(x))
+
+#define lua_number2str(s,sz,n)  \
+	l_sprintf((s), sz, LUA_NUMBER_FMT, (LUAI_UACNUMBER)(n))
+
+/*
+@@ lua_numbertointeger converts a float number with an integral value
+** to an integer, or returns 0 if float is not within the range of
+** a lua_Integer.  (The range comparisons are tricky because of
+** rounding. The tests here assume a two-complement representation,
+** where MININTEGER always has an exact representation as a float;
+** MAXINTEGER may not have one, and therefore its conversion to float
+** may have an ill-defined value.)
+*/
+#define lua_numbertointeger(n,p) \
+  ((n) >= (LUA_NUMBER)(LUA_MININTEGER) && \
+   (n) < -(LUA_NUMBER)(LUA_MININTEGER) && \
+      (*(p) = (LUA_INTEGER)(n), 1))
+
+
+/* now the variable definitions */
+
+#if LUA_FLOAT_TYPE == LUA_FLOAT_FLOAT		/* { single float */
+
+#define LUA_NUMBER	float
+
+#define l_floatatt(n)		(FLT_##n)
+
+#define LUAI_UACNUMBER	double
+
+#define LUA_NUMBER_FRMLEN	""
+#define LUA_NUMBER_FMT		"%.7g"
+
+#define l_mathop(op)		op##f
+
+#define lua_str2number(s,p)	strtof((s), (p))
+
+
+#elif LUA_FLOAT_TYPE == LUA_FLOAT_LONGDOUBLE	/* }{ long double */
+
+#define LUA_NUMBER	long double
+
+#define l_floatatt(n)		(LDBL_##n)
+
+#define LUAI_UACNUMBER	long double
+
+#define LUA_NUMBER_FRMLEN	"L"
+#define LUA_NUMBER_FMT		"%.19Lg"
+
+#define l_mathop(op)		op##l
+
+#define lua_str2number(s,p)	strtold((s), (p))
+
+#elif LUA_FLOAT_TYPE == LUA_FLOAT_DOUBLE	/* }{ double */
+
+#define LUA_NUMBER	double
+
+#define l_floatatt(n)		(DBL_##n)
+
+#define LUAI_UACNUMBER	double
+
+#define LUA_NUMBER_FRMLEN	""
+#define LUA_NUMBER_FMT		"%.14g"
+
+#define l_mathop(op)		op
+
+#define lua_str2number(s,p)	strtod((s), (p))
+
+#else						/* }{ */
+
+#error "numeric float type not defined"
+
+#endif					/* } */
+
+
+
+/*
+@@ LUA_INTEGER is the integer type used by Lua.
+**
+@@ LUA_UNSIGNED is the unsigned version of LUA_INTEGER.
+**
+@@ LUAI_UACINT is the result of a 'default argument promotion'
+@@ over a LUA_INTEGER.
+@@ LUA_INTEGER_FRMLEN is the length modifier for reading/writing integers.
+@@ LUA_INTEGER_FMT is the format for writing integers.
+@@ LUA_MAXINTEGER is the maximum value for a LUA_INTEGER.
+@@ LUA_MININTEGER is the minimum value for a LUA_INTEGER.
+@@ LUA_MAXUNSIGNED is the maximum value for a LUA_UNSIGNED.
+@@ LUA_UNSIGNEDBITS is the number of bits in a LUA_UNSIGNED.
+@@ lua_integer2str converts an integer to a string.
+*/
+
+
+/* The following definitions are good for most cases here */
+
+#define LUA_INTEGER_FMT		"%" LUA_INTEGER_FRMLEN "d"
+
+#define LUAI_UACINT		LUA_INTEGER
+
+#define lua_integer2str(s,sz,n)  \
+	l_sprintf((s), sz, LUA_INTEGER_FMT, (LUAI_UACINT)(n))
+
+/*
+** use LUAI_UACINT here to avoid problems with promotions (which
+** can turn a comparison between unsigneds into a signed comparison)
+*/
+#define LUA_UNSIGNED		unsigned LUAI_UACINT
+
+
+#define LUA_UNSIGNEDBITS	(sizeof(LUA_UNSIGNED) * CHAR_BIT)
+
+
+/* now the variable definitions */
+
+#if LUA_INT_TYPE == LUA_INT_INT		/* { int */
+
+#define LUA_INTEGER		int
+#define LUA_INTEGER_FRMLEN	""
+
+#define LUA_MAXINTEGER		INT_MAX
+#define LUA_MININTEGER		INT_MIN
+
+#define LUA_MAXUNSIGNED		UINT_MAX
+
+#elif LUA_INT_TYPE == LUA_INT_LONG	/* }{ long */
+
+#define LUA_INTEGER		long
+#define LUA_INTEGER_FRMLEN	"l"
+
+#define LUA_MAXINTEGER		LONG_MAX
+#define LUA_MININTEGER		LONG_MIN
+
+#define LUA_MAXUNSIGNED		ULONG_MAX
+
+#elif LUA_INT_TYPE == LUA_INT_LONGLONG	/* }{ long long */
+
+/* use presence of macro LLONG_MAX as proxy for C99 compliance */
+#if defined(LLONG_MAX)		/* { */
+/* use ISO C99 stuff */
+
+#define LUA_INTEGER		long long
+#define LUA_INTEGER_FRMLEN	"ll"
+
+#define LUA_MAXINTEGER		LLONG_MAX
+#define LUA_MININTEGER		LLONG_MIN
+
+#define LUA_MAXUNSIGNED		ULLONG_MAX
+
+#elif defined(LUA_USE_WINDOWS) /* }{ */
+/* in Windows, can use specific Windows types */
+
+#define LUA_INTEGER		__int64
+#define LUA_INTEGER_FRMLEN	"I64"
+
+#define LUA_MAXINTEGER		_I64_MAX
+#define LUA_MININTEGER		_I64_MIN
+
+#define LUA_MAXUNSIGNED		_UI64_MAX
+
+#else				/* }{ */
+
+#error "Compiler does not support 'long long'. Use option '-DLUA_32BITS' \
+  or '-DLUA_C89_NUMBERS' (see file 'luaconf.h' for details)"
+
+#endif				/* } */
+
+#else				/* }{ */
+
+#error "numeric integer type not defined"
+
+#endif				/* } */
+
+/* }================================================================== */
+
+
+/*
+** {==================================================================
+** Dependencies with C99 and other C details
+** ===================================================================
+*/
+
+/*
+@@ l_sprintf is equivalent to 'snprintf' or 'sprintf' in C89.
+** (All uses in Lua have only one format item.)
+*/
+#if !defined(LUA_USE_C89)
+#define l_sprintf(s,sz,f,i)	snprintf(s,sz,f,i)
+#else
+#define l_sprintf(s,sz,f,i)	((void)(sz), sprintf(s,f,i))
+#endif
+
+
+/*
+@@ lua_strx2number converts a hexadecimal numeral to a number.
+** In C99, 'strtod' does that conversion. Otherwise, you can
+** leave 'lua_strx2number' undefined and Lua will provide its own
+** implementation.
+*/
+#if !defined(LUA_USE_C89)
+#define lua_strx2number(s,p)		lua_str2number(s,p)
+#endif
+
+
+/*
+@@ lua_pointer2str converts a pointer to a readable string in a
+** non-specified way.
+*/
+#define lua_pointer2str(buff,sz,p)	l_sprintf(buff,sz,"%p",p)
+
+
+/*
+@@ lua_number2strx converts a float to a hexadecimal numeral.
+** In C99, 'sprintf' (with format specifiers '%a'/'%A') does that.
+** Otherwise, you can leave 'lua_number2strx' undefined and Lua will
+** provide its own implementation.
+*/
+#if !defined(LUA_USE_C89)
+#define lua_number2strx(L,b,sz,f,n)  \
+	((void)L, l_sprintf(b,sz,f,(LUAI_UACNUMBER)(n)))
+#endif
+
+
+/*
+** 'strtof' and 'opf' variants for math functions are not valid in
+** C89. Otherwise, the macro 'HUGE_VALF' is a good proxy for testing the
+** availability of these variants. ('math.h' is already included in
+** all files that use these macros.)
+*/
+#if defined(LUA_USE_C89) || (defined(HUGE_VAL) && !defined(HUGE_VALF))
+#undef l_mathop  /* variants not available */
+#undef lua_str2number
+#define l_mathop(op)		(lua_Number)op  /* no variant */
+#define lua_str2number(s,p)	((lua_Number)strtod((s), (p)))
+#endif
+
+
+/*
+@@ LUA_KCONTEXT is the type of the context ('ctx') for continuation
+** functions.  It must be a numerical type; Lua will use 'intptr_t' if
+** available, otherwise it will use 'ptrdiff_t' (the nearest thing to
+** 'intptr_t' in C89)
+*/
+#define LUA_KCONTEXT	ptrdiff_t
+
+#if !defined(LUA_USE_C89) && defined(__STDC_VERSION__) && \
+    __STDC_VERSION__ >= 199901L
+#include <stdint.h>
+#if defined(INTPTR_MAX)  /* even in C99 this type is optional */
+#undef LUA_KCONTEXT
+#define LUA_KCONTEXT	intptr_t
+#endif
+#endif
+
+
+/*
+@@ lua_getlocaledecpoint gets the locale "radix character" (decimal point).
+** Change that if you do not want to use C locales. (Code using this
+** macro must include the header 'locale.h'.)
+*/
+#if !defined(lua_getlocaledecpoint)
+#define lua_getlocaledecpoint()		(localeconv()->decimal_point[0])
+#endif
+
+/* }================================================================== */
+
+
+/*
+** {==================================================================
+** Language Variations
+** =====================================================================
+*/
+
+/*
+@@ LUA_NOCVTN2S/LUA_NOCVTS2N control how Lua performs some
+** coercions. Define LUA_NOCVTN2S to turn off automatic coercion from
+** numbers to strings. Define LUA_NOCVTS2N to turn off automatic
+** coercion from strings to numbers.
+*/
+/* #define LUA_NOCVTN2S */
+/* #define LUA_NOCVTS2N */
+
+
+/*
+@@ LUA_USE_APICHECK turns on several consistency checks on the C API.
+** Define it as a help when debugging C code.
+*/
+#if defined(LUA_USE_APICHECK)
+#include <assert.h>
+#define luai_apicheck(l,e)	assert(e)
+#endif
+
+/* }================================================================== */
+
+
+/*
+** {==================================================================
+** Macros that affect the API and must be stable (that is, must be the
+** same when you compile Lua and when you compile code that links to
+** Lua).
+** =====================================================================
+*/
+
+/*
+@@ LUAI_MAXSTACK limits the size of the Lua stack.
+** CHANGE it if you need a different limit. This limit is arbitrary;
+** its only purpose is to stop Lua from consuming unlimited stack
+** space (and to reserve some numbers for pseudo-indices).
+** (It must fit into max(size_t)/32.)
+*/
+#if LUAI_IS32INT
+#define LUAI_MAXSTACK		1000000
+#else
+#define LUAI_MAXSTACK		15000
+#endif
+
+
+/*
+@@ LUA_EXTRASPACE defines the size of a raw memory area associated with
+** a Lua state with very fast access.
+** CHANGE it if you need a different size.
+*/
+#define LUA_EXTRASPACE		(sizeof(void *))
+
+
+/*
+@@ LUA_IDSIZE gives the maximum size for the description of the source
+@@ of a function in debug information.
+** CHANGE it if you want a different size.
+*/
+#define LUA_IDSIZE	60
+
+
+/*
+@@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system.
+*/
+#define LUAL_BUFFERSIZE   ((int)(16 * sizeof(void*) * sizeof(lua_Number)))
+
+
+/*
+@@ LUAI_MAXALIGN defines fields that, when used in a union, ensure
+** maximum alignment for the other items in that union.
+*/
+#define LUAI_MAXALIGN  lua_Number n; double u; void *s; lua_Integer i; long l
+
+/* }================================================================== */
+
+
+
+
+
+/* =================================================================== */
+
+/*
+** Local configuration. You can use this space to add your redefinitions
+** without modifying the main part of the file.
+*/
+
+
+
+
+
+#endif
+

+ 58 - 0
vendor/lua/5.4/include/lualib.h

@@ -0,0 +1,58 @@
+/*
+** $Id: lualib.h $
+** Lua standard libraries
+** See Copyright Notice in lua.h
+*/
+
+
+#ifndef lualib_h
+#define lualib_h
+
+#include "lua.h"
+
+
+/* version suffix for environment variable names */
+#define LUA_VERSUFFIX          "_" LUA_VERSION_MAJOR "_" LUA_VERSION_MINOR
+
+
+LUAMOD_API int (luaopen_base) (lua_State *L);
+
+#define LUA_COLIBNAME	"coroutine"
+LUAMOD_API int (luaopen_coroutine) (lua_State *L);
+
+#define LUA_TABLIBNAME	"table"
+LUAMOD_API int (luaopen_table) (lua_State *L);
+
+#define LUA_IOLIBNAME	"io"
+LUAMOD_API int (luaopen_io) (lua_State *L);
+
+#define LUA_OSLIBNAME	"os"
+LUAMOD_API int (luaopen_os) (lua_State *L);
+
+#define LUA_STRLIBNAME	"string"
+LUAMOD_API int (luaopen_string) (lua_State *L);
+
+#define LUA_UTF8LIBNAME	"utf8"
+LUAMOD_API int (luaopen_utf8) (lua_State *L);
+
+#define LUA_MATHLIBNAME	"math"
+LUAMOD_API int (luaopen_math) (lua_State *L);
+
+#define LUA_DBLIBNAME	"debug"
+LUAMOD_API int (luaopen_debug) (lua_State *L);
+
+#define LUA_LOADLIBNAME	"package"
+LUAMOD_API int (luaopen_package) (lua_State *L);
+
+
+/* open all previous libraries */
+LUALIB_API void (luaL_openlibs) (lua_State *L);
+
+
+
+#if !defined(lua_assert)
+#define lua_assert(x)	((void)0)
+#endif
+
+
+#endif

BIN
vendor/lua/5.4/linux/liblua54.a


BIN
vendor/lua/5.4/linux/liblua54.so


+ 826 - 0
vendor/lua/5.4/lua.odin

@@ -0,0 +1,826 @@
+package lua_5_4
+
+import "core:intrinsics"
+import "core:builtin"
+
+import c "core:c/libc"
+
+#assert(size_of(c.int) == size_of(b32))
+
+when ODIN_OS == .Windows {
+	foreign import lib "windows/lua54dll.lib"
+} else when ODIN_OS == .Linux {
+	foreign import lib "linux/liblua54.a"
+} else {
+	foreign import lib "system:liblua54.a"
+}
+
+VERSION_MAJOR       :: "5"
+VERSION_MINOR       :: "4"
+VERSION_RELEASE     :: "2"
+
+VERSION_NUM         :: 504
+VERSION_RELEASE_NUM :: VERSION_NUM * 100 + 0
+
+VERSION             :: "Lua " + VERSION_MAJOR + "." + VERSION_MINOR
+RELEASE             :: VERSION + "." + VERSION_RELEASE
+COPYRIGHT           :: RELEASE + "  Copyright (C) 1994-2020 Lua.org, PUC-Rio"
+AUTHORS             :: "R. Ierusalimschy, L. H. de Figueiredo, W. Celes"
+
+
+/* mark for precompiled code ('<esc>Lua') */
+SIGNATURE :: "\x1bLua"
+
+/* option for multiple returns in 'lua_pcall' and 'lua_call' */
+MULTRET :: -1
+
+REGISTRYINDEX :: -MAXSTACK - 1000
+
+
+/*
+@@ LUAI_MAXSTACK limits the size of the Lua stack.
+** CHANGE it if you need a different limit. This limit is arbitrary;
+** its only purpose is to stop Lua from consuming unlimited stack
+** space (and to reserve some numbers for pseudo-indices).
+** (It must fit into max(size_t)/32.)
+*/
+MAXSTACK :: 1000000 when size_of(rawptr) == 4 else 15000
+
+
+/*
+@@ LUA_EXTRASPACE defines the size of a raw memory area associated with
+** a Lua state with very fast access.
+** CHANGE it if you need a different size.
+*/
+EXTRASPACE :: size_of(rawptr)
+
+
+
+/*
+@@ LUA_IDSIZE gives the maximum size for the description of the source
+@@ of a function in debug information.
+** CHANGE it if you want a different size.
+*/
+IDSIZE :: 60
+
+
+/*
+@@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system.
+*/
+L_BUFFERSIZE :: c.int(16 * size_of(rawptr) * size_of(Number))
+
+
+MAXALIGNVAL :: max(align_of(Number), align_of(f64), align_of(rawptr), align_of(Integer), align_of(c.long))
+
+
+Status :: enum c.int {
+	OK        = 0,
+	YIELD     = 1,
+	ERRRUN    = 2,
+	ERRSYNTAX = 3,
+	ERRMEM    = 4,
+	ERRERR    = 5,
+	ERRFILE   = 6,
+}
+
+/* thread status */
+OK        :: Status.OK
+YIELD     :: Status.YIELD
+ERRRUN    :: Status.ERRRUN
+ERRSYNTAX :: Status.ERRSYNTAX
+ERRMEM    :: Status.ERRMEM
+ERRERR    :: Status.ERRERR
+ERRFILE   :: Status.ERRFILE
+
+/*
+** basic types
+*/
+
+
+Type :: enum c.int {
+	NONE          = -1,
+
+	NIL           = 0,
+	BOOLEAN       = 1,
+	LIGHTUSERDATA = 2,
+	NUMBER        = 3,
+	STRING        = 4,
+	TABLE         = 5,
+	FUNCTION      = 6,
+	USERDATA      = 7,
+	THREAD        = 8,
+}
+
+TNONE          :: Type.NONE
+TNIL           :: Type.NIL
+TBOOLEAN       :: Type.BOOLEAN
+TLIGHTUSERDATA :: Type.LIGHTUSERDATA
+TNUMBER        :: Type.NUMBER
+TSTRING        :: Type.STRING
+TTABLE         :: Type.TABLE
+TFUNCTION      :: Type.FUNCTION
+TUSERDATA      :: Type.USERDATA
+TTHREAD        :: Type.THREAD
+NUMTYPES :: 9
+
+
+
+ArithOp :: enum c.int {
+	ADD  = 0,	/* ORDER TM, ORDER OP */
+	SUB  = 1,
+	MUL  = 2,
+	MOD  = 3,
+	POW  = 4,
+	DIV  = 5,
+	IDIV = 6,
+	BAND = 7,
+	BOR  = 8,
+	BXOR = 9,
+	SHL  = 10,
+	SHR  = 11,
+	UNM  = 12,
+	BNOT = 13,
+}
+
+CompareOp :: enum c.int {
+	EQ = 0,
+	LT = 1,
+	LE = 2,
+}
+
+OPADD  :: ArithOp.ADD
+OPSUB  :: ArithOp.SUB
+OPMUL  :: ArithOp.MUL
+OPMOD  :: ArithOp.MOD
+OPPOW  :: ArithOp.POW
+OPDIV  :: ArithOp.DIV
+OPIDIV :: ArithOp.IDIV
+OPBAND :: ArithOp.BAND
+OPBOR  :: ArithOp.BOR
+OPBXOR :: ArithOp.BXOR
+OPSHL  :: ArithOp.SHL
+OPSHR  :: ArithOp.SHR
+OPUNM  :: ArithOp.UNM
+OPBNOT :: ArithOp.BNOT
+
+OPEQ :: CompareOp.EQ
+OPLT :: CompareOp.LT
+OPLE :: CompareOp.LE
+
+
+/* minimum Lua stack available to a C function */
+MINSTACK :: 20
+
+
+/* predefined values in the registry */
+RIDX_MAINTHREAD :: 1
+RIDX_GLOBALS    :: 2
+RIDX_LAST       :: RIDX_GLOBALS
+
+
+/* type of numbers in Lua */
+Number :: distinct (f32 when size_of(uintptr) == 4 else f64)
+
+
+/* type for integer functions */
+Integer :: distinct (i32 when size_of(uintptr) == 4 else i64)
+
+/* unsigned integer type */
+Unsigned :: distinct (u32 when size_of(uintptr) == 4 else u64)
+
+/* type for continuation-function contexts */
+KContext :: distinct int
+
+
+/*
+** Type for C functions registered with Lua
+*/
+CFunction :: #type proc "c" (L: ^State) -> c.int
+
+/*
+** Type for continuation functions
+*/
+KFunction :: #type proc "c" (L: ^State, status: c.int, ctx: KContext) -> c.int
+
+
+/*
+** Type for functions that read/write blocks when loading/dumping Lua chunks
+*/
+Reader :: #type proc "c" (L: ^State, ud: rawptr, sz: ^c.size_t) -> cstring
+Writer :: #type proc "c" (L: ^State, p: rawptr, sz: ^c.size_t, ud: rawptr) -> c.int
+
+
+/*
+** Type for memory-allocation functions
+*/
+Alloc :: #type proc "c" (ud: rawptr, ptr: rawptr, osize, nsize: c.size_t) -> rawptr
+
+
+/*
+** Type for warning functions
+*/
+WarnFunction :: #type proc "c" (ud: rawptr, msg: rawptr, tocont: c.int)
+
+GCWhat :: enum c.int {
+	STOP       = 0,
+	RESTART    = 1,
+	COLLECT    = 2,
+	COUNT      = 3,
+	COUNTB     = 4,
+	STEP       = 5,
+	SETPAUSE   = 6,
+	SETSTEPMUL = 7,
+	ISRUNNING  = 9,
+	GEN        = 10,
+	INC        = 11,
+}
+GCSTOP       :: GCWhat.STOP
+GCRESTART    :: GCWhat.RESTART
+GCCOLLECT    :: GCWhat.COLLECT
+GCCOUNT      :: GCWhat.COUNT
+GCCOUNTB     :: GCWhat.COUNTB
+GCSTEP       :: GCWhat.STEP
+GCSETPAUSE   :: GCWhat.SETPAUSE
+GCSETSTEPMUL :: GCWhat.SETSTEPMUL
+GCISRUNNING  :: GCWhat.ISRUNNING
+GCGEN        :: GCWhat.GEN
+GCINC        :: GCWhat.INC
+
+
+
+/*
+** Event codes
+*/
+
+HookEvent :: enum c.int {
+	CALL     = 0,
+	RET      = 1,
+	LINE     = 2,
+	COUNT    = 3,
+	TAILCALL = 4,
+}
+HOOKCALL     :: HookEvent.CALL
+HOOKRET      :: HookEvent.RET
+HOOKLINE     :: HookEvent.LINE
+HOOKCOUNT    :: HookEvent.COUNT
+HOOKTAILCALL :: HookEvent.TAILCALL
+
+
+/*
+** Event masks
+*/
+HookMask :: distinct bit_set[HookEvent; c.int]
+MASKCALL  :: HookMask{.CALL}
+MASKRET   :: HookMask{.RET}
+MASKLINE  :: HookMask{.LINE}
+MASKCOUNT :: HookMask{.COUNT}
+
+/* activation record */
+Debug :: struct {
+	event:           HookEvent,
+	name:            cstring,                  /* (n) */
+	namewhat:        cstring,                  /* (n) 'global', 'local', 'field', 'method' */
+	what:            cstring,                  /* (S) 'Lua', 'C', 'main', 'tail' */
+	source:          cstring,                  /* (S) */
+	srclen:          c.size_t,                 /* (S) */
+	currentline:     c.int,                    /* (l) */
+	linedefined:     c.int,                    /* (S) */
+	lastlinedefined: c.int,                    /* (S) */
+	nups:            u8,                       /* (u) number of upvalues */
+	nparams:         u8,                       /* (u) number of parameters */
+	isvararg:        bool,                     /* (u) */
+	istailcall:      bool,                     /* (t) */
+	ftransfer:       u16,                      /* (r) index of first value transferred */
+	ntransfer:       u16,                      /* (r) number of transferred values */
+	short_src:       [IDSIZE]u8 `fmt:"s"`, /* (S) */
+	/* private part */
+	i_ci:            rawptr,                   /* active function */
+}
+
+
+/* Functions to be called by the debugger in specific events */
+Hook :: #type proc "c" (L: ^State, ar: ^Debug)
+
+
+State :: struct {} // opaque data type
+
+
+@(link_prefix="lua_")
+@(default_calling_convention="c")
+foreign lib {
+	/*
+	** RCS ident string
+	*/
+
+	ident: [^]u8 // TODO(bill): is this correct?
+
+
+	/*
+	** state manipulation
+	*/
+
+	newstate    :: proc(f: Alloc, ud: rawptr) -> ^State ---
+	close       :: proc(L: ^State) ---
+	newthread   :: proc(L: ^State) -> ^State ---
+	resetthread :: proc(L: ^State) -> Status ---
+
+	atpanic :: proc(L: ^State, panicf: CFunction) -> CFunction ---
+
+	version :: proc(L: ^State) -> Number ---
+
+
+	/*
+	** basic stack manipulation
+	*/
+
+	absindex   :: proc (L: ^State, idx: c.int) -> c.int ---
+	gettop     :: proc (L: ^State) -> c.int ---
+	settop     :: proc (L: ^State, idx: c.int) ---
+	pushvalue  :: proc (L: ^State, idx: c.int) ---
+	rotate     :: proc (L: ^State, idx: c.int, n: c.int) ---
+	copy       :: proc (L: ^State, fromidx, toidx: c.int) ---
+	checkstack :: proc (L: ^State, n: c.int) -> c.int ---
+
+	xmove :: proc(from, to: ^State, n: c.int) ---
+
+
+	/*
+	** access functions (stack -> C)
+	*/
+
+	isnumber    :: proc(L: ^State, idx: c.int) -> b32 ---
+	isstring    :: proc(L: ^State, idx: c.int) -> b32 ---
+	iscfunction :: proc(L: ^State, idx: c.int) -> b32 ---
+	isinteger   :: proc(L: ^State, idx: c.int) -> b32 ---
+	isuserdata  :: proc(L: ^State, idx: c.int) -> b32 ---
+	type        :: proc(L: ^State, idx: c.int) -> Type ---
+	typename    :: proc(L: ^State, tp: Type) -> cstring ---
+
+	@(link_name="lua_tonumberx")
+	tonumber    :: proc(L: ^State, idx: c.int, isnum: ^b32 = nil) -> Number ---
+	@(link_name="lua_tointegerx")
+	tointeger   :: proc(L: ^State, idx: c.int, isnum: ^b32 = nil) -> Integer ---
+	toboolean   :: proc(L: ^State, idx: c.int) -> b32 ---
+	tolstring   :: proc(L: ^State, idx: c.int, len: ^c.size_t) -> cstring ---
+	rawlen      :: proc(L: ^State, idx: c.int) -> Unsigned ---
+	tocfunction :: proc(L: ^State, idx: c.int) -> CFunction ---
+	touserdata  :: proc(L: ^State, idx: c.int) -> rawptr ---
+	tothread    :: proc(L: ^State, idx: c.int) -> ^State ---
+	topointer   :: proc(L: ^State, idx: c.int) -> rawptr ---
+
+	/*
+	** Comparison and arithmetic functions
+	*/
+
+	arith    :: proc(L: ^State, op: ArithOp) ---
+	rawequal :: proc(L: ^State, idx1, idx2: c.int) -> b32 ---
+	compare  :: proc(L: ^State, idx1, idx2: c.int, op: CompareOp) -> b32 ---
+
+	/*
+	** push functions (C -> stack)
+	*/
+
+	pushnil      :: proc(L: ^State) ---
+	pushnumber   :: proc(L: ^State, n: Number) ---
+	pushinteger  :: proc(L: ^State, n: Integer) ---
+	pushlstring  :: proc(L: ^State, s: cstring, len: c.size_t) -> cstring ---
+	pushstring   :: proc(L: ^State, s: cstring) -> cstring ---
+	pushvfstring :: proc(L: ^State, fmt: cstring, argp: c.va_list) -> cstring ---
+	pushfstring       :: proc(L: ^State, fmt: cstring, #c_vararg args: ..any) -> cstring ---
+	pushcclosure      :: proc(L: ^State, fn: CFunction, n: c.int) ---
+	pushboolean       :: proc(L: ^State, b: b32) ---
+	pushlightuserdata :: proc(L: ^State, p: rawptr) ---
+	pushthread        :: proc(L: ^State) -> Status ---
+
+	/*
+	** get functions (Lua -> stack)
+	*/
+
+	getglobal :: proc(L: ^State, name: cstring) -> c.int ---
+	gettable  :: proc(L: ^State, idx: c.int) -> c.int ---
+	getfield  :: proc(L: ^State, idx: c.int, k: cstring) -> c.int ---
+	geti      :: proc(L: ^State, idx: c.int, n: Integer) -> c.int ---
+	rawget    :: proc(L: ^State, idx: c.int) -> c.int ---
+	rawgeti   :: proc(L: ^State, idx: c.int, n: Integer) -> c.int ---
+	rawgetp   :: proc(L: ^State, idx: c.int, p: rawptr) -> c.int ---
+
+	createtable   :: proc(L: ^State, narr, nrec: c.int) ---
+	newuserdatauv :: proc(L: ^State, sz: c.size_t, nuvalue: c.int) -> rawptr ---
+	getmetatable  :: proc(L: ^State, objindex: c.int) -> c.int ---
+	getiuservalue :: proc(L: ^State, idx: c.int, n: c.int) -> c.int ---
+
+
+	/*
+	** set functions (stack -> Lua)
+	*/
+
+	setglobal     :: proc(L: ^State, name: cstring) ---
+	settable      :: proc(L: ^State, idx: c.int) ---
+	setfield      :: proc(L: ^State, idx: c.int, k: cstring) ---
+	seti          :: proc(L: ^State, idx: c.int, n: Integer) ---
+	rawset        :: proc(L: ^State, idx: c.int) ---
+	rawseti       :: proc(L: ^State, idx: c.int, n: Integer) ---
+	rawsetp       :: proc(L: ^State, idx: c.int, p: rawptr) ---
+	setmetatable  :: proc(L: ^State, objindex: c.int) -> c.int ---
+	setiuservalue :: proc(L: ^State, idx: c.int, n: c.int) -> c.int ---
+
+
+	/*
+	** 'load' and 'call' functions (load and run Lua code)
+	*/
+
+	@(link_name="lua_callk")
+	call :: proc(L: ^State, nargs, nresults: c.int,
+	             ctx: KContext = 0, k: KFunction = nil) ---
+
+	@(link_name="lua_pcallk")
+	pcall :: proc(L: ^State, nargs, nresults: c.int, errfunc: c.int,
+	              ctx: KContext = 0, k: KFunction = nil) -> c.int ---
+
+	load :: proc(L: ^State, reader: Reader, dt: rawptr,
+	             chunkname, mode: cstring) -> Status ---
+
+	dump :: proc(L: ^State, writer: Writer, data: rawptr, strip: b32) -> Status ---
+
+
+	/*
+	** coroutine functions
+	*/
+
+	@(link_name="lua_yieldk")
+	yield       :: proc(L: ^State, nresults: c.int, ctx: KContext = 0, k: KFunction = nil) -> Status ---
+	resume      :: proc(L: ^State, from: ^State, narg: c.int, nres: ^c.int) -> Status ---
+	status      :: proc(L: ^State) -> Status ---
+	isyieldable :: proc(L: ^State) -> b32 ---
+
+
+	/*
+	** Warning-related functions
+	*/
+
+	setwarnf :: proc(L: ^State, f: WarnFunction, ud: rawptr) ---
+	warning  :: proc(L: ^State, msg: string, tocont: b32) ---
+
+
+	/*
+	** garbage-collection function and options
+	*/
+
+
+
+	gc :: proc(L: ^State, what: GCWhat, #c_vararg args: ..any) -> c.int ---
+
+
+	/*
+	** miscellaneous functions
+	*/
+
+	error :: proc(L: ^State) -> Status ---
+
+	next :: proc(L: ^State, idx: c.int) -> c.int ---
+
+	concat :: proc(L: ^State, n: c.int) ---
+	len    :: proc(L: ^State, idx: c.int) ---
+
+	stringtonumber :: proc(L: ^State, s: cstring) -> c.size_t ---
+
+	getallocf :: proc(L: State, ud: ^rawptr) -> Alloc ---
+	setallocf :: proc(L: ^State, f: Alloc, ud: rawptr) ---
+
+	toclose :: proc(L: ^State, idx: c.int) ---
+
+	/*
+	** {======================================================================
+	** Debug API
+	** =======================================================================
+	*/
+
+	getstack   :: proc(L: ^State, level: c.int, ar: ^Debug) -> c.int ---
+	getinfo    :: proc(L: ^State, what: cstring, ar: ^Debug) -> c.int ---
+	getlocal   :: proc(L: ^State, ar: ^Debug, n: c.int) -> cstring ---
+	setlocal   :: proc(L: ^State, ar: ^Debug, n: c.int) -> cstring ---
+	getupvalue :: proc(L: ^State, funcindex: c.int, n: c.int) -> cstring ---
+	setupvalue :: proc(L: ^State, funcindex: c.int, n: c.int) -> cstring ---
+
+	upvalueid   :: proc(L: ^State, fidx, n: c.int) -> rawptr ---
+	upvaluejoin :: proc(L: ^State, fidx1, n1, fidx2, n2: c.int) ---
+
+	sethook :: proc(L: ^State, func: Hook, mask: HookMask, count: c.int) ---
+	gethook :: proc(L: ^State) -> Hook ---
+	gethookmask  :: proc(L: ^State) -> HookMask ---
+	gethookcount :: proc(L: ^State) -> c.int ---
+
+	setcstacklimit :: proc(L: ^State, limit: c.uint) -> c.int ---
+
+	/* }============================================================== */
+}
+
+
+
+/* version suffix for environment variable names */
+VERSUFFIX :: "_" + VERSION_MAJOR + "_" + VERSION_MINOR
+
+COLIBNAME   :: "coroutine"
+TABLIBNAME  :: "table"
+IOLIBNAME   :: "io"
+OSLIBNAME   :: "os"
+STRLIBNAME  :: "string"
+UTF8LIBNAME :: "utf8"
+MATHLIBNAME :: "math"
+DBLIBNAME   :: "debug"
+LOADLIBNAME :: "package"
+
+@(link_prefix="lua")
+@(default_calling_convention="c")
+foreign lib {
+	open_base      :: proc(L: ^State) -> c.int ---
+	open_coroutine :: proc(L: ^State) -> c.int ---
+	open_table     :: proc(L: ^State) -> c.int ---
+	open_io        :: proc(L: ^State) -> c.int ---
+	open_os        :: proc(L: ^State) -> c.int ---
+	open_string    :: proc(L: ^State) -> c.int ---
+	open_utf8      :: proc(L: ^State) -> c.int ---
+	open_math      :: proc(L: ^State) -> c.int ---
+	open_debug     :: proc(L: ^State) -> c.int ---
+	open_package   :: proc(L: ^State) -> c.int ---
+
+	/* open all previous libraries */
+
+	L_openlibs :: proc(L: ^State) ---
+}
+
+
+
+GNAME :: "_G"
+
+/* key, in the registry, for table of loaded modules */
+LOADED_TABLE :: "_LOADED"
+
+
+/* key, in the registry, for table of preloaded loaders */
+PRELOAD_TABLE :: "_PRELOAD"
+
+L_Reg :: struct {
+	name: cstring,
+  	func: CFunction,
+}
+
+L_NUMSIZES :: size_of(Integer)*16 + size_of(Number)
+
+
+/* predefined references */
+NOREF  :: -2
+REFNIL :: -1
+
+
+@(link_prefix="lua")
+@(default_calling_convention="c")
+foreign lib {
+	@(link_name="luaL_checkversion_")
+	L_checkversion :: proc(L: ^State, ver: Number = VERSION_NUM, sz: c.size_t = L_NUMSIZES) ---
+
+
+	L_getmetafield :: proc(L: ^State, obj: c.int, e: cstring) -> c.int ---
+	L_callmeta     :: proc(L: ^State, obj: c.int, e: cstring) -> c.int ---
+	@(link_name="luaL_tolstring")
+	L_tostring     :: proc(L: ^State, idx: c.int, len: ^c.size_t = nil) -> cstring ---
+	L_argerror     :: proc(L: ^State, arg: c.int, extramsg: cstring) -> c.int ---
+	L_typeerror    :: proc(L: ^State, arg: c.int, tname: cstring) -> c.int ---
+	@(link_name="luaL_checklstring")
+	L_checkstring  :: proc(L: ^State, arg: c.int, l: ^c.size_t = nil) -> cstring ---
+	@(link_name="luaL_optlstring")
+	L_optstring    :: proc(L: ^State, arg: c.int, def: cstring, l: ^c.size_t = nil) -> cstring ---
+	L_checknumber  :: proc(L: ^State, arg: c.int) -> Number ---
+	L_optnumber    :: proc(L: ^State, arg: c.int, def: Number) -> Number ---
+
+	L_checkinteger :: proc(L: ^State, arg: c.int) -> Integer ---
+	L_optinteger   :: proc(L: ^State, arg: c.int, def: Integer) -> Integer ---
+
+	L_checkstack :: proc(L: ^State, sz: c.int, msg: cstring) ---
+	L_checktype  :: proc(L: ^State, arg: c.int, t: c.int) ---
+	L_checkany   :: proc(L: ^State, arg: c.int) ---
+
+	L_newmetatable :: proc(L: ^State, tname: cstring) -> c.int ---
+	L_setmetatable :: proc(L: ^State, tname: cstring) ---
+	L_testudata    :: proc(L: ^State, ud: c.int, tname: cstring) -> rawptr ---
+	L_checkudata   :: proc(L: ^State, ud: c.int, tname: cstring) -> rawptr ---
+
+	L_where :: proc(L: ^State, lvl: c.int) ---
+	L_error :: proc(L: ^State, fmt: cstring, #c_vararg args: ..any) -> Status ---
+
+	L_checkoption :: proc(L: ^State, arg: c.int, def: cstring, lst: [^]cstring) -> c.int ---
+
+	L_fileresult :: proc(L: ^State, stat: c.int, fname: cstring) -> c.int ---
+	L_execresult :: proc(L: ^State, stat: c.int) -> c.int ---
+
+
+	L_ref   :: proc(L: ^State, t: c.int) -> c.int ---
+	L_unref :: proc(L: ^State, t: c.int, ref: c.int) ---
+
+	@(link_name="luaL_loadfilex")
+	L_loadfile :: proc (L: ^State, filename: cstring, mode: cstring = nil) -> Status ---
+
+	@(link_name="luaL_loadbufferx")
+	L_loadbuffer :: proc(L: ^State, buff: [^]byte, sz: c.size_t, name: cstring, mode: cstring = nil) -> Status ---
+	L_loadstring  :: proc(L: ^State, s: cstring) -> Status ---
+
+	L_newstate :: proc() -> ^State ---
+
+	L_len :: proc(L: ^State, idx: c.int) -> Integer ---
+
+	L_addgsub :: proc(b: ^L_Buffer, s, p, r: cstring) ---
+	L_gsub :: proc(L: ^State, s, p, r: cstring) -> cstring ---
+
+	L_setfuncs :: proc(L: ^State, l: [^]L_Reg, nup: c.int) ---
+
+	L_getsubtable :: proc(L: ^State, idx: c.int, fname: cstring) -> c.int ---
+
+	L_traceback   :: proc(L: ^State, L1: ^State, msg: cstring, level: c.int) ---
+
+	L_requiref    :: proc(L: ^State, modname: cstring, openf: CFunction, glb: c.int) ---
+
+}
+/*
+** {======================================================
+** Generic Buffer manipulation
+** =======================================================
+*/
+
+
+L_Buffer :: struct {
+	b:    [^]byte,  /* buffer address */
+	size: c.size_t, /* buffer size */
+	n:    c.size_t, /* number of characters in buffer */
+	L:    ^State,
+	init: struct #raw_union {
+		n: Number, u: f64, s: rawptr, i: Integer, l: c.long,
+		b: [L_BUFFERSIZE]byte,  /* initial buffer */
+	},
+}
+L_bufflen  :: #force_inline proc "c" (bf: ^L_Buffer) -> c.size_t {
+	return bf.n
+}
+L_buffaddr :: #force_inline proc "c" (bf: ^L_Buffer) -> [^]byte {
+	return bf.b
+}
+
+L_addchar :: #force_inline proc "c" (B: ^L_Buffer, c: byte) {
+	if B.n < B.size {
+		L_prepbuffsize(B, 1)
+	}
+	B.b[B.n] = c
+	B.n += 1
+}
+
+L_addsize :: #force_inline proc "c" (B: ^L_Buffer, s: c.size_t) -> c.size_t {
+	B.n += s
+	return B.n
+}
+
+L_buffsub :: #force_inline proc "c" (B: ^L_Buffer, s: c.size_t) -> c.size_t {
+	B.n -= s
+	return B.n
+}
+
+L_prepbuffer :: #force_inline proc "c" (B: ^L_Buffer) -> [^]byte {
+	return L_prepbuffsize(B, c.size_t(L_BUFFERSIZE))
+}
+
+
+@(link_prefix="lua")
+@(default_calling_convention="c")
+foreign lib {
+	L_buffinit       :: proc(L: ^State, B: ^L_Buffer) ---
+	L_prepbuffsize   :: proc(B: ^L_Buffer, sz: c.size_t) -> [^]byte ---
+	L_addlstring     :: proc(B: ^L_Buffer, s: cstring, l: c.size_t) ---
+	L_addstring      :: proc(B: ^L_Buffer, s: cstring) ---
+	L_addvalue       :: proc(B: ^L_Buffer) ---
+	L_pushresult     :: proc(B: ^L_Buffer) ---
+	L_pushresultsize :: proc(B: ^L_Buffer, sz: c.size_t) ---
+	L_buffinitsize   :: proc(L: ^State, B: ^L_Buffer, sz: c.size_t) -> [^]byte ---
+}
+
+
+/* }====================================================== */
+
+
+
+
+/*
+** {==============================================================
+** some useful macros
+** ===============================================================
+*/
+
+getextraspace :: #force_inline proc "c" (L: ^State) -> rawptr {
+	return rawptr(([^]byte)(L)[-EXTRASPACE:])
+}
+pop :: #force_inline proc "c" (L: ^State, n: c.int) {
+	settop(L, -n-1)
+}
+newtable :: #force_inline proc "c" (L: ^State) {
+	createtable(L, 0, 0)
+}
+register :: #force_inline proc "c" (L: ^State, n: cstring, f: CFunction) {
+	pushcfunction(L, f)
+	setglobal(L, n)
+}
+
+pushcfunction :: #force_inline proc "c" (L: ^State, f: CFunction) {
+	pushcclosure(L, f, 0)
+}
+
+
+isfunction      :: #force_inline proc "c" (L: ^State, n: c.int) -> bool { return type(L, n) == .FUNCTION      }
+istable         :: #force_inline proc "c" (L: ^State, n: c.int) -> bool { return type(L, n) == .TABLE         }
+islightuserdata :: #force_inline proc "c" (L: ^State, n: c.int) -> bool { return type(L, n) == .LIGHTUSERDATA }
+isnil           :: #force_inline proc "c" (L: ^State, n: c.int) -> bool { return type(L, n) == .NIL           }
+isboolean       :: #force_inline proc "c" (L: ^State, n: c.int) -> bool { return type(L, n) == .BOOLEAN       }
+isthread        :: #force_inline proc "c" (L: ^State, n: c.int) -> bool { return type(L, n) == .THREAD        }
+isnone          :: #force_inline proc "c" (L: ^State, n: c.int) -> bool { return type(L, n) == .NONE          }
+isnoneornil     :: #force_inline proc "c" (L: ^State, n: c.int) -> bool { return type(L, n) <= .NIL           }
+
+
+pushliteral :: pushstring
+pushglobaltable :: #force_inline proc "c" (L: ^State) {
+	rawgeti(L, REGISTRYINDEX, RIDX_GLOBALS)
+}
+tostring :: #force_inline proc "c" (L: ^State, i: c.int) -> cstring {
+	return tolstring(L, i, nil)
+}
+insert :: #force_inline proc "c" (L: ^State, idx: c.int) {
+	rotate(L, idx, 1)
+}
+remove :: #force_inline proc "c" (L: ^State, idx: c.int) {
+	rotate(L, idx, -1)
+	pop(L, 1)
+}
+replace :: #force_inline proc "c" (L: ^State, idx: c.int) {
+	copy(L, -1, idx)
+	pop(L, 1)
+}
+
+L_newlibtable :: #force_inline proc "c" (L: ^State, l: []L_Reg) {
+	createtable(L, 0, c.int(builtin.len(l) - 1))
+}
+
+L_newlib :: proc(L: ^State, l: []L_Reg) {
+	L_checkversion(L)
+	L_newlibtable(L, l)
+	L_setfuncs(L, raw_data(l), 0)
+}
+
+L_argcheck :: #force_inline proc "c" (L: ^State, cond: bool, arg: c.int, extramsg: cstring) {
+	if cond {
+		L_argerror(L, arg, extramsg)
+	}
+}
+
+L_argexpected :: #force_inline proc "c" (L: ^State, cond: bool, arg: c.int, tname: cstring) {
+	if cond {
+		L_typeerror(L, arg, tname)
+	}
+}
+
+L_typename :: #force_inline proc "c" (L: ^State, i: c.int) -> cstring {
+	return typename(L, type(L, i))
+}
+L_dofile :: #force_inline proc "c" (L: ^State, s: cstring) -> c.int {
+	err := L_loadfile(L, s)
+	return pcall(L, 0, MULTRET, 0) if err == nil else c.int(err)
+}
+L_dostring :: #force_inline proc "c" (L: ^State, s: cstring) -> c.int {
+	err := L_loadstring(L, s)
+	return pcall(L, 0, MULTRET, 0) if err == nil else c.int(err)
+}
+L_getmetatable :: #force_inline proc "c" (L: ^State, n: cstring) -> c.int {
+	return getfield(L, REGISTRYINDEX, n)
+}
+L_opt :: #force_inline proc "c" (L: ^State, f: $F, n: c.int, d: $T) -> T where intrinsics.type_is_proc(F) {
+	return d if isnoneornil(L, n) else f(L, n)
+}
+
+
+
+/* push the value used to represent failure/error */
+pushfail :: pushnil
+
+
+/* }============================================================== */
+
+
+/*
+** {==============================================================
+** compatibility macros
+** ===============================================================
+*/
+
+newuserdata  :: #force_inline proc "c" (L: ^State, s: c.size_t) -> rawptr {
+	return newuserdatauv(L, s, 1)
+}
+getuservalue :: #force_inline proc "c" (L: ^State, idx: c.int) -> c.int {
+	return getiuservalue(L, idx, 1)
+}
+setuservalue :: #force_inline proc "c" (L: ^State, idx: c.int) -> c.int {
+	return setiuservalue(L, idx, 1)
+}

BIN
vendor/lua/5.4/windows/lua54.dll


BIN
vendor/lua/5.4/windows/lua54dll.lib


+ 6 - 0
vendor/lua/LICENSE

@@ -0,0 +1,6 @@
+Copyright © 1994–2023 Lua.org, PUC-Rio.
+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.

+ 12 - 0
vendor/lua/README.md

@@ -0,0 +1,12 @@
+# Lua in Odin
+
+```odin
+import lua "vendor:lua/5.4" // or whatever version you want
+```
+
+Lua packages
+
+* `vendor:lua/5.1` (version 5.1.5)
+* `vendor:lua/5.2` (version 5.2.4)
+* `vendor:lua/5.3` (version 5.3.6)
+* `vendor:lua/5.4` (version 5.4.2)

+ 34 - 29
vendor/zlib/zlib.odin

@@ -2,8 +2,13 @@ package vendor_zlib
 
 import "core:c"
 
-when ODIN_OS == .Windows { foreign import zlib "libz.lib" }
-when ODIN_OS == .Linux   { foreign import zlib "system:z" }
+when ODIN_OS == .Windows {
+	foreign import zlib "libz.lib"
+} else when ODIN_OS == .Linux {
+	foreign import zlib "system:z"
+} else {
+	foreign import zlib "system:z"
+}
 
 VERSION         :: "1.2.12"
 VERNUM          :: 0x12c0
@@ -41,39 +46,39 @@ gzFile_s :: struct {
 gzFile :: ^gzFile_s
 
 z_stream_s :: struct {
-    next_in:   ^Bytef,
-    avail_in:  uInt,
-    total_in:  uLong,
-    next_out:  ^Bytef,
-    avail_out: uInt,
-    total_out: uLong,
-    msg:       [^]c.char,
-    state:     rawptr,
-    zalloc:    alloc_func,
-    zfree:     free_func,
-    opaque:    voidpf,
-    data_type: c.int,
-    adler:     uLong,
-    reserved:  uLong,
+	next_in:   ^Bytef,
+	avail_in:  uInt,
+	total_in:  uLong,
+	next_out:  ^Bytef,
+	avail_out: uInt,
+	total_out: uLong,
+	msg:       [^]c.char,
+	state:     rawptr,
+	zalloc:    alloc_func,
+	zfree:     free_func,
+	opaque:    voidpf,
+	data_type: c.int,
+	adler:     uLong,
+	reserved:  uLong,
 }
 
 z_stream  :: z_stream_s
 z_streamp :: ^z_stream
 
 gz_header_s :: struct {
-    text:      c.int,
-    time:      uLong,
-    xflags:    c.int,
-    os:        c.int,
-    extra:     [^]Bytef,
-    extra_len: uInt,
-    extra_max: uInt,
-    name:      [^]Bytef,
-    name_max:  uInt,
-    comment:   [^]Bytef,
-    comm_max:  uInt,
-    hcrc:      c.int,
-    done:      c.int,
+	text:      c.int,
+	time:      uLong,
+	xflags:    c.int,
+	os:        c.int,
+	extra:     [^]Bytef,
+	extra_len: uInt,
+	extra_max: uInt,
+	name:      [^]Bytef,
+	name_max:  uInt,
+	comment:   [^]Bytef,
+	comm_max:  uInt,
+	hcrc:      c.int,
+	done:      c.int,
 }
 
 gz_header  :: gz_header_s

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác