Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
a492a31e
Unverified
Commit
a492a31e
authored
Feb 25, 2024
by
Gregor Hartmann
Committed by
GitHub
Feb 25, 2024
Browse files
Add modules struct, bit, color_utils and sjson to luac.cross (#3230)
parent
3d09b747
Changes
14
Hide whitespace changes
Inline
Side-by-side
app/lua/linit.c
View file @
a492a31e
...
...
@@ -59,22 +59,63 @@ extern LROT_TABLE(math);
LROT_FUNCENTRY( debug, luaopen_debug )
#if defined(LUA_CROSS_COMPILER)
extern
LROT_TABLE
(
base_func
);
#define LUAC_MODULE(map) \
LUALIB_API LROT_TABLE(map);
#define LUAC_MODULE_INIT(map, initfunc) \
LUAC_MODULE(map);\
LUALIB_API int initfunc(lua_State *L);
#ifndef __MINGW32__
LUAC_MODULE
(
thislib
)
// module struct
LUAC_MODULE
(
bit
)
LUAC_MODULE
(
color_utils
)
LUAC_MODULE_INIT
(
sjson
,
luaopen_sjson
)
LUAC_MODULE
(
pipe
)
#ifndef _MSC_VER
LUAC_MODULE_INIT
(
pixbuf
,
luaopen_pixbuf
)
#endif
#endif
LUAC_MODULE
(
base_func
);
LROT_BEGIN
(
rotables_meta
,
NULL
,
LROT_MASK_INDEX
)
LROT_TABENTRY
(
__index
,
base_func
)
LROT_END
(
rotables_meta
,
NULL
,
LROT_MASK_INDEX
)
extern
LROT_TAB
LE
(
oslib
);
extern
LROT_TAB
LE
(
iolib
);
LUAC_MODU
LE
(
oslib
);
LUAC_MODU
LE
(
iolib
);
LROT_BEGIN
(
rotables
,
LROT_TABLEREF
(
rotables_meta
),
0
)
LROT_ROM_ENTRIES
LROT_TABENTRY
(
os
,
oslib
)
LROT_TABENTRY
(
io
,
iolib
)
#ifndef __MINGW32__
// modules
LROT_TABENTRY
(
struct
,
thislib
)
LROT_TABENTRY
(
bit
,
bit
)
LROT_TABENTRY
(
color_utils
,
color_utils
)
LROT_TABENTRY
(
sjson
,
sjson
)
LROT_TABENTRY
(
pipe
,
pipe
)
#ifndef _MSC_VER
LROT_TABENTRY
(
pixbuf
,
pixbuf
)
#endif
#endif
LROT_END
(
rotables
,
LROT_TABLEREF
(
rotables_meta
),
0
)
LROT_BEGIN
(
lua_libs
,
NULL
,
0
)
LROT_LIB_ENTRIES
LROT_FUNCENTRY
(
io
,
luaopen_io
)
#ifndef __MINGW32__
// modules
LROT_FUNCENTRY
(
struct
,
NULL
)
LROT_FUNCENTRY
(
bit
,
NULL
)
LROT_FUNCENTRY
(
color_utils
,
NULL
)
LROT_FUNCENTRY
(
sjson
,
luaopen_sjson
)
LROT_FUNCENTRY
(
pipe
,
NULL
)
#ifndef _MSC_VER
LROT_FUNCENTRY
(
pixbuf
,
luaopen_pixbuf
)
#endif
#endif
LROT_END
(
lua_libs
,
NULL
,
0
)
#else
...
...
app/lua/luac_cross/Makefile
View file @
a492a31e
...
...
@@ -8,7 +8,7 @@
summary
?=
@true
CCFLAGS
:=
-I
.
-I
..
-I
../../include
-I
../../uzlib
CCFLAGS
:=
-I
.
-I
..
-I
../../include
-I
../../uzlib
-I
../..
LDFLAGS
:=
-L
$(SDK_DIR)
/lib
-L
$(SDK_DIR)
/ld
-lm
-ldl
-Wl
,-Map
=
mapfile
CCFLAGS
+=
-Wall
...
...
@@ -59,12 +59,15 @@ LUASRC := lapi.c lauxlib.c lbaselib.c lcode.c ldblib.c ldebug.c
lstate.c lstring.c lstrlib.c ltable.c ltablib.c
\
ltm.c lundump.c lvm.c lzio.c lnodemcu.c
UZSRC
:=
uzlib_deflate.c crc32.c
SJSONSRC
:=
jsonsl.c
MODSRC
:=
struct.c bit.c color_utils.c sjson.c pipe.c pixbuf.c
#bloom.c crypto.c encoder.c (file.c)
#
# This relies on the files being unique on the vpath
#
SRC
:=
$(LUACSRC)
$(LUASRC)
$(UZSRC)
vpath %.c .
:
..:../../libc:../../uzlib
SRC
:=
$(LUACSRC)
$(LUASRC)
$(UZSRC)
$(MODSRC)
$(SJSONSRC)
vpath %.c .
:
..:../../libc:../../uzlib
:../../modules:../../sjson
ODIR
:=
.output/
$(TARGET)
/
$(FLAVOR)
/obj
...
...
app/lua/luac_cross/luac.c
View file @
a492a31e
...
...
@@ -291,8 +291,7 @@ static int pmain(lua_State* L)
{
luaL_openlibs
(
L
);
if
(
luaL_loadfile
(
L
,
execute
)
!=
0
)
fatal
(
lua_tostring
(
L
,
-
1
));
lua_pushstring
(
L
,
execute
);
if
(
lua_pcall
(
L
,
1
,
1
,
0
))
fatal
(
lua_tostring
(
L
,
-
1
));
if
(
lua_pcall
(
L
,
0
,
1
,
0
))
fatal
(
lua_tostring
(
L
,
-
1
));
if
(
!
lua_isfunction
(
L
,
-
1
))
{
lua_pop
(
L
,
1
);
...
...
app/lua53/host/Makefile
View file @
a492a31e
...
...
@@ -6,7 +6,7 @@
#
.NOTPARALLEL
:
CCFLAGS
:=
-I
.
-I
..
-I
../../include
-I
../../uzlib
CCFLAGS
:=
-I
.
-I
..
-I
../../include
-I
../../uzlib
-I
../..
LDFLAGS
:=
-L
$(SDK_DIR)
/lib
-L
$(SDK_DIR)
/ld
-lm
-ldl
-Wl
,-Map
=
mapfile
CCFLAGS
+=
-Wall
...
...
@@ -55,6 +55,9 @@ LUASRC := lapi.c lauxlib.c lbaselib.c lcode.c lcorolib.c lctype.c
ltable.c ltablib.c ltm.c lundump.c lutf8lib.c lvm.c
\
lzio.c
UZSRC
:=
uzlib_deflate.c crc32.c
SJSONSRC
:=
jsonsl.c
MODSRC
:=
struct.c bit.c color_utils.c sjson.c pipe.c pixbuf.c
#bloom.c crypto.c encoder.c (file.c)
TEST
?=
ifeq
("$(TEST)","1")
...
...
@@ -65,8 +68,8 @@ endif # $(TEST)==1
#
# This relies on the files being unique on the vpath
#
SRC
:=
$(LUACSRC)
$(LUASRC)
$(UZSRC)
vpath %.c .
:
..:../../libc:../../uzlib
SRC
:=
$(LUACSRC)
$(LUASRC)
$(UZSRC)
$(MODSRC)
$(SJSONSRC)
vpath %.c .
:
..:../../libc:../../uzlib
:../../modules:../../sjson
ODIR
:=
.output/
$(TARGET)
/
$(FLAVOR)
/obj
...
...
app/lua53/linit.c
View file @
a492a31e
...
...
@@ -72,9 +72,22 @@ extern LROT_TABLE(utf8);
#if defined(LUA_CROSS_COMPILER)
/* _G __index -> rotables __index -> base_func */
extern
LROT_TABLE
(
rotables_meta
);
extern
LROT_TABLE
(
base_func
);
#define LUAC_MODULE(map) \
LUALIB_API LROT_TABLE(map);
#define LUAC_MODULE_INIT(map, initfunc) \
LUAC_MODULE(map);\
LUALIB_API int initfunc(lua_State *L);
LUAC_MODULE
(
thislib
)
// module struct
LUAC_MODULE
(
bit
)
LUAC_MODULE
(
color_utils
)
LUAC_MODULE_INIT
(
sjson
,
luaopen_sjson
)
LUAC_MODULE
(
pipe
)
LUAC_MODULE_INIT
(
pixbuf
,
luaopen_pixbuf
)
LUAC_MODULE
(
rotables_meta
);
LUAC_MODULE
(
base_func
);
LROT_BEGIN
(
rotables_meta
,
NULL
,
LROT_MASK_INDEX
)
LROT_TABENTRY
(
__index
,
base_func
)
LROT_END
(
rotables_meta
,
NULL
,
LROT_MASK_INDEX
)
...
...
@@ -82,12 +95,26 @@ LROT_END(rotables_meta, NULL, LROT_MASK_INDEX)
LROT_BEGIN
(
rotables
,
LROT_TABLEREF
(
rotables_meta
),
0
)
LROT_TABENTRY
(
_G
,
base_func
)
LROT_ROM_ENTRIES
// modules
LROT_TABENTRY
(
struct
,
thislib
)
LROT_TABENTRY
(
bit
,
bit
)
LROT_TABENTRY
(
color_utils
,
color_utils
)
LROT_TABENTRY
(
sjson
,
sjson
)
LROT_TABENTRY
(
pipe
,
pipe
)
LROT_TABENTRY
(
pixbuf
,
pixbuf
)
LROT_END
(
rotables
,
LROT_TABLEREF
(
rotables_meta
),
0
)
LROT_BEGIN
(
lua_libs
,
NULL
,
0
)
LROT_LIB_ENTRIES
LROT_FUNCENTRY
(
io
,
luaopen_io
)
LROT_FUNCENTRY
(
os
,
luaopen_os
)
// modules
LROT_FUNCENTRY
(
struct
,
NULL
)
LROT_FUNCENTRY
(
bit
,
NULL
)
LROT_FUNCENTRY
(
color_utils
,
NULL
)
LROT_FUNCENTRY
(
sjson
,
luaopen_sjson
)
LROT_FUNCENTRY
(
pipe
,
NULL
)
LROT_FUNCENTRY
(
pixbuf
,
luaopen_pixbuf
)
LROT_END
(
lua_libs
,
NULL
,
0
)
#else
/* LUA_USE_ESP */
...
...
app/modules/color_utils.c
View file @
a492a31e
#include "module.h"
#include "lauxlib.h"
#include "lmem.h"
#include "platform.h"
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include "user_interface.h"
#include "osapi.h"
#include "color_utils.h"
...
...
app/modules/color_utils.h
View file @
a492a31e
#ifndef APP_MODULES_COLOR_UTILS_H_
#define APP_MODULES_COLOR_UTILS_H_
#include "module.h"
#include "lauxlib.h"
#include "lmem.h"
#include "platform.h"
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include "user_interface.h"
#include "osapi.h"
#include "lnodemcu.h"
/**
* Convert hsv to grb
...
...
app/modules/pipe.c
View file @
a492a31e
...
...
@@ -51,7 +51,6 @@
#include "module.h"
#include "lauxlib.h"
#include <string.h>
#include "platform.h"
#define INVALID_LEN ((unsigned)-1)
...
...
@@ -226,11 +225,11 @@ int pipe_create(lua_State *L) {
if
(
!
lua_isnil
(
L
,
1
))
{
luaL_checktype
(
L
,
1
,
LUA_TFUNCTION
);
/* non-nil arg1 must be a function */
if
(
lua_isnil
(
L
,
2
))
{
prio
=
PLATFORM_TASK_PRIORITY
_MEDIUM
;
prio
=
LUA_TASK
_MEDIUM
;
}
else
{
prio
=
(
int
)
lua_tointeger
(
L
,
2
);
luaL_argcheck
(
L
,
prio
>=
PLATFORM_TASK_PRIORITY
_LOW
&&
prio
<=
PLATFORM_TASK_PRIORITY
_HIGH
,
2
,
luaL_argcheck
(
L
,
prio
>=
LUA_TASK
_LOW
&&
prio
<=
LUA_TASK
_HIGH
,
2
,
"invalid priority"
);
}
}
...
...
lua_modules/liquidcrystal/lc-gpio4bit.lua
View file @
a492a31e
local
gpio
,
bit
=
gpio
,
bit
--luacheck: read globals gpio bit
local
gpio
,
bit
=
gpio
,
bit
return
function
(
bus_args
)
local
rs
=
bus_args
.
rs
or
0
...
...
lua_modules/liquidcrystal/lc-gpio8bit.lua
View file @
a492a31e
local
gpio
,
bit
=
gpio
,
bit
--luacheck: read globals gpio bit
local
gpio
,
bit
=
gpio
,
bit
return
function
(
bus_args
)
local
rs
=
bus_args
.
rs
or
0
...
...
lua_modules/liquidcrystal/lc-i2c4bit.lua
View file @
a492a31e
local
i2c
,
bit
=
i2c
,
bit
--luacheck: read globals i2c bit
local
i2c
,
bit
=
i2c
,
bit
return
function
(
bus_args
)
local
busid
=
bus_args
.
id
or
0
...
...
lua_modules/liquidcrystal/liquidcrystal.lua
View file @
a492a31e
local
bit
=
bit
--luacheck: read globals bit
local
bit
=
bit
-- metatable
local
LiquidCrystal
=
{}
LiquidCrystal
.
__index
=
LiquidCrystal
...
...
msvc/luac-cross/luac-cross.vcxproj
View file @
a492a31e
...
...
@@ -104,7 +104,7 @@
<ConformanceMode>
true
</ConformanceMode>
<PrecompiledHeaderFile>
pch.h
</PrecompiledHeaderFile>
<RuntimeLibrary>
MultiThreadedDebug
</RuntimeLibrary>
<AdditionalIncludeDirectories>
$(ProjectDir)\..\..\app\lua;$(ProjectDir)\..\..\app\libc;$(ProjectDir)\..\..\app\include;$(ProjectDir)\..\..\app\uzlib
</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>
$(ProjectDir)\..\..\app\lua;$(ProjectDir)\..\..\app\libc;$(ProjectDir)\..\..\app\include;$(ProjectDir)\..\..\app\uzlib
;$(ProjectDir)\..\..\app
</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>
Console
</SubSystem>
...
...
@@ -123,7 +123,7 @@
<ConformanceMode>
true
</ConformanceMode>
<PrecompiledHeaderFile>
pch.h
</PrecompiledHeaderFile>
<RuntimeLibrary>
MultiThreadedDebug
</RuntimeLibrary>
<AdditionalIncludeDirectories>
$(ProjectDir)\..\..\app\lua;$(ProjectDir)\..\..\app\libc;$(ProjectDir)\..\..\app\include;$(ProjectDir)\..\..\app\uzlib
</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>
$(ProjectDir)\..\..\app\lua;$(ProjectDir)\..\..\app\libc;$(ProjectDir)\..\..\app\include;$(ProjectDir)\..\..\app\uzlib
;$(ProjectDir)\..\..\app
</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>
Console
</SubSystem>
...
...
@@ -144,7 +144,7 @@
<ConformanceMode>
true
</ConformanceMode>
<PrecompiledHeaderFile>
pch.h
</PrecompiledHeaderFile>
<RuntimeLibrary>
MultiThreaded
</RuntimeLibrary>
<AdditionalIncludeDirectories>
$(ProjectDir)\..\..\app\lua;$(ProjectDir)\..\..\app\libc;$(ProjectDir)\..\..\app\include;$(ProjectDir)\..\..\app\uzlib
</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>
$(ProjectDir)\..\..\app\lua;$(ProjectDir)\..\..\app\libc;$(ProjectDir)\..\..\app\include;$(ProjectDir)\..\..\app\uzlib
;$(ProjectDir)\..\..\app
</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>
Console
</SubSystem>
...
...
@@ -167,7 +167,7 @@
<ConformanceMode>
true
</ConformanceMode>
<PrecompiledHeaderFile>
pch.h
</PrecompiledHeaderFile>
<RuntimeLibrary>
MultiThreaded
</RuntimeLibrary>
<AdditionalIncludeDirectories>
$(ProjectDir)\..\..\app\lua;$(ProjectDir)\..\..\app\libc;$(ProjectDir)\..\..\app\include;$(ProjectDir)\..\..\app\uzlib
</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>
$(ProjectDir)\..\..\app\lua;$(ProjectDir)\..\..\app\libc;$(ProjectDir)\..\..\app\include;$(ProjectDir)\..\..\app\uzlib
;$(ProjectDir)\..\..\app
</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>
Console
</SubSystem>
...
...
@@ -212,6 +212,12 @@
<ClCompile
Include=
"..\..\app\lua\lundump.c"
/>
<ClCompile
Include=
"..\..\app\lua\lvm.c"
/>
<ClCompile
Include=
"..\..\app\lua\lzio.c"
/>
<ClCompile
Include=
"..\..\app\modules\bit.c"
/>
<ClCompile
Include=
"..\..\app\modules\color_utils.c"
/>
<ClCompile
Include=
"..\..\app\modules\sjson.c"
/>
<ClCompile
Include=
"..\..\app\modules\pipe.c"
/>
<ClCompile
Include=
"..\..\app\modules\struct.c"
/>
<ClCompile
Include=
"..\..\app\sjson\jsonsl.c"
/>
<ClCompile
Include=
"..\..\app\uzlib\crc32.c"
/>
<ClCompile
Include=
"..\..\app\uzlib\uzlib_deflate.c"
/>
</ItemGroup>
...
...
@@ -246,6 +252,9 @@
<ClInclude
Include=
"..\..\app\lua\lundump.h"
/>
<ClInclude
Include=
"..\..\app\lua\lvm.h"
/>
<ClInclude
Include=
"..\..\app\lua\lzio.h"
/>
<ClInclude
Include=
"..\..\app\sjson\jsonsl.h"
/>
<ClInclude
Include=
"..\..\app\sjson\json_config.h"
/>
<ClInclude
Include=
"..\..\app\sjson\memcompat.h"
/>
<ClInclude
Include=
"..\..\app\uzlib\uzlib.h"
/>
</ItemGroup>
<Import
Project=
"$(VCTargetsPath)\Microsoft.Cpp.targets"
/>
...
...
msvc/luac-cross/luac-cross.vcxproj.filters
View file @
a492a31e
<?xml version="1.0" encoding="utf-8"?>
<Project
ToolsVersion=
"4.0"
xmlns=
"http://schemas.microsoft.com/developer/msbuild/2003"
>
<ItemGroup>
<Filter
Include=
"Source Files"
>
<UniqueIdentifier>
{4FC737F1-C7A5-4376-A066-2A32D752A2FF}
</UniqueIdentifier>
<Extensions>
cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
</Extensions>
</Filter>
<Filter
Include=
"Header Files"
>
<UniqueIdentifier>
{93995380-89BD-4b04-88EB-625FBE52EBFB}
</UniqueIdentifier>
<Extensions>
h;hh;hpp;hxx;hm;inl;inc;ipp;xsd
</Extensions>
...
...
@@ -28,6 +24,12 @@
<Filter
Include=
"app\include"
>
<UniqueIdentifier>
{439d70e8-0091-42d2-919f-7e710de3867c}
</UniqueIdentifier>
</Filter>
<Filter
Include=
"app\modules"
>
<UniqueIdentifier>
{3b52796e-cc0c-458d-bb40-d416bb18d49d}
</UniqueIdentifier>
</Filter>
<Filter
Include=
"app\sjson"
>
<UniqueIdentifier>
{fcd87750-9084-4308-bb91-bd4d44d29a90}
</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile
Include=
"..\..\app\uzlib\crc32.c"
>
...
...
@@ -132,6 +134,24 @@
<ClCompile
Include=
"..\..\app\lua\lzio.c"
>
<Filter>
app\lua
</Filter>
</ClCompile>
<ClCompile
Include=
"..\..\app\modules\struct.c"
>
<Filter>
app\modules
</Filter>
</ClCompile>
<ClCompile
Include=
"..\..\app\modules\bit.c"
>
<Filter>
app\modules
</Filter>
</ClCompile>
<ClCompile
Include=
"..\..\app\modules\color_utils.c"
>
<Filter>
app\modules
</Filter>
</ClCompile>
<ClCompile
Include=
"..\..\app\modules\sjson.c"
>
<Filter>
app\modules
</Filter>
</ClCompile>
<ClCompile
Include=
"..\..\app\modules\pipe.c"
>
<Filter>
app\modules
</Filter>
</ClCompile>
<ClCompile
Include=
"..\..\app\sjson\jsonsl.c"
>
<Filter>
app\sjson
</Filter>
</ClCompile>
<ClCompile
Include=
"..\..\app\lua\lnodemcu.c"
>
<Filter>
app\lua
</Filter>
</ClCompile>
...
...
@@ -230,5 +250,14 @@
<ClInclude
Include=
"..\..\app\include\user_modules.h"
>
<Filter>
app\include
</Filter>
</ClInclude>
<ClInclude
Include=
"..\..\app\sjson\json_config.h"
>
<Filter>
app\sjson
</Filter>
</ClInclude>
<ClInclude
Include=
"..\..\app\sjson\jsonsl.h"
>
<Filter>
app\sjson
</Filter>
</ClInclude>
<ClInclude
Include=
"..\..\app\sjson\memcompat.h"
>
<Filter>
app\sjson
</Filter>
</ClInclude>
</ItemGroup>
</Project>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment