Compare commits

...

17 Commits

Author SHA1 Message Date
22f7d00894 Merge pull request 'Use 'r' instead of 'nil' for io.open' (#1) from fix-io.open-type-mismatch into remove-dlls-from-repo
Reviewed-on: Auios/BlockLua#1
2025-10-05 14:43:20 -04:00
c9e7a9d672 Merge branch 'remove-dlls-from-repo' into fix-io.open-type-mismatch 2025-10-05 14:42:45 -04:00
6c8b2ce0d3 adjust output dir 2025-10-05 14:40:43 -04:00
ef809a3a5a Update .gitignore 2025-10-05 14:36:38 -04:00
a969d5365d Update libts-lua.lua 2025-10-05 14:28:57 -04:00
93472e7704 ocd 2025-10-05 14:27:07 -04:00
9550ba8c05 remove dlls from repo 2025-10-05 14:26:57 -04:00
2140b74d0b Merge remote-tracking branch 'upstream/master' 2025-10-05 14:00:18 -04:00
62967891c7 Updated dlls after merges 2025-10-03 15:09:34 -04:00
e0f5b03224 Merge branch 'fix-deprecated-use-of-getn' 2025-10-03 15:08:09 -04:00
015f461d9e Merge branch '_bllua_schedule_callback-checks-id-is-nil-first' 2025-10-03 15:08:06 -04:00
67118ab26c use @diagnostic comments to reduce warning spam in console 2025-10-03 15:03:44 -04:00
7db1fc75a9 address lua warning where id could be `nil 2025-10-03 15:02:09 -04:00
c017e14084 fix deprecated use of getn 2025-10-03 14:58:28 -04:00
74745108b6 typo fix: use table.empty instead of table.isempty 2025-10-03 14:42:42 -04:00
ac2a1ef1ba recreate .dlls 2025-10-03 14:42:42 -04:00
279361f241 compile.sh 2025-10-03 14:42:30 -04:00
5 changed files with 51 additions and 9 deletions

3
.gitignore vendored
View File

@@ -1,2 +1,3 @@
.*
!.gitignore
.*
build/

Binary file not shown.

View File

@@ -5,12 +5,13 @@ set buildargs=-Wall -Werror -m32 -shared -Isrc -Iinc/tsfuncs -Iinc/lua -lpsapi -
echo on
g++ src/bllua4.cpp %buildargs% -o BlockLua.dll
@rem g++ -DBLLUA_UNSAFE src/bllua4.cpp %buildargs% -o BlockLua-Unsafe.dll
set outdir=build
if not exist %outdir% mkdir %outdir%
g++ src/bllua4.cpp %buildargs% -o %outdir%\BlockLua.dll
@rem g++ -DBLLUA_UNSAFE src/bllua4.cpp %buildargs% -o %outdir%\BlockLua-Unsafe.dll
@echo off
rem objdump -d BlockLua.dll > BlockLua.dll.dump.txt
rem objdump -d BlockLua-Unsafe.dll > BlockLua-Unsafe.dll.dump.txt
pause
rem objdump -d %outdir%\BlockLua.dll > %outdir%\BlockLua.dll.dump.txt
rem objdump -d %outdir%\BlockLua-Unsafe.dll > %outdir%\BlockLua-Unsafe.dll.dump.txt

29
compile.sh Normal file
View File

@@ -0,0 +1,29 @@
#!/bin/bash
#
# BlockLua build script for MSYS2/MinGW32
#
# Usage:
# 1. Open the MSYS2 MinGW32 shell.
# 2. Install the required compiler with:
# pacman -S mingw-w64-i686-gcc
# 3. Run this script:
# ./compile.sh
#
# If your MSYS2 installation is not on C:, adjust the g++ path below as needed.
set -e
cd "$(dirname "$0")"
buildargs="-Wall -Werror -m32 -shared -Isrc -Iinc/tsfuncs -Iinc/lua -lpsapi -L. -llua5.1 -static-libgcc -static-libstdc++"
outdir="build"
mkdir -p "$outdir"
set -x
/mingw32/bin/g++ src/bllua4.cpp $buildargs -o "$outdir"/BlockLua.dll && /mingw32/bin/g++ -DBLLUA_UNSAFE src/bllua4.cpp $buildargs -o "$outdir"/BlockLua-Unsafe.dll
set +x
# objdump -d "$outdir"/BlockLua.dll > "$outdir"/BlockLua.dll.dump.txt
# objdump -d "$outdir"/BlockLua-Unsafe.dll > "$outdir"/BlockLua-Unsafe.dll.dump.txt

View File

@@ -7,7 +7,11 @@ ts = _bllua_ts
-- Provide limited OS functions
os = os or {}
---@diagnostic disable-next-line: duplicate-set-field
function os.time() return math.floor(tonumber(_bllua_ts.call('getSimTime'))/1000) end
---@diagnostic disable-next-line: duplicate-set-field
function os.clock() return tonumber(_bllua_ts.call('getSimTime'))/1000 end
-- Virtual file class, emulating a file object as returned by io.open
@@ -106,9 +110,10 @@ local function io_open_absolute(fn, mode)
end
io = io or {}
---@diagnostic disable-next-line: duplicate-set-field
function io.open(fn, mode, errn)
errn = errn or 1
-- try to open the file with relative path, otherwise use absolute path
local curfn = debug.getfilename(errn + 1) or _bllua_ts.getvar('Con::File')
if curfn == '' then curfn = nil end
@@ -126,13 +131,19 @@ function io.open(fn, mode, errn)
return fi, err, fn
end
end
---@diagnostic disable-next-line: duplicate-set-field
function io.lines(fn)
local fi, err, fn2 = io.open(fn, nil, 2)
local fi, err, fn2 = io.open(fn, 'r', 2)
if not fi then error('Error opening file \''..fn2..'\': '..err, 2) end
return fi:lines()
end
---@diagnostic disable-next-line: duplicate-set-field
function io.type(f)
---@diagnostic disable-next-line: undefined-field
if type(f)=='table' and f._is_file then
---@diagnostic disable-next-line: undefined-field
return f._is_open and 'file' or 'closed file'
else
return _bllua_io_type(f)