mirror of
https://github.com/nodemcu/nodemcu-firmware.git
synced 2025-01-16 20:52:57 +08:00
commit
bf3463d0dc
66
Makefile
66
Makefile
@ -4,12 +4,66 @@ ifndef PDIR
|
|||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
AR = xt-ar
|
#############################################################
|
||||||
CC = xt-xcc
|
# Select compile
|
||||||
NM = xt-nm
|
#
|
||||||
CPP = xt-cpp
|
ifeq ($(OS),Windows_NT)
|
||||||
OBJCOPY = xt-objcopy
|
# WIN32
|
||||||
#MAKE = xt-make
|
# We are under windows.
|
||||||
|
ifeq ($(XTENSA_CORE),lx106)
|
||||||
|
# It is xcc
|
||||||
|
AR = xt-ar
|
||||||
|
CC = xt-xcc
|
||||||
|
NM = xt-nm
|
||||||
|
CPP = xt-cpp
|
||||||
|
OBJCOPY = xt-objcopy
|
||||||
|
#MAKE = xt-make
|
||||||
|
CCFLAGS += -Os --rename-section .text=.irom0.text --rename-section .literal=.irom0.literal
|
||||||
|
else
|
||||||
|
# It is gcc, may be cygwin
|
||||||
|
# Can we use -fdata-sections?
|
||||||
|
CCFLAGS += -Os -ffunction-sections -fno-jump-tables
|
||||||
|
AR = xtensa-lx106-elf-ar
|
||||||
|
CC = xtensa-lx106-elf-gcc
|
||||||
|
NM = xtensa-lx106-elf-nm
|
||||||
|
CPP = xtensa-lx106-elf-cpp
|
||||||
|
OBJCOPY = xtensa-lx106-elf-objcopy
|
||||||
|
endif
|
||||||
|
ifeq ($(PROCESSOR_ARCHITECTURE),AMD64)
|
||||||
|
# ->AMD64
|
||||||
|
endif
|
||||||
|
ifeq ($(PROCESSOR_ARCHITECTURE),x86)
|
||||||
|
# ->IA32
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
# We are under other system, may be Linux. Assume using gcc.
|
||||||
|
# Can we use -fdata-sections?
|
||||||
|
CCFLAGS += -Os -ffunction-sections -fno-jump-tables
|
||||||
|
AR = xtensa-lx106-elf-ar
|
||||||
|
CC = xtensa-lx106-elf-gcc
|
||||||
|
NM = xtensa-lx106-elf-nm
|
||||||
|
CPP = xtensa-lx106-elf-cpp
|
||||||
|
OBJCOPY = xtensa-lx106-elf-objcopy
|
||||||
|
|
||||||
|
UNAME_S := $(shell uname -s)
|
||||||
|
ifeq ($(UNAME_S),Linux)
|
||||||
|
# LINUX
|
||||||
|
endif
|
||||||
|
ifeq ($(UNAME_S),Darwin)
|
||||||
|
# OSX
|
||||||
|
endif
|
||||||
|
UNAME_P := $(shell uname -p)
|
||||||
|
ifeq ($(UNAME_P),x86_64)
|
||||||
|
# ->AMD64
|
||||||
|
endif
|
||||||
|
ifneq ($(filter %86,$(UNAME_P)),)
|
||||||
|
# ->IA32
|
||||||
|
endif
|
||||||
|
ifneq ($(filter arm%,$(UNAME_P)),)
|
||||||
|
# ->ARM
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
#############################################################
|
||||||
|
|
||||||
CSRCS ?= $(wildcard *.c)
|
CSRCS ?= $(wildcard *.c)
|
||||||
ASRCs ?= $(wildcard *.s)
|
ASRCs ?= $(wildcard *.s)
|
||||||
|
19
README.md
19
README.md
@ -1,7 +1,7 @@
|
|||||||
# **NodeMcu** #
|
# **NodeMcu** #
|
||||||
version 0.9.4
|
version 0.9.5
|
||||||
###A lua based firmware for wifi-soc esp8266
|
###A lua based firmware for wifi-soc esp8266
|
||||||
Build on [ESP8266 sdk 0.9.4](http://bbs.espressif.com/viewtopic.php?f=5&t=90)<br />
|
Build on [ESP8266 sdk 0.9.5](http://bbs.espressif.com/viewtopic.php?f=7&t=104)<br />
|
||||||
Lua core based on [eLua project](http://www.eluaproject.net/)<br />
|
Lua core based on [eLua project](http://www.eluaproject.net/)<br />
|
||||||
File system based on [spiffs](https://github.com/pellepl/spiffs)<br />
|
File system based on [spiffs](https://github.com/pellepl/spiffs)<br />
|
||||||
Open source development kit for NodeMCU [nodemcu-devkit](https://github.com/nodemcu/nodemcu-devkit)<br />
|
Open source development kit for NodeMCU [nodemcu-devkit](https://github.com/nodemcu/nodemcu-devkit)<br />
|
||||||
@ -13,6 +13,13 @@ bbs: [中文论坛Chinese bbs](http://bbs.nodemcu.com)<br />
|
|||||||
Tencent QQ group QQ群: 309957875<br />
|
Tencent QQ group QQ群: 309957875<br />
|
||||||
|
|
||||||
# Change log
|
# Change log
|
||||||
|
2015-01-06<br />
|
||||||
|
update sdk to 0.9.5.<br />
|
||||||
|
pre_build bin now compiled by gcc toolchain.<br />
|
||||||
|
memory/heap usage optimized.<br />
|
||||||
|
add support for multiple platform and toolchain include eclipse. <br />
|
||||||
|
combine firmware for 512K, 1M, 2M, 4M flash to one. flash size auto-detected.
|
||||||
|
|
||||||
2014-12-30<br />
|
2014-12-30<br />
|
||||||
modify uart.on api, when run_input set to 0, uart.on now can read raw data from uart.<br />
|
modify uart.on api, when run_input set to 0, uart.on now can read raw data from uart.<br />
|
||||||
serial input now accept non-ascii chars.<br />
|
serial input now accept non-ascii chars.<br />
|
||||||
@ -98,13 +105,13 @@ add tmr.time() api to get rtc time and calibration.
|
|||||||
</table>
|
</table>
|
||||||
|
|
||||||
#Build option
|
#Build option
|
||||||
####*GNU toolchain is not tested*
|
|
||||||
####file ./app/include/user_config.h
|
####file ./app/include/user_config.h
|
||||||
```c
|
```c
|
||||||
#define FLASH_512K
|
// #define FLASH_512K
|
||||||
// #define FLASH_1M
|
// #define FLASH_1M
|
||||||
// #define FLASH_2M
|
// #define FLASH_2M
|
||||||
// #define FLASH_4M
|
// #define FLASH_4M
|
||||||
|
#define FLASH_AUTOSIZE
|
||||||
...
|
...
|
||||||
#define LUA_USE_MODULES
|
#define LUA_USE_MODULES
|
||||||
#ifdef LUA_USE_MODULES
|
#ifdef LUA_USE_MODULES
|
||||||
@ -119,12 +126,12 @@ add tmr.time() api to get rtc time and calibration.
|
|||||||
#define LUA_USE_MODULES_ADC
|
#define LUA_USE_MODULES_ADC
|
||||||
#define LUA_USE_MODULES_UART
|
#define LUA_USE_MODULES_UART
|
||||||
#define LUA_USE_MODULES_OW
|
#define LUA_USE_MODULES_OW
|
||||||
//#define LUA_USE_MODULES_BIT
|
#define LUA_USE_MODULES_BIT
|
||||||
#endif /* LUA_USE_MODULES */
|
#endif /* LUA_USE_MODULES */
|
||||||
```
|
```
|
||||||
|
|
||||||
#Flash the firmware
|
#Flash the firmware
|
||||||
nodemcu_512k.bin: 0x00000<br />
|
nodemcu_latest.bin: 0x00000<br />
|
||||||
for most esp8266 modules, just pull GPIO0 down and restart.<br />
|
for most esp8266 modules, just pull GPIO0 down and restart.<br />
|
||||||
You can use the [nodemcu-flasher](https://github.com/nodemcu/nodemcu-flasher) to burn the firmware.
|
You can use the [nodemcu-flasher](https://github.com/nodemcu/nodemcu-flasher) to burn the firmware.
|
||||||
|
|
||||||
|
72
app/.cproject
Normal file
72
app/.cproject
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
|
||||||
|
<storageModule moduleId="org.eclipse.cdt.core.settings">
|
||||||
|
<cconfiguration id="cdt.managedbuild.toolchain.gnu.cross.base.992255352">
|
||||||
|
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.toolchain.gnu.cross.base.992255352" moduleId="org.eclipse.cdt.core.settings" name="Default">
|
||||||
|
<externalSettings/>
|
||||||
|
<extensions>
|
||||||
|
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||||
|
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||||
|
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||||
|
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||||
|
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||||
|
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||||
|
</extensions>
|
||||||
|
</storageModule>
|
||||||
|
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||||
|
<configuration artifactName="${ProjName}" buildProperties="" description="" id="cdt.managedbuild.toolchain.gnu.cross.base.992255352" name="Default" parent="org.eclipse.cdt.build.core.emptycfg">
|
||||||
|
<folderInfo id="cdt.managedbuild.toolchain.gnu.cross.base.992255352.1209976491" name="/" resourcePath="">
|
||||||
|
<toolChain id="cdt.managedbuild.toolchain.gnu.cross.base.1901907892" name="Cross GCC" superClass="cdt.managedbuild.toolchain.gnu.cross.base">
|
||||||
|
<option id="cdt.managedbuild.option.gnu.cross.prefix.1771691886" name="Prefix" superClass="cdt.managedbuild.option.gnu.cross.prefix"/>
|
||||||
|
<option id="cdt.managedbuild.option.gnu.cross.path.1831805518" name="Path" superClass="cdt.managedbuild.option.gnu.cross.path"/>
|
||||||
|
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="cdt.managedbuild.targetPlatform.gnu.cross.2055058514" isAbstract="false" osList="all" superClass="cdt.managedbuild.targetPlatform.gnu.cross"/>
|
||||||
|
<builder command="gen_misc.bat" enableAutoBuild="false" enabledIncrementalBuild="true" id="cdt.managedbuild.builder.gnu.cross.415628675" incrementalBuildTarget="" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" parallelBuildOn="false" superClass="cdt.managedbuild.builder.gnu.cross">
|
||||||
|
<outputEntries>
|
||||||
|
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="outputPath" name=""/>
|
||||||
|
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="outputPath" name="bin"/>
|
||||||
|
</outputEntries>
|
||||||
|
</builder>
|
||||||
|
<tool id="cdt.managedbuild.tool.gnu.cross.c.compiler.972920545" name="Cross GCC Compiler" superClass="cdt.managedbuild.tool.gnu.cross.c.compiler">
|
||||||
|
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1985687892" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
|
||||||
|
</tool>
|
||||||
|
<tool id="cdt.managedbuild.tool.gnu.cross.cpp.compiler.36308842" name="Cross G++ Compiler" superClass="cdt.managedbuild.tool.gnu.cross.cpp.compiler">
|
||||||
|
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1696212951" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
|
||||||
|
</tool>
|
||||||
|
<tool id="cdt.managedbuild.tool.gnu.cross.c.linker.1453974065" name="Cross GCC Linker" superClass="cdt.managedbuild.tool.gnu.cross.c.linker"/>
|
||||||
|
<tool id="cdt.managedbuild.tool.gnu.cross.cpp.linker.2057246668" name="Cross G++ Linker" superClass="cdt.managedbuild.tool.gnu.cross.cpp.linker">
|
||||||
|
<inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.2049169207" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
|
||||||
|
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
|
||||||
|
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
|
||||||
|
</inputType>
|
||||||
|
</tool>
|
||||||
|
<tool id="cdt.managedbuild.tool.gnu.cross.archiver.2111505538" name="Cross GCC Archiver" superClass="cdt.managedbuild.tool.gnu.cross.archiver"/>
|
||||||
|
<tool id="cdt.managedbuild.tool.gnu.cross.assembler.353143895" name="Cross GCC Assembler" superClass="cdt.managedbuild.tool.gnu.cross.assembler">
|
||||||
|
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1235194497" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
|
||||||
|
</tool>
|
||||||
|
</toolChain>
|
||||||
|
</folderInfo>
|
||||||
|
</configuration>
|
||||||
|
</storageModule>
|
||||||
|
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||||
|
</cconfiguration>
|
||||||
|
</storageModule>
|
||||||
|
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||||
|
<project id="nodemcu-firmware.null.292794708" name="nodemcu-firmware"/>
|
||||||
|
</storageModule>
|
||||||
|
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
|
||||||
|
<storageModule moduleId="refreshScope" versionNumber="2">
|
||||||
|
<configuration configurationName="Default">
|
||||||
|
<resource resourceType="PROJECT" workspacePath="/nodemcu-firmware"/>
|
||||||
|
</configuration>
|
||||||
|
</storageModule>
|
||||||
|
<storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/>
|
||||||
|
<storageModule moduleId="scannerConfiguration">
|
||||||
|
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||||
|
<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.cross.base.992255352;cdt.managedbuild.toolchain.gnu.cross.base.992255352.1209976491;cdt.managedbuild.tool.gnu.cross.c.compiler.972920545;cdt.managedbuild.tool.gnu.c.compiler.input.1985687892">
|
||||||
|
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||||
|
</scannerConfigBuildInfo>
|
||||||
|
<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.cross.base.992255352;cdt.managedbuild.toolchain.gnu.cross.base.992255352.1209976491;cdt.managedbuild.tool.gnu.cross.cpp.compiler.36308842;cdt.managedbuild.tool.gnu.cpp.compiler.input.1696212951">
|
||||||
|
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||||
|
</scannerConfigBuildInfo>
|
||||||
|
</storageModule>
|
||||||
|
</cproject>
|
34
app/.project
Normal file
34
app/.project
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>nodemcu-firmware</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
|
||||||
|
<triggers>clean,full,incremental,</triggers>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
|
||||||
|
<triggers>full,incremental,</triggers>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.eclipse.cdt.core.cnature</nature>
|
||||||
|
<nature>org.eclipse.cdt.core.ccnature</nature>
|
||||||
|
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
|
||||||
|
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
|
||||||
|
</natures>
|
||||||
|
<linkedResources>
|
||||||
|
<link>
|
||||||
|
<name>bin</name>
|
||||||
|
<type>2</type>
|
||||||
|
<locationURI>PARENT-1-PROJECT_LOC/bin</locationURI>
|
||||||
|
</link>
|
||||||
|
</linkedResources>
|
||||||
|
</projectDescription>
|
15
app/.settings/language.settings.xml
Normal file
15
app/.settings/language.settings.xml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<project>
|
||||||
|
<configuration id="cdt.managedbuild.toolchain.gnu.cross.base.992255352" name="Default">
|
||||||
|
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
|
||||||
|
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
|
||||||
|
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
|
||||||
|
<provider copy-of="extension" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"/>
|
||||||
|
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="1912993350869412582" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
||||||
|
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
||||||
|
<language-scope id="org.eclipse.cdt.core.g++"/>
|
||||||
|
</provider>
|
||||||
|
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
|
||||||
|
</extension>
|
||||||
|
</configuration>
|
||||||
|
</project>
|
67
app/.settings/org.eclipse.cdt.codan.core.prefs
Normal file
67
app/.settings/org.eclipse.cdt.codan.core.prefs
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
eclipse.preferences.version=1
|
||||||
|
org.eclipse.cdt.codan.checkers.errnoreturn=Warning
|
||||||
|
org.eclipse.cdt.codan.checkers.errnoreturn.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},implicit\=>false}
|
||||||
|
org.eclipse.cdt.codan.checkers.errreturnvalue=Error
|
||||||
|
org.eclipse.cdt.codan.checkers.errreturnvalue.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||||
|
org.eclipse.cdt.codan.checkers.noreturn=Error
|
||||||
|
org.eclipse.cdt.codan.checkers.noreturn.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},implicit\=>false}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation=Error
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem=Error
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem=Warning
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem=Error
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem=Warning
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},no_break_comment\=>"no break",last_case_param\=>false,empty_case_param\=>false}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.CatchByReference=Warning
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.CatchByReference.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},unknown\=>false,exceptions\=>()}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem=Error
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.ClassMembersInitialization=Warning
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.ClassMembersInitialization.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},skip\=>true}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem=Error
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem=Error
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.InvalidArguments=Error
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.InvalidArguments.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem=Error
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem=Error
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem=Error
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem=Error
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker=-Info
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},pattern\=>"^[a-z]",macro\=>true,exceptions\=>()}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem=Warning
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.OverloadProblem=Error
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.OverloadProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem=Error
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem=Error
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem=-Warning
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem=-Warning
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem=Warning
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true,exceptions\=>()}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem=Warning
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},paramNot\=>false}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem=Warning
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},else\=>false,afterelse\=>false}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem=Error
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem=Warning
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem=Warning
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem=Warning
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true,exceptions\=>("@(\#)","$Id")}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem=Error
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
6
app/.settings/org.eclipse.cdt.core.prefs
Normal file
6
app/.settings/org.eclipse.cdt.core.prefs
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
eclipse.preferences.version=1
|
||||||
|
environment/project/cdt.managedbuild.toolchain.gnu.cross.base.992255352/PATH/delimiter=;
|
||||||
|
environment/project/cdt.managedbuild.toolchain.gnu.cross.base.992255352/PATH/operation=append
|
||||||
|
environment/project/cdt.managedbuild.toolchain.gnu.cross.base.992255352/PATH/value=C\:\\Espressif\\xtensa-lx106-elf\\bin
|
||||||
|
environment/project/cdt.managedbuild.toolchain.gnu.cross.base.992255352/append=true
|
||||||
|
environment/project/cdt.managedbuild.toolchain.gnu.cross.base.992255352/appendContributed=true
|
@ -41,7 +41,6 @@ endif # } PDIR
|
|||||||
APPDIR = .
|
APPDIR = .
|
||||||
LDDIR = ../ld
|
LDDIR = ../ld
|
||||||
|
|
||||||
CCFLAGS += -Os
|
|
||||||
|
|
||||||
TARGET_LDFLAGS = \
|
TARGET_LDFLAGS = \
|
||||||
-nostdlib \
|
-nostdlib \
|
||||||
@ -49,6 +48,7 @@ TARGET_LDFLAGS = \
|
|||||||
--longcalls \
|
--longcalls \
|
||||||
--text-section-literals
|
--text-section-literals
|
||||||
|
|
||||||
|
|
||||||
ifeq ($(FLAVOR),debug)
|
ifeq ($(FLAVOR),debug)
|
||||||
TARGET_LDFLAGS += -g -O2
|
TARGET_LDFLAGS += -g -O2
|
||||||
endif
|
endif
|
||||||
|
@ -72,7 +72,7 @@ static uint8_t LastFamilyDiscrepancy[NUM_OW];
|
|||||||
static uint8_t LastDeviceFlag[NUM_OW];
|
static uint8_t LastDeviceFlag[NUM_OW];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR onewire_init(uint8_t pin)
|
void onewire_init(uint8_t pin)
|
||||||
{
|
{
|
||||||
// pinMode(pin, INPUT);
|
// pinMode(pin, INPUT);
|
||||||
platform_gpio_mode(pin, PLATFORM_GPIO_INPUT, PLATFORM_GPIO_PULLUP);
|
platform_gpio_mode(pin, PLATFORM_GPIO_INPUT, PLATFORM_GPIO_PULLUP);
|
||||||
@ -88,7 +88,7 @@ void ICACHE_FLASH_ATTR onewire_init(uint8_t pin)
|
|||||||
//
|
//
|
||||||
// Returns 1 if a device asserted a presence pulse, 0 otherwise.
|
// Returns 1 if a device asserted a presence pulse, 0 otherwise.
|
||||||
//
|
//
|
||||||
uint8_t ICACHE_FLASH_ATTR onewire_reset(uint8_t pin)
|
uint8_t onewire_reset(uint8_t pin)
|
||||||
{
|
{
|
||||||
uint8_t r;
|
uint8_t r;
|
||||||
uint8_t retries = 125;
|
uint8_t retries = 125;
|
||||||
@ -120,7 +120,7 @@ uint8_t ICACHE_FLASH_ATTR onewire_reset(uint8_t pin)
|
|||||||
// Write a bit. Port and bit is used to cut lookup time and provide
|
// Write a bit. Port and bit is used to cut lookup time and provide
|
||||||
// more certain timing.
|
// more certain timing.
|
||||||
//
|
//
|
||||||
static void ICACHE_FLASH_ATTR onewire_write_bit(uint8_t pin, uint8_t v)
|
static void onewire_write_bit(uint8_t pin, uint8_t v)
|
||||||
{
|
{
|
||||||
if (v & 1) {
|
if (v & 1) {
|
||||||
noInterrupts();
|
noInterrupts();
|
||||||
@ -145,7 +145,7 @@ static void ICACHE_FLASH_ATTR onewire_write_bit(uint8_t pin, uint8_t v)
|
|||||||
// Read a bit. Port and bit is used to cut lookup time and provide
|
// Read a bit. Port and bit is used to cut lookup time and provide
|
||||||
// more certain timing.
|
// more certain timing.
|
||||||
//
|
//
|
||||||
static uint8_t ICACHE_FLASH_ATTR onewire_read_bit(uint8_t pin)
|
static uint8_t onewire_read_bit(uint8_t pin)
|
||||||
{
|
{
|
||||||
uint8_t r;
|
uint8_t r;
|
||||||
|
|
||||||
@ -168,7 +168,7 @@ static uint8_t ICACHE_FLASH_ATTR onewire_read_bit(uint8_t pin)
|
|||||||
// go tri-state at the end of the write to avoid heating in a short or
|
// go tri-state at the end of the write to avoid heating in a short or
|
||||||
// other mishap.
|
// other mishap.
|
||||||
//
|
//
|
||||||
void ICACHE_FLASH_ATTR onewire_write(uint8_t pin, uint8_t v, uint8_t power /* = 0 */) {
|
void onewire_write(uint8_t pin, uint8_t v, uint8_t power /* = 0 */) {
|
||||||
uint8_t bitMask;
|
uint8_t bitMask;
|
||||||
|
|
||||||
for (bitMask = 0x01; bitMask; bitMask <<= 1) {
|
for (bitMask = 0x01; bitMask; bitMask <<= 1) {
|
||||||
@ -182,7 +182,7 @@ void ICACHE_FLASH_ATTR onewire_write(uint8_t pin, uint8_t v, uint8_t power /* =
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR onewire_write_bytes(uint8_t pin, const uint8_t *buf, uint16_t count, bool power /* = 0 */) {
|
void onewire_write_bytes(uint8_t pin, const uint8_t *buf, uint16_t count, bool power /* = 0 */) {
|
||||||
uint16_t i;
|
uint16_t i;
|
||||||
for (i = 0 ; i < count ; i++)
|
for (i = 0 ; i < count ; i++)
|
||||||
onewire_write(pin, buf[i], 0);
|
onewire_write(pin, buf[i], 0);
|
||||||
@ -197,7 +197,7 @@ void ICACHE_FLASH_ATTR onewire_write_bytes(uint8_t pin, const uint8_t *buf, uint
|
|||||||
//
|
//
|
||||||
// Read a byte
|
// Read a byte
|
||||||
//
|
//
|
||||||
uint8_t ICACHE_FLASH_ATTR onewire_read(uint8_t pin) {
|
uint8_t onewire_read(uint8_t pin) {
|
||||||
uint8_t bitMask;
|
uint8_t bitMask;
|
||||||
uint8_t r = 0;
|
uint8_t r = 0;
|
||||||
|
|
||||||
@ -207,7 +207,7 @@ uint8_t ICACHE_FLASH_ATTR onewire_read(uint8_t pin) {
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR onewire_read_bytes(uint8_t pin, uint8_t *buf, uint16_t count) {
|
void onewire_read_bytes(uint8_t pin, uint8_t *buf, uint16_t count) {
|
||||||
uint16_t i;
|
uint16_t i;
|
||||||
for (i = 0 ; i < count ; i++)
|
for (i = 0 ; i < count ; i++)
|
||||||
buf[i] = onewire_read(pin);
|
buf[i] = onewire_read(pin);
|
||||||
@ -216,7 +216,7 @@ void ICACHE_FLASH_ATTR onewire_read_bytes(uint8_t pin, uint8_t *buf, uint16_t co
|
|||||||
//
|
//
|
||||||
// Do a ROM select
|
// Do a ROM select
|
||||||
//
|
//
|
||||||
void ICACHE_FLASH_ATTR onewire_select(uint8_t pin, const uint8_t rom[8])
|
void onewire_select(uint8_t pin, const uint8_t rom[8])
|
||||||
{
|
{
|
||||||
uint8_t i;
|
uint8_t i;
|
||||||
|
|
||||||
@ -228,12 +228,12 @@ void ICACHE_FLASH_ATTR onewire_select(uint8_t pin, const uint8_t rom[8])
|
|||||||
//
|
//
|
||||||
// Do a ROM skip
|
// Do a ROM skip
|
||||||
//
|
//
|
||||||
void ICACHE_FLASH_ATTR onewire_skip(uint8_t pin)
|
void onewire_skip(uint8_t pin)
|
||||||
{
|
{
|
||||||
onewire_write(pin, 0xCC, 0); // Skip ROM
|
onewire_write(pin, 0xCC, 0); // Skip ROM
|
||||||
}
|
}
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR onewire_depower(uint8_t pin)
|
void onewire_depower(uint8_t pin)
|
||||||
{
|
{
|
||||||
noInterrupts();
|
noInterrupts();
|
||||||
DIRECT_MODE_INPUT(pin);
|
DIRECT_MODE_INPUT(pin);
|
||||||
@ -246,7 +246,7 @@ void ICACHE_FLASH_ATTR onewire_depower(uint8_t pin)
|
|||||||
// You need to use this function to start a search again from the beginning.
|
// You need to use this function to start a search again from the beginning.
|
||||||
// You do not need to do it for the first search, though you could.
|
// You do not need to do it for the first search, though you could.
|
||||||
//
|
//
|
||||||
void ICACHE_FLASH_ATTR onewire_reset_search(uint8_t pin)
|
void onewire_reset_search(uint8_t pin)
|
||||||
{
|
{
|
||||||
// reset the search state
|
// reset the search state
|
||||||
LastDiscrepancy[pin] = 0;
|
LastDiscrepancy[pin] = 0;
|
||||||
@ -262,7 +262,7 @@ void ICACHE_FLASH_ATTR onewire_reset_search(uint8_t pin)
|
|||||||
// Setup the search to find the device type 'family_code' on the next call
|
// Setup the search to find the device type 'family_code' on the next call
|
||||||
// to search(*newAddr) if it is present.
|
// to search(*newAddr) if it is present.
|
||||||
//
|
//
|
||||||
void ICACHE_FLASH_ATTR onewire_target_search(uint8_t pin, uint8_t family_code)
|
void onewire_target_search(uint8_t pin, uint8_t family_code)
|
||||||
{
|
{
|
||||||
// set the search state to find SearchFamily type devices
|
// set the search state to find SearchFamily type devices
|
||||||
ROM_NO[pin][0] = family_code;
|
ROM_NO[pin][0] = family_code;
|
||||||
@ -290,7 +290,7 @@ void ICACHE_FLASH_ATTR onewire_target_search(uint8_t pin, uint8_t family_code)
|
|||||||
// Return TRUE : device found, ROM number in ROM_NO buffer
|
// Return TRUE : device found, ROM number in ROM_NO buffer
|
||||||
// FALSE : device not found, end of search
|
// FALSE : device not found, end of search
|
||||||
//
|
//
|
||||||
uint8_t ICACHE_FLASH_ATTR onewire_search(uint8_t pin, uint8_t *newAddr)
|
uint8_t onewire_search(uint8_t pin, uint8_t *newAddr)
|
||||||
{
|
{
|
||||||
uint8_t id_bit_number;
|
uint8_t id_bit_number;
|
||||||
uint8_t last_zero, rom_byte_number, search_result;
|
uint8_t last_zero, rom_byte_number, search_result;
|
||||||
@ -449,7 +449,7 @@ static const uint8_t dscrc_table[] = {
|
|||||||
// compared to all those delayMicrosecond() calls. But I got
|
// compared to all those delayMicrosecond() calls. But I got
|
||||||
// confused, so I use this table from the examples.)
|
// confused, so I use this table from the examples.)
|
||||||
//
|
//
|
||||||
uint8_t ICACHE_FLASH_ATTR onewire_crc8(const uint8_t *addr, uint8_t len)
|
uint8_t onewire_crc8(const uint8_t *addr, uint8_t len)
|
||||||
{
|
{
|
||||||
uint8_t crc = 0;
|
uint8_t crc = 0;
|
||||||
|
|
||||||
@ -463,7 +463,7 @@ uint8_t ICACHE_FLASH_ATTR onewire_crc8(const uint8_t *addr, uint8_t len)
|
|||||||
// Compute a Dallas Semiconductor 8 bit CRC directly.
|
// Compute a Dallas Semiconductor 8 bit CRC directly.
|
||||||
// this is much slower, but much smaller, than the lookup table.
|
// this is much slower, but much smaller, than the lookup table.
|
||||||
//
|
//
|
||||||
uint8_t ICACHE_FLASH_ATTR onewire_crc8(const uint8_t *addr, uint8_t len)
|
uint8_t onewire_crc8(const uint8_t *addr, uint8_t len)
|
||||||
{
|
{
|
||||||
uint8_t crc = 0;
|
uint8_t crc = 0;
|
||||||
|
|
||||||
@ -501,7 +501,7 @@ uint8_t ICACHE_FLASH_ATTR onewire_crc8(const uint8_t *addr, uint8_t len)
|
|||||||
// *not* at a 16-bit integer.
|
// *not* at a 16-bit integer.
|
||||||
// @param crc - The crc starting value (optional)
|
// @param crc - The crc starting value (optional)
|
||||||
// @return True, iff the CRC matches.
|
// @return True, iff the CRC matches.
|
||||||
bool ICACHE_FLASH_ATTR onewire_check_crc16(const uint8_t* input, uint16_t len, const uint8_t* inverted_crc, uint16_t crc)
|
bool onewire_check_crc16(const uint8_t* input, uint16_t len, const uint8_t* inverted_crc, uint16_t crc)
|
||||||
{
|
{
|
||||||
crc = ~onewire_crc16(input, len, crc);
|
crc = ~onewire_crc16(input, len, crc);
|
||||||
return (crc & 0xFF) == inverted_crc[0] && (crc >> 8) == inverted_crc[1];
|
return (crc & 0xFF) == inverted_crc[0] && (crc >> 8) == inverted_crc[1];
|
||||||
@ -519,7 +519,7 @@ bool ICACHE_FLASH_ATTR onewire_check_crc16(const uint8_t* input, uint16_t len, c
|
|||||||
// @param len - How many bytes to use.
|
// @param len - How many bytes to use.
|
||||||
// @param crc - The crc starting value (optional)
|
// @param crc - The crc starting value (optional)
|
||||||
// @return The CRC16, as defined by Dallas Semiconductor.
|
// @return The CRC16, as defined by Dallas Semiconductor.
|
||||||
uint16_t ICACHE_FLASH_ATTR onewire_crc16(const uint8_t* input, uint16_t len, uint16_t crc)
|
uint16_t onewire_crc16(const uint8_t* input, uint16_t len, uint16_t crc)
|
||||||
{
|
{
|
||||||
static const uint8_t oddparity[16] =
|
static const uint8_t oddparity[16] =
|
||||||
{ 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0 };
|
{ 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0 };
|
||||||
|
@ -305,7 +305,7 @@ pwm_get_freq(uint8 channel)
|
|||||||
* Parameters : NONE
|
* Parameters : NONE
|
||||||
* Returns : NONE
|
* Returns : NONE
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
LOCAL void
|
LOCAL void ICACHE_RAM_ATTR
|
||||||
pwm_tim1_intr_handler(void)
|
pwm_tim1_intr_handler(void)
|
||||||
{
|
{
|
||||||
uint8 local_toggle = pwm_toggle; // pwm_toggle may change outside
|
uint8 local_toggle = pwm_toggle; // pwm_toggle may change outside
|
||||||
|
@ -11,7 +11,7 @@ extern UartDevice UartDev;
|
|||||||
|
|
||||||
#define uart_putc uart0_putc
|
#define uart_putc uart0_putc
|
||||||
|
|
||||||
bool ICACHE_FLASH_ATTR uart_getc(char *c){
|
bool uart_getc(char *c){
|
||||||
RcvMsgBuff *pRxBuff = &(UartDev.rcv_buff);
|
RcvMsgBuff *pRxBuff = &(UartDev.rcv_buff);
|
||||||
if(pRxBuff->pWritePos == pRxBuff->pReadPos){ // empty
|
if(pRxBuff->pWritePos == pRxBuff->pReadPos){ // empty
|
||||||
return false;
|
return false;
|
||||||
@ -30,7 +30,7 @@ bool ICACHE_FLASH_ATTR uart_getc(char *c){
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
int ICACHE_FLASH_ATTR readline4lua(const char *prompt, char *buffer, int length){
|
int readline4lua(const char *prompt, char *buffer, int length){
|
||||||
char ch;
|
char ch;
|
||||||
int line_position;
|
int line_position;
|
||||||
|
|
||||||
|
@ -20,7 +20,8 @@
|
|||||||
// UartDev is defined and initialized in rom code.
|
// UartDev is defined and initialized in rom code.
|
||||||
extern UartDevice UartDev;
|
extern UartDevice UartDev;
|
||||||
|
|
||||||
LOCAL void uart0_rx_intr_handler(void *para);
|
LOCAL void ICACHE_RAM_ATTR
|
||||||
|
uart0_rx_intr_handler(void *para);
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* FunctionName : uart_config
|
* FunctionName : uart_config
|
||||||
|
@ -3,17 +3,31 @@ set BACKPATH=%PATH%
|
|||||||
set PATH=%BACKPATH%;%CD%\..\tools
|
set PATH=%BACKPATH%;%CD%\..\tools
|
||||||
@echo on
|
@echo on
|
||||||
|
|
||||||
|
make %1
|
||||||
|
|
||||||
del /F ..\bin\eagle.app.v6.flash.bin ..\bin\eagle.app.v6.irom0text.bin ..\bin\eagle.app.v6.dump ..\bin\eagle.app.v6.S
|
del /F ..\bin\eagle.app.v6.flash.bin ..\bin\eagle.app.v6.irom0text.bin ..\bin\eagle.app.v6.dump ..\bin\eagle.app.v6.S
|
||||||
|
|
||||||
cd .output\eagle\debug\image
|
cd .output\eagle\debug\image
|
||||||
|
|
||||||
xt-objdump -x -s eagle.app.v6.out > ..\..\..\..\..\bin\eagle.app.v6.dump
|
@echo off
|
||||||
xt-objdump -S eagle.app.v6.out > ..\..\..\..\..\bin\eagle.app.v6.S
|
set OBJDUMP=xt-objdump
|
||||||
|
set OBJCOPY=xt-objcopy
|
||||||
|
if defined XTENSA_CORE (
|
||||||
|
set OBJDUMP=xt-objdump
|
||||||
|
set OBJCOPY=xt-objcopy
|
||||||
|
) else (
|
||||||
|
set OBJDUMP=xtensa-lx106-elf-objdump
|
||||||
|
set OBJCOPY=xtensa-lx106-elf-objcopy
|
||||||
|
)
|
||||||
|
@echo on
|
||||||
|
|
||||||
xt-objcopy --only-section .text -O binary eagle.app.v6.out eagle.app.v6.text.bin
|
%OBJDUMP% -x -s eagle.app.v6.out > ..\..\..\..\..\bin\eagle.app.v6.dump
|
||||||
xt-objcopy --only-section .data -O binary eagle.app.v6.out eagle.app.v6.data.bin
|
%OBJDUMP% -S eagle.app.v6.out > ..\..\..\..\..\bin\eagle.app.v6.S
|
||||||
xt-objcopy --only-section .rodata -O binary eagle.app.v6.out eagle.app.v6.rodata.bin
|
|
||||||
xt-objcopy --only-section .irom0.text -O binary eagle.app.v6.out eagle.app.v6.irom0text.bin
|
%OBJCOPY% --only-section .text -O binary eagle.app.v6.out eagle.app.v6.text.bin
|
||||||
|
%OBJCOPY% --only-section .data -O binary eagle.app.v6.out eagle.app.v6.data.bin
|
||||||
|
%OBJCOPY% --only-section .rodata -O binary eagle.app.v6.out eagle.app.v6.rodata.bin
|
||||||
|
%OBJCOPY% --only-section .irom0.text -O binary eagle.app.v6.out eagle.app.v6.irom0text.bin
|
||||||
|
|
||||||
gen_appbin.py eagle.app.v6.out v6
|
gen_appbin.py eagle.app.v6.out v6
|
||||||
|
|
||||||
|
@ -5,13 +5,13 @@ rm ../bin/eagle.app.v6.flash.bin ../bin/eagle.app.v6.irom0text.bin ../bin/eagle.
|
|||||||
|
|
||||||
cd .output/eagle/debug/image
|
cd .output/eagle/debug/image
|
||||||
|
|
||||||
xt-objdump -x -s eagle.app.v6.out > ../../../../../bin/eagle.app.v6.dump
|
xtensa-lx106-elf-objdump -x -s eagle.app.v6.out > ../../../../../bin/eagle.app.v6.dump
|
||||||
xt-objdump -S eagle.app.v6.out > ../../../../../bin/eagle.app.v6.S
|
xtensa-lx106-elf-objdump -S eagle.app.v6.out > ../../../../../bin/eagle.app.v6.S
|
||||||
|
|
||||||
xt-objcopy --only-section .text -O binary eagle.app.v6.out eagle.app.v6.text.bin
|
xtensa-lx106-elf-objcopy --only-section .text -O binary eagle.app.v6.out eagle.app.v6.text.bin
|
||||||
xt-objcopy --only-section .data -O binary eagle.app.v6.out eagle.app.v6.data.bin
|
xtensa-lx106-elf-objcopy --only-section .data -O binary eagle.app.v6.out eagle.app.v6.data.bin
|
||||||
xt-objcopy --only-section .rodata -O binary eagle.app.v6.out eagle.app.v6.rodata.bin
|
xtensa-lx106-elf-objcopy --only-section .rodata -O binary eagle.app.v6.out eagle.app.v6.rodata.bin
|
||||||
xt-objcopy --only-section .irom0.text -O binary eagle.app.v6.out eagle.app.v6.irom0text.bin
|
xtensa-lx106-elf-objcopy --only-section .irom0.text -O binary eagle.app.v6.out eagle.app.v6.irom0text.bin
|
||||||
|
|
||||||
../../../../../tools/gen_appbin.py eagle.app.v6.out v6
|
../../../../../tools/gen_appbin.py eagle.app.v6.out v6
|
||||||
|
|
||||||
|
@ -3,14 +3,28 @@ set BACKPATH=%PATH%
|
|||||||
set PATH=%BACKPATH%;%CD%\..\tools
|
set PATH=%BACKPATH%;%CD%\..\tools
|
||||||
@echo on
|
@echo on
|
||||||
|
|
||||||
|
make APP=$1
|
||||||
|
|
||||||
rm ..\bin\upgrade\%1.bin
|
rm ..\bin\upgrade\%1.bin
|
||||||
|
|
||||||
cd .output\eagle\debug\image\
|
cd .output\eagle\debug\image\
|
||||||
|
|
||||||
xt-objcopy --only-section .text -O binary eagle.app.v6.out eagle.app.v6.text.bin
|
@echo off
|
||||||
xt-objcopy --only-section .data -O binary eagle.app.v6.out eagle.app.v6.data.bin
|
set OBJDUMP=xt-objdump
|
||||||
xt-objcopy --only-section .rodata -O binary eagle.app.v6.out eagle.app.v6.rodata.bin
|
set OBJCOPY=xt-objcopy
|
||||||
xt-objcopy --only-section .irom0.text -O binary eagle.app.v6.out eagle.app.v6.irom0text.bin
|
if defined XTENSA_CORE (
|
||||||
|
set OBJDUMP=xt-objdump
|
||||||
|
set OBJCOPY=xt-objcopy
|
||||||
|
) else (
|
||||||
|
set OBJDUMP=xtensa-lx106-elf-objdump
|
||||||
|
set OBJCOPY=xtensa-lx106-elf-objcopy
|
||||||
|
)
|
||||||
|
@echo on
|
||||||
|
|
||||||
|
%OBJCOPY% --only-section .text -O binary eagle.app.v6.out eagle.app.v6.text.bin
|
||||||
|
%OBJCOPY% --only-section .data -O binary eagle.app.v6.out eagle.app.v6.data.bin
|
||||||
|
%OBJCOPY% --only-section .rodata -O binary eagle.app.v6.out eagle.app.v6.rodata.bin
|
||||||
|
%OBJCOPY% --only-section .irom0.text -O binary eagle.app.v6.out eagle.app.v6.irom0text.bin
|
||||||
|
|
||||||
gen_appbin.py eagle.app.v6.out v6
|
gen_appbin.py eagle.app.v6.out v6
|
||||||
|
|
||||||
|
@ -6,13 +6,13 @@ rm ../bin/upgrade/user$1.bin ../bin/upgrade/user$1.dump ../bin/upgrade/user$1.S
|
|||||||
|
|
||||||
cd .output/eagle/debug/image/
|
cd .output/eagle/debug/image/
|
||||||
|
|
||||||
xt-objdump -x -s eagle.app.v6.out > ../../../../../bin/upgrade/user$1.dump
|
xtensa-lx106-elf-objdump -x -s eagle.app.v6.out > ../../../../../bin/upgrade/user$1.dump
|
||||||
xt-objdump -S eagle.app.v6.out > ../../../../../bin/upgrade/user$1.S
|
xtensa-lx106-elf-objdump -S eagle.app.v6.out > ../../../../../bin/upgrade/user$1.S
|
||||||
|
|
||||||
xt-objcopy --only-section .text -O binary eagle.app.v6.out eagle.app.v6.text.bin
|
xtensa-lx106-elf-objcopy --only-section .text -O binary eagle.app.v6.out eagle.app.v6.text.bin
|
||||||
xt-objcopy --only-section .data -O binary eagle.app.v6.out eagle.app.v6.data.bin
|
xtensa-lx106-elf-objcopy --only-section .data -O binary eagle.app.v6.out eagle.app.v6.data.bin
|
||||||
xt-objcopy --only-section .rodata -O binary eagle.app.v6.out eagle.app.v6.rodata.bin
|
xtensa-lx106-elf-objcopy --only-section .rodata -O binary eagle.app.v6.out eagle.app.v6.rodata.bin
|
||||||
xt-objcopy --only-section .irom0.text -O binary eagle.app.v6.out eagle.app.v6.irom0text.bin
|
xtensa-lx106-elf-objcopy --only-section .irom0.text -O binary eagle.app.v6.out eagle.app.v6.irom0text.bin
|
||||||
|
|
||||||
../../../../../tools/gen_appbin.py eagle.app.v6.out v6
|
../../../../../tools/gen_appbin.py eagle.app.v6.out v6
|
||||||
|
|
||||||
|
@ -3,11 +3,11 @@
|
|||||||
|
|
||||||
#define NODE_VERSION_MAJOR 0U
|
#define NODE_VERSION_MAJOR 0U
|
||||||
#define NODE_VERSION_MINOR 9U
|
#define NODE_VERSION_MINOR 9U
|
||||||
#define NODE_VERSION_REVISION 4U
|
#define NODE_VERSION_REVISION 5U
|
||||||
#define NODE_VERSION_INTERNAL 0U
|
#define NODE_VERSION_INTERNAL 0U
|
||||||
|
|
||||||
#define NODE_VERSION "NodeMcu 0.9.4"
|
#define NODE_VERSION "NodeMcu 0.9.5"
|
||||||
#define BUILD_DATE "build 20150101"
|
#define BUILD_DATE "build 20150106"
|
||||||
|
|
||||||
// #define FLASH_512K
|
// #define FLASH_512K
|
||||||
// #define FLASH_1M
|
// #define FLASH_1M
|
||||||
@ -35,8 +35,10 @@
|
|||||||
#define NODE_ERR
|
#define NODE_ERR
|
||||||
#endif /* NODE_ERROR */
|
#endif /* NODE_ERROR */
|
||||||
|
|
||||||
#define NODE_STORE_TYPEDEF_ATTR __attribute__((aligned(4),packed))
|
#define ICACHE_STORE_TYPEDEF_ATTR __attribute__((aligned(4),packed))
|
||||||
#define NODE_STORE_ATTR __attribute__((aligned(4)))
|
#define ICACHE_STORE_ATTR __attribute__((aligned(4)))
|
||||||
|
#define ICACHE_RAM_ATTR __attribute__((section(".iram0.text")))
|
||||||
|
#define ICACHE_RODATA_ATTR __attribute__((section(".rodata.text")))
|
||||||
|
|
||||||
#define CLIENT_SSL_ENABLE
|
#define CLIENT_SSL_ENABLE
|
||||||
#define GPIO_INTERRUPT_ENABLE
|
#define GPIO_INTERRUPT_ENABLE
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
#include "c_ctype.h"
|
#include "c_ctype.h"
|
||||||
#include "c_types.h"
|
#include "c_types.h"
|
||||||
|
|
||||||
// int ICACHE_FLASH_ATTR isalnum(int c){}
|
// int isalnum(int c){}
|
||||||
// int ICACHE_FLASH_ATTR isalpha(int c){}
|
// int isalpha(int c){}
|
||||||
// int ICACHE_FLASH_ATTR iscntrl(int c){}
|
// int iscntrl(int c){}
|
||||||
// int ICACHE_FLASH_ATTR isdigit(int c){}
|
// int isdigit(int c){}
|
||||||
// // int ICACHE_FLASH_ATTR isgraph(int c){}
|
// // int isgraph(int c){}
|
||||||
// int ICACHE_FLASH_ATTR islower(int c){}
|
// int islower(int c){}
|
||||||
// int ICACHE_FLASH_ATTR isprint(int c){}
|
// int isprint(int c){}
|
||||||
// int ICACHE_FLASH_ATTR ispunct(int c){}
|
// int ispunct(int c){}
|
||||||
// int ICACHE_FLASH_ATTR isspace(int c){}
|
// int isspace(int c){}
|
||||||
// int ICACHE_FLASH_ATTR isupper(int c){}
|
// int isupper(int c){}
|
||||||
// int ICACHE_FLASH_ATTR isxdigit(int c){}
|
// int isxdigit(int c){}
|
||||||
// int ICACHE_FLASH_ATTR tolower(int c){}
|
// int tolower(int c){}
|
||||||
// int ICACHE_FLASH_ATTR toupper(int c){}
|
// int toupper(int c){}
|
||||||
|
@ -3,34 +3,34 @@
|
|||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
#ifndef __math_68881
|
#ifndef __math_68881
|
||||||
double ICACHE_FLASH_ATTR atan(double x){
|
double atan(double x){
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
double ICACHE_FLASH_ATTR cos(double x){
|
double cos(double x){
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
double ICACHE_FLASH_ATTR sin(double x){
|
double sin(double x){
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
double ICACHE_FLASH_ATTR tan(double x){
|
double tan(double x){
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
double ICACHE_FLASH_ATTR tanh(double x){
|
double tanh(double x){
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
double ICACHE_FLASH_ATTR frexp(double x, int *y){
|
double frexp(double x, int *y){
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
double ICACHE_FLASH_ATTR modf(double x, double *y){
|
double modf(double x, double *y){
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
double ICACHE_FLASH_ATTR ceil(double x){
|
double ceil(double x){
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
double ICACHE_FLASH_ATTR fabs(double x){
|
double fabs(double x){
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
double ICACHE_FLASH_ATTR floor(double x){
|
double floor(double x){
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
#endif /* ! defined (__math_68881) */
|
#endif /* ! defined (__math_68881) */
|
||||||
@ -39,40 +39,40 @@ double ICACHE_FLASH_ATTR floor(double x){
|
|||||||
|
|
||||||
#ifndef _REENT_ONLY
|
#ifndef _REENT_ONLY
|
||||||
#ifndef __math_68881
|
#ifndef __math_68881
|
||||||
double ICACHE_FLASH_ATTR acos(double x){
|
double acos(double x){
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
double ICACHE_FLASH_ATTR asin(double x){
|
double asin(double x){
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
double ICACHE_FLASH_ATTR atan2(double x, double y){
|
double atan2(double x, double y){
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
double ICACHE_FLASH_ATTR cosh(double x){
|
double cosh(double x){
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
double ICACHE_FLASH_ATTR sinh(double x){
|
double sinh(double x){
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
double ICACHE_FLASH_ATTR exp(double x){
|
double exp(double x){
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
double ICACHE_FLASH_ATTR ldexp(double x, int y){
|
double ldexp(double x, int y){
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
double ICACHE_FLASH_ATTR log(double x){
|
double log(double x){
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
double ICACHE_FLASH_ATTR log10(double x){
|
double log10(double x){
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
double ICACHE_FLASH_ATTR pow(double x, double y){
|
double pow(double x, double y){
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
double ICACHE_FLASH_ATTR sqrt(double x){
|
double sqrt(double x){
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
double ICACHE_FLASH_ATTR fmod(double x, double y){
|
double fmod(double x, double y){
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
#endif /* ! defined (__math_68881) */
|
#endif /* ! defined (__math_68881) */
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#include "c_stdio.h"
|
#include "c_stdio.h"
|
||||||
// #include "driver/uart.h"
|
// #include "driver/uart.h"
|
||||||
|
|
||||||
unsigned char __print_buf[BUFSIZ];
|
|
||||||
int c_stdin = 999;
|
int c_stdin = 999;
|
||||||
int c_stdout = 1000;
|
int c_stdout = 1000;
|
||||||
int c_stderr = 1001;
|
int c_stderr = 1001;
|
||||||
|
@ -49,12 +49,13 @@ extern int c_stderr;
|
|||||||
|
|
||||||
extern void output_redirect(const char *str);
|
extern void output_redirect(const char *str);
|
||||||
#define c_puts output_redirect
|
#define c_puts output_redirect
|
||||||
extern unsigned char __print_buf[BUFSIZ];
|
|
||||||
// #define c_printf os_printf
|
// #define c_printf os_printf
|
||||||
// int c_printf(const char *c, ...);
|
// int c_printf(const char *c, ...);
|
||||||
#define c_sprintf os_sprintf
|
#define c_sprintf os_sprintf
|
||||||
// #define c_vsprintf ets_vsprintf
|
// #define c_vsprintf ets_vsprintf
|
||||||
#define c_printf(...) do { \
|
#define c_printf(...) do { \
|
||||||
|
unsigned char __print_buf[BUFSIZ]; \
|
||||||
c_sprintf(__print_buf, __VA_ARGS__); \
|
c_sprintf(__print_buf, __VA_ARGS__); \
|
||||||
c_puts(__print_buf); \
|
c_puts(__print_buf); \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
@ -7,12 +7,12 @@
|
|||||||
// const char *lua_init_value = "print(\"Hello world\")";
|
// const char *lua_init_value = "print(\"Hello world\")";
|
||||||
const char *lua_init_value = "@init.lua";
|
const char *lua_init_value = "@init.lua";
|
||||||
|
|
||||||
// int ICACHE_FLASH_ATTR c_abs(int x){
|
// int c_abs(int x){
|
||||||
// return x>0?x:0-x;
|
// return x>0?x:0-x;
|
||||||
// }
|
// }
|
||||||
// void ICACHE_FLASH_ATTR c_exit(int e){
|
// void c_exit(int e){
|
||||||
// }
|
// }
|
||||||
const char *ICACHE_FLASH_ATTR c_getenv(const char *__string){
|
const char *c_getenv(const char *__string){
|
||||||
if (c_strcmp(__string, "LUA_INIT") == 0){
|
if (c_strcmp(__string, "LUA_INIT") == 0){
|
||||||
return lua_init_value;
|
return lua_init_value;
|
||||||
}
|
}
|
||||||
@ -20,7 +20,7 @@ const char *ICACHE_FLASH_ATTR c_getenv(const char *__string){
|
|||||||
}
|
}
|
||||||
|
|
||||||
// make sure there is enough memory before real malloc, otherwise malloc will panic and reset
|
// make sure there is enough memory before real malloc, otherwise malloc will panic and reset
|
||||||
void *ICACHE_FLASH_ATTR c_malloc(size_t __size){
|
void *c_malloc(size_t __size){
|
||||||
if(__size>system_get_free_heap_size()){
|
if(__size>system_get_free_heap_size()){
|
||||||
NODE_ERR("malloc: not enough memory\n");
|
NODE_ERR("malloc: not enough memory\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -28,7 +28,7 @@ void *ICACHE_FLASH_ATTR c_malloc(size_t __size){
|
|||||||
return (void *)os_malloc(__size);
|
return (void *)os_malloc(__size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *ICACHE_FLASH_ATTR c_zalloc(size_t __size){
|
void *c_zalloc(size_t __size){
|
||||||
if(__size>system_get_free_heap_size()){
|
if(__size>system_get_free_heap_size()){
|
||||||
NODE_ERR("zalloc: not enough memory\n");
|
NODE_ERR("zalloc: not enough memory\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -36,25 +36,25 @@ void *ICACHE_FLASH_ATTR c_zalloc(size_t __size){
|
|||||||
return (void *)os_zalloc(__size);
|
return (void *)os_zalloc(__size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR c_free(void *p){
|
void c_free(void *p){
|
||||||
// NODE_ERR("free1: %d\n", system_get_free_heap_size());
|
// NODE_ERR("free1: %d\n", system_get_free_heap_size());
|
||||||
os_free(p);
|
os_free(p);
|
||||||
// NODE_ERR("-free1: %d\n", system_get_free_heap_size());
|
// NODE_ERR("-free1: %d\n", system_get_free_heap_size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// int ICACHE_FLASH_ATTR c_rand(void){
|
// int c_rand(void){
|
||||||
// }
|
// }
|
||||||
// void ICACHE_FLASH_ATTR c_srand(unsigned int __seed){
|
// void c_srand(unsigned int __seed){
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// int ICACHE_FLASH_ATTR c_atoi(const char *__nptr){
|
// int c_atoi(const char *__nptr){
|
||||||
// }
|
// }
|
||||||
// double ICACHE_FLASH_ATTR c_strtod(const char *__n, char **__end_PTR){
|
// double c_strtod(const char *__n, char **__end_PTR){
|
||||||
// }
|
// }
|
||||||
// long ICACHE_FLASH_ATTR c_strtol(const char *__n, char **__end_PTR, int __base){
|
// long c_strtol(const char *__n, char **__end_PTR, int __base){
|
||||||
// }
|
// }
|
||||||
// unsigned long ICACHE_FLASH_ATTR c_strtoul(const char *__n, char **__end_PTR, int __base){
|
// unsigned long c_strtoul(const char *__n, char **__end_PTR, int __base){
|
||||||
// }
|
// }
|
||||||
// long long ICACHE_FLASH_ATTR c_strtoll(const char *__n, char **__end_PTR, int __base){
|
// long long c_strtoll(const char *__n, char **__end_PTR, int __base){
|
||||||
// }
|
// }
|
||||||
|
@ -22,15 +22,15 @@ extern char Image$$ER_IROM1$$Limit;
|
|||||||
//#warning "Please check linker script to ensure rodata is between _stext and _etext."
|
//#warning "Please check linker script to ensure rodata is between _stext and _etext."
|
||||||
|
|
||||||
/* symbols defined in linker script */
|
/* symbols defined in linker script */
|
||||||
extern char _rodata_start;
|
// extern char _rodata_start;
|
||||||
extern char _rodata_end;
|
// extern char _rodata_end;
|
||||||
// extern char _irom0_text_start;
|
extern char _irom0_text_start;
|
||||||
// extern char _irom0_text_end;
|
extern char _irom0_text_end;
|
||||||
// modify linker script to ensure rodata and rodata1 is between _rodata_start and _rodata_end.
|
// modify linker script to ensure rodata and rodata1 is between _rodata_start and _rodata_end.
|
||||||
#define RODATA_START_ADDRESS (&_rodata_start)
|
// #define RODATA_START_ADDRESS (&_rodata_start)
|
||||||
#define RODATA_END_ADDRESS (&_rodata_end)
|
// #define RODATA_END_ADDRESS (&_rodata_end)
|
||||||
// #define RODATA_START_ADDRESS (&_irom0_text_start)
|
#define RODATA_START_ADDRESS (&_irom0_text_start)
|
||||||
// #define RODATA_END_ADDRESS (&_irom0_text_end)
|
#define RODATA_END_ADDRESS (&_irom0_text_end)
|
||||||
|
|
||||||
#else // other compilers
|
#else // other compilers
|
||||||
|
|
||||||
|
154
app/lua/lapi.c
154
app/lua/lapi.c
@ -46,7 +46,7 @@ const char lua_ident[] =
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static TValue *ICACHE_FLASH_ATTR index2adr (lua_State *L, int idx) {
|
static TValue *index2adr (lua_State *L, int idx) {
|
||||||
if (idx > 0) {
|
if (idx > 0) {
|
||||||
TValue *o = L->base + (idx - 1);
|
TValue *o = L->base + (idx - 1);
|
||||||
api_check(L, idx <= L->ci->top - L->base);
|
api_check(L, idx <= L->ci->top - L->base);
|
||||||
@ -77,7 +77,7 @@ static TValue *ICACHE_FLASH_ATTR index2adr (lua_State *L, int idx) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Table *ICACHE_FLASH_ATTR getcurrenv (lua_State *L) {
|
static Table *getcurrenv (lua_State *L) {
|
||||||
if (L->ci == L->base_ci) /* no enclosing function? */
|
if (L->ci == L->base_ci) /* no enclosing function? */
|
||||||
return hvalue(gt(L)); /* use global table as environment */
|
return hvalue(gt(L)); /* use global table as environment */
|
||||||
else {
|
else {
|
||||||
@ -87,13 +87,13 @@ static Table *ICACHE_FLASH_ATTR getcurrenv (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR luaA_pushobject (lua_State *L, const TValue *o) {
|
void luaA_pushobject (lua_State *L, const TValue *o) {
|
||||||
setobj2s(L, L->top, o);
|
setobj2s(L, L->top, o);
|
||||||
api_incr_top(L);
|
api_incr_top(L);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API int ICACHE_FLASH_ATTR lua_checkstack (lua_State *L, int size) {
|
LUA_API int lua_checkstack (lua_State *L, int size) {
|
||||||
int res = 1;
|
int res = 1;
|
||||||
lua_lock(L);
|
lua_lock(L);
|
||||||
if (size > LUAI_MAXCSTACK || (L->top - L->base + size) > LUAI_MAXCSTACK)
|
if (size > LUAI_MAXCSTACK || (L->top - L->base + size) > LUAI_MAXCSTACK)
|
||||||
@ -108,7 +108,7 @@ LUA_API int ICACHE_FLASH_ATTR lua_checkstack (lua_State *L, int size) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API void ICACHE_FLASH_ATTR lua_xmove (lua_State *from, lua_State *to, int n) {
|
LUA_API void lua_xmove (lua_State *from, lua_State *to, int n) {
|
||||||
int i;
|
int i;
|
||||||
if (from == to) return;
|
if (from == to) return;
|
||||||
lua_lock(to);
|
lua_lock(to);
|
||||||
@ -123,12 +123,12 @@ LUA_API void ICACHE_FLASH_ATTR lua_xmove (lua_State *from, lua_State *to, int n)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API void ICACHE_FLASH_ATTR lua_setlevel (lua_State *from, lua_State *to) {
|
LUA_API void lua_setlevel (lua_State *from, lua_State *to) {
|
||||||
to->nCcalls = from->nCcalls;
|
to->nCcalls = from->nCcalls;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API lua_CFunction ICACHE_FLASH_ATTR lua_atpanic (lua_State *L, lua_CFunction panicf) {
|
LUA_API lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf) {
|
||||||
lua_CFunction old;
|
lua_CFunction old;
|
||||||
lua_lock(L);
|
lua_lock(L);
|
||||||
old = G(L)->panic;
|
old = G(L)->panic;
|
||||||
@ -138,7 +138,7 @@ LUA_API lua_CFunction ICACHE_FLASH_ATTR lua_atpanic (lua_State *L, lua_CFunction
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API lua_State *ICACHE_FLASH_ATTR lua_newthread (lua_State *L) {
|
LUA_API lua_State *lua_newthread (lua_State *L) {
|
||||||
lua_State *L1;
|
lua_State *L1;
|
||||||
lua_lock(L);
|
lua_lock(L);
|
||||||
luaC_checkGC(L);
|
luaC_checkGC(L);
|
||||||
@ -157,12 +157,12 @@ LUA_API lua_State *ICACHE_FLASH_ATTR lua_newthread (lua_State *L) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
LUA_API int ICACHE_FLASH_ATTR lua_gettop (lua_State *L) {
|
LUA_API int lua_gettop (lua_State *L) {
|
||||||
return cast_int(L->top - L->base);
|
return cast_int(L->top - L->base);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API void ICACHE_FLASH_ATTR lua_settop (lua_State *L, int idx) {
|
LUA_API void lua_settop (lua_State *L, int idx) {
|
||||||
lua_lock(L);
|
lua_lock(L);
|
||||||
if (idx >= 0) {
|
if (idx >= 0) {
|
||||||
api_check(L, idx <= L->stack_last - L->base);
|
api_check(L, idx <= L->stack_last - L->base);
|
||||||
@ -178,7 +178,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_settop (lua_State *L, int idx) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API void ICACHE_FLASH_ATTR lua_remove (lua_State *L, int idx) {
|
LUA_API void lua_remove (lua_State *L, int idx) {
|
||||||
StkId p;
|
StkId p;
|
||||||
lua_lock(L);
|
lua_lock(L);
|
||||||
p = index2adr(L, idx);
|
p = index2adr(L, idx);
|
||||||
@ -189,7 +189,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_remove (lua_State *L, int idx) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API void ICACHE_FLASH_ATTR lua_insert (lua_State *L, int idx) {
|
LUA_API void lua_insert (lua_State *L, int idx) {
|
||||||
StkId p;
|
StkId p;
|
||||||
StkId q;
|
StkId q;
|
||||||
lua_lock(L);
|
lua_lock(L);
|
||||||
@ -201,7 +201,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_insert (lua_State *L, int idx) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API void ICACHE_FLASH_ATTR lua_replace (lua_State *L, int idx) {
|
LUA_API void lua_replace (lua_State *L, int idx) {
|
||||||
StkId o;
|
StkId o;
|
||||||
lua_lock(L);
|
lua_lock(L);
|
||||||
/* explicit test for incompatible code */
|
/* explicit test for incompatible code */
|
||||||
@ -230,7 +230,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_replace (lua_State *L, int idx) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API void ICACHE_FLASH_ATTR lua_pushvalue (lua_State *L, int idx) {
|
LUA_API void lua_pushvalue (lua_State *L, int idx) {
|
||||||
lua_lock(L);
|
lua_lock(L);
|
||||||
setobj2s(L, L->top, index2adr(L, idx));
|
setobj2s(L, L->top, index2adr(L, idx));
|
||||||
api_incr_top(L);
|
api_incr_top(L);
|
||||||
@ -244,44 +244,44 @@ LUA_API void ICACHE_FLASH_ATTR lua_pushvalue (lua_State *L, int idx) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
LUA_API int ICACHE_FLASH_ATTR lua_type (lua_State *L, int idx) {
|
LUA_API int lua_type (lua_State *L, int idx) {
|
||||||
StkId o = index2adr(L, idx);
|
StkId o = index2adr(L, idx);
|
||||||
return (o == luaO_nilobject) ? LUA_TNONE : ttype(o);
|
return (o == luaO_nilobject) ? LUA_TNONE : ttype(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API const char *ICACHE_FLASH_ATTR lua_typename (lua_State *L, int t) {
|
LUA_API const char *lua_typename (lua_State *L, int t) {
|
||||||
UNUSED(L);
|
UNUSED(L);
|
||||||
return (t == LUA_TNONE) ? "no value" : luaT_typenames[t];
|
return (t == LUA_TNONE) ? "no value" : luaT_typenames[t];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API int ICACHE_FLASH_ATTR lua_iscfunction (lua_State *L, int idx) {
|
LUA_API int lua_iscfunction (lua_State *L, int idx) {
|
||||||
StkId o = index2adr(L, idx);
|
StkId o = index2adr(L, idx);
|
||||||
return iscfunction(o);
|
return iscfunction(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API int ICACHE_FLASH_ATTR lua_isnumber (lua_State *L, int idx) {
|
LUA_API int lua_isnumber (lua_State *L, int idx) {
|
||||||
TValue n;
|
TValue n;
|
||||||
const TValue *o = index2adr(L, idx);
|
const TValue *o = index2adr(L, idx);
|
||||||
return tonumber(o, &n);
|
return tonumber(o, &n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API int ICACHE_FLASH_ATTR lua_isstring (lua_State *L, int idx) {
|
LUA_API int lua_isstring (lua_State *L, int idx) {
|
||||||
int t = lua_type(L, idx);
|
int t = lua_type(L, idx);
|
||||||
return (t == LUA_TSTRING || t == LUA_TNUMBER);
|
return (t == LUA_TSTRING || t == LUA_TNUMBER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API int ICACHE_FLASH_ATTR lua_isuserdata (lua_State *L, int idx) {
|
LUA_API int lua_isuserdata (lua_State *L, int idx) {
|
||||||
const TValue *o = index2adr(L, idx);
|
const TValue *o = index2adr(L, idx);
|
||||||
return (ttisuserdata(o) || ttislightuserdata(o));
|
return (ttisuserdata(o) || ttislightuserdata(o));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API int ICACHE_FLASH_ATTR lua_rawequal (lua_State *L, int index1, int index2) {
|
LUA_API int lua_rawequal (lua_State *L, int index1, int index2) {
|
||||||
StkId o1 = index2adr(L, index1);
|
StkId o1 = index2adr(L, index1);
|
||||||
StkId o2 = index2adr(L, index2);
|
StkId o2 = index2adr(L, index2);
|
||||||
return (o1 == luaO_nilobject || o2 == luaO_nilobject) ? 0
|
return (o1 == luaO_nilobject || o2 == luaO_nilobject) ? 0
|
||||||
@ -289,7 +289,7 @@ LUA_API int ICACHE_FLASH_ATTR lua_rawequal (lua_State *L, int index1, int index2
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API int ICACHE_FLASH_ATTR lua_equal (lua_State *L, int index1, int index2) {
|
LUA_API int lua_equal (lua_State *L, int index1, int index2) {
|
||||||
StkId o1, o2;
|
StkId o1, o2;
|
||||||
int i;
|
int i;
|
||||||
lua_lock(L); /* may call tag method */
|
lua_lock(L); /* may call tag method */
|
||||||
@ -301,7 +301,7 @@ LUA_API int ICACHE_FLASH_ATTR lua_equal (lua_State *L, int index1, int index2) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API int ICACHE_FLASH_ATTR lua_lessthan (lua_State *L, int index1, int index2) {
|
LUA_API int lua_lessthan (lua_State *L, int index1, int index2) {
|
||||||
StkId o1, o2;
|
StkId o1, o2;
|
||||||
int i;
|
int i;
|
||||||
lua_lock(L); /* may call tag method */
|
lua_lock(L); /* may call tag method */
|
||||||
@ -315,7 +315,7 @@ LUA_API int ICACHE_FLASH_ATTR lua_lessthan (lua_State *L, int index1, int index2
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
LUA_API lua_Number ICACHE_FLASH_ATTR lua_tonumber (lua_State *L, int idx) {
|
LUA_API lua_Number lua_tonumber (lua_State *L, int idx) {
|
||||||
TValue n;
|
TValue n;
|
||||||
const TValue *o = index2adr(L, idx);
|
const TValue *o = index2adr(L, idx);
|
||||||
if (tonumber(o, &n))
|
if (tonumber(o, &n))
|
||||||
@ -325,7 +325,7 @@ LUA_API lua_Number ICACHE_FLASH_ATTR lua_tonumber (lua_State *L, int idx) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API lua_Integer ICACHE_FLASH_ATTR lua_tointeger (lua_State *L, int idx) {
|
LUA_API lua_Integer lua_tointeger (lua_State *L, int idx) {
|
||||||
TValue n;
|
TValue n;
|
||||||
const TValue *o = index2adr(L, idx);
|
const TValue *o = index2adr(L, idx);
|
||||||
if (tonumber(o, &n)) {
|
if (tonumber(o, &n)) {
|
||||||
@ -339,13 +339,13 @@ LUA_API lua_Integer ICACHE_FLASH_ATTR lua_tointeger (lua_State *L, int idx) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API int ICACHE_FLASH_ATTR lua_toboolean (lua_State *L, int idx) {
|
LUA_API int lua_toboolean (lua_State *L, int idx) {
|
||||||
const TValue *o = index2adr(L, idx);
|
const TValue *o = index2adr(L, idx);
|
||||||
return !l_isfalse(o);
|
return !l_isfalse(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API const char *ICACHE_FLASH_ATTR lua_tolstring (lua_State *L, int idx, size_t *len) {
|
LUA_API const char *lua_tolstring (lua_State *L, int idx, size_t *len) {
|
||||||
StkId o = index2adr(L, idx);
|
StkId o = index2adr(L, idx);
|
||||||
if (!ttisstring(o)) {
|
if (!ttisstring(o)) {
|
||||||
lua_lock(L); /* `luaV_tostring' may create a new string */
|
lua_lock(L); /* `luaV_tostring' may create a new string */
|
||||||
@ -363,7 +363,7 @@ LUA_API const char *ICACHE_FLASH_ATTR lua_tolstring (lua_State *L, int idx, size
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API size_t ICACHE_FLASH_ATTR lua_objlen (lua_State *L, int idx) {
|
LUA_API size_t lua_objlen (lua_State *L, int idx) {
|
||||||
StkId o = index2adr(L, idx);
|
StkId o = index2adr(L, idx);
|
||||||
switch (ttype(o)) {
|
switch (ttype(o)) {
|
||||||
case LUA_TSTRING: return tsvalue(o)->len;
|
case LUA_TSTRING: return tsvalue(o)->len;
|
||||||
@ -382,13 +382,13 @@ LUA_API size_t ICACHE_FLASH_ATTR lua_objlen (lua_State *L, int idx) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API lua_CFunction ICACHE_FLASH_ATTR lua_tocfunction (lua_State *L, int idx) {
|
LUA_API lua_CFunction lua_tocfunction (lua_State *L, int idx) {
|
||||||
StkId o = index2adr(L, idx);
|
StkId o = index2adr(L, idx);
|
||||||
return (!iscfunction(o)) ? NULL : clvalue(o)->c.f;
|
return (!iscfunction(o)) ? NULL : clvalue(o)->c.f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API void *ICACHE_FLASH_ATTR lua_touserdata (lua_State *L, int idx) {
|
LUA_API void *lua_touserdata (lua_State *L, int idx) {
|
||||||
StkId o = index2adr(L, idx);
|
StkId o = index2adr(L, idx);
|
||||||
switch (ttype(o)) {
|
switch (ttype(o)) {
|
||||||
case LUA_TUSERDATA: return (rawuvalue(o) + 1);
|
case LUA_TUSERDATA: return (rawuvalue(o) + 1);
|
||||||
@ -398,13 +398,13 @@ LUA_API void *ICACHE_FLASH_ATTR lua_touserdata (lua_State *L, int idx) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API lua_State *ICACHE_FLASH_ATTR lua_tothread (lua_State *L, int idx) {
|
LUA_API lua_State *lua_tothread (lua_State *L, int idx) {
|
||||||
StkId o = index2adr(L, idx);
|
StkId o = index2adr(L, idx);
|
||||||
return (!ttisthread(o)) ? NULL : thvalue(o);
|
return (!ttisthread(o)) ? NULL : thvalue(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API const void *ICACHE_FLASH_ATTR lua_topointer (lua_State *L, int idx) {
|
LUA_API const void *lua_topointer (lua_State *L, int idx) {
|
||||||
StkId o = index2adr(L, idx);
|
StkId o = index2adr(L, idx);
|
||||||
switch (ttype(o)) {
|
switch (ttype(o)) {
|
||||||
case LUA_TTABLE: return hvalue(o);
|
case LUA_TTABLE: return hvalue(o);
|
||||||
@ -427,7 +427,7 @@ LUA_API const void *ICACHE_FLASH_ATTR lua_topointer (lua_State *L, int idx) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
LUA_API void ICACHE_FLASH_ATTR lua_pushnil (lua_State *L) {
|
LUA_API void lua_pushnil (lua_State *L) {
|
||||||
lua_lock(L);
|
lua_lock(L);
|
||||||
setnilvalue(L->top);
|
setnilvalue(L->top);
|
||||||
api_incr_top(L);
|
api_incr_top(L);
|
||||||
@ -435,7 +435,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_pushnil (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API void ICACHE_FLASH_ATTR lua_pushnumber (lua_State *L, lua_Number n) {
|
LUA_API void lua_pushnumber (lua_State *L, lua_Number n) {
|
||||||
lua_lock(L);
|
lua_lock(L);
|
||||||
setnvalue(L->top, n);
|
setnvalue(L->top, n);
|
||||||
api_incr_top(L);
|
api_incr_top(L);
|
||||||
@ -443,7 +443,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_pushnumber (lua_State *L, lua_Number n) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API void ICACHE_FLASH_ATTR lua_pushinteger (lua_State *L, lua_Integer n) {
|
LUA_API void lua_pushinteger (lua_State *L, lua_Integer n) {
|
||||||
lua_lock(L);
|
lua_lock(L);
|
||||||
setnvalue(L->top, cast_num(n));
|
setnvalue(L->top, cast_num(n));
|
||||||
api_incr_top(L);
|
api_incr_top(L);
|
||||||
@ -451,7 +451,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_pushinteger (lua_State *L, lua_Integer n) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API void ICACHE_FLASH_ATTR lua_pushlstring (lua_State *L, const char *s, size_t len) {
|
LUA_API void lua_pushlstring (lua_State *L, const char *s, size_t len) {
|
||||||
lua_lock(L);
|
lua_lock(L);
|
||||||
luaC_checkGC(L);
|
luaC_checkGC(L);
|
||||||
setsvalue2s(L, L->top, luaS_newlstr(L, s, len));
|
setsvalue2s(L, L->top, luaS_newlstr(L, s, len));
|
||||||
@ -460,7 +460,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_pushlstring (lua_State *L, const char *s, siz
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API void ICACHE_FLASH_ATTR lua_pushrolstring (lua_State *L, const char *s, size_t len) {
|
LUA_API void lua_pushrolstring (lua_State *L, const char *s, size_t len) {
|
||||||
lua_lock(L);
|
lua_lock(L);
|
||||||
luaC_checkGC(L);
|
luaC_checkGC(L);
|
||||||
setsvalue2s(L, L->top, luaS_newrolstr(L, s, len));
|
setsvalue2s(L, L->top, luaS_newrolstr(L, s, len));
|
||||||
@ -469,7 +469,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_pushrolstring (lua_State *L, const char *s, s
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API void ICACHE_FLASH_ATTR lua_pushstring (lua_State *L, const char *s) {
|
LUA_API void lua_pushstring (lua_State *L, const char *s) {
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
lua_pushnil(L);
|
lua_pushnil(L);
|
||||||
else
|
else
|
||||||
@ -477,7 +477,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_pushstring (lua_State *L, const char *s) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API const char *ICACHE_FLASH_ATTR lua_pushvfstring (lua_State *L, const char *fmt,
|
LUA_API const char *lua_pushvfstring (lua_State *L, const char *fmt,
|
||||||
va_list argp) {
|
va_list argp) {
|
||||||
const char *ret;
|
const char *ret;
|
||||||
lua_lock(L);
|
lua_lock(L);
|
||||||
@ -488,7 +488,7 @@ LUA_API const char *ICACHE_FLASH_ATTR lua_pushvfstring (lua_State *L, const char
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API const char *ICACHE_FLASH_ATTR lua_pushfstring (lua_State *L, const char *fmt, ...) {
|
LUA_API const char *lua_pushfstring (lua_State *L, const char *fmt, ...) {
|
||||||
const char *ret;
|
const char *ret;
|
||||||
va_list argp;
|
va_list argp;
|
||||||
lua_lock(L);
|
lua_lock(L);
|
||||||
@ -501,7 +501,7 @@ LUA_API const char *ICACHE_FLASH_ATTR lua_pushfstring (lua_State *L, const char
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API void ICACHE_FLASH_ATTR lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) {
|
LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) {
|
||||||
Closure *cl;
|
Closure *cl;
|
||||||
lua_lock(L);
|
lua_lock(L);
|
||||||
luaC_checkGC(L);
|
luaC_checkGC(L);
|
||||||
@ -518,7 +518,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_pushcclosure (lua_State *L, lua_CFunction fn,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API void ICACHE_FLASH_ATTR lua_pushboolean (lua_State *L, int b) {
|
LUA_API void lua_pushboolean (lua_State *L, int b) {
|
||||||
lua_lock(L);
|
lua_lock(L);
|
||||||
setbvalue(L->top, (b != 0)); /* ensure that true is 1 */
|
setbvalue(L->top, (b != 0)); /* ensure that true is 1 */
|
||||||
api_incr_top(L);
|
api_incr_top(L);
|
||||||
@ -526,21 +526,21 @@ LUA_API void ICACHE_FLASH_ATTR lua_pushboolean (lua_State *L, int b) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API void ICACHE_FLASH_ATTR lua_pushlightuserdata (lua_State *L, void *p) {
|
LUA_API void lua_pushlightuserdata (lua_State *L, void *p) {
|
||||||
lua_lock(L);
|
lua_lock(L);
|
||||||
setpvalue(L->top, p);
|
setpvalue(L->top, p);
|
||||||
api_incr_top(L);
|
api_incr_top(L);
|
||||||
lua_unlock(L);
|
lua_unlock(L);
|
||||||
}
|
}
|
||||||
|
|
||||||
LUA_API void ICACHE_FLASH_ATTR lua_pushrotable (lua_State *L, void *p) {
|
LUA_API void lua_pushrotable (lua_State *L, void *p) {
|
||||||
lua_lock(L);
|
lua_lock(L);
|
||||||
setrvalue(L->top, p);
|
setrvalue(L->top, p);
|
||||||
api_incr_top(L);
|
api_incr_top(L);
|
||||||
lua_unlock(L);
|
lua_unlock(L);
|
||||||
}
|
}
|
||||||
|
|
||||||
LUA_API void ICACHE_FLASH_ATTR lua_pushlightfunction(lua_State *L, void *p) {
|
LUA_API void lua_pushlightfunction(lua_State *L, void *p) {
|
||||||
lua_lock(L);
|
lua_lock(L);
|
||||||
setfvalue(L->top, p);
|
setfvalue(L->top, p);
|
||||||
api_incr_top(L);
|
api_incr_top(L);
|
||||||
@ -548,7 +548,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_pushlightfunction(lua_State *L, void *p) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API int ICACHE_FLASH_ATTR lua_pushthread (lua_State *L) {
|
LUA_API int lua_pushthread (lua_State *L) {
|
||||||
lua_lock(L);
|
lua_lock(L);
|
||||||
setthvalue(L, L->top, L);
|
setthvalue(L, L->top, L);
|
||||||
api_incr_top(L);
|
api_incr_top(L);
|
||||||
@ -563,7 +563,7 @@ LUA_API int ICACHE_FLASH_ATTR lua_pushthread (lua_State *L) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
LUA_API void ICACHE_FLASH_ATTR lua_gettable (lua_State *L, int idx) {
|
LUA_API void lua_gettable (lua_State *L, int idx) {
|
||||||
StkId t;
|
StkId t;
|
||||||
lua_lock(L);
|
lua_lock(L);
|
||||||
t = index2adr(L, idx);
|
t = index2adr(L, idx);
|
||||||
@ -573,7 +573,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_gettable (lua_State *L, int idx) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API void ICACHE_FLASH_ATTR lua_getfield (lua_State *L, int idx, const char *k) {
|
LUA_API void lua_getfield (lua_State *L, int idx, const char *k) {
|
||||||
StkId t;
|
StkId t;
|
||||||
TValue key;
|
TValue key;
|
||||||
lua_lock(L);
|
lua_lock(L);
|
||||||
@ -588,7 +588,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_getfield (lua_State *L, int idx, const char *
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API void ICACHE_FLASH_ATTR lua_rawget (lua_State *L, int idx) {
|
LUA_API void lua_rawget (lua_State *L, int idx) {
|
||||||
StkId t;
|
StkId t;
|
||||||
const TValue *res;
|
const TValue *res;
|
||||||
lua_lock(L);
|
lua_lock(L);
|
||||||
@ -600,7 +600,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_rawget (lua_State *L, int idx) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API void ICACHE_FLASH_ATTR lua_rawgeti (lua_State *L, int idx, int n) {
|
LUA_API void lua_rawgeti (lua_State *L, int idx, int n) {
|
||||||
StkId o;
|
StkId o;
|
||||||
lua_lock(L);
|
lua_lock(L);
|
||||||
o = index2adr(L, idx);
|
o = index2adr(L, idx);
|
||||||
@ -611,7 +611,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_rawgeti (lua_State *L, int idx, int n) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API void ICACHE_FLASH_ATTR lua_createtable (lua_State *L, int narray, int nrec) {
|
LUA_API void lua_createtable (lua_State *L, int narray, int nrec) {
|
||||||
lua_lock(L);
|
lua_lock(L);
|
||||||
luaC_checkGC(L);
|
luaC_checkGC(L);
|
||||||
sethvalue(L, L->top, luaH_new(L, narray, nrec));
|
sethvalue(L, L->top, luaH_new(L, narray, nrec));
|
||||||
@ -620,7 +620,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_createtable (lua_State *L, int narray, int nr
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API int ICACHE_FLASH_ATTR lua_getmetatable (lua_State *L, int objindex) {
|
LUA_API int lua_getmetatable (lua_State *L, int objindex) {
|
||||||
const TValue *obj;
|
const TValue *obj;
|
||||||
Table *mt = NULL;
|
Table *mt = NULL;
|
||||||
int res;
|
int res;
|
||||||
@ -655,7 +655,7 @@ LUA_API int ICACHE_FLASH_ATTR lua_getmetatable (lua_State *L, int objindex) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API void ICACHE_FLASH_ATTR lua_getfenv (lua_State *L, int idx) {
|
LUA_API void lua_getfenv (lua_State *L, int idx) {
|
||||||
StkId o;
|
StkId o;
|
||||||
lua_lock(L);
|
lua_lock(L);
|
||||||
o = index2adr(L, idx);
|
o = index2adr(L, idx);
|
||||||
@ -684,7 +684,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_getfenv (lua_State *L, int idx) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
LUA_API void ICACHE_FLASH_ATTR lua_settable (lua_State *L, int idx) {
|
LUA_API void lua_settable (lua_State *L, int idx) {
|
||||||
StkId t;
|
StkId t;
|
||||||
lua_lock(L);
|
lua_lock(L);
|
||||||
api_checknelems(L, 2);
|
api_checknelems(L, 2);
|
||||||
@ -696,7 +696,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_settable (lua_State *L, int idx) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API void ICACHE_FLASH_ATTR lua_setfield (lua_State *L, int idx, const char *k) {
|
LUA_API void lua_setfield (lua_State *L, int idx, const char *k) {
|
||||||
StkId t;
|
StkId t;
|
||||||
lua_lock(L);
|
lua_lock(L);
|
||||||
api_checknelems(L, 1);
|
api_checknelems(L, 1);
|
||||||
@ -710,7 +710,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_setfield (lua_State *L, int idx, const char *
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API void ICACHE_FLASH_ATTR lua_rawset (lua_State *L, int idx) {
|
LUA_API void lua_rawset (lua_State *L, int idx) {
|
||||||
StkId t;
|
StkId t;
|
||||||
lua_lock(L);
|
lua_lock(L);
|
||||||
api_checknelems(L, 2);
|
api_checknelems(L, 2);
|
||||||
@ -725,7 +725,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_rawset (lua_State *L, int idx) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API void ICACHE_FLASH_ATTR lua_rawseti (lua_State *L, int idx, int n) {
|
LUA_API void lua_rawseti (lua_State *L, int idx, int n) {
|
||||||
StkId o;
|
StkId o;
|
||||||
lua_lock(L);
|
lua_lock(L);
|
||||||
api_checknelems(L, 1);
|
api_checknelems(L, 1);
|
||||||
@ -740,7 +740,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_rawseti (lua_State *L, int idx, int n) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API int ICACHE_FLASH_ATTR lua_setmetatable (lua_State *L, int objindex) {
|
LUA_API int lua_setmetatable (lua_State *L, int objindex) {
|
||||||
TValue *obj;
|
TValue *obj;
|
||||||
Table *mt;
|
Table *mt;
|
||||||
int isrometa = 0;
|
int isrometa = 0;
|
||||||
@ -783,7 +783,7 @@ LUA_API int ICACHE_FLASH_ATTR lua_setmetatable (lua_State *L, int objindex) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API int ICACHE_FLASH_ATTR lua_setfenv (lua_State *L, int idx) {
|
LUA_API int lua_setfenv (lua_State *L, int idx) {
|
||||||
StkId o;
|
StkId o;
|
||||||
int res = 1;
|
int res = 1;
|
||||||
lua_lock(L);
|
lua_lock(L);
|
||||||
@ -825,7 +825,7 @@ LUA_API int ICACHE_FLASH_ATTR lua_setfenv (lua_State *L, int idx) {
|
|||||||
api_check(L, (nr) == LUA_MULTRET || (L->ci->top - L->top >= (nr) - (na)))
|
api_check(L, (nr) == LUA_MULTRET || (L->ci->top - L->top >= (nr) - (na)))
|
||||||
|
|
||||||
|
|
||||||
LUA_API void ICACHE_FLASH_ATTR lua_call (lua_State *L, int nargs, int nresults) {
|
LUA_API void lua_call (lua_State *L, int nargs, int nresults) {
|
||||||
StkId func;
|
StkId func;
|
||||||
lua_lock(L);
|
lua_lock(L);
|
||||||
api_checknelems(L, nargs+1);
|
api_checknelems(L, nargs+1);
|
||||||
@ -847,14 +847,14 @@ struct CallS { /* data to `f_call' */
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR f_call (lua_State *L, void *ud) {
|
static void f_call (lua_State *L, void *ud) {
|
||||||
struct CallS *c = cast(struct CallS *, ud);
|
struct CallS *c = cast(struct CallS *, ud);
|
||||||
luaD_call(L, c->func, c->nresults);
|
luaD_call(L, c->func, c->nresults);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
LUA_API int ICACHE_FLASH_ATTR lua_pcall (lua_State *L, int nargs, int nresults, int errfunc) {
|
LUA_API int lua_pcall (lua_State *L, int nargs, int nresults, int errfunc) {
|
||||||
struct CallS c;
|
struct CallS c;
|
||||||
int status;
|
int status;
|
||||||
ptrdiff_t func;
|
ptrdiff_t func;
|
||||||
@ -886,7 +886,7 @@ struct CCallS { /* data to `f_Ccall' */
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR f_Ccall (lua_State *L, void *ud) {
|
static void f_Ccall (lua_State *L, void *ud) {
|
||||||
struct CCallS *c = cast(struct CCallS *, ud);
|
struct CCallS *c = cast(struct CCallS *, ud);
|
||||||
Closure *cl;
|
Closure *cl;
|
||||||
cl = luaF_newCclosure(L, 0, getcurrenv(L));
|
cl = luaF_newCclosure(L, 0, getcurrenv(L));
|
||||||
@ -899,7 +899,7 @@ static void ICACHE_FLASH_ATTR f_Ccall (lua_State *L, void *ud) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API int ICACHE_FLASH_ATTR lua_cpcall (lua_State *L, lua_CFunction func, void *ud) {
|
LUA_API int lua_cpcall (lua_State *L, lua_CFunction func, void *ud) {
|
||||||
struct CCallS c;
|
struct CCallS c;
|
||||||
int status;
|
int status;
|
||||||
lua_lock(L);
|
lua_lock(L);
|
||||||
@ -911,7 +911,7 @@ LUA_API int ICACHE_FLASH_ATTR lua_cpcall (lua_State *L, lua_CFunction func, void
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API int ICACHE_FLASH_ATTR lua_load (lua_State *L, lua_Reader reader, void *data,
|
LUA_API int lua_load (lua_State *L, lua_Reader reader, void *data,
|
||||||
const char *chunkname) {
|
const char *chunkname) {
|
||||||
ZIO z;
|
ZIO z;
|
||||||
int status;
|
int status;
|
||||||
@ -924,7 +924,7 @@ LUA_API int ICACHE_FLASH_ATTR lua_load (lua_State *L, lua_Reader reader, void *d
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API int ICACHE_FLASH_ATTR lua_dump (lua_State *L, lua_Writer writer, void *data) {
|
LUA_API int lua_dump (lua_State *L, lua_Writer writer, void *data) {
|
||||||
int status;
|
int status;
|
||||||
TValue *o;
|
TValue *o;
|
||||||
lua_lock(L);
|
lua_lock(L);
|
||||||
@ -939,7 +939,7 @@ LUA_API int ICACHE_FLASH_ATTR lua_dump (lua_State *L, lua_Writer writer, void *d
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API int ICACHE_FLASH_ATTR lua_status (lua_State *L) {
|
LUA_API int lua_status (lua_State *L) {
|
||||||
return L->status;
|
return L->status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -948,7 +948,7 @@ LUA_API int ICACHE_FLASH_ATTR lua_status (lua_State *L) {
|
|||||||
** Garbage-collection function
|
** Garbage-collection function
|
||||||
*/
|
*/
|
||||||
|
|
||||||
LUA_API int ICACHE_FLASH_ATTR lua_gc (lua_State *L, int what, int data) {
|
LUA_API int lua_gc (lua_State *L, int what, int data) {
|
||||||
int res = 0;
|
int res = 0;
|
||||||
global_State *g;
|
global_State *g;
|
||||||
lua_lock(L);
|
lua_lock(L);
|
||||||
@ -1035,7 +1035,7 @@ LUA_API int ICACHE_FLASH_ATTR lua_gc (lua_State *L, int what, int data) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
LUA_API int ICACHE_FLASH_ATTR lua_error (lua_State *L) {
|
LUA_API int lua_error (lua_State *L) {
|
||||||
lua_lock(L);
|
lua_lock(L);
|
||||||
api_checknelems(L, 1);
|
api_checknelems(L, 1);
|
||||||
luaG_errormsg(L);
|
luaG_errormsg(L);
|
||||||
@ -1044,7 +1044,7 @@ LUA_API int ICACHE_FLASH_ATTR lua_error (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API int ICACHE_FLASH_ATTR lua_next (lua_State *L, int idx) {
|
LUA_API int lua_next (lua_State *L, int idx) {
|
||||||
StkId t;
|
StkId t;
|
||||||
int more;
|
int more;
|
||||||
lua_lock(L);
|
lua_lock(L);
|
||||||
@ -1061,7 +1061,7 @@ LUA_API int ICACHE_FLASH_ATTR lua_next (lua_State *L, int idx) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API void ICACHE_FLASH_ATTR lua_concat (lua_State *L, int n) {
|
LUA_API void lua_concat (lua_State *L, int n) {
|
||||||
lua_lock(L);
|
lua_lock(L);
|
||||||
api_checknelems(L, n);
|
api_checknelems(L, n);
|
||||||
if (n >= 2) {
|
if (n >= 2) {
|
||||||
@ -1078,7 +1078,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_concat (lua_State *L, int n) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API lua_Alloc ICACHE_FLASH_ATTR lua_getallocf (lua_State *L, void **ud) {
|
LUA_API lua_Alloc lua_getallocf (lua_State *L, void **ud) {
|
||||||
lua_Alloc f;
|
lua_Alloc f;
|
||||||
lua_lock(L);
|
lua_lock(L);
|
||||||
if (ud) *ud = G(L)->ud;
|
if (ud) *ud = G(L)->ud;
|
||||||
@ -1088,7 +1088,7 @@ LUA_API lua_Alloc ICACHE_FLASH_ATTR lua_getallocf (lua_State *L, void **ud) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API void ICACHE_FLASH_ATTR lua_setallocf (lua_State *L, lua_Alloc f, void *ud) {
|
LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud) {
|
||||||
lua_lock(L);
|
lua_lock(L);
|
||||||
G(L)->ud = ud;
|
G(L)->ud = ud;
|
||||||
G(L)->frealloc = f;
|
G(L)->frealloc = f;
|
||||||
@ -1096,7 +1096,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_setallocf (lua_State *L, lua_Alloc f, void *u
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API void *ICACHE_FLASH_ATTR lua_newuserdata (lua_State *L, size_t size) {
|
LUA_API void *lua_newuserdata (lua_State *L, size_t size) {
|
||||||
Udata *u;
|
Udata *u;
|
||||||
lua_lock(L);
|
lua_lock(L);
|
||||||
luaC_checkGC(L);
|
luaC_checkGC(L);
|
||||||
@ -1110,7 +1110,7 @@ LUA_API void *ICACHE_FLASH_ATTR lua_newuserdata (lua_State *L, size_t size) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static const char *ICACHE_FLASH_ATTR aux_upvalue (StkId fi, int n, TValue **val) {
|
static const char *aux_upvalue (StkId fi, int n, TValue **val) {
|
||||||
Closure *f;
|
Closure *f;
|
||||||
if (!ttisfunction(fi)) return NULL;
|
if (!ttisfunction(fi)) return NULL;
|
||||||
f = clvalue(fi);
|
f = clvalue(fi);
|
||||||
@ -1128,7 +1128,7 @@ static const char *ICACHE_FLASH_ATTR aux_upvalue (StkId fi, int n, TValue **val)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API const char *ICACHE_FLASH_ATTR lua_getupvalue (lua_State *L, int funcindex, int n) {
|
LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n) {
|
||||||
const char *name;
|
const char *name;
|
||||||
TValue *val;
|
TValue *val;
|
||||||
lua_lock(L);
|
lua_lock(L);
|
||||||
@ -1142,7 +1142,7 @@ LUA_API const char *ICACHE_FLASH_ATTR lua_getupvalue (lua_State *L, int funcinde
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API const char *ICACHE_FLASH_ATTR lua_setupvalue (lua_State *L, int funcindex, int n) {
|
LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n) {
|
||||||
const char *name;
|
const char *name;
|
||||||
TValue *val;
|
TValue *val;
|
||||||
StkId fi;
|
StkId fi;
|
||||||
|
@ -49,7 +49,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
LUALIB_API int ICACHE_FLASH_ATTR luaL_argerror (lua_State *L, int narg, const char *extramsg) {
|
LUALIB_API int luaL_argerror (lua_State *L, int narg, const char *extramsg) {
|
||||||
lua_Debug ar;
|
lua_Debug ar;
|
||||||
if (!lua_getstack(L, 0, &ar)) /* no stack frame? */
|
if (!lua_getstack(L, 0, &ar)) /* no stack frame? */
|
||||||
return luaL_error(L, "bad argument #%d (%s)", narg, extramsg);
|
return luaL_error(L, "bad argument #%d (%s)", narg, extramsg);
|
||||||
@ -67,19 +67,19 @@ LUALIB_API int ICACHE_FLASH_ATTR luaL_argerror (lua_State *L, int narg, const ch
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUALIB_API int ICACHE_FLASH_ATTR luaL_typerror (lua_State *L, int narg, const char *tname) {
|
LUALIB_API int luaL_typerror (lua_State *L, int narg, const char *tname) {
|
||||||
const char *msg = lua_pushfstring(L, "%s expected, got %s",
|
const char *msg = lua_pushfstring(L, "%s expected, got %s",
|
||||||
tname, luaL_typename(L, narg));
|
tname, luaL_typename(L, narg));
|
||||||
return luaL_argerror(L, narg, msg);
|
return luaL_argerror(L, narg, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR tag_error (lua_State *L, int narg, int tag) {
|
static void tag_error (lua_State *L, int narg, int tag) {
|
||||||
luaL_typerror(L, narg, lua_typename(L, tag));
|
luaL_typerror(L, narg, lua_typename(L, tag));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUALIB_API void ICACHE_FLASH_ATTR luaL_where (lua_State *L, int level) {
|
LUALIB_API void luaL_where (lua_State *L, int level) {
|
||||||
lua_Debug ar;
|
lua_Debug ar;
|
||||||
if (lua_getstack(L, level, &ar)) { /* check function at level */
|
if (lua_getstack(L, level, &ar)) { /* check function at level */
|
||||||
lua_getinfo(L, "Sl", &ar); /* get info about it */
|
lua_getinfo(L, "Sl", &ar); /* get info about it */
|
||||||
@ -92,7 +92,7 @@ LUALIB_API void ICACHE_FLASH_ATTR luaL_where (lua_State *L, int level) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUALIB_API int ICACHE_FLASH_ATTR luaL_error (lua_State *L, const char *fmt, ...) {
|
LUALIB_API int luaL_error (lua_State *L, const char *fmt, ...) {
|
||||||
va_list argp;
|
va_list argp;
|
||||||
va_start(argp, fmt);
|
va_start(argp, fmt);
|
||||||
luaL_where(L, 1);
|
luaL_where(L, 1);
|
||||||
@ -105,7 +105,7 @@ LUALIB_API int ICACHE_FLASH_ATTR luaL_error (lua_State *L, const char *fmt, ...)
|
|||||||
/* }====================================================== */
|
/* }====================================================== */
|
||||||
|
|
||||||
|
|
||||||
LUALIB_API int ICACHE_FLASH_ATTR luaL_checkoption (lua_State *L, int narg, const char *def,
|
LUALIB_API int luaL_checkoption (lua_State *L, int narg, const char *def,
|
||||||
const char *const lst[]) {
|
const char *const lst[]) {
|
||||||
const char *name = (def) ? luaL_optstring(L, narg, def) :
|
const char *name = (def) ? luaL_optstring(L, narg, def) :
|
||||||
luaL_checkstring(L, narg);
|
luaL_checkstring(L, narg);
|
||||||
@ -118,7 +118,7 @@ LUALIB_API int ICACHE_FLASH_ATTR luaL_checkoption (lua_State *L, int narg, const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUALIB_API int ICACHE_FLASH_ATTR luaL_newmetatable (lua_State *L, const char *tname) {
|
LUALIB_API int luaL_newmetatable (lua_State *L, const char *tname) {
|
||||||
lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get registry.name */
|
lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get registry.name */
|
||||||
if (!lua_isnil(L, -1)) /* name already in use? */
|
if (!lua_isnil(L, -1)) /* name already in use? */
|
||||||
return 0; /* leave previous value on top, but return 0 */
|
return 0; /* leave previous value on top, but return 0 */
|
||||||
@ -129,7 +129,7 @@ LUALIB_API int ICACHE_FLASH_ATTR luaL_newmetatable (lua_State *L, const char *tn
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
LUALIB_API int ICACHE_FLASH_ATTR luaL_rometatable (lua_State *L, const char* tname, void *p) {
|
LUALIB_API int luaL_rometatable (lua_State *L, const char* tname, void *p) {
|
||||||
lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get registry.name */
|
lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get registry.name */
|
||||||
if (!lua_isnil(L, -1)) /* name already in use? */
|
if (!lua_isnil(L, -1)) /* name already in use? */
|
||||||
return 0; /* leave previous value on top, but return 0 */
|
return 0; /* leave previous value on top, but return 0 */
|
||||||
@ -140,7 +140,7 @@ LUALIB_API int ICACHE_FLASH_ATTR luaL_rometatable (lua_State *L, const char* tna
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
LUALIB_API void *ICACHE_FLASH_ATTR luaL_checkudata (lua_State *L, int ud, const char *tname) {
|
LUALIB_API void *luaL_checkudata (lua_State *L, int ud, const char *tname) {
|
||||||
void *p = lua_touserdata(L, ud);
|
void *p = lua_touserdata(L, ud);
|
||||||
if (p != NULL) { /* value is a userdata? */
|
if (p != NULL) { /* value is a userdata? */
|
||||||
if (lua_getmetatable(L, ud)) { /* does it have a metatable? */
|
if (lua_getmetatable(L, ud)) { /* does it have a metatable? */
|
||||||
@ -156,18 +156,18 @@ LUALIB_API void *ICACHE_FLASH_ATTR luaL_checkudata (lua_State *L, int ud, const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUALIB_API void ICACHE_FLASH_ATTR luaL_checkstack (lua_State *L, int space, const char *mes) {
|
LUALIB_API void luaL_checkstack (lua_State *L, int space, const char *mes) {
|
||||||
if (!lua_checkstack(L, space))
|
if (!lua_checkstack(L, space))
|
||||||
luaL_error(L, "stack overflow (%s)", mes);
|
luaL_error(L, "stack overflow (%s)", mes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUALIB_API void ICACHE_FLASH_ATTR luaL_checktype (lua_State *L, int narg, int t) {
|
LUALIB_API void luaL_checktype (lua_State *L, int narg, int t) {
|
||||||
if (lua_type(L, narg) != t)
|
if (lua_type(L, narg) != t)
|
||||||
tag_error(L, narg, t);
|
tag_error(L, narg, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
LUALIB_API void ICACHE_FLASH_ATTR luaL_checkanyfunction (lua_State *L, int narg) {
|
LUALIB_API void luaL_checkanyfunction (lua_State *L, int narg) {
|
||||||
if (lua_type(L, narg) != LUA_TFUNCTION && lua_type(L, narg) != LUA_TLIGHTFUNCTION) {
|
if (lua_type(L, narg) != LUA_TFUNCTION && lua_type(L, narg) != LUA_TLIGHTFUNCTION) {
|
||||||
const char *msg = lua_pushfstring(L, "function or lightfunction expected, got %s",
|
const char *msg = lua_pushfstring(L, "function or lightfunction expected, got %s",
|
||||||
luaL_typename(L, narg));
|
luaL_typename(L, narg));
|
||||||
@ -175,7 +175,7 @@ LUALIB_API void ICACHE_FLASH_ATTR luaL_checkanyfunction (lua_State *L, int narg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LUALIB_API void ICACHE_FLASH_ATTR luaL_checkanytable (lua_State *L, int narg) {
|
LUALIB_API void luaL_checkanytable (lua_State *L, int narg) {
|
||||||
if (lua_type(L, narg) != LUA_TTABLE && lua_type(L, narg) != LUA_TROTABLE) {
|
if (lua_type(L, narg) != LUA_TTABLE && lua_type(L, narg) != LUA_TROTABLE) {
|
||||||
const char *msg = lua_pushfstring(L, "table or rotable expected, got %s",
|
const char *msg = lua_pushfstring(L, "table or rotable expected, got %s",
|
||||||
luaL_typename(L, narg));
|
luaL_typename(L, narg));
|
||||||
@ -184,20 +184,20 @@ LUALIB_API void ICACHE_FLASH_ATTR luaL_checkanytable (lua_State *L, int narg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUALIB_API void ICACHE_FLASH_ATTR luaL_checkany (lua_State *L, int narg) {
|
LUALIB_API void luaL_checkany (lua_State *L, int narg) {
|
||||||
if (lua_type(L, narg) == LUA_TNONE)
|
if (lua_type(L, narg) == LUA_TNONE)
|
||||||
luaL_argerror(L, narg, "value expected");
|
luaL_argerror(L, narg, "value expected");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUALIB_API const char *ICACHE_FLASH_ATTR luaL_checklstring (lua_State *L, int narg, size_t *len) {
|
LUALIB_API const char *luaL_checklstring (lua_State *L, int narg, size_t *len) {
|
||||||
const char *s = lua_tolstring(L, narg, len);
|
const char *s = lua_tolstring(L, narg, len);
|
||||||
if (!s) tag_error(L, narg, LUA_TSTRING);
|
if (!s) tag_error(L, narg, LUA_TSTRING);
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUALIB_API const char *ICACHE_FLASH_ATTR luaL_optlstring (lua_State *L, int narg,
|
LUALIB_API const char *luaL_optlstring (lua_State *L, int narg,
|
||||||
const char *def, size_t *len) {
|
const char *def, size_t *len) {
|
||||||
if (lua_isnoneornil(L, narg)) {
|
if (lua_isnoneornil(L, narg)) {
|
||||||
if (len)
|
if (len)
|
||||||
@ -208,7 +208,7 @@ LUALIB_API const char *ICACHE_FLASH_ATTR luaL_optlstring (lua_State *L, int narg
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUALIB_API lua_Number ICACHE_FLASH_ATTR luaL_checknumber (lua_State *L, int narg) {
|
LUALIB_API lua_Number luaL_checknumber (lua_State *L, int narg) {
|
||||||
lua_Number d = lua_tonumber(L, narg);
|
lua_Number d = lua_tonumber(L, narg);
|
||||||
if (d == 0 && !lua_isnumber(L, narg)) /* avoid extra test when d is not 0 */
|
if (d == 0 && !lua_isnumber(L, narg)) /* avoid extra test when d is not 0 */
|
||||||
tag_error(L, narg, LUA_TNUMBER);
|
tag_error(L, narg, LUA_TNUMBER);
|
||||||
@ -216,12 +216,12 @@ LUALIB_API lua_Number ICACHE_FLASH_ATTR luaL_checknumber (lua_State *L, int narg
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUALIB_API lua_Number ICACHE_FLASH_ATTR luaL_optnumber (lua_State *L, int narg, lua_Number def) {
|
LUALIB_API lua_Number luaL_optnumber (lua_State *L, int narg, lua_Number def) {
|
||||||
return luaL_opt(L, luaL_checknumber, narg, def);
|
return luaL_opt(L, luaL_checknumber, narg, def);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUALIB_API lua_Integer ICACHE_FLASH_ATTR luaL_checkinteger (lua_State *L, int narg) {
|
LUALIB_API lua_Integer luaL_checkinteger (lua_State *L, int narg) {
|
||||||
lua_Integer d = lua_tointeger(L, narg);
|
lua_Integer d = lua_tointeger(L, narg);
|
||||||
if (d == 0 && !lua_isnumber(L, narg)) /* avoid extra test when d is not 0 */
|
if (d == 0 && !lua_isnumber(L, narg)) /* avoid extra test when d is not 0 */
|
||||||
tag_error(L, narg, LUA_TNUMBER);
|
tag_error(L, narg, LUA_TNUMBER);
|
||||||
@ -229,13 +229,13 @@ LUALIB_API lua_Integer ICACHE_FLASH_ATTR luaL_checkinteger (lua_State *L, int na
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUALIB_API lua_Integer ICACHE_FLASH_ATTR luaL_optinteger (lua_State *L, int narg,
|
LUALIB_API lua_Integer luaL_optinteger (lua_State *L, int narg,
|
||||||
lua_Integer def) {
|
lua_Integer def) {
|
||||||
return luaL_opt(L, luaL_checkinteger, narg, def);
|
return luaL_opt(L, luaL_checkinteger, narg, def);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUALIB_API int ICACHE_FLASH_ATTR luaL_getmetafield (lua_State *L, int obj, const char *event) {
|
LUALIB_API int luaL_getmetafield (lua_State *L, int obj, const char *event) {
|
||||||
if (!lua_getmetatable(L, obj)) /* no metatable? */
|
if (!lua_getmetatable(L, obj)) /* no metatable? */
|
||||||
return 0;
|
return 0;
|
||||||
lua_pushstring(L, event);
|
lua_pushstring(L, event);
|
||||||
@ -251,7 +251,7 @@ LUALIB_API int ICACHE_FLASH_ATTR luaL_getmetafield (lua_State *L, int obj, const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUALIB_API int ICACHE_FLASH_ATTR luaL_callmeta (lua_State *L, int obj, const char *event) {
|
LUALIB_API int luaL_callmeta (lua_State *L, int obj, const char *event) {
|
||||||
obj = abs_index(L, obj);
|
obj = abs_index(L, obj);
|
||||||
if (!luaL_getmetafield(L, obj, event)) /* no metafield? */
|
if (!luaL_getmetafield(L, obj, event)) /* no metafield? */
|
||||||
return 0;
|
return 0;
|
||||||
@ -261,12 +261,12 @@ LUALIB_API int ICACHE_FLASH_ATTR luaL_callmeta (lua_State *L, int obj, const cha
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUALIB_API void ICACHE_FLASH_ATTR (luaL_register) (lua_State *L, const char *libname,
|
LUALIB_API void (luaL_register) (lua_State *L, const char *libname,
|
||||||
const luaL_Reg *l) {
|
const luaL_Reg *l) {
|
||||||
luaI_openlib(L, libname, l, 0, LUA_USECCLOSURES);
|
luaI_openlib(L, libname, l, 0, LUA_USECCLOSURES);
|
||||||
}
|
}
|
||||||
|
|
||||||
LUALIB_API void ICACHE_FLASH_ATTR (luaL_register_light) (lua_State *L, const char *libname,
|
LUALIB_API void (luaL_register_light) (lua_State *L, const char *libname,
|
||||||
const luaL_Reg *l) {
|
const luaL_Reg *l) {
|
||||||
#if LUA_OPTIMIZE_MEMORY > 0
|
#if LUA_OPTIMIZE_MEMORY > 0
|
||||||
luaI_openlib(L, libname, l, 0, LUA_USELIGHTFUNCTIONS);
|
luaI_openlib(L, libname, l, 0, LUA_USELIGHTFUNCTIONS);
|
||||||
@ -275,14 +275,14 @@ LUALIB_API void ICACHE_FLASH_ATTR (luaL_register_light) (lua_State *L, const cha
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR libsize (const luaL_Reg *l) {
|
static int libsize (const luaL_Reg *l) {
|
||||||
int size = 0;
|
int size = 0;
|
||||||
for (; l->name; l++) size++;
|
for (; l->name; l++) size++;
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUALIB_API void ICACHE_FLASH_ATTR luaI_openlib (lua_State *L, const char *libname,
|
LUALIB_API void luaI_openlib (lua_State *L, const char *libname,
|
||||||
const luaL_Reg *l, int nup, int ftype) {
|
const luaL_Reg *l, int nup, int ftype) {
|
||||||
if (libname) {
|
if (libname) {
|
||||||
int size = libsize(l);
|
int size = libsize(l);
|
||||||
@ -323,14 +323,14 @@ LUALIB_API void ICACHE_FLASH_ATTR luaI_openlib (lua_State *L, const char *libnam
|
|||||||
|
|
||||||
#if defined(LUA_COMPAT_GETN)
|
#if defined(LUA_COMPAT_GETN)
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR checkint (lua_State *L, int topop) {
|
static int checkint (lua_State *L, int topop) {
|
||||||
int n = (lua_type(L, -1) == LUA_TNUMBER) ? lua_tointeger(L, -1) : -1;
|
int n = (lua_type(L, -1) == LUA_TNUMBER) ? lua_tointeger(L, -1) : -1;
|
||||||
lua_pop(L, topop);
|
lua_pop(L, topop);
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR getsizes (lua_State *L) {
|
static void getsizes (lua_State *L) {
|
||||||
lua_getfield(L, LUA_REGISTRYINDEX, "LUA_SIZES");
|
lua_getfield(L, LUA_REGISTRYINDEX, "LUA_SIZES");
|
||||||
if (lua_isnil(L, -1)) { /* no `size' table? */
|
if (lua_isnil(L, -1)) { /* no `size' table? */
|
||||||
lua_pop(L, 1); /* remove nil */
|
lua_pop(L, 1); /* remove nil */
|
||||||
@ -345,7 +345,7 @@ static void ICACHE_FLASH_ATTR getsizes (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUALIB_API void ICACHE_FLASH_ATTR luaL_setn (lua_State *L, int t, int n) {
|
LUALIB_API void luaL_setn (lua_State *L, int t, int n) {
|
||||||
t = abs_index(L, t);
|
t = abs_index(L, t);
|
||||||
lua_pushliteral(L, "n");
|
lua_pushliteral(L, "n");
|
||||||
lua_rawget(L, t);
|
lua_rawget(L, t);
|
||||||
@ -364,7 +364,7 @@ LUALIB_API void ICACHE_FLASH_ATTR luaL_setn (lua_State *L, int t, int n) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUALIB_API int ICACHE_FLASH_ATTR luaL_getn (lua_State *L, int t) {
|
LUALIB_API int luaL_getn (lua_State *L, int t) {
|
||||||
int n;
|
int n;
|
||||||
t = abs_index(L, t);
|
t = abs_index(L, t);
|
||||||
lua_pushliteral(L, "n"); /* try t.n */
|
lua_pushliteral(L, "n"); /* try t.n */
|
||||||
@ -383,7 +383,7 @@ LUALIB_API int ICACHE_FLASH_ATTR luaL_getn (lua_State *L, int t) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
LUALIB_API const char *ICACHE_FLASH_ATTR luaL_gsub (lua_State *L, const char *s, const char *p,
|
LUALIB_API const char *luaL_gsub (lua_State *L, const char *s, const char *p,
|
||||||
const char *r) {
|
const char *r) {
|
||||||
const char *wild;
|
const char *wild;
|
||||||
size_t l = c_strlen(p);
|
size_t l = c_strlen(p);
|
||||||
@ -400,7 +400,7 @@ LUALIB_API const char *ICACHE_FLASH_ATTR luaL_gsub (lua_State *L, const char *s,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUALIB_API const char *ICACHE_FLASH_ATTR luaL_findtable (lua_State *L, int idx,
|
LUALIB_API const char *luaL_findtable (lua_State *L, int idx,
|
||||||
const char *fname, int szhint) {
|
const char *fname, int szhint) {
|
||||||
const char *e;
|
const char *e;
|
||||||
lua_pushvalue(L, idx);
|
lua_pushvalue(L, idx);
|
||||||
@ -449,7 +449,7 @@ LUALIB_API const char *ICACHE_FLASH_ATTR luaL_findtable (lua_State *L, int idx,
|
|||||||
#define LIMIT (LUA_MINSTACK/2)
|
#define LIMIT (LUA_MINSTACK/2)
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR emptybuffer (luaL_Buffer *B) {
|
static int emptybuffer (luaL_Buffer *B) {
|
||||||
size_t l = bufflen(B);
|
size_t l = bufflen(B);
|
||||||
if (l == 0) return 0; /* put nothing on stack */
|
if (l == 0) return 0; /* put nothing on stack */
|
||||||
else {
|
else {
|
||||||
@ -461,7 +461,7 @@ static int ICACHE_FLASH_ATTR emptybuffer (luaL_Buffer *B) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR adjuststack (luaL_Buffer *B) {
|
static void adjuststack (luaL_Buffer *B) {
|
||||||
if (B->lvl > 1) {
|
if (B->lvl > 1) {
|
||||||
lua_State *L = B->L;
|
lua_State *L = B->L;
|
||||||
int toget = 1; /* number of levels to concat */
|
int toget = 1; /* number of levels to concat */
|
||||||
@ -480,32 +480,32 @@ static void ICACHE_FLASH_ATTR adjuststack (luaL_Buffer *B) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUALIB_API char *ICACHE_FLASH_ATTR luaL_prepbuffer (luaL_Buffer *B) {
|
LUALIB_API char *luaL_prepbuffer (luaL_Buffer *B) {
|
||||||
if (emptybuffer(B))
|
if (emptybuffer(B))
|
||||||
adjuststack(B);
|
adjuststack(B);
|
||||||
return B->buffer;
|
return B->buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUALIB_API void ICACHE_FLASH_ATTR luaL_addlstring (luaL_Buffer *B, const char *s, size_t l) {
|
LUALIB_API void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l) {
|
||||||
while (l--)
|
while (l--)
|
||||||
luaL_addchar(B, *s++);
|
luaL_addchar(B, *s++);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUALIB_API void ICACHE_FLASH_ATTR luaL_addstring (luaL_Buffer *B, const char *s) {
|
LUALIB_API void luaL_addstring (luaL_Buffer *B, const char *s) {
|
||||||
luaL_addlstring(B, s, c_strlen(s));
|
luaL_addlstring(B, s, c_strlen(s));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUALIB_API void ICACHE_FLASH_ATTR luaL_pushresult (luaL_Buffer *B) {
|
LUALIB_API void luaL_pushresult (luaL_Buffer *B) {
|
||||||
emptybuffer(B);
|
emptybuffer(B);
|
||||||
lua_concat(B->L, B->lvl);
|
lua_concat(B->L, B->lvl);
|
||||||
B->lvl = 1;
|
B->lvl = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUALIB_API void ICACHE_FLASH_ATTR luaL_addvalue (luaL_Buffer *B) {
|
LUALIB_API void luaL_addvalue (luaL_Buffer *B) {
|
||||||
lua_State *L = B->L;
|
lua_State *L = B->L;
|
||||||
size_t vl;
|
size_t vl;
|
||||||
const char *s = lua_tolstring(L, -1, &vl);
|
const char *s = lua_tolstring(L, -1, &vl);
|
||||||
@ -523,7 +523,7 @@ LUALIB_API void ICACHE_FLASH_ATTR luaL_addvalue (luaL_Buffer *B) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUALIB_API void ICACHE_FLASH_ATTR luaL_buffinit (lua_State *L, luaL_Buffer *B) {
|
LUALIB_API void luaL_buffinit (lua_State *L, luaL_Buffer *B) {
|
||||||
B->L = L;
|
B->L = L;
|
||||||
B->p = B->buffer;
|
B->p = B->buffer;
|
||||||
B->lvl = 0;
|
B->lvl = 0;
|
||||||
@ -532,7 +532,7 @@ LUALIB_API void ICACHE_FLASH_ATTR luaL_buffinit (lua_State *L, luaL_Buffer *B) {
|
|||||||
/* }====================================================== */
|
/* }====================================================== */
|
||||||
|
|
||||||
|
|
||||||
LUALIB_API int ICACHE_FLASH_ATTR luaL_ref (lua_State *L, int t) {
|
LUALIB_API int luaL_ref (lua_State *L, int t) {
|
||||||
int ref;
|
int ref;
|
||||||
t = abs_index(L, t);
|
t = abs_index(L, t);
|
||||||
if (lua_isnil(L, -1)) {
|
if (lua_isnil(L, -1)) {
|
||||||
@ -555,7 +555,7 @@ LUALIB_API int ICACHE_FLASH_ATTR luaL_ref (lua_State *L, int t) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUALIB_API void ICACHE_FLASH_ATTR luaL_unref (lua_State *L, int t, int ref) {
|
LUALIB_API void luaL_unref (lua_State *L, int t, int ref) {
|
||||||
if (ref >= 0) {
|
if (ref >= 0) {
|
||||||
t = abs_index(L, t);
|
t = abs_index(L, t);
|
||||||
lua_rawgeti(L, t, FREELIST_REF);
|
lua_rawgeti(L, t, FREELIST_REF);
|
||||||
@ -582,7 +582,7 @@ typedef struct LoadF {
|
|||||||
} LoadF;
|
} LoadF;
|
||||||
|
|
||||||
|
|
||||||
static const char *ICACHE_FLASH_ATTR getF (lua_State *L, void *ud, size_t *size) {
|
static const char *getF (lua_State *L, void *ud, size_t *size) {
|
||||||
LoadF *lf = (LoadF *)ud;
|
LoadF *lf = (LoadF *)ud;
|
||||||
(void)L;
|
(void)L;
|
||||||
if (lf->extraline) {
|
if (lf->extraline) {
|
||||||
@ -596,7 +596,7 @@ static const char *ICACHE_FLASH_ATTR getF (lua_State *L, void *ud, size_t *size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR errfile (lua_State *L, const char *what, int fnameindex) {
|
static int errfile (lua_State *L, const char *what, int fnameindex) {
|
||||||
const char *serr = c_strerror(errno);
|
const char *serr = c_strerror(errno);
|
||||||
const char *filename = lua_tostring(L, fnameindex) + 1;
|
const char *filename = lua_tostring(L, fnameindex) + 1;
|
||||||
lua_pushfstring(L, "cannot %s %s: %s", what, filename, serr);
|
lua_pushfstring(L, "cannot %s %s: %s", what, filename, serr);
|
||||||
@ -605,7 +605,7 @@ static int ICACHE_FLASH_ATTR errfile (lua_State *L, const char *what, int fnamei
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUALIB_API int ICACHE_FLASH_ATTR luaL_loadfile (lua_State *L, const char *filename) {
|
LUALIB_API int luaL_loadfile (lua_State *L, const char *filename) {
|
||||||
LoadF lf;
|
LoadF lf;
|
||||||
int status, readstatus;
|
int status, readstatus;
|
||||||
int c;
|
int c;
|
||||||
@ -656,7 +656,7 @@ typedef struct LoadFSF {
|
|||||||
} LoadFSF;
|
} LoadFSF;
|
||||||
|
|
||||||
|
|
||||||
static const char *ICACHE_FLASH_ATTR getFSF (lua_State *L, void *ud, size_t *size) {
|
static const char *getFSF (lua_State *L, void *ud, size_t *size) {
|
||||||
LoadFSF *lf = (LoadFSF *)ud;
|
LoadFSF *lf = (LoadFSF *)ud;
|
||||||
(void)L;
|
(void)L;
|
||||||
if (lf->extraline) {
|
if (lf->extraline) {
|
||||||
@ -670,7 +670,7 @@ static const char *ICACHE_FLASH_ATTR getFSF (lua_State *L, void *ud, size_t *siz
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR errfsfile (lua_State *L, const char *what, int fnameindex) {
|
static int errfsfile (lua_State *L, const char *what, int fnameindex) {
|
||||||
const char *filename = lua_tostring(L, fnameindex) + 1;
|
const char *filename = lua_tostring(L, fnameindex) + 1;
|
||||||
lua_pushfstring(L, "cannot %s %s", what, filename);
|
lua_pushfstring(L, "cannot %s %s", what, filename);
|
||||||
lua_remove(L, fnameindex);
|
lua_remove(L, fnameindex);
|
||||||
@ -678,7 +678,7 @@ static int ICACHE_FLASH_ATTR errfsfile (lua_State *L, const char *what, int fnam
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUALIB_API int ICACHE_FLASH_ATTR luaL_loadfsfile (lua_State *L, const char *filename) {
|
LUALIB_API int luaL_loadfsfile (lua_State *L, const char *filename) {
|
||||||
LoadFSF lf;
|
LoadFSF lf;
|
||||||
int status, readstatus;
|
int status, readstatus;
|
||||||
int c;
|
int c;
|
||||||
@ -722,7 +722,7 @@ typedef struct LoadS {
|
|||||||
} LoadS;
|
} LoadS;
|
||||||
|
|
||||||
|
|
||||||
static const char *ICACHE_FLASH_ATTR getS (lua_State *L, void *ud, size_t *size) {
|
static const char *getS (lua_State *L, void *ud, size_t *size) {
|
||||||
LoadS *ls = (LoadS *)ud;
|
LoadS *ls = (LoadS *)ud;
|
||||||
(void)L;
|
(void)L;
|
||||||
if (L == NULL && size == NULL) // direct mode check
|
if (L == NULL && size == NULL) // direct mode check
|
||||||
@ -734,7 +734,7 @@ static const char *ICACHE_FLASH_ATTR getS (lua_State *L, void *ud, size_t *size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUALIB_API int ICACHE_FLASH_ATTR luaL_loadbuffer (lua_State *L, const char *buff, size_t size,
|
LUALIB_API int luaL_loadbuffer (lua_State *L, const char *buff, size_t size,
|
||||||
const char *name) {
|
const char *name) {
|
||||||
LoadS ls;
|
LoadS ls;
|
||||||
ls.s = buff;
|
ls.s = buff;
|
||||||
@ -743,7 +743,7 @@ LUALIB_API int ICACHE_FLASH_ATTR luaL_loadbuffer (lua_State *L, const char *buff
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUALIB_API int ICACHE_FLASH_ATTR (luaL_loadstring) (lua_State *L, const char *s) {
|
LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s) {
|
||||||
return luaL_loadbuffer(L, s, c_strlen(s), s);
|
return luaL_loadbuffer(L, s, c_strlen(s), s);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -752,7 +752,7 @@ LUALIB_API int ICACHE_FLASH_ATTR (luaL_loadstring) (lua_State *L, const char *s)
|
|||||||
/* }====================================================== */
|
/* }====================================================== */
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR l_check_memlimit(lua_State *L, size_t needbytes) {
|
static int l_check_memlimit(lua_State *L, size_t needbytes) {
|
||||||
global_State *g = G(L);
|
global_State *g = G(L);
|
||||||
int cycle_count = 0;
|
int cycle_count = 0;
|
||||||
lu_mem limit = g->memlimit - needbytes;
|
lu_mem limit = g->memlimit - needbytes;
|
||||||
@ -770,7 +770,7 @@ static int ICACHE_FLASH_ATTR l_check_memlimit(lua_State *L, size_t needbytes) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void *ICACHE_FLASH_ATTR l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) {
|
static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) {
|
||||||
lua_State *L = (lua_State *)ud;
|
lua_State *L = (lua_State *)ud;
|
||||||
int mode = L == NULL ? 0 : G(L)->egcmode;
|
int mode = L == NULL ? 0 : G(L)->egcmode;
|
||||||
void *nptr;
|
void *nptr;
|
||||||
@ -797,7 +797,7 @@ static void *ICACHE_FLASH_ATTR l_alloc (void *ud, void *ptr, size_t osize, size_
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR panic (lua_State *L) {
|
static int panic (lua_State *L) {
|
||||||
(void)L; /* to avoid warnings */
|
(void)L; /* to avoid warnings */
|
||||||
#if defined(LUA_USE_STDIO)
|
#if defined(LUA_USE_STDIO)
|
||||||
c_fprintf(c_stderr, "PANIC: unprotected error in call to Lua API (%s)\n",
|
c_fprintf(c_stderr, "PANIC: unprotected error in call to Lua API (%s)\n",
|
||||||
@ -810,7 +810,7 @@ static int ICACHE_FLASH_ATTR panic (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUALIB_API lua_State *ICACHE_FLASH_ATTR luaL_newstate (void) {
|
LUALIB_API lua_State *luaL_newstate (void) {
|
||||||
lua_State *L = lua_newstate(l_alloc, NULL);
|
lua_State *L = lua_newstate(l_alloc, NULL);
|
||||||
lua_setallocf(L, l_alloc, L); /* allocator need lua_State. */
|
lua_setallocf(L, l_alloc, L); /* allocator need lua_State. */
|
||||||
if (L) lua_atpanic(L, &panic);
|
if (L) lua_atpanic(L, &panic);
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
** model but changing `fputs' to put the strings at a proper place
|
** model but changing `fputs' to put the strings at a proper place
|
||||||
** (a console window or a log file, for instance).
|
** (a console window or a log file, for instance).
|
||||||
*/
|
*/
|
||||||
static int ICACHE_FLASH_ATTR luaB_print (lua_State *L) {
|
static int luaB_print (lua_State *L) {
|
||||||
int n = lua_gettop(L); /* number of arguments */
|
int n = lua_gettop(L); /* number of arguments */
|
||||||
int i;
|
int i;
|
||||||
lua_getglobal(L, "tostring");
|
lua_getglobal(L, "tostring");
|
||||||
@ -60,7 +60,7 @@ static int ICACHE_FLASH_ATTR luaB_print (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR luaB_tonumber (lua_State *L) {
|
static int luaB_tonumber (lua_State *L) {
|
||||||
int base = luaL_optint(L, 2, 10);
|
int base = luaL_optint(L, 2, 10);
|
||||||
if (base == 10) { /* standard conversion */
|
if (base == 10) { /* standard conversion */
|
||||||
luaL_checkany(L, 1);
|
luaL_checkany(L, 1);
|
||||||
@ -88,7 +88,7 @@ static int ICACHE_FLASH_ATTR luaB_tonumber (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR luaB_error (lua_State *L) {
|
static int luaB_error (lua_State *L) {
|
||||||
int level = luaL_optint(L, 2, 1);
|
int level = luaL_optint(L, 2, 1);
|
||||||
lua_settop(L, 1);
|
lua_settop(L, 1);
|
||||||
if (lua_isstring(L, 1) && level > 0) { /* add extra information? */
|
if (lua_isstring(L, 1) && level > 0) { /* add extra information? */
|
||||||
@ -100,7 +100,7 @@ static int ICACHE_FLASH_ATTR luaB_error (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR luaB_getmetatable (lua_State *L) {
|
static int luaB_getmetatable (lua_State *L) {
|
||||||
luaL_checkany(L, 1);
|
luaL_checkany(L, 1);
|
||||||
if (!lua_getmetatable(L, 1)) {
|
if (!lua_getmetatable(L, 1)) {
|
||||||
lua_pushnil(L);
|
lua_pushnil(L);
|
||||||
@ -111,7 +111,7 @@ static int ICACHE_FLASH_ATTR luaB_getmetatable (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR luaB_setmetatable (lua_State *L) {
|
static int luaB_setmetatable (lua_State *L) {
|
||||||
int t = lua_type(L, 2);
|
int t = lua_type(L, 2);
|
||||||
luaL_checktype(L, 1, LUA_TTABLE);
|
luaL_checktype(L, 1, LUA_TTABLE);
|
||||||
luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE || t == LUA_TROTABLE, 2,
|
luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE || t == LUA_TROTABLE, 2,
|
||||||
@ -124,7 +124,7 @@ static int ICACHE_FLASH_ATTR luaB_setmetatable (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR getfunc (lua_State *L, int opt) {
|
static void getfunc (lua_State *L, int opt) {
|
||||||
if (lua_isfunction(L, 1)) lua_pushvalue(L, 1);
|
if (lua_isfunction(L, 1)) lua_pushvalue(L, 1);
|
||||||
else {
|
else {
|
||||||
lua_Debug ar;
|
lua_Debug ar;
|
||||||
@ -140,7 +140,7 @@ static void ICACHE_FLASH_ATTR getfunc (lua_State *L, int opt) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR luaB_getfenv (lua_State *L) {
|
static int luaB_getfenv (lua_State *L) {
|
||||||
getfunc(L, 1);
|
getfunc(L, 1);
|
||||||
if (lua_iscfunction(L, -1)) /* is a C function? */
|
if (lua_iscfunction(L, -1)) /* is a C function? */
|
||||||
lua_pushvalue(L, LUA_GLOBALSINDEX); /* return the thread's global env. */
|
lua_pushvalue(L, LUA_GLOBALSINDEX); /* return the thread's global env. */
|
||||||
@ -150,7 +150,7 @@ static int ICACHE_FLASH_ATTR luaB_getfenv (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR luaB_setfenv (lua_State *L) {
|
static int luaB_setfenv (lua_State *L) {
|
||||||
luaL_checktype(L, 2, LUA_TTABLE);
|
luaL_checktype(L, 2, LUA_TTABLE);
|
||||||
getfunc(L, 0);
|
getfunc(L, 0);
|
||||||
lua_pushvalue(L, 2);
|
lua_pushvalue(L, 2);
|
||||||
@ -168,7 +168,7 @@ static int ICACHE_FLASH_ATTR luaB_setfenv (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR luaB_rawequal (lua_State *L) {
|
static int luaB_rawequal (lua_State *L) {
|
||||||
luaL_checkany(L, 1);
|
luaL_checkany(L, 1);
|
||||||
luaL_checkany(L, 2);
|
luaL_checkany(L, 2);
|
||||||
lua_pushboolean(L, lua_rawequal(L, 1, 2));
|
lua_pushboolean(L, lua_rawequal(L, 1, 2));
|
||||||
@ -176,7 +176,7 @@ static int ICACHE_FLASH_ATTR luaB_rawequal (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR luaB_rawget (lua_State *L) {
|
static int luaB_rawget (lua_State *L) {
|
||||||
luaL_checkanytable(L, 1);
|
luaL_checkanytable(L, 1);
|
||||||
luaL_checkany(L, 2);
|
luaL_checkany(L, 2);
|
||||||
lua_settop(L, 2);
|
lua_settop(L, 2);
|
||||||
@ -184,7 +184,7 @@ static int ICACHE_FLASH_ATTR luaB_rawget (lua_State *L) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR luaB_rawset (lua_State *L) {
|
static int luaB_rawset (lua_State *L) {
|
||||||
luaL_checktype(L, 1, LUA_TTABLE);
|
luaL_checktype(L, 1, LUA_TTABLE);
|
||||||
luaL_checkany(L, 2);
|
luaL_checkany(L, 2);
|
||||||
luaL_checkany(L, 3);
|
luaL_checkany(L, 3);
|
||||||
@ -194,13 +194,13 @@ static int ICACHE_FLASH_ATTR luaB_rawset (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR luaB_gcinfo (lua_State *L) {
|
static int luaB_gcinfo (lua_State *L) {
|
||||||
lua_pushinteger(L, lua_getgccount(L));
|
lua_pushinteger(L, lua_getgccount(L));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR luaB_collectgarbage (lua_State *L) {
|
static int luaB_collectgarbage (lua_State *L) {
|
||||||
static const char *const opts[] = {"stop", "restart", "collect",
|
static const char *const opts[] = {"stop", "restart", "collect",
|
||||||
"count", "step", "setpause", "setstepmul","setmemlimit","getmemlimit", NULL};
|
"count", "step", "setpause", "setstepmul","setmemlimit","getmemlimit", NULL};
|
||||||
static const int optsnum[] = {LUA_GCSTOP, LUA_GCRESTART, LUA_GCCOLLECT,
|
static const int optsnum[] = {LUA_GCSTOP, LUA_GCRESTART, LUA_GCCOLLECT,
|
||||||
@ -227,14 +227,14 @@ static int ICACHE_FLASH_ATTR luaB_collectgarbage (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR luaB_type (lua_State *L) {
|
static int luaB_type (lua_State *L) {
|
||||||
luaL_checkany(L, 1);
|
luaL_checkany(L, 1);
|
||||||
lua_pushstring(L, luaL_typename(L, 1));
|
lua_pushstring(L, luaL_typename(L, 1));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR luaB_next (lua_State *L) {
|
static int luaB_next (lua_State *L) {
|
||||||
luaL_checkanytable(L, 1);
|
luaL_checkanytable(L, 1);
|
||||||
lua_settop(L, 2); /* create a 2nd argument if there isn't one */
|
lua_settop(L, 2); /* create a 2nd argument if there isn't one */
|
||||||
if (lua_next(L, 1))
|
if (lua_next(L, 1))
|
||||||
@ -246,7 +246,7 @@ static int ICACHE_FLASH_ATTR luaB_next (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR luaB_pairs (lua_State *L) {
|
static int luaB_pairs (lua_State *L) {
|
||||||
luaL_checkanytable(L, 1);
|
luaL_checkanytable(L, 1);
|
||||||
lua_pushvalue(L, lua_upvalueindex(1)); /* return generator, */
|
lua_pushvalue(L, lua_upvalueindex(1)); /* return generator, */
|
||||||
lua_pushvalue(L, 1); /* state, */
|
lua_pushvalue(L, 1); /* state, */
|
||||||
@ -255,7 +255,7 @@ static int ICACHE_FLASH_ATTR luaB_pairs (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR ipairsaux (lua_State *L) {
|
static int ipairsaux (lua_State *L) {
|
||||||
int i = luaL_checkint(L, 2);
|
int i = luaL_checkint(L, 2);
|
||||||
luaL_checkanytable(L, 1);
|
luaL_checkanytable(L, 1);
|
||||||
i++; /* next value */
|
i++; /* next value */
|
||||||
@ -265,7 +265,7 @@ static int ICACHE_FLASH_ATTR ipairsaux (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR luaB_ipairs (lua_State *L) {
|
static int luaB_ipairs (lua_State *L) {
|
||||||
luaL_checkanytable(L, 1);
|
luaL_checkanytable(L, 1);
|
||||||
lua_pushvalue(L, lua_upvalueindex(1)); /* return generator, */
|
lua_pushvalue(L, lua_upvalueindex(1)); /* return generator, */
|
||||||
lua_pushvalue(L, 1); /* state, */
|
lua_pushvalue(L, 1); /* state, */
|
||||||
@ -274,7 +274,7 @@ static int ICACHE_FLASH_ATTR luaB_ipairs (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR load_aux (lua_State *L, int status) {
|
static int load_aux (lua_State *L, int status) {
|
||||||
if (status == 0) /* OK? */
|
if (status == 0) /* OK? */
|
||||||
return 1;
|
return 1;
|
||||||
else {
|
else {
|
||||||
@ -285,7 +285,7 @@ static int ICACHE_FLASH_ATTR load_aux (lua_State *L, int status) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR luaB_loadstring (lua_State *L) {
|
static int luaB_loadstring (lua_State *L) {
|
||||||
size_t l;
|
size_t l;
|
||||||
const char *s = luaL_checklstring(L, 1, &l);
|
const char *s = luaL_checklstring(L, 1, &l);
|
||||||
const char *chunkname = luaL_optstring(L, 2, s);
|
const char *chunkname = luaL_optstring(L, 2, s);
|
||||||
@ -293,7 +293,7 @@ static int ICACHE_FLASH_ATTR luaB_loadstring (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR luaB_loadfile (lua_State *L) {
|
static int luaB_loadfile (lua_State *L) {
|
||||||
const char *fname = luaL_optstring(L, 1, NULL);
|
const char *fname = luaL_optstring(L, 1, NULL);
|
||||||
#if 0
|
#if 0
|
||||||
return load_aux(L, luaL_loadfile(L, fname));
|
return load_aux(L, luaL_loadfile(L, fname));
|
||||||
@ -309,7 +309,7 @@ static int ICACHE_FLASH_ATTR luaB_loadfile (lua_State *L) {
|
|||||||
** stack top. Instead, it keeps its resulting string in a
|
** stack top. Instead, it keeps its resulting string in a
|
||||||
** reserved slot inside the stack.
|
** reserved slot inside the stack.
|
||||||
*/
|
*/
|
||||||
static const char *ICACHE_FLASH_ATTR generic_reader (lua_State *L, void *ud, size_t *size) {
|
static const char *generic_reader (lua_State *L, void *ud, size_t *size) {
|
||||||
(void)ud; /* to avoid warnings */
|
(void)ud; /* to avoid warnings */
|
||||||
if (L == NULL && size == NULL) // direct mode check, doesn't happen
|
if (L == NULL && size == NULL) // direct mode check, doesn't happen
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -329,7 +329,7 @@ static const char *ICACHE_FLASH_ATTR generic_reader (lua_State *L, void *ud, siz
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR luaB_load (lua_State *L) {
|
static int luaB_load (lua_State *L) {
|
||||||
int status;
|
int status;
|
||||||
const char *cname = luaL_optstring(L, 2, "=(load)");
|
const char *cname = luaL_optstring(L, 2, "=(load)");
|
||||||
luaL_checktype(L, 1, LUA_TFUNCTION);
|
luaL_checktype(L, 1, LUA_TFUNCTION);
|
||||||
@ -339,7 +339,7 @@ static int ICACHE_FLASH_ATTR luaB_load (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR luaB_dofile (lua_State *L) {
|
static int luaB_dofile (lua_State *L) {
|
||||||
const char *fname = luaL_optstring(L, 1, NULL);
|
const char *fname = luaL_optstring(L, 1, NULL);
|
||||||
int n = lua_gettop(L);
|
int n = lua_gettop(L);
|
||||||
#if 0
|
#if 0
|
||||||
@ -352,7 +352,7 @@ static int ICACHE_FLASH_ATTR luaB_dofile (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR luaB_assert (lua_State *L) {
|
static int luaB_assert (lua_State *L) {
|
||||||
luaL_checkany(L, 1);
|
luaL_checkany(L, 1);
|
||||||
if (!lua_toboolean(L, 1))
|
if (!lua_toboolean(L, 1))
|
||||||
return luaL_error(L, "%s", luaL_optstring(L, 2, "assertion failed!"));
|
return luaL_error(L, "%s", luaL_optstring(L, 2, "assertion failed!"));
|
||||||
@ -360,7 +360,7 @@ static int ICACHE_FLASH_ATTR luaB_assert (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR luaB_unpack (lua_State *L) {
|
static int luaB_unpack (lua_State *L) {
|
||||||
int i, e, n;
|
int i, e, n;
|
||||||
luaL_checktype(L, 1, LUA_TTABLE);
|
luaL_checktype(L, 1, LUA_TTABLE);
|
||||||
i = luaL_optint(L, 2, 1);
|
i = luaL_optint(L, 2, 1);
|
||||||
@ -376,7 +376,7 @@ static int ICACHE_FLASH_ATTR luaB_unpack (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR luaB_select (lua_State *L) {
|
static int luaB_select (lua_State *L) {
|
||||||
int n = lua_gettop(L);
|
int n = lua_gettop(L);
|
||||||
if (lua_type(L, 1) == LUA_TSTRING && *lua_tostring(L, 1) == '#') {
|
if (lua_type(L, 1) == LUA_TSTRING && *lua_tostring(L, 1) == '#') {
|
||||||
lua_pushinteger(L, n-1);
|
lua_pushinteger(L, n-1);
|
||||||
@ -392,7 +392,7 @@ static int ICACHE_FLASH_ATTR luaB_select (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR luaB_pcall (lua_State *L) {
|
static int luaB_pcall (lua_State *L) {
|
||||||
int status;
|
int status;
|
||||||
luaL_checkany(L, 1);
|
luaL_checkany(L, 1);
|
||||||
status = lua_pcall(L, lua_gettop(L) - 1, LUA_MULTRET, 0);
|
status = lua_pcall(L, lua_gettop(L) - 1, LUA_MULTRET, 0);
|
||||||
@ -402,7 +402,7 @@ static int ICACHE_FLASH_ATTR luaB_pcall (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR luaB_xpcall (lua_State *L) {
|
static int luaB_xpcall (lua_State *L) {
|
||||||
int status;
|
int status;
|
||||||
luaL_checkany(L, 2);
|
luaL_checkany(L, 2);
|
||||||
lua_settop(L, 2);
|
lua_settop(L, 2);
|
||||||
@ -414,7 +414,7 @@ static int ICACHE_FLASH_ATTR luaB_xpcall (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR luaB_tostring (lua_State *L) {
|
static int luaB_tostring (lua_State *L) {
|
||||||
luaL_checkany(L, 1);
|
luaL_checkany(L, 1);
|
||||||
if (luaL_callmeta(L, 1, "__tostring")) /* is there a metafield? */
|
if (luaL_callmeta(L, 1, "__tostring")) /* is there a metafield? */
|
||||||
return 1; /* use its value */
|
return 1; /* use its value */
|
||||||
@ -439,7 +439,7 @@ static int ICACHE_FLASH_ATTR luaB_tostring (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR luaB_newproxy (lua_State *L) {
|
static int luaB_newproxy (lua_State *L) {
|
||||||
lua_settop(L, 1);
|
lua_settop(L, 1);
|
||||||
lua_newuserdata(L, 0); /* create proxy */
|
lua_newuserdata(L, 0); /* create proxy */
|
||||||
if (lua_toboolean(L, 1) == 0)
|
if (lua_toboolean(L, 1) == 0)
|
||||||
@ -500,7 +500,7 @@ const LUA_REG_TYPE base_funcs_list[] = {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR luaB_index(lua_State *L) {
|
static int luaB_index(lua_State *L) {
|
||||||
#if LUA_OPTIMIZE_MEMORY == 2
|
#if LUA_OPTIMIZE_MEMORY == 2
|
||||||
int fres;
|
int fres;
|
||||||
if ((fres = luaR_findfunction(L, base_funcs_list)) != 0)
|
if ((fres = luaR_findfunction(L, base_funcs_list)) != 0)
|
||||||
@ -546,7 +546,7 @@ static const luaL_Reg base_funcs[] = {
|
|||||||
static const char *const statnames[] =
|
static const char *const statnames[] =
|
||||||
{"running", "suspended", "normal", "dead"};
|
{"running", "suspended", "normal", "dead"};
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR costatus (lua_State *L, lua_State *co) {
|
static int costatus (lua_State *L, lua_State *co) {
|
||||||
if (L == co) return CO_RUN;
|
if (L == co) return CO_RUN;
|
||||||
switch (lua_status(co)) {
|
switch (lua_status(co)) {
|
||||||
case LUA_YIELD:
|
case LUA_YIELD:
|
||||||
@ -566,7 +566,7 @@ static int ICACHE_FLASH_ATTR costatus (lua_State *L, lua_State *co) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR luaB_costatus (lua_State *L) {
|
static int luaB_costatus (lua_State *L) {
|
||||||
lua_State *co = lua_tothread(L, 1);
|
lua_State *co = lua_tothread(L, 1);
|
||||||
luaL_argcheck(L, co, 1, "coroutine expected");
|
luaL_argcheck(L, co, 1, "coroutine expected");
|
||||||
lua_pushstring(L, statnames[costatus(L, co)]);
|
lua_pushstring(L, statnames[costatus(L, co)]);
|
||||||
@ -574,7 +574,7 @@ static int ICACHE_FLASH_ATTR luaB_costatus (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR auxresume (lua_State *L, lua_State *co, int narg) {
|
static int auxresume (lua_State *L, lua_State *co, int narg) {
|
||||||
int status = costatus(L, co);
|
int status = costatus(L, co);
|
||||||
if (!lua_checkstack(co, narg))
|
if (!lua_checkstack(co, narg))
|
||||||
luaL_error(L, "too many arguments to resume");
|
luaL_error(L, "too many arguments to resume");
|
||||||
@ -599,7 +599,7 @@ static int ICACHE_FLASH_ATTR auxresume (lua_State *L, lua_State *co, int narg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR luaB_coresume (lua_State *L) {
|
static int luaB_coresume (lua_State *L) {
|
||||||
lua_State *co = lua_tothread(L, 1);
|
lua_State *co = lua_tothread(L, 1);
|
||||||
int r;
|
int r;
|
||||||
luaL_argcheck(L, co, 1, "coroutine expected");
|
luaL_argcheck(L, co, 1, "coroutine expected");
|
||||||
@ -617,7 +617,7 @@ static int ICACHE_FLASH_ATTR luaB_coresume (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR luaB_auxwrap (lua_State *L) {
|
static int luaB_auxwrap (lua_State *L) {
|
||||||
lua_State *co = lua_tothread(L, lua_upvalueindex(1));
|
lua_State *co = lua_tothread(L, lua_upvalueindex(1));
|
||||||
int r = auxresume(L, co, lua_gettop(L));
|
int r = auxresume(L, co, lua_gettop(L));
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
@ -632,7 +632,7 @@ static int ICACHE_FLASH_ATTR luaB_auxwrap (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR luaB_cocreate (lua_State *L) {
|
static int luaB_cocreate (lua_State *L) {
|
||||||
lua_State *NL = lua_newthread(L);
|
lua_State *NL = lua_newthread(L);
|
||||||
luaL_argcheck(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), 1,
|
luaL_argcheck(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), 1,
|
||||||
"Lua function expected");
|
"Lua function expected");
|
||||||
@ -642,19 +642,19 @@ static int ICACHE_FLASH_ATTR luaB_cocreate (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR luaB_cowrap (lua_State *L) {
|
static int luaB_cowrap (lua_State *L) {
|
||||||
luaB_cocreate(L);
|
luaB_cocreate(L);
|
||||||
lua_pushcclosure(L, luaB_auxwrap, 1);
|
lua_pushcclosure(L, luaB_auxwrap, 1);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR luaB_yield (lua_State *L) {
|
static int luaB_yield (lua_State *L) {
|
||||||
return lua_yield(L, lua_gettop(L));
|
return lua_yield(L, lua_gettop(L));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR luaB_corunning (lua_State *L) {
|
static int luaB_corunning (lua_State *L) {
|
||||||
if (lua_pushthread(L))
|
if (lua_pushthread(L))
|
||||||
lua_pushnil(L); /* main thread is not a coroutine */
|
lua_pushnil(L); /* main thread is not a coroutine */
|
||||||
return 1;
|
return 1;
|
||||||
@ -676,7 +676,7 @@ const LUA_REG_TYPE co_funcs[] = {
|
|||||||
/* }====================================================== */
|
/* }====================================================== */
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR auxopen (lua_State *L, const char *name,
|
static void auxopen (lua_State *L, const char *name,
|
||||||
lua_CFunction f, lua_CFunction u) {
|
lua_CFunction f, lua_CFunction u) {
|
||||||
lua_pushcfunction(L, u);
|
lua_pushcfunction(L, u);
|
||||||
lua_pushcclosure(L, f, 1);
|
lua_pushcclosure(L, f, 1);
|
||||||
@ -684,7 +684,7 @@ static void ICACHE_FLASH_ATTR auxopen (lua_State *L, const char *name,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR base_open (lua_State *L) {
|
static void base_open (lua_State *L) {
|
||||||
/* set global _G */
|
/* set global _G */
|
||||||
lua_pushvalue(L, LUA_GLOBALSINDEX);
|
lua_pushvalue(L, LUA_GLOBALSINDEX);
|
||||||
lua_setglobal(L, "_G");
|
lua_setglobal(L, "_G");
|
||||||
@ -711,7 +711,7 @@ static void ICACHE_FLASH_ATTR base_open (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUALIB_API int ICACHE_FLASH_ATTR luaopen_base (lua_State *L) {
|
LUALIB_API int luaopen_base (lua_State *L) {
|
||||||
base_open(L);
|
base_open(L);
|
||||||
#if LUA_OPTIMIZE_MEMORY == 0
|
#if LUA_OPTIMIZE_MEMORY == 0
|
||||||
luaL_register(L, LUA_COLIBNAME, co_funcs);
|
luaL_register(L, LUA_COLIBNAME, co_funcs);
|
||||||
|
112
app/lua/lcode.c
112
app/lua/lcode.c
@ -27,12 +27,12 @@
|
|||||||
#define hasjumps(e) ((e)->t != (e)->f)
|
#define hasjumps(e) ((e)->t != (e)->f)
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR isnumeral(expdesc *e) {
|
static int isnumeral(expdesc *e) {
|
||||||
return (e->k == VKNUM && e->t == NO_JUMP && e->f == NO_JUMP);
|
return (e->k == VKNUM && e->t == NO_JUMP && e->f == NO_JUMP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR luaK_nil (FuncState *fs, int from, int n) {
|
void luaK_nil (FuncState *fs, int from, int n) {
|
||||||
Instruction *previous;
|
Instruction *previous;
|
||||||
if (fs->pc > fs->lasttarget) { /* no jumps to current position? */
|
if (fs->pc > fs->lasttarget) { /* no jumps to current position? */
|
||||||
if (fs->pc == 0) { /* function start? */
|
if (fs->pc == 0) { /* function start? */
|
||||||
@ -56,7 +56,7 @@ void ICACHE_FLASH_ATTR luaK_nil (FuncState *fs, int from, int n) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int ICACHE_FLASH_ATTR luaK_jump (FuncState *fs) {
|
int luaK_jump (FuncState *fs) {
|
||||||
int jpc = fs->jpc; /* save list of jumps to here */
|
int jpc = fs->jpc; /* save list of jumps to here */
|
||||||
int j;
|
int j;
|
||||||
fs->jpc = NO_JUMP;
|
fs->jpc = NO_JUMP;
|
||||||
@ -66,18 +66,18 @@ int ICACHE_FLASH_ATTR luaK_jump (FuncState *fs) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR luaK_ret (FuncState *fs, int first, int nret) {
|
void luaK_ret (FuncState *fs, int first, int nret) {
|
||||||
luaK_codeABC(fs, OP_RETURN, first, nret+1, 0);
|
luaK_codeABC(fs, OP_RETURN, first, nret+1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR condjump (FuncState *fs, OpCode op, int A, int B, int C) {
|
static int condjump (FuncState *fs, OpCode op, int A, int B, int C) {
|
||||||
luaK_codeABC(fs, op, A, B, C);
|
luaK_codeABC(fs, op, A, B, C);
|
||||||
return luaK_jump(fs);
|
return luaK_jump(fs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR fixjump (FuncState *fs, int pc, int dest) {
|
static void fixjump (FuncState *fs, int pc, int dest) {
|
||||||
Instruction *jmp = &fs->f->code[pc];
|
Instruction *jmp = &fs->f->code[pc];
|
||||||
int offset = dest-(pc+1);
|
int offset = dest-(pc+1);
|
||||||
lua_assert(dest != NO_JUMP);
|
lua_assert(dest != NO_JUMP);
|
||||||
@ -91,13 +91,13 @@ static void ICACHE_FLASH_ATTR fixjump (FuncState *fs, int pc, int dest) {
|
|||||||
** returns current `pc' and marks it as a jump target (to avoid wrong
|
** returns current `pc' and marks it as a jump target (to avoid wrong
|
||||||
** optimizations with consecutive instructions not in the same basic block).
|
** optimizations with consecutive instructions not in the same basic block).
|
||||||
*/
|
*/
|
||||||
int ICACHE_FLASH_ATTR luaK_getlabel (FuncState *fs) {
|
int luaK_getlabel (FuncState *fs) {
|
||||||
fs->lasttarget = fs->pc;
|
fs->lasttarget = fs->pc;
|
||||||
return fs->pc;
|
return fs->pc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR getjump (FuncState *fs, int pc) {
|
static int getjump (FuncState *fs, int pc) {
|
||||||
int offset = GETARG_sBx(fs->f->code[pc]);
|
int offset = GETARG_sBx(fs->f->code[pc]);
|
||||||
if (offset == NO_JUMP) /* point to itself represents end of list */
|
if (offset == NO_JUMP) /* point to itself represents end of list */
|
||||||
return NO_JUMP; /* end of list */
|
return NO_JUMP; /* end of list */
|
||||||
@ -106,7 +106,7 @@ static int ICACHE_FLASH_ATTR getjump (FuncState *fs, int pc) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Instruction *ICACHE_FLASH_ATTR getjumpcontrol (FuncState *fs, int pc) {
|
static Instruction *getjumpcontrol (FuncState *fs, int pc) {
|
||||||
Instruction *pi = &fs->f->code[pc];
|
Instruction *pi = &fs->f->code[pc];
|
||||||
if (pc >= 1 && testTMode(GET_OPCODE(*(pi-1))))
|
if (pc >= 1 && testTMode(GET_OPCODE(*(pi-1))))
|
||||||
return pi-1;
|
return pi-1;
|
||||||
@ -119,7 +119,7 @@ static Instruction *ICACHE_FLASH_ATTR getjumpcontrol (FuncState *fs, int pc) {
|
|||||||
** check whether list has any jump that do not produce a value
|
** check whether list has any jump that do not produce a value
|
||||||
** (or produce an inverted value)
|
** (or produce an inverted value)
|
||||||
*/
|
*/
|
||||||
static int ICACHE_FLASH_ATTR need_value (FuncState *fs, int list) {
|
static int need_value (FuncState *fs, int list) {
|
||||||
for (; list != NO_JUMP; list = getjump(fs, list)) {
|
for (; list != NO_JUMP; list = getjump(fs, list)) {
|
||||||
Instruction i = *getjumpcontrol(fs, list);
|
Instruction i = *getjumpcontrol(fs, list);
|
||||||
if (GET_OPCODE(i) != OP_TESTSET) return 1;
|
if (GET_OPCODE(i) != OP_TESTSET) return 1;
|
||||||
@ -128,7 +128,7 @@ static int ICACHE_FLASH_ATTR need_value (FuncState *fs, int list) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR patchtestreg (FuncState *fs, int node, int reg) {
|
static int patchtestreg (FuncState *fs, int node, int reg) {
|
||||||
Instruction *i = getjumpcontrol(fs, node);
|
Instruction *i = getjumpcontrol(fs, node);
|
||||||
if (GET_OPCODE(*i) != OP_TESTSET)
|
if (GET_OPCODE(*i) != OP_TESTSET)
|
||||||
return 0; /* cannot patch other instructions */
|
return 0; /* cannot patch other instructions */
|
||||||
@ -141,13 +141,13 @@ static int ICACHE_FLASH_ATTR patchtestreg (FuncState *fs, int node, int reg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR removevalues (FuncState *fs, int list) {
|
static void removevalues (FuncState *fs, int list) {
|
||||||
for (; list != NO_JUMP; list = getjump(fs, list))
|
for (; list != NO_JUMP; list = getjump(fs, list))
|
||||||
patchtestreg(fs, list, NO_REG);
|
patchtestreg(fs, list, NO_REG);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR patchlistaux (FuncState *fs, int list, int vtarget, int reg,
|
static void patchlistaux (FuncState *fs, int list, int vtarget, int reg,
|
||||||
int dtarget) {
|
int dtarget) {
|
||||||
while (list != NO_JUMP) {
|
while (list != NO_JUMP) {
|
||||||
int next = getjump(fs, list);
|
int next = getjump(fs, list);
|
||||||
@ -160,13 +160,13 @@ static void ICACHE_FLASH_ATTR patchlistaux (FuncState *fs, int list, int vtarget
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR dischargejpc (FuncState *fs) {
|
static void dischargejpc (FuncState *fs) {
|
||||||
patchlistaux(fs, fs->jpc, fs->pc, NO_REG, fs->pc);
|
patchlistaux(fs, fs->jpc, fs->pc, NO_REG, fs->pc);
|
||||||
fs->jpc = NO_JUMP;
|
fs->jpc = NO_JUMP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR luaK_patchlist (FuncState *fs, int list, int target) {
|
void luaK_patchlist (FuncState *fs, int list, int target) {
|
||||||
if (target == fs->pc)
|
if (target == fs->pc)
|
||||||
luaK_patchtohere(fs, list);
|
luaK_patchtohere(fs, list);
|
||||||
else {
|
else {
|
||||||
@ -176,13 +176,13 @@ void ICACHE_FLASH_ATTR luaK_patchlist (FuncState *fs, int list, int target) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR luaK_patchtohere (FuncState *fs, int list) {
|
void luaK_patchtohere (FuncState *fs, int list) {
|
||||||
luaK_getlabel(fs);
|
luaK_getlabel(fs);
|
||||||
luaK_concat(fs, &fs->jpc, list);
|
luaK_concat(fs, &fs->jpc, list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR luaK_concat (FuncState *fs, int *l1, int l2) {
|
void luaK_concat (FuncState *fs, int *l1, int l2) {
|
||||||
if (l2 == NO_JUMP) return;
|
if (l2 == NO_JUMP) return;
|
||||||
else if (*l1 == NO_JUMP)
|
else if (*l1 == NO_JUMP)
|
||||||
*l1 = l2;
|
*l1 = l2;
|
||||||
@ -196,7 +196,7 @@ void ICACHE_FLASH_ATTR luaK_concat (FuncState *fs, int *l1, int l2) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR luaK_checkstack (FuncState *fs, int n) {
|
void luaK_checkstack (FuncState *fs, int n) {
|
||||||
int newstack = fs->freereg + n;
|
int newstack = fs->freereg + n;
|
||||||
if (newstack > fs->f->maxstacksize) {
|
if (newstack > fs->f->maxstacksize) {
|
||||||
if (newstack >= MAXSTACK)
|
if (newstack >= MAXSTACK)
|
||||||
@ -206,13 +206,13 @@ void ICACHE_FLASH_ATTR luaK_checkstack (FuncState *fs, int n) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR luaK_reserveregs (FuncState *fs, int n) {
|
void luaK_reserveregs (FuncState *fs, int n) {
|
||||||
luaK_checkstack(fs, n);
|
luaK_checkstack(fs, n);
|
||||||
fs->freereg += n;
|
fs->freereg += n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR freereg (FuncState *fs, int reg) {
|
static void freereg (FuncState *fs, int reg) {
|
||||||
if (!ISK(reg) && reg >= fs->nactvar) {
|
if (!ISK(reg) && reg >= fs->nactvar) {
|
||||||
fs->freereg--;
|
fs->freereg--;
|
||||||
lua_assert(reg == fs->freereg);
|
lua_assert(reg == fs->freereg);
|
||||||
@ -220,13 +220,13 @@ static void ICACHE_FLASH_ATTR freereg (FuncState *fs, int reg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR freeexp (FuncState *fs, expdesc *e) {
|
static void freeexp (FuncState *fs, expdesc *e) {
|
||||||
if (e->k == VNONRELOC)
|
if (e->k == VNONRELOC)
|
||||||
freereg(fs, e->u.s.info);
|
freereg(fs, e->u.s.info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR addk (FuncState *fs, TValue *k, TValue *v) {
|
static int addk (FuncState *fs, TValue *k, TValue *v) {
|
||||||
lua_State *L = fs->L;
|
lua_State *L = fs->L;
|
||||||
TValue *idx = luaH_set(L, fs->h, k);
|
TValue *idx = luaH_set(L, fs->h, k);
|
||||||
Proto *f = fs->f;
|
Proto *f = fs->f;
|
||||||
@ -247,28 +247,28 @@ static int ICACHE_FLASH_ATTR addk (FuncState *fs, TValue *k, TValue *v) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int ICACHE_FLASH_ATTR luaK_stringK (FuncState *fs, TString *s) {
|
int luaK_stringK (FuncState *fs, TString *s) {
|
||||||
TValue o;
|
TValue o;
|
||||||
setsvalue(fs->L, &o, s);
|
setsvalue(fs->L, &o, s);
|
||||||
return addk(fs, &o, &o);
|
return addk(fs, &o, &o);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int ICACHE_FLASH_ATTR luaK_numberK (FuncState *fs, lua_Number r) {
|
int luaK_numberK (FuncState *fs, lua_Number r) {
|
||||||
TValue o;
|
TValue o;
|
||||||
setnvalue(&o, r);
|
setnvalue(&o, r);
|
||||||
return addk(fs, &o, &o);
|
return addk(fs, &o, &o);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR boolK (FuncState *fs, int b) {
|
static int boolK (FuncState *fs, int b) {
|
||||||
TValue o;
|
TValue o;
|
||||||
setbvalue(&o, b);
|
setbvalue(&o, b);
|
||||||
return addk(fs, &o, &o);
|
return addk(fs, &o, &o);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR nilK (FuncState *fs) {
|
static int nilK (FuncState *fs) {
|
||||||
TValue k, v;
|
TValue k, v;
|
||||||
setnilvalue(&v);
|
setnilvalue(&v);
|
||||||
/* cannot use nil as key; instead use table itself to represent nil */
|
/* cannot use nil as key; instead use table itself to represent nil */
|
||||||
@ -277,7 +277,7 @@ static int ICACHE_FLASH_ATTR nilK (FuncState *fs) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR luaK_setreturns (FuncState *fs, expdesc *e, int nresults) {
|
void luaK_setreturns (FuncState *fs, expdesc *e, int nresults) {
|
||||||
if (e->k == VCALL) { /* expression is an open function call? */
|
if (e->k == VCALL) { /* expression is an open function call? */
|
||||||
SETARG_C(getcode(fs, e), nresults+1);
|
SETARG_C(getcode(fs, e), nresults+1);
|
||||||
}
|
}
|
||||||
@ -289,7 +289,7 @@ void ICACHE_FLASH_ATTR luaK_setreturns (FuncState *fs, expdesc *e, int nresults)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR luaK_setoneret (FuncState *fs, expdesc *e) {
|
void luaK_setoneret (FuncState *fs, expdesc *e) {
|
||||||
if (e->k == VCALL) { /* expression is an open function call? */
|
if (e->k == VCALL) { /* expression is an open function call? */
|
||||||
e->k = VNONRELOC;
|
e->k = VNONRELOC;
|
||||||
e->u.s.info = GETARG_A(getcode(fs, e));
|
e->u.s.info = GETARG_A(getcode(fs, e));
|
||||||
@ -301,7 +301,7 @@ void ICACHE_FLASH_ATTR luaK_setoneret (FuncState *fs, expdesc *e) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR luaK_dischargevars (FuncState *fs, expdesc *e) {
|
void luaK_dischargevars (FuncState *fs, expdesc *e) {
|
||||||
switch (e->k) {
|
switch (e->k) {
|
||||||
case VLOCAL: {
|
case VLOCAL: {
|
||||||
e->k = VNONRELOC;
|
e->k = VNONRELOC;
|
||||||
@ -334,13 +334,13 @@ void ICACHE_FLASH_ATTR luaK_dischargevars (FuncState *fs, expdesc *e) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR code_label (FuncState *fs, int A, int b, int jump) {
|
static int code_label (FuncState *fs, int A, int b, int jump) {
|
||||||
luaK_getlabel(fs); /* those instructions may be jump targets */
|
luaK_getlabel(fs); /* those instructions may be jump targets */
|
||||||
return luaK_codeABC(fs, OP_LOADBOOL, A, b, jump);
|
return luaK_codeABC(fs, OP_LOADBOOL, A, b, jump);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR discharge2reg (FuncState *fs, expdesc *e, int reg) {
|
static void discharge2reg (FuncState *fs, expdesc *e, int reg) {
|
||||||
luaK_dischargevars(fs, e);
|
luaK_dischargevars(fs, e);
|
||||||
switch (e->k) {
|
switch (e->k) {
|
||||||
case VNIL: {
|
case VNIL: {
|
||||||
@ -379,7 +379,7 @@ static void ICACHE_FLASH_ATTR discharge2reg (FuncState *fs, expdesc *e, int reg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR discharge2anyreg (FuncState *fs, expdesc *e) {
|
static void discharge2anyreg (FuncState *fs, expdesc *e) {
|
||||||
if (e->k != VNONRELOC) {
|
if (e->k != VNONRELOC) {
|
||||||
luaK_reserveregs(fs, 1);
|
luaK_reserveregs(fs, 1);
|
||||||
discharge2reg(fs, e, fs->freereg-1);
|
discharge2reg(fs, e, fs->freereg-1);
|
||||||
@ -387,7 +387,7 @@ static void ICACHE_FLASH_ATTR discharge2anyreg (FuncState *fs, expdesc *e) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR exp2reg (FuncState *fs, expdesc *e, int reg) {
|
static void exp2reg (FuncState *fs, expdesc *e, int reg) {
|
||||||
discharge2reg(fs, e, reg);
|
discharge2reg(fs, e, reg);
|
||||||
if (e->k == VJMP)
|
if (e->k == VJMP)
|
||||||
luaK_concat(fs, &e->t, e->u.s.info); /* put this jump in `t' list */
|
luaK_concat(fs, &e->t, e->u.s.info); /* put this jump in `t' list */
|
||||||
@ -411,7 +411,7 @@ static void ICACHE_FLASH_ATTR exp2reg (FuncState *fs, expdesc *e, int reg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR luaK_exp2nextreg (FuncState *fs, expdesc *e) {
|
void luaK_exp2nextreg (FuncState *fs, expdesc *e) {
|
||||||
luaK_dischargevars(fs, e);
|
luaK_dischargevars(fs, e);
|
||||||
freeexp(fs, e);
|
freeexp(fs, e);
|
||||||
luaK_reserveregs(fs, 1);
|
luaK_reserveregs(fs, 1);
|
||||||
@ -419,7 +419,7 @@ void ICACHE_FLASH_ATTR luaK_exp2nextreg (FuncState *fs, expdesc *e) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int ICACHE_FLASH_ATTR luaK_exp2anyreg (FuncState *fs, expdesc *e) {
|
int luaK_exp2anyreg (FuncState *fs, expdesc *e) {
|
||||||
luaK_dischargevars(fs, e);
|
luaK_dischargevars(fs, e);
|
||||||
if (e->k == VNONRELOC) {
|
if (e->k == VNONRELOC) {
|
||||||
if (!hasjumps(e)) return e->u.s.info; /* exp is already in a register */
|
if (!hasjumps(e)) return e->u.s.info; /* exp is already in a register */
|
||||||
@ -433,7 +433,7 @@ int ICACHE_FLASH_ATTR luaK_exp2anyreg (FuncState *fs, expdesc *e) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR luaK_exp2val (FuncState *fs, expdesc *e) {
|
void luaK_exp2val (FuncState *fs, expdesc *e) {
|
||||||
if (hasjumps(e))
|
if (hasjumps(e))
|
||||||
luaK_exp2anyreg(fs, e);
|
luaK_exp2anyreg(fs, e);
|
||||||
else
|
else
|
||||||
@ -441,7 +441,7 @@ void ICACHE_FLASH_ATTR luaK_exp2val (FuncState *fs, expdesc *e) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int ICACHE_FLASH_ATTR luaK_exp2RK (FuncState *fs, expdesc *e) {
|
int luaK_exp2RK (FuncState *fs, expdesc *e) {
|
||||||
luaK_exp2val(fs, e);
|
luaK_exp2val(fs, e);
|
||||||
switch (e->k) {
|
switch (e->k) {
|
||||||
case VKNUM:
|
case VKNUM:
|
||||||
@ -469,7 +469,7 @@ int ICACHE_FLASH_ATTR luaK_exp2RK (FuncState *fs, expdesc *e) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR luaK_storevar (FuncState *fs, expdesc *var, expdesc *ex) {
|
void luaK_storevar (FuncState *fs, expdesc *var, expdesc *ex) {
|
||||||
switch (var->k) {
|
switch (var->k) {
|
||||||
case VLOCAL: {
|
case VLOCAL: {
|
||||||
freeexp(fs, ex);
|
freeexp(fs, ex);
|
||||||
@ -500,7 +500,7 @@ void ICACHE_FLASH_ATTR luaK_storevar (FuncState *fs, expdesc *var, expdesc *ex)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR luaK_self (FuncState *fs, expdesc *e, expdesc *key) {
|
void luaK_self (FuncState *fs, expdesc *e, expdesc *key) {
|
||||||
int func;
|
int func;
|
||||||
luaK_exp2anyreg(fs, e);
|
luaK_exp2anyreg(fs, e);
|
||||||
freeexp(fs, e);
|
freeexp(fs, e);
|
||||||
@ -513,7 +513,7 @@ void ICACHE_FLASH_ATTR luaK_self (FuncState *fs, expdesc *e, expdesc *key) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR invertjump (FuncState *fs, expdesc *e) {
|
static void invertjump (FuncState *fs, expdesc *e) {
|
||||||
Instruction *pc = getjumpcontrol(fs, e->u.s.info);
|
Instruction *pc = getjumpcontrol(fs, e->u.s.info);
|
||||||
lua_assert(testTMode(GET_OPCODE(*pc)) && GET_OPCODE(*pc) != OP_TESTSET &&
|
lua_assert(testTMode(GET_OPCODE(*pc)) && GET_OPCODE(*pc) != OP_TESTSET &&
|
||||||
GET_OPCODE(*pc) != OP_TEST);
|
GET_OPCODE(*pc) != OP_TEST);
|
||||||
@ -521,7 +521,7 @@ static void ICACHE_FLASH_ATTR invertjump (FuncState *fs, expdesc *e) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR jumponcond (FuncState *fs, expdesc *e, int cond) {
|
static int jumponcond (FuncState *fs, expdesc *e, int cond) {
|
||||||
if (e->k == VRELOCABLE) {
|
if (e->k == VRELOCABLE) {
|
||||||
Instruction ie = getcode(fs, e);
|
Instruction ie = getcode(fs, e);
|
||||||
if (GET_OPCODE(ie) == OP_NOT) {
|
if (GET_OPCODE(ie) == OP_NOT) {
|
||||||
@ -536,7 +536,7 @@ static int ICACHE_FLASH_ATTR jumponcond (FuncState *fs, expdesc *e, int cond) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR luaK_goiftrue (FuncState *fs, expdesc *e) {
|
void luaK_goiftrue (FuncState *fs, expdesc *e) {
|
||||||
int pc; /* pc of last jump */
|
int pc; /* pc of last jump */
|
||||||
luaK_dischargevars(fs, e);
|
luaK_dischargevars(fs, e);
|
||||||
switch (e->k) {
|
switch (e->k) {
|
||||||
@ -560,7 +560,7 @@ void ICACHE_FLASH_ATTR luaK_goiftrue (FuncState *fs, expdesc *e) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR luaK_goiffalse (FuncState *fs, expdesc *e) {
|
static void luaK_goiffalse (FuncState *fs, expdesc *e) {
|
||||||
int pc; /* pc of last jump */
|
int pc; /* pc of last jump */
|
||||||
luaK_dischargevars(fs, e);
|
luaK_dischargevars(fs, e);
|
||||||
switch (e->k) {
|
switch (e->k) {
|
||||||
@ -583,7 +583,7 @@ static void ICACHE_FLASH_ATTR luaK_goiffalse (FuncState *fs, expdesc *e) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR codenot (FuncState *fs, expdesc *e) {
|
static void codenot (FuncState *fs, expdesc *e) {
|
||||||
luaK_dischargevars(fs, e);
|
luaK_dischargevars(fs, e);
|
||||||
switch (e->k) {
|
switch (e->k) {
|
||||||
case VNIL: case VFALSE: {
|
case VNIL: case VFALSE: {
|
||||||
@ -618,13 +618,13 @@ static void ICACHE_FLASH_ATTR codenot (FuncState *fs, expdesc *e) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) {
|
void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) {
|
||||||
t->u.s.aux = luaK_exp2RK(fs, k);
|
t->u.s.aux = luaK_exp2RK(fs, k);
|
||||||
t->k = VINDEXED;
|
t->k = VINDEXED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR constfolding (OpCode op, expdesc *e1, expdesc *e2) {
|
static int constfolding (OpCode op, expdesc *e1, expdesc *e2) {
|
||||||
lua_Number v1, v2, r;
|
lua_Number v1, v2, r;
|
||||||
if (!isnumeral(e1) || !isnumeral(e2)) return 0;
|
if (!isnumeral(e1) || !isnumeral(e2)) return 0;
|
||||||
v1 = e1->u.nval;
|
v1 = e1->u.nval;
|
||||||
@ -650,7 +650,7 @@ static int ICACHE_FLASH_ATTR constfolding (OpCode op, expdesc *e1, expdesc *e2)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR codearith (FuncState *fs, OpCode op, expdesc *e1, expdesc *e2) {
|
static void codearith (FuncState *fs, OpCode op, expdesc *e1, expdesc *e2) {
|
||||||
if (constfolding(op, e1, e2))
|
if (constfolding(op, e1, e2))
|
||||||
return;
|
return;
|
||||||
else {
|
else {
|
||||||
@ -670,7 +670,7 @@ static void ICACHE_FLASH_ATTR codearith (FuncState *fs, OpCode op, expdesc *e1,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR codecomp (FuncState *fs, OpCode op, int cond, expdesc *e1,
|
static void codecomp (FuncState *fs, OpCode op, int cond, expdesc *e1,
|
||||||
expdesc *e2) {
|
expdesc *e2) {
|
||||||
int o1 = luaK_exp2RK(fs, e1);
|
int o1 = luaK_exp2RK(fs, e1);
|
||||||
int o2 = luaK_exp2RK(fs, e2);
|
int o2 = luaK_exp2RK(fs, e2);
|
||||||
@ -686,7 +686,7 @@ static void ICACHE_FLASH_ATTR codecomp (FuncState *fs, OpCode op, int cond, expd
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR luaK_prefix (FuncState *fs, UnOpr op, expdesc *e) {
|
void luaK_prefix (FuncState *fs, UnOpr op, expdesc *e) {
|
||||||
expdesc e2;
|
expdesc e2;
|
||||||
e2.t = e2.f = NO_JUMP; e2.k = VKNUM; e2.u.nval = 0;
|
e2.t = e2.f = NO_JUMP; e2.k = VKNUM; e2.u.nval = 0;
|
||||||
switch (op) {
|
switch (op) {
|
||||||
@ -707,7 +707,7 @@ void ICACHE_FLASH_ATTR luaK_prefix (FuncState *fs, UnOpr op, expdesc *e) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR luaK_infix (FuncState *fs, BinOpr op, expdesc *v) {
|
void luaK_infix (FuncState *fs, BinOpr op, expdesc *v) {
|
||||||
switch (op) {
|
switch (op) {
|
||||||
case OPR_AND: {
|
case OPR_AND: {
|
||||||
luaK_goiftrue(fs, v);
|
luaK_goiftrue(fs, v);
|
||||||
@ -734,7 +734,7 @@ void ICACHE_FLASH_ATTR luaK_infix (FuncState *fs, BinOpr op, expdesc *v) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR luaK_posfix (FuncState *fs, BinOpr op, expdesc *e1, expdesc *e2) {
|
void luaK_posfix (FuncState *fs, BinOpr op, expdesc *e1, expdesc *e2) {
|
||||||
switch (op) {
|
switch (op) {
|
||||||
case OPR_AND: {
|
case OPR_AND: {
|
||||||
lua_assert(e1->t == NO_JUMP); /* list must be closed */
|
lua_assert(e1->t == NO_JUMP); /* list must be closed */
|
||||||
@ -781,12 +781,12 @@ void ICACHE_FLASH_ATTR luaK_posfix (FuncState *fs, BinOpr op, expdesc *e1, expde
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR luaK_fixline (FuncState *fs, int line) {
|
void luaK_fixline (FuncState *fs, int line) {
|
||||||
fs->f->lineinfo[fs->pc - 1] = line;
|
fs->f->lineinfo[fs->pc - 1] = line;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR luaK_code (FuncState *fs, Instruction i, int line) {
|
static int luaK_code (FuncState *fs, Instruction i, int line) {
|
||||||
Proto *f = fs->f;
|
Proto *f = fs->f;
|
||||||
dischargejpc(fs); /* `pc' will change */
|
dischargejpc(fs); /* `pc' will change */
|
||||||
/* put new instruction in code array */
|
/* put new instruction in code array */
|
||||||
@ -801,7 +801,7 @@ static int ICACHE_FLASH_ATTR luaK_code (FuncState *fs, Instruction i, int line)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int ICACHE_FLASH_ATTR luaK_codeABC (FuncState *fs, OpCode o, int a, int b, int c) {
|
int luaK_codeABC (FuncState *fs, OpCode o, int a, int b, int c) {
|
||||||
lua_assert(getOpMode(o) == iABC);
|
lua_assert(getOpMode(o) == iABC);
|
||||||
lua_assert(getBMode(o) != OpArgN || b == 0);
|
lua_assert(getBMode(o) != OpArgN || b == 0);
|
||||||
lua_assert(getCMode(o) != OpArgN || c == 0);
|
lua_assert(getCMode(o) != OpArgN || c == 0);
|
||||||
@ -809,14 +809,14 @@ int ICACHE_FLASH_ATTR luaK_codeABC (FuncState *fs, OpCode o, int a, int b, int c
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int ICACHE_FLASH_ATTR luaK_codeABx (FuncState *fs, OpCode o, int a, unsigned int bc) {
|
int luaK_codeABx (FuncState *fs, OpCode o, int a, unsigned int bc) {
|
||||||
lua_assert(getOpMode(o) == iABx || getOpMode(o) == iAsBx);
|
lua_assert(getOpMode(o) == iABx || getOpMode(o) == iAsBx);
|
||||||
lua_assert(getCMode(o) == OpArgN);
|
lua_assert(getCMode(o) == OpArgN);
|
||||||
return luaK_code(fs, CREATE_ABx(o, a, bc), fs->ls->lastline);
|
return luaK_code(fs, CREATE_ABx(o, a, bc), fs->ls->lastline);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR luaK_setlist (FuncState *fs, int base, int nelems, int tostore) {
|
void luaK_setlist (FuncState *fs, int base, int nelems, int tostore) {
|
||||||
int c = (nelems - 1)/LFIELDS_PER_FLUSH + 1;
|
int c = (nelems - 1)/LFIELDS_PER_FLUSH + 1;
|
||||||
int b = (tostore == LUA_MULTRET) ? 0 : tostore;
|
int b = (tostore == LUA_MULTRET) ? 0 : tostore;
|
||||||
lua_assert(tostore != 0);
|
lua_assert(tostore != 0);
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name);
|
static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name);
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR currentpc (lua_State *L, CallInfo *ci) {
|
static int currentpc (lua_State *L, CallInfo *ci) {
|
||||||
if (!isLua(ci)) return -1; /* function is not a Lua function? */
|
if (!isLua(ci)) return -1; /* function is not a Lua function? */
|
||||||
if (ci == L->ci)
|
if (ci == L->ci)
|
||||||
ci->savedpc = L->savedpc;
|
ci->savedpc = L->savedpc;
|
||||||
@ -41,7 +41,7 @@ static int ICACHE_FLASH_ATTR currentpc (lua_State *L, CallInfo *ci) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR currentline (lua_State *L, CallInfo *ci) {
|
static int currentline (lua_State *L, CallInfo *ci) {
|
||||||
int pc = currentpc(L, ci);
|
int pc = currentpc(L, ci);
|
||||||
if (pc < 0)
|
if (pc < 0)
|
||||||
return -1; /* only active lua functions have current-line information */
|
return -1; /* only active lua functions have current-line information */
|
||||||
@ -53,7 +53,7 @@ static int ICACHE_FLASH_ATTR currentline (lua_State *L, CallInfo *ci) {
|
|||||||
/*
|
/*
|
||||||
** this function can be called asynchronous (e.g. during a signal)
|
** this function can be called asynchronous (e.g. during a signal)
|
||||||
*/
|
*/
|
||||||
LUA_API int ICACHE_FLASH_ATTR lua_sethook (lua_State *L, lua_Hook func, int mask, int count) {
|
LUA_API int lua_sethook (lua_State *L, lua_Hook func, int mask, int count) {
|
||||||
if (func == NULL || mask == 0) { /* turn off hooks? */
|
if (func == NULL || mask == 0) { /* turn off hooks? */
|
||||||
mask = 0;
|
mask = 0;
|
||||||
func = NULL;
|
func = NULL;
|
||||||
@ -66,22 +66,22 @@ LUA_API int ICACHE_FLASH_ATTR lua_sethook (lua_State *L, lua_Hook func, int mask
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API lua_Hook ICACHE_FLASH_ATTR lua_gethook (lua_State *L) {
|
LUA_API lua_Hook lua_gethook (lua_State *L) {
|
||||||
return L->hook;
|
return L->hook;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API int ICACHE_FLASH_ATTR lua_gethookmask (lua_State *L) {
|
LUA_API int lua_gethookmask (lua_State *L) {
|
||||||
return L->hookmask;
|
return L->hookmask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API int ICACHE_FLASH_ATTR lua_gethookcount (lua_State *L) {
|
LUA_API int lua_gethookcount (lua_State *L) {
|
||||||
return L->basehookcount;
|
return L->basehookcount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API int ICACHE_FLASH_ATTR lua_getstack (lua_State *L, int level, lua_Debug *ar) {
|
LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar) {
|
||||||
int status;
|
int status;
|
||||||
CallInfo *ci;
|
CallInfo *ci;
|
||||||
lua_lock(L);
|
lua_lock(L);
|
||||||
@ -104,12 +104,12 @@ LUA_API int ICACHE_FLASH_ATTR lua_getstack (lua_State *L, int level, lua_Debug *
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Proto *ICACHE_FLASH_ATTR getluaproto (CallInfo *ci) {
|
static Proto *getluaproto (CallInfo *ci) {
|
||||||
return (isLua(ci) ? ci_func(ci)->l.p : NULL);
|
return (isLua(ci) ? ci_func(ci)->l.p : NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static const char *ICACHE_FLASH_ATTR findlocal (lua_State *L, CallInfo *ci, int n) {
|
static const char *findlocal (lua_State *L, CallInfo *ci, int n) {
|
||||||
const char *name;
|
const char *name;
|
||||||
Proto *fp = getluaproto(ci);
|
Proto *fp = getluaproto(ci);
|
||||||
if (fp && (name = luaF_getlocalname(fp, n, currentpc(L, ci))) != NULL)
|
if (fp && (name = luaF_getlocalname(fp, n, currentpc(L, ci))) != NULL)
|
||||||
@ -124,7 +124,7 @@ static const char *ICACHE_FLASH_ATTR findlocal (lua_State *L, CallInfo *ci, int
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API const char *ICACHE_FLASH_ATTR lua_getlocal (lua_State *L, const lua_Debug *ar, int n) {
|
LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n) {
|
||||||
CallInfo *ci = L->base_ci + ar->i_ci;
|
CallInfo *ci = L->base_ci + ar->i_ci;
|
||||||
const char *name = findlocal(L, ci, n);
|
const char *name = findlocal(L, ci, n);
|
||||||
lua_lock(L);
|
lua_lock(L);
|
||||||
@ -135,7 +135,7 @@ LUA_API const char *ICACHE_FLASH_ATTR lua_getlocal (lua_State *L, const lua_Debu
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API const char *ICACHE_FLASH_ATTR lua_setlocal (lua_State *L, const lua_Debug *ar, int n) {
|
LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n) {
|
||||||
CallInfo *ci = L->base_ci + ar->i_ci;
|
CallInfo *ci = L->base_ci + ar->i_ci;
|
||||||
const char *name = findlocal(L, ci, n);
|
const char *name = findlocal(L, ci, n);
|
||||||
lua_lock(L);
|
lua_lock(L);
|
||||||
@ -147,7 +147,7 @@ LUA_API const char *ICACHE_FLASH_ATTR lua_setlocal (lua_State *L, const lua_Debu
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR funcinfo (lua_Debug *ar, Closure *cl, void *plight) {
|
static void funcinfo (lua_Debug *ar, Closure *cl, void *plight) {
|
||||||
if (plight || cl->c.isC) {
|
if (plight || cl->c.isC) {
|
||||||
ar->source = "=[C]";
|
ar->source = "=[C]";
|
||||||
ar->linedefined = -1;
|
ar->linedefined = -1;
|
||||||
@ -164,7 +164,7 @@ static void ICACHE_FLASH_ATTR funcinfo (lua_Debug *ar, Closure *cl, void *plight
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR info_tailcall (lua_Debug *ar) {
|
static void info_tailcall (lua_Debug *ar) {
|
||||||
ar->name = ar->namewhat = "";
|
ar->name = ar->namewhat = "";
|
||||||
ar->what = "tail";
|
ar->what = "tail";
|
||||||
ar->lastlinedefined = ar->linedefined = ar->currentline = -1;
|
ar->lastlinedefined = ar->linedefined = ar->currentline = -1;
|
||||||
@ -174,7 +174,7 @@ static void ICACHE_FLASH_ATTR info_tailcall (lua_Debug *ar) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR collectvalidlines (lua_State *L, Closure *f) {
|
static void collectvalidlines (lua_State *L, Closure *f) {
|
||||||
if (f == NULL || f->c.isC) {
|
if (f == NULL || f->c.isC) {
|
||||||
setnilvalue(L->top);
|
setnilvalue(L->top);
|
||||||
}
|
}
|
||||||
@ -190,7 +190,7 @@ static void ICACHE_FLASH_ATTR collectvalidlines (lua_State *L, Closure *f) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR auxgetinfo (lua_State *L, const char *what, lua_Debug *ar,
|
static int auxgetinfo (lua_State *L, const char *what, lua_Debug *ar,
|
||||||
Closure *f, void *plight, CallInfo *ci) {
|
Closure *f, void *plight, CallInfo *ci) {
|
||||||
int status = 1;
|
int status = 1;
|
||||||
if (plight == NULL && f == NULL) {
|
if (plight == NULL && f == NULL) {
|
||||||
@ -229,7 +229,7 @@ static int ICACHE_FLASH_ATTR auxgetinfo (lua_State *L, const char *what, lua_Deb
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API int ICACHE_FLASH_ATTR lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) {
|
LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) {
|
||||||
int status;
|
int status;
|
||||||
Closure *f = NULL;
|
Closure *f = NULL;
|
||||||
CallInfo *ci = NULL;
|
CallInfo *ci = NULL;
|
||||||
@ -284,7 +284,7 @@ LUA_API int ICACHE_FLASH_ATTR lua_getinfo (lua_State *L, const char *what, lua_D
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR precheck (const Proto *pt) {
|
static int precheck (const Proto *pt) {
|
||||||
check(pt->maxstacksize <= MAXSTACK);
|
check(pt->maxstacksize <= MAXSTACK);
|
||||||
check(pt->numparams+(pt->is_vararg & VARARG_HASARG) <= pt->maxstacksize);
|
check(pt->numparams+(pt->is_vararg & VARARG_HASARG) <= pt->maxstacksize);
|
||||||
check(!(pt->is_vararg & VARARG_NEEDSARG) ||
|
check(!(pt->is_vararg & VARARG_NEEDSARG) ||
|
||||||
@ -298,7 +298,7 @@ static int ICACHE_FLASH_ATTR precheck (const Proto *pt) {
|
|||||||
|
|
||||||
#define checkopenop(pt,pc) luaG_checkopenop((pt)->code[(pc)+1])
|
#define checkopenop(pt,pc) luaG_checkopenop((pt)->code[(pc)+1])
|
||||||
|
|
||||||
int ICACHE_FLASH_ATTR luaG_checkopenop (Instruction i) {
|
int luaG_checkopenop (Instruction i) {
|
||||||
switch (GET_OPCODE(i)) {
|
switch (GET_OPCODE(i)) {
|
||||||
case OP_CALL:
|
case OP_CALL:
|
||||||
case OP_TAILCALL:
|
case OP_TAILCALL:
|
||||||
@ -312,7 +312,7 @@ int ICACHE_FLASH_ATTR luaG_checkopenop (Instruction i) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR checkArgMode (const Proto *pt, int r, enum OpArgMask mode) {
|
static int checkArgMode (const Proto *pt, int r, enum OpArgMask mode) {
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case OpArgN: check(r == 0); break;
|
case OpArgN: check(r == 0); break;
|
||||||
case OpArgU: break;
|
case OpArgU: break;
|
||||||
@ -325,7 +325,7 @@ static int ICACHE_FLASH_ATTR checkArgMode (const Proto *pt, int r, enum OpArgMas
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Instruction ICACHE_FLASH_ATTR symbexec (const Proto *pt, int lastpc, int reg) {
|
static Instruction symbexec (const Proto *pt, int lastpc, int reg) {
|
||||||
int pc;
|
int pc;
|
||||||
int last; /* stores position of last instruction that changed `reg' */
|
int last; /* stores position of last instruction that changed `reg' */
|
||||||
last = pt->sizecode-1; /* points to final return (a `neutral' instruction) */
|
last = pt->sizecode-1; /* points to final return (a `neutral' instruction) */
|
||||||
@ -492,12 +492,12 @@ static Instruction ICACHE_FLASH_ATTR symbexec (const Proto *pt, int lastpc, int
|
|||||||
/* }====================================================== */
|
/* }====================================================== */
|
||||||
|
|
||||||
|
|
||||||
int ICACHE_FLASH_ATTR luaG_checkcode (const Proto *pt) {
|
int luaG_checkcode (const Proto *pt) {
|
||||||
return (symbexec(pt, pt->sizecode, NO_REG) != 0);
|
return (symbexec(pt, pt->sizecode, NO_REG) != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static const char *ICACHE_FLASH_ATTR kname (Proto *p, int c) {
|
static const char *kname (Proto *p, int c) {
|
||||||
if (ISK(c) && ttisstring(&p->k[INDEXK(c)]))
|
if (ISK(c) && ttisstring(&p->k[INDEXK(c)]))
|
||||||
return svalue(&p->k[INDEXK(c)]);
|
return svalue(&p->k[INDEXK(c)]);
|
||||||
else
|
else
|
||||||
@ -505,7 +505,7 @@ static const char *ICACHE_FLASH_ATTR kname (Proto *p, int c) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static const char *ICACHE_FLASH_ATTR getobjname (lua_State *L, CallInfo *ci, int stackpos,
|
static const char *getobjname (lua_State *L, CallInfo *ci, int stackpos,
|
||||||
const char **name) {
|
const char **name) {
|
||||||
if (isLua(ci)) { /* a Lua function? */
|
if (isLua(ci)) { /* a Lua function? */
|
||||||
Proto *p = ci_func(ci)->l.p;
|
Proto *p = ci_func(ci)->l.p;
|
||||||
@ -552,7 +552,7 @@ static const char *ICACHE_FLASH_ATTR getobjname (lua_State *L, CallInfo *ci, int
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static const char *ICACHE_FLASH_ATTR getfuncname (lua_State *L, CallInfo *ci, const char **name) {
|
static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name) {
|
||||||
Instruction i;
|
Instruction i;
|
||||||
if ((isLua(ci) && ci->tailcalls > 0) || !isLua(ci - 1))
|
if ((isLua(ci) && ci->tailcalls > 0) || !isLua(ci - 1))
|
||||||
return NULL; /* calling function is not Lua (or is unknown) */
|
return NULL; /* calling function is not Lua (or is unknown) */
|
||||||
@ -567,7 +567,7 @@ static const char *ICACHE_FLASH_ATTR getfuncname (lua_State *L, CallInfo *ci, co
|
|||||||
|
|
||||||
|
|
||||||
/* only ANSI way to check whether a pointer points to an array */
|
/* only ANSI way to check whether a pointer points to an array */
|
||||||
static int ICACHE_FLASH_ATTR isinstack (CallInfo *ci, const TValue *o) {
|
static int isinstack (CallInfo *ci, const TValue *o) {
|
||||||
StkId p;
|
StkId p;
|
||||||
for (p = ci->base; p < ci->top; p++)
|
for (p = ci->base; p < ci->top; p++)
|
||||||
if (o == p) return 1;
|
if (o == p) return 1;
|
||||||
@ -575,7 +575,7 @@ static int ICACHE_FLASH_ATTR isinstack (CallInfo *ci, const TValue *o) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR luaG_typeerror (lua_State *L, const TValue *o, const char *op) {
|
void luaG_typeerror (lua_State *L, const TValue *o, const char *op) {
|
||||||
const char *name = NULL;
|
const char *name = NULL;
|
||||||
const char *t = luaT_typenames[ttype(o)];
|
const char *t = luaT_typenames[ttype(o)];
|
||||||
const char *kind = (isinstack(L->ci, o)) ?
|
const char *kind = (isinstack(L->ci, o)) ?
|
||||||
@ -589,14 +589,14 @@ void ICACHE_FLASH_ATTR luaG_typeerror (lua_State *L, const TValue *o, const char
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR luaG_concaterror (lua_State *L, StkId p1, StkId p2) {
|
void luaG_concaterror (lua_State *L, StkId p1, StkId p2) {
|
||||||
if (ttisstring(p1) || ttisnumber(p1)) p1 = p2;
|
if (ttisstring(p1) || ttisnumber(p1)) p1 = p2;
|
||||||
lua_assert(!ttisstring(p1) && !ttisnumber(p1));
|
lua_assert(!ttisstring(p1) && !ttisnumber(p1));
|
||||||
luaG_typeerror(L, p1, "concatenate");
|
luaG_typeerror(L, p1, "concatenate");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR luaG_aritherror (lua_State *L, const TValue *p1, const TValue *p2) {
|
void luaG_aritherror (lua_State *L, const TValue *p1, const TValue *p2) {
|
||||||
TValue temp;
|
TValue temp;
|
||||||
if (luaV_tonumber(p1, &temp) == NULL)
|
if (luaV_tonumber(p1, &temp) == NULL)
|
||||||
p2 = p1; /* first operand is wrong */
|
p2 = p1; /* first operand is wrong */
|
||||||
@ -604,7 +604,7 @@ void ICACHE_FLASH_ATTR luaG_aritherror (lua_State *L, const TValue *p1, const TV
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int ICACHE_FLASH_ATTR luaG_ordererror (lua_State *L, const TValue *p1, const TValue *p2) {
|
int luaG_ordererror (lua_State *L, const TValue *p1, const TValue *p2) {
|
||||||
const char *t1 = luaT_typenames[ttype(p1)];
|
const char *t1 = luaT_typenames[ttype(p1)];
|
||||||
const char *t2 = luaT_typenames[ttype(p2)];
|
const char *t2 = luaT_typenames[ttype(p2)];
|
||||||
if (t1[2] == t2[2])
|
if (t1[2] == t2[2])
|
||||||
@ -615,7 +615,7 @@ int ICACHE_FLASH_ATTR luaG_ordererror (lua_State *L, const TValue *p1, const TVa
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR addinfo (lua_State *L, const char *msg) {
|
static void addinfo (lua_State *L, const char *msg) {
|
||||||
CallInfo *ci = L->ci;
|
CallInfo *ci = L->ci;
|
||||||
if (isLua(ci)) { /* is Lua code? */
|
if (isLua(ci)) { /* is Lua code? */
|
||||||
char buff[LUA_IDSIZE]; /* add file:line information */
|
char buff[LUA_IDSIZE]; /* add file:line information */
|
||||||
@ -626,7 +626,7 @@ static void ICACHE_FLASH_ATTR addinfo (lua_State *L, const char *msg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR luaG_errormsg (lua_State *L) {
|
void luaG_errormsg (lua_State *L) {
|
||||||
if (L->errfunc != 0) { /* is there an error handling function? */
|
if (L->errfunc != 0) { /* is there an error handling function? */
|
||||||
StkId errfunc = restorestack(L, L->errfunc);
|
StkId errfunc = restorestack(L, L->errfunc);
|
||||||
if (!ttisfunction(errfunc) && !ttislightfunction(errfunc)) luaD_throw(L, LUA_ERRERR);
|
if (!ttisfunction(errfunc) && !ttislightfunction(errfunc)) luaD_throw(L, LUA_ERRERR);
|
||||||
@ -639,7 +639,7 @@ void ICACHE_FLASH_ATTR luaG_errormsg (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR luaG_runerror (lua_State *L, const char *fmt, ...) {
|
void luaG_runerror (lua_State *L, const char *fmt, ...) {
|
||||||
va_list argp;
|
va_list argp;
|
||||||
va_start(argp, fmt);
|
va_start(argp, fmt);
|
||||||
addinfo(L, luaO_pushvfstring(L, fmt, argp));
|
addinfo(L, luaO_pushvfstring(L, fmt, argp));
|
||||||
|
@ -48,7 +48,7 @@ struct lua_longjmp {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop) {
|
void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop) {
|
||||||
switch (errcode) {
|
switch (errcode) {
|
||||||
case LUA_ERRMEM: {
|
case LUA_ERRMEM: {
|
||||||
ptrdiff_t oldtopr = savestack(L, oldtop);
|
ptrdiff_t oldtopr = savestack(L, oldtop);
|
||||||
@ -70,7 +70,7 @@ void ICACHE_FLASH_ATTR luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR restore_stack_limit (lua_State *L) {
|
static void restore_stack_limit (lua_State *L) {
|
||||||
lua_assert(L->stack_last - L->stack == L->stacksize - EXTRA_STACK - 1);
|
lua_assert(L->stack_last - L->stack == L->stacksize - EXTRA_STACK - 1);
|
||||||
if (L->size_ci > LUAI_MAXCALLS) { /* there was an overflow? */
|
if (L->size_ci > LUAI_MAXCALLS) { /* there was an overflow? */
|
||||||
int inuse = cast_int(L->ci - L->base_ci);
|
int inuse = cast_int(L->ci - L->base_ci);
|
||||||
@ -80,7 +80,7 @@ static void ICACHE_FLASH_ATTR restore_stack_limit (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR resetstack (lua_State *L, int status) {
|
static void resetstack (lua_State *L, int status) {
|
||||||
L->ci = L->base_ci;
|
L->ci = L->base_ci;
|
||||||
L->base = L->ci->base;
|
L->base = L->ci->base;
|
||||||
luaF_close(L, L->base); /* close eventual pending closures */
|
luaF_close(L, L->base); /* close eventual pending closures */
|
||||||
@ -93,7 +93,7 @@ static void ICACHE_FLASH_ATTR resetstack (lua_State *L, int status) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR luaD_throw (lua_State *L, int errcode) {
|
void luaD_throw (lua_State *L, int errcode) {
|
||||||
unfixedstack(L); /* make sure the fixedstack & block_gc flags get reset. */
|
unfixedstack(L); /* make sure the fixedstack & block_gc flags get reset. */
|
||||||
unset_block_gc(L);
|
unset_block_gc(L);
|
||||||
if (L->errorJmp) {
|
if (L->errorJmp) {
|
||||||
@ -112,7 +112,7 @@ void ICACHE_FLASH_ATTR luaD_throw (lua_State *L, int errcode) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int ICACHE_FLASH_ATTR luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud) {
|
int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud) {
|
||||||
struct lua_longjmp lj;
|
struct lua_longjmp lj;
|
||||||
lj.status = 0;
|
lj.status = 0;
|
||||||
lj.previous = L->errorJmp; /* chain new error handler */
|
lj.previous = L->errorJmp; /* chain new error handler */
|
||||||
@ -127,7 +127,7 @@ int ICACHE_FLASH_ATTR luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud) {
|
|||||||
/* }====================================================== */
|
/* }====================================================== */
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR correctstack (lua_State *L, TValue *oldstack) {
|
static void correctstack (lua_State *L, TValue *oldstack) {
|
||||||
CallInfo *ci;
|
CallInfo *ci;
|
||||||
GCObject *up;
|
GCObject *up;
|
||||||
L->top = (L->top - oldstack) + L->stack;
|
L->top = (L->top - oldstack) + L->stack;
|
||||||
@ -142,7 +142,7 @@ static void ICACHE_FLASH_ATTR correctstack (lua_State *L, TValue *oldstack) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR luaD_reallocstack (lua_State *L, int newsize) {
|
void luaD_reallocstack (lua_State *L, int newsize) {
|
||||||
TValue *oldstack = L->stack;
|
TValue *oldstack = L->stack;
|
||||||
int realsize = newsize + 1 + EXTRA_STACK;
|
int realsize = newsize + 1 + EXTRA_STACK;
|
||||||
lua_assert(L->stack_last - L->stack == L->stacksize - EXTRA_STACK - 1);
|
lua_assert(L->stack_last - L->stack == L->stacksize - EXTRA_STACK - 1);
|
||||||
@ -153,7 +153,7 @@ void ICACHE_FLASH_ATTR luaD_reallocstack (lua_State *L, int newsize) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR luaD_reallocCI (lua_State *L, int newsize) {
|
void luaD_reallocCI (lua_State *L, int newsize) {
|
||||||
CallInfo *oldci = L->base_ci;
|
CallInfo *oldci = L->base_ci;
|
||||||
luaM_reallocvector(L, L->base_ci, L->size_ci, newsize, CallInfo);
|
luaM_reallocvector(L, L->base_ci, L->size_ci, newsize, CallInfo);
|
||||||
L->size_ci = newsize;
|
L->size_ci = newsize;
|
||||||
@ -162,7 +162,7 @@ void ICACHE_FLASH_ATTR luaD_reallocCI (lua_State *L, int newsize) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR luaD_growstack (lua_State *L, int n) {
|
void luaD_growstack (lua_State *L, int n) {
|
||||||
if (n <= L->stacksize) /* double size is enough? */
|
if (n <= L->stacksize) /* double size is enough? */
|
||||||
luaD_reallocstack(L, 2*L->stacksize);
|
luaD_reallocstack(L, 2*L->stacksize);
|
||||||
else
|
else
|
||||||
@ -170,7 +170,7 @@ void ICACHE_FLASH_ATTR luaD_growstack (lua_State *L, int n) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static CallInfo *ICACHE_FLASH_ATTR growCI (lua_State *L) {
|
static CallInfo *growCI (lua_State *L) {
|
||||||
if (L->size_ci > LUAI_MAXCALLS) /* overflow while handling overflow? */
|
if (L->size_ci > LUAI_MAXCALLS) /* overflow while handling overflow? */
|
||||||
luaD_throw(L, LUA_ERRERR);
|
luaD_throw(L, LUA_ERRERR);
|
||||||
else {
|
else {
|
||||||
@ -182,7 +182,7 @@ static CallInfo *ICACHE_FLASH_ATTR growCI (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR luaD_callhook (lua_State *L, int event, int line) {
|
void luaD_callhook (lua_State *L, int event, int line) {
|
||||||
lua_Hook hook = L->hook;
|
lua_Hook hook = L->hook;
|
||||||
if (hook && L->allowhook) {
|
if (hook && L->allowhook) {
|
||||||
ptrdiff_t top = savestack(L, L->top);
|
ptrdiff_t top = savestack(L, L->top);
|
||||||
@ -209,7 +209,7 @@ void ICACHE_FLASH_ATTR luaD_callhook (lua_State *L, int event, int line) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static StkId ICACHE_FLASH_ATTR adjust_varargs (lua_State *L, Proto *p, int actual) {
|
static StkId adjust_varargs (lua_State *L, Proto *p, int actual) {
|
||||||
int i;
|
int i;
|
||||||
int nfixargs = p->numparams;
|
int nfixargs = p->numparams;
|
||||||
#if defined(LUA_COMPAT_VARARG)
|
#if defined(LUA_COMPAT_VARARG)
|
||||||
@ -253,7 +253,7 @@ static StkId ICACHE_FLASH_ATTR adjust_varargs (lua_State *L, Proto *p, int actua
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static StkId ICACHE_FLASH_ATTR tryfuncTM (lua_State *L, StkId func) {
|
static StkId tryfuncTM (lua_State *L, StkId func) {
|
||||||
const TValue *tm = luaT_gettmbyobj(L, func, TM_CALL);
|
const TValue *tm = luaT_gettmbyobj(L, func, TM_CALL);
|
||||||
StkId p;
|
StkId p;
|
||||||
ptrdiff_t funcr = savestack(L, func);
|
ptrdiff_t funcr = savestack(L, func);
|
||||||
@ -274,7 +274,7 @@ static StkId ICACHE_FLASH_ATTR tryfuncTM (lua_State *L, StkId func) {
|
|||||||
(condhardstacktests(luaD_reallocCI(L, L->size_ci)), ++L->ci))
|
(condhardstacktests(luaD_reallocCI(L, L->size_ci)), ++L->ci))
|
||||||
|
|
||||||
|
|
||||||
int ICACHE_FLASH_ATTR luaD_precall (lua_State *L, StkId func, int nresults) {
|
int luaD_precall (lua_State *L, StkId func, int nresults) {
|
||||||
ptrdiff_t funcr;
|
ptrdiff_t funcr;
|
||||||
LClosure *cl = NULL;
|
LClosure *cl = NULL;
|
||||||
if (!ttisfunction(func) && !ttislightfunction(func)) /* `func' is not a function? */
|
if (!ttisfunction(func) && !ttislightfunction(func)) /* `func' is not a function? */
|
||||||
@ -345,7 +345,7 @@ int ICACHE_FLASH_ATTR luaD_precall (lua_State *L, StkId func, int nresults) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static StkId ICACHE_FLASH_ATTR callrethooks (lua_State *L, StkId firstResult) {
|
static StkId callrethooks (lua_State *L, StkId firstResult) {
|
||||||
ptrdiff_t fr = savestack(L, firstResult); /* next call may change stack */
|
ptrdiff_t fr = savestack(L, firstResult); /* next call may change stack */
|
||||||
luaD_callhook(L, LUA_HOOKRET, -1);
|
luaD_callhook(L, LUA_HOOKRET, -1);
|
||||||
if (f_isLua(L->ci)) { /* Lua function? */
|
if (f_isLua(L->ci)) { /* Lua function? */
|
||||||
@ -356,7 +356,7 @@ static StkId ICACHE_FLASH_ATTR callrethooks (lua_State *L, StkId firstResult) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int ICACHE_FLASH_ATTR luaD_poscall (lua_State *L, StkId firstResult) {
|
int luaD_poscall (lua_State *L, StkId firstResult) {
|
||||||
StkId res;
|
StkId res;
|
||||||
int wanted, i;
|
int wanted, i;
|
||||||
CallInfo *ci;
|
CallInfo *ci;
|
||||||
@ -383,7 +383,7 @@ int ICACHE_FLASH_ATTR luaD_poscall (lua_State *L, StkId firstResult) {
|
|||||||
** When returns, all the results are on the stack, starting at the original
|
** When returns, all the results are on the stack, starting at the original
|
||||||
** function position.
|
** function position.
|
||||||
*/
|
*/
|
||||||
void ICACHE_FLASH_ATTR luaD_call (lua_State *L, StkId func, int nResults) {
|
void luaD_call (lua_State *L, StkId func, int nResults) {
|
||||||
if (++L->nCcalls >= LUAI_MAXCCALLS) {
|
if (++L->nCcalls >= LUAI_MAXCCALLS) {
|
||||||
if (L->nCcalls == LUAI_MAXCCALLS)
|
if (L->nCcalls == LUAI_MAXCCALLS)
|
||||||
luaG_runerror(L, "C stack overflow");
|
luaG_runerror(L, "C stack overflow");
|
||||||
@ -397,7 +397,7 @@ void ICACHE_FLASH_ATTR luaD_call (lua_State *L, StkId func, int nResults) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR resume (lua_State *L, void *ud) {
|
static void resume (lua_State *L, void *ud) {
|
||||||
StkId firstArg = cast(StkId, ud);
|
StkId firstArg = cast(StkId, ud);
|
||||||
CallInfo *ci = L->ci;
|
CallInfo *ci = L->ci;
|
||||||
if (L->status == 0) { /* start coroutine? */
|
if (L->status == 0) { /* start coroutine? */
|
||||||
@ -422,7 +422,7 @@ static void ICACHE_FLASH_ATTR resume (lua_State *L, void *ud) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR resume_error (lua_State *L, const char *msg) {
|
static int resume_error (lua_State *L, const char *msg) {
|
||||||
L->top = L->ci->base;
|
L->top = L->ci->base;
|
||||||
setsvalue2s(L, L->top, luaS_new(L, msg));
|
setsvalue2s(L, L->top, luaS_new(L, msg));
|
||||||
incr_top(L);
|
incr_top(L);
|
||||||
@ -431,7 +431,7 @@ static int ICACHE_FLASH_ATTR resume_error (lua_State *L, const char *msg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API int ICACHE_FLASH_ATTR lua_resume (lua_State *L, int nargs) {
|
LUA_API int lua_resume (lua_State *L, int nargs) {
|
||||||
int status;
|
int status;
|
||||||
lua_lock(L);
|
lua_lock(L);
|
||||||
if (L->status != LUA_YIELD && (L->status != 0 || L->ci != L->base_ci))
|
if (L->status != LUA_YIELD && (L->status != 0 || L->ci != L->base_ci))
|
||||||
@ -457,7 +457,7 @@ LUA_API int ICACHE_FLASH_ATTR lua_resume (lua_State *L, int nargs) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API int ICACHE_FLASH_ATTR lua_yield (lua_State *L, int nresults) {
|
LUA_API int lua_yield (lua_State *L, int nresults) {
|
||||||
luai_userstateyield(L, nresults);
|
luai_userstateyield(L, nresults);
|
||||||
lua_lock(L);
|
lua_lock(L);
|
||||||
if (L->nCcalls > L->baseCcalls)
|
if (L->nCcalls > L->baseCcalls)
|
||||||
@ -469,7 +469,7 @@ LUA_API int ICACHE_FLASH_ATTR lua_yield (lua_State *L, int nresults) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int ICACHE_FLASH_ATTR luaD_pcall (lua_State *L, Pfunc func, void *u,
|
int luaD_pcall (lua_State *L, Pfunc func, void *u,
|
||||||
ptrdiff_t old_top, ptrdiff_t ef) {
|
ptrdiff_t old_top, ptrdiff_t ef) {
|
||||||
int status;
|
int status;
|
||||||
unsigned short oldnCcalls = L->nCcalls;
|
unsigned short oldnCcalls = L->nCcalls;
|
||||||
@ -504,7 +504,7 @@ struct SParser { /* data to `f_parser' */
|
|||||||
const char *name;
|
const char *name;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR f_parser (lua_State *L, void *ud) {
|
static void f_parser (lua_State *L, void *ud) {
|
||||||
int i;
|
int i;
|
||||||
Proto *tf;
|
Proto *tf;
|
||||||
Closure *cl;
|
Closure *cl;
|
||||||
@ -524,7 +524,7 @@ static void ICACHE_FLASH_ATTR f_parser (lua_State *L, void *ud) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int ICACHE_FLASH_ATTR luaD_protectedparser (lua_State *L, ZIO *z, const char *name) {
|
int luaD_protectedparser (lua_State *L, ZIO *z, const char *name) {
|
||||||
struct SParser p;
|
struct SParser p;
|
||||||
int status;
|
int status;
|
||||||
p.z = z; p.name = name;
|
p.z = z; p.name = name;
|
||||||
|
@ -29,7 +29,7 @@ typedef struct {
|
|||||||
#define DumpMem(b,n,size,D) DumpBlock(b,(n)*(size),D)
|
#define DumpMem(b,n,size,D) DumpBlock(b,(n)*(size),D)
|
||||||
#define DumpVar(x,D) DumpMem(&x,1,sizeof(x),D)
|
#define DumpVar(x,D) DumpMem(&x,1,sizeof(x),D)
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR DumpBlock(const void* b, size_t size, DumpState* D)
|
static void DumpBlock(const void* b, size_t size, DumpState* D)
|
||||||
{
|
{
|
||||||
if (D->status==0)
|
if (D->status==0)
|
||||||
{
|
{
|
||||||
@ -40,19 +40,19 @@ static void ICACHE_FLASH_ATTR DumpBlock(const void* b, size_t size, DumpState* D
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR DumpChar(int y, DumpState* D)
|
static void DumpChar(int y, DumpState* D)
|
||||||
{
|
{
|
||||||
char x=(char)y;
|
char x=(char)y;
|
||||||
DumpVar(x,D);
|
DumpVar(x,D);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR Align4(DumpState *D)
|
static void Align4(DumpState *D)
|
||||||
{
|
{
|
||||||
while(D->wrote&3)
|
while(D->wrote&3)
|
||||||
DumpChar(0,D);
|
DumpChar(0,D);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR MaybeByteSwap(char *number, size_t numbersize, DumpState *D)
|
static void MaybeByteSwap(char *number, size_t numbersize, DumpState *D)
|
||||||
{
|
{
|
||||||
int x=1;
|
int x=1;
|
||||||
int platform_little_endian = *(char*)&x;
|
int platform_little_endian = *(char*)&x;
|
||||||
@ -68,7 +68,7 @@ static void ICACHE_FLASH_ATTR MaybeByteSwap(char *number, size_t numbersize, Dum
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR DumpIntWithSize(int x, int sizeof_int, DumpState* D)
|
static void DumpIntWithSize(int x, int sizeof_int, DumpState* D)
|
||||||
{
|
{
|
||||||
/* dump signed integer */
|
/* dump signed integer */
|
||||||
switch(sizeof_int) {
|
switch(sizeof_int) {
|
||||||
@ -93,12 +93,12 @@ static void ICACHE_FLASH_ATTR DumpIntWithSize(int x, int sizeof_int, DumpState*
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR DumpInt(int x, DumpState* D)
|
static void DumpInt(int x, DumpState* D)
|
||||||
{
|
{
|
||||||
DumpIntWithSize(x,D->target.sizeof_int,D);
|
DumpIntWithSize(x,D->target.sizeof_int,D);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR DumpSize(uint32_t x, DumpState* D)
|
static void DumpSize(uint32_t x, DumpState* D)
|
||||||
{
|
{
|
||||||
/* dump unsigned integer */
|
/* dump unsigned integer */
|
||||||
switch(D->target.sizeof_strsize_t) {
|
switch(D->target.sizeof_strsize_t) {
|
||||||
@ -123,7 +123,7 @@ static void ICACHE_FLASH_ATTR DumpSize(uint32_t x, DumpState* D)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR DumpNumber(lua_Number x, DumpState* D)
|
static void DumpNumber(lua_Number x, DumpState* D)
|
||||||
{
|
{
|
||||||
#if defined( LUA_NUMBER_INTEGRAL ) && !defined( LUA_CROSS_COMPILER )
|
#if defined( LUA_NUMBER_INTEGRAL ) && !defined( LUA_CROSS_COMPILER )
|
||||||
DumpIntWithSize(x,D->target.sizeof_lua_Number,D);
|
DumpIntWithSize(x,D->target.sizeof_lua_Number,D);
|
||||||
@ -164,7 +164,7 @@ static void ICACHE_FLASH_ATTR DumpNumber(lua_Number x, DumpState* D)
|
|||||||
#endif // #if defined( LUA_NUMBER_INTEGRAL ) && !defined( LUA_CROSS_COMPILER )
|
#endif // #if defined( LUA_NUMBER_INTEGRAL ) && !defined( LUA_CROSS_COMPILER )
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR DumpCode(const Proto *f, DumpState* D)
|
static void DumpCode(const Proto *f, DumpState* D)
|
||||||
{
|
{
|
||||||
DumpInt(f->sizecode,D);
|
DumpInt(f->sizecode,D);
|
||||||
char buf[10];
|
char buf[10];
|
||||||
@ -178,7 +178,7 @@ static void ICACHE_FLASH_ATTR DumpCode(const Proto *f, DumpState* D)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR DumpString(const TString* s, DumpState* D)
|
static void DumpString(const TString* s, DumpState* D)
|
||||||
{
|
{
|
||||||
if (s==NULL || getstr(s)==NULL)
|
if (s==NULL || getstr(s)==NULL)
|
||||||
{
|
{
|
||||||
@ -195,7 +195,7 @@ static void ICACHE_FLASH_ATTR DumpString(const TString* s, DumpState* D)
|
|||||||
|
|
||||||
static void DumpFunction(const Proto* f, const TString* p, DumpState* D);
|
static void DumpFunction(const Proto* f, const TString* p, DumpState* D);
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR DumpConstants(const Proto* f, DumpState* D)
|
static void DumpConstants(const Proto* f, DumpState* D)
|
||||||
{
|
{
|
||||||
int i,n=f->sizek;
|
int i,n=f->sizek;
|
||||||
DumpInt(n,D);
|
DumpInt(n,D);
|
||||||
@ -226,7 +226,7 @@ static void ICACHE_FLASH_ATTR DumpConstants(const Proto* f, DumpState* D)
|
|||||||
for (i=0; i<n; i++) DumpFunction(f->p[i],f->source,D);
|
for (i=0; i<n; i++) DumpFunction(f->p[i],f->source,D);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR DumpDebug(const Proto* f, DumpState* D)
|
static void DumpDebug(const Proto* f, DumpState* D)
|
||||||
{
|
{
|
||||||
int i,n;
|
int i,n;
|
||||||
n= (D->strip) ? 0 : f->sizelineinfo;
|
n= (D->strip) ? 0 : f->sizelineinfo;
|
||||||
@ -251,7 +251,7 @@ static void ICACHE_FLASH_ATTR DumpDebug(const Proto* f, DumpState* D)
|
|||||||
for (i=0; i<n; i++) DumpString(f->upvalues[i],D);
|
for (i=0; i<n; i++) DumpString(f->upvalues[i],D);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR DumpFunction(const Proto* f, const TString* p, DumpState* D)
|
static void DumpFunction(const Proto* f, const TString* p, DumpState* D)
|
||||||
{
|
{
|
||||||
DumpString((f->source==p || D->strip) ? NULL : f->source,D);
|
DumpString((f->source==p || D->strip) ? NULL : f->source,D);
|
||||||
DumpInt(f->linedefined,D);
|
DumpInt(f->linedefined,D);
|
||||||
@ -265,7 +265,7 @@ static void ICACHE_FLASH_ATTR DumpFunction(const Proto* f, const TString* p, Dum
|
|||||||
DumpDebug(f,D);
|
DumpDebug(f,D);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR DumpHeader(DumpState* D)
|
static void DumpHeader(DumpState* D)
|
||||||
{
|
{
|
||||||
char buf[LUAC_HEADERSIZE];
|
char buf[LUAC_HEADERSIZE];
|
||||||
char *h=buf;
|
char *h=buf;
|
||||||
@ -288,7 +288,7 @@ static void ICACHE_FLASH_ATTR DumpHeader(DumpState* D)
|
|||||||
/*
|
/*
|
||||||
** dump Lua function as precompiled chunk with specified target
|
** dump Lua function as precompiled chunk with specified target
|
||||||
*/
|
*/
|
||||||
int ICACHE_FLASH_ATTR luaU_dump_crosscompile (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip, DumpTargetInfo target)
|
int luaU_dump_crosscompile (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip, DumpTargetInfo target)
|
||||||
{
|
{
|
||||||
DumpState D;
|
DumpState D;
|
||||||
D.L=L;
|
D.L=L;
|
||||||
@ -306,7 +306,7 @@ int ICACHE_FLASH_ATTR luaU_dump_crosscompile (lua_State* L, const Proto* f, lua_
|
|||||||
/*
|
/*
|
||||||
** dump Lua function as precompiled chunk with local machine as target
|
** dump Lua function as precompiled chunk with local machine as target
|
||||||
*/
|
*/
|
||||||
int ICACHE_FLASH_ATTR luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip)
|
int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip)
|
||||||
{
|
{
|
||||||
DumpTargetInfo target;
|
DumpTargetInfo target;
|
||||||
int test=1;
|
int test=1;
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include "lstate.h"
|
#include "lstate.h"
|
||||||
#include "c_types.h"
|
#include "c_types.h"
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR legc_set_mode(lua_State *L, int mode, unsigned limit) {
|
void legc_set_mode(lua_State *L, int mode, unsigned limit) {
|
||||||
global_State *g = G(L);
|
global_State *g = G(L);
|
||||||
|
|
||||||
g->egcmode = mode;
|
g->egcmode = mode;
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
Closure *ICACHE_FLASH_ATTR luaF_newCclosure (lua_State *L, int nelems, Table *e) {
|
Closure *luaF_newCclosure (lua_State *L, int nelems, Table *e) {
|
||||||
Closure *c = cast(Closure *, luaM_malloc(L, sizeCclosure(nelems)));
|
Closure *c = cast(Closure *, luaM_malloc(L, sizeCclosure(nelems)));
|
||||||
luaC_link(L, obj2gco(c), LUA_TFUNCTION);
|
luaC_link(L, obj2gco(c), LUA_TFUNCTION);
|
||||||
c->c.isC = 1;
|
c->c.isC = 1;
|
||||||
@ -30,7 +30,7 @@ Closure *ICACHE_FLASH_ATTR luaF_newCclosure (lua_State *L, int nelems, Table *e)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Closure *ICACHE_FLASH_ATTR luaF_newLclosure (lua_State *L, int nelems, Table *e) {
|
Closure *luaF_newLclosure (lua_State *L, int nelems, Table *e) {
|
||||||
Closure *c = cast(Closure *, luaM_malloc(L, sizeLclosure(nelems)));
|
Closure *c = cast(Closure *, luaM_malloc(L, sizeLclosure(nelems)));
|
||||||
luaC_link(L, obj2gco(c), LUA_TFUNCTION);
|
luaC_link(L, obj2gco(c), LUA_TFUNCTION);
|
||||||
c->l.isC = 0;
|
c->l.isC = 0;
|
||||||
@ -41,7 +41,7 @@ Closure *ICACHE_FLASH_ATTR luaF_newLclosure (lua_State *L, int nelems, Table *e)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
UpVal *ICACHE_FLASH_ATTR luaF_newupval (lua_State *L) {
|
UpVal *luaF_newupval (lua_State *L) {
|
||||||
UpVal *uv = luaM_new(L, UpVal);
|
UpVal *uv = luaM_new(L, UpVal);
|
||||||
luaC_link(L, obj2gco(uv), LUA_TUPVAL);
|
luaC_link(L, obj2gco(uv), LUA_TUPVAL);
|
||||||
uv->v = &uv->u.value;
|
uv->v = &uv->u.value;
|
||||||
@ -50,7 +50,7 @@ UpVal *ICACHE_FLASH_ATTR luaF_newupval (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
UpVal *ICACHE_FLASH_ATTR luaF_findupval (lua_State *L, StkId level) {
|
UpVal *luaF_findupval (lua_State *L, StkId level) {
|
||||||
global_State *g = G(L);
|
global_State *g = G(L);
|
||||||
GCObject **pp = &L->openupval;
|
GCObject **pp = &L->openupval;
|
||||||
UpVal *p;
|
UpVal *p;
|
||||||
@ -79,21 +79,21 @@ UpVal *ICACHE_FLASH_ATTR luaF_findupval (lua_State *L, StkId level) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR unlinkupval (UpVal *uv) {
|
static void unlinkupval (UpVal *uv) {
|
||||||
lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv);
|
lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv);
|
||||||
uv->u.l.next->u.l.prev = uv->u.l.prev; /* remove from `uvhead' list */
|
uv->u.l.next->u.l.prev = uv->u.l.prev; /* remove from `uvhead' list */
|
||||||
uv->u.l.prev->u.l.next = uv->u.l.next;
|
uv->u.l.prev->u.l.next = uv->u.l.next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR luaF_freeupval (lua_State *L, UpVal *uv) {
|
void luaF_freeupval (lua_State *L, UpVal *uv) {
|
||||||
if (uv->v != &uv->u.value) /* is it open? */
|
if (uv->v != &uv->u.value) /* is it open? */
|
||||||
unlinkupval(uv); /* remove from open list */
|
unlinkupval(uv); /* remove from open list */
|
||||||
luaM_free(L, uv); /* free upvalue */
|
luaM_free(L, uv); /* free upvalue */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR luaF_close (lua_State *L, StkId level) {
|
void luaF_close (lua_State *L, StkId level) {
|
||||||
UpVal *uv;
|
UpVal *uv;
|
||||||
global_State *g = G(L);
|
global_State *g = G(L);
|
||||||
while (L->openupval != NULL && (uv = ngcotouv(L->openupval))->v >= level) {
|
while (L->openupval != NULL && (uv = ngcotouv(L->openupval))->v >= level) {
|
||||||
@ -112,7 +112,7 @@ void ICACHE_FLASH_ATTR luaF_close (lua_State *L, StkId level) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Proto *ICACHE_FLASH_ATTR luaF_newproto (lua_State *L) {
|
Proto *luaF_newproto (lua_State *L) {
|
||||||
Proto *f = luaM_new(L, Proto);
|
Proto *f = luaM_new(L, Proto);
|
||||||
luaC_link(L, obj2gco(f), LUA_TPROTO);
|
luaC_link(L, obj2gco(f), LUA_TPROTO);
|
||||||
f->k = NULL;
|
f->k = NULL;
|
||||||
@ -138,7 +138,7 @@ Proto *ICACHE_FLASH_ATTR luaF_newproto (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR luaF_freeproto (lua_State *L, Proto *f) {
|
void luaF_freeproto (lua_State *L, Proto *f) {
|
||||||
luaM_freearray(L, f->p, f->sizep, Proto *);
|
luaM_freearray(L, f->p, f->sizep, Proto *);
|
||||||
luaM_freearray(L, f->k, f->sizek, TValue);
|
luaM_freearray(L, f->k, f->sizek, TValue);
|
||||||
luaM_freearray(L, f->locvars, f->sizelocvars, struct LocVar);
|
luaM_freearray(L, f->locvars, f->sizelocvars, struct LocVar);
|
||||||
@ -151,7 +151,7 @@ void ICACHE_FLASH_ATTR luaF_freeproto (lua_State *L, Proto *f) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR luaF_freeclosure (lua_State *L, Closure *c) {
|
void luaF_freeclosure (lua_State *L, Closure *c) {
|
||||||
int size = (c->c.isC) ? sizeCclosure(c->c.nupvalues) :
|
int size = (c->c.isC) ? sizeCclosure(c->c.nupvalues) :
|
||||||
sizeLclosure(c->l.nupvalues);
|
sizeLclosure(c->l.nupvalues);
|
||||||
luaM_freemem(L, c, size);
|
luaM_freemem(L, c, size);
|
||||||
@ -162,7 +162,7 @@ void ICACHE_FLASH_ATTR luaF_freeclosure (lua_State *L, Closure *c) {
|
|||||||
** Look for n-th local variable at line `line' in function `func'.
|
** Look for n-th local variable at line `line' in function `func'.
|
||||||
** Returns NULL if not found.
|
** Returns NULL if not found.
|
||||||
*/
|
*/
|
||||||
const char *ICACHE_FLASH_ATTR luaF_getlocalname (const Proto *f, int local_number, int pc) {
|
const char *luaF_getlocalname (const Proto *f, int local_number, int pc) {
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i<f->sizelocvars && f->locvars[i].startpc <= pc; i++) {
|
for (i = 0; i<f->sizelocvars && f->locvars[i].startpc <= pc; i++) {
|
||||||
if (pc < f->locvars[i].endpc) { /* is variable active? */
|
if (pc < f->locvars[i].endpc) { /* is variable active? */
|
||||||
|
@ -59,14 +59,14 @@
|
|||||||
#define setthreshold(g) (g->GCthreshold = (g->estimate/100) * g->gcpause)
|
#define setthreshold(g) (g->GCthreshold = (g->estimate/100) * g->gcpause)
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR removeentry (Node *n) {
|
static void removeentry (Node *n) {
|
||||||
lua_assert(ttisnil(gval(n)));
|
lua_assert(ttisnil(gval(n)));
|
||||||
if (iscollectable(gkey(n)))
|
if (iscollectable(gkey(n)))
|
||||||
setttype(gkey(n), LUA_TDEADKEY); /* dead key; remove it */
|
setttype(gkey(n), LUA_TDEADKEY); /* dead key; remove it */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR reallymarkobject (global_State *g, GCObject *o) {
|
static void reallymarkobject (global_State *g, GCObject *o) {
|
||||||
lua_assert(iswhite(o) && !isdead(g, o));
|
lua_assert(iswhite(o) && !isdead(g, o));
|
||||||
white2gray(o);
|
white2gray(o);
|
||||||
switch (o->gch.tt) {
|
switch (o->gch.tt) {
|
||||||
@ -112,7 +112,7 @@ static void ICACHE_FLASH_ATTR reallymarkobject (global_State *g, GCObject *o) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR marktmu (global_State *g) {
|
static void marktmu (global_State *g) {
|
||||||
GCObject *u = g->tmudata;
|
GCObject *u = g->tmudata;
|
||||||
if (u) {
|
if (u) {
|
||||||
do {
|
do {
|
||||||
@ -125,7 +125,7 @@ static void ICACHE_FLASH_ATTR marktmu (global_State *g) {
|
|||||||
|
|
||||||
|
|
||||||
/* move `dead' udata that need finalization to list `tmudata' */
|
/* move `dead' udata that need finalization to list `tmudata' */
|
||||||
size_t ICACHE_FLASH_ATTR luaC_separateudata (lua_State *L, int all) {
|
size_t luaC_separateudata (lua_State *L, int all) {
|
||||||
global_State *g = G(L);
|
global_State *g = G(L);
|
||||||
size_t deadmem = 0;
|
size_t deadmem = 0;
|
||||||
GCObject **p = &g->mainthread->next;
|
GCObject **p = &g->mainthread->next;
|
||||||
@ -155,7 +155,7 @@ size_t ICACHE_FLASH_ATTR luaC_separateudata (lua_State *L, int all) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR traversetable (global_State *g, Table *h) {
|
static int traversetable (global_State *g, Table *h) {
|
||||||
int i;
|
int i;
|
||||||
int weakkey = 0;
|
int weakkey = 0;
|
||||||
int weakvalue = 0;
|
int weakvalue = 0;
|
||||||
@ -200,7 +200,7 @@ static int ICACHE_FLASH_ATTR traversetable (global_State *g, Table *h) {
|
|||||||
** All marks are conditional because a GC may happen while the
|
** All marks are conditional because a GC may happen while the
|
||||||
** prototype is still being created
|
** prototype is still being created
|
||||||
*/
|
*/
|
||||||
static void ICACHE_FLASH_ATTR traverseproto (global_State *g, Proto *f) {
|
static void traverseproto (global_State *g, Proto *f) {
|
||||||
int i;
|
int i;
|
||||||
if (f->source) stringmark(f->source);
|
if (f->source) stringmark(f->source);
|
||||||
for (i=0; i<f->sizek; i++) /* mark literals */
|
for (i=0; i<f->sizek; i++) /* mark literals */
|
||||||
@ -221,7 +221,7 @@ static void ICACHE_FLASH_ATTR traverseproto (global_State *g, Proto *f) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR traverseclosure (global_State *g, Closure *cl) {
|
static void traverseclosure (global_State *g, Closure *cl) {
|
||||||
markobject(g, cl->c.env);
|
markobject(g, cl->c.env);
|
||||||
if (cl->c.isC) {
|
if (cl->c.isC) {
|
||||||
int i;
|
int i;
|
||||||
@ -240,7 +240,7 @@ static void ICACHE_FLASH_ATTR traverseclosure (global_State *g, Closure *cl) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR checkstacksizes (lua_State *L, StkId max) {
|
static void checkstacksizes (lua_State *L, StkId max) {
|
||||||
int ci_used = cast_int(L->ci - L->base_ci); /* number of `ci' in use */
|
int ci_used = cast_int(L->ci - L->base_ci); /* number of `ci' in use */
|
||||||
int s_used = cast_int(max - L->stack); /* part of stack in use */
|
int s_used = cast_int(max - L->stack); /* part of stack in use */
|
||||||
if (L->size_ci > LUAI_MAXCALLS) /* handling overflow? */
|
if (L->size_ci > LUAI_MAXCALLS) /* handling overflow? */
|
||||||
@ -255,7 +255,7 @@ static void ICACHE_FLASH_ATTR checkstacksizes (lua_State *L, StkId max) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR traversestack (global_State *g, lua_State *l) {
|
static void traversestack (global_State *g, lua_State *l) {
|
||||||
StkId o, lim;
|
StkId o, lim;
|
||||||
CallInfo *ci;
|
CallInfo *ci;
|
||||||
markvalue(g, gt(l));
|
markvalue(g, gt(l));
|
||||||
@ -278,7 +278,7 @@ static void ICACHE_FLASH_ATTR traversestack (global_State *g, lua_State *l) {
|
|||||||
** traverse one gray object, turning it to black.
|
** traverse one gray object, turning it to black.
|
||||||
** Returns `quantity' traversed.
|
** Returns `quantity' traversed.
|
||||||
*/
|
*/
|
||||||
static l_mem ICACHE_FLASH_ATTR propagatemark (global_State *g) {
|
static l_mem propagatemark (global_State *g) {
|
||||||
GCObject *o = g->gray;
|
GCObject *o = g->gray;
|
||||||
lua_assert(isgray(o));
|
lua_assert(isgray(o));
|
||||||
gray2black(o);
|
gray2black(o);
|
||||||
@ -324,7 +324,7 @@ static l_mem ICACHE_FLASH_ATTR propagatemark (global_State *g) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static size_t ICACHE_FLASH_ATTR propagateall (global_State *g) {
|
static size_t propagateall (global_State *g) {
|
||||||
size_t m = 0;
|
size_t m = 0;
|
||||||
while (g->gray) m += propagatemark(g);
|
while (g->gray) m += propagatemark(g);
|
||||||
return m;
|
return m;
|
||||||
@ -338,7 +338,7 @@ static size_t ICACHE_FLASH_ATTR propagateall (global_State *g) {
|
|||||||
** other objects: if really collected, cannot keep them; for userdata
|
** other objects: if really collected, cannot keep them; for userdata
|
||||||
** being finalized, keep them in keys, but not in values
|
** being finalized, keep them in keys, but not in values
|
||||||
*/
|
*/
|
||||||
static int ICACHE_FLASH_ATTR iscleared (const TValue *o, int iskey) {
|
static int iscleared (const TValue *o, int iskey) {
|
||||||
if (!iscollectable(o)) return 0;
|
if (!iscollectable(o)) return 0;
|
||||||
if (ttisstring(o)) {
|
if (ttisstring(o)) {
|
||||||
stringmark(rawtsvalue(o)); /* strings are `values', so are never weak */
|
stringmark(rawtsvalue(o)); /* strings are `values', so are never weak */
|
||||||
@ -352,7 +352,7 @@ static int ICACHE_FLASH_ATTR iscleared (const TValue *o, int iskey) {
|
|||||||
/*
|
/*
|
||||||
** clear collected entries from weaktables
|
** clear collected entries from weaktables
|
||||||
*/
|
*/
|
||||||
static void ICACHE_FLASH_ATTR cleartable (GCObject *l) {
|
static void cleartable (GCObject *l) {
|
||||||
while (l) {
|
while (l) {
|
||||||
Table *h = gco2h(l);
|
Table *h = gco2h(l);
|
||||||
int i = h->sizearray;
|
int i = h->sizearray;
|
||||||
@ -379,7 +379,7 @@ static void ICACHE_FLASH_ATTR cleartable (GCObject *l) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR freeobj (lua_State *L, GCObject *o) {
|
static void freeobj (lua_State *L, GCObject *o) {
|
||||||
switch (o->gch.tt) {
|
switch (o->gch.tt) {
|
||||||
case LUA_TPROTO: luaF_freeproto(L, gco2p(o)); break;
|
case LUA_TPROTO: luaF_freeproto(L, gco2p(o)); break;
|
||||||
case LUA_TFUNCTION: luaF_freeclosure(L, gco2cl(o)); break;
|
case LUA_TFUNCTION: luaF_freeclosure(L, gco2cl(o)); break;
|
||||||
@ -408,7 +408,7 @@ static void ICACHE_FLASH_ATTR freeobj (lua_State *L, GCObject *o) {
|
|||||||
#define sweepwholelist(L,p) sweeplist(L,p,MAX_LUMEM)
|
#define sweepwholelist(L,p) sweeplist(L,p,MAX_LUMEM)
|
||||||
|
|
||||||
|
|
||||||
static GCObject **ICACHE_FLASH_ATTR sweeplist (lua_State *L, GCObject **p, lu_mem count) {
|
static GCObject **sweeplist (lua_State *L, GCObject **p, lu_mem count) {
|
||||||
GCObject *curr;
|
GCObject *curr;
|
||||||
global_State *g = G(L);
|
global_State *g = G(L);
|
||||||
int deadmask = otherwhite(g);
|
int deadmask = otherwhite(g);
|
||||||
@ -430,7 +430,7 @@ static GCObject **ICACHE_FLASH_ATTR sweeplist (lua_State *L, GCObject **p, lu_me
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR checkSizes (lua_State *L) {
|
static void checkSizes (lua_State *L) {
|
||||||
global_State *g = G(L);
|
global_State *g = G(L);
|
||||||
/* check size of string hash */
|
/* check size of string hash */
|
||||||
if (g->strt.nuse < cast(lu_int32, g->strt.size/4) &&
|
if (g->strt.nuse < cast(lu_int32, g->strt.size/4) &&
|
||||||
@ -446,7 +446,7 @@ static void ICACHE_FLASH_ATTR checkSizes (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR GCTM (lua_State *L) {
|
static void GCTM (lua_State *L) {
|
||||||
global_State *g = G(L);
|
global_State *g = G(L);
|
||||||
GCObject *o = g->tmudata->gch.next; /* get first element */
|
GCObject *o = g->tmudata->gch.next; /* get first element */
|
||||||
Udata *udata = rawgco2u(o);
|
Udata *udata = rawgco2u(o);
|
||||||
@ -478,13 +478,13 @@ static void ICACHE_FLASH_ATTR GCTM (lua_State *L) {
|
|||||||
/*
|
/*
|
||||||
** Call all GC tag methods
|
** Call all GC tag methods
|
||||||
*/
|
*/
|
||||||
void ICACHE_FLASH_ATTR luaC_callGCTM (lua_State *L) {
|
void luaC_callGCTM (lua_State *L) {
|
||||||
while (G(L)->tmudata)
|
while (G(L)->tmudata)
|
||||||
GCTM(L);
|
GCTM(L);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR luaC_freeall (lua_State *L) {
|
void luaC_freeall (lua_State *L) {
|
||||||
global_State *g = G(L);
|
global_State *g = G(L);
|
||||||
int i;
|
int i;
|
||||||
g->currentwhite = WHITEBITS | bitmask(SFIXEDBIT); /* mask to collect all elements */
|
g->currentwhite = WHITEBITS | bitmask(SFIXEDBIT); /* mask to collect all elements */
|
||||||
@ -494,7 +494,7 @@ void ICACHE_FLASH_ATTR luaC_freeall (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR markmt (global_State *g) {
|
static void markmt (global_State *g) {
|
||||||
int i;
|
int i;
|
||||||
for (i=0; i<NUM_TAGS; i++)
|
for (i=0; i<NUM_TAGS; i++)
|
||||||
if (g->mt[i] && !luaR_isrotable(g->mt[i])) markobject(g, g->mt[i]);
|
if (g->mt[i] && !luaR_isrotable(g->mt[i])) markobject(g, g->mt[i]);
|
||||||
@ -502,7 +502,7 @@ static void ICACHE_FLASH_ATTR markmt (global_State *g) {
|
|||||||
|
|
||||||
|
|
||||||
/* mark root set */
|
/* mark root set */
|
||||||
static void ICACHE_FLASH_ATTR markroot (lua_State *L) {
|
static void markroot (lua_State *L) {
|
||||||
global_State *g = G(L);
|
global_State *g = G(L);
|
||||||
g->gray = NULL;
|
g->gray = NULL;
|
||||||
g->grayagain = NULL;
|
g->grayagain = NULL;
|
||||||
@ -516,7 +516,7 @@ static void ICACHE_FLASH_ATTR markroot (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR remarkupvals (global_State *g) {
|
static void remarkupvals (global_State *g) {
|
||||||
UpVal *uv;
|
UpVal *uv;
|
||||||
for (uv = g->uvhead.u.l.next; uv != &g->uvhead; uv = uv->u.l.next) {
|
for (uv = g->uvhead.u.l.next; uv != &g->uvhead; uv = uv->u.l.next) {
|
||||||
lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv);
|
lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv);
|
||||||
@ -526,7 +526,7 @@ static void ICACHE_FLASH_ATTR remarkupvals (global_State *g) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR atomic (lua_State *L) {
|
static void atomic (lua_State *L) {
|
||||||
global_State *g = G(L);
|
global_State *g = G(L);
|
||||||
size_t udsize; /* total size of userdata to be finalized */
|
size_t udsize; /* total size of userdata to be finalized */
|
||||||
/* remark occasional upvalues of (maybe) dead threads */
|
/* remark occasional upvalues of (maybe) dead threads */
|
||||||
@ -556,7 +556,7 @@ static void ICACHE_FLASH_ATTR atomic (lua_State *L) {
|
|||||||
g->estimate = g->totalbytes - udsize; /* first estimate */
|
g->estimate = g->totalbytes - udsize; /* first estimate */
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR sweepstrstep (global_State *g, lua_State *L) {
|
static void sweepstrstep (global_State *g, lua_State *L) {
|
||||||
lu_mem old = g->totalbytes;
|
lu_mem old = g->totalbytes;
|
||||||
sweepwholelist(L, &g->strt.hash[g->sweepstrgc++]);
|
sweepwholelist(L, &g->strt.hash[g->sweepstrgc++]);
|
||||||
if (g->sweepstrgc >= g->strt.size) /* nothing more to sweep? */
|
if (g->sweepstrgc >= g->strt.size) /* nothing more to sweep? */
|
||||||
@ -566,7 +566,7 @@ static void ICACHE_FLASH_ATTR sweepstrstep (global_State *g, lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static l_mem ICACHE_FLASH_ATTR singlestep (lua_State *L) {
|
static l_mem singlestep (lua_State *L) {
|
||||||
global_State *g = G(L);
|
global_State *g = G(L);
|
||||||
/*lua_checkmemory(L);*/
|
/*lua_checkmemory(L);*/
|
||||||
switch (g->gcstate) {
|
switch (g->gcstate) {
|
||||||
@ -615,7 +615,7 @@ static l_mem ICACHE_FLASH_ATTR singlestep (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR luaC_step (lua_State *L) {
|
void luaC_step (lua_State *L) {
|
||||||
global_State *g = G(L);
|
global_State *g = G(L);
|
||||||
if(is_block_gc(L)) return;
|
if(is_block_gc(L)) return;
|
||||||
set_block_gc(L);
|
set_block_gc(L);
|
||||||
@ -645,7 +645,7 @@ void ICACHE_FLASH_ATTR luaC_step (lua_State *L) {
|
|||||||
unset_block_gc(L);
|
unset_block_gc(L);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ICACHE_FLASH_ATTR luaC_sweepstrgc (lua_State *L) {
|
int luaC_sweepstrgc (lua_State *L) {
|
||||||
global_State *g = G(L);
|
global_State *g = G(L);
|
||||||
if (g->gcstate == GCSsweepstring) {
|
if (g->gcstate == GCSsweepstring) {
|
||||||
sweepstrstep(g, L);
|
sweepstrstep(g, L);
|
||||||
@ -654,7 +654,7 @@ int ICACHE_FLASH_ATTR luaC_sweepstrgc (lua_State *L) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR luaC_fullgc (lua_State *L) {
|
void luaC_fullgc (lua_State *L) {
|
||||||
global_State *g = G(L);
|
global_State *g = G(L);
|
||||||
if(is_block_gc(L)) return;
|
if(is_block_gc(L)) return;
|
||||||
set_block_gc(L);
|
set_block_gc(L);
|
||||||
@ -683,7 +683,7 @@ void ICACHE_FLASH_ATTR luaC_fullgc (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR luaC_barrierf (lua_State *L, GCObject *o, GCObject *v) {
|
void luaC_barrierf (lua_State *L, GCObject *o, GCObject *v) {
|
||||||
global_State *g = G(L);
|
global_State *g = G(L);
|
||||||
lua_assert(isblack(o) && iswhite(v) && !isdead(g, v) && !isdead(g, o));
|
lua_assert(isblack(o) && iswhite(v) && !isdead(g, v) && !isdead(g, o));
|
||||||
lua_assert(g->gcstate != GCSfinalize && g->gcstate != GCSpause);
|
lua_assert(g->gcstate != GCSfinalize && g->gcstate != GCSpause);
|
||||||
@ -696,7 +696,7 @@ void ICACHE_FLASH_ATTR luaC_barrierf (lua_State *L, GCObject *o, GCObject *v) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR luaC_barrierback (lua_State *L, Table *t) {
|
void luaC_barrierback (lua_State *L, Table *t) {
|
||||||
global_State *g = G(L);
|
global_State *g = G(L);
|
||||||
GCObject *o = obj2gco(t);
|
GCObject *o = obj2gco(t);
|
||||||
lua_assert(isblack(o) && !isdead(g, o));
|
lua_assert(isblack(o) && !isdead(g, o));
|
||||||
@ -707,7 +707,7 @@ void ICACHE_FLASH_ATTR luaC_barrierback (lua_State *L, Table *t) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR luaC_marknew (lua_State *L, GCObject *o) {
|
void luaC_marknew (lua_State *L, GCObject *o) {
|
||||||
global_State *g = G(L);
|
global_State *g = G(L);
|
||||||
o->gch.marked = luaC_white(g);
|
o->gch.marked = luaC_white(g);
|
||||||
if (g->gcstate == GCSpropagate)
|
if (g->gcstate == GCSpropagate)
|
||||||
@ -715,7 +715,7 @@ void ICACHE_FLASH_ATTR luaC_marknew (lua_State *L, GCObject *o) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR luaC_link (lua_State *L, GCObject *o, lu_byte tt) {
|
void luaC_link (lua_State *L, GCObject *o, lu_byte tt) {
|
||||||
global_State *g = G(L);
|
global_State *g = G(L);
|
||||||
o->gch.next = g->rootgc;
|
o->gch.next = g->rootgc;
|
||||||
g->rootgc = o;
|
g->rootgc = o;
|
||||||
@ -724,7 +724,7 @@ void ICACHE_FLASH_ATTR luaC_link (lua_State *L, GCObject *o, lu_byte tt) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR luaC_linkupval (lua_State *L, UpVal *uv) {
|
void luaC_linkupval (lua_State *L, UpVal *uv) {
|
||||||
global_State *g = G(L);
|
global_State *g = G(L);
|
||||||
GCObject *o = obj2gco(uv);
|
GCObject *o = obj2gco(uv);
|
||||||
o->gch.next = g->rootgc; /* link upvalue into `rootgc' list */
|
o->gch.next = g->rootgc; /* link upvalue into `rootgc' list */
|
||||||
|
@ -71,7 +71,7 @@ const luaR_table lua_rotable[] =
|
|||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
LUALIB_API void ICACHE_FLASH_ATTR luaL_openlibs (lua_State *L) {
|
LUALIB_API void luaL_openlibs (lua_State *L) {
|
||||||
const luaL_Reg *lib = lualibs;
|
const luaL_Reg *lib = lualibs;
|
||||||
for (; lib->func; lib++) {
|
for (; lib->func; lib++) {
|
||||||
lua_pushcfunction(L, lib->func);
|
lua_pushcfunction(L, lib->func);
|
||||||
|
@ -38,7 +38,7 @@ static const int liolib_keys[] = {(int)&luaL_callmeta, (int)&luaL_typerror, (int
|
|||||||
|
|
||||||
static const char *const fnames[] = {"input", "output"};
|
static const char *const fnames[] = {"input", "output"};
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR pushresult (lua_State *L, int i, const char *filename) {
|
static int pushresult (lua_State *L, int i, const char *filename) {
|
||||||
int en = fs_error(0); /* calls to Lua API may change this value */
|
int en = fs_error(0); /* calls to Lua API may change this value */
|
||||||
if (i) {
|
if (i) {
|
||||||
lua_pushboolean(L, 1);
|
lua_pushboolean(L, 1);
|
||||||
@ -56,7 +56,7 @@ static int ICACHE_FLASH_ATTR pushresult (lua_State *L, int i, const char *filena
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR fileerror (lua_State *L, int arg, const char *filename) {
|
static void fileerror (lua_State *L, int arg, const char *filename) {
|
||||||
lua_pushfstring(L, "%s: err(%d)", filename, fs_error(0));
|
lua_pushfstring(L, "%s: err(%d)", filename, fs_error(0));
|
||||||
luaL_argerror(L, arg, lua_tostring(L, -1));
|
luaL_argerror(L, arg, lua_tostring(L, -1));
|
||||||
}
|
}
|
||||||
@ -65,7 +65,7 @@ static void ICACHE_FLASH_ATTR fileerror (lua_State *L, int arg, const char *file
|
|||||||
#define tofilep(L) ((int *)luaL_checkudata(L, 1, LUA_FILEHANDLE))
|
#define tofilep(L) ((int *)luaL_checkudata(L, 1, LUA_FILEHANDLE))
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR io_type (lua_State *L) {
|
static int io_type (lua_State *L) {
|
||||||
void *ud;
|
void *ud;
|
||||||
luaL_checkany(L, 1);
|
luaL_checkany(L, 1);
|
||||||
ud = lua_touserdata(L, 1);
|
ud = lua_touserdata(L, 1);
|
||||||
@ -80,7 +80,7 @@ static int ICACHE_FLASH_ATTR io_type (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR tofile (lua_State *L) {
|
static int tofile (lua_State *L) {
|
||||||
int *f = tofilep(L);
|
int *f = tofilep(L);
|
||||||
if (*f < FS_OPEN_OK)
|
if (*f < FS_OPEN_OK)
|
||||||
luaL_error(L, "attempt to use a closed file");
|
luaL_error(L, "attempt to use a closed file");
|
||||||
@ -94,7 +94,7 @@ static int ICACHE_FLASH_ATTR tofile (lua_State *L) {
|
|||||||
** before opening the actual file; so, if there is a memory error, the
|
** before opening the actual file; so, if there is a memory error, the
|
||||||
** file is not left opened.
|
** file is not left opened.
|
||||||
*/
|
*/
|
||||||
static int *ICACHE_FLASH_ATTR newfile (lua_State *L) {
|
static int *newfile (lua_State *L) {
|
||||||
int *pf = (int *)lua_newuserdata(L, sizeof(int));
|
int *pf = (int *)lua_newuserdata(L, sizeof(int));
|
||||||
*pf = FS_OPEN_OK - 1; /* file handle is currently `closed' */
|
*pf = FS_OPEN_OK - 1; /* file handle is currently `closed' */
|
||||||
luaL_getmetatable(L, LUA_FILEHANDLE);
|
luaL_getmetatable(L, LUA_FILEHANDLE);
|
||||||
@ -107,7 +107,7 @@ static int *ICACHE_FLASH_ATTR newfile (lua_State *L) {
|
|||||||
/*
|
/*
|
||||||
** function to (not) close the standard files stdin, stdout, and stderr
|
** function to (not) close the standard files stdin, stdout, and stderr
|
||||||
*/
|
*/
|
||||||
static int ICACHE_FLASH_ATTR io_noclose (lua_State *L) {
|
static int io_noclose (lua_State *L) {
|
||||||
lua_pushnil(L);
|
lua_pushnil(L);
|
||||||
lua_pushliteral(L, "cannot close standard file");
|
lua_pushliteral(L, "cannot close standard file");
|
||||||
return 2;
|
return 2;
|
||||||
@ -117,7 +117,7 @@ static int ICACHE_FLASH_ATTR io_noclose (lua_State *L) {
|
|||||||
/*
|
/*
|
||||||
** function to close 'popen' files
|
** function to close 'popen' files
|
||||||
*/
|
*/
|
||||||
static int ICACHE_FLASH_ATTR io_pclose (lua_State *L) {
|
static int io_pclose (lua_State *L) {
|
||||||
int *p = tofilep(L);
|
int *p = tofilep(L);
|
||||||
int ok = lua_pclose(L, *p);
|
int ok = lua_pclose(L, *p);
|
||||||
*p = FS_OPEN_OK - 1;
|
*p = FS_OPEN_OK - 1;
|
||||||
@ -128,7 +128,7 @@ static int ICACHE_FLASH_ATTR io_pclose (lua_State *L) {
|
|||||||
/*
|
/*
|
||||||
** function to close regular files
|
** function to close regular files
|
||||||
*/
|
*/
|
||||||
static int ICACHE_FLASH_ATTR io_fclose (lua_State *L) {
|
static int io_fclose (lua_State *L) {
|
||||||
int *p = tofilep(L);
|
int *p = tofilep(L);
|
||||||
int ok = (fs_close(*p) == 0);
|
int ok = (fs_close(*p) == 0);
|
||||||
*p = FS_OPEN_OK - 1;
|
*p = FS_OPEN_OK - 1;
|
||||||
@ -136,7 +136,7 @@ static int ICACHE_FLASH_ATTR io_fclose (lua_State *L) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR aux_close (lua_State *L) {
|
static int aux_close (lua_State *L) {
|
||||||
#if LUA_OPTIMIZE_MEMORY != 2
|
#if LUA_OPTIMIZE_MEMORY != 2
|
||||||
lua_getfenv(L, 1);
|
lua_getfenv(L, 1);
|
||||||
lua_getfield(L, -1, "__close");
|
lua_getfield(L, -1, "__close");
|
||||||
@ -156,7 +156,7 @@ static int ICACHE_FLASH_ATTR aux_close (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR io_close (lua_State *L) {
|
static int io_close (lua_State *L) {
|
||||||
if (lua_isnone(L, 1))
|
if (lua_isnone(L, 1))
|
||||||
LUA_IO_GETFIELD(IO_OUTPUT);
|
LUA_IO_GETFIELD(IO_OUTPUT);
|
||||||
tofile(L); /* make sure argument is a file */
|
tofile(L); /* make sure argument is a file */
|
||||||
@ -164,7 +164,7 @@ static int ICACHE_FLASH_ATTR io_close (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR io_gc (lua_State *L) {
|
static int io_gc (lua_State *L) {
|
||||||
int f = *tofilep(L);
|
int f = *tofilep(L);
|
||||||
/* ignore closed files */
|
/* ignore closed files */
|
||||||
if (f != FS_OPEN_OK - 1)
|
if (f != FS_OPEN_OK - 1)
|
||||||
@ -173,7 +173,7 @@ static int ICACHE_FLASH_ATTR io_gc (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR io_tostring (lua_State *L) {
|
static int io_tostring (lua_State *L) {
|
||||||
int f = *tofilep(L);
|
int f = *tofilep(L);
|
||||||
if (f == FS_OPEN_OK - 1)
|
if (f == FS_OPEN_OK - 1)
|
||||||
lua_pushliteral(L, "file (closed)");
|
lua_pushliteral(L, "file (closed)");
|
||||||
@ -183,7 +183,7 @@ static int ICACHE_FLASH_ATTR io_tostring (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR io_open (lua_State *L) {
|
static int io_open (lua_State *L) {
|
||||||
const char *filename = luaL_checkstring(L, 1);
|
const char *filename = luaL_checkstring(L, 1);
|
||||||
const char *mode = luaL_optstring(L, 2, "r");
|
const char *mode = luaL_optstring(L, 2, "r");
|
||||||
int *pf = newfile(L);
|
int *pf = newfile(L);
|
||||||
@ -197,7 +197,7 @@ static int ICACHE_FLASH_ATTR io_open (lua_State *L) {
|
|||||||
** correct __close for 'popen' files
|
** correct __close for 'popen' files
|
||||||
*/
|
*/
|
||||||
#if 0
|
#if 0
|
||||||
static int ICACHE_FLASH_ATTR io_popen (lua_State *L) {
|
static int io_popen (lua_State *L) {
|
||||||
const char *filename = luaL_checkstring(L, 1);
|
const char *filename = luaL_checkstring(L, 1);
|
||||||
const char *mode = luaL_optstring(L, 2, "r");
|
const char *mode = luaL_optstring(L, 2, "r");
|
||||||
int *pf = newfile(L);
|
int *pf = newfile(L);
|
||||||
@ -206,14 +206,14 @@ static int ICACHE_FLASH_ATTR io_popen (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR io_tmpfile (lua_State *L) {
|
static int io_tmpfile (lua_State *L) {
|
||||||
int *pf = newfile(L);
|
int *pf = newfile(L);
|
||||||
*pf = tmpfile();
|
*pf = tmpfile();
|
||||||
return (*pf == FS_OPEN_OK - 1) ? pushresult(L, 0, NULL) : 1;
|
return (*pf == FS_OPEN_OK - 1) ? pushresult(L, 0, NULL) : 1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR getiofile (lua_State *L, int findex) {
|
static int getiofile (lua_State *L, int findex) {
|
||||||
int *pf;
|
int *pf;
|
||||||
LUA_IO_GETFIELD(findex);
|
LUA_IO_GETFIELD(findex);
|
||||||
pf = (int *)lua_touserdata(L, -1);
|
pf = (int *)lua_touserdata(L, -1);
|
||||||
@ -225,7 +225,7 @@ static int ICACHE_FLASH_ATTR getiofile (lua_State *L, int findex) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR g_iofile (lua_State *L, int f, const char *mode) {
|
static int g_iofile (lua_State *L, int f, const char *mode) {
|
||||||
if (!lua_isnoneornil(L, 1)) {
|
if (!lua_isnoneornil(L, 1)) {
|
||||||
const char *filename = lua_tostring(L, 1);
|
const char *filename = lua_tostring(L, 1);
|
||||||
if (filename) {
|
if (filename) {
|
||||||
@ -246,34 +246,34 @@ static int ICACHE_FLASH_ATTR g_iofile (lua_State *L, int f, const char *mode) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR io_input (lua_State *L) {
|
static int io_input (lua_State *L) {
|
||||||
return g_iofile(L, IO_INPUT, "r");
|
return g_iofile(L, IO_INPUT, "r");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR io_output (lua_State *L) {
|
static int io_output (lua_State *L) {
|
||||||
return g_iofile(L, IO_OUTPUT, "w");
|
return g_iofile(L, IO_OUTPUT, "w");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR io_readline (lua_State *L);
|
static int io_readline (lua_State *L);
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR aux_lines (lua_State *L, int idx, int toclose) {
|
static void aux_lines (lua_State *L, int idx, int toclose) {
|
||||||
lua_pushvalue(L, idx);
|
lua_pushvalue(L, idx);
|
||||||
lua_pushboolean(L, toclose); /* close/not close file when finished */
|
lua_pushboolean(L, toclose); /* close/not close file when finished */
|
||||||
lua_pushcclosure(L, io_readline, 2);
|
lua_pushcclosure(L, io_readline, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR f_lines (lua_State *L) {
|
static int f_lines (lua_State *L) {
|
||||||
tofile(L); /* check that it's a valid file handle */
|
tofile(L); /* check that it's a valid file handle */
|
||||||
aux_lines(L, 1, 0);
|
aux_lines(L, 1, 0);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR io_lines (lua_State *L) {
|
static int io_lines (lua_State *L) {
|
||||||
if (lua_isnoneornil(L, 1)) { /* no arguments? */
|
if (lua_isnoneornil(L, 1)) { /* no arguments? */
|
||||||
/* will iterate over default input */
|
/* will iterate over default input */
|
||||||
LUA_IO_GETFIELD(IO_INPUT);
|
LUA_IO_GETFIELD(IO_INPUT);
|
||||||
@ -298,7 +298,7 @@ static int ICACHE_FLASH_ATTR io_lines (lua_State *L) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
static int ICACHE_FLASH_ATTR read_number (lua_State *L, int f) {
|
static int read_number (lua_State *L, int f) {
|
||||||
lua_Number d;
|
lua_Number d;
|
||||||
if (fs_scanf(f, LUA_NUMBER_SCAN, &d) == 1) {
|
if (fs_scanf(f, LUA_NUMBER_SCAN, &d) == 1) {
|
||||||
lua_pushnumber(L, d);
|
lua_pushnumber(L, d);
|
||||||
@ -311,7 +311,7 @@ static int ICACHE_FLASH_ATTR read_number (lua_State *L, int f) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR test_eof (lua_State *L, int f) {
|
static int test_eof (lua_State *L, int f) {
|
||||||
int c = fs_getc(f);
|
int c = fs_getc(f);
|
||||||
fs_ungetc(c, f);
|
fs_ungetc(c, f);
|
||||||
lua_pushlstring(L, NULL, 0);
|
lua_pushlstring(L, NULL, 0);
|
||||||
@ -319,7 +319,7 @@ static int ICACHE_FLASH_ATTR test_eof (lua_State *L, int f) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
static int ICACHE_FLASH_ATTR read_line (lua_State *L, int f) {
|
static int read_line (lua_State *L, int f) {
|
||||||
luaL_Buffer b;
|
luaL_Buffer b;
|
||||||
luaL_buffinit(L, &b);
|
luaL_buffinit(L, &b);
|
||||||
for (;;) {
|
for (;;) {
|
||||||
@ -340,7 +340,7 @@ static int ICACHE_FLASH_ATTR read_line (lua_State *L, int f) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
static int ICACHE_FLASH_ATTR read_line (lua_State *L, int f) {
|
static int read_line (lua_State *L, int f) {
|
||||||
luaL_Buffer b;
|
luaL_Buffer b;
|
||||||
luaL_buffinit(L, &b);
|
luaL_buffinit(L, &b);
|
||||||
char *p = luaL_prepbuffer(&b);
|
char *p = luaL_prepbuffer(&b);
|
||||||
@ -368,7 +368,7 @@ static int ICACHE_FLASH_ATTR read_line (lua_State *L, int f) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR read_chars (lua_State *L, int f, size_t n) {
|
static int read_chars (lua_State *L, int f, size_t n) {
|
||||||
size_t rlen; /* how much to read */
|
size_t rlen; /* how much to read */
|
||||||
size_t nr; /* number of chars actually read */
|
size_t nr; /* number of chars actually read */
|
||||||
luaL_Buffer b;
|
luaL_Buffer b;
|
||||||
@ -386,7 +386,7 @@ static int ICACHE_FLASH_ATTR read_chars (lua_State *L, int f, size_t n) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR g_read (lua_State *L, int f, int first) {
|
static int g_read (lua_State *L, int f, int first) {
|
||||||
int nargs = lua_gettop(L) - 1;
|
int nargs = lua_gettop(L) - 1;
|
||||||
int success;
|
int success;
|
||||||
int n;
|
int n;
|
||||||
@ -435,17 +435,17 @@ static int ICACHE_FLASH_ATTR g_read (lua_State *L, int f, int first) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR io_read (lua_State *L) {
|
static int io_read (lua_State *L) {
|
||||||
return g_read(L, getiofile(L, IO_INPUT), 1);
|
return g_read(L, getiofile(L, IO_INPUT), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR f_read (lua_State *L) {
|
static int f_read (lua_State *L) {
|
||||||
return g_read(L, tofile(L), 2);
|
return g_read(L, tofile(L), 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR io_readline (lua_State *L) {
|
static int io_readline (lua_State *L) {
|
||||||
int *pf = (int *)lua_touserdata(L, lua_upvalueindex(1));
|
int *pf = (int *)lua_touserdata(L, lua_upvalueindex(1));
|
||||||
int sucess;
|
int sucess;
|
||||||
if (pf == NULL || *pf == FS_OPEN_OK - 1){ /* file is already closed? */
|
if (pf == NULL || *pf == FS_OPEN_OK - 1){ /* file is already closed? */
|
||||||
@ -469,7 +469,7 @@ static int ICACHE_FLASH_ATTR io_readline (lua_State *L) {
|
|||||||
/* }====================================================== */
|
/* }====================================================== */
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR g_write (lua_State *L, int f, int arg) {
|
static int g_write (lua_State *L, int f, int arg) {
|
||||||
int nargs = lua_gettop(L) - 1;
|
int nargs = lua_gettop(L) - 1;
|
||||||
int status = 1;
|
int status = 1;
|
||||||
for (; nargs--; arg++) {
|
for (; nargs--; arg++) {
|
||||||
@ -491,17 +491,17 @@ static int ICACHE_FLASH_ATTR g_write (lua_State *L, int f, int arg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR io_write (lua_State *L) {
|
static int io_write (lua_State *L) {
|
||||||
return g_write(L, getiofile(L, IO_OUTPUT), 1);
|
return g_write(L, getiofile(L, IO_OUTPUT), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR f_write (lua_State *L) {
|
static int f_write (lua_State *L) {
|
||||||
return g_write(L, tofile(L), 2);
|
return g_write(L, tofile(L), 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR f_seek (lua_State *L) {
|
static int f_seek (lua_State *L) {
|
||||||
static const int mode[] = {FS_SEEK_SET, FS_SEEK_CUR, FS_SEEK_END};
|
static const int mode[] = {FS_SEEK_SET, FS_SEEK_CUR, FS_SEEK_END};
|
||||||
static const char *const modenames[] = {"set", "cur", "end", NULL};
|
static const char *const modenames[] = {"set", "cur", "end", NULL};
|
||||||
int f = tofile(L);
|
int f = tofile(L);
|
||||||
@ -517,7 +517,7 @@ static int ICACHE_FLASH_ATTR f_seek (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
static int ICACHE_FLASH_ATTR f_setvbuf (lua_State *L) {
|
static int f_setvbuf (lua_State *L) {
|
||||||
static const int mode[] = {_IONBF, _IOFBF, _IOLBF};
|
static const int mode[] = {_IONBF, _IOFBF, _IOLBF};
|
||||||
static const char *const modenames[] = {"no", "full", "line", NULL};
|
static const char *const modenames[] = {"no", "full", "line", NULL};
|
||||||
int f = tofile(L);
|
int f = tofile(L);
|
||||||
@ -529,12 +529,12 @@ static int ICACHE_FLASH_ATTR f_setvbuf (lua_State *L) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR io_flush (lua_State *L) {
|
static int io_flush (lua_State *L) {
|
||||||
return pushresult(L, fs_flush(getiofile(L, IO_OUTPUT)) == 0, NULL);
|
return pushresult(L, fs_flush(getiofile(L, IO_OUTPUT)) == 0, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR f_flush (lua_State *L) {
|
static int f_flush (lua_State *L) {
|
||||||
return pushresult(L, fs_flush(tofile(L)) == 0, NULL);
|
return pushresult(L, fs_flush(tofile(L)) == 0, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -560,7 +560,7 @@ const LUA_REG_TYPE iolib[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#if LUA_OPTIMIZE_MEMORY == 2
|
#if LUA_OPTIMIZE_MEMORY == 2
|
||||||
static int ICACHE_FLASH_ATTR luaL_index(lua_State *L)
|
static int luaL_index(lua_State *L)
|
||||||
{
|
{
|
||||||
return luaR_findfunction(L, iolib_funcs);
|
return luaR_findfunction(L, iolib_funcs);
|
||||||
}
|
}
|
||||||
@ -590,7 +590,7 @@ const LUA_REG_TYPE flib[] = {
|
|||||||
{LNILKEY, LNILVAL}
|
{LNILKEY, LNILVAL}
|
||||||
};
|
};
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR createmeta (lua_State *L) {
|
static void createmeta (lua_State *L) {
|
||||||
#if LUA_OPTIMIZE_MEMORY == 0
|
#if LUA_OPTIMIZE_MEMORY == 0
|
||||||
luaL_newmetatable(L, LUA_FILEHANDLE); /* create metatable for file handles */
|
luaL_newmetatable(L, LUA_FILEHANDLE); /* create metatable for file handles */
|
||||||
lua_pushvalue(L, -1); /* push metatable */
|
lua_pushvalue(L, -1); /* push metatable */
|
||||||
@ -602,7 +602,7 @@ static void ICACHE_FLASH_ATTR createmeta (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR createstdfile (lua_State *L, int f, int k, const char *fname) {
|
static void createstdfile (lua_State *L, int f, int k, const char *fname) {
|
||||||
*newfile(L) = f;
|
*newfile(L) = f;
|
||||||
#if LUA_OPTIMIZE_MEMORY != 2
|
#if LUA_OPTIMIZE_MEMORY != 2
|
||||||
if (k > 0) {
|
if (k > 0) {
|
||||||
@ -620,14 +620,14 @@ static void ICACHE_FLASH_ATTR createstdfile (lua_State *L, int f, int k, const c
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if LUA_OPTIMIZE_MEMORY != 2
|
#if LUA_OPTIMIZE_MEMORY != 2
|
||||||
static void ICACHE_FLASH_ATTR newfenv (lua_State *L, lua_CFunction cls) {
|
static void newfenv (lua_State *L, lua_CFunction cls) {
|
||||||
lua_createtable(L, 0, 1);
|
lua_createtable(L, 0, 1);
|
||||||
lua_pushcfunction(L, cls);
|
lua_pushcfunction(L, cls);
|
||||||
lua_setfield(L, -2, "__close");
|
lua_setfield(L, -2, "__close");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
LUALIB_API int ICACHE_FLASH_ATTR luaopen_io (lua_State *L) {
|
LUALIB_API int luaopen_io (lua_State *L) {
|
||||||
createmeta(L);
|
createmeta(L);
|
||||||
#if LUA_OPTIMIZE_MEMORY != 2
|
#if LUA_OPTIMIZE_MEMORY != 2
|
||||||
/* create (private) environment (with fields IO_INPUT, IO_OUTPUT, __close) */
|
/* create (private) environment (with fields IO_INPUT, IO_OUTPUT, __close) */
|
||||||
|
@ -48,7 +48,7 @@ const char *const luaX_tokens [] = {
|
|||||||
#define save_and_next(ls) (save(ls, ls->current), next(ls))
|
#define save_and_next(ls) (save(ls, ls->current), next(ls))
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR save (LexState *ls, int c) {
|
static void save (LexState *ls, int c) {
|
||||||
Mbuffer *b = ls->buff;
|
Mbuffer *b = ls->buff;
|
||||||
if (b->n + 1 > b->buffsize) {
|
if (b->n + 1 > b->buffsize) {
|
||||||
size_t newsize;
|
size_t newsize;
|
||||||
@ -61,14 +61,14 @@ static void ICACHE_FLASH_ATTR save (LexState *ls, int c) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR luaX_init (lua_State *L) {
|
void luaX_init (lua_State *L) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#define MAXSRC 80
|
#define MAXSRC 80
|
||||||
|
|
||||||
|
|
||||||
const char *ICACHE_FLASH_ATTR luaX_token2str (LexState *ls, int token) {
|
const char *luaX_token2str (LexState *ls, int token) {
|
||||||
if (token < FIRST_RESERVED) {
|
if (token < FIRST_RESERVED) {
|
||||||
lua_assert(token == cast(unsigned char, token));
|
lua_assert(token == cast(unsigned char, token));
|
||||||
return (iscntrl(token)) ? luaO_pushfstring(ls->L, "char(%d)", token) :
|
return (iscntrl(token)) ? luaO_pushfstring(ls->L, "char(%d)", token) :
|
||||||
@ -79,7 +79,7 @@ const char *ICACHE_FLASH_ATTR luaX_token2str (LexState *ls, int token) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static const char *ICACHE_FLASH_ATTR txtToken (LexState *ls, int token) {
|
static const char *txtToken (LexState *ls, int token) {
|
||||||
switch (token) {
|
switch (token) {
|
||||||
case TK_NAME:
|
case TK_NAME:
|
||||||
case TK_STRING:
|
case TK_STRING:
|
||||||
@ -92,7 +92,7 @@ static const char *ICACHE_FLASH_ATTR txtToken (LexState *ls, int token) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR luaX_lexerror (LexState *ls, const char *msg, int token) {
|
void luaX_lexerror (LexState *ls, const char *msg, int token) {
|
||||||
char buff[MAXSRC];
|
char buff[MAXSRC];
|
||||||
luaO_chunkid(buff, getstr(ls->source), MAXSRC);
|
luaO_chunkid(buff, getstr(ls->source), MAXSRC);
|
||||||
msg = luaO_pushfstring(ls->L, "%s:%d: %s", buff, ls->linenumber, msg);
|
msg = luaO_pushfstring(ls->L, "%s:%d: %s", buff, ls->linenumber, msg);
|
||||||
@ -102,12 +102,12 @@ void ICACHE_FLASH_ATTR luaX_lexerror (LexState *ls, const char *msg, int token)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR luaX_syntaxerror (LexState *ls, const char *msg) {
|
void luaX_syntaxerror (LexState *ls, const char *msg) {
|
||||||
luaX_lexerror(ls, msg, ls->t.token);
|
luaX_lexerror(ls, msg, ls->t.token);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TString *ICACHE_FLASH_ATTR luaX_newstring (LexState *ls, const char *str, size_t l) {
|
TString *luaX_newstring (LexState *ls, const char *str, size_t l) {
|
||||||
lua_State *L = ls->L;
|
lua_State *L = ls->L;
|
||||||
TString *ts = luaS_newlstr(L, str, l);
|
TString *ts = luaS_newlstr(L, str, l);
|
||||||
TValue *o = luaH_setstr(L, ls->fs->h, ts); /* entry for `str' */
|
TValue *o = luaH_setstr(L, ls->fs->h, ts); /* entry for `str' */
|
||||||
@ -119,7 +119,7 @@ TString *ICACHE_FLASH_ATTR luaX_newstring (LexState *ls, const char *str, size_t
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR inclinenumber (LexState *ls) {
|
static void inclinenumber (LexState *ls) {
|
||||||
int old = ls->current;
|
int old = ls->current;
|
||||||
lua_assert(currIsNewline(ls));
|
lua_assert(currIsNewline(ls));
|
||||||
next(ls); /* skip `\n' or `\r' */
|
next(ls); /* skip `\n' or `\r' */
|
||||||
@ -130,7 +130,7 @@ static void ICACHE_FLASH_ATTR inclinenumber (LexState *ls) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR luaX_setinput (lua_State *L, LexState *ls, ZIO *z, TString *source) {
|
void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, TString *source) {
|
||||||
ls->decpoint = '.';
|
ls->decpoint = '.';
|
||||||
ls->L = L;
|
ls->L = L;
|
||||||
ls->lookahead.token = TK_EOS; /* no look-ahead token */
|
ls->lookahead.token = TK_EOS; /* no look-ahead token */
|
||||||
@ -153,7 +153,7 @@ void ICACHE_FLASH_ATTR luaX_setinput (lua_State *L, LexState *ls, ZIO *z, TStrin
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR check_next (LexState *ls, const char *set) {
|
static int check_next (LexState *ls, const char *set) {
|
||||||
if (!c_strchr(set, ls->current))
|
if (!c_strchr(set, ls->current))
|
||||||
return 0;
|
return 0;
|
||||||
save_and_next(ls);
|
save_and_next(ls);
|
||||||
@ -161,7 +161,7 @@ static int ICACHE_FLASH_ATTR check_next (LexState *ls, const char *set) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR buffreplace (LexState *ls, char from, char to) {
|
static void buffreplace (LexState *ls, char from, char to) {
|
||||||
size_t n = luaZ_bufflen(ls->buff);
|
size_t n = luaZ_bufflen(ls->buff);
|
||||||
char *p = luaZ_buffer(ls->buff);
|
char *p = luaZ_buffer(ls->buff);
|
||||||
while (n--)
|
while (n--)
|
||||||
@ -169,7 +169,7 @@ static void ICACHE_FLASH_ATTR buffreplace (LexState *ls, char from, char to) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR trydecpoint (LexState *ls, SemInfo *seminfo) {
|
static void trydecpoint (LexState *ls, SemInfo *seminfo) {
|
||||||
/* format error: try to update decimal point separator */
|
/* format error: try to update decimal point separator */
|
||||||
struct lconv *cv = localeconv();
|
struct lconv *cv = localeconv();
|
||||||
char old = ls->decpoint;
|
char old = ls->decpoint;
|
||||||
@ -184,7 +184,7 @@ static void ICACHE_FLASH_ATTR trydecpoint (LexState *ls, SemInfo *seminfo) {
|
|||||||
|
|
||||||
|
|
||||||
/* LUA_NUMBER */
|
/* LUA_NUMBER */
|
||||||
static void ICACHE_FLASH_ATTR read_numeral (LexState *ls, SemInfo *seminfo) {
|
static void read_numeral (LexState *ls, SemInfo *seminfo) {
|
||||||
lua_assert(isdigit(ls->current));
|
lua_assert(isdigit(ls->current));
|
||||||
do {
|
do {
|
||||||
save_and_next(ls);
|
save_and_next(ls);
|
||||||
@ -200,7 +200,7 @@ static void ICACHE_FLASH_ATTR read_numeral (LexState *ls, SemInfo *seminfo) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR skip_sep (LexState *ls) {
|
static int skip_sep (LexState *ls) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
int s = ls->current;
|
int s = ls->current;
|
||||||
lua_assert(s == '[' || s == ']');
|
lua_assert(s == '[' || s == ']');
|
||||||
@ -213,7 +213,7 @@ static int ICACHE_FLASH_ATTR skip_sep (LexState *ls) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR read_long_string (LexState *ls, SemInfo *seminfo, int sep) {
|
static void read_long_string (LexState *ls, SemInfo *seminfo, int sep) {
|
||||||
int cont = 0;
|
int cont = 0;
|
||||||
(void)(cont); /* avoid warnings when `cont' is not used */
|
(void)(cont); /* avoid warnings when `cont' is not used */
|
||||||
save_and_next(ls); /* skip 2nd `[' */
|
save_and_next(ls); /* skip 2nd `[' */
|
||||||
@ -268,7 +268,7 @@ static void ICACHE_FLASH_ATTR read_long_string (LexState *ls, SemInfo *seminfo,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR read_string (LexState *ls, int del, SemInfo *seminfo) {
|
static void read_string (LexState *ls, int del, SemInfo *seminfo) {
|
||||||
save_and_next(ls);
|
save_and_next(ls);
|
||||||
while (ls->current != del) {
|
while (ls->current != del) {
|
||||||
switch (ls->current) {
|
switch (ls->current) {
|
||||||
@ -324,7 +324,7 @@ static void ICACHE_FLASH_ATTR read_string (LexState *ls, int del, SemInfo *semin
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR llex (LexState *ls, SemInfo *seminfo) {
|
static int llex (LexState *ls, SemInfo *seminfo) {
|
||||||
luaZ_resetbuffer(ls->buff);
|
luaZ_resetbuffer(ls->buff);
|
||||||
for (;;) {
|
for (;;) {
|
||||||
switch (ls->current) {
|
switch (ls->current) {
|
||||||
@ -440,7 +440,7 @@ static int ICACHE_FLASH_ATTR llex (LexState *ls, SemInfo *seminfo) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR luaX_next (LexState *ls) {
|
void luaX_next (LexState *ls) {
|
||||||
ls->lastline = ls->linenumber;
|
ls->lastline = ls->linenumber;
|
||||||
if (ls->lookahead.token != TK_EOS) { /* is there a look-ahead token? */
|
if (ls->lookahead.token != TK_EOS) { /* is there a look-ahead token? */
|
||||||
ls->t = ls->lookahead; /* use this one */
|
ls->t = ls->lookahead; /* use this one */
|
||||||
@ -451,7 +451,7 @@ void ICACHE_FLASH_ATTR luaX_next (LexState *ls) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR luaX_lookahead (LexState *ls) {
|
void luaX_lookahead (LexState *ls) {
|
||||||
lua_assert(ls->lookahead.token == TK_EOS);
|
lua_assert(ls->lookahead.token == TK_EOS);
|
||||||
ls->lookahead.token = llex(ls, &ls->lookahead.seminfo);
|
ls->lookahead.token = llex(ls, &ls->lookahead.seminfo);
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR math_abs (lua_State *L) {
|
static int math_abs (lua_State *L) {
|
||||||
#ifdef LUA_NUMBER_INTEGRAL
|
#ifdef LUA_NUMBER_INTEGRAL
|
||||||
lua_Number x = luaL_checknumber(L, 1);
|
lua_Number x = luaL_checknumber(L, 1);
|
||||||
if (x < 0) x = -x; //fails for -2^31
|
if (x < 0) x = -x; //fails for -2^31
|
||||||
@ -36,72 +36,72 @@ static int ICACHE_FLASH_ATTR math_abs (lua_State *L) {
|
|||||||
|
|
||||||
#ifndef LUA_NUMBER_INTEGRAL
|
#ifndef LUA_NUMBER_INTEGRAL
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR math_sin (lua_State *L) {
|
static int math_sin (lua_State *L) {
|
||||||
lua_pushnumber(L, sin(luaL_checknumber(L, 1)));
|
lua_pushnumber(L, sin(luaL_checknumber(L, 1)));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR math_sinh (lua_State *L) {
|
static int math_sinh (lua_State *L) {
|
||||||
lua_pushnumber(L, sinh(luaL_checknumber(L, 1)));
|
lua_pushnumber(L, sinh(luaL_checknumber(L, 1)));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR math_cos (lua_State *L) {
|
static int math_cos (lua_State *L) {
|
||||||
lua_pushnumber(L, cos(luaL_checknumber(L, 1)));
|
lua_pushnumber(L, cos(luaL_checknumber(L, 1)));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR math_cosh (lua_State *L) {
|
static int math_cosh (lua_State *L) {
|
||||||
lua_pushnumber(L, cosh(luaL_checknumber(L, 1)));
|
lua_pushnumber(L, cosh(luaL_checknumber(L, 1)));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR math_tan (lua_State *L) {
|
static int math_tan (lua_State *L) {
|
||||||
lua_pushnumber(L, tan(luaL_checknumber(L, 1)));
|
lua_pushnumber(L, tan(luaL_checknumber(L, 1)));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR math_tanh (lua_State *L) {
|
static int math_tanh (lua_State *L) {
|
||||||
lua_pushnumber(L, tanh(luaL_checknumber(L, 1)));
|
lua_pushnumber(L, tanh(luaL_checknumber(L, 1)));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR math_asin (lua_State *L) {
|
static int math_asin (lua_State *L) {
|
||||||
lua_pushnumber(L, asin(luaL_checknumber(L, 1)));
|
lua_pushnumber(L, asin(luaL_checknumber(L, 1)));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR math_acos (lua_State *L) {
|
static int math_acos (lua_State *L) {
|
||||||
lua_pushnumber(L, acos(luaL_checknumber(L, 1)));
|
lua_pushnumber(L, acos(luaL_checknumber(L, 1)));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR math_atan (lua_State *L) {
|
static int math_atan (lua_State *L) {
|
||||||
lua_pushnumber(L, atan(luaL_checknumber(L, 1)));
|
lua_pushnumber(L, atan(luaL_checknumber(L, 1)));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR math_atan2 (lua_State *L) {
|
static int math_atan2 (lua_State *L) {
|
||||||
lua_pushnumber(L, atan2(luaL_checknumber(L, 1), luaL_checknumber(L, 2)));
|
lua_pushnumber(L, atan2(luaL_checknumber(L, 1), luaL_checknumber(L, 2)));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR math_ceil (lua_State *L) {
|
static int math_ceil (lua_State *L) {
|
||||||
lua_pushnumber(L, ceil(luaL_checknumber(L, 1)));
|
lua_pushnumber(L, ceil(luaL_checknumber(L, 1)));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR math_floor (lua_State *L) {
|
static int math_floor (lua_State *L) {
|
||||||
lua_pushnumber(L, floor(luaL_checknumber(L, 1)));
|
lua_pushnumber(L, floor(luaL_checknumber(L, 1)));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR math_fmod (lua_State *L) {
|
static int math_fmod (lua_State *L) {
|
||||||
lua_pushnumber(L, fmod(luaL_checknumber(L, 1), luaL_checknumber(L, 2)));
|
lua_pushnumber(L, fmod(luaL_checknumber(L, 1), luaL_checknumber(L, 2)));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR math_modf (lua_State *L) {
|
static int math_modf (lua_State *L) {
|
||||||
double ip;
|
double ip;
|
||||||
double fp = modf(luaL_checknumber(L, 1), &ip);
|
double fp = modf(luaL_checknumber(L, 1), &ip);
|
||||||
lua_pushnumber(L, ip);
|
lua_pushnumber(L, ip);
|
||||||
@ -116,7 +116,7 @@ static int ICACHE_FLASH_ATTR math_modf (lua_State *L) {
|
|||||||
// works in both integer and floating point versions of Lua.
|
// works in both integer and floating point versions of Lua.
|
||||||
// This identity function is used for them.
|
// This identity function is used for them.
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR math_identity (lua_State *L) {
|
static int math_identity (lua_State *L) {
|
||||||
lua_pushnumber(L, luaL_checknumber(L, 1));
|
lua_pushnumber(L, luaL_checknumber(L, 1));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -125,7 +125,7 @@ static int ICACHE_FLASH_ATTR math_identity (lua_State *L) {
|
|||||||
|
|
||||||
#ifdef LUA_NUMBER_INTEGRAL
|
#ifdef LUA_NUMBER_INTEGRAL
|
||||||
// Integer square root for integer version
|
// Integer square root for integer version
|
||||||
static lua_Number ICACHE_FLASH_ATTR isqrt(lua_Number x)
|
static lua_Number isqrt(lua_Number x)
|
||||||
{
|
{
|
||||||
lua_Number op, res, one;
|
lua_Number op, res, one;
|
||||||
|
|
||||||
@ -147,7 +147,7 @@ static lua_Number ICACHE_FLASH_ATTR isqrt(lua_Number x)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR math_sqrt (lua_State *L) {
|
static int math_sqrt (lua_State *L) {
|
||||||
#ifdef LUA_NUMBER_INTEGRAL
|
#ifdef LUA_NUMBER_INTEGRAL
|
||||||
lua_Number x = luaL_checknumber(L, 1);
|
lua_Number x = luaL_checknumber(L, 1);
|
||||||
luaL_argcheck(L, 0<=x, 1, "negative");
|
luaL_argcheck(L, 0<=x, 1, "negative");
|
||||||
@ -162,7 +162,7 @@ static int ICACHE_FLASH_ATTR math_sqrt (lua_State *L) {
|
|||||||
# define pow(a,b) luai_ipow(a,b)
|
# define pow(a,b) luai_ipow(a,b)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR math_pow (lua_State *L) {
|
static int math_pow (lua_State *L) {
|
||||||
lua_pushnumber(L, pow(luaL_checknumber(L, 1), luaL_checknumber(L, 2)));
|
lua_pushnumber(L, pow(luaL_checknumber(L, 1), luaL_checknumber(L, 2)));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -174,46 +174,46 @@ static int ICACHE_FLASH_ATTR math_pow (lua_State *L) {
|
|||||||
|
|
||||||
#ifndef LUA_NUMBER_INTEGRAL
|
#ifndef LUA_NUMBER_INTEGRAL
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR math_log (lua_State *L) {
|
static int math_log (lua_State *L) {
|
||||||
lua_pushnumber(L, log(luaL_checknumber(L, 1)));
|
lua_pushnumber(L, log(luaL_checknumber(L, 1)));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR math_log10 (lua_State *L) {
|
static int math_log10 (lua_State *L) {
|
||||||
lua_pushnumber(L, log10(luaL_checknumber(L, 1)));
|
lua_pushnumber(L, log10(luaL_checknumber(L, 1)));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR math_exp (lua_State *L) {
|
static int math_exp (lua_State *L) {
|
||||||
lua_pushnumber(L, exp(luaL_checknumber(L, 1)));
|
lua_pushnumber(L, exp(luaL_checknumber(L, 1)));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR math_deg (lua_State *L) {
|
static int math_deg (lua_State *L) {
|
||||||
lua_pushnumber(L, luaL_checknumber(L, 1)/RADIANS_PER_DEGREE);
|
lua_pushnumber(L, luaL_checknumber(L, 1)/RADIANS_PER_DEGREE);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR math_rad (lua_State *L) {
|
static int math_rad (lua_State *L) {
|
||||||
lua_pushnumber(L, luaL_checknumber(L, 1)*RADIANS_PER_DEGREE);
|
lua_pushnumber(L, luaL_checknumber(L, 1)*RADIANS_PER_DEGREE);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR math_frexp (lua_State *L) {
|
static int math_frexp (lua_State *L) {
|
||||||
int e;
|
int e;
|
||||||
lua_pushnumber(L, frexp(luaL_checknumber(L, 1), &e));
|
lua_pushnumber(L, frexp(luaL_checknumber(L, 1), &e));
|
||||||
lua_pushinteger(L, e);
|
lua_pushinteger(L, e);
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR math_ldexp (lua_State *L) {
|
static int math_ldexp (lua_State *L) {
|
||||||
lua_pushnumber(L, ldexp(luaL_checknumber(L, 1), luaL_checkint(L, 2)));
|
lua_pushnumber(L, ldexp(luaL_checknumber(L, 1), luaL_checkint(L, 2)));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // #ifdef LUA_NUMBER_INTEGRAL
|
#endif // #ifdef LUA_NUMBER_INTEGRAL
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR math_min (lua_State *L) {
|
static int math_min (lua_State *L) {
|
||||||
int n = lua_gettop(L); /* number of arguments */
|
int n = lua_gettop(L); /* number of arguments */
|
||||||
lua_Number dmin = luaL_checknumber(L, 1);
|
lua_Number dmin = luaL_checknumber(L, 1);
|
||||||
int i;
|
int i;
|
||||||
@ -227,7 +227,7 @@ static int ICACHE_FLASH_ATTR math_min (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR math_max (lua_State *L) {
|
static int math_max (lua_State *L) {
|
||||||
int n = lua_gettop(L); /* number of arguments */
|
int n = lua_gettop(L); /* number of arguments */
|
||||||
lua_Number dmax = luaL_checknumber(L, 1);
|
lua_Number dmax = luaL_checknumber(L, 1);
|
||||||
int i;
|
int i;
|
||||||
@ -243,7 +243,7 @@ static int ICACHE_FLASH_ATTR math_max (lua_State *L) {
|
|||||||
|
|
||||||
#ifdef LUA_NUMBER_INTEGRAL
|
#ifdef LUA_NUMBER_INTEGRAL
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR math_random (lua_State *L) {
|
static int math_random (lua_State *L) {
|
||||||
lua_Number r = (lua_Number)(rand()%RAND_MAX);
|
lua_Number r = (lua_Number)(rand()%RAND_MAX);
|
||||||
|
|
||||||
switch (lua_gettop(L)) { /* check number of arguments */
|
switch (lua_gettop(L)) { /* check number of arguments */
|
||||||
@ -271,7 +271,7 @@ static int ICACHE_FLASH_ATTR math_random (lua_State *L) {
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR math_random (lua_State *L) {
|
static int math_random (lua_State *L) {
|
||||||
/* the `%' avoids the (rare) case of r==1, and is needed also because on
|
/* the `%' avoids the (rare) case of r==1, and is needed also because on
|
||||||
some systems (SunOS!) `rand()' may return a value larger than RAND_MAX */
|
some systems (SunOS!) `rand()' may return a value larger than RAND_MAX */
|
||||||
lua_Number r = (lua_Number)(rand()%RAND_MAX) / (lua_Number)RAND_MAX;
|
lua_Number r = (lua_Number)(rand()%RAND_MAX) / (lua_Number)RAND_MAX;
|
||||||
@ -301,7 +301,7 @@ static int ICACHE_FLASH_ATTR math_random (lua_State *L) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR math_randomseed (lua_State *L) {
|
static int math_randomseed (lua_State *L) {
|
||||||
srand(luaL_checkint(L, 1));
|
srand(luaL_checkint(L, 1));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -371,7 +371,7 @@ const LUA_REG_TYPE math_map[] = {
|
|||||||
# include "c_limits.h" /* for LONG_MAX */
|
# include "c_limits.h" /* for LONG_MAX */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
LUALIB_API int ICACHE_FLASH_ATTR luaopen_math (lua_State *L) {
|
LUALIB_API int luaopen_math (lua_State *L) {
|
||||||
#if LUA_OPTIMIZE_MEMORY > 0
|
#if LUA_OPTIMIZE_MEMORY > 0
|
||||||
return 0;
|
return 0;
|
||||||
#else
|
#else
|
||||||
|
@ -43,7 +43,7 @@
|
|||||||
#define MINSIZEARRAY 4
|
#define MINSIZEARRAY 4
|
||||||
|
|
||||||
|
|
||||||
void *ICACHE_FLASH_ATTR luaM_growaux_ (lua_State *L, void *block, int *size, size_t size_elems,
|
void *luaM_growaux_ (lua_State *L, void *block, int *size, size_t size_elems,
|
||||||
int limit, const char *errormsg) {
|
int limit, const char *errormsg) {
|
||||||
void *newblock;
|
void *newblock;
|
||||||
int newsize;
|
int newsize;
|
||||||
@ -63,7 +63,7 @@ void *ICACHE_FLASH_ATTR luaM_growaux_ (lua_State *L, void *block, int *size, siz
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void *ICACHE_FLASH_ATTR luaM_toobig (lua_State *L) {
|
void *luaM_toobig (lua_State *L) {
|
||||||
luaG_runerror(L, "memory allocation error: block too big");
|
luaG_runerror(L, "memory allocation error: block too big");
|
||||||
return NULL; /* to avoid warnings */
|
return NULL; /* to avoid warnings */
|
||||||
}
|
}
|
||||||
@ -73,7 +73,7 @@ void *ICACHE_FLASH_ATTR luaM_toobig (lua_State *L) {
|
|||||||
/*
|
/*
|
||||||
** generic allocation routine.
|
** generic allocation routine.
|
||||||
*/
|
*/
|
||||||
void *ICACHE_FLASH_ATTR luaM_realloc_ (lua_State *L, void *block, size_t osize, size_t nsize) {
|
void *luaM_realloc_ (lua_State *L, void *block, size_t osize, size_t nsize) {
|
||||||
global_State *g = G(L);
|
global_State *g = G(L);
|
||||||
lua_assert((osize == 0) == (block == NULL));
|
lua_assert((osize == 0) == (block == NULL));
|
||||||
block = (*g->frealloc)(g->ud, block, osize, nsize);
|
block = (*g->frealloc)(g->ud, block, osize, nsize);
|
||||||
|
@ -237,19 +237,19 @@ static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) {
|
|||||||
#define DLMSG "dynamic libraries not enabled; check your Lua installation"
|
#define DLMSG "dynamic libraries not enabled; check your Lua installation"
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR ll_unloadlib (void *lib) {
|
static void ll_unloadlib (void *lib) {
|
||||||
(void)lib; /* to avoid warnings */
|
(void)lib; /* to avoid warnings */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void * ICACHE_FLASH_ATTR ll_load (lua_State *L, const char *path) {
|
static void * ll_load (lua_State *L, const char *path) {
|
||||||
(void)path; /* to avoid warnings */
|
(void)path; /* to avoid warnings */
|
||||||
lua_pushliteral(L, DLMSG);
|
lua_pushliteral(L, DLMSG);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static lua_CFunction ICACHE_FLASH_ATTR ll_sym (lua_State *L, void *lib, const char *sym) {
|
static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) {
|
||||||
(void)lib; (void)sym; /* to avoid warnings */
|
(void)lib; (void)sym; /* to avoid warnings */
|
||||||
lua_pushliteral(L, DLMSG);
|
lua_pushliteral(L, DLMSG);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -260,7 +260,7 @@ static lua_CFunction ICACHE_FLASH_ATTR ll_sym (lua_State *L, void *lib, const ch
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void ** ICACHE_FLASH_ATTR ll_register (lua_State *L, const char *path) {
|
static void ** ll_register (lua_State *L, const char *path) {
|
||||||
void **plib;
|
void **plib;
|
||||||
lua_pushfstring(L, "%s%s", LIBPREFIX, path);
|
lua_pushfstring(L, "%s%s", LIBPREFIX, path);
|
||||||
lua_gettable(L, LUA_REGISTRYINDEX); /* check library in registry? */
|
lua_gettable(L, LUA_REGISTRYINDEX); /* check library in registry? */
|
||||||
@ -284,7 +284,7 @@ static void ** ICACHE_FLASH_ATTR ll_register (lua_State *L, const char *path) {
|
|||||||
** __gc tag method: calls library's `ll_unloadlib' function with the lib
|
** __gc tag method: calls library's `ll_unloadlib' function with the lib
|
||||||
** handle
|
** handle
|
||||||
*/
|
*/
|
||||||
static int ICACHE_FLASH_ATTR gctm (lua_State *L) {
|
static int gctm (lua_State *L) {
|
||||||
void **lib = (void **)luaL_checkudata(L, 1, "_LOADLIB");
|
void **lib = (void **)luaL_checkudata(L, 1, "_LOADLIB");
|
||||||
if (*lib) ll_unloadlib(*lib);
|
if (*lib) ll_unloadlib(*lib);
|
||||||
*lib = NULL; /* mark library as closed */
|
*lib = NULL; /* mark library as closed */
|
||||||
@ -292,7 +292,7 @@ static int ICACHE_FLASH_ATTR gctm (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR ll_loadfunc (lua_State *L, const char *path, const char *sym) {
|
static int ll_loadfunc (lua_State *L, const char *path, const char *sym) {
|
||||||
void **reg = ll_register(L, path);
|
void **reg = ll_register(L, path);
|
||||||
if (*reg == NULL) *reg = ll_load(L, path);
|
if (*reg == NULL) *reg = ll_load(L, path);
|
||||||
if (*reg == NULL)
|
if (*reg == NULL)
|
||||||
@ -307,7 +307,7 @@ static int ICACHE_FLASH_ATTR ll_loadfunc (lua_State *L, const char *path, const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR ll_loadlib (lua_State *L) {
|
static int ll_loadlib (lua_State *L) {
|
||||||
const char *path = luaL_checkstring(L, 1);
|
const char *path = luaL_checkstring(L, 1);
|
||||||
const char *init = luaL_checkstring(L, 2);
|
const char *init = luaL_checkstring(L, 2);
|
||||||
int stat = ll_loadfunc(L, path, init);
|
int stat = ll_loadfunc(L, path, init);
|
||||||
@ -336,7 +336,7 @@ static int readable (const char *filename) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
static int ICACHE_FLASH_ATTR readable (const char *filename) {
|
static int readable (const char *filename) {
|
||||||
int f = fs_open(filename, FS_RDONLY); /* try to open file */
|
int f = fs_open(filename, FS_RDONLY); /* try to open file */
|
||||||
if (f < FS_OPEN_OK) return 0; /* open failed */
|
if (f < FS_OPEN_OK) return 0; /* open failed */
|
||||||
fs_close(f);
|
fs_close(f);
|
||||||
@ -344,7 +344,7 @@ static int ICACHE_FLASH_ATTR readable (const char *filename) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const char * ICACHE_FLASH_ATTR pushnexttemplate (lua_State *L, const char *path) {
|
static const char * pushnexttemplate (lua_State *L, const char *path) {
|
||||||
const char *l;
|
const char *l;
|
||||||
while (*path == *LUA_PATHSEP) path++; /* skip separators */
|
while (*path == *LUA_PATHSEP) path++; /* skip separators */
|
||||||
if (*path == '\0') return NULL; /* no more templates */
|
if (*path == '\0') return NULL; /* no more templates */
|
||||||
@ -355,7 +355,7 @@ static const char * ICACHE_FLASH_ATTR pushnexttemplate (lua_State *L, const char
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static const char * ICACHE_FLASH_ATTR findfile (lua_State *L, const char *name,
|
static const char * findfile (lua_State *L, const char *name,
|
||||||
const char *pname) {
|
const char *pname) {
|
||||||
const char *path;
|
const char *path;
|
||||||
name = luaL_gsub(L, name, ".", LUA_DIRSEP);
|
name = luaL_gsub(L, name, ".", LUA_DIRSEP);
|
||||||
@ -378,13 +378,13 @@ static const char * ICACHE_FLASH_ATTR findfile (lua_State *L, const char *name,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR loaderror (lua_State *L, const char *filename) {
|
static void loaderror (lua_State *L, const char *filename) {
|
||||||
luaL_error(L, "error loading module " LUA_QS " from file " LUA_QS ":\n\t%s",
|
luaL_error(L, "error loading module " LUA_QS " from file " LUA_QS ":\n\t%s",
|
||||||
lua_tostring(L, 1), filename, lua_tostring(L, -1));
|
lua_tostring(L, 1), filename, lua_tostring(L, -1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR loader_Lua (lua_State *L) {
|
static int loader_Lua (lua_State *L) {
|
||||||
const char *filename;
|
const char *filename;
|
||||||
const char *name = luaL_checkstring(L, 1);
|
const char *name = luaL_checkstring(L, 1);
|
||||||
filename = findfile(L, name, "path");
|
filename = findfile(L, name, "path");
|
||||||
@ -410,7 +410,7 @@ static const char *mkfuncname (lua_State *L, const char *modname) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR loader_C (lua_State *L) {
|
static int loader_C (lua_State *L) {
|
||||||
const char *funcname;
|
const char *funcname;
|
||||||
const char *name = luaL_checkstring(L, 1);
|
const char *name = luaL_checkstring(L, 1);
|
||||||
const char *filename = findfile(L, name, "cpath");
|
const char *filename = findfile(L, name, "cpath");
|
||||||
@ -422,7 +422,7 @@ static int ICACHE_FLASH_ATTR loader_C (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR loader_Croot (lua_State *L) {
|
static int loader_Croot (lua_State *L) {
|
||||||
const char *funcname;
|
const char *funcname;
|
||||||
const char *filename;
|
const char *filename;
|
||||||
const char *name = luaL_checkstring(L, 1);
|
const char *name = luaL_checkstring(L, 1);
|
||||||
@ -443,7 +443,7 @@ static int ICACHE_FLASH_ATTR loader_Croot (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR loader_preload (lua_State *L) {
|
static int loader_preload (lua_State *L) {
|
||||||
const char *name = luaL_checkstring(L, 1);
|
const char *name = luaL_checkstring(L, 1);
|
||||||
lua_getfield(L, LUA_ENVIRONINDEX, "preload");
|
lua_getfield(L, LUA_ENVIRONINDEX, "preload");
|
||||||
if (!lua_istable(L, -1))
|
if (!lua_istable(L, -1))
|
||||||
@ -459,7 +459,7 @@ static const int sentinel_ = 0;
|
|||||||
#define sentinel ((void *)&sentinel_)
|
#define sentinel ((void *)&sentinel_)
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR ll_require (lua_State *L) {
|
static int ll_require (lua_State *L) {
|
||||||
const char *name = luaL_checkstring(L, 1);
|
const char *name = luaL_checkstring(L, 1);
|
||||||
int i;
|
int i;
|
||||||
lua_settop(L, 1); /* _LOADED table will be at index 2 */
|
lua_settop(L, 1); /* _LOADED table will be at index 2 */
|
||||||
@ -521,7 +521,7 @@ static int ICACHE_FLASH_ATTR ll_require (lua_State *L) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR setfenv (lua_State *L) {
|
static void setfenv (lua_State *L) {
|
||||||
lua_Debug ar;
|
lua_Debug ar;
|
||||||
if (lua_getstack(L, 1, &ar) == 0 ||
|
if (lua_getstack(L, 1, &ar) == 0 ||
|
||||||
lua_getinfo(L, "f", &ar) == 0 || /* get calling function */
|
lua_getinfo(L, "f", &ar) == 0 || /* get calling function */
|
||||||
@ -533,7 +533,7 @@ static void ICACHE_FLASH_ATTR setfenv (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR dooptions (lua_State *L, int n) {
|
static void dooptions (lua_State *L, int n) {
|
||||||
int i;
|
int i;
|
||||||
for (i = 2; i <= n; i++) {
|
for (i = 2; i <= n; i++) {
|
||||||
lua_pushvalue(L, i); /* get option (a function) */
|
lua_pushvalue(L, i); /* get option (a function) */
|
||||||
@ -543,7 +543,7 @@ static void ICACHE_FLASH_ATTR dooptions (lua_State *L, int n) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR modinit (lua_State *L, const char *modname) {
|
static void modinit (lua_State *L, const char *modname) {
|
||||||
const char *dot;
|
const char *dot;
|
||||||
lua_pushvalue(L, -1);
|
lua_pushvalue(L, -1);
|
||||||
lua_setfield(L, -2, "_M"); /* module._M = module */
|
lua_setfield(L, -2, "_M"); /* module._M = module */
|
||||||
@ -558,7 +558,7 @@ static void ICACHE_FLASH_ATTR modinit (lua_State *L, const char *modname) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR ll_module (lua_State *L) {
|
static int ll_module (lua_State *L) {
|
||||||
const char *modname = luaL_checkstring(L, 1);
|
const char *modname = luaL_checkstring(L, 1);
|
||||||
if (luaR_findglobal(modname, c_strlen(modname)))
|
if (luaR_findglobal(modname, c_strlen(modname)))
|
||||||
return 0;
|
return 0;
|
||||||
@ -608,7 +608,7 @@ static int ll_seeall (lua_State *L) {
|
|||||||
/* auxiliary mark (for internal use) */
|
/* auxiliary mark (for internal use) */
|
||||||
#define AUXMARK "\1"
|
#define AUXMARK "\1"
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR setpath (lua_State *L, const char *fieldname, const char *envname,
|
static void setpath (lua_State *L, const char *fieldname, const char *envname,
|
||||||
const char *def) {
|
const char *def) {
|
||||||
const char *path = c_getenv(envname);
|
const char *path = c_getenv(envname);
|
||||||
if (path == NULL) /* no environment variable? */
|
if (path == NULL) /* no environment variable? */
|
||||||
@ -643,13 +643,15 @@ static const lua_CFunction loaders[] =
|
|||||||
{loader_preload, loader_Lua, loader_C, loader_Croot, NULL};
|
{loader_preload, loader_Lua, loader_C, loader_Croot, NULL};
|
||||||
|
|
||||||
#if LUA_OPTIMIZE_MEMORY > 0
|
#if LUA_OPTIMIZE_MEMORY > 0
|
||||||
const luaR_entry lmt[] = {
|
#define MIN_OPT_LEVEL 1
|
||||||
|
#include "lrodefs.h"
|
||||||
|
const LUA_REG_TYPE lmt[] = {
|
||||||
{LRO_STRKEY("__gc"), LRO_FUNCVAL(gctm)},
|
{LRO_STRKEY("__gc"), LRO_FUNCVAL(gctm)},
|
||||||
{LRO_NILKEY, LRO_NILVAL}
|
{LRO_NILKEY, LRO_NILVAL}
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
LUALIB_API int ICACHE_FLASH_ATTR luaopen_package (lua_State *L) {
|
LUALIB_API int luaopen_package (lua_State *L) {
|
||||||
int i;
|
int i;
|
||||||
/* create new type _LOADLIB */
|
/* create new type _LOADLIB */
|
||||||
#if LUA_OPTIMIZE_MEMORY == 0
|
#if LUA_OPTIMIZE_MEMORY == 0
|
||||||
|
@ -32,7 +32,7 @@ const TValue luaO_nilobject_ = {LUA_TVALUE_NIL};
|
|||||||
** (eeeeexxx), where the real value is (1xxx) * 2^(eeeee - 1) if
|
** (eeeeexxx), where the real value is (1xxx) * 2^(eeeee - 1) if
|
||||||
** eeeee != 0 and (xxx) otherwise.
|
** eeeee != 0 and (xxx) otherwise.
|
||||||
*/
|
*/
|
||||||
int ICACHE_FLASH_ATTR luaO_int2fb (unsigned int x) {
|
int luaO_int2fb (unsigned int x) {
|
||||||
int e = 0; /* expoent */
|
int e = 0; /* expoent */
|
||||||
while (x >= 16) {
|
while (x >= 16) {
|
||||||
x = (x+1) >> 1;
|
x = (x+1) >> 1;
|
||||||
@ -44,14 +44,14 @@ int ICACHE_FLASH_ATTR luaO_int2fb (unsigned int x) {
|
|||||||
|
|
||||||
|
|
||||||
/* converts back */
|
/* converts back */
|
||||||
int ICACHE_FLASH_ATTR luaO_fb2int (int x) {
|
int luaO_fb2int (int x) {
|
||||||
int e = (x >> 3) & 31;
|
int e = (x >> 3) & 31;
|
||||||
if (e == 0) return x;
|
if (e == 0) return x;
|
||||||
else return ((x & 7)+8) << (e - 1);
|
else return ((x & 7)+8) << (e - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int ICACHE_FLASH_ATTR luaO_log2 (unsigned int x) {
|
int luaO_log2 (unsigned int x) {
|
||||||
static const lu_byte log_2[256] = {
|
static const lu_byte log_2[256] = {
|
||||||
0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
|
0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
|
||||||
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
|
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
|
||||||
@ -69,7 +69,7 @@ int ICACHE_FLASH_ATTR luaO_log2 (unsigned int x) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int ICACHE_FLASH_ATTR luaO_rawequalObj (const TValue *t1, const TValue *t2) {
|
int luaO_rawequalObj (const TValue *t1, const TValue *t2) {
|
||||||
if (ttype(t1) != ttype(t2)) return 0;
|
if (ttype(t1) != ttype(t2)) return 0;
|
||||||
else switch (ttype(t1)) {
|
else switch (ttype(t1)) {
|
||||||
case LUA_TNIL:
|
case LUA_TNIL:
|
||||||
@ -89,7 +89,7 @@ int ICACHE_FLASH_ATTR luaO_rawequalObj (const TValue *t1, const TValue *t2) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int ICACHE_FLASH_ATTR luaO_str2d (const char *s, lua_Number *result) {
|
int luaO_str2d (const char *s, lua_Number *result) {
|
||||||
char *endptr;
|
char *endptr;
|
||||||
*result = lua_str2number(s, &endptr);
|
*result = lua_str2number(s, &endptr);
|
||||||
if (endptr == s) return 0; /* conversion failed */
|
if (endptr == s) return 0; /* conversion failed */
|
||||||
@ -103,14 +103,14 @@ int ICACHE_FLASH_ATTR luaO_str2d (const char *s, lua_Number *result) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR pushstr (lua_State *L, const char *str) {
|
static void pushstr (lua_State *L, const char *str) {
|
||||||
setsvalue2s(L, L->top, luaS_new(L, str));
|
setsvalue2s(L, L->top, luaS_new(L, str));
|
||||||
incr_top(L);
|
incr_top(L);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* this function handles only `%d', `%c', %f, %p, and `%s' formats */
|
/* this function handles only `%d', `%c', %f, %p, and `%s' formats */
|
||||||
const char *ICACHE_FLASH_ATTR luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) {
|
const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) {
|
||||||
int n = 1;
|
int n = 1;
|
||||||
pushstr(L, "");
|
pushstr(L, "");
|
||||||
for (;;) {
|
for (;;) {
|
||||||
@ -171,7 +171,7 @@ const char *ICACHE_FLASH_ATTR luaO_pushvfstring (lua_State *L, const char *fmt,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char *ICACHE_FLASH_ATTR luaO_pushfstring (lua_State *L, const char *fmt, ...) {
|
const char *luaO_pushfstring (lua_State *L, const char *fmt, ...) {
|
||||||
const char *msg;
|
const char *msg;
|
||||||
va_list argp;
|
va_list argp;
|
||||||
va_start(argp, fmt);
|
va_start(argp, fmt);
|
||||||
@ -181,7 +181,7 @@ const char *ICACHE_FLASH_ATTR luaO_pushfstring (lua_State *L, const char *fmt, .
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR luaO_chunkid (char *out, const char *source, size_t bufflen) {
|
void luaO_chunkid (char *out, const char *source, size_t bufflen) {
|
||||||
if (*source == '=') {
|
if (*source == '=') {
|
||||||
c_strncpy(out, source+1, bufflen); /* remove first char */
|
c_strncpy(out, source+1, bufflen); /* remove first char */
|
||||||
out[bufflen-1] = '\0'; /* ensures null termination */
|
out[bufflen-1] = '\0'; /* ensures null termination */
|
||||||
|
@ -54,7 +54,7 @@ static void chunk (LexState *ls);
|
|||||||
static void expr (LexState *ls, expdesc *v);
|
static void expr (LexState *ls, expdesc *v);
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR anchor_token (LexState *ls) {
|
static void anchor_token (LexState *ls) {
|
||||||
if (ls->t.token == TK_NAME || ls->t.token == TK_STRING) {
|
if (ls->t.token == TK_NAME || ls->t.token == TK_STRING) {
|
||||||
TString *ts = ls->t.seminfo.ts;
|
TString *ts = ls->t.seminfo.ts;
|
||||||
luaX_newstring(ls, getstr(ts), ts->tsv.len);
|
luaX_newstring(ls, getstr(ts), ts->tsv.len);
|
||||||
@ -62,13 +62,13 @@ static void ICACHE_FLASH_ATTR anchor_token (LexState *ls) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR error_expected (LexState *ls, int token) {
|
static void error_expected (LexState *ls, int token) {
|
||||||
luaX_syntaxerror(ls,
|
luaX_syntaxerror(ls,
|
||||||
luaO_pushfstring(ls->L, LUA_QS " expected", luaX_token2str(ls, token)));
|
luaO_pushfstring(ls->L, LUA_QS " expected", luaX_token2str(ls, token)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR errorlimit (FuncState *fs, int limit, const char *what) {
|
static void errorlimit (FuncState *fs, int limit, const char *what) {
|
||||||
const char *msg = (fs->f->linedefined == 0) ?
|
const char *msg = (fs->f->linedefined == 0) ?
|
||||||
luaO_pushfstring(fs->L, "main function has more than %d %s", limit, what) :
|
luaO_pushfstring(fs->L, "main function has more than %d %s", limit, what) :
|
||||||
luaO_pushfstring(fs->L, "function at line %d has more than %d %s",
|
luaO_pushfstring(fs->L, "function at line %d has more than %d %s",
|
||||||
@ -77,7 +77,7 @@ static void ICACHE_FLASH_ATTR errorlimit (FuncState *fs, int limit, const char *
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR testnext (LexState *ls, int c) {
|
static int testnext (LexState *ls, int c) {
|
||||||
if (ls->t.token == c) {
|
if (ls->t.token == c) {
|
||||||
luaX_next(ls);
|
luaX_next(ls);
|
||||||
return 1;
|
return 1;
|
||||||
@ -86,12 +86,12 @@ static int ICACHE_FLASH_ATTR testnext (LexState *ls, int c) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR check (LexState *ls, int c) {
|
static void check (LexState *ls, int c) {
|
||||||
if (ls->t.token != c)
|
if (ls->t.token != c)
|
||||||
error_expected(ls, c);
|
error_expected(ls, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR checknext (LexState *ls, int c) {
|
static void checknext (LexState *ls, int c) {
|
||||||
check(ls, c);
|
check(ls, c);
|
||||||
luaX_next(ls);
|
luaX_next(ls);
|
||||||
}
|
}
|
||||||
@ -101,7 +101,7 @@ static void ICACHE_FLASH_ATTR checknext (LexState *ls, int c) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR check_match (LexState *ls, int what, int who, int where) {
|
static void check_match (LexState *ls, int what, int who, int where) {
|
||||||
if (!testnext(ls, what)) {
|
if (!testnext(ls, what)) {
|
||||||
if (where == ls->linenumber)
|
if (where == ls->linenumber)
|
||||||
error_expected(ls, what);
|
error_expected(ls, what);
|
||||||
@ -114,7 +114,7 @@ static void ICACHE_FLASH_ATTR check_match (LexState *ls, int what, int who, int
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static TString *ICACHE_FLASH_ATTR str_checkname (LexState *ls) {
|
static TString *str_checkname (LexState *ls) {
|
||||||
TString *ts;
|
TString *ts;
|
||||||
check(ls, TK_NAME);
|
check(ls, TK_NAME);
|
||||||
ts = ls->t.seminfo.ts;
|
ts = ls->t.seminfo.ts;
|
||||||
@ -123,24 +123,24 @@ static TString *ICACHE_FLASH_ATTR str_checkname (LexState *ls) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR init_exp (expdesc *e, expkind k, int i) {
|
static void init_exp (expdesc *e, expkind k, int i) {
|
||||||
e->f = e->t = NO_JUMP;
|
e->f = e->t = NO_JUMP;
|
||||||
e->k = k;
|
e->k = k;
|
||||||
e->u.s.info = i;
|
e->u.s.info = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR codestring (LexState *ls, expdesc *e, TString *s) {
|
static void codestring (LexState *ls, expdesc *e, TString *s) {
|
||||||
init_exp(e, VK, luaK_stringK(ls->fs, s));
|
init_exp(e, VK, luaK_stringK(ls->fs, s));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR checkname(LexState *ls, expdesc *e) {
|
static void checkname(LexState *ls, expdesc *e) {
|
||||||
codestring(ls, e, str_checkname(ls));
|
codestring(ls, e, str_checkname(ls));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR registerlocalvar (LexState *ls, TString *varname) {
|
static int registerlocalvar (LexState *ls, TString *varname) {
|
||||||
FuncState *fs = ls->fs;
|
FuncState *fs = ls->fs;
|
||||||
Proto *f = fs->f;
|
Proto *f = fs->f;
|
||||||
int oldsize = f->sizelocvars;
|
int oldsize = f->sizelocvars;
|
||||||
@ -157,14 +157,14 @@ static int ICACHE_FLASH_ATTR registerlocalvar (LexState *ls, TString *varname) {
|
|||||||
new_localvar(ls, luaX_newstring(ls, "" v, (sizeof(v)/sizeof(char))-1), n)
|
new_localvar(ls, luaX_newstring(ls, "" v, (sizeof(v)/sizeof(char))-1), n)
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR new_localvar (LexState *ls, TString *name, int n) {
|
static void new_localvar (LexState *ls, TString *name, int n) {
|
||||||
FuncState *fs = ls->fs;
|
FuncState *fs = ls->fs;
|
||||||
luaY_checklimit(fs, fs->nactvar+n+1, LUAI_MAXVARS, "local variables");
|
luaY_checklimit(fs, fs->nactvar+n+1, LUAI_MAXVARS, "local variables");
|
||||||
fs->actvar[fs->nactvar+n] = cast(unsigned short, registerlocalvar(ls, name));
|
fs->actvar[fs->nactvar+n] = cast(unsigned short, registerlocalvar(ls, name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR adjustlocalvars (LexState *ls, int nvars) {
|
static void adjustlocalvars (LexState *ls, int nvars) {
|
||||||
FuncState *fs = ls->fs;
|
FuncState *fs = ls->fs;
|
||||||
fs->nactvar = cast_byte(fs->nactvar + nvars);
|
fs->nactvar = cast_byte(fs->nactvar + nvars);
|
||||||
for (; nvars; nvars--) {
|
for (; nvars; nvars--) {
|
||||||
@ -173,14 +173,14 @@ static void ICACHE_FLASH_ATTR adjustlocalvars (LexState *ls, int nvars) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR removevars (LexState *ls, int tolevel) {
|
static void removevars (LexState *ls, int tolevel) {
|
||||||
FuncState *fs = ls->fs;
|
FuncState *fs = ls->fs;
|
||||||
while (fs->nactvar > tolevel)
|
while (fs->nactvar > tolevel)
|
||||||
getlocvar(fs, --fs->nactvar).endpc = fs->pc;
|
getlocvar(fs, --fs->nactvar).endpc = fs->pc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR indexupvalue (FuncState *fs, TString *name, expdesc *v) {
|
static int indexupvalue (FuncState *fs, TString *name, expdesc *v) {
|
||||||
int i;
|
int i;
|
||||||
Proto *f = fs->f;
|
Proto *f = fs->f;
|
||||||
int oldsize = f->sizeupvalues;
|
int oldsize = f->sizeupvalues;
|
||||||
@ -204,7 +204,7 @@ static int ICACHE_FLASH_ATTR indexupvalue (FuncState *fs, TString *name, expdesc
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR searchvar (FuncState *fs, TString *n) {
|
static int searchvar (FuncState *fs, TString *n) {
|
||||||
int i;
|
int i;
|
||||||
for (i=fs->nactvar-1; i >= 0; i--) {
|
for (i=fs->nactvar-1; i >= 0; i--) {
|
||||||
if (n == getlocvar(fs, i).varname)
|
if (n == getlocvar(fs, i).varname)
|
||||||
@ -214,14 +214,14 @@ static int ICACHE_FLASH_ATTR searchvar (FuncState *fs, TString *n) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR markupval (FuncState *fs, int level) {
|
static void markupval (FuncState *fs, int level) {
|
||||||
BlockCnt *bl = fs->bl;
|
BlockCnt *bl = fs->bl;
|
||||||
while (bl && bl->nactvar > level) bl = bl->previous;
|
while (bl && bl->nactvar > level) bl = bl->previous;
|
||||||
if (bl) bl->upval = 1;
|
if (bl) bl->upval = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR singlevaraux (FuncState *fs, TString *n, expdesc *var, int base) {
|
static int singlevaraux (FuncState *fs, TString *n, expdesc *var, int base) {
|
||||||
if (fs == NULL) { /* no more levels? */
|
if (fs == NULL) { /* no more levels? */
|
||||||
init_exp(var, VGLOBAL, NO_REG); /* default is global variable */
|
init_exp(var, VGLOBAL, NO_REG); /* default is global variable */
|
||||||
return VGLOBAL;
|
return VGLOBAL;
|
||||||
@ -245,7 +245,7 @@ static int ICACHE_FLASH_ATTR singlevaraux (FuncState *fs, TString *n, expdesc *v
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR singlevar (LexState *ls, expdesc *var) {
|
static void singlevar (LexState *ls, expdesc *var) {
|
||||||
TString *varname = str_checkname(ls);
|
TString *varname = str_checkname(ls);
|
||||||
FuncState *fs = ls->fs;
|
FuncState *fs = ls->fs;
|
||||||
if (singlevaraux(fs, varname, var, 1) == VGLOBAL)
|
if (singlevaraux(fs, varname, var, 1) == VGLOBAL)
|
||||||
@ -253,7 +253,7 @@ static void ICACHE_FLASH_ATTR singlevar (LexState *ls, expdesc *var) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR adjust_assign (LexState *ls, int nvars, int nexps, expdesc *e) {
|
static void adjust_assign (LexState *ls, int nvars, int nexps, expdesc *e) {
|
||||||
FuncState *fs = ls->fs;
|
FuncState *fs = ls->fs;
|
||||||
int extra = nvars - nexps;
|
int extra = nvars - nexps;
|
||||||
if (hasmultret(e->k)) {
|
if (hasmultret(e->k)) {
|
||||||
@ -273,7 +273,7 @@ static void ICACHE_FLASH_ATTR adjust_assign (LexState *ls, int nvars, int nexps,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR enterlevel (LexState *ls) {
|
static void enterlevel (LexState *ls) {
|
||||||
if (++ls->L->nCcalls > LUAI_MAXCCALLS)
|
if (++ls->L->nCcalls > LUAI_MAXCCALLS)
|
||||||
luaX_lexerror(ls, "chunk has too many syntax levels", 0);
|
luaX_lexerror(ls, "chunk has too many syntax levels", 0);
|
||||||
}
|
}
|
||||||
@ -282,7 +282,7 @@ static void ICACHE_FLASH_ATTR enterlevel (LexState *ls) {
|
|||||||
#define leavelevel(ls) ((ls)->L->nCcalls--)
|
#define leavelevel(ls) ((ls)->L->nCcalls--)
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR enterblock (FuncState *fs, BlockCnt *bl, lu_byte isbreakable) {
|
static void enterblock (FuncState *fs, BlockCnt *bl, lu_byte isbreakable) {
|
||||||
bl->breaklist = NO_JUMP;
|
bl->breaklist = NO_JUMP;
|
||||||
bl->isbreakable = isbreakable;
|
bl->isbreakable = isbreakable;
|
||||||
bl->nactvar = fs->nactvar;
|
bl->nactvar = fs->nactvar;
|
||||||
@ -293,7 +293,7 @@ static void ICACHE_FLASH_ATTR enterblock (FuncState *fs, BlockCnt *bl, lu_byte i
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR leaveblock (FuncState *fs) {
|
static void leaveblock (FuncState *fs) {
|
||||||
BlockCnt *bl = fs->bl;
|
BlockCnt *bl = fs->bl;
|
||||||
fs->bl = bl->previous;
|
fs->bl = bl->previous;
|
||||||
removevars(fs->ls, bl->nactvar);
|
removevars(fs->ls, bl->nactvar);
|
||||||
@ -307,7 +307,7 @@ static void ICACHE_FLASH_ATTR leaveblock (FuncState *fs) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR pushclosure (LexState *ls, FuncState *func, expdesc *v) {
|
static void pushclosure (LexState *ls, FuncState *func, expdesc *v) {
|
||||||
FuncState *fs = ls->fs;
|
FuncState *fs = ls->fs;
|
||||||
Proto *f = fs->f;
|
Proto *f = fs->f;
|
||||||
int oldsize = f->sizep;
|
int oldsize = f->sizep;
|
||||||
@ -325,7 +325,7 @@ static void ICACHE_FLASH_ATTR pushclosure (LexState *ls, FuncState *func, expdes
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR open_func (LexState *ls, FuncState *fs) {
|
static void open_func (LexState *ls, FuncState *fs) {
|
||||||
lua_State *L = ls->L;
|
lua_State *L = ls->L;
|
||||||
Proto *f = luaF_newproto(L);
|
Proto *f = luaF_newproto(L);
|
||||||
fs->f = f;
|
fs->f = f;
|
||||||
@ -353,7 +353,7 @@ static void ICACHE_FLASH_ATTR open_func (LexState *ls, FuncState *fs) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR close_func (LexState *ls) {
|
static void close_func (LexState *ls) {
|
||||||
lua_State *L = ls->L;
|
lua_State *L = ls->L;
|
||||||
FuncState *fs = ls->fs;
|
FuncState *fs = ls->fs;
|
||||||
Proto *f = fs->f;
|
Proto *f = fs->f;
|
||||||
@ -380,7 +380,7 @@ static void ICACHE_FLASH_ATTR close_func (LexState *ls) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Proto *ICACHE_FLASH_ATTR luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, const char *name) {
|
Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, const char *name) {
|
||||||
struct LexState lexstate;
|
struct LexState lexstate;
|
||||||
struct FuncState funcstate;
|
struct FuncState funcstate;
|
||||||
TString *tname = luaS_new(L, name);
|
TString *tname = luaS_new(L, name);
|
||||||
@ -408,7 +408,7 @@ Proto *ICACHE_FLASH_ATTR luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, const
|
|||||||
/*============================================================*/
|
/*============================================================*/
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR field (LexState *ls, expdesc *v) {
|
static void field (LexState *ls, expdesc *v) {
|
||||||
/* field -> ['.' | ':'] NAME */
|
/* field -> ['.' | ':'] NAME */
|
||||||
FuncState *fs = ls->fs;
|
FuncState *fs = ls->fs;
|
||||||
expdesc key;
|
expdesc key;
|
||||||
@ -419,7 +419,7 @@ static void ICACHE_FLASH_ATTR field (LexState *ls, expdesc *v) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR yindex (LexState *ls, expdesc *v) {
|
static void yindex (LexState *ls, expdesc *v) {
|
||||||
/* index -> '[' expr ']' */
|
/* index -> '[' expr ']' */
|
||||||
luaX_next(ls); /* skip the '[' */
|
luaX_next(ls); /* skip the '[' */
|
||||||
expr(ls, v);
|
expr(ls, v);
|
||||||
@ -444,7 +444,7 @@ struct ConsControl {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR recfield (LexState *ls, struct ConsControl *cc) {
|
static void recfield (LexState *ls, struct ConsControl *cc) {
|
||||||
/* recfield -> (NAME | `['exp1`]') = exp1 */
|
/* recfield -> (NAME | `['exp1`]') = exp1 */
|
||||||
FuncState *fs = ls->fs;
|
FuncState *fs = ls->fs;
|
||||||
int reg = ls->fs->freereg;
|
int reg = ls->fs->freereg;
|
||||||
@ -465,7 +465,7 @@ static void ICACHE_FLASH_ATTR recfield (LexState *ls, struct ConsControl *cc) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR closelistfield (FuncState *fs, struct ConsControl *cc) {
|
static void closelistfield (FuncState *fs, struct ConsControl *cc) {
|
||||||
if (cc->v.k == VVOID) return; /* there is no list item */
|
if (cc->v.k == VVOID) return; /* there is no list item */
|
||||||
luaK_exp2nextreg(fs, &cc->v);
|
luaK_exp2nextreg(fs, &cc->v);
|
||||||
cc->v.k = VVOID;
|
cc->v.k = VVOID;
|
||||||
@ -476,7 +476,7 @@ static void ICACHE_FLASH_ATTR closelistfield (FuncState *fs, struct ConsControl
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR lastlistfield (FuncState *fs, struct ConsControl *cc) {
|
static void lastlistfield (FuncState *fs, struct ConsControl *cc) {
|
||||||
if (cc->tostore == 0) return;
|
if (cc->tostore == 0) return;
|
||||||
if (hasmultret(cc->v.k)) {
|
if (hasmultret(cc->v.k)) {
|
||||||
luaK_setmultret(fs, &cc->v);
|
luaK_setmultret(fs, &cc->v);
|
||||||
@ -491,7 +491,7 @@ static void ICACHE_FLASH_ATTR lastlistfield (FuncState *fs, struct ConsControl *
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR listfield (LexState *ls, struct ConsControl *cc) {
|
static void listfield (LexState *ls, struct ConsControl *cc) {
|
||||||
expr(ls, &cc->v);
|
expr(ls, &cc->v);
|
||||||
luaY_checklimit(ls->fs, cc->na, MAX_INT, "items in a constructor");
|
luaY_checklimit(ls->fs, cc->na, MAX_INT, "items in a constructor");
|
||||||
cc->na++;
|
cc->na++;
|
||||||
@ -499,7 +499,7 @@ static void ICACHE_FLASH_ATTR listfield (LexState *ls, struct ConsControl *cc) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR constructor (LexState *ls, expdesc *t) {
|
static void constructor (LexState *ls, expdesc *t) {
|
||||||
/* constructor -> ?? */
|
/* constructor -> ?? */
|
||||||
FuncState *fs = ls->fs;
|
FuncState *fs = ls->fs;
|
||||||
int line = ls->linenumber;
|
int line = ls->linenumber;
|
||||||
@ -544,7 +544,7 @@ static void ICACHE_FLASH_ATTR constructor (LexState *ls, expdesc *t) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR parlist (LexState *ls) {
|
static void parlist (LexState *ls) {
|
||||||
/* parlist -> [ param { `,' param } ] */
|
/* parlist -> [ param { `,' param } ] */
|
||||||
FuncState *fs = ls->fs;
|
FuncState *fs = ls->fs;
|
||||||
Proto *f = fs->f;
|
Proto *f = fs->f;
|
||||||
@ -577,7 +577,7 @@ static void ICACHE_FLASH_ATTR parlist (LexState *ls) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR body (LexState *ls, expdesc *e, int needself, int line) {
|
static void body (LexState *ls, expdesc *e, int needself, int line) {
|
||||||
/* body -> `(' parlist `)' chunk END */
|
/* body -> `(' parlist `)' chunk END */
|
||||||
FuncState new_fs;
|
FuncState new_fs;
|
||||||
open_func(ls, &new_fs);
|
open_func(ls, &new_fs);
|
||||||
@ -597,7 +597,7 @@ static void ICACHE_FLASH_ATTR body (LexState *ls, expdesc *e, int needself, int
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR explist1 (LexState *ls, expdesc *v) {
|
static int explist1 (LexState *ls, expdesc *v) {
|
||||||
/* explist1 -> expr { `,' expr } */
|
/* explist1 -> expr { `,' expr } */
|
||||||
int n = 1; /* at least one expression */
|
int n = 1; /* at least one expression */
|
||||||
expr(ls, v);
|
expr(ls, v);
|
||||||
@ -610,7 +610,7 @@ static int ICACHE_FLASH_ATTR explist1 (LexState *ls, expdesc *v) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR funcargs (LexState *ls, expdesc *f) {
|
static void funcargs (LexState *ls, expdesc *f) {
|
||||||
FuncState *fs = ls->fs;
|
FuncState *fs = ls->fs;
|
||||||
expdesc args;
|
expdesc args;
|
||||||
int base, nparams;
|
int base, nparams;
|
||||||
@ -668,7 +668,7 @@ static void ICACHE_FLASH_ATTR funcargs (LexState *ls, expdesc *f) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR prefixexp (LexState *ls, expdesc *v) {
|
static void prefixexp (LexState *ls, expdesc *v) {
|
||||||
/* prefixexp -> NAME | '(' expr ')' */
|
/* prefixexp -> NAME | '(' expr ')' */
|
||||||
switch (ls->t.token) {
|
switch (ls->t.token) {
|
||||||
case '(': {
|
case '(': {
|
||||||
@ -691,7 +691,7 @@ static void ICACHE_FLASH_ATTR prefixexp (LexState *ls, expdesc *v) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR primaryexp (LexState *ls, expdesc *v) {
|
static void primaryexp (LexState *ls, expdesc *v) {
|
||||||
/* primaryexp ->
|
/* primaryexp ->
|
||||||
prefixexp { `.' NAME | `[' exp `]' | `:' NAME funcargs | funcargs } */
|
prefixexp { `.' NAME | `[' exp `]' | `:' NAME funcargs | funcargs } */
|
||||||
FuncState *fs = ls->fs;
|
FuncState *fs = ls->fs;
|
||||||
@ -728,7 +728,7 @@ static void ICACHE_FLASH_ATTR primaryexp (LexState *ls, expdesc *v) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR simpleexp (LexState *ls, expdesc *v) {
|
static void simpleexp (LexState *ls, expdesc *v) {
|
||||||
/* simpleexp -> NUMBER | STRING | NIL | true | false | ... |
|
/* simpleexp -> NUMBER | STRING | NIL | true | false | ... |
|
||||||
constructor | FUNCTION body | primaryexp */
|
constructor | FUNCTION body | primaryexp */
|
||||||
switch (ls->t.token) {
|
switch (ls->t.token) {
|
||||||
@ -779,7 +779,7 @@ static void ICACHE_FLASH_ATTR simpleexp (LexState *ls, expdesc *v) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static UnOpr ICACHE_FLASH_ATTR getunopr (int op) {
|
static UnOpr getunopr (int op) {
|
||||||
switch (op) {
|
switch (op) {
|
||||||
case TK_NOT: return OPR_NOT;
|
case TK_NOT: return OPR_NOT;
|
||||||
case '-': return OPR_MINUS;
|
case '-': return OPR_MINUS;
|
||||||
@ -789,7 +789,7 @@ static UnOpr ICACHE_FLASH_ATTR getunopr (int op) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static BinOpr ICACHE_FLASH_ATTR getbinopr (int op) {
|
static BinOpr getbinopr (int op) {
|
||||||
switch (op) {
|
switch (op) {
|
||||||
case '+': return OPR_ADD;
|
case '+': return OPR_ADD;
|
||||||
case '-': return OPR_SUB;
|
case '-': return OPR_SUB;
|
||||||
@ -829,7 +829,7 @@ static const struct {
|
|||||||
** subexpr -> (simpleexp | unop subexpr) { binop subexpr }
|
** subexpr -> (simpleexp | unop subexpr) { binop subexpr }
|
||||||
** where `binop' is any binary operator with a priority higher than `limit'
|
** where `binop' is any binary operator with a priority higher than `limit'
|
||||||
*/
|
*/
|
||||||
static BinOpr ICACHE_FLASH_ATTR subexpr (LexState *ls, expdesc *v, unsigned int limit) {
|
static BinOpr subexpr (LexState *ls, expdesc *v, unsigned int limit) {
|
||||||
BinOpr op;
|
BinOpr op;
|
||||||
UnOpr uop;
|
UnOpr uop;
|
||||||
enterlevel(ls);
|
enterlevel(ls);
|
||||||
@ -857,7 +857,7 @@ static BinOpr ICACHE_FLASH_ATTR subexpr (LexState *ls, expdesc *v, unsigned int
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR expr (LexState *ls, expdesc *v) {
|
static void expr (LexState *ls, expdesc *v) {
|
||||||
subexpr(ls, v, 0);
|
subexpr(ls, v, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -872,7 +872,7 @@ static void ICACHE_FLASH_ATTR expr (LexState *ls, expdesc *v) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR block_follow (int token) {
|
static int block_follow (int token) {
|
||||||
switch (token) {
|
switch (token) {
|
||||||
case TK_ELSE: case TK_ELSEIF: case TK_END:
|
case TK_ELSE: case TK_ELSEIF: case TK_END:
|
||||||
case TK_UNTIL: case TK_EOS:
|
case TK_UNTIL: case TK_EOS:
|
||||||
@ -882,7 +882,7 @@ static int ICACHE_FLASH_ATTR block_follow (int token) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR block (LexState *ls) {
|
static void block (LexState *ls) {
|
||||||
/* block -> chunk */
|
/* block -> chunk */
|
||||||
FuncState *fs = ls->fs;
|
FuncState *fs = ls->fs;
|
||||||
BlockCnt *pbl = (BlockCnt*)luaM_malloc(ls->L,sizeof(BlockCnt));
|
BlockCnt *pbl = (BlockCnt*)luaM_malloc(ls->L,sizeof(BlockCnt));
|
||||||
@ -910,7 +910,7 @@ struct LHS_assign {
|
|||||||
** local value in a safe place and use this safe copy in the previous
|
** local value in a safe place and use this safe copy in the previous
|
||||||
** assignment.
|
** assignment.
|
||||||
*/
|
*/
|
||||||
static void ICACHE_FLASH_ATTR check_conflict (LexState *ls, struct LHS_assign *lh, expdesc *v) {
|
static void check_conflict (LexState *ls, struct LHS_assign *lh, expdesc *v) {
|
||||||
FuncState *fs = ls->fs;
|
FuncState *fs = ls->fs;
|
||||||
int extra = fs->freereg; /* eventual position to save local variable */
|
int extra = fs->freereg; /* eventual position to save local variable */
|
||||||
int conflict = 0;
|
int conflict = 0;
|
||||||
@ -933,7 +933,7 @@ static void ICACHE_FLASH_ATTR check_conflict (LexState *ls, struct LHS_assign *l
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR assignment (LexState *ls, struct LHS_assign *lh, int nvars) {
|
static void assignment (LexState *ls, struct LHS_assign *lh, int nvars) {
|
||||||
expdesc e;
|
expdesc e;
|
||||||
check_condition(ls, VLOCAL <= lh->v.k && lh->v.k <= VINDEXED,
|
check_condition(ls, VLOCAL <= lh->v.k && lh->v.k <= VINDEXED,
|
||||||
"syntax error");
|
"syntax error");
|
||||||
@ -967,7 +967,7 @@ static void ICACHE_FLASH_ATTR assignment (LexState *ls, struct LHS_assign *lh, i
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR cond (LexState *ls) {
|
static int cond (LexState *ls) {
|
||||||
/* cond -> exp */
|
/* cond -> exp */
|
||||||
expdesc v;
|
expdesc v;
|
||||||
expr(ls, &v); /* read condition */
|
expr(ls, &v); /* read condition */
|
||||||
@ -977,7 +977,7 @@ static int ICACHE_FLASH_ATTR cond (LexState *ls) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR breakstat (LexState *ls) {
|
static void breakstat (LexState *ls) {
|
||||||
FuncState *fs = ls->fs;
|
FuncState *fs = ls->fs;
|
||||||
BlockCnt *bl = fs->bl;
|
BlockCnt *bl = fs->bl;
|
||||||
int upval = 0;
|
int upval = 0;
|
||||||
@ -993,7 +993,7 @@ static void ICACHE_FLASH_ATTR breakstat (LexState *ls) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR whilestat (LexState *ls, int line) {
|
static void whilestat (LexState *ls, int line) {
|
||||||
/* whilestat -> WHILE cond DO block END */
|
/* whilestat -> WHILE cond DO block END */
|
||||||
FuncState *fs = ls->fs;
|
FuncState *fs = ls->fs;
|
||||||
int whileinit;
|
int whileinit;
|
||||||
@ -1012,7 +1012,7 @@ static void ICACHE_FLASH_ATTR whilestat (LexState *ls, int line) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR repeatstat (LexState *ls, int line) {
|
static void repeatstat (LexState *ls, int line) {
|
||||||
/* repeatstat -> REPEAT block UNTIL cond */
|
/* repeatstat -> REPEAT block UNTIL cond */
|
||||||
int condexit;
|
int condexit;
|
||||||
FuncState *fs = ls->fs;
|
FuncState *fs = ls->fs;
|
||||||
@ -1038,7 +1038,7 @@ static void ICACHE_FLASH_ATTR repeatstat (LexState *ls, int line) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR exp1 (LexState *ls) {
|
static int exp1 (LexState *ls) {
|
||||||
expdesc e;
|
expdesc e;
|
||||||
int k;
|
int k;
|
||||||
expr(ls, &e);
|
expr(ls, &e);
|
||||||
@ -1048,7 +1048,7 @@ static int ICACHE_FLASH_ATTR exp1 (LexState *ls) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR forbody (LexState *ls, int base, int line, int nvars, int isnum) {
|
static void forbody (LexState *ls, int base, int line, int nvars, int isnum) {
|
||||||
/* forbody -> DO block */
|
/* forbody -> DO block */
|
||||||
BlockCnt *pbl = (BlockCnt*)luaM_malloc(ls->L,sizeof(BlockCnt));
|
BlockCnt *pbl = (BlockCnt*)luaM_malloc(ls->L,sizeof(BlockCnt));
|
||||||
FuncState *fs = ls->fs;
|
FuncState *fs = ls->fs;
|
||||||
@ -1070,7 +1070,7 @@ static void ICACHE_FLASH_ATTR forbody (LexState *ls, int base, int line, int nva
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR fornum (LexState *ls, TString *varname, int line) {
|
static void fornum (LexState *ls, TString *varname, int line) {
|
||||||
/* fornum -> NAME = exp1,exp1[,exp1] forbody */
|
/* fornum -> NAME = exp1,exp1[,exp1] forbody */
|
||||||
FuncState *fs = ls->fs;
|
FuncState *fs = ls->fs;
|
||||||
int base = fs->freereg;
|
int base = fs->freereg;
|
||||||
@ -1092,7 +1092,7 @@ static void ICACHE_FLASH_ATTR fornum (LexState *ls, TString *varname, int line)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR forlist (LexState *ls, TString *indexname) {
|
static void forlist (LexState *ls, TString *indexname) {
|
||||||
/* forlist -> NAME {,NAME} IN explist1 forbody */
|
/* forlist -> NAME {,NAME} IN explist1 forbody */
|
||||||
FuncState *fs = ls->fs;
|
FuncState *fs = ls->fs;
|
||||||
expdesc e;
|
expdesc e;
|
||||||
@ -1115,7 +1115,7 @@ static void ICACHE_FLASH_ATTR forlist (LexState *ls, TString *indexname) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR forstat (LexState *ls, int line) {
|
static void forstat (LexState *ls, int line) {
|
||||||
/* forstat -> FOR (fornum | forlist) END */
|
/* forstat -> FOR (fornum | forlist) END */
|
||||||
FuncState *fs = ls->fs;
|
FuncState *fs = ls->fs;
|
||||||
TString *varname;
|
TString *varname;
|
||||||
@ -1133,7 +1133,7 @@ static void ICACHE_FLASH_ATTR forstat (LexState *ls, int line) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR test_then_block (LexState *ls) {
|
static int test_then_block (LexState *ls) {
|
||||||
/* test_then_block -> [IF | ELSEIF] cond THEN block */
|
/* test_then_block -> [IF | ELSEIF] cond THEN block */
|
||||||
int condexit;
|
int condexit;
|
||||||
luaX_next(ls); /* skip IF or ELSEIF */
|
luaX_next(ls); /* skip IF or ELSEIF */
|
||||||
@ -1144,7 +1144,7 @@ static int ICACHE_FLASH_ATTR test_then_block (LexState *ls) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR ifstat (LexState *ls, int line) {
|
static void ifstat (LexState *ls, int line) {
|
||||||
/* ifstat -> IF cond THEN block {ELSEIF cond THEN block} [ELSE block] END */
|
/* ifstat -> IF cond THEN block {ELSEIF cond THEN block} [ELSE block] END */
|
||||||
FuncState *fs = ls->fs;
|
FuncState *fs = ls->fs;
|
||||||
int flist;
|
int flist;
|
||||||
@ -1168,7 +1168,7 @@ static void ICACHE_FLASH_ATTR ifstat (LexState *ls, int line) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR localfunc (LexState *ls) {
|
static void localfunc (LexState *ls) {
|
||||||
expdesc v, b;
|
expdesc v, b;
|
||||||
FuncState *fs = ls->fs;
|
FuncState *fs = ls->fs;
|
||||||
new_localvar(ls, str_checkname(ls), 0);
|
new_localvar(ls, str_checkname(ls), 0);
|
||||||
@ -1182,7 +1182,7 @@ static void ICACHE_FLASH_ATTR localfunc (LexState *ls) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR localstat (LexState *ls) {
|
static void localstat (LexState *ls) {
|
||||||
/* stat -> LOCAL NAME {`,' NAME} [`=' explist1] */
|
/* stat -> LOCAL NAME {`,' NAME} [`=' explist1] */
|
||||||
int nvars = 0;
|
int nvars = 0;
|
||||||
int nexps;
|
int nexps;
|
||||||
@ -1201,7 +1201,7 @@ static void ICACHE_FLASH_ATTR localstat (LexState *ls) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR funcname (LexState *ls, expdesc *v) {
|
static int funcname (LexState *ls, expdesc *v) {
|
||||||
/* funcname -> NAME {field} [`:' NAME] */
|
/* funcname -> NAME {field} [`:' NAME] */
|
||||||
int needself = 0;
|
int needself = 0;
|
||||||
singlevar(ls, v);
|
singlevar(ls, v);
|
||||||
@ -1215,7 +1215,7 @@ static int ICACHE_FLASH_ATTR funcname (LexState *ls, expdesc *v) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR funcstat (LexState *ls, int line) {
|
static void funcstat (LexState *ls, int line) {
|
||||||
/* funcstat -> FUNCTION funcname body */
|
/* funcstat -> FUNCTION funcname body */
|
||||||
int needself;
|
int needself;
|
||||||
expdesc v, b;
|
expdesc v, b;
|
||||||
@ -1227,7 +1227,7 @@ static void ICACHE_FLASH_ATTR funcstat (LexState *ls, int line) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR exprstat (LexState *ls) {
|
static void exprstat (LexState *ls) {
|
||||||
/* stat -> func | assignment */
|
/* stat -> func | assignment */
|
||||||
FuncState *fs = ls->fs;
|
FuncState *fs = ls->fs;
|
||||||
struct LHS_assign v;
|
struct LHS_assign v;
|
||||||
@ -1241,7 +1241,7 @@ static void ICACHE_FLASH_ATTR exprstat (LexState *ls) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR retstat (LexState *ls) {
|
static void retstat (LexState *ls) {
|
||||||
/* stat -> RETURN explist */
|
/* stat -> RETURN explist */
|
||||||
FuncState *fs = ls->fs;
|
FuncState *fs = ls->fs;
|
||||||
expdesc e;
|
expdesc e;
|
||||||
@ -1274,7 +1274,7 @@ static void ICACHE_FLASH_ATTR retstat (LexState *ls) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR statement (LexState *ls) {
|
static int statement (LexState *ls) {
|
||||||
int line = ls->linenumber; /* may be needed for error messages */
|
int line = ls->linenumber; /* may be needed for error messages */
|
||||||
switch (ls->t.token) {
|
switch (ls->t.token) {
|
||||||
case TK_IF: { /* stat -> ifstat */
|
case TK_IF: { /* stat -> ifstat */
|
||||||
@ -1328,7 +1328,7 @@ static int ICACHE_FLASH_ATTR statement (LexState *ls) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR chunk (LexState *ls) {
|
static void chunk (LexState *ls) {
|
||||||
/* chunk -> { stat [`;'] } */
|
/* chunk -> { stat [`;'] } */
|
||||||
int islast = 0;
|
int islast = 0;
|
||||||
enterlevel(ls);
|
enterlevel(ls);
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
#undef LREGISTER
|
#undef LREGISTER
|
||||||
|
|
||||||
#if (MIN_OPT_LEVEL > 0) && (LUA_OPTIMIZE_MEMORY >= MIN_OPT_LEVEL)
|
#if (MIN_OPT_LEVEL > 0) && (LUA_OPTIMIZE_MEMORY >= MIN_OPT_LEVEL)
|
||||||
#define LUA_REG_TYPE luaR_entry
|
#define LUA_REG_TYPE luaR_entry ICACHE_RODATA_ATTR
|
||||||
#define LSTRKEY LRO_STRKEY
|
#define LSTRKEY LRO_STRKEY
|
||||||
#define LNUMKEY LRO_NUMKEY
|
#define LNUMKEY LRO_NUMKEY
|
||||||
#define LNILKEY LRO_NILKEY
|
#define LNILKEY LRO_NILKEY
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
extern const luaR_table lua_rotable[];
|
extern const luaR_table lua_rotable[];
|
||||||
|
|
||||||
/* Find a global "read only table" in the constant lua_rotable array */
|
/* Find a global "read only table" in the constant lua_rotable array */
|
||||||
void* ICACHE_FLASH_ATTR luaR_findglobal(const char *name, unsigned len) {
|
void* luaR_findglobal(const char *name, unsigned len) {
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
if (c_strlen(name) > LUA_MAX_ROTABLE_NAME)
|
if (c_strlen(name) > LUA_MAX_ROTABLE_NAME)
|
||||||
@ -29,7 +29,7 @@ void* ICACHE_FLASH_ATTR luaR_findglobal(const char *name, unsigned len) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Find an entry in a rotable and return it */
|
/* Find an entry in a rotable and return it */
|
||||||
static const TValue* ICACHE_FLASH_ATTR luaR_auxfind(const luaR_entry *pentry, const char *strkey, luaR_numkey numkey, unsigned *ppos) {
|
static const TValue* luaR_auxfind(const luaR_entry *pentry, const char *strkey, luaR_numkey numkey, unsigned *ppos) {
|
||||||
const TValue *res = NULL;
|
const TValue *res = NULL;
|
||||||
unsigned i = 0;
|
unsigned i = 0;
|
||||||
|
|
||||||
@ -48,7 +48,7 @@ static const TValue* ICACHE_FLASH_ATTR luaR_auxfind(const luaR_entry *pentry, co
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ICACHE_FLASH_ATTR luaR_findfunction(lua_State *L, const luaR_entry *ptable) {
|
int luaR_findfunction(lua_State *L, const luaR_entry *ptable) {
|
||||||
const TValue *res = NULL;
|
const TValue *res = NULL;
|
||||||
const char *key = luaL_checkstring(L, 2);
|
const char *key = luaL_checkstring(L, 2);
|
||||||
|
|
||||||
@ -64,12 +64,12 @@ int ICACHE_FLASH_ATTR luaR_findfunction(lua_State *L, const luaR_entry *ptable)
|
|||||||
/* Find an entry in a rotable and return its type
|
/* Find an entry in a rotable and return its type
|
||||||
If "strkey" is not NULL, the function will look for a string key,
|
If "strkey" is not NULL, the function will look for a string key,
|
||||||
otherwise it will look for a number key */
|
otherwise it will look for a number key */
|
||||||
const TValue* ICACHE_FLASH_ATTR luaR_findentry(void *data, const char *strkey, luaR_numkey numkey, unsigned *ppos) {
|
const TValue* luaR_findentry(void *data, const char *strkey, luaR_numkey numkey, unsigned *ppos) {
|
||||||
return luaR_auxfind((const luaR_entry*)data, strkey, numkey, ppos);
|
return luaR_auxfind((const luaR_entry*)data, strkey, numkey, ppos);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Find the metatable of a given table */
|
/* Find the metatable of a given table */
|
||||||
void* ICACHE_FLASH_ATTR luaR_getmeta(void *data) {
|
void* luaR_getmeta(void *data) {
|
||||||
#ifdef LUA_META_ROTABLES
|
#ifdef LUA_META_ROTABLES
|
||||||
const TValue *res = luaR_auxfind((const luaR_entry*)data, "__metatable", 0, NULL);
|
const TValue *res = luaR_auxfind((const luaR_entry*)data, "__metatable", 0, NULL);
|
||||||
return res && ttisrotable(res) ? rvalue(res) : NULL;
|
return res && ttisrotable(res) ? rvalue(res) : NULL;
|
||||||
@ -78,7 +78,7 @@ void* ICACHE_FLASH_ATTR luaR_getmeta(void *data) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR luaR_next_helper(lua_State *L, const luaR_entry *pentries, int pos, TValue *key, TValue *val) {
|
static void luaR_next_helper(lua_State *L, const luaR_entry *pentries, int pos, TValue *key, TValue *val) {
|
||||||
setnilvalue(key);
|
setnilvalue(key);
|
||||||
setnilvalue(val);
|
setnilvalue(val);
|
||||||
if (pentries[pos].key.type != LUA_TNIL) {
|
if (pentries[pos].key.type != LUA_TNIL) {
|
||||||
@ -91,7 +91,7 @@ static void ICACHE_FLASH_ATTR luaR_next_helper(lua_State *L, const luaR_entry *p
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* next (used for iteration) */
|
/* next (used for iteration) */
|
||||||
void ICACHE_FLASH_ATTR luaR_next(lua_State *L, void *data, TValue *key, TValue *val) {
|
void luaR_next(lua_State *L, void *data, TValue *key, TValue *val) {
|
||||||
const luaR_entry* pentries = (const luaR_entry*)data;
|
const luaR_entry* pentries = (const luaR_entry*)data;
|
||||||
char strkey[LUA_MAX_ROTABLE_NAME + 1], *pstrkey = NULL;
|
char strkey[LUA_MAX_ROTABLE_NAME + 1], *pstrkey = NULL;
|
||||||
luaR_numkey numkey = 0;
|
luaR_numkey numkey = 0;
|
||||||
@ -115,7 +115,7 @@ void ICACHE_FLASH_ATTR luaR_next(lua_State *L, void *data, TValue *key, TValue *
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Convert a Lua string to a C string */
|
/* Convert a Lua string to a C string */
|
||||||
void ICACHE_FLASH_ATTR luaR_getcstr(char *dest, const TString *src, size_t maxsize) {
|
void luaR_getcstr(char *dest, const TString *src, size_t maxsize) {
|
||||||
if (src->tsv.len+1 > maxsize)
|
if (src->tsv.len+1 > maxsize)
|
||||||
dest[0] = '\0';
|
dest[0] = '\0';
|
||||||
else {
|
else {
|
||||||
@ -129,7 +129,7 @@ void ICACHE_FLASH_ATTR luaR_getcstr(char *dest, const TString *src, size_t maxsi
|
|||||||
|
|
||||||
#include "compiler.h"
|
#include "compiler.h"
|
||||||
|
|
||||||
int ICACHE_FLASH_ATTR luaR_isrotable(void *p) {
|
int luaR_isrotable(void *p) {
|
||||||
return RODATA_START_ADDRESS <= (char*)p && (char*)p <= RODATA_END_ADDRESS;
|
return RODATA_START_ADDRESS <= (char*)p && (char*)p <= RODATA_END_ADDRESS;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -38,7 +38,7 @@ typedef struct LG {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR stack_init (lua_State *L1, lua_State *L) {
|
static void stack_init (lua_State *L1, lua_State *L) {
|
||||||
/* initialize CallInfo array */
|
/* initialize CallInfo array */
|
||||||
L1->base_ci = luaM_newvector(L, BASIC_CI_SIZE, CallInfo);
|
L1->base_ci = luaM_newvector(L, BASIC_CI_SIZE, CallInfo);
|
||||||
L1->ci = L1->base_ci;
|
L1->ci = L1->base_ci;
|
||||||
@ -57,7 +57,7 @@ static void ICACHE_FLASH_ATTR stack_init (lua_State *L1, lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR freestack (lua_State *L, lua_State *L1) {
|
static void freestack (lua_State *L, lua_State *L1) {
|
||||||
luaM_freearray(L, L1->base_ci, L1->size_ci, CallInfo);
|
luaM_freearray(L, L1->base_ci, L1->size_ci, CallInfo);
|
||||||
luaM_freearray(L, L1->stack, L1->stacksize, TValue);
|
luaM_freearray(L, L1->stack, L1->stacksize, TValue);
|
||||||
}
|
}
|
||||||
@ -66,7 +66,7 @@ static void ICACHE_FLASH_ATTR freestack (lua_State *L, lua_State *L1) {
|
|||||||
/*
|
/*
|
||||||
** open parts that may cause memory-allocation errors
|
** open parts that may cause memory-allocation errors
|
||||||
*/
|
*/
|
||||||
static void ICACHE_FLASH_ATTR f_luaopen (lua_State *L, void *ud) {
|
static void f_luaopen (lua_State *L, void *ud) {
|
||||||
global_State *g = G(L);
|
global_State *g = G(L);
|
||||||
UNUSED(ud);
|
UNUSED(ud);
|
||||||
stack_init(L, L); /* init stack */
|
stack_init(L, L); /* init stack */
|
||||||
@ -80,7 +80,7 @@ static void ICACHE_FLASH_ATTR f_luaopen (lua_State *L, void *ud) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR preinit_state (lua_State *L, global_State *g) {
|
static void preinit_state (lua_State *L, global_State *g) {
|
||||||
G(L) = g;
|
G(L) = g;
|
||||||
L->stack = NULL;
|
L->stack = NULL;
|
||||||
L->stacksize = 0;
|
L->stacksize = 0;
|
||||||
@ -101,7 +101,7 @@ static void ICACHE_FLASH_ATTR preinit_state (lua_State *L, global_State *g) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR close_state (lua_State *L) {
|
static void close_state (lua_State *L) {
|
||||||
global_State *g = G(L);
|
global_State *g = G(L);
|
||||||
luaF_close(L, L->stack); /* close all upvalues for this thread */
|
luaF_close(L, L->stack); /* close all upvalues for this thread */
|
||||||
luaC_freeall(L); /* collect all objects */
|
luaC_freeall(L); /* collect all objects */
|
||||||
@ -115,7 +115,7 @@ static void ICACHE_FLASH_ATTR close_state (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
lua_State *ICACHE_FLASH_ATTR luaE_newthread (lua_State *L) {
|
lua_State *luaE_newthread (lua_State *L) {
|
||||||
lua_State *L1 = tostate(luaM_malloc(L, state_size(lua_State)));
|
lua_State *L1 = tostate(luaM_malloc(L, state_size(lua_State)));
|
||||||
luaC_link(L, obj2gco(L1), LUA_TTHREAD);
|
luaC_link(L, obj2gco(L1), LUA_TTHREAD);
|
||||||
setthvalue(L, L->top, L1); /* put thread on stack */
|
setthvalue(L, L->top, L1); /* put thread on stack */
|
||||||
@ -133,7 +133,7 @@ lua_State *ICACHE_FLASH_ATTR luaE_newthread (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR luaE_freethread (lua_State *L, lua_State *L1) {
|
void luaE_freethread (lua_State *L, lua_State *L1) {
|
||||||
luaF_close(L1, L1->stack); /* close all upvalues for this thread */
|
luaF_close(L1, L1->stack); /* close all upvalues for this thread */
|
||||||
lua_assert(L1->openupval == NULL);
|
lua_assert(L1->openupval == NULL);
|
||||||
luai_userstatefree(L1);
|
luai_userstatefree(L1);
|
||||||
@ -142,7 +142,7 @@ void ICACHE_FLASH_ATTR luaE_freethread (lua_State *L, lua_State *L1) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API lua_State *ICACHE_FLASH_ATTR lua_newstate (lua_Alloc f, void *ud) {
|
LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) {
|
||||||
int i;
|
int i;
|
||||||
lua_State *L;
|
lua_State *L;
|
||||||
global_State *g;
|
global_State *g;
|
||||||
@ -205,7 +205,7 @@ LUA_API lua_State *ICACHE_FLASH_ATTR lua_newstate (lua_Alloc f, void *ud) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR callallgcTM (lua_State *L, void *ud) {
|
static void callallgcTM (lua_State *L, void *ud) {
|
||||||
UNUSED(ud);
|
UNUSED(ud);
|
||||||
luaC_callGCTM(L); /* call GC metamethods for all udata */
|
luaC_callGCTM(L); /* call GC metamethods for all udata */
|
||||||
}
|
}
|
||||||
@ -214,15 +214,15 @@ static void ICACHE_FLASH_ATTR callallgcTM (lua_State *L, void *ud) {
|
|||||||
extern lua_State *luaL_newstate (void);
|
extern lua_State *luaL_newstate (void);
|
||||||
static lua_State *lua_crtstate;
|
static lua_State *lua_crtstate;
|
||||||
|
|
||||||
lua_State *ICACHE_FLASH_ATTR lua_open(void) {
|
lua_State *lua_open(void) {
|
||||||
lua_crtstate = luaL_newstate();
|
lua_crtstate = luaL_newstate();
|
||||||
return lua_crtstate;
|
return lua_crtstate;
|
||||||
}
|
}
|
||||||
|
|
||||||
lua_State *ICACHE_FLASH_ATTR lua_getstate(void) {
|
lua_State *lua_getstate(void) {
|
||||||
return lua_crtstate;
|
return lua_crtstate;
|
||||||
}
|
}
|
||||||
LUA_API void ICACHE_FLASH_ATTR lua_close (lua_State *L) {
|
LUA_API void lua_close (lua_State *L) {
|
||||||
#ifndef LUA_CROSS_COMPILER
|
#ifndef LUA_CROSS_COMPILER
|
||||||
lua_sethook( L, NULL, 0, 0 );
|
lua_sethook( L, NULL, 0, 0 );
|
||||||
lua_crtstate = NULL;
|
lua_crtstate = NULL;
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#define LUAS_READONLY_STRING 1
|
#define LUAS_READONLY_STRING 1
|
||||||
#define LUAS_REGULAR_STRING 0
|
#define LUAS_REGULAR_STRING 0
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR luaS_resize (lua_State *L, int newsize) {
|
void luaS_resize (lua_State *L, int newsize) {
|
||||||
stringtable *tb;
|
stringtable *tb;
|
||||||
int i;
|
int i;
|
||||||
tb = &G(L)->strt;
|
tb = &G(L)->strt;
|
||||||
@ -51,7 +51,7 @@ void ICACHE_FLASH_ATTR luaS_resize (lua_State *L, int newsize) {
|
|||||||
unset_resizing_strings_gc(L);
|
unset_resizing_strings_gc(L);
|
||||||
}
|
}
|
||||||
|
|
||||||
static TString *ICACHE_FLASH_ATTR newlstr (lua_State *L, const char *str, size_t l,
|
static TString *newlstr (lua_State *L, const char *str, size_t l,
|
||||||
unsigned int h, int readonly) {
|
unsigned int h, int readonly) {
|
||||||
TString *ts;
|
TString *ts;
|
||||||
stringtable *tb;
|
stringtable *tb;
|
||||||
@ -80,7 +80,7 @@ static TString *ICACHE_FLASH_ATTR newlstr (lua_State *L, const char *str, size_t
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static TString *ICACHE_FLASH_ATTR luaS_newlstr_helper (lua_State *L, const char *str, size_t l, int readonly) {
|
static TString *luaS_newlstr_helper (lua_State *L, const char *str, size_t l, int readonly) {
|
||||||
GCObject *o;
|
GCObject *o;
|
||||||
unsigned int h = cast(unsigned int, l); /* seed */
|
unsigned int h = cast(unsigned int, l); /* seed */
|
||||||
size_t step = (l>>5)+1; /* if string is too long, don't hash all its chars */
|
size_t step = (l>>5)+1; /* if string is too long, don't hash all its chars */
|
||||||
@ -100,7 +100,7 @@ static TString *ICACHE_FLASH_ATTR luaS_newlstr_helper (lua_State *L, const char
|
|||||||
return newlstr(L, str, l, h, readonly); /* not found */
|
return newlstr(L, str, l, h, readonly); /* not found */
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR lua_is_ptr_in_ro_area(const char *p) {
|
static int lua_is_ptr_in_ro_area(const char *p) {
|
||||||
#ifdef LUA_CROSS_COMPILER
|
#ifdef LUA_CROSS_COMPILER
|
||||||
return 0;
|
return 0;
|
||||||
#else
|
#else
|
||||||
@ -111,7 +111,7 @@ static int ICACHE_FLASH_ATTR lua_is_ptr_in_ro_area(const char *p) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
TString *ICACHE_FLASH_ATTR luaS_newlstr (lua_State *L, const char *str, size_t l) {
|
TString *luaS_newlstr (lua_State *L, const char *str, size_t l) {
|
||||||
// If the pointer is in a read-only memory and the string is at least 4 chars in length,
|
// If the pointer is in a read-only memory and the string is at least 4 chars in length,
|
||||||
// create it as a read-only string instead
|
// create it as a read-only string instead
|
||||||
if(lua_is_ptr_in_ro_area(str) && l+1 > sizeof(char**) && l == c_strlen(str))
|
if(lua_is_ptr_in_ro_area(str) && l+1 > sizeof(char**) && l == c_strlen(str))
|
||||||
@ -121,7 +121,7 @@ TString *ICACHE_FLASH_ATTR luaS_newlstr (lua_State *L, const char *str, size_t l
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUAI_FUNC TString *ICACHE_FLASH_ATTR luaS_newrolstr (lua_State *L, const char *str, size_t l) {
|
LUAI_FUNC TString *luaS_newrolstr (lua_State *L, const char *str, size_t l) {
|
||||||
if(l+1 > sizeof(char**) && l == c_strlen(str))
|
if(l+1 > sizeof(char**) && l == c_strlen(str))
|
||||||
return luaS_newlstr_helper(L, str, l, LUAS_READONLY_STRING);
|
return luaS_newlstr_helper(L, str, l, LUAS_READONLY_STRING);
|
||||||
else // no point in creating a RO string, as it would actually be larger
|
else // no point in creating a RO string, as it would actually be larger
|
||||||
@ -129,7 +129,7 @@ LUAI_FUNC TString *ICACHE_FLASH_ATTR luaS_newrolstr (lua_State *L, const char *s
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Udata *ICACHE_FLASH_ATTR luaS_newudata (lua_State *L, size_t s, Table *e) {
|
Udata *luaS_newudata (lua_State *L, size_t s, Table *e) {
|
||||||
Udata *u;
|
Udata *u;
|
||||||
if (s > MAX_SIZET - sizeof(Udata))
|
if (s > MAX_SIZET - sizeof(Udata))
|
||||||
luaM_toobig(L);
|
luaM_toobig(L);
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR str_len (lua_State *L) {
|
static int str_len (lua_State *L) {
|
||||||
size_t l;
|
size_t l;
|
||||||
luaL_checklstring(L, 1, &l);
|
luaL_checklstring(L, 1, &l);
|
||||||
lua_pushinteger(L, l);
|
lua_pushinteger(L, l);
|
||||||
@ -33,14 +33,14 @@ static int ICACHE_FLASH_ATTR str_len (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static ptrdiff_t ICACHE_FLASH_ATTR posrelat (ptrdiff_t pos, size_t len) {
|
static ptrdiff_t posrelat (ptrdiff_t pos, size_t len) {
|
||||||
/* relative string position: negative means back from end */
|
/* relative string position: negative means back from end */
|
||||||
if (pos < 0) pos += (ptrdiff_t)len + 1;
|
if (pos < 0) pos += (ptrdiff_t)len + 1;
|
||||||
return (pos >= 0) ? pos : 0;
|
return (pos >= 0) ? pos : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR str_sub (lua_State *L) {
|
static int str_sub (lua_State *L) {
|
||||||
size_t l;
|
size_t l;
|
||||||
const char *s = luaL_checklstring(L, 1, &l);
|
const char *s = luaL_checklstring(L, 1, &l);
|
||||||
ptrdiff_t start = posrelat(luaL_checkinteger(L, 2), l);
|
ptrdiff_t start = posrelat(luaL_checkinteger(L, 2), l);
|
||||||
@ -54,7 +54,7 @@ static int ICACHE_FLASH_ATTR str_sub (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR str_reverse (lua_State *L) {
|
static int str_reverse (lua_State *L) {
|
||||||
size_t l;
|
size_t l;
|
||||||
luaL_Buffer b;
|
luaL_Buffer b;
|
||||||
const char *s = luaL_checklstring(L, 1, &l);
|
const char *s = luaL_checklstring(L, 1, &l);
|
||||||
@ -65,7 +65,7 @@ static int ICACHE_FLASH_ATTR str_reverse (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR str_lower (lua_State *L) {
|
static int str_lower (lua_State *L) {
|
||||||
size_t l;
|
size_t l;
|
||||||
size_t i;
|
size_t i;
|
||||||
luaL_Buffer b;
|
luaL_Buffer b;
|
||||||
@ -78,7 +78,7 @@ static int ICACHE_FLASH_ATTR str_lower (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR str_upper (lua_State *L) {
|
static int str_upper (lua_State *L) {
|
||||||
size_t l;
|
size_t l;
|
||||||
size_t i;
|
size_t i;
|
||||||
luaL_Buffer b;
|
luaL_Buffer b;
|
||||||
@ -90,7 +90,7 @@ static int ICACHE_FLASH_ATTR str_upper (lua_State *L) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR str_rep (lua_State *L) {
|
static int str_rep (lua_State *L) {
|
||||||
size_t l;
|
size_t l;
|
||||||
luaL_Buffer b;
|
luaL_Buffer b;
|
||||||
const char *s = luaL_checklstring(L, 1, &l);
|
const char *s = luaL_checklstring(L, 1, &l);
|
||||||
@ -103,7 +103,7 @@ static int ICACHE_FLASH_ATTR str_rep (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR str_byte (lua_State *L) {
|
static int str_byte (lua_State *L) {
|
||||||
size_t l;
|
size_t l;
|
||||||
const char *s = luaL_checklstring(L, 1, &l);
|
const char *s = luaL_checklstring(L, 1, &l);
|
||||||
ptrdiff_t posi = posrelat(luaL_optinteger(L, 2, 1), l);
|
ptrdiff_t posi = posrelat(luaL_optinteger(L, 2, 1), l);
|
||||||
@ -122,7 +122,7 @@ static int ICACHE_FLASH_ATTR str_byte (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR str_char (lua_State *L) {
|
static int str_char (lua_State *L) {
|
||||||
int n = lua_gettop(L); /* number of arguments */
|
int n = lua_gettop(L); /* number of arguments */
|
||||||
int i;
|
int i;
|
||||||
luaL_Buffer b;
|
luaL_Buffer b;
|
||||||
@ -137,14 +137,14 @@ static int ICACHE_FLASH_ATTR str_char (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR writer (lua_State *L, const void* b, size_t size, void* B) {
|
static int writer (lua_State *L, const void* b, size_t size, void* B) {
|
||||||
(void)L;
|
(void)L;
|
||||||
luaL_addlstring((luaL_Buffer*) B, (const char *)b, size);
|
luaL_addlstring((luaL_Buffer*) B, (const char *)b, size);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR str_dump (lua_State *L) {
|
static int str_dump (lua_State *L) {
|
||||||
luaL_Buffer b;
|
luaL_Buffer b;
|
||||||
luaL_checktype(L, 1, LUA_TFUNCTION);
|
luaL_checktype(L, 1, LUA_TFUNCTION);
|
||||||
lua_settop(L, 1);
|
lua_settop(L, 1);
|
||||||
@ -183,7 +183,7 @@ typedef struct MatchState {
|
|||||||
#define SPECIALS "^$*+?.([%-"
|
#define SPECIALS "^$*+?.([%-"
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR check_capture (MatchState *ms, int l) {
|
static int check_capture (MatchState *ms, int l) {
|
||||||
l -= '1';
|
l -= '1';
|
||||||
if (l < 0 || l >= ms->level || ms->capture[l].len == CAP_UNFINISHED)
|
if (l < 0 || l >= ms->level || ms->capture[l].len == CAP_UNFINISHED)
|
||||||
return luaL_error(ms->L, "invalid capture index");
|
return luaL_error(ms->L, "invalid capture index");
|
||||||
@ -191,7 +191,7 @@ static int ICACHE_FLASH_ATTR check_capture (MatchState *ms, int l) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR capture_to_close (MatchState *ms) {
|
static int capture_to_close (MatchState *ms) {
|
||||||
int level = ms->level;
|
int level = ms->level;
|
||||||
for (level--; level>=0; level--)
|
for (level--; level>=0; level--)
|
||||||
if (ms->capture[level].len == CAP_UNFINISHED) return level;
|
if (ms->capture[level].len == CAP_UNFINISHED) return level;
|
||||||
@ -199,7 +199,7 @@ static int ICACHE_FLASH_ATTR capture_to_close (MatchState *ms) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static const char *ICACHE_FLASH_ATTR classend (MatchState *ms, const char *p) {
|
static const char *classend (MatchState *ms, const char *p) {
|
||||||
switch (*p++) {
|
switch (*p++) {
|
||||||
case L_ESC: {
|
case L_ESC: {
|
||||||
if (*p == '\0')
|
if (*p == '\0')
|
||||||
@ -223,7 +223,7 @@ static const char *ICACHE_FLASH_ATTR classend (MatchState *ms, const char *p) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR match_class (int c, int cl) {
|
static int match_class (int c, int cl) {
|
||||||
int res;
|
int res;
|
||||||
switch (tolower(cl)) {
|
switch (tolower(cl)) {
|
||||||
case 'a' : res = isalpha(c); break;
|
case 'a' : res = isalpha(c); break;
|
||||||
@ -242,7 +242,7 @@ static int ICACHE_FLASH_ATTR match_class (int c, int cl) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR matchbracketclass (int c, const char *p, const char *ec) {
|
static int matchbracketclass (int c, const char *p, const char *ec) {
|
||||||
int sig = 1;
|
int sig = 1;
|
||||||
if (*(p+1) == '^') {
|
if (*(p+1) == '^') {
|
||||||
sig = 0;
|
sig = 0;
|
||||||
@ -265,7 +265,7 @@ static int ICACHE_FLASH_ATTR matchbracketclass (int c, const char *p, const char
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR singlematch (int c, const char *p, const char *ep) {
|
static int singlematch (int c, const char *p, const char *ep) {
|
||||||
switch (*p) {
|
switch (*p) {
|
||||||
case '.': return 1; /* matches any char */
|
case '.': return 1; /* matches any char */
|
||||||
case L_ESC: return match_class(c, uchar(*(p+1)));
|
case L_ESC: return match_class(c, uchar(*(p+1)));
|
||||||
@ -278,7 +278,7 @@ static int ICACHE_FLASH_ATTR singlematch (int c, const char *p, const char *ep)
|
|||||||
static const char *match (MatchState *ms, const char *s, const char *p);
|
static const char *match (MatchState *ms, const char *s, const char *p);
|
||||||
|
|
||||||
|
|
||||||
static const char *ICACHE_FLASH_ATTR matchbalance (MatchState *ms, const char *s,
|
static const char *matchbalance (MatchState *ms, const char *s,
|
||||||
const char *p) {
|
const char *p) {
|
||||||
if (*p == 0 || *(p+1) == 0)
|
if (*p == 0 || *(p+1) == 0)
|
||||||
luaL_error(ms->L, "unbalanced pattern");
|
luaL_error(ms->L, "unbalanced pattern");
|
||||||
@ -298,7 +298,7 @@ static const char *ICACHE_FLASH_ATTR matchbalance (MatchState *ms, const char *s
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static const char *ICACHE_FLASH_ATTR max_expand (MatchState *ms, const char *s,
|
static const char *max_expand (MatchState *ms, const char *s,
|
||||||
const char *p, const char *ep) {
|
const char *p, const char *ep) {
|
||||||
ptrdiff_t i = 0; /* counts maximum expand for item */
|
ptrdiff_t i = 0; /* counts maximum expand for item */
|
||||||
while ((s+i)<ms->src_end && singlematch(uchar(*(s+i)), p, ep))
|
while ((s+i)<ms->src_end && singlematch(uchar(*(s+i)), p, ep))
|
||||||
@ -313,7 +313,7 @@ static const char *ICACHE_FLASH_ATTR max_expand (MatchState *ms, const char *s,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static const char *ICACHE_FLASH_ATTR min_expand (MatchState *ms, const char *s,
|
static const char *min_expand (MatchState *ms, const char *s,
|
||||||
const char *p, const char *ep) {
|
const char *p, const char *ep) {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
const char *res = match(ms, s, ep+1);
|
const char *res = match(ms, s, ep+1);
|
||||||
@ -326,7 +326,7 @@ static const char *ICACHE_FLASH_ATTR min_expand (MatchState *ms, const char *s,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static const char *ICACHE_FLASH_ATTR start_capture (MatchState *ms, const char *s,
|
static const char *start_capture (MatchState *ms, const char *s,
|
||||||
const char *p, int what) {
|
const char *p, int what) {
|
||||||
const char *res;
|
const char *res;
|
||||||
int level = ms->level;
|
int level = ms->level;
|
||||||
@ -340,7 +340,7 @@ static const char *ICACHE_FLASH_ATTR start_capture (MatchState *ms, const char *
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static const char *ICACHE_FLASH_ATTR end_capture (MatchState *ms, const char *s,
|
static const char *end_capture (MatchState *ms, const char *s,
|
||||||
const char *p) {
|
const char *p) {
|
||||||
int l = capture_to_close(ms);
|
int l = capture_to_close(ms);
|
||||||
const char *res;
|
const char *res;
|
||||||
@ -351,7 +351,7 @@ static const char *ICACHE_FLASH_ATTR end_capture (MatchState *ms, const char *s,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static const char *ICACHE_FLASH_ATTR match_capture (MatchState *ms, const char *s, int l) {
|
static const char *match_capture (MatchState *ms, const char *s, int l) {
|
||||||
size_t len;
|
size_t len;
|
||||||
l = check_capture(ms, l);
|
l = check_capture(ms, l);
|
||||||
len = ms->capture[l].len;
|
len = ms->capture[l].len;
|
||||||
@ -362,7 +362,7 @@ static const char *ICACHE_FLASH_ATTR match_capture (MatchState *ms, const char *
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static const char *ICACHE_FLASH_ATTR match (MatchState *ms, const char *s, const char *p) {
|
static const char *match (MatchState *ms, const char *s, const char *p) {
|
||||||
init: /* using goto's to optimize tail recursion */
|
init: /* using goto's to optimize tail recursion */
|
||||||
switch (*p) {
|
switch (*p) {
|
||||||
case '(': { /* start capture */
|
case '(': { /* start capture */
|
||||||
@ -441,7 +441,7 @@ static const char *ICACHE_FLASH_ATTR match (MatchState *ms, const char *s, const
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static const char *ICACHE_FLASH_ATTR lmemfind (const char *s1, size_t l1,
|
static const char *lmemfind (const char *s1, size_t l1,
|
||||||
const char *s2, size_t l2) {
|
const char *s2, size_t l2) {
|
||||||
if (l2 == 0) return s1; /* empty strings are everywhere */
|
if (l2 == 0) return s1; /* empty strings are everywhere */
|
||||||
else if (l2 > l1) return NULL; /* avoids a negative `l1' */
|
else if (l2 > l1) return NULL; /* avoids a negative `l1' */
|
||||||
@ -463,7 +463,7 @@ static const char *ICACHE_FLASH_ATTR lmemfind (const char *s1, size_t l1,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR push_onecapture (MatchState *ms, int i, const char *s,
|
static void push_onecapture (MatchState *ms, int i, const char *s,
|
||||||
const char *e) {
|
const char *e) {
|
||||||
if (i >= ms->level) {
|
if (i >= ms->level) {
|
||||||
if (i == 0) /* ms->level == 0, too */
|
if (i == 0) /* ms->level == 0, too */
|
||||||
@ -482,7 +482,7 @@ static void ICACHE_FLASH_ATTR push_onecapture (MatchState *ms, int i, const char
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR push_captures (MatchState *ms, const char *s, const char *e) {
|
static int push_captures (MatchState *ms, const char *s, const char *e) {
|
||||||
int i;
|
int i;
|
||||||
int nlevels = (ms->level == 0 && s) ? 1 : ms->level;
|
int nlevels = (ms->level == 0 && s) ? 1 : ms->level;
|
||||||
luaL_checkstack(ms->L, nlevels, "too many captures");
|
luaL_checkstack(ms->L, nlevels, "too many captures");
|
||||||
@ -492,7 +492,7 @@ static int ICACHE_FLASH_ATTR push_captures (MatchState *ms, const char *s, const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR str_find_aux (lua_State *L, int find) {
|
static int str_find_aux (lua_State *L, int find) {
|
||||||
size_t l1, l2;
|
size_t l1, l2;
|
||||||
const char *s = luaL_checklstring(L, 1, &l1);
|
const char *s = luaL_checklstring(L, 1, &l1);
|
||||||
const char *p = luaL_checklstring(L, 2, &l2);
|
const char *p = luaL_checklstring(L, 2, &l2);
|
||||||
@ -535,17 +535,17 @@ static int ICACHE_FLASH_ATTR str_find_aux (lua_State *L, int find) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR str_find (lua_State *L) {
|
static int str_find (lua_State *L) {
|
||||||
return str_find_aux(L, 1);
|
return str_find_aux(L, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR str_match (lua_State *L) {
|
static int str_match (lua_State *L) {
|
||||||
return str_find_aux(L, 0);
|
return str_find_aux(L, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR gmatch_aux (lua_State *L) {
|
static int gmatch_aux (lua_State *L) {
|
||||||
MatchState ms;
|
MatchState ms;
|
||||||
size_t ls;
|
size_t ls;
|
||||||
const char *s = lua_tolstring(L, lua_upvalueindex(1), &ls);
|
const char *s = lua_tolstring(L, lua_upvalueindex(1), &ls);
|
||||||
@ -571,7 +571,7 @@ static int ICACHE_FLASH_ATTR gmatch_aux (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR gmatch (lua_State *L) {
|
static int gmatch (lua_State *L) {
|
||||||
luaL_checkstring(L, 1);
|
luaL_checkstring(L, 1);
|
||||||
luaL_checkstring(L, 2);
|
luaL_checkstring(L, 2);
|
||||||
lua_settop(L, 2);
|
lua_settop(L, 2);
|
||||||
@ -581,13 +581,13 @@ static int ICACHE_FLASH_ATTR gmatch (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if LUA_OPTIMIZE_MEMORY == 0 || !defined(LUA_COMPAT_GFIND)
|
#if LUA_OPTIMIZE_MEMORY == 0 || !defined(LUA_COMPAT_GFIND)
|
||||||
static int ICACHE_FLASH_ATTR gfind_nodef (lua_State *L) {
|
static int gfind_nodef (lua_State *L) {
|
||||||
return luaL_error(L, LUA_QL("string.gfind") " was renamed to "
|
return luaL_error(L, LUA_QL("string.gfind") " was renamed to "
|
||||||
LUA_QL("string.gmatch"));
|
LUA_QL("string.gmatch"));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR add_s (MatchState *ms, luaL_Buffer *b, const char *s,
|
static void add_s (MatchState *ms, luaL_Buffer *b, const char *s,
|
||||||
const char *e) {
|
const char *e) {
|
||||||
size_t l, i;
|
size_t l, i;
|
||||||
const char *news = lua_tolstring(ms->L, 3, &l);
|
const char *news = lua_tolstring(ms->L, 3, &l);
|
||||||
@ -609,7 +609,7 @@ static void ICACHE_FLASH_ATTR add_s (MatchState *ms, luaL_Buffer *b, const char
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR add_value (MatchState *ms, luaL_Buffer *b, const char *s,
|
static void add_value (MatchState *ms, luaL_Buffer *b, const char *s,
|
||||||
const char *e) {
|
const char *e) {
|
||||||
lua_State *L = ms->L;
|
lua_State *L = ms->L;
|
||||||
switch (lua_type(L, 3)) {
|
switch (lua_type(L, 3)) {
|
||||||
@ -642,7 +642,7 @@ static void ICACHE_FLASH_ATTR add_value (MatchState *ms, luaL_Buffer *b, const c
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR str_gsub (lua_State *L) {
|
static int str_gsub (lua_State *L) {
|
||||||
size_t srcl;
|
size_t srcl;
|
||||||
const char *src = luaL_checklstring(L, 1, &srcl);
|
const char *src = luaL_checklstring(L, 1, &srcl);
|
||||||
const char *p = luaL_checkstring(L, 2);
|
const char *p = luaL_checkstring(L, 2);
|
||||||
@ -696,7 +696,7 @@ static int ICACHE_FLASH_ATTR str_gsub (lua_State *L) {
|
|||||||
#define MAX_FORMAT (sizeof(FLAGS) + sizeof(LUA_INTFRMLEN) + 10)
|
#define MAX_FORMAT (sizeof(FLAGS) + sizeof(LUA_INTFRMLEN) + 10)
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR addquoted (lua_State *L, luaL_Buffer *b, int arg) {
|
static void addquoted (lua_State *L, luaL_Buffer *b, int arg) {
|
||||||
size_t l;
|
size_t l;
|
||||||
const char *s = luaL_checklstring(L, arg, &l);
|
const char *s = luaL_checklstring(L, arg, &l);
|
||||||
luaL_addchar(b, '"');
|
luaL_addchar(b, '"');
|
||||||
@ -725,7 +725,7 @@ static void ICACHE_FLASH_ATTR addquoted (lua_State *L, luaL_Buffer *b, int arg)
|
|||||||
luaL_addchar(b, '"');
|
luaL_addchar(b, '"');
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *ICACHE_FLASH_ATTR scanformat (lua_State *L, const char *strfrmt, char *form) {
|
static const char *scanformat (lua_State *L, const char *strfrmt, char *form) {
|
||||||
const char *p = strfrmt;
|
const char *p = strfrmt;
|
||||||
while (*p != '\0' && c_strchr(FLAGS, *p) != NULL) p++; /* skip flags */
|
while (*p != '\0' && c_strchr(FLAGS, *p) != NULL) p++; /* skip flags */
|
||||||
if ((size_t)(p - strfrmt) >= sizeof(FLAGS))
|
if ((size_t)(p - strfrmt) >= sizeof(FLAGS))
|
||||||
@ -747,7 +747,7 @@ static const char *ICACHE_FLASH_ATTR scanformat (lua_State *L, const char *strfr
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR addintlen (char *form) {
|
static void addintlen (char *form) {
|
||||||
size_t l = c_strlen(form);
|
size_t l = c_strlen(form);
|
||||||
char spec = form[l - 1];
|
char spec = form[l - 1];
|
||||||
c_strcpy(form + l - 1, LUA_INTFRMLEN);
|
c_strcpy(form + l - 1, LUA_INTFRMLEN);
|
||||||
@ -756,7 +756,7 @@ static void ICACHE_FLASH_ATTR addintlen (char *form) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR str_format (lua_State *L) {
|
static int str_format (lua_State *L) {
|
||||||
int top = lua_gettop(L);
|
int top = lua_gettop(L);
|
||||||
int arg = 1;
|
int arg = 1;
|
||||||
size_t sfl;
|
size_t sfl;
|
||||||
@ -858,7 +858,7 @@ const LUA_REG_TYPE strlib[] = {
|
|||||||
|
|
||||||
|
|
||||||
#if LUA_OPTIMIZE_MEMORY != 2
|
#if LUA_OPTIMIZE_MEMORY != 2
|
||||||
static void ICACHE_FLASH_ATTR createmetatable (lua_State *L) {
|
static void createmetatable (lua_State *L) {
|
||||||
lua_createtable(L, 0, 1); /* create metatable for strings */
|
lua_createtable(L, 0, 1); /* create metatable for strings */
|
||||||
lua_pushliteral(L, ""); /* dummy string */
|
lua_pushliteral(L, ""); /* dummy string */
|
||||||
lua_pushvalue(L, -2);
|
lua_pushvalue(L, -2);
|
||||||
@ -873,7 +873,7 @@ static void ICACHE_FLASH_ATTR createmetatable (lua_State *L) {
|
|||||||
/*
|
/*
|
||||||
** Open string library
|
** Open string library
|
||||||
*/
|
*/
|
||||||
LUALIB_API int ICACHE_FLASH_ATTR luaopen_string (lua_State *L) {
|
LUALIB_API int luaopen_string (lua_State *L) {
|
||||||
#if LUA_OPTIMIZE_MEMORY == 0
|
#if LUA_OPTIMIZE_MEMORY == 0
|
||||||
luaL_register(L, LUA_STRLIBNAME, strlib);
|
luaL_register(L, LUA_STRLIBNAME, strlib);
|
||||||
#if defined(LUA_COMPAT_GFIND)
|
#if defined(LUA_COMPAT_GFIND)
|
||||||
|
@ -81,7 +81,7 @@ static const Node dummynode_ = {
|
|||||||
/*
|
/*
|
||||||
** hash for lua_Numbers
|
** hash for lua_Numbers
|
||||||
*/
|
*/
|
||||||
static Node *ICACHE_FLASH_ATTR hashnum (const Table *t, lua_Number n) {
|
static Node *hashnum (const Table *t, lua_Number n) {
|
||||||
unsigned int a[numints];
|
unsigned int a[numints];
|
||||||
int i;
|
int i;
|
||||||
if (luai_numeq(n, 0)) /* avoid problems with -0 */
|
if (luai_numeq(n, 0)) /* avoid problems with -0 */
|
||||||
@ -97,7 +97,7 @@ static Node *ICACHE_FLASH_ATTR hashnum (const Table *t, lua_Number n) {
|
|||||||
** returns the `main' position of an element in a table (that is, the index
|
** returns the `main' position of an element in a table (that is, the index
|
||||||
** of its hash value)
|
** of its hash value)
|
||||||
*/
|
*/
|
||||||
static Node *ICACHE_FLASH_ATTR mainposition (const Table *t, const TValue *key) {
|
static Node *mainposition (const Table *t, const TValue *key) {
|
||||||
switch (ttype(key)) {
|
switch (ttype(key)) {
|
||||||
case LUA_TNUMBER:
|
case LUA_TNUMBER:
|
||||||
return hashnum(t, nvalue(key));
|
return hashnum(t, nvalue(key));
|
||||||
@ -119,7 +119,7 @@ static Node *ICACHE_FLASH_ATTR mainposition (const Table *t, const TValue *key)
|
|||||||
** returns the index for `key' if `key' is an appropriate key to live in
|
** returns the index for `key' if `key' is an appropriate key to live in
|
||||||
** the array part of the table, -1 otherwise.
|
** the array part of the table, -1 otherwise.
|
||||||
*/
|
*/
|
||||||
static int ICACHE_FLASH_ATTR arrayindex (const TValue *key) {
|
static int arrayindex (const TValue *key) {
|
||||||
if (ttisnumber(key)) {
|
if (ttisnumber(key)) {
|
||||||
lua_Number n = nvalue(key);
|
lua_Number n = nvalue(key);
|
||||||
int k;
|
int k;
|
||||||
@ -136,7 +136,7 @@ static int ICACHE_FLASH_ATTR arrayindex (const TValue *key) {
|
|||||||
** elements in the array part, then elements in the hash part. The
|
** elements in the array part, then elements in the hash part. The
|
||||||
** beginning of a traversal is signalled by -1.
|
** beginning of a traversal is signalled by -1.
|
||||||
*/
|
*/
|
||||||
static int ICACHE_FLASH_ATTR findindex (lua_State *L, Table *t, StkId key) {
|
static int findindex (lua_State *L, Table *t, StkId key) {
|
||||||
int i;
|
int i;
|
||||||
if (ttisnil(key)) return -1; /* first iteration */
|
if (ttisnil(key)) return -1; /* first iteration */
|
||||||
i = arrayindex(key);
|
i = arrayindex(key);
|
||||||
@ -161,7 +161,7 @@ static int ICACHE_FLASH_ATTR findindex (lua_State *L, Table *t, StkId key) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int ICACHE_FLASH_ATTR luaH_next (lua_State *L, Table *t, StkId key) {
|
int luaH_next (lua_State *L, Table *t, StkId key) {
|
||||||
int i = findindex(L, t, key); /* find original element */
|
int i = findindex(L, t, key); /* find original element */
|
||||||
for (i++; i < t->sizearray; i++) { /* try first array part */
|
for (i++; i < t->sizearray; i++) { /* try first array part */
|
||||||
if (!ttisnil(&t->array[i])) { /* a non-nil value? */
|
if (!ttisnil(&t->array[i])) { /* a non-nil value? */
|
||||||
@ -181,7 +181,7 @@ int ICACHE_FLASH_ATTR luaH_next (lua_State *L, Table *t, StkId key) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int ICACHE_FLASH_ATTR luaH_next_ro (lua_State *L, void *t, StkId key) {
|
int luaH_next_ro (lua_State *L, void *t, StkId key) {
|
||||||
luaR_next(L, t, key, key+1);
|
luaR_next(L, t, key, key+1);
|
||||||
return ttisnil(key) ? 0 : 1;
|
return ttisnil(key) ? 0 : 1;
|
||||||
}
|
}
|
||||||
@ -194,7 +194,7 @@ int ICACHE_FLASH_ATTR luaH_next_ro (lua_State *L, void *t, StkId key) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR computesizes (int nums[], int *narray) {
|
static int computesizes (int nums[], int *narray) {
|
||||||
int i;
|
int i;
|
||||||
int twotoi; /* 2^i */
|
int twotoi; /* 2^i */
|
||||||
int a = 0; /* number of elements smaller than 2^i */
|
int a = 0; /* number of elements smaller than 2^i */
|
||||||
@ -216,7 +216,7 @@ static int ICACHE_FLASH_ATTR computesizes (int nums[], int *narray) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR countint (const TValue *key, int *nums) {
|
static int countint (const TValue *key, int *nums) {
|
||||||
int k = arrayindex(key);
|
int k = arrayindex(key);
|
||||||
if (0 < k && k <= MAXASIZE) { /* is `key' an appropriate array index? */
|
if (0 < k && k <= MAXASIZE) { /* is `key' an appropriate array index? */
|
||||||
nums[ceillog2(k)]++; /* count as such */
|
nums[ceillog2(k)]++; /* count as such */
|
||||||
@ -227,7 +227,7 @@ static int ICACHE_FLASH_ATTR countint (const TValue *key, int *nums) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR numusearray (const Table *t, int *nums) {
|
static int numusearray (const Table *t, int *nums) {
|
||||||
int lg;
|
int lg;
|
||||||
int ttlg; /* 2^lg */
|
int ttlg; /* 2^lg */
|
||||||
int ause = 0; /* summation of `nums' */
|
int ause = 0; /* summation of `nums' */
|
||||||
@ -252,7 +252,7 @@ static int ICACHE_FLASH_ATTR numusearray (const Table *t, int *nums) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR numusehash (const Table *t, int *nums, int *pnasize) {
|
static int numusehash (const Table *t, int *nums, int *pnasize) {
|
||||||
int totaluse = 0; /* total number of elements */
|
int totaluse = 0; /* total number of elements */
|
||||||
int ause = 0; /* summation of `nums' */
|
int ause = 0; /* summation of `nums' */
|
||||||
int i = sizenode(t);
|
int i = sizenode(t);
|
||||||
@ -268,7 +268,7 @@ static int ICACHE_FLASH_ATTR numusehash (const Table *t, int *nums, int *pnasize
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR setarrayvector (lua_State *L, Table *t, int size) {
|
static void setarrayvector (lua_State *L, Table *t, int size) {
|
||||||
int i;
|
int i;
|
||||||
luaM_reallocvector(L, t->array, t->sizearray, size, TValue);
|
luaM_reallocvector(L, t->array, t->sizearray, size, TValue);
|
||||||
for (i=t->sizearray; i<size; i++)
|
for (i=t->sizearray; i<size; i++)
|
||||||
@ -277,7 +277,7 @@ static void ICACHE_FLASH_ATTR setarrayvector (lua_State *L, Table *t, int size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Node *ICACHE_FLASH_ATTR getfreepos (Table *t) {
|
static Node *getfreepos (Table *t) {
|
||||||
while (t->lastfree-- > t->node) {
|
while (t->lastfree-- > t->node) {
|
||||||
if (ttisnil(gkey(t->lastfree)))
|
if (ttisnil(gkey(t->lastfree)))
|
||||||
return t->lastfree;
|
return t->lastfree;
|
||||||
@ -286,7 +286,7 @@ static Node *ICACHE_FLASH_ATTR getfreepos (Table *t) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR resizenodevector (lua_State *L, Table *t, int oldsize, int newsize) {
|
static void resizenodevector (lua_State *L, Table *t, int oldsize, int newsize) {
|
||||||
int lsize;
|
int lsize;
|
||||||
if (newsize == 0) { /* no elements to hash part? */
|
if (newsize == 0) { /* no elements to hash part? */
|
||||||
t->node = cast(Node *, dummynode); /* use common `dummynode' */
|
t->node = cast(Node *, dummynode); /* use common `dummynode' */
|
||||||
@ -317,7 +317,7 @@ static void ICACHE_FLASH_ATTR resizenodevector (lua_State *L, Table *t, int olds
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Node *ICACHE_FLASH_ATTR find_prev_node(Node *mp, Node *next) {
|
static Node *find_prev_node(Node *mp, Node *next) {
|
||||||
Node *prev = mp;
|
Node *prev = mp;
|
||||||
while (prev != NULL && gnext(prev) != next) prev = gnext(prev);
|
while (prev != NULL && gnext(prev) != next) prev = gnext(prev);
|
||||||
return prev;
|
return prev;
|
||||||
@ -331,7 +331,7 @@ static Node *ICACHE_FLASH_ATTR find_prev_node(Node *mp, Node *next) {
|
|||||||
** node to an empty place and put moving node in its main position; otherwise
|
** node to an empty place and put moving node in its main position; otherwise
|
||||||
** (colliding node is in its main position), moving node goes to an empty position.
|
** (colliding node is in its main position), moving node goes to an empty position.
|
||||||
*/
|
*/
|
||||||
static int ICACHE_FLASH_ATTR move_node (lua_State *L, Table *t, Node *node) {
|
static int move_node (lua_State *L, Table *t, Node *node) {
|
||||||
Node *mp = mainposition(t, key2tval(node));
|
Node *mp = mainposition(t, key2tval(node));
|
||||||
/* if node is in it's main position, don't need to move node. */
|
/* if node is in it's main position, don't need to move node. */
|
||||||
if (mp == node) return 1;
|
if (mp == node) return 1;
|
||||||
@ -369,7 +369,7 @@ static int ICACHE_FLASH_ATTR move_node (lua_State *L, Table *t, Node *node) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR move_number (lua_State *L, Table *t, Node *node) {
|
static int move_number (lua_State *L, Table *t, Node *node) {
|
||||||
int key;
|
int key;
|
||||||
lua_Number n = nvalue(key2tval(node));
|
lua_Number n = nvalue(key2tval(node));
|
||||||
lua_number2int(key, n);
|
lua_number2int(key, n);
|
||||||
@ -386,7 +386,7 @@ static int ICACHE_FLASH_ATTR move_number (lua_State *L, Table *t, Node *node) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR resize_hashpart (lua_State *L, Table *t, int nhsize) {
|
static void resize_hashpart (lua_State *L, Table *t, int nhsize) {
|
||||||
int i;
|
int i;
|
||||||
int lsize=0;
|
int lsize=0;
|
||||||
int oldhsize = (t->node != dummynode) ? twoto(t->lsizenode) : 0;
|
int oldhsize = (t->node != dummynode) ? twoto(t->lsizenode) : 0;
|
||||||
@ -439,7 +439,7 @@ static void ICACHE_FLASH_ATTR resize_hashpart (lua_State *L, Table *t, int nhsiz
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR resize (lua_State *L, Table *t, int nasize, int nhsize) {
|
static void resize (lua_State *L, Table *t, int nasize, int nhsize) {
|
||||||
int i;
|
int i;
|
||||||
int oldasize = t->sizearray;
|
int oldasize = t->sizearray;
|
||||||
if (nasize > oldasize) /* array part must grow? */
|
if (nasize > oldasize) /* array part must grow? */
|
||||||
@ -458,13 +458,13 @@ static void ICACHE_FLASH_ATTR resize (lua_State *L, Table *t, int nasize, int nh
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR luaH_resizearray (lua_State *L, Table *t, int nasize) {
|
void luaH_resizearray (lua_State *L, Table *t, int nasize) {
|
||||||
int nsize = (t->node == dummynode) ? 0 : sizenode(t);
|
int nsize = (t->node == dummynode) ? 0 : sizenode(t);
|
||||||
resize(L, t, nasize, nsize);
|
resize(L, t, nasize, nsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR rehash (lua_State *L, Table *t, const TValue *ek) {
|
static void rehash (lua_State *L, Table *t, const TValue *ek) {
|
||||||
int nasize, na;
|
int nasize, na;
|
||||||
int nums[MAXBITS+1]; /* nums[i] = number of keys between 2^(i-1) and 2^i */
|
int nums[MAXBITS+1]; /* nums[i] = number of keys between 2^(i-1) and 2^i */
|
||||||
int i;
|
int i;
|
||||||
@ -489,7 +489,7 @@ static void ICACHE_FLASH_ATTR rehash (lua_State *L, Table *t, const TValue *ek)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
Table *ICACHE_FLASH_ATTR luaH_new (lua_State *L, int narray, int nhash) {
|
Table *luaH_new (lua_State *L, int narray, int nhash) {
|
||||||
Table *t = luaM_new(L, Table);
|
Table *t = luaM_new(L, Table);
|
||||||
luaC_link(L, obj2gco(t), LUA_TTABLE);
|
luaC_link(L, obj2gco(t), LUA_TTABLE);
|
||||||
sethvalue2s(L, L->top, t); /* put table on stack */
|
sethvalue2s(L, L->top, t); /* put table on stack */
|
||||||
@ -508,7 +508,7 @@ Table *ICACHE_FLASH_ATTR luaH_new (lua_State *L, int narray, int nhash) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR luaH_free (lua_State *L, Table *t) {
|
void luaH_free (lua_State *L, Table *t) {
|
||||||
if (t->node != dummynode)
|
if (t->node != dummynode)
|
||||||
luaM_freearray(L, t->node, sizenode(t), Node);
|
luaM_freearray(L, t->node, sizenode(t), Node);
|
||||||
luaM_freearray(L, t->array, t->sizearray, TValue);
|
luaM_freearray(L, t->array, t->sizearray, TValue);
|
||||||
@ -524,7 +524,7 @@ void ICACHE_FLASH_ATTR luaH_free (lua_State *L, Table *t) {
|
|||||||
** put new key in its main position; otherwise (colliding node is in its main
|
** put new key in its main position; otherwise (colliding node is in its main
|
||||||
** position), new key goes to an empty position.
|
** position), new key goes to an empty position.
|
||||||
*/
|
*/
|
||||||
static TValue *ICACHE_FLASH_ATTR newkey (lua_State *L, Table *t, const TValue *key) {
|
static TValue *newkey (lua_State *L, Table *t, const TValue *key) {
|
||||||
Node *mp = mainposition(t, key);
|
Node *mp = mainposition(t, key);
|
||||||
if (!ttisnil(gval(mp)) || mp == dummynode) {
|
if (!ttisnil(gval(mp)) || mp == dummynode) {
|
||||||
Node *othern;
|
Node *othern;
|
||||||
@ -560,7 +560,7 @@ static TValue *ICACHE_FLASH_ATTR newkey (lua_State *L, Table *t, const TValue *k
|
|||||||
/*
|
/*
|
||||||
** search function for integers
|
** search function for integers
|
||||||
*/
|
*/
|
||||||
const TValue *ICACHE_FLASH_ATTR luaH_getnum (Table *t, int key) {
|
const TValue *luaH_getnum (Table *t, int key) {
|
||||||
/* (1 <= key && key <= t->sizearray) */
|
/* (1 <= key && key <= t->sizearray) */
|
||||||
if (cast(unsigned int, key-1) < cast(unsigned int, t->sizearray))
|
if (cast(unsigned int, key-1) < cast(unsigned int, t->sizearray))
|
||||||
return &t->array[key-1];
|
return &t->array[key-1];
|
||||||
@ -577,7 +577,7 @@ const TValue *ICACHE_FLASH_ATTR luaH_getnum (Table *t, int key) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* same thing for rotables */
|
/* same thing for rotables */
|
||||||
const TValue *ICACHE_FLASH_ATTR luaH_getnum_ro (void *t, int key) {
|
const TValue *luaH_getnum_ro (void *t, int key) {
|
||||||
const TValue *res = luaR_findentry(t, NULL, key, NULL);
|
const TValue *res = luaR_findentry(t, NULL, key, NULL);
|
||||||
return res ? res : luaO_nilobject;
|
return res ? res : luaO_nilobject;
|
||||||
}
|
}
|
||||||
@ -586,7 +586,7 @@ const TValue *ICACHE_FLASH_ATTR luaH_getnum_ro (void *t, int key) {
|
|||||||
/*
|
/*
|
||||||
** search function for strings
|
** search function for strings
|
||||||
*/
|
*/
|
||||||
const TValue *ICACHE_FLASH_ATTR luaH_getstr (Table *t, TString *key) {
|
const TValue *luaH_getstr (Table *t, TString *key) {
|
||||||
Node *n = hashstr(t, key);
|
Node *n = hashstr(t, key);
|
||||||
do { /* check whether `key' is somewhere in the chain */
|
do { /* check whether `key' is somewhere in the chain */
|
||||||
if (ttisstring(gkey(n)) && rawtsvalue(gkey(n)) == key)
|
if (ttisstring(gkey(n)) && rawtsvalue(gkey(n)) == key)
|
||||||
@ -597,7 +597,7 @@ const TValue *ICACHE_FLASH_ATTR luaH_getstr (Table *t, TString *key) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* same thing for rotables */
|
/* same thing for rotables */
|
||||||
const TValue *ICACHE_FLASH_ATTR luaH_getstr_ro (void *t, TString *key) {
|
const TValue *luaH_getstr_ro (void *t, TString *key) {
|
||||||
char keyname[LUA_MAX_ROTABLE_NAME + 1];
|
char keyname[LUA_MAX_ROTABLE_NAME + 1];
|
||||||
const TValue *res;
|
const TValue *res;
|
||||||
if (!t)
|
if (!t)
|
||||||
@ -611,7 +611,7 @@ const TValue *ICACHE_FLASH_ATTR luaH_getstr_ro (void *t, TString *key) {
|
|||||||
/*
|
/*
|
||||||
** main search function
|
** main search function
|
||||||
*/
|
*/
|
||||||
const TValue *ICACHE_FLASH_ATTR luaH_get (Table *t, const TValue *key) {
|
const TValue *luaH_get (Table *t, const TValue *key) {
|
||||||
switch (ttype(key)) {
|
switch (ttype(key)) {
|
||||||
case LUA_TNIL: return luaO_nilobject;
|
case LUA_TNIL: return luaO_nilobject;
|
||||||
case LUA_TSTRING: return luaH_getstr(t, rawtsvalue(key));
|
case LUA_TSTRING: return luaH_getstr(t, rawtsvalue(key));
|
||||||
@ -636,7 +636,7 @@ const TValue *ICACHE_FLASH_ATTR luaH_get (Table *t, const TValue *key) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* same thing for rotables */
|
/* same thing for rotables */
|
||||||
const TValue *ICACHE_FLASH_ATTR luaH_get_ro (void *t, const TValue *key) {
|
const TValue *luaH_get_ro (void *t, const TValue *key) {
|
||||||
switch (ttype(key)) {
|
switch (ttype(key)) {
|
||||||
case LUA_TNIL: return luaO_nilobject;
|
case LUA_TNIL: return luaO_nilobject;
|
||||||
case LUA_TSTRING: return luaH_getstr_ro(t, rawtsvalue(key));
|
case LUA_TSTRING: return luaH_getstr_ro(t, rawtsvalue(key));
|
||||||
@ -655,7 +655,7 @@ const TValue *ICACHE_FLASH_ATTR luaH_get_ro (void *t, const TValue *key) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TValue *ICACHE_FLASH_ATTR luaH_set (lua_State *L, Table *t, const TValue *key) {
|
TValue *luaH_set (lua_State *L, Table *t, const TValue *key) {
|
||||||
const TValue *p = luaH_get(t, key);
|
const TValue *p = luaH_get(t, key);
|
||||||
t->flags = 0;
|
t->flags = 0;
|
||||||
if (p != luaO_nilobject)
|
if (p != luaO_nilobject)
|
||||||
@ -669,7 +669,7 @@ TValue *ICACHE_FLASH_ATTR luaH_set (lua_State *L, Table *t, const TValue *key) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TValue *ICACHE_FLASH_ATTR luaH_setnum (lua_State *L, Table *t, int key) {
|
TValue *luaH_setnum (lua_State *L, Table *t, int key) {
|
||||||
const TValue *p = luaH_getnum(t, key);
|
const TValue *p = luaH_getnum(t, key);
|
||||||
if (p != luaO_nilobject)
|
if (p != luaO_nilobject)
|
||||||
return cast(TValue *, p);
|
return cast(TValue *, p);
|
||||||
@ -681,7 +681,7 @@ TValue *ICACHE_FLASH_ATTR luaH_setnum (lua_State *L, Table *t, int key) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TValue *ICACHE_FLASH_ATTR luaH_setstr (lua_State *L, Table *t, TString *key) {
|
TValue *luaH_setstr (lua_State *L, Table *t, TString *key) {
|
||||||
const TValue *p = luaH_getstr(t, key);
|
const TValue *p = luaH_getstr(t, key);
|
||||||
if (p != luaO_nilobject)
|
if (p != luaO_nilobject)
|
||||||
return cast(TValue *, p);
|
return cast(TValue *, p);
|
||||||
@ -693,7 +693,7 @@ TValue *ICACHE_FLASH_ATTR luaH_setstr (lua_State *L, Table *t, TString *key) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR unbound_search (Table *t, unsigned int j) {
|
static int unbound_search (Table *t, unsigned int j) {
|
||||||
unsigned int i = j; /* i is zero or a present index */
|
unsigned int i = j; /* i is zero or a present index */
|
||||||
j++;
|
j++;
|
||||||
/* find `i' and `j' such that i is present and j is not */
|
/* find `i' and `j' such that i is present and j is not */
|
||||||
@ -721,7 +721,7 @@ static int ICACHE_FLASH_ATTR unbound_search (Table *t, unsigned int j) {
|
|||||||
** Try to find a boundary in table `t'. A `boundary' is an integer index
|
** Try to find a boundary in table `t'. A `boundary' is an integer index
|
||||||
** such that t[i] is non-nil and t[i+1] is nil (and 0 if t[1] is nil).
|
** such that t[i] is non-nil and t[i+1] is nil (and 0 if t[1] is nil).
|
||||||
*/
|
*/
|
||||||
int ICACHE_FLASH_ATTR luaH_getn (Table *t) {
|
int luaH_getn (Table *t) {
|
||||||
unsigned int j = t->sizearray;
|
unsigned int j = t->sizearray;
|
||||||
if (j > 0 && ttisnil(&t->array[j - 1])) {
|
if (j > 0 && ttisnil(&t->array[j - 1])) {
|
||||||
/* there is a boundary in the array part: (binary) search for it */
|
/* there is a boundary in the array part: (binary) search for it */
|
||||||
@ -740,7 +740,7 @@ int ICACHE_FLASH_ATTR luaH_getn (Table *t) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* same thing for rotables */
|
/* same thing for rotables */
|
||||||
int ICACHE_FLASH_ATTR luaH_getn_ro (void *t) {
|
int luaH_getn_ro (void *t) {
|
||||||
int i = 1, len=0;
|
int i = 1, len=0;
|
||||||
|
|
||||||
while(luaR_findentry(t, NULL, i ++, NULL))
|
while(luaR_findentry(t, NULL, i ++, NULL))
|
||||||
@ -750,10 +750,10 @@ int ICACHE_FLASH_ATTR luaH_getn_ro (void *t) {
|
|||||||
|
|
||||||
#if defined(LUA_DEBUG)
|
#if defined(LUA_DEBUG)
|
||||||
|
|
||||||
Node *ICACHE_FLASH_ATTR luaH_mainposition (const Table *t, const TValue *key) {
|
Node *luaH_mainposition (const Table *t, const TValue *key) {
|
||||||
return mainposition(t, key);
|
return mainposition(t, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ICACHE_FLASH_ATTR luaH_isdummy (Node *n) { return n == dummynode; }
|
int luaH_isdummy (Node *n) { return n == dummynode; }
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#define aux_getn(L,n) (luaL_checktype(L, n, LUA_TTABLE), luaL_getn(L, n))
|
#define aux_getn(L,n) (luaL_checktype(L, n, LUA_TTABLE), luaL_getn(L, n))
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR foreachi (lua_State *L) {
|
static int foreachi (lua_State *L) {
|
||||||
int i;
|
int i;
|
||||||
int n = aux_getn(L, 1);
|
int n = aux_getn(L, 1);
|
||||||
luaL_checkanyfunction(L, 2);
|
luaL_checkanyfunction(L, 2);
|
||||||
@ -37,7 +37,7 @@ static int ICACHE_FLASH_ATTR foreachi (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR foreach (lua_State *L) {
|
static int foreach (lua_State *L) {
|
||||||
luaL_checktype(L, 1, LUA_TTABLE);
|
luaL_checktype(L, 1, LUA_TTABLE);
|
||||||
luaL_checkanyfunction(L, 2);
|
luaL_checkanyfunction(L, 2);
|
||||||
lua_pushnil(L); /* first key */
|
lua_pushnil(L); /* first key */
|
||||||
@ -54,7 +54,7 @@ static int ICACHE_FLASH_ATTR foreach (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR maxn (lua_State *L) {
|
static int maxn (lua_State *L) {
|
||||||
lua_Number max = 0;
|
lua_Number max = 0;
|
||||||
luaL_checktype(L, 1, LUA_TTABLE);
|
luaL_checktype(L, 1, LUA_TTABLE);
|
||||||
lua_pushnil(L); /* first key */
|
lua_pushnil(L); /* first key */
|
||||||
@ -70,13 +70,13 @@ static int ICACHE_FLASH_ATTR maxn (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR getn (lua_State *L) {
|
static int getn (lua_State *L) {
|
||||||
lua_pushinteger(L, aux_getn(L, 1));
|
lua_pushinteger(L, aux_getn(L, 1));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR setn (lua_State *L) {
|
static int setn (lua_State *L) {
|
||||||
luaL_checktype(L, 1, LUA_TTABLE);
|
luaL_checktype(L, 1, LUA_TTABLE);
|
||||||
#ifndef luaL_setn
|
#ifndef luaL_setn
|
||||||
luaL_setn(L, 1, luaL_checkint(L, 2));
|
luaL_setn(L, 1, luaL_checkint(L, 2));
|
||||||
@ -88,7 +88,7 @@ static int ICACHE_FLASH_ATTR setn (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR tinsert (lua_State *L) {
|
static int tinsert (lua_State *L) {
|
||||||
int e = aux_getn(L, 1) + 1; /* first empty element */
|
int e = aux_getn(L, 1) + 1; /* first empty element */
|
||||||
int pos; /* where to insert new element */
|
int pos; /* where to insert new element */
|
||||||
switch (lua_gettop(L)) {
|
switch (lua_gettop(L)) {
|
||||||
@ -116,7 +116,7 @@ static int ICACHE_FLASH_ATTR tinsert (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR tremove (lua_State *L) {
|
static int tremove (lua_State *L) {
|
||||||
int e = aux_getn(L, 1);
|
int e = aux_getn(L, 1);
|
||||||
int pos = luaL_optint(L, 2, e);
|
int pos = luaL_optint(L, 2, e);
|
||||||
if (!(1 <= pos && pos <= e)) /* position is outside bounds? */
|
if (!(1 <= pos && pos <= e)) /* position is outside bounds? */
|
||||||
@ -133,7 +133,7 @@ static int ICACHE_FLASH_ATTR tremove (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR addfield (lua_State *L, luaL_Buffer *b, int i) {
|
static void addfield (lua_State *L, luaL_Buffer *b, int i) {
|
||||||
lua_rawgeti(L, 1, i);
|
lua_rawgeti(L, 1, i);
|
||||||
if (!lua_isstring(L, -1))
|
if (!lua_isstring(L, -1))
|
||||||
luaL_error(L, "invalid value (%s) at index %d in table for "
|
luaL_error(L, "invalid value (%s) at index %d in table for "
|
||||||
@ -142,7 +142,7 @@ static void ICACHE_FLASH_ATTR addfield (lua_State *L, luaL_Buffer *b, int i) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR tconcat (lua_State *L) {
|
static int tconcat (lua_State *L) {
|
||||||
luaL_Buffer b;
|
luaL_Buffer b;
|
||||||
size_t lsep;
|
size_t lsep;
|
||||||
int i, last;
|
int i, last;
|
||||||
@ -171,12 +171,12 @@ static int ICACHE_FLASH_ATTR tconcat (lua_State *L) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR set2 (lua_State *L, int i, int j) {
|
static void set2 (lua_State *L, int i, int j) {
|
||||||
lua_rawseti(L, 1, i);
|
lua_rawseti(L, 1, i);
|
||||||
lua_rawseti(L, 1, j);
|
lua_rawseti(L, 1, j);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR sort_comp (lua_State *L, int a, int b) {
|
static int sort_comp (lua_State *L, int a, int b) {
|
||||||
if (!lua_isnil(L, 2)) { /* function? */
|
if (!lua_isnil(L, 2)) { /* function? */
|
||||||
int res;
|
int res;
|
||||||
lua_pushvalue(L, 2);
|
lua_pushvalue(L, 2);
|
||||||
@ -191,7 +191,7 @@ static int ICACHE_FLASH_ATTR sort_comp (lua_State *L, int a, int b) {
|
|||||||
return lua_lessthan(L, a, b);
|
return lua_lessthan(L, a, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR auxsort (lua_State *L, int l, int u) {
|
static void auxsort (lua_State *L, int l, int u) {
|
||||||
while (l < u) { /* for tail recursion */
|
while (l < u) { /* for tail recursion */
|
||||||
int i, j;
|
int i, j;
|
||||||
/* sort elements a[l], a[(l+u)/2] and a[u] */
|
/* sort elements a[l], a[(l+u)/2] and a[u] */
|
||||||
@ -254,7 +254,7 @@ static void ICACHE_FLASH_ATTR auxsort (lua_State *L, int l, int u) {
|
|||||||
} /* repeat the routine for the larger one */
|
} /* repeat the routine for the larger one */
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR sort (lua_State *L) {
|
static int sort (lua_State *L) {
|
||||||
int n = aux_getn(L, 1);
|
int n = aux_getn(L, 1);
|
||||||
luaL_checkstack(L, 40, ""); /* assume array is smaller than 2^40 */
|
luaL_checkstack(L, 40, ""); /* assume array is smaller than 2^40 */
|
||||||
if (!lua_isnoneornil(L, 2)) /* is there a 2nd argument? */
|
if (!lua_isnoneornil(L, 2)) /* is there a 2nd argument? */
|
||||||
@ -282,6 +282,6 @@ const LUA_REG_TYPE tab_funcs[] = {
|
|||||||
{LNILKEY, LNILVAL}
|
{LNILKEY, LNILVAL}
|
||||||
};
|
};
|
||||||
|
|
||||||
LUALIB_API int ICACHE_FLASH_ATTR luaopen_table (lua_State *L) {
|
LUALIB_API int luaopen_table (lua_State *L) {
|
||||||
LREGISTER(L, LUA_TABLIBNAME, tab_funcs);
|
LREGISTER(L, LUA_TABLIBNAME, tab_funcs);
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ const char *const luaT_typenames[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR luaT_init (lua_State *L) {
|
void luaT_init (lua_State *L) {
|
||||||
static const char *const luaT_eventname[] = { /* ORDER TM */
|
static const char *const luaT_eventname[] = { /* ORDER TM */
|
||||||
"__index", "__newindex",
|
"__index", "__newindex",
|
||||||
"__gc", "__mode", "__eq",
|
"__gc", "__mode", "__eq",
|
||||||
@ -48,7 +48,7 @@ void ICACHE_FLASH_ATTR luaT_init (lua_State *L) {
|
|||||||
** function to be used with macro "fasttm": optimized for absence of
|
** function to be used with macro "fasttm": optimized for absence of
|
||||||
** tag methods
|
** tag methods
|
||||||
*/
|
*/
|
||||||
const TValue *ICACHE_FLASH_ATTR luaT_gettm (Table *events, TMS event, TString *ename) {
|
const TValue *luaT_gettm (Table *events, TMS event, TString *ename) {
|
||||||
const TValue *tm = luaR_isrotable(events) ? luaH_getstr_ro(events, ename) : luaH_getstr(events, ename);
|
const TValue *tm = luaR_isrotable(events) ? luaH_getstr_ro(events, ename) : luaH_getstr(events, ename);
|
||||||
lua_assert(event <= TM_EQ);
|
lua_assert(event <= TM_EQ);
|
||||||
if (ttisnil(tm)) { /* no tag method? */
|
if (ttisnil(tm)) { /* no tag method? */
|
||||||
@ -60,7 +60,7 @@ const TValue *ICACHE_FLASH_ATTR luaT_gettm (Table *events, TMS event, TString *e
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const TValue *ICACHE_FLASH_ATTR luaT_gettmbyobj (lua_State *L, const TValue *o, TMS event) {
|
const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, TMS event) {
|
||||||
Table *mt;
|
Table *mt;
|
||||||
switch (ttype(o)) {
|
switch (ttype(o)) {
|
||||||
case LUA_TTABLE:
|
case LUA_TTABLE:
|
||||||
|
@ -35,14 +35,14 @@ int led_high_count = LED_HIGH_COUNT_DEFAULT;
|
|||||||
int led_low_count = LED_LOW_COUNT_DEFAULT;
|
int led_low_count = LED_LOW_COUNT_DEFAULT;
|
||||||
static int led_count = 0;
|
static int led_count = 0;
|
||||||
#if 0
|
#if 0
|
||||||
static void ICACHE_FLASH_ATTR lstop (lua_State *L, lua_Debug *ar) {
|
static void lstop (lua_State *L, lua_Debug *ar) {
|
||||||
(void)ar; /* unused arg. */
|
(void)ar; /* unused arg. */
|
||||||
lua_sethook(L, NULL, 0, 0);
|
lua_sethook(L, NULL, 0, 0);
|
||||||
luaL_error(L, "interrupted!");
|
luaL_error(L, "interrupted!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR laction (int i) {
|
static void laction (int i) {
|
||||||
// signal(i, SIG_DFL);
|
// signal(i, SIG_DFL);
|
||||||
/* if another SIGINT happens before lstop,
|
/* if another SIGINT happens before lstop,
|
||||||
terminate process (default action) */
|
terminate process (default action) */
|
||||||
@ -50,7 +50,7 @@ static void ICACHE_FLASH_ATTR laction (int i) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR print_usage (void) {
|
static void print_usage (void) {
|
||||||
#if defined(LUA_USE_STDIO)
|
#if defined(LUA_USE_STDIO)
|
||||||
c_fprintf(c_stderr,
|
c_fprintf(c_stderr,
|
||||||
#else
|
#else
|
||||||
@ -73,7 +73,7 @@ static void ICACHE_FLASH_ATTR print_usage (void) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR l_message (const char *pname, const char *msg) {
|
static void l_message (const char *pname, const char *msg) {
|
||||||
#if defined(LUA_USE_STDIO)
|
#if defined(LUA_USE_STDIO)
|
||||||
if (pname) c_fprintf(c_stderr, "%s: ", pname);
|
if (pname) c_fprintf(c_stderr, "%s: ", pname);
|
||||||
c_fprintf(c_stderr, "%s\n", msg);
|
c_fprintf(c_stderr, "%s\n", msg);
|
||||||
@ -85,7 +85,7 @@ static void ICACHE_FLASH_ATTR l_message (const char *pname, const char *msg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR report (lua_State *L, int status) {
|
static int report (lua_State *L, int status) {
|
||||||
if (status && !lua_isnil(L, -1)) {
|
if (status && !lua_isnil(L, -1)) {
|
||||||
const char *msg = lua_tostring(L, -1);
|
const char *msg = lua_tostring(L, -1);
|
||||||
if (msg == NULL) msg = "(error object is not a string)";
|
if (msg == NULL) msg = "(error object is not a string)";
|
||||||
@ -96,7 +96,7 @@ static int ICACHE_FLASH_ATTR report (lua_State *L, int status) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR traceback (lua_State *L) {
|
static int traceback (lua_State *L) {
|
||||||
if (!lua_isstring(L, 1)) /* 'message' not a string? */
|
if (!lua_isstring(L, 1)) /* 'message' not a string? */
|
||||||
return 1; /* keep it intact */
|
return 1; /* keep it intact */
|
||||||
lua_getfield(L, LUA_GLOBALSINDEX, "debug");
|
lua_getfield(L, LUA_GLOBALSINDEX, "debug");
|
||||||
@ -116,7 +116,7 @@ static int ICACHE_FLASH_ATTR traceback (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR docall (lua_State *L, int narg, int clear) {
|
static int docall (lua_State *L, int narg, int clear) {
|
||||||
int status;
|
int status;
|
||||||
int base = lua_gettop(L) - narg; /* function index */
|
int base = lua_gettop(L) - narg; /* function index */
|
||||||
lua_pushcfunction(L, traceback); /* push traceback function */
|
lua_pushcfunction(L, traceback); /* push traceback function */
|
||||||
@ -131,13 +131,13 @@ static int ICACHE_FLASH_ATTR docall (lua_State *L, int narg, int clear) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR print_version (void) {
|
static void print_version (void) {
|
||||||
// l_message(NULL, LUA_RELEASE " " LUA_COPYRIGHT);
|
// l_message(NULL, LUA_RELEASE " " LUA_COPYRIGHT);
|
||||||
l_message(NULL, NODE_VERSION " " BUILD_DATE " powered by " LUA_RELEASE);
|
l_message(NULL, NODE_VERSION " " BUILD_DATE " powered by " LUA_RELEASE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR getargs (lua_State *L, char **argv, int n) {
|
static int getargs (lua_State *L, char **argv, int n) {
|
||||||
int narg;
|
int narg;
|
||||||
int i;
|
int i;
|
||||||
int argc = 0;
|
int argc = 0;
|
||||||
@ -155,30 +155,30 @@ static int ICACHE_FLASH_ATTR getargs (lua_State *L, char **argv, int n) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
static int ICACHE_FLASH_ATTR dofile (lua_State *L, const char *name) {
|
static int dofile (lua_State *L, const char *name) {
|
||||||
int status = luaL_loadfile(L, name) || docall(L, 0, 1);
|
int status = luaL_loadfile(L, name) || docall(L, 0, 1);
|
||||||
return report(L, status);
|
return report(L, status);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
static int ICACHE_FLASH_ATTR dofsfile (lua_State *L, const char *name) {
|
static int dofsfile (lua_State *L, const char *name) {
|
||||||
int status = luaL_loadfsfile(L, name) || docall(L, 0, 1);
|
int status = luaL_loadfsfile(L, name) || docall(L, 0, 1);
|
||||||
return report(L, status);
|
return report(L, status);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR dostring (lua_State *L, const char *s, const char *name) {
|
static int dostring (lua_State *L, const char *s, const char *name) {
|
||||||
int status = luaL_loadbuffer(L, s, c_strlen(s), name) || docall(L, 0, 1);
|
int status = luaL_loadbuffer(L, s, c_strlen(s), name) || docall(L, 0, 1);
|
||||||
return report(L, status);
|
return report(L, status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR dolibrary (lua_State *L, const char *name) {
|
static int dolibrary (lua_State *L, const char *name) {
|
||||||
lua_getglobal(L, "require");
|
lua_getglobal(L, "require");
|
||||||
lua_pushstring(L, name);
|
lua_pushstring(L, name);
|
||||||
return report(L, docall(L, 1, 1));
|
return report(L, docall(L, 1, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *ICACHE_FLASH_ATTR get_prompt (lua_State *L, int firstline) {
|
static const char *get_prompt (lua_State *L, int firstline) {
|
||||||
const char *p;
|
const char *p;
|
||||||
lua_getfield(L, LUA_GLOBALSINDEX, firstline ? "_PROMPT" : "_PROMPT2");
|
lua_getfield(L, LUA_GLOBALSINDEX, firstline ? "_PROMPT" : "_PROMPT2");
|
||||||
p = lua_tostring(L, -1);
|
p = lua_tostring(L, -1);
|
||||||
@ -188,7 +188,7 @@ static const char *ICACHE_FLASH_ATTR get_prompt (lua_State *L, int firstline) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR incomplete (lua_State *L, int status) {
|
static int incomplete (lua_State *L, int status) {
|
||||||
if (status == LUA_ERRSYNTAX) {
|
if (status == LUA_ERRSYNTAX) {
|
||||||
size_t lmsg;
|
size_t lmsg;
|
||||||
const char *msg = lua_tolstring(L, -1, &lmsg);
|
const char *msg = lua_tolstring(L, -1, &lmsg);
|
||||||
@ -202,7 +202,7 @@ static int ICACHE_FLASH_ATTR incomplete (lua_State *L, int status) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
static int ICACHE_FLASH_ATTR pushline (lua_State *L, int firstline) {
|
static int pushline (lua_State *L, int firstline) {
|
||||||
char buffer[LUA_MAXINPUT];
|
char buffer[LUA_MAXINPUT];
|
||||||
char *b = buffer;
|
char *b = buffer;
|
||||||
size_t l;
|
size_t l;
|
||||||
@ -221,7 +221,7 @@ static int ICACHE_FLASH_ATTR pushline (lua_State *L, int firstline) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR loadline (lua_State *L) {
|
static int loadline (lua_State *L) {
|
||||||
int status;
|
int status;
|
||||||
lua_settop(L, 0);
|
lua_settop(L, 0);
|
||||||
if (!pushline(L, 1))
|
if (!pushline(L, 1))
|
||||||
@ -241,7 +241,7 @@ static int ICACHE_FLASH_ATTR loadline (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR dotty (lua_State *L) {
|
static void dotty (lua_State *L) {
|
||||||
int status;
|
int status;
|
||||||
const char *oldprogname = progname;
|
const char *oldprogname = progname;
|
||||||
progname = NULL;
|
progname = NULL;
|
||||||
@ -270,7 +270,7 @@ static void ICACHE_FLASH_ATTR dotty (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR handle_script (lua_State *L, char **argv, int n) {
|
static int handle_script (lua_State *L, char **argv, int n) {
|
||||||
int status;
|
int status;
|
||||||
const char *fname;
|
const char *fname;
|
||||||
int narg = getargs(L, argv, n); /* collect arguments */
|
int narg = getargs(L, argv, n); /* collect arguments */
|
||||||
@ -292,7 +292,7 @@ static int ICACHE_FLASH_ATTR handle_script (lua_State *L, char **argv, int n) {
|
|||||||
#define notail(x) {if ((x)[2] != '\0') return -1;}
|
#define notail(x) {if ((x)[2] != '\0') return -1;}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR collectargs (char **argv, int *pi, int *pv, int *pe) {
|
static int collectargs (char **argv, int *pi, int *pv, int *pe) {
|
||||||
int i;
|
int i;
|
||||||
for (i = 1; argv[i] != NULL; i++) {
|
for (i = 1; argv[i] != NULL; i++) {
|
||||||
if (argv[i][0] != '-') /* not an option? */
|
if (argv[i][0] != '-') /* not an option? */
|
||||||
@ -326,7 +326,7 @@ static int ICACHE_FLASH_ATTR collectargs (char **argv, int *pi, int *pv, int *pe
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR runargs (lua_State *L, char **argv, int n) {
|
static int runargs (lua_State *L, char **argv, int n) {
|
||||||
int i;
|
int i;
|
||||||
for (i = 1; i < n; i++) {
|
for (i = 1; i < n; i++) {
|
||||||
if (argv[i] == NULL) continue;
|
if (argv[i] == NULL) continue;
|
||||||
@ -364,7 +364,7 @@ static int ICACHE_FLASH_ATTR runargs (lua_State *L, char **argv, int n) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR handle_luainit (lua_State *L) {
|
static int handle_luainit (lua_State *L) {
|
||||||
const char *init = c_getenv(LUA_INIT);
|
const char *init = c_getenv(LUA_INIT);
|
||||||
if (init == NULL) return 0; /* status OK */
|
if (init == NULL) return 0; /* status OK */
|
||||||
else if (init[0] == '@')
|
else if (init[0] == '@')
|
||||||
@ -385,7 +385,7 @@ struct Smain {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR pmain (lua_State *L) {
|
static int pmain (lua_State *L) {
|
||||||
struct Smain *s = (struct Smain *)lua_touserdata(L, 1);
|
struct Smain *s = (struct Smain *)lua_touserdata(L, 1);
|
||||||
char **argv = s->argv;
|
char **argv = s->argv;
|
||||||
int script;
|
int script;
|
||||||
@ -433,9 +433,9 @@ void readline(lua_Load *load);
|
|||||||
char line_buffer[LUA_MAXINPUT];
|
char line_buffer[LUA_MAXINPUT];
|
||||||
|
|
||||||
#ifdef LUA_RPC
|
#ifdef LUA_RPC
|
||||||
int ICACHE_FLASH_ATTR main (int argc, char **argv) {
|
int main (int argc, char **argv) {
|
||||||
#else
|
#else
|
||||||
int ICACHE_FLASH_ATTR lua_main (int argc, char **argv) {
|
int lua_main (int argc, char **argv) {
|
||||||
#endif
|
#endif
|
||||||
int status;
|
int status;
|
||||||
struct Smain s;
|
struct Smain s;
|
||||||
@ -469,7 +469,7 @@ int ICACHE_FLASH_ATTR lua_main (int argc, char **argv) {
|
|||||||
return (status || s.status) ? EXIT_FAILURE : EXIT_SUCCESS;
|
return (status || s.status) ? EXIT_FAILURE : EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR donejob(lua_Load *load){
|
void donejob(lua_Load *load){
|
||||||
lua_close(load->L);
|
lua_close(load->L);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -478,7 +478,7 @@ int log_fd = -1;
|
|||||||
int noparse = 0;
|
int noparse = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR dojob(lua_Load *load){
|
void dojob(lua_Load *load){
|
||||||
size_t l, rs;
|
size_t l, rs;
|
||||||
int status;
|
int status;
|
||||||
char *b = load->line;
|
char *b = load->line;
|
||||||
@ -545,7 +545,7 @@ extern void key_long_press(void *arg);
|
|||||||
extern void key_short_press(void *arg);
|
extern void key_short_press(void *arg);
|
||||||
static bool key_short_pressed = false;
|
static bool key_short_pressed = false;
|
||||||
static bool key_long_pressed = false;
|
static bool key_long_pressed = false;
|
||||||
void ICACHE_FLASH_ATTR update_key_led(){
|
void update_key_led(){
|
||||||
uint8_t temp = 1, level = 1;
|
uint8_t temp = 1, level = 1;
|
||||||
led_count++;
|
led_count++;
|
||||||
if(led_count>led_low_count+led_high_count){
|
if(led_count>led_low_count+led_high_count){
|
||||||
@ -588,7 +588,7 @@ extern bool uart0_echo;
|
|||||||
extern bool run_input;
|
extern bool run_input;
|
||||||
extern uint16_t need_len;
|
extern uint16_t need_len;
|
||||||
extern int16_t end_char;
|
extern int16_t end_char;
|
||||||
void ICACHE_FLASH_ATTR readline(lua_Load *load){
|
void readline(lua_Load *load){
|
||||||
// NODE_DBG("readline() is called.\n");
|
// NODE_DBG("readline() is called.\n");
|
||||||
update_key_led();
|
update_key_led();
|
||||||
char ch;
|
char ch;
|
||||||
|
@ -37,7 +37,7 @@ typedef struct {
|
|||||||
#else
|
#else
|
||||||
#define IF(c,s) if (c) error(S,s)
|
#define IF(c,s) if (c) error(S,s)
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR error(LoadState* S, const char* why)
|
static void error(LoadState* S, const char* why)
|
||||||
{
|
{
|
||||||
luaO_pushfstring(S->L,"%s: %s in precompiled chunk",S->name,why);
|
luaO_pushfstring(S->L,"%s: %s in precompiled chunk",S->name,why);
|
||||||
luaD_throw(S->L,LUA_ERRSYNTAX);
|
luaD_throw(S->L,LUA_ERRSYNTAX);
|
||||||
@ -48,14 +48,14 @@ static void ICACHE_FLASH_ATTR error(LoadState* S, const char* why)
|
|||||||
#define LoadVar(S,x) LoadMem(S,&x,1,sizeof(x))
|
#define LoadVar(S,x) LoadMem(S,&x,1,sizeof(x))
|
||||||
#define LoadVector(S,b,n,size) LoadMem(S,b,n,size)
|
#define LoadVector(S,b,n,size) LoadMem(S,b,n,size)
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR LoadBlock(LoadState* S, void* b, size_t size)
|
static void LoadBlock(LoadState* S, void* b, size_t size)
|
||||||
{
|
{
|
||||||
size_t r=luaZ_read(S->Z,b,size);
|
size_t r=luaZ_read(S->Z,b,size);
|
||||||
IF (r!=0, "unexpected end");
|
IF (r!=0, "unexpected end");
|
||||||
S->total+=size;
|
S->total+=size;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR LoadMem (LoadState* S, void* b, int n, size_t size)
|
static void LoadMem (LoadState* S, void* b, int n, size_t size)
|
||||||
{
|
{
|
||||||
LoadBlock(S,b,n*size);
|
LoadBlock(S,b,n*size);
|
||||||
if (S->swap && b)
|
if (S->swap && b)
|
||||||
@ -98,20 +98,20 @@ static void ICACHE_FLASH_ATTR LoadMem (LoadState* S, void* b, int n, size_t size
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR LoadChar(LoadState* S)
|
static int LoadChar(LoadState* S)
|
||||||
{
|
{
|
||||||
char x;
|
char x;
|
||||||
LoadVar(S,x);
|
LoadVar(S,x);
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR Align4(LoadState* S)
|
static void Align4(LoadState* S)
|
||||||
{
|
{
|
||||||
while(S->total&3)
|
while(S->total&3)
|
||||||
LoadChar(S);
|
LoadChar(S);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR LoadInt(LoadState* S)
|
static int LoadInt(LoadState* S)
|
||||||
{
|
{
|
||||||
int x;
|
int x;
|
||||||
LoadVar(S,x);
|
LoadVar(S,x);
|
||||||
@ -119,7 +119,7 @@ static int ICACHE_FLASH_ATTR LoadInt(LoadState* S)
|
|||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
static lua_Number ICACHE_FLASH_ATTR LoadNumber(LoadState* S)
|
static lua_Number LoadNumber(LoadState* S)
|
||||||
{
|
{
|
||||||
lua_Number x;
|
lua_Number x;
|
||||||
if(S->toflt)
|
if(S->toflt)
|
||||||
@ -158,7 +158,7 @@ static lua_Number ICACHE_FLASH_ATTR LoadNumber(LoadState* S)
|
|||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
static TString* ICACHE_FLASH_ATTR LoadString(LoadState* S)
|
static TString* LoadString(LoadState* S)
|
||||||
{
|
{
|
||||||
int32_t size;
|
int32_t size;
|
||||||
LoadVar(S,size);
|
LoadVar(S,size);
|
||||||
@ -179,7 +179,7 @@ static TString* ICACHE_FLASH_ATTR LoadString(LoadState* S)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR LoadCode(LoadState* S, Proto* f)
|
static void LoadCode(LoadState* S, Proto* f)
|
||||||
{
|
{
|
||||||
int n=LoadInt(S);
|
int n=LoadInt(S);
|
||||||
Align4(S);
|
Align4(S);
|
||||||
@ -195,7 +195,7 @@ static void ICACHE_FLASH_ATTR LoadCode(LoadState* S, Proto* f)
|
|||||||
|
|
||||||
static Proto* LoadFunction(LoadState* S, TString* p);
|
static Proto* LoadFunction(LoadState* S, TString* p);
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR LoadConstants(LoadState* S, Proto* f)
|
static void LoadConstants(LoadState* S, Proto* f)
|
||||||
{
|
{
|
||||||
int i,n;
|
int i,n;
|
||||||
n=LoadInt(S);
|
n=LoadInt(S);
|
||||||
@ -232,7 +232,7 @@ static void ICACHE_FLASH_ATTR LoadConstants(LoadState* S, Proto* f)
|
|||||||
for (i=0; i<n; i++) f->p[i]=LoadFunction(S,f->source);
|
for (i=0; i<n; i++) f->p[i]=LoadFunction(S,f->source);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR LoadDebug(LoadState* S, Proto* f)
|
static void LoadDebug(LoadState* S, Proto* f)
|
||||||
{
|
{
|
||||||
int i,n;
|
int i,n;
|
||||||
n=LoadInt(S);
|
n=LoadInt(S);
|
||||||
@ -262,7 +262,7 @@ static void ICACHE_FLASH_ATTR LoadDebug(LoadState* S, Proto* f)
|
|||||||
for (i=0; i<n; i++) f->upvalues[i]=LoadString(S);
|
for (i=0; i<n; i++) f->upvalues[i]=LoadString(S);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Proto* ICACHE_FLASH_ATTR LoadFunction(LoadState* S, TString* p)
|
static Proto* LoadFunction(LoadState* S, TString* p)
|
||||||
{
|
{
|
||||||
Proto* f;
|
Proto* f;
|
||||||
if (++S->L->nCcalls > LUAI_MAXCCALLS) error(S,"code too deep");
|
if (++S->L->nCcalls > LUAI_MAXCCALLS) error(S,"code too deep");
|
||||||
@ -285,7 +285,7 @@ static Proto* ICACHE_FLASH_ATTR LoadFunction(LoadState* S, TString* p)
|
|||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR LoadHeader(LoadState* S)
|
static void LoadHeader(LoadState* S)
|
||||||
{
|
{
|
||||||
char h[LUAC_HEADERSIZE];
|
char h[LUAC_HEADERSIZE];
|
||||||
char s[LUAC_HEADERSIZE];
|
char s[LUAC_HEADERSIZE];
|
||||||
@ -302,7 +302,7 @@ static void ICACHE_FLASH_ATTR LoadHeader(LoadState* S)
|
|||||||
/*
|
/*
|
||||||
** load precompiled chunk
|
** load precompiled chunk
|
||||||
*/
|
*/
|
||||||
Proto* ICACHE_FLASH_ATTR luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name)
|
Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name)
|
||||||
{
|
{
|
||||||
LoadState S;
|
LoadState S;
|
||||||
if (*name=='@' || *name=='=')
|
if (*name=='@' || *name=='=')
|
||||||
@ -322,7 +322,7 @@ Proto* ICACHE_FLASH_ATTR luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const
|
|||||||
/*
|
/*
|
||||||
* make header
|
* make header
|
||||||
*/
|
*/
|
||||||
void ICACHE_FLASH_ATTR luaU_header (char* h)
|
void luaU_header (char* h)
|
||||||
{
|
{
|
||||||
int x=1;
|
int x=1;
|
||||||
c_memcpy(h,LUA_SIGNATURE,sizeof(LUA_SIGNATURE)-1);
|
c_memcpy(h,LUA_SIGNATURE,sizeof(LUA_SIGNATURE)-1);
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
#define MAXTAGLOOP 100
|
#define MAXTAGLOOP 100
|
||||||
|
|
||||||
#if defined LUA_NUMBER_INTEGRAL
|
#if defined LUA_NUMBER_INTEGRAL
|
||||||
LUA_NUMBER ICACHE_FLASH_ATTR luai_ipow(LUA_NUMBER a, LUA_NUMBER b) {
|
LUA_NUMBER luai_ipow(LUA_NUMBER a, LUA_NUMBER b) {
|
||||||
if (b < 0)
|
if (b < 0)
|
||||||
return 0;
|
return 0;
|
||||||
else if (b == 0)
|
else if (b == 0)
|
||||||
@ -51,7 +51,7 @@ LUA_NUMBER ICACHE_FLASH_ATTR luai_ipow(LUA_NUMBER a, LUA_NUMBER b) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const TValue *ICACHE_FLASH_ATTR luaV_tonumber (const TValue *obj, TValue *n) {
|
const TValue *luaV_tonumber (const TValue *obj, TValue *n) {
|
||||||
lua_Number num;
|
lua_Number num;
|
||||||
if (ttisnumber(obj)) return obj;
|
if (ttisnumber(obj)) return obj;
|
||||||
if (ttisstring(obj) && luaO_str2d(svalue(obj), &num)) {
|
if (ttisstring(obj) && luaO_str2d(svalue(obj), &num)) {
|
||||||
@ -63,7 +63,7 @@ const TValue *ICACHE_FLASH_ATTR luaV_tonumber (const TValue *obj, TValue *n) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int ICACHE_FLASH_ATTR luaV_tostring (lua_State *L, StkId obj) {
|
int luaV_tostring (lua_State *L, StkId obj) {
|
||||||
if (!ttisnumber(obj))
|
if (!ttisnumber(obj))
|
||||||
return 0;
|
return 0;
|
||||||
else {
|
else {
|
||||||
@ -77,7 +77,7 @@ int ICACHE_FLASH_ATTR luaV_tostring (lua_State *L, StkId obj) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR traceexec (lua_State *L, const Instruction *pc) {
|
static void traceexec (lua_State *L, const Instruction *pc) {
|
||||||
lu_byte mask = L->hookmask;
|
lu_byte mask = L->hookmask;
|
||||||
const Instruction *oldpc = L->savedpc;
|
const Instruction *oldpc = L->savedpc;
|
||||||
L->savedpc = pc;
|
L->savedpc = pc;
|
||||||
@ -97,7 +97,7 @@ static void ICACHE_FLASH_ATTR traceexec (lua_State *L, const Instruction *pc) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR callTMres (lua_State *L, StkId res, const TValue *f,
|
static void callTMres (lua_State *L, StkId res, const TValue *f,
|
||||||
const TValue *p1, const TValue *p2) {
|
const TValue *p1, const TValue *p2) {
|
||||||
ptrdiff_t result = savestack(L, res);
|
ptrdiff_t result = savestack(L, res);
|
||||||
setobj2s(L, L->top, f); /* push function */
|
setobj2s(L, L->top, f); /* push function */
|
||||||
@ -113,7 +113,7 @@ static void ICACHE_FLASH_ATTR callTMres (lua_State *L, StkId res, const TValue *
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR callTM (lua_State *L, const TValue *f, const TValue *p1,
|
static void callTM (lua_State *L, const TValue *f, const TValue *p1,
|
||||||
const TValue *p2, const TValue *p3) {
|
const TValue *p2, const TValue *p3) {
|
||||||
setobj2s(L, L->top, f); /* push function */
|
setobj2s(L, L->top, f); /* push function */
|
||||||
setobj2s(L, L->top+1, p1); /* 1st argument */
|
setobj2s(L, L->top+1, p1); /* 1st argument */
|
||||||
@ -125,7 +125,7 @@ static void ICACHE_FLASH_ATTR callTM (lua_State *L, const TValue *f, const TValu
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR luaV_gettable (lua_State *L, const TValue *t, TValue *key, StkId val) {
|
void luaV_gettable (lua_State *L, const TValue *t, TValue *key, StkId val) {
|
||||||
int loop;
|
int loop;
|
||||||
TValue temp;
|
TValue temp;
|
||||||
for (loop = 0; loop < MAXTAGLOOP; loop++) {
|
for (loop = 0; loop < MAXTAGLOOP; loop++) {
|
||||||
@ -154,7 +154,7 @@ void ICACHE_FLASH_ATTR luaV_gettable (lua_State *L, const TValue *t, TValue *key
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR luaV_settable (lua_State *L, const TValue *t, TValue *key, StkId val) {
|
void luaV_settable (lua_State *L, const TValue *t, TValue *key, StkId val) {
|
||||||
int loop;
|
int loop;
|
||||||
TValue temp;
|
TValue temp;
|
||||||
setnilvalue(L->top);
|
setnilvalue(L->top);
|
||||||
@ -195,7 +195,7 @@ void ICACHE_FLASH_ATTR luaV_settable (lua_State *L, const TValue *t, TValue *key
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR call_binTM (lua_State *L, const TValue *p1, const TValue *p2,
|
static int call_binTM (lua_State *L, const TValue *p1, const TValue *p2,
|
||||||
StkId res, TMS event) {
|
StkId res, TMS event) {
|
||||||
const TValue *tm = luaT_gettmbyobj(L, p1, event); /* try first operand */
|
const TValue *tm = luaT_gettmbyobj(L, p1, event); /* try first operand */
|
||||||
if (ttisnil(tm))
|
if (ttisnil(tm))
|
||||||
@ -206,7 +206,7 @@ static int ICACHE_FLASH_ATTR call_binTM (lua_State *L, const TValue *p1, const T
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static const TValue *ICACHE_FLASH_ATTR get_compTM (lua_State *L, Table *mt1, Table *mt2,
|
static const TValue *get_compTM (lua_State *L, Table *mt1, Table *mt2,
|
||||||
TMS event) {
|
TMS event) {
|
||||||
const TValue *tm1 = fasttm(L, mt1, event);
|
const TValue *tm1 = fasttm(L, mt1, event);
|
||||||
const TValue *tm2;
|
const TValue *tm2;
|
||||||
@ -220,7 +220,7 @@ static const TValue *ICACHE_FLASH_ATTR get_compTM (lua_State *L, Table *mt1, Tab
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR call_orderTM (lua_State *L, const TValue *p1, const TValue *p2,
|
static int call_orderTM (lua_State *L, const TValue *p1, const TValue *p2,
|
||||||
TMS event) {
|
TMS event) {
|
||||||
const TValue *tm1 = luaT_gettmbyobj(L, p1, event);
|
const TValue *tm1 = luaT_gettmbyobj(L, p1, event);
|
||||||
const TValue *tm2;
|
const TValue *tm2;
|
||||||
@ -233,7 +233,7 @@ static int ICACHE_FLASH_ATTR call_orderTM (lua_State *L, const TValue *p1, const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR l_strcmp (const TString *ls, const TString *rs) {
|
static int l_strcmp (const TString *ls, const TString *rs) {
|
||||||
const char *l = getstr(ls);
|
const char *l = getstr(ls);
|
||||||
size_t ll = ls->tsv.len;
|
size_t ll = ls->tsv.len;
|
||||||
const char *r = getstr(rs);
|
const char *r = getstr(rs);
|
||||||
@ -255,7 +255,7 @@ static int ICACHE_FLASH_ATTR l_strcmp (const TString *ls, const TString *rs) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int ICACHE_FLASH_ATTR luaV_lessthan (lua_State *L, const TValue *l, const TValue *r) {
|
int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r) {
|
||||||
int res;
|
int res;
|
||||||
if (ttype(l) != ttype(r))
|
if (ttype(l) != ttype(r))
|
||||||
return luaG_ordererror(L, l, r);
|
return luaG_ordererror(L, l, r);
|
||||||
@ -269,7 +269,7 @@ int ICACHE_FLASH_ATTR luaV_lessthan (lua_State *L, const TValue *l, const TValue
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR lessequal (lua_State *L, const TValue *l, const TValue *r) {
|
static int lessequal (lua_State *L, const TValue *l, const TValue *r) {
|
||||||
int res;
|
int res;
|
||||||
if (ttype(l) != ttype(r))
|
if (ttype(l) != ttype(r))
|
||||||
return luaG_ordererror(L, l, r);
|
return luaG_ordererror(L, l, r);
|
||||||
@ -285,7 +285,7 @@ static int ICACHE_FLASH_ATTR lessequal (lua_State *L, const TValue *l, const TVa
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int ICACHE_FLASH_ATTR luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2) {
|
int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2) {
|
||||||
const TValue *tm;
|
const TValue *tm;
|
||||||
lua_assert(ttype(t1) == ttype(t2));
|
lua_assert(ttype(t1) == ttype(t2));
|
||||||
switch (ttype(t1)) {
|
switch (ttype(t1)) {
|
||||||
@ -315,7 +315,7 @@ int ICACHE_FLASH_ATTR luaV_equalval (lua_State *L, const TValue *t1, const TValu
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR luaV_concat (lua_State *L, int total, int last) {
|
void luaV_concat (lua_State *L, int total, int last) {
|
||||||
lu_mem max_sizet = MAX_SIZET;
|
lu_mem max_sizet = MAX_SIZET;
|
||||||
if (G(L)->memlimit < max_sizet) max_sizet = G(L)->memlimit;
|
if (G(L)->memlimit < max_sizet) max_sizet = G(L)->memlimit;
|
||||||
do {
|
do {
|
||||||
@ -359,7 +359,7 @@ void ICACHE_FLASH_ATTR luaV_concat (lua_State *L, int total, int last) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR Arith (lua_State *L, StkId ra, const TValue *rb,
|
static void Arith (lua_State *L, StkId ra, const TValue *rb,
|
||||||
const TValue *rc, TMS op) {
|
const TValue *rc, TMS op) {
|
||||||
TValue tempb, tempc;
|
TValue tempb, tempc;
|
||||||
const TValue *b, *c;
|
const TValue *b, *c;
|
||||||
@ -424,7 +424,7 @@ static void ICACHE_FLASH_ATTR Arith (lua_State *L, StkId ra, const TValue *rb,
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR luaV_execute (lua_State *L, int nexeccalls) {
|
void luaV_execute (lua_State *L, int nexeccalls) {
|
||||||
LClosure *cl;
|
LClosure *cl;
|
||||||
StkId base;
|
StkId base;
|
||||||
TValue *k;
|
TValue *k;
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
#include "lzio.h"
|
#include "lzio.h"
|
||||||
|
|
||||||
|
|
||||||
int ICACHE_FLASH_ATTR luaZ_fill (ZIO *z) {
|
int luaZ_fill (ZIO *z) {
|
||||||
size_t size;
|
size_t size;
|
||||||
lua_State *L = z->L;
|
lua_State *L = z->L;
|
||||||
const char *buff;
|
const char *buff;
|
||||||
@ -32,7 +32,7 @@ int ICACHE_FLASH_ATTR luaZ_fill (ZIO *z) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int ICACHE_FLASH_ATTR luaZ_lookahead (ZIO *z) {
|
int luaZ_lookahead (ZIO *z) {
|
||||||
if (z->n == 0) {
|
if (z->n == 0) {
|
||||||
if (luaZ_fill(z) == EOZ)
|
if (luaZ_fill(z) == EOZ)
|
||||||
return EOZ;
|
return EOZ;
|
||||||
@ -45,7 +45,7 @@ int ICACHE_FLASH_ATTR luaZ_lookahead (ZIO *z) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void *data) {
|
void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void *data) {
|
||||||
z->L = L;
|
z->L = L;
|
||||||
z->reader = reader;
|
z->reader = reader;
|
||||||
z->data = data;
|
z->data = data;
|
||||||
@ -55,7 +55,7 @@ void ICACHE_FLASH_ATTR luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void
|
|||||||
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------- read --- */
|
/* --------------------------------------------------------------- read --- */
|
||||||
size_t ICACHE_FLASH_ATTR luaZ_read (ZIO *z, void *b, size_t n) {
|
size_t luaZ_read (ZIO *z, void *b, size_t n) {
|
||||||
while (n) {
|
while (n) {
|
||||||
size_t m;
|
size_t m;
|
||||||
if (luaZ_lookahead(z) == EOZ)
|
if (luaZ_lookahead(z) == EOZ)
|
||||||
@ -74,7 +74,7 @@ size_t ICACHE_FLASH_ATTR luaZ_read (ZIO *z, void *b, size_t n) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------------ */
|
||||||
char *ICACHE_FLASH_ATTR luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n) {
|
char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n) {
|
||||||
if (n > buff->buffsize) {
|
if (n > buff->buffsize) {
|
||||||
if (n < LUA_MINBUFFER) n = LUA_MINBUFFER;
|
if (n < LUA_MINBUFFER) n = LUA_MINBUFFER;
|
||||||
luaZ_resizebuffer(L, buff, n);
|
luaZ_resizebuffer(L, buff, n);
|
||||||
|
@ -20,13 +20,13 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR db_getregistry (lua_State *L) {
|
static int db_getregistry (lua_State *L) {
|
||||||
lua_pushvalue(L, LUA_REGISTRYINDEX);
|
lua_pushvalue(L, LUA_REGISTRYINDEX);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR db_getmetatable (lua_State *L) {
|
static int db_getmetatable (lua_State *L) {
|
||||||
luaL_checkany(L, 1);
|
luaL_checkany(L, 1);
|
||||||
if (!lua_getmetatable(L, 1)) {
|
if (!lua_getmetatable(L, 1)) {
|
||||||
lua_pushnil(L); /* no metatable */
|
lua_pushnil(L); /* no metatable */
|
||||||
@ -35,7 +35,7 @@ static int ICACHE_FLASH_ATTR db_getmetatable (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR db_setmetatable (lua_State *L) {
|
static int db_setmetatable (lua_State *L) {
|
||||||
int t = lua_type(L, 2);
|
int t = lua_type(L, 2);
|
||||||
luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE, 2,
|
luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE, 2,
|
||||||
"nil or table expected");
|
"nil or table expected");
|
||||||
@ -45,14 +45,14 @@ static int ICACHE_FLASH_ATTR db_setmetatable (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR db_getfenv (lua_State *L) {
|
static int db_getfenv (lua_State *L) {
|
||||||
luaL_checkany(L, 1);
|
luaL_checkany(L, 1);
|
||||||
lua_getfenv(L, 1);
|
lua_getfenv(L, 1);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR db_setfenv (lua_State *L) {
|
static int db_setfenv (lua_State *L) {
|
||||||
luaL_checktype(L, 2, LUA_TTABLE);
|
luaL_checktype(L, 2, LUA_TTABLE);
|
||||||
lua_settop(L, 2);
|
lua_settop(L, 2);
|
||||||
if (lua_setfenv(L, 1) == 0)
|
if (lua_setfenv(L, 1) == 0)
|
||||||
@ -62,19 +62,19 @@ static int ICACHE_FLASH_ATTR db_setfenv (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR settabss (lua_State *L, const char *i, const char *v) {
|
static void settabss (lua_State *L, const char *i, const char *v) {
|
||||||
lua_pushstring(L, v);
|
lua_pushstring(L, v);
|
||||||
lua_setfield(L, -2, i);
|
lua_setfield(L, -2, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR settabsi (lua_State *L, const char *i, int v) {
|
static void settabsi (lua_State *L, const char *i, int v) {
|
||||||
lua_pushinteger(L, v);
|
lua_pushinteger(L, v);
|
||||||
lua_setfield(L, -2, i);
|
lua_setfield(L, -2, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static lua_State *ICACHE_FLASH_ATTR getthread (lua_State *L, int *arg) {
|
static lua_State *getthread (lua_State *L, int *arg) {
|
||||||
if (lua_isthread(L, 1)) {
|
if (lua_isthread(L, 1)) {
|
||||||
*arg = 1;
|
*arg = 1;
|
||||||
return lua_tothread(L, 1);
|
return lua_tothread(L, 1);
|
||||||
@ -86,7 +86,7 @@ static lua_State *ICACHE_FLASH_ATTR getthread (lua_State *L, int *arg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR treatstackoption (lua_State *L, lua_State *L1, const char *fname) {
|
static void treatstackoption (lua_State *L, lua_State *L1, const char *fname) {
|
||||||
if (L == L1) {
|
if (L == L1) {
|
||||||
lua_pushvalue(L, -2);
|
lua_pushvalue(L, -2);
|
||||||
lua_remove(L, -3);
|
lua_remove(L, -3);
|
||||||
@ -97,7 +97,7 @@ static void ICACHE_FLASH_ATTR treatstackoption (lua_State *L, lua_State *L1, con
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR db_getinfo (lua_State *L) {
|
static int db_getinfo (lua_State *L) {
|
||||||
lua_Debug ar;
|
lua_Debug ar;
|
||||||
int arg;
|
int arg;
|
||||||
lua_State *L1 = getthread(L, &arg);
|
lua_State *L1 = getthread(L, &arg);
|
||||||
@ -142,7 +142,7 @@ static int ICACHE_FLASH_ATTR db_getinfo (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR db_getlocal (lua_State *L) {
|
static int db_getlocal (lua_State *L) {
|
||||||
int arg;
|
int arg;
|
||||||
lua_State *L1 = getthread(L, &arg);
|
lua_State *L1 = getthread(L, &arg);
|
||||||
lua_Debug ar;
|
lua_Debug ar;
|
||||||
@ -163,7 +163,7 @@ static int ICACHE_FLASH_ATTR db_getlocal (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR db_setlocal (lua_State *L) {
|
static int db_setlocal (lua_State *L) {
|
||||||
int arg;
|
int arg;
|
||||||
lua_State *L1 = getthread(L, &arg);
|
lua_State *L1 = getthread(L, &arg);
|
||||||
lua_Debug ar;
|
lua_Debug ar;
|
||||||
@ -177,7 +177,7 @@ static int ICACHE_FLASH_ATTR db_setlocal (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR auxupvalue (lua_State *L, int get) {
|
static int auxupvalue (lua_State *L, int get) {
|
||||||
const char *name;
|
const char *name;
|
||||||
int n = luaL_checkint(L, 2);
|
int n = luaL_checkint(L, 2);
|
||||||
luaL_checktype(L, 1, LUA_TFUNCTION);
|
luaL_checktype(L, 1, LUA_TFUNCTION);
|
||||||
@ -190,12 +190,12 @@ static int ICACHE_FLASH_ATTR auxupvalue (lua_State *L, int get) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR db_getupvalue (lua_State *L) {
|
static int db_getupvalue (lua_State *L) {
|
||||||
return auxupvalue(L, 1);
|
return auxupvalue(L, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR db_setupvalue (lua_State *L) {
|
static int db_setupvalue (lua_State *L) {
|
||||||
luaL_checkany(L, 3);
|
luaL_checkany(L, 3);
|
||||||
return auxupvalue(L, 0);
|
return auxupvalue(L, 0);
|
||||||
}
|
}
|
||||||
@ -205,7 +205,7 @@ static int ICACHE_FLASH_ATTR db_setupvalue (lua_State *L) {
|
|||||||
static const char KEY_HOOK = 'h';
|
static const char KEY_HOOK = 'h';
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR hookf (lua_State *L, lua_Debug *ar) {
|
static void hookf (lua_State *L, lua_Debug *ar) {
|
||||||
static const char *const hooknames[] =
|
static const char *const hooknames[] =
|
||||||
{"call", "return", "line", "count", "tail return"};
|
{"call", "return", "line", "count", "tail return"};
|
||||||
lua_pushlightuserdata(L, (void *)&KEY_HOOK);
|
lua_pushlightuserdata(L, (void *)&KEY_HOOK);
|
||||||
@ -223,7 +223,7 @@ static void ICACHE_FLASH_ATTR hookf (lua_State *L, lua_Debug *ar) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR makemask (const char *smask, int count) {
|
static int makemask (const char *smask, int count) {
|
||||||
int mask = 0;
|
int mask = 0;
|
||||||
if (c_strchr(smask, 'c')) mask |= LUA_MASKCALL;
|
if (c_strchr(smask, 'c')) mask |= LUA_MASKCALL;
|
||||||
if (c_strchr(smask, 'r')) mask |= LUA_MASKRET;
|
if (c_strchr(smask, 'r')) mask |= LUA_MASKRET;
|
||||||
@ -233,7 +233,7 @@ static int ICACHE_FLASH_ATTR makemask (const char *smask, int count) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static char *ICACHE_FLASH_ATTR unmakemask (int mask, char *smask) {
|
static char *unmakemask (int mask, char *smask) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
if (mask & LUA_MASKCALL) smask[i++] = 'c';
|
if (mask & LUA_MASKCALL) smask[i++] = 'c';
|
||||||
if (mask & LUA_MASKRET) smask[i++] = 'r';
|
if (mask & LUA_MASKRET) smask[i++] = 'r';
|
||||||
@ -243,7 +243,7 @@ static char *ICACHE_FLASH_ATTR unmakemask (int mask, char *smask) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR gethooktable (lua_State *L) {
|
static void gethooktable (lua_State *L) {
|
||||||
lua_pushlightuserdata(L, (void *)&KEY_HOOK);
|
lua_pushlightuserdata(L, (void *)&KEY_HOOK);
|
||||||
lua_rawget(L, LUA_REGISTRYINDEX);
|
lua_rawget(L, LUA_REGISTRYINDEX);
|
||||||
if (!lua_istable(L, -1)) {
|
if (!lua_istable(L, -1)) {
|
||||||
@ -256,7 +256,7 @@ static void ICACHE_FLASH_ATTR gethooktable (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR db_sethook (lua_State *L) {
|
static int db_sethook (lua_State *L) {
|
||||||
int arg, mask, count;
|
int arg, mask, count;
|
||||||
lua_Hook func;
|
lua_Hook func;
|
||||||
lua_State *L1 = getthread(L, &arg);
|
lua_State *L1 = getthread(L, &arg);
|
||||||
@ -280,7 +280,7 @@ static int ICACHE_FLASH_ATTR db_sethook (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR db_gethook (lua_State *L) {
|
static int db_gethook (lua_State *L) {
|
||||||
int arg;
|
int arg;
|
||||||
lua_State *L1 = getthread(L, &arg);
|
lua_State *L1 = getthread(L, &arg);
|
||||||
char buff[5];
|
char buff[5];
|
||||||
@ -300,7 +300,7 @@ static int ICACHE_FLASH_ATTR db_gethook (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR db_debug (lua_State *L) {
|
static int db_debug (lua_State *L) {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
char buffer[LUA_MAXINPUT];
|
char buffer[LUA_MAXINPUT];
|
||||||
#if defined(LUA_USE_STDIO)
|
#if defined(LUA_USE_STDIO)
|
||||||
@ -329,7 +329,7 @@ static int ICACHE_FLASH_ATTR db_debug (lua_State *L) {
|
|||||||
#define LEVELS1 12 /* size of the first part of the stack */
|
#define LEVELS1 12 /* size of the first part of the stack */
|
||||||
#define LEVELS2 10 /* size of the second part of the stack */
|
#define LEVELS2 10 /* size of the second part of the stack */
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR db_errorfb (lua_State *L) {
|
static int db_errorfb (lua_State *L) {
|
||||||
int level;
|
int level;
|
||||||
int firstpart = 1; /* still before eventual `...' */
|
int firstpart = 1; /* still before eventual `...' */
|
||||||
int arg;
|
int arg;
|
||||||
@ -401,6 +401,6 @@ const LUA_REG_TYPE dblib[] = {
|
|||||||
{LNILKEY, LNILVAL}
|
{LNILKEY, LNILVAL}
|
||||||
};
|
};
|
||||||
|
|
||||||
LUALIB_API int ICACHE_FLASH_ATTR luaopen_debug (lua_State *L) {
|
LUALIB_API int luaopen_debug (lua_State *L) {
|
||||||
LREGISTER(L, LUA_DBLIBNAME, dblib);
|
LREGISTER(L, LUA_DBLIBNAME, dblib);
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#include "c_types.h"
|
#include "c_types.h"
|
||||||
|
|
||||||
// Lua: read(id) , return system adc
|
// Lua: read(id) , return system adc
|
||||||
static int ICACHE_FLASH_ATTR adc_sample( lua_State* L )
|
static int adc_sample( lua_State* L )
|
||||||
{
|
{
|
||||||
unsigned id = luaL_checkinteger( L, 1 );
|
unsigned id = luaL_checkinteger( L, 1 );
|
||||||
MOD_CHECK_ID( adc, id );
|
MOD_CHECK_ID( adc, id );
|
||||||
@ -31,7 +31,7 @@ const LUA_REG_TYPE adc_map[] =
|
|||||||
{ LNILKEY, LNILVAL }
|
{ LNILKEY, LNILVAL }
|
||||||
};
|
};
|
||||||
|
|
||||||
LUALIB_API int ICACHE_FLASH_ATTR luaopen_adc( lua_State *L )
|
LUALIB_API int luaopen_adc( lua_State *L )
|
||||||
{
|
{
|
||||||
#if LUA_OPTIMIZE_MEMORY > 0
|
#if LUA_OPTIMIZE_MEMORY > 0
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -34,13 +34,13 @@ typedef size_t lua_UInteger;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#define MONADIC(name, op) \
|
#define MONADIC(name, op) \
|
||||||
static int ICACHE_FLASH_ATTR bit_ ## name(lua_State *L) { \
|
static int bit_ ## name(lua_State *L) { \
|
||||||
lua_pushinteger(L, op TOBIT(L, 1)); \
|
lua_pushinteger(L, op TOBIT(L, 1)); \
|
||||||
return 1; \
|
return 1; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define VARIADIC(name, op) \
|
#define VARIADIC(name, op) \
|
||||||
static int ICACHE_FLASH_ATTR bit_ ## name(lua_State *L) { \
|
static int bit_ ## name(lua_State *L) { \
|
||||||
int n = lua_gettop(L), i; \
|
int n = lua_gettop(L), i; \
|
||||||
lua_Integer w = TOBIT(L, 1); \
|
lua_Integer w = TOBIT(L, 1); \
|
||||||
for (i = 2; i <= n; i++) \
|
for (i = 2; i <= n; i++) \
|
||||||
@ -50,14 +50,14 @@ typedef size_t lua_UInteger;
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define LOGICAL_SHIFT(name, op) \
|
#define LOGICAL_SHIFT(name, op) \
|
||||||
static int ICACHE_FLASH_ATTR bit_ ## name(lua_State *L) { \
|
static int bit_ ## name(lua_State *L) { \
|
||||||
lua_pushinteger(L, (lua_UInteger)TOBIT(L, 1) op \
|
lua_pushinteger(L, (lua_UInteger)TOBIT(L, 1) op \
|
||||||
(unsigned)luaL_checknumber(L, 2)); \
|
(unsigned)luaL_checknumber(L, 2)); \
|
||||||
return 1; \
|
return 1; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ARITHMETIC_SHIFT(name, op) \
|
#define ARITHMETIC_SHIFT(name, op) \
|
||||||
static int ICACHE_FLASH_ATTR bit_ ## name(lua_State *L) { \
|
static int bit_ ## name(lua_State *L) { \
|
||||||
lua_pushinteger(L, (lua_Integer)TOBIT(L, 1) op \
|
lua_pushinteger(L, (lua_Integer)TOBIT(L, 1) op \
|
||||||
(unsigned)luaL_checknumber(L, 2)); \
|
(unsigned)luaL_checknumber(L, 2)); \
|
||||||
return 1; \
|
return 1; \
|
||||||
@ -72,14 +72,14 @@ LOGICAL_SHIFT(rshift, >>)
|
|||||||
ARITHMETIC_SHIFT(arshift, >>)
|
ARITHMETIC_SHIFT(arshift, >>)
|
||||||
|
|
||||||
// Lua: res = bit( position )
|
// Lua: res = bit( position )
|
||||||
static int ICACHE_FLASH_ATTR bit_bit( lua_State* L )
|
static int bit_bit( lua_State* L )
|
||||||
{
|
{
|
||||||
lua_pushinteger( L, ( lua_Integer )( 1 << luaL_checkinteger( L, 1 ) ) );
|
lua_pushinteger( L, ( lua_Integer )( 1 << luaL_checkinteger( L, 1 ) ) );
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lua: res = isset( value, position )
|
// Lua: res = isset( value, position )
|
||||||
static int ICACHE_FLASH_ATTR bit_isset( lua_State* L )
|
static int bit_isset( lua_State* L )
|
||||||
{
|
{
|
||||||
lua_UInteger val = ( lua_UInteger )luaL_checkinteger( L, 1 );
|
lua_UInteger val = ( lua_UInteger )luaL_checkinteger( L, 1 );
|
||||||
unsigned pos = ( unsigned )luaL_checkinteger( L, 2 );
|
unsigned pos = ( unsigned )luaL_checkinteger( L, 2 );
|
||||||
@ -89,7 +89,7 @@ static int ICACHE_FLASH_ATTR bit_isset( lua_State* L )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lua: res = isclear( value, position )
|
// Lua: res = isclear( value, position )
|
||||||
static int ICACHE_FLASH_ATTR bit_isclear( lua_State* L )
|
static int bit_isclear( lua_State* L )
|
||||||
{
|
{
|
||||||
lua_UInteger val = ( lua_UInteger )luaL_checkinteger( L, 1 );
|
lua_UInteger val = ( lua_UInteger )luaL_checkinteger( L, 1 );
|
||||||
unsigned pos = ( unsigned )luaL_checkinteger( L, 2 );
|
unsigned pos = ( unsigned )luaL_checkinteger( L, 2 );
|
||||||
@ -99,7 +99,7 @@ static int ICACHE_FLASH_ATTR bit_isclear( lua_State* L )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lua: res = set( value, pos1, pos2, ... )
|
// Lua: res = set( value, pos1, pos2, ... )
|
||||||
static int ICACHE_FLASH_ATTR bit_set( lua_State* L )
|
static int bit_set( lua_State* L )
|
||||||
{
|
{
|
||||||
lua_UInteger val = ( lua_UInteger )luaL_checkinteger( L, 1 );
|
lua_UInteger val = ( lua_UInteger )luaL_checkinteger( L, 1 );
|
||||||
unsigned total = lua_gettop( L ), i;
|
unsigned total = lua_gettop( L ), i;
|
||||||
@ -111,7 +111,7 @@ static int ICACHE_FLASH_ATTR bit_set( lua_State* L )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lua: res = clear( value, pos1, pos2, ... )
|
// Lua: res = clear( value, pos1, pos2, ... )
|
||||||
static int ICACHE_FLASH_ATTR bit_clear( lua_State* L )
|
static int bit_clear( lua_State* L )
|
||||||
{
|
{
|
||||||
lua_UInteger val = ( lua_UInteger )luaL_checkinteger( L, 1 );
|
lua_UInteger val = ( lua_UInteger )luaL_checkinteger( L, 1 );
|
||||||
unsigned total = lua_gettop( L ), i;
|
unsigned total = lua_gettop( L ), i;
|
||||||
@ -140,6 +140,6 @@ const LUA_REG_TYPE bit_map[] = {
|
|||||||
{ LNILKEY, LNILVAL}
|
{ LNILKEY, LNILVAL}
|
||||||
};
|
};
|
||||||
|
|
||||||
LUALIB_API int ICACHE_FLASH_ATTR luaopen_bit (lua_State *L) {
|
LUALIB_API int luaopen_bit (lua_State *L) {
|
||||||
LREGISTER( L, "bit", bit_map );
|
LREGISTER( L, "bit", bit_map );
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
static int file_fd = FS_OPEN_OK - 1;
|
static int file_fd = FS_OPEN_OK - 1;
|
||||||
|
|
||||||
// Lua: open(filename, mode)
|
// Lua: open(filename, mode)
|
||||||
static int ICACHE_FLASH_ATTR file_open( lua_State* L )
|
static int file_open( lua_State* L )
|
||||||
{
|
{
|
||||||
size_t len;
|
size_t len;
|
||||||
if((FS_OPEN_OK - 1)!=file_fd){
|
if((FS_OPEN_OK - 1)!=file_fd){
|
||||||
@ -39,7 +39,7 @@ static int ICACHE_FLASH_ATTR file_open( lua_State* L )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lua: close()
|
// Lua: close()
|
||||||
static int ICACHE_FLASH_ATTR file_close( lua_State* L )
|
static int file_close( lua_State* L )
|
||||||
{
|
{
|
||||||
if((FS_OPEN_OK - 1)!=file_fd){
|
if((FS_OPEN_OK - 1)!=file_fd){
|
||||||
fs_close(file_fd);
|
fs_close(file_fd);
|
||||||
@ -50,7 +50,7 @@ static int ICACHE_FLASH_ATTR file_close( lua_State* L )
|
|||||||
|
|
||||||
#if defined(BUILD_WOFS)
|
#if defined(BUILD_WOFS)
|
||||||
// Lua: list()
|
// Lua: list()
|
||||||
static int ICACHE_FLASH_ATTR file_list( lua_State* L )
|
static int file_list( lua_State* L )
|
||||||
{
|
{
|
||||||
uint32_t start = 0;
|
uint32_t start = 0;
|
||||||
size_t act_len = 0;
|
size_t act_len = 0;
|
||||||
@ -64,7 +64,7 @@ static int ICACHE_FLASH_ATTR file_list( lua_State* L )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lua: format()
|
// Lua: format()
|
||||||
static int ICACHE_FLASH_ATTR file_format( lua_State* L )
|
static int file_format( lua_State* L )
|
||||||
{
|
{
|
||||||
size_t len;
|
size_t len;
|
||||||
file_close(L);
|
file_close(L);
|
||||||
@ -84,7 +84,7 @@ static int ICACHE_FLASH_ATTR file_format( lua_State* L )
|
|||||||
extern spiffs fs;
|
extern spiffs fs;
|
||||||
|
|
||||||
// Lua: list()
|
// Lua: list()
|
||||||
static int ICACHE_FLASH_ATTR file_list( lua_State* L )
|
static int file_list( lua_State* L )
|
||||||
{
|
{
|
||||||
spiffs_DIR d;
|
spiffs_DIR d;
|
||||||
struct spiffs_dirent e;
|
struct spiffs_dirent e;
|
||||||
@ -101,7 +101,7 @@ static int ICACHE_FLASH_ATTR file_list( lua_State* L )
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR file_seek (lua_State *L)
|
static int file_seek (lua_State *L)
|
||||||
{
|
{
|
||||||
static const int mode[] = {FS_SEEK_SET, FS_SEEK_CUR, FS_SEEK_END};
|
static const int mode[] = {FS_SEEK_SET, FS_SEEK_CUR, FS_SEEK_END};
|
||||||
static const char *const modenames[] = {"set", "cur", "end", NULL};
|
static const char *const modenames[] = {"set", "cur", "end", NULL};
|
||||||
@ -118,7 +118,7 @@ static int ICACHE_FLASH_ATTR file_seek (lua_State *L)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lua: remove(filename)
|
// Lua: remove(filename)
|
||||||
static int ICACHE_FLASH_ATTR file_remove( lua_State* L )
|
static int file_remove( lua_State* L )
|
||||||
{
|
{
|
||||||
size_t len;
|
size_t len;
|
||||||
const char *fname = luaL_checklstring( L, 1, &len );
|
const char *fname = luaL_checklstring( L, 1, &len );
|
||||||
@ -130,7 +130,7 @@ static int ICACHE_FLASH_ATTR file_remove( lua_State* L )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lua: flush()
|
// Lua: flush()
|
||||||
static int ICACHE_FLASH_ATTR file_flush( lua_State* L )
|
static int file_flush( lua_State* L )
|
||||||
{
|
{
|
||||||
if((FS_OPEN_OK - 1)==file_fd)
|
if((FS_OPEN_OK - 1)==file_fd)
|
||||||
return luaL_error(L, "open a file first");
|
return luaL_error(L, "open a file first");
|
||||||
@ -142,7 +142,7 @@ static int ICACHE_FLASH_ATTR file_flush( lua_State* L )
|
|||||||
}
|
}
|
||||||
#if 0
|
#if 0
|
||||||
// Lua: check()
|
// Lua: check()
|
||||||
static int ICACHE_FLASH_ATTR file_check( lua_State* L )
|
static int file_check( lua_State* L )
|
||||||
{
|
{
|
||||||
file_close(L);
|
file_close(L);
|
||||||
lua_pushinteger(L, fs_check());
|
lua_pushinteger(L, fs_check());
|
||||||
@ -153,7 +153,7 @@ static int ICACHE_FLASH_ATTR file_check( lua_State* L )
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// g_read()
|
// g_read()
|
||||||
static int ICACHE_FLASH_ATTR file_g_read( lua_State* L, int n, int16_t end_char )
|
static int file_g_read( lua_State* L, int n, int16_t end_char )
|
||||||
{
|
{
|
||||||
if(n< 0 || n>LUAL_BUFFERSIZE)
|
if(n< 0 || n>LUAL_BUFFERSIZE)
|
||||||
n = LUAL_BUFFERSIZE;
|
n = LUAL_BUFFERSIZE;
|
||||||
@ -197,7 +197,7 @@ static int ICACHE_FLASH_ATTR file_g_read( lua_State* L, int n, int16_t end_char
|
|||||||
// file.read() will read all byte in file
|
// file.read() will read all byte in file
|
||||||
// file.read(10) will read 10 byte from file, or EOF is reached.
|
// file.read(10) will read 10 byte from file, or EOF is reached.
|
||||||
// file.read('q') will read until 'q' or EOF is reached.
|
// file.read('q') will read until 'q' or EOF is reached.
|
||||||
static int ICACHE_FLASH_ATTR file_read( lua_State* L )
|
static int file_read( lua_State* L )
|
||||||
{
|
{
|
||||||
unsigned need_len = LUAL_BUFFERSIZE;
|
unsigned need_len = LUAL_BUFFERSIZE;
|
||||||
int16_t end_char = EOF;
|
int16_t end_char = EOF;
|
||||||
@ -222,13 +222,13 @@ static int ICACHE_FLASH_ATTR file_read( lua_State* L )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lua: readline()
|
// Lua: readline()
|
||||||
static int ICACHE_FLASH_ATTR file_readline( lua_State* L )
|
static int file_readline( lua_State* L )
|
||||||
{
|
{
|
||||||
return file_g_read(L, LUAL_BUFFERSIZE, '\n');
|
return file_g_read(L, LUAL_BUFFERSIZE, '\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lua: write("string")
|
// Lua: write("string")
|
||||||
static int ICACHE_FLASH_ATTR file_write( lua_State* L )
|
static int file_write( lua_State* L )
|
||||||
{
|
{
|
||||||
if((FS_OPEN_OK - 1)==file_fd)
|
if((FS_OPEN_OK - 1)==file_fd)
|
||||||
return luaL_error(L, "open a file first");
|
return luaL_error(L, "open a file first");
|
||||||
@ -243,7 +243,7 @@ static int ICACHE_FLASH_ATTR file_write( lua_State* L )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lua: writeline("string")
|
// Lua: writeline("string")
|
||||||
static int ICACHE_FLASH_ATTR file_writeline( lua_State* L )
|
static int file_writeline( lua_State* L )
|
||||||
{
|
{
|
||||||
if((FS_OPEN_OK - 1)==file_fd)
|
if((FS_OPEN_OK - 1)==file_fd)
|
||||||
return luaL_error(L, "open a file first");
|
return luaL_error(L, "open a file first");
|
||||||
@ -290,7 +290,7 @@ const LUA_REG_TYPE file_map[] =
|
|||||||
{ LNILKEY, LNILVAL }
|
{ LNILKEY, LNILVAL }
|
||||||
};
|
};
|
||||||
|
|
||||||
LUALIB_API int ICACHE_FLASH_ATTR luaopen_file( lua_State *L )
|
LUALIB_API int luaopen_file( lua_State *L )
|
||||||
{
|
{
|
||||||
#if LUA_OPTIMIZE_MEMORY > 0
|
#if LUA_OPTIMIZE_MEMORY > 0
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
static int gpio_cb_ref[GPIO_PIN_NUM];
|
static int gpio_cb_ref[GPIO_PIN_NUM];
|
||||||
static lua_State* gL = NULL;
|
static lua_State* gL = NULL;
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR lua_gpio_unref(unsigned pin){
|
void lua_gpio_unref(unsigned pin){
|
||||||
if(gpio_cb_ref[pin] != LUA_NOREF){
|
if(gpio_cb_ref[pin] != LUA_NOREF){
|
||||||
if(gL!=NULL)
|
if(gL!=NULL)
|
||||||
luaL_unref(gL, LUA_REGISTRYINDEX, gpio_cb_ref[pin]);
|
luaL_unref(gL, LUA_REGISTRYINDEX, gpio_cb_ref[pin]);
|
||||||
@ -31,7 +31,7 @@ void ICACHE_FLASH_ATTR lua_gpio_unref(unsigned pin){
|
|||||||
gpio_cb_ref[pin] = LUA_NOREF;
|
gpio_cb_ref[pin] = LUA_NOREF;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR gpio_intr_callback( unsigned pin, unsigned level )
|
void gpio_intr_callback( unsigned pin, unsigned level )
|
||||||
{
|
{
|
||||||
NODE_DBG("pin:%d, level:%d \n", pin, level);
|
NODE_DBG("pin:%d, level:%d \n", pin, level);
|
||||||
if(gpio_cb_ref[pin] == LUA_NOREF)
|
if(gpio_cb_ref[pin] == LUA_NOREF)
|
||||||
@ -44,7 +44,7 @@ void ICACHE_FLASH_ATTR gpio_intr_callback( unsigned pin, unsigned level )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lua: trig( pin, type, function )
|
// Lua: trig( pin, type, function )
|
||||||
static int ICACHE_FLASH_ATTR lgpio_trig( lua_State* L )
|
static int lgpio_trig( lua_State* L )
|
||||||
{
|
{
|
||||||
unsigned type;
|
unsigned type;
|
||||||
unsigned pin;
|
unsigned pin;
|
||||||
@ -87,7 +87,7 @@ static int ICACHE_FLASH_ATTR lgpio_trig( lua_State* L )
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Lua: mode( pin, mode, pullup )
|
// Lua: mode( pin, mode, pullup )
|
||||||
static int ICACHE_FLASH_ATTR lgpio_mode( lua_State* L )
|
static int lgpio_mode( lua_State* L )
|
||||||
{
|
{
|
||||||
unsigned mode, pullup = FLOAT;
|
unsigned mode, pullup = FLOAT;
|
||||||
unsigned pin;
|
unsigned pin;
|
||||||
@ -119,7 +119,7 @@ static int ICACHE_FLASH_ATTR lgpio_mode( lua_State* L )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lua: read( pin )
|
// Lua: read( pin )
|
||||||
static int ICACHE_FLASH_ATTR lgpio_read( lua_State* L )
|
static int lgpio_read( lua_State* L )
|
||||||
{
|
{
|
||||||
unsigned pin;
|
unsigned pin;
|
||||||
|
|
||||||
@ -132,7 +132,7 @@ static int ICACHE_FLASH_ATTR lgpio_read( lua_State* L )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lua: write( pin, level )
|
// Lua: write( pin, level )
|
||||||
static int ICACHE_FLASH_ATTR lgpio_write( lua_State* L )
|
static int lgpio_write( lua_State* L )
|
||||||
{
|
{
|
||||||
unsigned level;
|
unsigned level;
|
||||||
unsigned pin;
|
unsigned pin;
|
||||||
@ -171,7 +171,7 @@ const LUA_REG_TYPE gpio_map[] =
|
|||||||
{ LNILKEY, LNILVAL }
|
{ LNILKEY, LNILVAL }
|
||||||
};
|
};
|
||||||
|
|
||||||
LUALIB_API int ICACHE_FLASH_ATTR luaopen_gpio( lua_State *L )
|
LUALIB_API int luaopen_gpio( lua_State *L )
|
||||||
{
|
{
|
||||||
#ifdef GPIO_INTERRUPT_ENABLE
|
#ifdef GPIO_INTERRUPT_ENABLE
|
||||||
int i;
|
int i;
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
#include "lrotable.h"
|
#include "lrotable.h"
|
||||||
|
|
||||||
// Lua: speed = i2c.setup( id, sda, scl, speed )
|
// Lua: speed = i2c.setup( id, sda, scl, speed )
|
||||||
static int ICACHE_FLASH_ATTR i2c_setup( lua_State *L )
|
static int i2c_setup( lua_State *L )
|
||||||
{
|
{
|
||||||
unsigned id = luaL_checkinteger( L, 1 );
|
unsigned id = luaL_checkinteger( L, 1 );
|
||||||
unsigned sda = luaL_checkinteger( L, 2 );
|
unsigned sda = luaL_checkinteger( L, 2 );
|
||||||
@ -29,7 +29,7 @@ static int ICACHE_FLASH_ATTR i2c_setup( lua_State *L )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lua: i2c.start( id )
|
// Lua: i2c.start( id )
|
||||||
static int ICACHE_FLASH_ATTR i2c_start( lua_State *L )
|
static int i2c_start( lua_State *L )
|
||||||
{
|
{
|
||||||
unsigned id = luaL_checkinteger( L, 1 );
|
unsigned id = luaL_checkinteger( L, 1 );
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ static int ICACHE_FLASH_ATTR i2c_start( lua_State *L )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lua: i2c.stop( id )
|
// Lua: i2c.stop( id )
|
||||||
static int ICACHE_FLASH_ATTR i2c_stop( lua_State *L )
|
static int i2c_stop( lua_State *L )
|
||||||
{
|
{
|
||||||
unsigned id = luaL_checkinteger( L, 1 );
|
unsigned id = luaL_checkinteger( L, 1 );
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ static int ICACHE_FLASH_ATTR i2c_stop( lua_State *L )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lua: status = i2c.address( id, address, direction )
|
// Lua: status = i2c.address( id, address, direction )
|
||||||
static int ICACHE_FLASH_ATTR i2c_address( lua_State *L )
|
static int i2c_address( lua_State *L )
|
||||||
{
|
{
|
||||||
unsigned id = luaL_checkinteger( L, 1 );
|
unsigned id = luaL_checkinteger( L, 1 );
|
||||||
int address = luaL_checkinteger( L, 2 );
|
int address = luaL_checkinteger( L, 2 );
|
||||||
@ -64,7 +64,7 @@ static int ICACHE_FLASH_ATTR i2c_address( lua_State *L )
|
|||||||
|
|
||||||
// Lua: wrote = i2c.write( id, data1, [data2], ..., [datan] )
|
// Lua: wrote = i2c.write( id, data1, [data2], ..., [datan] )
|
||||||
// data can be either a string, a table or an 8-bit number
|
// data can be either a string, a table or an 8-bit number
|
||||||
static int ICACHE_FLASH_ATTR i2c_write( lua_State *L )
|
static int i2c_write( lua_State *L )
|
||||||
{
|
{
|
||||||
unsigned id = luaL_checkinteger( L, 1 );
|
unsigned id = luaL_checkinteger( L, 1 );
|
||||||
const char *pdata;
|
const char *pdata;
|
||||||
@ -122,7 +122,7 @@ static int ICACHE_FLASH_ATTR i2c_write( lua_State *L )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lua: read = i2c.read( id, size )
|
// Lua: read = i2c.read( id, size )
|
||||||
static int ICACHE_FLASH_ATTR i2c_read( lua_State *L )
|
static int i2c_read( lua_State *L )
|
||||||
{
|
{
|
||||||
unsigned id = luaL_checkinteger( L, 1 );
|
unsigned id = luaL_checkinteger( L, 1 );
|
||||||
u32 size = ( u32 )luaL_checkinteger( L, 2 ), i;
|
u32 size = ( u32 )luaL_checkinteger( L, 2 ), i;
|
||||||
@ -162,7 +162,7 @@ const LUA_REG_TYPE i2c_map[] =
|
|||||||
{ LNILKEY, LNILVAL }
|
{ LNILKEY, LNILVAL }
|
||||||
};
|
};
|
||||||
|
|
||||||
LUALIB_API int ICACHE_FLASH_ATTR luaopen_i2c( lua_State *L )
|
LUALIB_API int luaopen_i2c( lua_State *L )
|
||||||
{
|
{
|
||||||
#if LUA_OPTIMIZE_MEMORY > 0
|
#if LUA_OPTIMIZE_MEMORY > 0
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -55,8 +55,7 @@ typedef struct lnet_userdata
|
|||||||
#endif
|
#endif
|
||||||
}lnet_userdata;
|
}lnet_userdata;
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR
|
static void net_server_disconnected(void *arg) // for tcp server only
|
||||||
net_server_disconnected(void *arg) // for tcp server only
|
|
||||||
{
|
{
|
||||||
NODE_DBG("net_server_disconnected is called.\n");
|
NODE_DBG("net_server_disconnected is called.\n");
|
||||||
struct espconn *pesp_conn = arg;
|
struct espconn *pesp_conn = arg;
|
||||||
@ -99,8 +98,7 @@ net_server_disconnected(void *arg) // for tcp server only
|
|||||||
lua_gc(gL, LUA_GCRESTART, 0);
|
lua_gc(gL, LUA_GCRESTART, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR
|
static void net_socket_disconnected(void *arg) // tcp only
|
||||||
net_socket_disconnected(void *arg) // tcp only
|
|
||||||
{
|
{
|
||||||
NODE_DBG("net_socket_disconnected is called.\n");
|
NODE_DBG("net_socket_disconnected is called.\n");
|
||||||
struct espconn *pesp_conn = arg;
|
struct espconn *pesp_conn = arg;
|
||||||
@ -130,22 +128,19 @@ net_socket_disconnected(void *arg) // tcp only
|
|||||||
lua_gc(gL, LUA_GCRESTART, 0);
|
lua_gc(gL, LUA_GCRESTART, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR
|
static void net_server_reconnected(void *arg, sint8_t err)
|
||||||
net_server_reconnected(void *arg, sint8_t err)
|
|
||||||
{
|
{
|
||||||
NODE_DBG("net_server_reconnected is called.\n");
|
NODE_DBG("net_server_reconnected is called.\n");
|
||||||
net_server_disconnected(arg);
|
net_server_disconnected(arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR
|
static void net_socket_reconnected(void *arg, sint8_t err)
|
||||||
net_socket_reconnected(void *arg, sint8_t err)
|
|
||||||
{
|
{
|
||||||
NODE_DBG("net_socket_reconnected is called.\n");
|
NODE_DBG("net_socket_reconnected is called.\n");
|
||||||
net_socket_disconnected(arg);
|
net_socket_disconnected(arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR
|
static void net_socket_received(void *arg, char *pdata, unsigned short len)
|
||||||
net_socket_received(void *arg, char *pdata, unsigned short len)
|
|
||||||
{
|
{
|
||||||
NODE_DBG("net_socket_received is called.\n");
|
NODE_DBG("net_socket_received is called.\n");
|
||||||
struct espconn *pesp_conn = arg;
|
struct espconn *pesp_conn = arg;
|
||||||
@ -169,8 +164,7 @@ net_socket_received(void *arg, char *pdata, unsigned short len)
|
|||||||
lua_call(gL, 2, 0);
|
lua_call(gL, 2, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR
|
static void net_socket_sent(void *arg)
|
||||||
net_socket_sent(void *arg)
|
|
||||||
{
|
{
|
||||||
// NODE_DBG("net_socket_sent is called.\n");
|
// NODE_DBG("net_socket_sent is called.\n");
|
||||||
struct espconn *pesp_conn = arg;
|
struct espconn *pesp_conn = arg;
|
||||||
@ -188,8 +182,7 @@ net_socket_sent(void *arg)
|
|||||||
lua_call(gL, 1, 0);
|
lua_call(gL, 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR
|
static void net_dns_found(const char *name, ip_addr_t *ipaddr, void *arg)
|
||||||
net_dns_found(const char *name, ip_addr_t *ipaddr, void *arg)
|
|
||||||
{
|
{
|
||||||
NODE_DBG("net_dns_found is called.\n");
|
NODE_DBG("net_dns_found is called.\n");
|
||||||
struct espconn *pesp_conn = arg;
|
struct espconn *pesp_conn = arg;
|
||||||
@ -242,8 +235,7 @@ net_dns_found(const char *name, ip_addr_t *ipaddr, void *arg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR
|
static void net_server_connected(void *arg) // for tcp only
|
||||||
net_server_connected(void *arg) // for tcp only
|
|
||||||
{
|
{
|
||||||
NODE_DBG("net_server_connected is called.\n");
|
NODE_DBG("net_server_connected is called.\n");
|
||||||
struct espconn *pesp_conn = arg;
|
struct espconn *pesp_conn = arg;
|
||||||
@ -324,8 +316,7 @@ net_server_connected(void *arg) // for tcp only
|
|||||||
lua_call(gL, 1, 0); // function(conn)
|
lua_call(gL, 1, 0); // function(conn)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR
|
static void net_socket_connected(void *arg)
|
||||||
net_socket_connected(void *arg)
|
|
||||||
{
|
{
|
||||||
NODE_DBG("net_socket_connected is called.\n");
|
NODE_DBG("net_socket_connected is called.\n");
|
||||||
struct espconn *pesp_conn = arg;
|
struct espconn *pesp_conn = arg;
|
||||||
@ -349,8 +340,7 @@ net_socket_connected(void *arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lua: s = net.create(type, secure/timeout, function(conn))
|
// Lua: s = net.create(type, secure/timeout, function(conn))
|
||||||
static int ICACHE_FLASH_ATTR
|
static int net_create( lua_State* L, const char* mt )
|
||||||
net_create( lua_State* L, const char* mt )
|
|
||||||
{
|
{
|
||||||
NODE_DBG("net_create is called.\n");
|
NODE_DBG("net_create is called.\n");
|
||||||
struct espconn *pesp_conn = NULL;
|
struct espconn *pesp_conn = NULL;
|
||||||
@ -496,8 +486,7 @@ net_create( lua_State* L, const char* mt )
|
|||||||
// call close() first
|
// call close() first
|
||||||
// server: disconnect server, unref everything
|
// server: disconnect server, unref everything
|
||||||
// socket: unref everything
|
// socket: unref everything
|
||||||
static int ICACHE_FLASH_ATTR
|
static int net_delete( lua_State* L, const char* mt )
|
||||||
net_delete( lua_State* L, const char* mt )
|
|
||||||
{
|
{
|
||||||
NODE_DBG("net_delete is called.\n");
|
NODE_DBG("net_delete is called.\n");
|
||||||
bool isserver = false;
|
bool isserver = false;
|
||||||
@ -571,7 +560,7 @@ net_delete( lua_State* L, const char* mt )
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR socket_connect(struct espconn *pesp_conn)
|
static void socket_connect(struct espconn *pesp_conn)
|
||||||
{
|
{
|
||||||
if(pesp_conn == NULL)
|
if(pesp_conn == NULL)
|
||||||
return;
|
return;
|
||||||
@ -600,8 +589,7 @@ static void ICACHE_FLASH_ATTR socket_connect(struct espconn *pesp_conn)
|
|||||||
|
|
||||||
static void socket_dns_found(const char *name, ip_addr_t *ipaddr, void *arg);
|
static void socket_dns_found(const char *name, ip_addr_t *ipaddr, void *arg);
|
||||||
static dns_reconn_count = 0;
|
static dns_reconn_count = 0;
|
||||||
static void ICACHE_FLASH_ATTR
|
static void socket_dns_found(const char *name, ip_addr_t *ipaddr, void *arg)
|
||||||
socket_dns_found(const char *name, ip_addr_t *ipaddr, void *arg)
|
|
||||||
{
|
{
|
||||||
NODE_DBG("socket_dns_found is called.\n");
|
NODE_DBG("socket_dns_found is called.\n");
|
||||||
struct espconn *pesp_conn = arg;
|
struct espconn *pesp_conn = arg;
|
||||||
@ -647,8 +635,7 @@ socket_dns_found(const char *name, ip_addr_t *ipaddr, void *arg)
|
|||||||
|
|
||||||
// Lua: server:listen( port, ip, function(con) )
|
// Lua: server:listen( port, ip, function(con) )
|
||||||
// Lua: socket:connect( port, ip, function(con) )
|
// Lua: socket:connect( port, ip, function(con) )
|
||||||
static int ICACHE_FLASH_ATTR
|
static int net_start( lua_State* L, const char* mt )
|
||||||
net_start( lua_State* L, const char* mt )
|
|
||||||
{
|
{
|
||||||
NODE_DBG("net_start is called.\n");
|
NODE_DBG("net_start is called.\n");
|
||||||
struct espconn *pesp_conn = NULL;
|
struct espconn *pesp_conn = NULL;
|
||||||
@ -819,8 +806,7 @@ net_start( lua_State* L, const char* mt )
|
|||||||
// Lua: server/socket:close()
|
// Lua: server/socket:close()
|
||||||
// server disconnect everything, unref everything
|
// server disconnect everything, unref everything
|
||||||
// client disconnect and unref itself
|
// client disconnect and unref itself
|
||||||
static int ICACHE_FLASH_ATTR
|
static int net_close( lua_State* L, const char* mt )
|
||||||
net_close( lua_State* L, const char* mt )
|
|
||||||
{
|
{
|
||||||
NODE_DBG("net_close is called.\n");
|
NODE_DBG("net_close is called.\n");
|
||||||
bool isserver = false;
|
bool isserver = false;
|
||||||
@ -929,8 +915,7 @@ net_close( lua_State* L, const char* mt )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lua: socket/udpserver:on( "method", function(s) )
|
// Lua: socket/udpserver:on( "method", function(s) )
|
||||||
static int ICACHE_FLASH_ATTR
|
static int net_on( lua_State* L, const char* mt )
|
||||||
net_on( lua_State* L, const char* mt )
|
|
||||||
{
|
{
|
||||||
NODE_DBG("net_on is called.\n");
|
NODE_DBG("net_on is called.\n");
|
||||||
bool isserver = false;
|
bool isserver = false;
|
||||||
@ -994,8 +979,7 @@ net_on( lua_State* L, const char* mt )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lua: server/socket:send( string, function(sent) )
|
// Lua: server/socket:send( string, function(sent) )
|
||||||
static int ICACHE_FLASH_ATTR
|
static int net_send( lua_State* L, const char* mt )
|
||||||
net_send( lua_State* L, const char* mt )
|
|
||||||
{
|
{
|
||||||
// NODE_DBG("net_send is called.\n");
|
// NODE_DBG("net_send is called.\n");
|
||||||
bool isserver = false;
|
bool isserver = false;
|
||||||
@ -1061,8 +1045,7 @@ net_send( lua_State* L, const char* mt )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lua: socket:dns( string, function(socket, ip) )
|
// Lua: socket:dns( string, function(socket, ip) )
|
||||||
static int ICACHE_FLASH_ATTR
|
static int net_dns( lua_State* L, const char* mt )
|
||||||
net_dns( lua_State* L, const char* mt )
|
|
||||||
{
|
{
|
||||||
NODE_DBG("net_dns is called.\n");
|
NODE_DBG("net_dns is called.\n");
|
||||||
bool isserver = false;
|
bool isserver = false;
|
||||||
@ -1115,111 +1098,98 @@ net_dns( lua_State* L, const char* mt )
|
|||||||
|
|
||||||
|
|
||||||
// Lua: s = net.createServer(type, function(server))
|
// Lua: s = net.createServer(type, function(server))
|
||||||
static int ICACHE_FLASH_ATTR net_createServer( lua_State* L )
|
static int net_createServer( lua_State* L )
|
||||||
{
|
{
|
||||||
const char *mt = "net.server";
|
const char *mt = "net.server";
|
||||||
return net_create(L, mt);
|
return net_create(L, mt);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lua: server:delete()
|
// Lua: server:delete()
|
||||||
static int ICACHE_FLASH_ATTR
|
static int net_server_delete( lua_State* L )
|
||||||
net_server_delete( lua_State* L )
|
|
||||||
{
|
{
|
||||||
const char *mt = "net.server";
|
const char *mt = "net.server";
|
||||||
return net_delete(L, mt);
|
return net_delete(L, mt);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lua: server:listen( port, ip )
|
// Lua: server:listen( port, ip )
|
||||||
static int ICACHE_FLASH_ATTR
|
static int net_server_listen( lua_State* L )
|
||||||
net_server_listen( lua_State* L )
|
|
||||||
{
|
{
|
||||||
const char *mt = "net.server";
|
const char *mt = "net.server";
|
||||||
return net_start(L, mt);
|
return net_start(L, mt);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lua: server:close()
|
// Lua: server:close()
|
||||||
static int ICACHE_FLASH_ATTR
|
static int net_server_close( lua_State* L )
|
||||||
net_server_close( lua_State* L )
|
|
||||||
{
|
{
|
||||||
const char *mt = "net.server";
|
const char *mt = "net.server";
|
||||||
return net_close(L, mt);
|
return net_close(L, mt);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lua: udpserver:on( "method", function(udpserver) )
|
// Lua: udpserver:on( "method", function(udpserver) )
|
||||||
static int ICACHE_FLASH_ATTR
|
static int net_udpserver_on( lua_State* L )
|
||||||
net_udpserver_on( lua_State* L )
|
|
||||||
{
|
{
|
||||||
const char *mt = "net.server";
|
const char *mt = "net.server";
|
||||||
return net_on(L, mt);
|
return net_on(L, mt);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lua: udpserver:send(string, function() )
|
// Lua: udpserver:send(string, function() )
|
||||||
static int ICACHE_FLASH_ATTR
|
static int net_udpserver_send( lua_State* L )
|
||||||
net_udpserver_send( lua_State* L )
|
|
||||||
{
|
{
|
||||||
const char *mt = "net.server";
|
const char *mt = "net.server";
|
||||||
return net_send(L, mt);;
|
return net_send(L, mt);;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lua: s = net.createConnection(type, function(conn))
|
// Lua: s = net.createConnection(type, function(conn))
|
||||||
static int ICACHE_FLASH_ATTR
|
static int net_createConnection( lua_State* L )
|
||||||
net_createConnection( lua_State* L )
|
|
||||||
{
|
{
|
||||||
const char *mt = "net.socket";
|
const char *mt = "net.socket";
|
||||||
return net_create(L, mt);
|
return net_create(L, mt);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lua: socket:delete()
|
// Lua: socket:delete()
|
||||||
static int ICACHE_FLASH_ATTR
|
static int net_socket_delete( lua_State* L )
|
||||||
net_socket_delete( lua_State* L )
|
|
||||||
{
|
{
|
||||||
const char *mt = "net.socket";
|
const char *mt = "net.socket";
|
||||||
return net_delete(L, mt);
|
return net_delete(L, mt);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lua: socket:connect( port, ip )
|
// Lua: socket:connect( port, ip )
|
||||||
static int ICACHE_FLASH_ATTR
|
static int net_socket_connect( lua_State* L )
|
||||||
net_socket_connect( lua_State* L )
|
|
||||||
{
|
{
|
||||||
const char *mt = "net.socket";
|
const char *mt = "net.socket";
|
||||||
return net_start(L, mt);
|
return net_start(L, mt);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lua: socket:close()
|
// Lua: socket:close()
|
||||||
static int ICACHE_FLASH_ATTR
|
static int net_socket_close( lua_State* L )
|
||||||
net_socket_close( lua_State* L )
|
|
||||||
{
|
{
|
||||||
const char *mt = "net.socket";
|
const char *mt = "net.socket";
|
||||||
return net_close(L, mt);
|
return net_close(L, mt);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lua: socket:on( "method", function(socket) )
|
// Lua: socket:on( "method", function(socket) )
|
||||||
static int ICACHE_FLASH_ATTR
|
static int net_socket_on( lua_State* L )
|
||||||
net_socket_on( lua_State* L )
|
|
||||||
{
|
{
|
||||||
const char *mt = "net.socket";
|
const char *mt = "net.socket";
|
||||||
return net_on(L, mt);
|
return net_on(L, mt);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lua: socket:send( string, function() )
|
// Lua: socket:send( string, function() )
|
||||||
static int ICACHE_FLASH_ATTR
|
static int net_socket_send( lua_State* L )
|
||||||
net_socket_send( lua_State* L )
|
|
||||||
{
|
{
|
||||||
const char *mt = "net.socket";
|
const char *mt = "net.socket";
|
||||||
return net_send(L, mt);
|
return net_send(L, mt);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lua: socket:dns( string, function(ip) )
|
// Lua: socket:dns( string, function(ip) )
|
||||||
static int ICACHE_FLASH_ATTR
|
static int net_socket_dns( lua_State* L )
|
||||||
net_socket_dns( lua_State* L )
|
|
||||||
{
|
{
|
||||||
const char *mt = "net.socket";
|
const char *mt = "net.socket";
|
||||||
return net_dns(L, mt);
|
return net_dns(L, mt);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
static int ICACHE_FLASH_ATTR
|
static int net_array_index( lua_State* L )
|
||||||
net_array_index( lua_State* L )
|
|
||||||
{
|
{
|
||||||
char** parray = luaL_checkudata(L, 1, "net.array");
|
char** parray = luaL_checkudata(L, 1, "net.array");
|
||||||
int index = luaL_checkint(L, 2);
|
int index = luaL_checkint(L, 2);
|
||||||
@ -1227,8 +1197,7 @@ net_array_index( lua_State* L )
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR
|
static int net_array_newindex( lua_State* L )
|
||||||
net_array_newindex( lua_State* L )
|
|
||||||
{
|
{
|
||||||
char** parray = luaL_checkudata(L, 1, "net.array");
|
char** parray = luaL_checkudata(L, 1, "net.array");
|
||||||
int index = luaL_checkint(L, 2);
|
int index = luaL_checkint(L, 2);
|
||||||
@ -1238,8 +1207,7 @@ net_array_newindex( lua_State* L )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// expose an array to lua, by storing it in a userdata with the array metatable
|
// expose an array to lua, by storing it in a userdata with the array metatable
|
||||||
static int ICACHE_FLASH_ATTR
|
static int expose_array(lua_State* L, char *array, unsigned short len) {
|
||||||
expose_array(lua_State* L, char *array, unsigned short len) {
|
|
||||||
char** parray = lua_newuserdata(L, len);
|
char** parray = lua_newuserdata(L, len);
|
||||||
*parray = array;
|
*parray = array;
|
||||||
luaL_getmetatable(L, "net.array");
|
luaL_getmetatable(L, "net.array");
|
||||||
@ -1300,7 +1268,7 @@ const LUA_REG_TYPE net_map[] =
|
|||||||
{ LNILKEY, LNILVAL }
|
{ LNILKEY, LNILVAL }
|
||||||
};
|
};
|
||||||
|
|
||||||
LUALIB_API int ICACHE_FLASH_ATTR luaopen_net( lua_State *L )
|
LUALIB_API int luaopen_net( lua_State *L )
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for(i=0;i<MAX_SOCKET;i++)
|
for(i=0;i<MAX_SOCKET;i++)
|
||||||
|
@ -15,14 +15,14 @@
|
|||||||
#include "flash_api.h"
|
#include "flash_api.h"
|
||||||
|
|
||||||
// Lua: restart()
|
// Lua: restart()
|
||||||
static int ICACHE_FLASH_ATTR node_restart( lua_State* L )
|
static int node_restart( lua_State* L )
|
||||||
{
|
{
|
||||||
system_restart();
|
system_restart();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lua: dsleep( us )
|
// Lua: dsleep( us )
|
||||||
static int ICACHE_FLASH_ATTR node_deepsleep( lua_State* L )
|
static int node_deepsleep( lua_State* L )
|
||||||
{
|
{
|
||||||
s32 us;
|
s32 us;
|
||||||
us = luaL_checkinteger( L, 1 );
|
us = luaL_checkinteger( L, 1 );
|
||||||
@ -33,7 +33,7 @@ static int ICACHE_FLASH_ATTR node_deepsleep( lua_State* L )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lua: info()
|
// Lua: info()
|
||||||
static int ICACHE_FLASH_ATTR node_info( lua_State* L )
|
static int node_info( lua_State* L )
|
||||||
{
|
{
|
||||||
lua_pushinteger(L, NODE_VERSION_MAJOR);
|
lua_pushinteger(L, NODE_VERSION_MAJOR);
|
||||||
lua_pushinteger(L, NODE_VERSION_MINOR);
|
lua_pushinteger(L, NODE_VERSION_MINOR);
|
||||||
@ -47,7 +47,7 @@ static int ICACHE_FLASH_ATTR node_info( lua_State* L )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lua: chipid()
|
// Lua: chipid()
|
||||||
static int ICACHE_FLASH_ATTR node_chipid( lua_State* L )
|
static int node_chipid( lua_State* L )
|
||||||
{
|
{
|
||||||
uint32_t id = system_get_chip_id();
|
uint32_t id = system_get_chip_id();
|
||||||
lua_pushinteger(L, id);
|
lua_pushinteger(L, id);
|
||||||
@ -55,7 +55,7 @@ static int ICACHE_FLASH_ATTR node_chipid( lua_State* L )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lua: flashid()
|
// Lua: flashid()
|
||||||
static int ICACHE_FLASH_ATTR node_flashid( lua_State* L )
|
static int node_flashid( lua_State* L )
|
||||||
{
|
{
|
||||||
uint32_t id = spi_flash_get_id();
|
uint32_t id = spi_flash_get_id();
|
||||||
lua_pushinteger( L, id );
|
lua_pushinteger( L, id );
|
||||||
@ -63,7 +63,7 @@ static int ICACHE_FLASH_ATTR node_flashid( lua_State* L )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lua: flashsize()
|
// Lua: flashsize()
|
||||||
static int ICACHE_FLASH_ATTR node_flashsize( lua_State* L )
|
static int node_flashsize( lua_State* L )
|
||||||
{
|
{
|
||||||
//uint32_t sz = 0;
|
//uint32_t sz = 0;
|
||||||
//if(lua_type(L, 1) == LUA_TNUMBER)
|
//if(lua_type(L, 1) == LUA_TNUMBER)
|
||||||
@ -80,7 +80,7 @@ static int ICACHE_FLASH_ATTR node_flashsize( lua_State* L )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lua: heap()
|
// Lua: heap()
|
||||||
static int ICACHE_FLASH_ATTR node_heap( lua_State* L )
|
static int node_heap( lua_State* L )
|
||||||
{
|
{
|
||||||
uint32_t sz = system_get_free_heap_size();
|
uint32_t sz = system_get_free_heap_size();
|
||||||
lua_pushinteger(L, sz);
|
lua_pushinteger(L, sz);
|
||||||
@ -90,7 +90,7 @@ static int ICACHE_FLASH_ATTR node_heap( lua_State* L )
|
|||||||
extern int led_high_count; // this is defined in lua.c
|
extern int led_high_count; // this is defined in lua.c
|
||||||
extern int led_low_count;
|
extern int led_low_count;
|
||||||
// Lua: led(low, high)
|
// Lua: led(low, high)
|
||||||
static int ICACHE_FLASH_ATTR node_led( lua_State* L )
|
static int node_led( lua_State* L )
|
||||||
{
|
{
|
||||||
int low, high;
|
int low, high;
|
||||||
if ( lua_isnumber(L, 1) )
|
if ( lua_isnumber(L, 1) )
|
||||||
@ -120,7 +120,7 @@ static int long_key_ref = LUA_NOREF;
|
|||||||
static int short_key_ref = LUA_NOREF;
|
static int short_key_ref = LUA_NOREF;
|
||||||
static lua_State *gL = NULL;
|
static lua_State *gL = NULL;
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR default_long_press(void *arg){
|
void default_long_press(void *arg){
|
||||||
if(led_high_count == 12 && led_low_count == 12){
|
if(led_high_count == 12 && led_low_count == 12){
|
||||||
led_low_count = led_high_count = 6;
|
led_low_count = led_high_count = 6;
|
||||||
} else {
|
} else {
|
||||||
@ -131,11 +131,11 @@ void ICACHE_FLASH_ATTR default_long_press(void *arg){
|
|||||||
// NODE_DBG("default_long_press is called. hc: %d, lc: %d\n", led_high_count, led_low_count);
|
// NODE_DBG("default_long_press is called. hc: %d, lc: %d\n", led_high_count, led_low_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR default_short_press(void *arg){
|
void default_short_press(void *arg){
|
||||||
system_restart();
|
system_restart();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR key_long_press(void *arg){
|
void key_long_press(void *arg){
|
||||||
NODE_DBG("key_long_press is called.\n");
|
NODE_DBG("key_long_press is called.\n");
|
||||||
if(long_key_ref == LUA_NOREF){
|
if(long_key_ref == LUA_NOREF){
|
||||||
default_long_press(arg);
|
default_long_press(arg);
|
||||||
@ -147,7 +147,7 @@ void ICACHE_FLASH_ATTR key_long_press(void *arg){
|
|||||||
lua_call(gL, 0, 0);
|
lua_call(gL, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR key_short_press(void *arg){
|
void key_short_press(void *arg){
|
||||||
NODE_DBG("key_short_press is called.\n");
|
NODE_DBG("key_short_press is called.\n");
|
||||||
if(short_key_ref == LUA_NOREF){
|
if(short_key_ref == LUA_NOREF){
|
||||||
default_short_press(arg);
|
default_short_press(arg);
|
||||||
@ -160,7 +160,7 @@ void ICACHE_FLASH_ATTR key_short_press(void *arg){
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lua: key(type, function)
|
// Lua: key(type, function)
|
||||||
static int ICACHE_FLASH_ATTR node_key( lua_State* L )
|
static int node_key( lua_State* L )
|
||||||
{
|
{
|
||||||
int *ref = NULL;
|
int *ref = NULL;
|
||||||
size_t sl;
|
size_t sl;
|
||||||
@ -196,7 +196,7 @@ extern lua_Load gLoad;
|
|||||||
extern os_timer_t lua_timer;
|
extern os_timer_t lua_timer;
|
||||||
extern void dojob(lua_Load *load);
|
extern void dojob(lua_Load *load);
|
||||||
// Lua: input("string")
|
// Lua: input("string")
|
||||||
static int ICACHE_FLASH_ATTR node_input( lua_State* L )
|
static int node_input( lua_State* L )
|
||||||
{
|
{
|
||||||
size_t l=0;
|
size_t l=0;
|
||||||
const char *s = luaL_checklstring(L, 1, &l);
|
const char *s = luaL_checklstring(L, 1, &l);
|
||||||
@ -221,7 +221,7 @@ static int ICACHE_FLASH_ATTR node_input( lua_State* L )
|
|||||||
|
|
||||||
static int output_redir_ref = LUA_NOREF;
|
static int output_redir_ref = LUA_NOREF;
|
||||||
static int serial_debug = 1;
|
static int serial_debug = 1;
|
||||||
void ICACHE_FLASH_ATTR output_redirect(const char *str){
|
void output_redirect(const char *str){
|
||||||
// if(c_strlen(str)>=TX_BUFF_SIZE){
|
// if(c_strlen(str)>=TX_BUFF_SIZE){
|
||||||
// NODE_ERR("output too long.\n");
|
// NODE_ERR("output too long.\n");
|
||||||
// return;
|
// return;
|
||||||
@ -242,7 +242,7 @@ void ICACHE_FLASH_ATTR output_redirect(const char *str){
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lua: output(function(c), debug)
|
// Lua: output(function(c), debug)
|
||||||
static int ICACHE_FLASH_ATTR node_output( lua_State* L )
|
static int node_output( lua_State* L )
|
||||||
{
|
{
|
||||||
gL = L;
|
gL = L;
|
||||||
// luaL_checkanyfunction(L, 1);
|
// luaL_checkanyfunction(L, 1);
|
||||||
@ -293,7 +293,7 @@ const LUA_REG_TYPE node_map[] =
|
|||||||
{ LNILKEY, LNILVAL }
|
{ LNILKEY, LNILVAL }
|
||||||
};
|
};
|
||||||
|
|
||||||
LUALIB_API int ICACHE_FLASH_ATTR luaopen_node( lua_State *L )
|
LUALIB_API int luaopen_node( lua_State *L )
|
||||||
{
|
{
|
||||||
#if LUA_OPTIMIZE_MEMORY > 0
|
#if LUA_OPTIMIZE_MEMORY > 0
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
#include "driver/onewire.h"
|
#include "driver/onewire.h"
|
||||||
|
|
||||||
// Lua: ow.setup( id )
|
// Lua: ow.setup( id )
|
||||||
static int ICACHE_FLASH_ATTR ow_setup( lua_State *L )
|
static int ow_setup( lua_State *L )
|
||||||
{
|
{
|
||||||
unsigned id = luaL_checkinteger( L, 1 );
|
unsigned id = luaL_checkinteger( L, 1 );
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ static int ICACHE_FLASH_ATTR ow_setup( lua_State *L )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lua: r = ow.reset( id )
|
// Lua: r = ow.reset( id )
|
||||||
static int ICACHE_FLASH_ATTR ow_reset( lua_State *L )
|
static int ow_reset( lua_State *L )
|
||||||
{
|
{
|
||||||
unsigned id = luaL_checkinteger( L, 1 );
|
unsigned id = luaL_checkinteger( L, 1 );
|
||||||
MOD_CHECK_ID( ow, id );
|
MOD_CHECK_ID( ow, id );
|
||||||
@ -31,7 +31,7 @@ static int ICACHE_FLASH_ATTR ow_reset( lua_State *L )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lua: ow.skip( id )
|
// Lua: ow.skip( id )
|
||||||
static int ICACHE_FLASH_ATTR ow_skip( lua_State *L )
|
static int ow_skip( lua_State *L )
|
||||||
{
|
{
|
||||||
unsigned id = luaL_checkinteger( L, 1 );
|
unsigned id = luaL_checkinteger( L, 1 );
|
||||||
MOD_CHECK_ID( ow, id );
|
MOD_CHECK_ID( ow, id );
|
||||||
@ -40,7 +40,7 @@ static int ICACHE_FLASH_ATTR ow_skip( lua_State *L )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lua: ow.select( id, buf[8])
|
// Lua: ow.select( id, buf[8])
|
||||||
static int ICACHE_FLASH_ATTR ow_select( lua_State *L )
|
static int ow_select( lua_State *L )
|
||||||
{
|
{
|
||||||
uint8_t rom[8];
|
uint8_t rom[8];
|
||||||
size_t datalen;
|
size_t datalen;
|
||||||
@ -79,7 +79,7 @@ static int ICACHE_FLASH_ATTR ow_select( lua_State *L )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lua: ow.write( id, v, power)
|
// Lua: ow.write( id, v, power)
|
||||||
static int ICACHE_FLASH_ATTR ow_write( lua_State *L )
|
static int ow_write( lua_State *L )
|
||||||
{
|
{
|
||||||
int power = 0;
|
int power = 0;
|
||||||
unsigned id = luaL_checkinteger( L, 1 );
|
unsigned id = luaL_checkinteger( L, 1 );
|
||||||
@ -99,7 +99,7 @@ static int ICACHE_FLASH_ATTR ow_write( lua_State *L )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lua: ow.write_bytes( id, buf, power)
|
// Lua: ow.write_bytes( id, buf, power)
|
||||||
static int ICACHE_FLASH_ATTR ow_write_bytes( lua_State *L )
|
static int ow_write_bytes( lua_State *L )
|
||||||
{
|
{
|
||||||
int power = 0;
|
int power = 0;
|
||||||
size_t datalen;
|
size_t datalen;
|
||||||
@ -119,7 +119,7 @@ static int ICACHE_FLASH_ATTR ow_write_bytes( lua_State *L )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lua: r = ow.read( id )
|
// Lua: r = ow.read( id )
|
||||||
static int ICACHE_FLASH_ATTR ow_read( lua_State *L )
|
static int ow_read( lua_State *L )
|
||||||
{
|
{
|
||||||
unsigned id = luaL_checkinteger( L, 1 );
|
unsigned id = luaL_checkinteger( L, 1 );
|
||||||
MOD_CHECK_ID( ow, id );
|
MOD_CHECK_ID( ow, id );
|
||||||
@ -128,7 +128,7 @@ static int ICACHE_FLASH_ATTR ow_read( lua_State *L )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lua: r = ow.read_bytes( id, size )
|
// Lua: r = ow.read_bytes( id, size )
|
||||||
static int ICACHE_FLASH_ATTR ow_read_bytes( lua_State *L )
|
static int ow_read_bytes( lua_State *L )
|
||||||
{
|
{
|
||||||
unsigned id = luaL_checkinteger( L, 1 );
|
unsigned id = luaL_checkinteger( L, 1 );
|
||||||
MOD_CHECK_ID( ow, id );
|
MOD_CHECK_ID( ow, id );
|
||||||
@ -148,7 +148,7 @@ static int ICACHE_FLASH_ATTR ow_read_bytes( lua_State *L )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lua: ow.depower( id )
|
// Lua: ow.depower( id )
|
||||||
static int ICACHE_FLASH_ATTR ow_depower( lua_State *L )
|
static int ow_depower( lua_State *L )
|
||||||
{
|
{
|
||||||
unsigned id = luaL_checkinteger( L, 1 );
|
unsigned id = luaL_checkinteger( L, 1 );
|
||||||
MOD_CHECK_ID( ow, id );
|
MOD_CHECK_ID( ow, id );
|
||||||
@ -159,7 +159,7 @@ static int ICACHE_FLASH_ATTR ow_depower( lua_State *L )
|
|||||||
#if ONEWIRE_SEARCH
|
#if ONEWIRE_SEARCH
|
||||||
// Clear the search state so that if will start from the beginning again.
|
// Clear the search state so that if will start from the beginning again.
|
||||||
// Lua: ow.reset_search( id )
|
// Lua: ow.reset_search( id )
|
||||||
static int ICACHE_FLASH_ATTR ow_reset_search( lua_State *L )
|
static int ow_reset_search( lua_State *L )
|
||||||
{
|
{
|
||||||
unsigned id = luaL_checkinteger( L, 1 );
|
unsigned id = luaL_checkinteger( L, 1 );
|
||||||
MOD_CHECK_ID( ow, id );
|
MOD_CHECK_ID( ow, id );
|
||||||
@ -171,7 +171,7 @@ static int ICACHE_FLASH_ATTR ow_reset_search( lua_State *L )
|
|||||||
// Setup the search to find the device type 'family_code' on the next call
|
// Setup the search to find the device type 'family_code' on the next call
|
||||||
// to search(*newAddr) if it is present.
|
// to search(*newAddr) if it is present.
|
||||||
// Lua: ow.target_search( id, family_code)
|
// Lua: ow.target_search( id, family_code)
|
||||||
static int ICACHE_FLASH_ATTR ow_target_search( lua_State *L )
|
static int ow_target_search( lua_State *L )
|
||||||
{
|
{
|
||||||
unsigned id = luaL_checkinteger( L, 1 );
|
unsigned id = luaL_checkinteger( L, 1 );
|
||||||
MOD_CHECK_ID( ow, id );
|
MOD_CHECK_ID( ow, id );
|
||||||
@ -193,7 +193,7 @@ static int ICACHE_FLASH_ATTR ow_target_search( lua_State *L )
|
|||||||
// the same devices in the same order.
|
// the same devices in the same order.
|
||||||
|
|
||||||
// Lua: r = ow.search( id )
|
// Lua: r = ow.search( id )
|
||||||
static int ICACHE_FLASH_ATTR ow_search( lua_State *L )
|
static int ow_search( lua_State *L )
|
||||||
{
|
{
|
||||||
unsigned id = luaL_checkinteger( L, 1 );
|
unsigned id = luaL_checkinteger( L, 1 );
|
||||||
MOD_CHECK_ID( ow, id );
|
MOD_CHECK_ID( ow, id );
|
||||||
@ -217,7 +217,7 @@ static int ICACHE_FLASH_ATTR ow_search( lua_State *L )
|
|||||||
#if ONEWIRE_CRC
|
#if ONEWIRE_CRC
|
||||||
// uint8_t onewire_crc8(const uint8_t *addr, uint8_t len);
|
// uint8_t onewire_crc8(const uint8_t *addr, uint8_t len);
|
||||||
// Lua: r = ow.crc8( buf )
|
// Lua: r = ow.crc8( buf )
|
||||||
static int ICACHE_FLASH_ATTR ow_crc8( lua_State *L )
|
static int ow_crc8( lua_State *L )
|
||||||
{
|
{
|
||||||
size_t datalen;
|
size_t datalen;
|
||||||
const uint8_t *pdata = luaL_checklstring( L, 1, &datalen );
|
const uint8_t *pdata = luaL_checklstring( L, 1, &datalen );
|
||||||
@ -230,7 +230,7 @@ static int ICACHE_FLASH_ATTR ow_crc8( lua_State *L )
|
|||||||
#if ONEWIRE_CRC16
|
#if ONEWIRE_CRC16
|
||||||
// bool onewire_check_crc16(const uint8_t* input, uint16_t len, const uint8_t* inverted_crc, uint16_t crc);
|
// bool onewire_check_crc16(const uint8_t* input, uint16_t len, const uint8_t* inverted_crc, uint16_t crc);
|
||||||
// Lua: b = ow.check_crc16( buf, inverted_crc0, inverted_crc1, crc )
|
// Lua: b = ow.check_crc16( buf, inverted_crc0, inverted_crc1, crc )
|
||||||
static int ICACHE_FLASH_ATTR ow_check_crc16( lua_State *L )
|
static int ow_check_crc16( lua_State *L )
|
||||||
{
|
{
|
||||||
size_t datalen;
|
size_t datalen;
|
||||||
uint8_t inverted_crc[2];
|
uint8_t inverted_crc[2];
|
||||||
@ -262,7 +262,7 @@ static int ICACHE_FLASH_ATTR ow_check_crc16( lua_State *L )
|
|||||||
|
|
||||||
// uint16_t onewire_crc16(const uint8_t* input, uint16_t len, uint16_t crc);
|
// uint16_t onewire_crc16(const uint8_t* input, uint16_t len, uint16_t crc);
|
||||||
// Lua: r = ow.crc16( buf, crc )
|
// Lua: r = ow.crc16( buf, crc )
|
||||||
static int ICACHE_FLASH_ATTR ow_crc16( lua_State *L )
|
static int ow_crc16( lua_State *L )
|
||||||
{
|
{
|
||||||
size_t datalen;
|
size_t datalen;
|
||||||
const uint8_t *pdata = luaL_checklstring( L, 1, &datalen );
|
const uint8_t *pdata = luaL_checklstring( L, 1, &datalen );
|
||||||
@ -313,7 +313,7 @@ const LUA_REG_TYPE ow_map[] =
|
|||||||
{ LNILKEY, LNILVAL }
|
{ LNILKEY, LNILVAL }
|
||||||
};
|
};
|
||||||
|
|
||||||
LUALIB_API int ICACHE_FLASH_ATTR luaopen_ow( lua_State *L )
|
LUALIB_API int luaopen_ow( lua_State *L )
|
||||||
{
|
{
|
||||||
#if LUA_OPTIMIZE_MEMORY > 0
|
#if LUA_OPTIMIZE_MEMORY > 0
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#include "c_types.h"
|
#include "c_types.h"
|
||||||
|
|
||||||
// Lua: realfrequency = setup( id, frequency, duty )
|
// Lua: realfrequency = setup( id, frequency, duty )
|
||||||
static int ICACHE_FLASH_ATTR lpwm_setup( lua_State* L )
|
static int lpwm_setup( lua_State* L )
|
||||||
{
|
{
|
||||||
s32 freq; // signed, to error check for negative values
|
s32 freq; // signed, to error check for negative values
|
||||||
unsigned duty;
|
unsigned duty;
|
||||||
@ -35,7 +35,7 @@ static int ICACHE_FLASH_ATTR lpwm_setup( lua_State* L )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lua: close( id )
|
// Lua: close( id )
|
||||||
static int ICACHE_FLASH_ATTR lpwm_close( lua_State* L )
|
static int lpwm_close( lua_State* L )
|
||||||
{
|
{
|
||||||
unsigned id;
|
unsigned id;
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ static int ICACHE_FLASH_ATTR lpwm_close( lua_State* L )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lua: start( id )
|
// Lua: start( id )
|
||||||
static int ICACHE_FLASH_ATTR lpwm_start( lua_State* L )
|
static int lpwm_start( lua_State* L )
|
||||||
{
|
{
|
||||||
unsigned id;
|
unsigned id;
|
||||||
id = luaL_checkinteger( L, 1 );
|
id = luaL_checkinteger( L, 1 );
|
||||||
@ -56,7 +56,7 @@ static int ICACHE_FLASH_ATTR lpwm_start( lua_State* L )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lua: stop( id )
|
// Lua: stop( id )
|
||||||
static int ICACHE_FLASH_ATTR lpwm_stop( lua_State* L )
|
static int lpwm_stop( lua_State* L )
|
||||||
{
|
{
|
||||||
unsigned id;
|
unsigned id;
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ static int ICACHE_FLASH_ATTR lpwm_stop( lua_State* L )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lua: realclock = setclock( id, clock )
|
// Lua: realclock = setclock( id, clock )
|
||||||
static int ICACHE_FLASH_ATTR lpwm_setclock( lua_State* L )
|
static int lpwm_setclock( lua_State* L )
|
||||||
{
|
{
|
||||||
unsigned id;
|
unsigned id;
|
||||||
s32 clk; // signed to error-check for negative values
|
s32 clk; // signed to error-check for negative values
|
||||||
@ -83,7 +83,7 @@ static int ICACHE_FLASH_ATTR lpwm_setclock( lua_State* L )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lua: clock = getclock( id )
|
// Lua: clock = getclock( id )
|
||||||
static int ICACHE_FLASH_ATTR lpwm_getclock( lua_State* L )
|
static int lpwm_getclock( lua_State* L )
|
||||||
{
|
{
|
||||||
unsigned id;
|
unsigned id;
|
||||||
u32 clk;
|
u32 clk;
|
||||||
@ -96,7 +96,7 @@ static int ICACHE_FLASH_ATTR lpwm_getclock( lua_State* L )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lua: realduty = setduty( id, duty )
|
// Lua: realduty = setduty( id, duty )
|
||||||
static int ICACHE_FLASH_ATTR lpwm_setduty( lua_State* L )
|
static int lpwm_setduty( lua_State* L )
|
||||||
{
|
{
|
||||||
unsigned id;
|
unsigned id;
|
||||||
s32 duty; // signed to error-check for negative values
|
s32 duty; // signed to error-check for negative values
|
||||||
@ -112,7 +112,7 @@ static int ICACHE_FLASH_ATTR lpwm_setduty( lua_State* L )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lua: duty = getduty( id )
|
// Lua: duty = getduty( id )
|
||||||
static int ICACHE_FLASH_ATTR lpwm_getduty( lua_State* L )
|
static int lpwm_getduty( lua_State* L )
|
||||||
{
|
{
|
||||||
unsigned id;
|
unsigned id;
|
||||||
u32 duty;
|
u32 duty;
|
||||||
@ -143,7 +143,7 @@ const LUA_REG_TYPE pwm_map[] =
|
|||||||
{ LNILKEY, LNILVAL }
|
{ LNILKEY, LNILVAL }
|
||||||
};
|
};
|
||||||
|
|
||||||
LUALIB_API int ICACHE_FLASH_ATTR luaopen_pwm( lua_State *L )
|
LUALIB_API int luaopen_pwm( lua_State *L )
|
||||||
{
|
{
|
||||||
#if LUA_OPTIMIZE_MEMORY > 0
|
#if LUA_OPTIMIZE_MEMORY > 0
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -12,57 +12,50 @@
|
|||||||
static os_timer_t alarm_timer[NUM_TMR];
|
static os_timer_t alarm_timer[NUM_TMR];
|
||||||
static int alarm_timer_cb_ref[NUM_TMR] = {LUA_NOREF,LUA_NOREF,LUA_NOREF,LUA_NOREF,LUA_NOREF,LUA_NOREF,LUA_NOREF};
|
static int alarm_timer_cb_ref[NUM_TMR] = {LUA_NOREF,LUA_NOREF,LUA_NOREF,LUA_NOREF,LUA_NOREF,LUA_NOREF,LUA_NOREF};
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR alarm_timer_common(lua_State* L, unsigned id){
|
void alarm_timer_common(lua_State* L, unsigned id){
|
||||||
if(alarm_timer_cb_ref[id] == LUA_NOREF)
|
if(alarm_timer_cb_ref[id] == LUA_NOREF)
|
||||||
return;
|
return;
|
||||||
lua_rawgeti(L, LUA_REGISTRYINDEX, alarm_timer_cb_ref[id]);
|
lua_rawgeti(L, LUA_REGISTRYINDEX, alarm_timer_cb_ref[id]);
|
||||||
lua_call(L, 0, 0);
|
lua_call(L, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR
|
void alarm_timer_cb0(void *arg){
|
||||||
alarm_timer_cb0(void *arg){
|
|
||||||
if( !arg )
|
if( !arg )
|
||||||
return;
|
return;
|
||||||
alarm_timer_common((lua_State*)arg, 0);
|
alarm_timer_common((lua_State*)arg, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR
|
void alarm_timer_cb1(void *arg){
|
||||||
alarm_timer_cb1(void *arg){
|
|
||||||
if( !arg )
|
if( !arg )
|
||||||
return;
|
return;
|
||||||
alarm_timer_common((lua_State*)arg, 1);
|
alarm_timer_common((lua_State*)arg, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR
|
void alarm_timer_cb2(void *arg){
|
||||||
alarm_timer_cb2(void *arg){
|
|
||||||
if( !arg )
|
if( !arg )
|
||||||
return;
|
return;
|
||||||
alarm_timer_common((lua_State*)arg, 2);
|
alarm_timer_common((lua_State*)arg, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR
|
void alarm_timer_cb3(void *arg){
|
||||||
alarm_timer_cb3(void *arg){
|
|
||||||
if( !arg )
|
if( !arg )
|
||||||
return;
|
return;
|
||||||
alarm_timer_common((lua_State*)arg, 3);
|
alarm_timer_common((lua_State*)arg, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR
|
void alarm_timer_cb4(void *arg){
|
||||||
alarm_timer_cb4(void *arg){
|
|
||||||
if( !arg )
|
if( !arg )
|
||||||
return;
|
return;
|
||||||
alarm_timer_common((lua_State*)arg, 4);
|
alarm_timer_common((lua_State*)arg, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR
|
void alarm_timer_cb5(void *arg){
|
||||||
alarm_timer_cb5(void *arg){
|
|
||||||
if( !arg )
|
if( !arg )
|
||||||
return;
|
return;
|
||||||
alarm_timer_common((lua_State*)arg, 5);
|
alarm_timer_common((lua_State*)arg, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR
|
void alarm_timer_cb6(void *arg){
|
||||||
alarm_timer_cb6(void *arg){
|
|
||||||
if( !arg )
|
if( !arg )
|
||||||
return;
|
return;
|
||||||
alarm_timer_common((lua_State*)arg, 6);
|
alarm_timer_common((lua_State*)arg, 6);
|
||||||
@ -72,7 +65,7 @@ typedef void (*alarm_timer_callback)(void *arg);
|
|||||||
static alarm_timer_callback alarm_timer_cb[NUM_TMR] = {alarm_timer_cb0,alarm_timer_cb1,alarm_timer_cb2,alarm_timer_cb3,alarm_timer_cb4,alarm_timer_cb5,alarm_timer_cb6};
|
static alarm_timer_callback alarm_timer_cb[NUM_TMR] = {alarm_timer_cb0,alarm_timer_cb1,alarm_timer_cb2,alarm_timer_cb3,alarm_timer_cb4,alarm_timer_cb5,alarm_timer_cb6};
|
||||||
|
|
||||||
// Lua: delay( us )
|
// Lua: delay( us )
|
||||||
static int ICACHE_FLASH_ATTR tmr_delay( lua_State* L )
|
static int tmr_delay( lua_State* L )
|
||||||
{
|
{
|
||||||
s32 us;
|
s32 us;
|
||||||
us = luaL_checkinteger( L, 1 );
|
us = luaL_checkinteger( L, 1 );
|
||||||
@ -91,7 +84,7 @@ static int ICACHE_FLASH_ATTR tmr_delay( lua_State* L )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lua: now() , return system timer in us
|
// Lua: now() , return system timer in us
|
||||||
static int ICACHE_FLASH_ATTR tmr_now( lua_State* L )
|
static int tmr_now( lua_State* L )
|
||||||
{
|
{
|
||||||
unsigned now = 0x7FFFFFFF & system_get_time();
|
unsigned now = 0x7FFFFFFF & system_get_time();
|
||||||
lua_pushinteger( L, now );
|
lua_pushinteger( L, now );
|
||||||
@ -99,7 +92,7 @@ static int ICACHE_FLASH_ATTR tmr_now( lua_State* L )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lua: alarm( id, interval, repeat, function )
|
// Lua: alarm( id, interval, repeat, function )
|
||||||
static int ICACHE_FLASH_ATTR tmr_alarm( lua_State* L )
|
static int tmr_alarm( lua_State* L )
|
||||||
{
|
{
|
||||||
s32 interval;
|
s32 interval;
|
||||||
unsigned repeat = 0;
|
unsigned repeat = 0;
|
||||||
@ -136,7 +129,7 @@ static int ICACHE_FLASH_ATTR tmr_alarm( lua_State* L )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lua: stop( id )
|
// Lua: stop( id )
|
||||||
static int ICACHE_FLASH_ATTR tmr_stop( lua_State* L )
|
static int tmr_stop( lua_State* L )
|
||||||
{
|
{
|
||||||
unsigned id = luaL_checkinteger( L, 1 );
|
unsigned id = luaL_checkinteger( L, 1 );
|
||||||
MOD_CHECK_ID( tmr, id );
|
MOD_CHECK_ID( tmr, id );
|
||||||
@ -147,7 +140,7 @@ static int ICACHE_FLASH_ATTR tmr_stop( lua_State* L )
|
|||||||
|
|
||||||
// extern void update_key_led();
|
// extern void update_key_led();
|
||||||
// Lua: wdclr()
|
// Lua: wdclr()
|
||||||
static int ICACHE_FLASH_ATTR tmr_wdclr( lua_State* L )
|
static int tmr_wdclr( lua_State* L )
|
||||||
{
|
{
|
||||||
WRITE_PERI_REG(0x60000914, 0x73);
|
WRITE_PERI_REG(0x60000914, 0x73);
|
||||||
// update_key_led();
|
// update_key_led();
|
||||||
@ -155,7 +148,7 @@ static int ICACHE_FLASH_ATTR tmr_wdclr( lua_State* L )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lua: time() , return rtc time in us
|
// Lua: time() , return rtc time in us
|
||||||
static int ICACHE_FLASH_ATTR tmr_time( lua_State* L )
|
static int tmr_time( lua_State* L )
|
||||||
{
|
{
|
||||||
unsigned t = 0xFFFFFFFF & system_get_rtc_time();
|
unsigned t = 0xFFFFFFFF & system_get_rtc_time();
|
||||||
unsigned c = 0xFFFFFFFF & system_rtc_clock_cali_proc();
|
unsigned c = 0xFFFFFFFF & system_rtc_clock_cali_proc();
|
||||||
@ -181,7 +174,7 @@ const LUA_REG_TYPE tmr_map[] =
|
|||||||
{ LNILKEY, LNILVAL }
|
{ LNILKEY, LNILVAL }
|
||||||
};
|
};
|
||||||
|
|
||||||
LUALIB_API int ICACHE_FLASH_ATTR luaopen_tmr( lua_State *L )
|
LUALIB_API int luaopen_tmr( lua_State *L )
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for(i=0;i<NUM_TMR;i++){
|
for(i=0;i<NUM_TMR;i++){
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
static lua_State *gL = NULL;
|
static lua_State *gL = NULL;
|
||||||
static int uart_receive_rf = LUA_NOREF;
|
static int uart_receive_rf = LUA_NOREF;
|
||||||
bool run_input = true;
|
bool run_input = true;
|
||||||
bool ICACHE_FLASH_ATTR uart_on_data_cb(const char *buf, size_t len){
|
bool uart_on_data_cb(const char *buf, size_t len){
|
||||||
if(!buf || len==0)
|
if(!buf || len==0)
|
||||||
return false;
|
return false;
|
||||||
if(uart_receive_rf == LUA_NOREF)
|
if(uart_receive_rf == LUA_NOREF)
|
||||||
@ -29,7 +29,7 @@ bool ICACHE_FLASH_ATTR uart_on_data_cb(const char *buf, size_t len){
|
|||||||
uint16_t need_len = 0;
|
uint16_t need_len = 0;
|
||||||
int16_t end_char = -1;
|
int16_t end_char = -1;
|
||||||
// Lua: uart.on("method", [number/char], function, [run_input])
|
// Lua: uart.on("method", [number/char], function, [run_input])
|
||||||
static int ICACHE_FLASH_ATTR uart_on( lua_State* L )
|
static int uart_on( lua_State* L )
|
||||||
{
|
{
|
||||||
size_t sl, el;
|
size_t sl, el;
|
||||||
int32_t run = 1;
|
int32_t run = 1;
|
||||||
@ -160,7 +160,7 @@ const LUA_REG_TYPE uart_map[] =
|
|||||||
{ LNILKEY, LNILVAL }
|
{ LNILKEY, LNILVAL }
|
||||||
};
|
};
|
||||||
|
|
||||||
LUALIB_API int ICACHE_FLASH_ATTR luaopen_uart( lua_State *L )
|
LUALIB_API int luaopen_uart( lua_State *L )
|
||||||
{
|
{
|
||||||
#if LUA_OPTIMIZE_MEMORY > 0
|
#if LUA_OPTIMIZE_MEMORY > 0
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
static int wifi_smart_succeed = LUA_NOREF;
|
static int wifi_smart_succeed = LUA_NOREF;
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR wifi_smart_succeed_cb(void *arg){
|
static void wifi_smart_succeed_cb(void *arg){
|
||||||
NODE_DBG("wifi_smart_succeed_cb is called.\n");
|
NODE_DBG("wifi_smart_succeed_cb is called.\n");
|
||||||
if( !arg )
|
if( !arg )
|
||||||
return;
|
return;
|
||||||
@ -34,8 +34,7 @@ static lua_State* gL = NULL;
|
|||||||
* @param status: scan over status
|
* @param status: scan over status
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
static void ICACHE_FLASH_ATTR
|
static void wifi_scan_done(void *arg, STATUS status)
|
||||||
wifi_scan_done(void *arg, STATUS status)
|
|
||||||
{
|
{
|
||||||
uint8 ssid[33];
|
uint8 ssid[33];
|
||||||
char temp[128];
|
char temp[128];
|
||||||
@ -82,7 +81,7 @@ wifi_scan_done(void *arg, STATUS status)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lua: smart(channel, function succeed_cb)
|
// Lua: smart(channel, function succeed_cb)
|
||||||
static int ICACHE_FLASH_ATTR wifi_start_smart( lua_State* L )
|
static int wifi_start_smart( lua_State* L )
|
||||||
{
|
{
|
||||||
unsigned channel;
|
unsigned channel;
|
||||||
int stack = 1;
|
int stack = 1;
|
||||||
@ -114,7 +113,7 @@ static int ICACHE_FLASH_ATTR wifi_start_smart( lua_State* L )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lua: exit_smart(channel)
|
// Lua: exit_smart(channel)
|
||||||
static int ICACHE_FLASH_ATTR wifi_exit_smart( lua_State* L )
|
static int wifi_exit_smart( lua_State* L )
|
||||||
{
|
{
|
||||||
smart_end();
|
smart_end();
|
||||||
if(wifi_smart_succeed != LUA_NOREF)
|
if(wifi_smart_succeed != LUA_NOREF)
|
||||||
@ -124,7 +123,7 @@ static int ICACHE_FLASH_ATTR wifi_exit_smart( lua_State* L )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lua: realmode = setmode(mode)
|
// Lua: realmode = setmode(mode)
|
||||||
static int ICACHE_FLASH_ATTR wifi_setmode( lua_State* L )
|
static int wifi_setmode( lua_State* L )
|
||||||
{
|
{
|
||||||
unsigned mode;
|
unsigned mode;
|
||||||
|
|
||||||
@ -139,7 +138,7 @@ static int ICACHE_FLASH_ATTR wifi_setmode( lua_State* L )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lua: realmode = getmode()
|
// Lua: realmode = getmode()
|
||||||
static int ICACHE_FLASH_ATTR wifi_getmode( lua_State* L )
|
static int wifi_getmode( lua_State* L )
|
||||||
{
|
{
|
||||||
unsigned mode;
|
unsigned mode;
|
||||||
mode = (unsigned)wifi_get_opmode();
|
mode = (unsigned)wifi_get_opmode();
|
||||||
@ -149,7 +148,7 @@ static int ICACHE_FLASH_ATTR wifi_getmode( lua_State* L )
|
|||||||
|
|
||||||
|
|
||||||
// Lua: mac = wifi.xx.getmac()
|
// Lua: mac = wifi.xx.getmac()
|
||||||
static int ICACHE_FLASH_ATTR wifi_getmac( lua_State* L, uint8_t mode )
|
static int wifi_getmac( lua_State* L, uint8_t mode )
|
||||||
{
|
{
|
||||||
char temp[64];
|
char temp[64];
|
||||||
uint8_t mac[6];
|
uint8_t mac[6];
|
||||||
@ -160,7 +159,7 @@ static int ICACHE_FLASH_ATTR wifi_getmac( lua_State* L, uint8_t mode )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lua: mac = wifi.xx.setmac()
|
// Lua: mac = wifi.xx.setmac()
|
||||||
static int ICACHE_FLASH_ATTR wifi_setmac( lua_State* L, uint8_t mode )
|
static int wifi_setmac( lua_State* L, uint8_t mode )
|
||||||
{
|
{
|
||||||
unsigned len = 0;
|
unsigned len = 0;
|
||||||
const char *mac = luaL_checklstring( L, 1, &len );
|
const char *mac = luaL_checklstring( L, 1, &len );
|
||||||
@ -172,7 +171,7 @@ static int ICACHE_FLASH_ATTR wifi_setmac( lua_State* L, uint8_t mode )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lua: ip = wifi.xx.getip()
|
// Lua: ip = wifi.xx.getip()
|
||||||
static int ICACHE_FLASH_ATTR wifi_getip( lua_State* L, uint8_t mode )
|
static int wifi_getip( lua_State* L, uint8_t mode )
|
||||||
{
|
{
|
||||||
struct ip_info pTempIp;
|
struct ip_info pTempIp;
|
||||||
char temp[64];
|
char temp[64];
|
||||||
@ -204,7 +203,7 @@ static uint32_t parse_key(lua_State* L, const char * key){
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lua: ip = wifi.xx.setip()
|
// Lua: ip = wifi.xx.setip()
|
||||||
static int ICACHE_FLASH_ATTR wifi_setip( lua_State* L, uint8_t mode )
|
static int wifi_setip( lua_State* L, uint8_t mode )
|
||||||
{
|
{
|
||||||
struct ip_info pTempIp;
|
struct ip_info pTempIp;
|
||||||
wifi_get_ip_info(mode, &pTempIp);
|
wifi_get_ip_info(mode, &pTempIp);
|
||||||
@ -228,7 +227,7 @@ static int ICACHE_FLASH_ATTR wifi_setip( lua_State* L, uint8_t mode )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lua: realtype = sleeptype(type)
|
// Lua: realtype = sleeptype(type)
|
||||||
static int ICACHE_FLASH_ATTR wifi_sleeptype( lua_State* L )
|
static int wifi_sleeptype( lua_State* L )
|
||||||
{
|
{
|
||||||
unsigned type;
|
unsigned type;
|
||||||
|
|
||||||
@ -248,27 +247,27 @@ static int ICACHE_FLASH_ATTR wifi_sleeptype( lua_State* L )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lua: wifi.sta.getmac()
|
// Lua: wifi.sta.getmac()
|
||||||
static int ICACHE_FLASH_ATTR wifi_station_getmac( lua_State* L ){
|
static int wifi_station_getmac( lua_State* L ){
|
||||||
return wifi_getmac(L, STATION_IF);
|
return wifi_getmac(L, STATION_IF);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lua: wifi.sta.setmac()
|
// Lua: wifi.sta.setmac()
|
||||||
static int ICACHE_FLASH_ATTR wifi_station_setmac( lua_State* L ){
|
static int wifi_station_setmac( lua_State* L ){
|
||||||
return wifi_setmac(L, STATION_IF);
|
return wifi_setmac(L, STATION_IF);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lua: wifi.sta.getip()
|
// Lua: wifi.sta.getip()
|
||||||
static int ICACHE_FLASH_ATTR wifi_station_getip( lua_State* L ){
|
static int wifi_station_getip( lua_State* L ){
|
||||||
return wifi_getip(L, STATION_IF);
|
return wifi_getip(L, STATION_IF);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lua: wifi.sta.setip()
|
// Lua: wifi.sta.setip()
|
||||||
static int ICACHE_FLASH_ATTR wifi_station_setip( lua_State* L ){
|
static int wifi_station_setip( lua_State* L ){
|
||||||
return wifi_setip(L, STATION_IF);
|
return wifi_setip(L, STATION_IF);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lua: wifi.sta.config(ssid, password)
|
// Lua: wifi.sta.config(ssid, password)
|
||||||
static int ICACHE_FLASH_ATTR wifi_station_config( lua_State* L )
|
static int wifi_station_config( lua_State* L )
|
||||||
{
|
{
|
||||||
size_t sl, pl;
|
size_t sl, pl;
|
||||||
struct station_config sta_conf;
|
struct station_config sta_conf;
|
||||||
@ -301,21 +300,21 @@ static int ICACHE_FLASH_ATTR wifi_station_config( lua_State* L )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lua: wifi.sta.connect()
|
// Lua: wifi.sta.connect()
|
||||||
static int ICACHE_FLASH_ATTR wifi_station_connect4lua( lua_State* L )
|
static int wifi_station_connect4lua( lua_State* L )
|
||||||
{
|
{
|
||||||
wifi_station_connect();
|
wifi_station_connect();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lua: wifi.sta.disconnect()
|
// Lua: wifi.sta.disconnect()
|
||||||
static int ICACHE_FLASH_ATTR wifi_station_disconnect4lua( lua_State* L )
|
static int wifi_station_disconnect4lua( lua_State* L )
|
||||||
{
|
{
|
||||||
wifi_station_disconnect();
|
wifi_station_disconnect();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lua: wifi.sta.auto(true/false)
|
// Lua: wifi.sta.auto(true/false)
|
||||||
static int ICACHE_FLASH_ATTR wifi_station_setauto( lua_State* L )
|
static int wifi_station_setauto( lua_State* L )
|
||||||
{
|
{
|
||||||
unsigned a;
|
unsigned a;
|
||||||
|
|
||||||
@ -330,7 +329,7 @@ static int ICACHE_FLASH_ATTR wifi_station_setauto( lua_State* L )
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR wifi_station_listap( lua_State* L )
|
static int wifi_station_listap( lua_State* L )
|
||||||
{
|
{
|
||||||
if(wifi_get_opmode() == SOFTAP_MODE)
|
if(wifi_get_opmode() == SOFTAP_MODE)
|
||||||
{
|
{
|
||||||
@ -352,7 +351,7 @@ static int ICACHE_FLASH_ATTR wifi_station_listap( lua_State* L )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lua: wifi.sta.status()
|
// Lua: wifi.sta.status()
|
||||||
static int ICACHE_FLASH_ATTR wifi_station_status( lua_State* L )
|
static int wifi_station_status( lua_State* L )
|
||||||
{
|
{
|
||||||
uint8_t status = wifi_station_get_connect_status();
|
uint8_t status = wifi_station_get_connect_status();
|
||||||
lua_pushinteger( L, status );
|
lua_pushinteger( L, status );
|
||||||
@ -360,27 +359,27 @@ static int ICACHE_FLASH_ATTR wifi_station_status( lua_State* L )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lua: wifi.ap.getmac()
|
// Lua: wifi.ap.getmac()
|
||||||
static int ICACHE_FLASH_ATTR wifi_ap_getmac( lua_State* L ){
|
static int wifi_ap_getmac( lua_State* L ){
|
||||||
return wifi_getmac(L, SOFTAP_IF);
|
return wifi_getmac(L, SOFTAP_IF);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lua: wifi.ap.setmac()
|
// Lua: wifi.ap.setmac()
|
||||||
static int ICACHE_FLASH_ATTR wifi_ap_setmac( lua_State* L ){
|
static int wifi_ap_setmac( lua_State* L ){
|
||||||
return wifi_setmac(L, SOFTAP_IF);
|
return wifi_setmac(L, SOFTAP_IF);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lua: wifi.ap.getip()
|
// Lua: wifi.ap.getip()
|
||||||
static int ICACHE_FLASH_ATTR wifi_ap_getip( lua_State* L ){
|
static int wifi_ap_getip( lua_State* L ){
|
||||||
return wifi_getip(L, SOFTAP_IF);
|
return wifi_getip(L, SOFTAP_IF);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lua: wifi.ap.setip()
|
// Lua: wifi.ap.setip()
|
||||||
static int ICACHE_FLASH_ATTR wifi_ap_setip( lua_State* L ){
|
static int wifi_ap_setip( lua_State* L ){
|
||||||
return wifi_setip(L, SOFTAP_IF);
|
return wifi_setip(L, SOFTAP_IF);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lua: wifi.ap.config(table)
|
// Lua: wifi.ap.config(table)
|
||||||
static int ICACHE_FLASH_ATTR wifi_ap_config( lua_State* L )
|
static int wifi_ap_config( lua_State* L )
|
||||||
{
|
{
|
||||||
struct softap_config config;
|
struct softap_config config;
|
||||||
size_t len;
|
size_t len;
|
||||||
@ -495,7 +494,7 @@ const LUA_REG_TYPE wifi_map[] =
|
|||||||
{ LNILKEY, LNILVAL }
|
{ LNILKEY, LNILVAL }
|
||||||
};
|
};
|
||||||
|
|
||||||
LUALIB_API int ICACHE_FLASH_ATTR luaopen_wifi( lua_State *L )
|
LUALIB_API int luaopen_wifi( lua_State *L )
|
||||||
{
|
{
|
||||||
#if LUA_OPTIMIZE_MEMORY > 0
|
#if LUA_OPTIMIZE_MEMORY > 0
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#include "c_string.h"
|
#include "c_string.h"
|
||||||
#include "c_stdio.h"
|
#include "c_stdio.h"
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR cmn_platform_init(void)
|
void cmn_platform_init(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -13,7 +13,7 @@ void ICACHE_FLASH_ATTR cmn_platform_init(void)
|
|||||||
// ****************************************************************************
|
// ****************************************************************************
|
||||||
// GPIO functions
|
// GPIO functions
|
||||||
|
|
||||||
int ICACHE_FLASH_ATTR platform_gpio_exists( unsigned pin )
|
int platform_gpio_exists( unsigned pin )
|
||||||
{
|
{
|
||||||
return pin < NUM_GPIO;
|
return pin < NUM_GPIO;
|
||||||
}
|
}
|
||||||
@ -21,7 +21,7 @@ int ICACHE_FLASH_ATTR platform_gpio_exists( unsigned pin )
|
|||||||
// ****************************************************************************
|
// ****************************************************************************
|
||||||
// CAN functions
|
// CAN functions
|
||||||
|
|
||||||
int ICACHE_FLASH_ATTR platform_can_exists( unsigned id )
|
int platform_can_exists( unsigned id )
|
||||||
{
|
{
|
||||||
return id < NUM_CAN;
|
return id < NUM_CAN;
|
||||||
}
|
}
|
||||||
@ -30,7 +30,7 @@ int ICACHE_FLASH_ATTR platform_can_exists( unsigned id )
|
|||||||
// SPI functions
|
// SPI functions
|
||||||
|
|
||||||
|
|
||||||
int ICACHE_FLASH_ATTR platform_spi_exists( unsigned id )
|
int platform_spi_exists( unsigned id )
|
||||||
{
|
{
|
||||||
return id < NUM_SPI;
|
return id < NUM_SPI;
|
||||||
}
|
}
|
||||||
@ -38,7 +38,7 @@ int ICACHE_FLASH_ATTR platform_spi_exists( unsigned id )
|
|||||||
// ****************************************************************************
|
// ****************************************************************************
|
||||||
// PWM functions
|
// PWM functions
|
||||||
|
|
||||||
int ICACHE_FLASH_ATTR platform_pwm_exists( unsigned id )
|
int platform_pwm_exists( unsigned id )
|
||||||
{
|
{
|
||||||
return ((id < NUM_PWM) && (id > 0));
|
return ((id < NUM_PWM) && (id > 0));
|
||||||
}
|
}
|
||||||
@ -46,7 +46,7 @@ int ICACHE_FLASH_ATTR platform_pwm_exists( unsigned id )
|
|||||||
// ****************************************************************************
|
// ****************************************************************************
|
||||||
// ADC functions
|
// ADC functions
|
||||||
|
|
||||||
int ICACHE_FLASH_ATTR platform_adc_exists( unsigned id )
|
int platform_adc_exists( unsigned id )
|
||||||
{
|
{
|
||||||
return id < NUM_ADC;
|
return id < NUM_ADC;
|
||||||
}
|
}
|
||||||
@ -54,7 +54,7 @@ int ICACHE_FLASH_ATTR platform_adc_exists( unsigned id )
|
|||||||
// ****************************************************************************
|
// ****************************************************************************
|
||||||
// UART functions
|
// UART functions
|
||||||
|
|
||||||
int ICACHE_FLASH_ATTR platform_uart_exists( unsigned id )
|
int platform_uart_exists( unsigned id )
|
||||||
{
|
{
|
||||||
return id < NUM_UART;
|
return id < NUM_UART;
|
||||||
}
|
}
|
||||||
@ -62,7 +62,7 @@ int ICACHE_FLASH_ATTR platform_uart_exists( unsigned id )
|
|||||||
// ****************************************************************************
|
// ****************************************************************************
|
||||||
// OneWire functions
|
// OneWire functions
|
||||||
|
|
||||||
int ICACHE_FLASH_ATTR platform_ow_exists( unsigned id )
|
int platform_ow_exists( unsigned id )
|
||||||
{
|
{
|
||||||
return ((id < NUM_OW) && (id > 0));
|
return ((id < NUM_OW) && (id > 0));
|
||||||
}
|
}
|
||||||
@ -70,13 +70,13 @@ int ICACHE_FLASH_ATTR platform_ow_exists( unsigned id )
|
|||||||
// ****************************************************************************
|
// ****************************************************************************
|
||||||
// Timer functions
|
// Timer functions
|
||||||
|
|
||||||
int ICACHE_FLASH_ATTR platform_tmr_exists( unsigned id )
|
int platform_tmr_exists( unsigned id )
|
||||||
{
|
{
|
||||||
return id < NUM_TMR;
|
return id < NUM_TMR;
|
||||||
}
|
}
|
||||||
|
|
||||||
// I2C support
|
// I2C support
|
||||||
int ICACHE_FLASH_ATTR platform_i2c_exists( unsigned id )
|
int platform_i2c_exists( unsigned id )
|
||||||
{
|
{
|
||||||
#ifndef NUM_I2C
|
#ifndef NUM_I2C
|
||||||
return 0;
|
return 0;
|
||||||
@ -99,7 +99,7 @@ extern char _flash_used_end[];
|
|||||||
|
|
||||||
// Helper function: find the flash sector in which an address resides
|
// Helper function: find the flash sector in which an address resides
|
||||||
// Return the sector number, as well as the start and end address of the sector
|
// Return the sector number, as well as the start and end address of the sector
|
||||||
static uint32_t ICACHE_FLASH_ATTR flashh_find_sector( uint32_t address, uint32_t *pstart, uint32_t *pend )
|
static uint32_t flashh_find_sector( uint32_t address, uint32_t *pstart, uint32_t *pend )
|
||||||
{
|
{
|
||||||
address -= INTERNAL_FLASH_START_ADDRESS;
|
address -= INTERNAL_FLASH_START_ADDRESS;
|
||||||
#ifdef INTERNAL_FLASH_SECTOR_SIZE
|
#ifdef INTERNAL_FLASH_SECTOR_SIZE
|
||||||
@ -127,12 +127,12 @@ static uint32_t ICACHE_FLASH_ATTR flashh_find_sector( uint32_t address, uint32_t
|
|||||||
#endif // #ifdef INTERNAL_FLASH_SECTOR_SIZE
|
#endif // #ifdef INTERNAL_FLASH_SECTOR_SIZE
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t ICACHE_FLASH_ATTR platform_flash_get_sector_of_address( uint32_t addr )
|
uint32_t platform_flash_get_sector_of_address( uint32_t addr )
|
||||||
{
|
{
|
||||||
return flashh_find_sector( addr, NULL, NULL );
|
return flashh_find_sector( addr, NULL, NULL );
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t ICACHE_FLASH_ATTR platform_flash_get_num_sectors(void)
|
uint32_t platform_flash_get_num_sectors(void)
|
||||||
{
|
{
|
||||||
#ifdef INTERNAL_FLASH_SECTOR_SIZE
|
#ifdef INTERNAL_FLASH_SECTOR_SIZE
|
||||||
return INTERNAL_FLASH_SIZE / INTERNAL_FLASH_SECTOR_SIZE;
|
return INTERNAL_FLASH_SIZE / INTERNAL_FLASH_SECTOR_SIZE;
|
||||||
@ -143,7 +143,7 @@ uint32_t ICACHE_FLASH_ATTR platform_flash_get_num_sectors(void)
|
|||||||
#endif // #ifdef INTERNAL_FLASH_SECTOR_SIZE
|
#endif // #ifdef INTERNAL_FLASH_SECTOR_SIZE
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t ICACHE_FLASH_ATTR platform_flash_get_first_free_block_address( uint32_t *psect )
|
uint32_t platform_flash_get_first_free_block_address( uint32_t *psect )
|
||||||
{
|
{
|
||||||
// Round the total used flash size to the closest flash block address
|
// Round the total used flash size to the closest flash block address
|
||||||
uint32_t start, end, sect;
|
uint32_t start, end, sect;
|
||||||
@ -162,7 +162,7 @@ uint32_t ICACHE_FLASH_ATTR platform_flash_get_first_free_block_address( uint32_t
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t ICACHE_FLASH_ATTR platform_flash_write( const void *from, uint32_t toaddr, uint32_t size )
|
uint32_t platform_flash_write( const void *from, uint32_t toaddr, uint32_t size )
|
||||||
{
|
{
|
||||||
#ifndef INTERNAL_FLASH_WRITE_UNIT_SIZE
|
#ifndef INTERNAL_FLASH_WRITE_UNIT_SIZE
|
||||||
return platform_s_flash_write( from, toaddr, size );
|
return platform_s_flash_write( from, toaddr, size );
|
||||||
@ -212,7 +212,7 @@ uint32_t ICACHE_FLASH_ATTR platform_flash_write( const void *from, uint32_t toad
|
|||||||
#endif // #ifndef INTERNAL_FLASH_WRITE_UNIT_SIZE
|
#endif // #ifndef INTERNAL_FLASH_WRITE_UNIT_SIZE
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t ICACHE_FLASH_ATTR platform_flash_read( void *to, uint32_t fromaddr, uint32_t size )
|
uint32_t platform_flash_read( void *to, uint32_t fromaddr, uint32_t size )
|
||||||
{
|
{
|
||||||
#ifndef INTERNAL_FLASH_READ_UNIT_SIZE
|
#ifndef INTERNAL_FLASH_READ_UNIT_SIZE
|
||||||
return platform_s_flash_read( to, fromaddr, size );
|
return platform_s_flash_read( to, fromaddr, size );
|
||||||
|
@ -6,87 +6,82 @@
|
|||||||
#include "user_config.h"
|
#include "user_config.h"
|
||||||
#include "flash_api.h"
|
#include "flash_api.h"
|
||||||
#include "spi_flash.h"
|
#include "spi_flash.h"
|
||||||
|
#include "c_stdio.h"
|
||||||
|
|
||||||
SPIFlashInfo *ICACHE_FLASH_ATTR
|
static volatile const uint8_t flash_init_data[128] ICACHE_STORE_ATTR ICACHE_RODATA_ATTR =
|
||||||
flash_get_info(void)
|
{
|
||||||
{
|
0x05, 0x00, 0x04, 0x02, 0x05, 0x05, 0x05, 0x02, 0x05, 0x00, 0x04, 0x05, 0x05, 0x04, 0x05, 0x05,
|
||||||
static SPIFlashInfo spi_flash_info NODE_STORE_ATTR;
|
0x04, 0xFE, 0xFD, 0xFF, 0xF0, 0xF0, 0xF0, 0xE0, 0xE0, 0xE0, 0xE1, 0x0A, 0xFF, 0xFF, 0xF8, 0x00,
|
||||||
static bool is_spi_flash_info_initialized = false;
|
0xF8, 0xF8, 0x52, 0x4E, 0x4A, 0x44, 0x40, 0x38, 0x00, 0x00, 0x01, 0x01, 0x02, 0x03, 0x04, 0x05,
|
||||||
// Make the code more fast
|
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
if (!is_spi_flash_info_initialized)
|
0xE1, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x93, 0x43, 0x00, 0x00, 0x00,
|
||||||
{
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
SPIRead(0, &spi_flash_info, sizeof(spi_flash_info));
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
is_spi_flash_info_initialized = true;
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||||
}
|
};
|
||||||
// return (SPIFlashInfo *)(0x40200000);
|
|
||||||
return &spi_flash_info;
|
SPIFlashInfo flash_get_info(void)
|
||||||
|
{
|
||||||
|
volatile SPIFlashInfo spi_flash_info ICACHE_STORE_ATTR;
|
||||||
|
spi_flash_info = *((SPIFlashInfo *)(FLASH_MAP_START_ADDRESS));
|
||||||
|
return spi_flash_info;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t ICACHE_FLASH_ATTR
|
uint8_t flash_get_size(void)
|
||||||
flash_get_size(void)
|
|
||||||
{
|
{
|
||||||
SPIFlashInfo *p_spi_flash_info = flash_get_info();
|
return flash_get_info().size;
|
||||||
return p_spi_flash_info->size;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t ICACHE_FLASH_ATTR
|
uint32_t flash_get_size_byte(void)
|
||||||
flash_get_size_byte(void)
|
|
||||||
{
|
{
|
||||||
static uint32_t flash_size = 0;
|
uint32_t flash_size = 0;
|
||||||
// Make the code more fast
|
switch (flash_get_info().size)
|
||||||
if (flash_size == 0 )
|
|
||||||
{
|
{
|
||||||
SPIFlashInfo *p_spi_flash_info = flash_get_info();
|
case SIZE_2MBIT:
|
||||||
switch (p_spi_flash_info->size)
|
// 2Mbit, 256kByte
|
||||||
{
|
flash_size = 256 * 1024;
|
||||||
case SIZE_2MBIT:
|
break;
|
||||||
// 2Mbit, 256kByte
|
case SIZE_4MBIT:
|
||||||
flash_size = 256 * 1024;
|
// 4Mbit, 512kByte
|
||||||
break;
|
flash_size = 512 * 1024;
|
||||||
case SIZE_4MBIT:
|
break;
|
||||||
// 4Mbit, 512kByte
|
case SIZE_8MBIT:
|
||||||
flash_size = 512 * 1024;
|
// 8Mbit, 1MByte
|
||||||
break;
|
flash_size = 1 * 1024 * 1024;
|
||||||
case SIZE_8MBIT:
|
break;
|
||||||
// 8Mbit, 1MByte
|
case SIZE_16MBIT:
|
||||||
flash_size = 1 * 1024 * 1024;
|
// 16Mbit, 2MByte
|
||||||
break;
|
flash_size = 2 * 1024 * 1024;
|
||||||
case SIZE_16MBIT:
|
break;
|
||||||
// 16Mbit, 2MByte
|
case SIZE_32MBIT:
|
||||||
flash_size = 2 * 1024 * 1024;
|
// 32Mbit, 4MByte
|
||||||
break;
|
flash_size = 4 * 1024 * 1024;
|
||||||
case SIZE_32MBIT:
|
break;
|
||||||
// 32Mbit, 4MByte
|
default:
|
||||||
flash_size = 4 * 1024 * 1024;
|
// Unknown flash size, fall back mode.
|
||||||
break;
|
flash_size = 512 * 1024;
|
||||||
default:
|
break;
|
||||||
// Unknown flash size, fall back mode.
|
|
||||||
flash_size = 512 * 1024;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return flash_size;
|
return flash_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ICACHE_FLASH_ATTR
|
bool flash_set_size(uint8_t size)
|
||||||
flash_set_size(uint8_t size)
|
|
||||||
{
|
{
|
||||||
// Dangerous, here are dinosaur infested!!!!!
|
// Dangerous, here are dinosaur infested!!!!!
|
||||||
// Reboot required!!!
|
// Reboot required!!!
|
||||||
// If you don't know what you're doing, your nodemcu may turn into stone ...
|
// If you don't know what you're doing, your nodemcu may turn into stone ...
|
||||||
uint8_t data[SPI_FLASH_SEC_SIZE] NODE_STORE_ATTR;
|
uint8_t data[SPI_FLASH_SEC_SIZE] ICACHE_STORE_ATTR;
|
||||||
SPIRead(0, data, sizeof(data));
|
SPIRead(0, data, sizeof(data));
|
||||||
SPIFlashInfo *p_spi_flash_info = (SPIFlashInfo *)(data);
|
SPIFlashInfo *p_spi_flash_info = (SPIFlashInfo *)(data);
|
||||||
p_spi_flash_info->size = size;
|
p_spi_flash_info->size = size;
|
||||||
SPIEraseSector(0);
|
SPIEraseSector(0);
|
||||||
SPIWrite(data, 0, sizeof(data));
|
spi_flash_write(0, (uint32 *)data, sizeof(data));
|
||||||
//p_spi_flash_info = flash_get_info();
|
//p_spi_flash_info = flash_get_info();
|
||||||
//p_spi_flash_info->size = size;
|
//p_spi_flash_info->size = size;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ICACHE_FLASH_ATTR
|
bool flash_set_size_byte(uint32_t size)
|
||||||
flash_set_size_byte(uint32_t size)
|
|
||||||
{
|
{
|
||||||
// Dangerous, here are dinosaur infested!!!!!
|
// Dangerous, here are dinosaur infested!!!!!
|
||||||
// Reboot required!!!
|
// Reboot required!!!
|
||||||
@ -128,23 +123,15 @@ flash_set_size_byte(uint32_t size)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t ICACHE_FLASH_ATTR
|
uint16_t flash_get_sec_num(void)
|
||||||
flash_get_sec_num(void)
|
|
||||||
{
|
{
|
||||||
static uint16_t result = 0;
|
return flash_get_size_byte() / SPI_FLASH_SEC_SIZE;
|
||||||
// Make the code more fast
|
|
||||||
if (result == 0 )
|
|
||||||
{
|
|
||||||
result = flash_get_size_byte() / SPI_FLASH_SEC_SIZE;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t ICACHE_FLASH_ATTR
|
uint8_t flash_get_mode(void)
|
||||||
flash_get_mode(void)
|
|
||||||
{
|
{
|
||||||
SPIFlashInfo *p_spi_flash_info = flash_get_info();
|
SPIFlashInfo spi_flash_info = flash_get_info();
|
||||||
switch (p_spi_flash_info->mode)
|
switch (spi_flash_info.mode)
|
||||||
{
|
{
|
||||||
// Reserved for future use
|
// Reserved for future use
|
||||||
case MODE_QIO:
|
case MODE_QIO:
|
||||||
@ -156,15 +143,14 @@ flash_get_mode(void)
|
|||||||
case MODE_DOUT:
|
case MODE_DOUT:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return p_spi_flash_info->mode;
|
return spi_flash_info.mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t ICACHE_FLASH_ATTR
|
uint32_t flash_get_speed(void)
|
||||||
flash_get_speed(void)
|
|
||||||
{
|
{
|
||||||
uint32_t speed = 0;
|
uint32_t speed = 0;
|
||||||
SPIFlashInfo *p_spi_flash_info = flash_get_info();
|
SPIFlashInfo spi_flash_info = flash_get_info();
|
||||||
switch (p_spi_flash_info->speed)
|
switch (spi_flash_info.speed)
|
||||||
{
|
{
|
||||||
case SPEED_40MHZ:
|
case SPEED_40MHZ:
|
||||||
// 40MHz
|
// 40MHz
|
||||||
@ -186,8 +172,21 @@ flash_get_speed(void)
|
|||||||
return speed;
|
return speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ICACHE_FLASH_ATTR
|
bool flash_init_data_written(void)
|
||||||
flash_init_data_default(void)
|
{
|
||||||
|
// FLASH SEC - 4
|
||||||
|
// Dangerous, here are dinosaur infested!!!!!
|
||||||
|
// Reboot required!!!
|
||||||
|
// It will init system data to default!
|
||||||
|
uint32_t data[2] ICACHE_STORE_ATTR;
|
||||||
|
SPIRead((flash_get_sec_num() - 4) * SPI_FLASH_SEC_SIZE, data, sizeof(data));
|
||||||
|
if(data[0] == 0xFFFFFFFF && data[1] == 0xFFFFFFFF) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool flash_init_data_default(void)
|
||||||
{
|
{
|
||||||
// FLASH SEC - 4
|
// FLASH SEC - 4
|
||||||
// Dangerous, here are dinosaur infested!!!!!
|
// Dangerous, here are dinosaur infested!!!!!
|
||||||
@ -195,12 +194,11 @@ flash_init_data_default(void)
|
|||||||
// It will init system data to default!
|
// It will init system data to default!
|
||||||
|
|
||||||
SPIEraseSector((flash_get_sec_num() - 4));
|
SPIEraseSector((flash_get_sec_num() - 4));
|
||||||
SPIWrite((flash_get_sec_num() - 4) * SPI_FLASH_SEC_SIZE, 0x10000 - SPI_FLASH_SEC_SIZE + (0), 128);
|
spi_flash_write((flash_get_sec_num() - 4) * SPI_FLASH_SEC_SIZE, (uint32 *)flash_init_data, 128);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ICACHE_FLASH_ATTR
|
bool flash_init_data_blank(void)
|
||||||
flash_init_data_blank(void)
|
|
||||||
{
|
{
|
||||||
// FLASH SEC - 2
|
// FLASH SEC - 2
|
||||||
// Dangerous, here are dinosaur infested!!!!!
|
// Dangerous, here are dinosaur infested!!!!!
|
||||||
@ -211,8 +209,7 @@ flash_init_data_blank(void)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ICACHE_FLASH_ATTR
|
bool flash_self_destruct(void)
|
||||||
flash_self_destruct(void)
|
|
||||||
{
|
{
|
||||||
// Erase your flash. Good bye!
|
// Erase your flash. Good bye!
|
||||||
SPIEraseChip();
|
SPIEraseChip();
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
#define __FLASH_API_H__
|
#define __FLASH_API_H__
|
||||||
#include "ets_sys.h"
|
#include "ets_sys.h"
|
||||||
#include "user_config.h"
|
#include "user_config.h"
|
||||||
|
#include "cpu_esp8266.h"
|
||||||
|
#define FLASH_MAP_START_ADDRESS (INTERNAL_FLASH_START_ADDRESS)
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
@ -29,9 +31,9 @@ typedef struct
|
|||||||
SIZE_16MBIT = 3,
|
SIZE_16MBIT = 3,
|
||||||
SIZE_32MBIT = 4,
|
SIZE_32MBIT = 4,
|
||||||
} size : 4;
|
} size : 4;
|
||||||
} NODE_STORE_TYPEDEF_ATTR SPIFlashInfo;
|
} ICACHE_STORE_TYPEDEF_ATTR SPIFlashInfo;
|
||||||
|
|
||||||
SPIFlashInfo *flash_get_info(void);
|
SPIFlashInfo flash_get_info(void);
|
||||||
uint8_t flash_get_size(void);
|
uint8_t flash_get_size(void);
|
||||||
uint32_t flash_get_size_byte(void);
|
uint32_t flash_get_size_byte(void);
|
||||||
bool flash_set_size(uint8_t);
|
bool flash_set_size(uint8_t);
|
||||||
@ -39,6 +41,7 @@ bool flash_set_size_byte(uint32_t);
|
|||||||
uint16_t flash_get_sec_num(void);
|
uint16_t flash_get_sec_num(void);
|
||||||
uint8_t flash_get_mode(void);
|
uint8_t flash_get_mode(void);
|
||||||
uint32_t flash_get_speed(void);
|
uint32_t flash_get_speed(void);
|
||||||
|
bool flash_init_data_written(void);
|
||||||
bool flash_init_data_default(void);
|
bool flash_init_data_default(void);
|
||||||
bool flash_init_data_blank(void);
|
bool flash_init_data_blank(void);
|
||||||
bool flash_self_destruct(void);
|
bool flash_self_destruct(void);
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#include "spiffs.h"
|
#include "spiffs.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int ICACHE_FLASH_ATTR fs_mode2flag(const char *mode){
|
int fs_mode2flag(const char *mode){
|
||||||
if(c_strlen(mode)==1){
|
if(c_strlen(mode)==1){
|
||||||
if(c_strcmp(mode,"w")==0)
|
if(c_strcmp(mode,"w")==0)
|
||||||
return FS_WRONLY|FS_CREAT|FS_TRUNC;
|
return FS_WRONLY|FS_CREAT|FS_TRUNC;
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
static void pwms_init();
|
static void pwms_init();
|
||||||
|
|
||||||
int ICACHE_FLASH_ATTR platform_init()
|
int platform_init()
|
||||||
{
|
{
|
||||||
// Setup PWMs
|
// Setup PWMs
|
||||||
pwms_init();
|
pwms_init();
|
||||||
@ -23,7 +23,7 @@ int ICACHE_FLASH_ATTR platform_init()
|
|||||||
|
|
||||||
// ****************************************************************************
|
// ****************************************************************************
|
||||||
// KEY_LED functions
|
// KEY_LED functions
|
||||||
uint8_t ICACHE_FLASH_ATTR platform_key_led( uint8_t level){
|
uint8_t platform_key_led( uint8_t level){
|
||||||
uint8_t temp;
|
uint8_t temp;
|
||||||
gpio16_output_set(1); // set to high first, for reading key low level
|
gpio16_output_set(1); // set to high first, for reading key low level
|
||||||
gpio16_input_conf();
|
gpio16_input_conf();
|
||||||
@ -38,7 +38,7 @@ uint8_t ICACHE_FLASH_ATTR platform_key_led( uint8_t level){
|
|||||||
#ifdef GPIO_INTERRUPT_ENABLE
|
#ifdef GPIO_INTERRUPT_ENABLE
|
||||||
extern void lua_gpio_unref(unsigned pin);
|
extern void lua_gpio_unref(unsigned pin);
|
||||||
#endif
|
#endif
|
||||||
int ICACHE_FLASH_ATTR platform_gpio_mode( unsigned pin, unsigned mode, unsigned pull )
|
int platform_gpio_mode( unsigned pin, unsigned mode, unsigned pull )
|
||||||
{
|
{
|
||||||
// NODE_DBG("Function platform_gpio_mode() is called. pin_mux:%d, func:%d\n",pin_mux[pin],pin_func[pin]);
|
// NODE_DBG("Function platform_gpio_mode() is called. pin_mux:%d, func:%d\n",pin_mux[pin],pin_func[pin]);
|
||||||
if (pin >= NUM_GPIO)
|
if (pin >= NUM_GPIO)
|
||||||
@ -108,7 +108,7 @@ int ICACHE_FLASH_ATTR platform_gpio_mode( unsigned pin, unsigned mode, unsigned
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ICACHE_FLASH_ATTR platform_gpio_write( unsigned pin, unsigned level )
|
int platform_gpio_write( unsigned pin, unsigned level )
|
||||||
{
|
{
|
||||||
// NODE_DBG("Function platform_gpio_write() is called. pin:%d, level:%d\n",GPIO_ID_PIN(pin_num[pin]),level);
|
// NODE_DBG("Function platform_gpio_write() is called. pin:%d, level:%d\n",GPIO_ID_PIN(pin_num[pin]),level);
|
||||||
if (pin >= NUM_GPIO)
|
if (pin >= NUM_GPIO)
|
||||||
@ -122,7 +122,7 @@ int ICACHE_FLASH_ATTR platform_gpio_write( unsigned pin, unsigned level )
|
|||||||
GPIO_OUTPUT_SET(GPIO_ID_PIN(pin_num[pin]), level);
|
GPIO_OUTPUT_SET(GPIO_ID_PIN(pin_num[pin]), level);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ICACHE_FLASH_ATTR platform_gpio_read( unsigned pin )
|
int platform_gpio_read( unsigned pin )
|
||||||
{
|
{
|
||||||
// NODE_DBG("Function platform_gpio_read() is called. pin:%d\n",GPIO_ID_PIN(pin_num[pin]));
|
// NODE_DBG("Function platform_gpio_read() is called. pin:%d\n",GPIO_ID_PIN(pin_num[pin]));
|
||||||
if (pin >= NUM_GPIO)
|
if (pin >= NUM_GPIO)
|
||||||
@ -138,7 +138,7 @@ int ICACHE_FLASH_ATTR platform_gpio_read( unsigned pin )
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef GPIO_INTERRUPT_ENABLE
|
#ifdef GPIO_INTERRUPT_ENABLE
|
||||||
static void ICACHE_FLASH_ATTR platform_gpio_intr_dispatcher( platform_gpio_intr_handler_fn_t cb){
|
static void platform_gpio_intr_dispatcher( platform_gpio_intr_handler_fn_t cb){
|
||||||
uint8 i, level;
|
uint8 i, level;
|
||||||
uint32 gpio_status = GPIO_REG_READ(GPIO_STATUS_ADDRESS);
|
uint32 gpio_status = GPIO_REG_READ(GPIO_STATUS_ADDRESS);
|
||||||
for (i = 0; i < GPIO_PIN_NUM; i++) {
|
for (i = 0; i < GPIO_PIN_NUM; i++) {
|
||||||
@ -156,12 +156,12 @@ static void ICACHE_FLASH_ATTR platform_gpio_intr_dispatcher( platform_gpio_intr_
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR platform_gpio_init( platform_gpio_intr_handler_fn_t cb )
|
void platform_gpio_init( platform_gpio_intr_handler_fn_t cb )
|
||||||
{
|
{
|
||||||
ETS_GPIO_INTR_ATTACH(platform_gpio_intr_dispatcher, cb);
|
ETS_GPIO_INTR_ATTACH(platform_gpio_intr_dispatcher, cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ICACHE_FLASH_ATTR platform_gpio_intr_init( unsigned pin, GPIO_INT_TYPE type )
|
int platform_gpio_intr_init( unsigned pin, GPIO_INT_TYPE type )
|
||||||
{
|
{
|
||||||
if (pin >= NUM_GPIO)
|
if (pin >= NUM_GPIO)
|
||||||
return -1;
|
return -1;
|
||||||
@ -181,7 +181,7 @@ int ICACHE_FLASH_ATTR platform_gpio_intr_init( unsigned pin, GPIO_INT_TYPE type
|
|||||||
|
|
||||||
// UartDev is defined and initialized in rom code.
|
// UartDev is defined and initialized in rom code.
|
||||||
extern UartDevice UartDev;
|
extern UartDevice UartDev;
|
||||||
uint32_t ICACHE_FLASH_ATTR platform_uart_setup( unsigned id, uint32_t baud, int databits, int parity, int stopbits )
|
uint32_t platform_uart_setup( unsigned id, uint32_t baud, int databits, int parity, int stopbits )
|
||||||
{
|
{
|
||||||
switch( baud )
|
switch( baud )
|
||||||
{
|
{
|
||||||
@ -262,7 +262,7 @@ void platform_uart_send( unsigned id, u8 data )
|
|||||||
|
|
||||||
static uint16_t pwms_duty[NUM_PWM] = {0};
|
static uint16_t pwms_duty[NUM_PWM] = {0};
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR pwms_init()
|
static void pwms_init()
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for(i=0;i<NUM_PWM;i++){
|
for(i=0;i<NUM_PWM;i++){
|
||||||
@ -276,7 +276,7 @@ static void ICACHE_FLASH_ATTR pwms_init()
|
|||||||
// NOTE: Can't find a function to query for the period set for the timer,
|
// NOTE: Can't find a function to query for the period set for the timer,
|
||||||
// therefore using the struct.
|
// therefore using the struct.
|
||||||
// This may require adjustment if driver libraries are updated.
|
// This may require adjustment if driver libraries are updated.
|
||||||
uint32_t ICACHE_FLASH_ATTR platform_pwm_get_clock( unsigned pin )
|
uint32_t platform_pwm_get_clock( unsigned pin )
|
||||||
{
|
{
|
||||||
// NODE_DBG("Function platform_pwm_get_clock() is called.\n");
|
// NODE_DBG("Function platform_pwm_get_clock() is called.\n");
|
||||||
if( pin >= NUM_PWM)
|
if( pin >= NUM_PWM)
|
||||||
@ -288,7 +288,7 @@ uint32_t ICACHE_FLASH_ATTR platform_pwm_get_clock( unsigned pin )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set the PWM clock
|
// Set the PWM clock
|
||||||
uint32_t ICACHE_FLASH_ATTR platform_pwm_set_clock( unsigned pin, uint32_t clock )
|
uint32_t platform_pwm_set_clock( unsigned pin, uint32_t clock )
|
||||||
{
|
{
|
||||||
// NODE_DBG("Function platform_pwm_set_clock() is called.\n");
|
// NODE_DBG("Function platform_pwm_set_clock() is called.\n");
|
||||||
if( pin >= NUM_PWM)
|
if( pin >= NUM_PWM)
|
||||||
@ -301,7 +301,7 @@ uint32_t ICACHE_FLASH_ATTR platform_pwm_set_clock( unsigned pin, uint32_t clock
|
|||||||
return (uint32_t)pwm_get_freq( pin );
|
return (uint32_t)pwm_get_freq( pin );
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t ICACHE_FLASH_ATTR platform_pwm_get_duty( unsigned pin )
|
uint32_t platform_pwm_get_duty( unsigned pin )
|
||||||
{
|
{
|
||||||
// NODE_DBG("Function platform_pwm_get_duty() is called.\n");
|
// NODE_DBG("Function platform_pwm_get_duty() is called.\n");
|
||||||
if( pin < NUM_PWM){
|
if( pin < NUM_PWM){
|
||||||
@ -314,7 +314,7 @@ uint32_t ICACHE_FLASH_ATTR platform_pwm_get_duty( unsigned pin )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set the PWM duty
|
// Set the PWM duty
|
||||||
uint32_t ICACHE_FLASH_ATTR platform_pwm_set_duty( unsigned pin, uint32_t duty )
|
uint32_t platform_pwm_set_duty( unsigned pin, uint32_t duty )
|
||||||
{
|
{
|
||||||
// NODE_DBG("Function platform_pwm_set_duty() is called.\n");
|
// NODE_DBG("Function platform_pwm_set_duty() is called.\n");
|
||||||
if ( pin < NUM_PWM)
|
if ( pin < NUM_PWM)
|
||||||
@ -330,7 +330,7 @@ uint32_t ICACHE_FLASH_ATTR platform_pwm_set_duty( unsigned pin, uint32_t duty )
|
|||||||
return pwms_duty[pin];
|
return pwms_duty[pin];
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t ICACHE_FLASH_ATTR platform_pwm_setup( unsigned pin, uint32_t frequency, unsigned duty )
|
uint32_t platform_pwm_setup( unsigned pin, uint32_t frequency, unsigned duty )
|
||||||
{
|
{
|
||||||
uint32_t clock;
|
uint32_t clock;
|
||||||
if ( pin < NUM_PWM)
|
if ( pin < NUM_PWM)
|
||||||
@ -350,7 +350,7 @@ uint32_t ICACHE_FLASH_ATTR platform_pwm_setup( unsigned pin, uint32_t frequency,
|
|||||||
return clock;
|
return clock;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR platform_pwm_close( unsigned pin )
|
void platform_pwm_close( unsigned pin )
|
||||||
{
|
{
|
||||||
// NODE_DBG("Function platform_pwm_stop() is called.\n");
|
// NODE_DBG("Function platform_pwm_stop() is called.\n");
|
||||||
if ( pin < NUM_PWM)
|
if ( pin < NUM_PWM)
|
||||||
@ -360,7 +360,7 @@ void ICACHE_FLASH_ATTR platform_pwm_close( unsigned pin )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR platform_pwm_start( unsigned pin )
|
void platform_pwm_start( unsigned pin )
|
||||||
{
|
{
|
||||||
// NODE_DBG("Function platform_pwm_start() is called.\n");
|
// NODE_DBG("Function platform_pwm_start() is called.\n");
|
||||||
if ( pin < NUM_PWM)
|
if ( pin < NUM_PWM)
|
||||||
@ -372,7 +372,7 @@ void ICACHE_FLASH_ATTR platform_pwm_start( unsigned pin )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR platform_pwm_stop( unsigned pin )
|
void platform_pwm_stop( unsigned pin )
|
||||||
{
|
{
|
||||||
// NODE_DBG("Function platform_pwm_stop() is called.\n");
|
// NODE_DBG("Function platform_pwm_stop() is called.\n");
|
||||||
if ( pin < NUM_PWM)
|
if ( pin < NUM_PWM)
|
||||||
@ -387,7 +387,7 @@ void ICACHE_FLASH_ATTR platform_pwm_stop( unsigned pin )
|
|||||||
// *****************************************************************************
|
// *****************************************************************************
|
||||||
// I2C platform interface
|
// I2C platform interface
|
||||||
|
|
||||||
uint32_t ICACHE_FLASH_ATTR platform_i2c_setup( unsigned id, uint8_t sda, uint8_t scl, uint32_t speed ){
|
uint32_t platform_i2c_setup( unsigned id, uint8_t sda, uint8_t scl, uint32_t speed ){
|
||||||
if (sda >= NUM_GPIO || scl >= NUM_GPIO)
|
if (sda >= NUM_GPIO || scl >= NUM_GPIO)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@ -402,15 +402,15 @@ uint32_t ICACHE_FLASH_ATTR platform_i2c_setup( unsigned id, uint8_t sda, uint8_t
|
|||||||
return PLATFORM_I2C_SPEED_SLOW;
|
return PLATFORM_I2C_SPEED_SLOW;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR platform_i2c_send_start( unsigned id ){
|
void platform_i2c_send_start( unsigned id ){
|
||||||
i2c_master_start();
|
i2c_master_start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR platform_i2c_send_stop( unsigned id ){
|
void platform_i2c_send_stop( unsigned id ){
|
||||||
i2c_master_stop();
|
i2c_master_stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
int ICACHE_FLASH_ATTR platform_i2c_send_address( unsigned id, uint16_t address, int direction ){
|
int platform_i2c_send_address( unsigned id, uint16_t address, int direction ){
|
||||||
// Convert enum codes to R/w bit value.
|
// Convert enum codes to R/w bit value.
|
||||||
// If TX == 0 and RX == 1, this test will be removed by the compiler
|
// If TX == 0 and RX == 1, this test will be removed by the compiler
|
||||||
if ( ! ( PLATFORM_I2C_DIRECTION_TRANSMITTER == 0 &&
|
if ( ! ( PLATFORM_I2C_DIRECTION_TRANSMITTER == 0 &&
|
||||||
@ -423,13 +423,13 @@ int ICACHE_FLASH_ATTR platform_i2c_send_address( unsigned id, uint16_t address,
|
|||||||
return ! i2c_master_getAck();
|
return ! i2c_master_getAck();
|
||||||
}
|
}
|
||||||
|
|
||||||
int ICACHE_FLASH_ATTR platform_i2c_send_byte( unsigned id, uint8_t data ){
|
int platform_i2c_send_byte( unsigned id, uint8_t data ){
|
||||||
i2c_master_writeByte(data);
|
i2c_master_writeByte(data);
|
||||||
// Low-level returns nack (0=acked); we return ack (1=acked).
|
// Low-level returns nack (0=acked); we return ack (1=acked).
|
||||||
return ! i2c_master_getAck();
|
return ! i2c_master_getAck();
|
||||||
}
|
}
|
||||||
|
|
||||||
int ICACHE_FLASH_ATTR platform_i2c_recv_byte( unsigned id, int ack ){
|
int platform_i2c_recv_byte( unsigned id, int ack ){
|
||||||
uint8_t r = i2c_master_readByte();
|
uint8_t r = i2c_master_readByte();
|
||||||
i2c_master_setAck( !ack );
|
i2c_master_setAck( !ack );
|
||||||
return r;
|
return r;
|
||||||
@ -438,7 +438,7 @@ int ICACHE_FLASH_ATTR platform_i2c_recv_byte( unsigned id, int ack ){
|
|||||||
// ****************************************************************************
|
// ****************************************************************************
|
||||||
// Flash access functions
|
// Flash access functions
|
||||||
|
|
||||||
uint32_t ICACHE_FLASH_ATTR platform_s_flash_write( const void *from, uint32_t toaddr, uint32_t size )
|
uint32_t platform_s_flash_write( const void *from, uint32_t toaddr, uint32_t size )
|
||||||
{
|
{
|
||||||
toaddr -= INTERNAL_FLASH_START_ADDRESS;
|
toaddr -= INTERNAL_FLASH_START_ADDRESS;
|
||||||
SpiFlashOpResult r;
|
SpiFlashOpResult r;
|
||||||
@ -462,7 +462,7 @@ uint32_t ICACHE_FLASH_ATTR platform_s_flash_write( const void *from, uint32_t to
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t ICACHE_FLASH_ATTR platform_s_flash_read( void *to, uint32_t fromaddr, uint32_t size )
|
uint32_t platform_s_flash_read( void *to, uint32_t fromaddr, uint32_t size )
|
||||||
{
|
{
|
||||||
fromaddr -= INTERNAL_FLASH_START_ADDRESS;
|
fromaddr -= INTERNAL_FLASH_START_ADDRESS;
|
||||||
SpiFlashOpResult r;
|
SpiFlashOpResult r;
|
||||||
@ -476,7 +476,7 @@ uint32_t ICACHE_FLASH_ATTR platform_s_flash_read( void *to, uint32_t fromaddr, u
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int ICACHE_FLASH_ATTR platform_flash_erase_sector( uint32_t sector_id )
|
int platform_flash_erase_sector( uint32_t sector_id )
|
||||||
{
|
{
|
||||||
WRITE_PERI_REG(0x60000914, 0x73);
|
WRITE_PERI_REG(0x60000914, 0x73);
|
||||||
return flash_erase( sector_id ) == SPI_FLASH_RESULT_OK ? PLATFORM_OK : PLATFORM_ERR;
|
return flash_erase( sector_id ) == SPI_FLASH_RESULT_OK ? PLATFORM_OK : PLATFORM_ERR;
|
||||||
|
@ -32,7 +32,7 @@ static smart_succeed succeed = NULL;
|
|||||||
static void *smart_succeed_arg = NULL;
|
static void *smart_succeed_arg = NULL;
|
||||||
|
|
||||||
void smart_end();
|
void smart_end();
|
||||||
int ICACHE_FLASH_ATTR smart_check(uint8_t *nibble, uint16_t len, uint8_t *dst, uint8_t *got){
|
int smart_check(uint8_t *nibble, uint16_t len, uint8_t *dst, uint8_t *got){
|
||||||
if(len == 0)
|
if(len == 0)
|
||||||
return 0;
|
return 0;
|
||||||
uint16_t dst_len = len/NIBBLE_PER_BYTE;
|
uint16_t dst_len = len/NIBBLE_PER_BYTE;
|
||||||
@ -127,7 +127,7 @@ int ICACHE_FLASH_ATTR smart_check(uint8_t *nibble, uint16_t len, uint8_t *dst, u
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR detect(uint8 *buf, uint16 len){
|
void detect(uint8 *buf, uint16 len){
|
||||||
uint16_t seq;
|
uint16_t seq;
|
||||||
int16_t seq_delta = 0;
|
int16_t seq_delta = 0;
|
||||||
uint16_t byte_num = 0, bit_num = 0;
|
uint16_t byte_num = 0, bit_num = 0;
|
||||||
@ -435,7 +435,7 @@ end:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR reset_map(smart_addr_map **am, size_t num){
|
void reset_map(smart_addr_map **am, size_t num){
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < num; ++i)
|
for (i = 0; i < num; ++i)
|
||||||
{
|
{
|
||||||
@ -461,15 +461,15 @@ void ICACHE_FLASH_ATTR reset_map(smart_addr_map **am, size_t num){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR smart_enable(void){
|
void smart_enable(void){
|
||||||
wifi_promiscuous_enable(1);
|
wifi_promiscuous_enable(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR smart_disable(void){
|
void smart_disable(void){
|
||||||
wifi_promiscuous_enable(0);
|
wifi_promiscuous_enable(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR smart_end(){
|
void smart_end(){
|
||||||
int i;
|
int i;
|
||||||
os_timer_disarm(&smart_timer);
|
os_timer_disarm(&smart_timer);
|
||||||
smart_disable();
|
smart_disable();
|
||||||
@ -532,7 +532,7 @@ void ICACHE_FLASH_ATTR smart_end(){
|
|||||||
// system_restart(); // restart to enable the mode
|
// system_restart(); // restart to enable the mode
|
||||||
}
|
}
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR smart_next_channel(){
|
void smart_next_channel(){
|
||||||
smart_disable();
|
smart_disable();
|
||||||
switch(cur_channel){
|
switch(cur_channel){
|
||||||
case 1:
|
case 1:
|
||||||
@ -586,7 +586,7 @@ void ICACHE_FLASH_ATTR smart_next_channel(){
|
|||||||
smart_enable();
|
smart_enable();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR smart_begin(int chnl, smart_succeed s, void *arg){
|
void smart_begin(int chnl, smart_succeed s, void *arg){
|
||||||
int i;
|
int i;
|
||||||
alldone = 0;
|
alldone = 0;
|
||||||
for (i = 0; i < ADDR_MAP_NUM; ++i)
|
for (i = 0; i < ADDR_MAP_NUM; ++i)
|
||||||
@ -674,7 +674,7 @@ void ICACHE_FLASH_ATTR smart_begin(int chnl, smart_succeed s, void *arg){
|
|||||||
smart_enable();
|
smart_enable();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR station_check_connect(bool smart){
|
void station_check_connect(bool smart){
|
||||||
mode = wifi_get_opmode();
|
mode = wifi_get_opmode();
|
||||||
if( (STATION_MODE != mode) && (mode != STATIONAP_MODE) ){
|
if( (STATION_MODE != mode) && (mode != STATIONAP_MODE) ){
|
||||||
return;
|
return;
|
||||||
|
@ -10,17 +10,17 @@ static u8_t spiffs_work_buf[LOG_PAGE_SIZE*2];
|
|||||||
static u8_t spiffs_fds[32*4];
|
static u8_t spiffs_fds[32*4];
|
||||||
static u8_t spiffs_cache[(LOG_PAGE_SIZE+32)*4];
|
static u8_t spiffs_cache[(LOG_PAGE_SIZE+32)*4];
|
||||||
|
|
||||||
static s32_t ICACHE_FLASH_ATTR my_spiffs_read(u32_t addr, u32_t size, u8_t *dst) {
|
static s32_t my_spiffs_read(u32_t addr, u32_t size, u8_t *dst) {
|
||||||
platform_flash_read(dst, addr, size);
|
platform_flash_read(dst, addr, size);
|
||||||
return SPIFFS_OK;
|
return SPIFFS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static s32_t ICACHE_FLASH_ATTR my_spiffs_write(u32_t addr, u32_t size, u8_t *src) {
|
static s32_t my_spiffs_write(u32_t addr, u32_t size, u8_t *src) {
|
||||||
platform_flash_write(src, addr, size);
|
platform_flash_write(src, addr, size);
|
||||||
return SPIFFS_OK;
|
return SPIFFS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static s32_t ICACHE_FLASH_ATTR my_spiffs_erase(u32_t addr, u32_t size) {
|
static s32_t my_spiffs_erase(u32_t addr, u32_t size) {
|
||||||
u32_t sect_first = platform_flash_get_sector_of_address(addr);
|
u32_t sect_first = platform_flash_get_sector_of_address(addr);
|
||||||
u32_t sect_last = sect_first;
|
u32_t sect_last = sect_first;
|
||||||
while( sect_first <= sect_last )
|
while( sect_first <= sect_last )
|
||||||
@ -42,7 +42,7 @@ The small 4KB sectors allow for greater flexibility in applications th
|
|||||||
|
|
||||||
********************/
|
********************/
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR spiffs_mount() {
|
void spiffs_mount() {
|
||||||
spiffs_config cfg;
|
spiffs_config cfg;
|
||||||
cfg.phys_addr = ( u32_t )platform_flash_get_first_free_block_address( NULL );
|
cfg.phys_addr = ( u32_t )platform_flash_get_first_free_block_address( NULL );
|
||||||
cfg.phys_size = INTERNAL_FLASH_SIZE - ( ( u32_t )cfg.phys_addr - INTERNAL_FLASH_START_ADDRESS );
|
cfg.phys_size = INTERNAL_FLASH_SIZE - ( ( u32_t )cfg.phys_addr - INTERNAL_FLASH_START_ADDRESS );
|
||||||
@ -69,7 +69,7 @@ void ICACHE_FLASH_ATTR spiffs_mount() {
|
|||||||
|
|
||||||
// FS formatting function
|
// FS formatting function
|
||||||
// Returns 1 if OK, 0 for error
|
// Returns 1 if OK, 0 for error
|
||||||
int ICACHE_FLASH_ATTR myspiffs_format( void )
|
int myspiffs_format( void )
|
||||||
{
|
{
|
||||||
SPIFFS_unmount(&fs);
|
SPIFFS_unmount(&fs);
|
||||||
u32_t sect_first, sect_last;
|
u32_t sect_first, sect_last;
|
||||||
@ -84,7 +84,7 @@ int ICACHE_FLASH_ATTR myspiffs_format( void )
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ICACHE_FLASH_ATTR myspiffs_check( void )
|
int myspiffs_check( void )
|
||||||
{
|
{
|
||||||
// ets_wdt_disable();
|
// ets_wdt_disable();
|
||||||
// int res = (int)SPIFFS_check(&fs);
|
// int res = (int)SPIFFS_check(&fs);
|
||||||
@ -92,15 +92,15 @@ int ICACHE_FLASH_ATTR myspiffs_check( void )
|
|||||||
// return res;
|
// return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ICACHE_FLASH_ATTR myspiffs_open(const char *name, int flags){
|
int myspiffs_open(const char *name, int flags){
|
||||||
return (int)SPIFFS_open(&fs, name, (spiffs_flags)flags, 0);
|
return (int)SPIFFS_open(&fs, name, (spiffs_flags)flags, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ICACHE_FLASH_ATTR myspiffs_close( int fd ){
|
int myspiffs_close( int fd ){
|
||||||
SPIFFS_close(&fs, (spiffs_file)fd);
|
SPIFFS_close(&fs, (spiffs_file)fd);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
size_t ICACHE_FLASH_ATTR myspiffs_write( int fd, const void* ptr, size_t len ){
|
size_t myspiffs_write( int fd, const void* ptr, size_t len ){
|
||||||
#if 0
|
#if 0
|
||||||
if(fd==c_stdout || fd==c_stderr){
|
if(fd==c_stdout || fd==c_stderr){
|
||||||
uart0_tx_buffer((u8_t*)ptr, len);
|
uart0_tx_buffer((u8_t*)ptr, len);
|
||||||
@ -109,39 +109,39 @@ size_t ICACHE_FLASH_ATTR myspiffs_write( int fd, const void* ptr, size_t len ){
|
|||||||
#endif
|
#endif
|
||||||
return SPIFFS_write(&fs, (spiffs_file)fd, (void *)ptr, len);
|
return SPIFFS_write(&fs, (spiffs_file)fd, (void *)ptr, len);
|
||||||
}
|
}
|
||||||
size_t ICACHE_FLASH_ATTR myspiffs_read( int fd, void* ptr, size_t len){
|
size_t myspiffs_read( int fd, void* ptr, size_t len){
|
||||||
return SPIFFS_read(&fs, (spiffs_file)fd, ptr, len);
|
return SPIFFS_read(&fs, (spiffs_file)fd, ptr, len);
|
||||||
}
|
}
|
||||||
int ICACHE_FLASH_ATTR myspiffs_lseek( int fd, int off, int whence ){
|
int myspiffs_lseek( int fd, int off, int whence ){
|
||||||
return SPIFFS_lseek(&fs, (spiffs_file)fd, off, whence);
|
return SPIFFS_lseek(&fs, (spiffs_file)fd, off, whence);
|
||||||
}
|
}
|
||||||
int ICACHE_FLASH_ATTR myspiffs_eof( int fd ){
|
int myspiffs_eof( int fd ){
|
||||||
return SPIFFS_eof(&fs, (spiffs_file)fd);
|
return SPIFFS_eof(&fs, (spiffs_file)fd);
|
||||||
}
|
}
|
||||||
int ICACHE_FLASH_ATTR myspiffs_tell( int fd ){
|
int myspiffs_tell( int fd ){
|
||||||
return SPIFFS_tell(&fs, (spiffs_file)fd);
|
return SPIFFS_tell(&fs, (spiffs_file)fd);
|
||||||
}
|
}
|
||||||
int ICACHE_FLASH_ATTR myspiffs_getc( int fd ){
|
int myspiffs_getc( int fd ){
|
||||||
char c = EOF;
|
char c = EOF;
|
||||||
if(!myspiffs_eof(fd)){
|
if(!myspiffs_eof(fd)){
|
||||||
SPIFFS_read(&fs, (spiffs_file)fd, &c, 1);
|
SPIFFS_read(&fs, (spiffs_file)fd, &c, 1);
|
||||||
}
|
}
|
||||||
return (int)c;
|
return (int)c;
|
||||||
}
|
}
|
||||||
int ICACHE_FLASH_ATTR myspiffs_ungetc( int c, int fd ){
|
int myspiffs_ungetc( int c, int fd ){
|
||||||
return SPIFFS_lseek(&fs, (spiffs_file)fd, -1, SEEK_CUR);
|
return SPIFFS_lseek(&fs, (spiffs_file)fd, -1, SEEK_CUR);
|
||||||
}
|
}
|
||||||
int ICACHE_FLASH_ATTR myspiffs_flush( int fd ){
|
int myspiffs_flush( int fd ){
|
||||||
return SPIFFS_fflush(&fs, (spiffs_file)fd);
|
return SPIFFS_fflush(&fs, (spiffs_file)fd);
|
||||||
}
|
}
|
||||||
int ICACHE_FLASH_ATTR myspiffs_error( int fd ){
|
int myspiffs_error( int fd ){
|
||||||
return SPIFFS_errno(&fs);
|
return SPIFFS_errno(&fs);
|
||||||
}
|
}
|
||||||
void ICACHE_FLASH_ATTR myspiffs_clearerr( int fd ){
|
void myspiffs_clearerr( int fd ){
|
||||||
fs.errno = SPIFFS_OK;
|
fs.errno = SPIFFS_OK;
|
||||||
}
|
}
|
||||||
#if 0
|
#if 0
|
||||||
void ICACHE_FLASH_ATTR test_spiffs() {
|
void test_spiffs() {
|
||||||
char buf[12];
|
char buf[12];
|
||||||
|
|
||||||
// Surely, I've mounted spiffs before entering here
|
// Surely, I've mounted spiffs before entering here
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
#if SPIFFS_CACHE
|
#if SPIFFS_CACHE
|
||||||
|
|
||||||
// returns cached page for give page index, or null if no such cached page
|
// returns cached page for give page index, or null if no such cached page
|
||||||
static spiffs_cache_page *ICACHE_FLASH_ATTR spiffs_cache_page_get(spiffs *fs, spiffs_page_ix pix) {
|
static spiffs_cache_page *spiffs_cache_page_get(spiffs *fs, spiffs_page_ix pix) {
|
||||||
spiffs_cache *cache = spiffs_get_cache(fs);
|
spiffs_cache *cache = spiffs_get_cache(fs);
|
||||||
if ((cache->cpage_use_map & cache->cpage_use_mask) == 0) return 0;
|
if ((cache->cpage_use_map & cache->cpage_use_mask) == 0) return 0;
|
||||||
int i;
|
int i;
|
||||||
@ -30,7 +30,7 @@ static spiffs_cache_page *ICACHE_FLASH_ATTR spiffs_cache_page_get(spiffs *fs, sp
|
|||||||
}
|
}
|
||||||
|
|
||||||
// frees cached page
|
// frees cached page
|
||||||
static s32_t ICACHE_FLASH_ATTR spiffs_cache_page_free(spiffs *fs, int ix, u8_t write_back) {
|
static s32_t spiffs_cache_page_free(spiffs *fs, int ix, u8_t write_back) {
|
||||||
s32_t res = SPIFFS_OK;
|
s32_t res = SPIFFS_OK;
|
||||||
spiffs_cache *cache = spiffs_get_cache(fs);
|
spiffs_cache *cache = spiffs_get_cache(fs);
|
||||||
spiffs_cache_page *cp = spiffs_get_cache_page_hdr(fs, cache, ix);
|
spiffs_cache_page *cp = spiffs_get_cache_page_hdr(fs, cache, ix);
|
||||||
@ -56,7 +56,7 @@ static s32_t ICACHE_FLASH_ATTR spiffs_cache_page_free(spiffs *fs, int ix, u8_t w
|
|||||||
}
|
}
|
||||||
|
|
||||||
// removes the oldest accessed cached page
|
// removes the oldest accessed cached page
|
||||||
static s32_t ICACHE_FLASH_ATTR spiffs_cache_page_remove_oldest(spiffs *fs, u8_t flag_mask, u8_t flags) {
|
static s32_t spiffs_cache_page_remove_oldest(spiffs *fs, u8_t flag_mask, u8_t flags) {
|
||||||
s32_t res = SPIFFS_OK;
|
s32_t res = SPIFFS_OK;
|
||||||
spiffs_cache *cache = spiffs_get_cache(fs);
|
spiffs_cache *cache = spiffs_get_cache(fs);
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ static s32_t ICACHE_FLASH_ATTR spiffs_cache_page_remove_oldest(spiffs *fs, u8_t
|
|||||||
}
|
}
|
||||||
|
|
||||||
// allocates a new cached page and returns it, or null if all cache pages are busy
|
// allocates a new cached page and returns it, or null if all cache pages are busy
|
||||||
static spiffs_cache_page *ICACHE_FLASH_ATTR spiffs_cache_page_allocate(spiffs *fs) {
|
static spiffs_cache_page *spiffs_cache_page_allocate(spiffs *fs) {
|
||||||
spiffs_cache *cache = spiffs_get_cache(fs);
|
spiffs_cache *cache = spiffs_get_cache(fs);
|
||||||
if (cache->cpage_use_map == 0xffffffff) {
|
if (cache->cpage_use_map == 0xffffffff) {
|
||||||
// out of cache memory
|
// out of cache memory
|
||||||
@ -107,7 +107,7 @@ static spiffs_cache_page *ICACHE_FLASH_ATTR spiffs_cache_page_allocate(spiffs *f
|
|||||||
}
|
}
|
||||||
|
|
||||||
// drops the cache page for give page index
|
// drops the cache page for give page index
|
||||||
void ICACHE_FLASH_ATTR spiffs_cache_drop_page(spiffs *fs, spiffs_page_ix pix) {
|
void spiffs_cache_drop_page(spiffs *fs, spiffs_page_ix pix) {
|
||||||
spiffs_cache_page *cp = spiffs_cache_page_get(fs, pix);
|
spiffs_cache_page *cp = spiffs_cache_page_get(fs, pix);
|
||||||
if (cp) {
|
if (cp) {
|
||||||
spiffs_cache_page_free(fs, cp->ix, 0);
|
spiffs_cache_page_free(fs, cp->ix, 0);
|
||||||
@ -117,7 +117,7 @@ void ICACHE_FLASH_ATTR spiffs_cache_drop_page(spiffs *fs, spiffs_page_ix pix) {
|
|||||||
// ------------------------------
|
// ------------------------------
|
||||||
|
|
||||||
// reads from spi flash or the cache
|
// reads from spi flash or the cache
|
||||||
s32_t ICACHE_FLASH_ATTR spiffs_phys_rd(
|
s32_t spiffs_phys_rd(
|
||||||
spiffs *fs,
|
spiffs *fs,
|
||||||
u8_t op,
|
u8_t op,
|
||||||
spiffs_file fh,
|
spiffs_file fh,
|
||||||
@ -165,7 +165,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_phys_rd(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// writes to spi flash and/or the cache
|
// writes to spi flash and/or the cache
|
||||||
s32_t ICACHE_FLASH_ATTR spiffs_phys_wr(
|
s32_t spiffs_phys_wr(
|
||||||
spiffs *fs,
|
spiffs *fs,
|
||||||
u8_t op,
|
u8_t op,
|
||||||
spiffs_file fh,
|
spiffs_file fh,
|
||||||
@ -207,7 +207,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_phys_wr(
|
|||||||
|
|
||||||
#if SPIFFS_CACHE_WR
|
#if SPIFFS_CACHE_WR
|
||||||
// returns the cache page that this fd refers, or null if no cache page
|
// returns the cache page that this fd refers, or null if no cache page
|
||||||
spiffs_cache_page *ICACHE_FLASH_ATTR spiffs_cache_page_get_by_fd(spiffs *fs, spiffs_fd *fd) {
|
spiffs_cache_page *spiffs_cache_page_get_by_fd(spiffs *fs, spiffs_fd *fd) {
|
||||||
spiffs_cache *cache = spiffs_get_cache(fs);
|
spiffs_cache *cache = spiffs_get_cache(fs);
|
||||||
|
|
||||||
if ((cache->cpage_use_map & cache->cpage_use_mask) == 0) {
|
if ((cache->cpage_use_map & cache->cpage_use_mask) == 0) {
|
||||||
@ -230,7 +230,7 @@ spiffs_cache_page *ICACHE_FLASH_ATTR spiffs_cache_page_get_by_fd(spiffs *fs, spi
|
|||||||
|
|
||||||
// allocates a new cache page and refers this to given fd - flushes an old cache
|
// allocates a new cache page and refers this to given fd - flushes an old cache
|
||||||
// page if all cache is busy
|
// page if all cache is busy
|
||||||
spiffs_cache_page *ICACHE_FLASH_ATTR spiffs_cache_page_allocate_by_fd(spiffs *fs, spiffs_fd *fd) {
|
spiffs_cache_page *spiffs_cache_page_allocate_by_fd(spiffs *fs, spiffs_fd *fd) {
|
||||||
// before this function is called, it is ensured that there is no already existing
|
// before this function is called, it is ensured that there is no already existing
|
||||||
// cache page with same object id
|
// cache page with same object id
|
||||||
spiffs_cache_page_remove_oldest(fs, SPIFFS_CACHE_FLAG_TYPE_WR, 0);
|
spiffs_cache_page_remove_oldest(fs, SPIFFS_CACHE_FLAG_TYPE_WR, 0);
|
||||||
@ -247,7 +247,7 @@ spiffs_cache_page *ICACHE_FLASH_ATTR spiffs_cache_page_allocate_by_fd(spiffs *fs
|
|||||||
}
|
}
|
||||||
|
|
||||||
// unrefers all fds that this cache page refers to and releases the cache page
|
// unrefers all fds that this cache page refers to and releases the cache page
|
||||||
void ICACHE_FLASH_ATTR spiffs_cache_fd_release(spiffs *fs, spiffs_cache_page *cp) {
|
void spiffs_cache_fd_release(spiffs *fs, spiffs_cache_page *cp) {
|
||||||
if (cp == 0) return;
|
if (cp == 0) return;
|
||||||
int i;
|
int i;
|
||||||
spiffs_fd *fds = (spiffs_fd *)fs->fd_space;
|
spiffs_fd *fds = (spiffs_fd *)fs->fd_space;
|
||||||
@ -265,7 +265,7 @@ void ICACHE_FLASH_ATTR spiffs_cache_fd_release(spiffs *fs, spiffs_cache_page *cp
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// initializes the cache
|
// initializes the cache
|
||||||
void ICACHE_FLASH_ATTR spiffs_cache_init(spiffs *fs) {
|
void spiffs_cache_init(spiffs *fs) {
|
||||||
if (fs->cache == 0) return;
|
if (fs->cache == 0) return;
|
||||||
u32_t sz = fs->cache_size;
|
u32_t sz = fs->cache_size;
|
||||||
u32_t cache_mask = 0;
|
u32_t cache_mask = 0;
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
// searches in the object indices and returns the referenced page index given
|
// searches in the object indices and returns the referenced page index given
|
||||||
// the object id and the data span index
|
// the object id and the data span index
|
||||||
// destroys fs->lu_work
|
// destroys fs->lu_work
|
||||||
static s32_t ICACHE_FLASH_ATTR spiffs_object_get_data_page_index_reference(
|
static s32_t spiffs_object_get_data_page_index_reference(
|
||||||
spiffs *fs,
|
spiffs *fs,
|
||||||
spiffs_obj_id obj_id,
|
spiffs_obj_id obj_id,
|
||||||
spiffs_span_ix data_spix,
|
spiffs_span_ix data_spix,
|
||||||
@ -59,7 +59,7 @@ static s32_t ICACHE_FLASH_ATTR spiffs_object_get_data_page_index_reference(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// copies page contents to a new page
|
// copies page contents to a new page
|
||||||
static s32_t ICACHE_FLASH_ATTR spiffs_rewrite_page(spiffs *fs, spiffs_page_ix cur_pix, spiffs_page_header *p_hdr, spiffs_page_ix *new_pix) {
|
static s32_t spiffs_rewrite_page(spiffs *fs, spiffs_page_ix cur_pix, spiffs_page_header *p_hdr, spiffs_page_ix *new_pix) {
|
||||||
s32_t res;
|
s32_t res;
|
||||||
res = spiffs_page_allocate_data(fs, p_hdr->obj_id, p_hdr, 0,0,0,0, new_pix);
|
res = spiffs_page_allocate_data(fs, p_hdr->obj_id, p_hdr, 0,0,0,0, new_pix);
|
||||||
SPIFFS_CHECK_RES(res);
|
SPIFFS_CHECK_RES(res);
|
||||||
@ -73,7 +73,7 @@ static s32_t ICACHE_FLASH_ATTR spiffs_rewrite_page(spiffs *fs, spiffs_page_ix cu
|
|||||||
|
|
||||||
// rewrites the object index for given object id and replaces the
|
// rewrites the object index for given object id and replaces the
|
||||||
// data page index to a new page index
|
// data page index to a new page index
|
||||||
static s32_t ICACHE_FLASH_ATTR spiffs_rewrite_index(spiffs *fs, spiffs_obj_id obj_id, spiffs_span_ix data_spix, spiffs_page_ix new_data_pix, spiffs_page_ix objix_pix) {
|
static s32_t spiffs_rewrite_index(spiffs *fs, spiffs_obj_id obj_id, spiffs_span_ix data_spix, spiffs_page_ix new_data_pix, spiffs_page_ix objix_pix) {
|
||||||
s32_t res;
|
s32_t res;
|
||||||
spiffs_block_ix bix;
|
spiffs_block_ix bix;
|
||||||
int entry;
|
int entry;
|
||||||
@ -137,7 +137,7 @@ static s32_t ICACHE_FLASH_ATTR spiffs_rewrite_index(spiffs *fs, spiffs_obj_id ob
|
|||||||
}
|
}
|
||||||
|
|
||||||
// deletes an object just by marking object index header as deleted
|
// deletes an object just by marking object index header as deleted
|
||||||
static s32_t ICACHE_FLASH_ATTR spiffs_delete_obj_lazy(spiffs *fs, spiffs_obj_id obj_id) {
|
static s32_t spiffs_delete_obj_lazy(spiffs *fs, spiffs_obj_id obj_id) {
|
||||||
spiffs_page_ix objix_hdr_pix;
|
spiffs_page_ix objix_hdr_pix;
|
||||||
s32_t res;
|
s32_t res;
|
||||||
res = spiffs_obj_lu_find_id_and_span(fs, obj_id, 0, 0, &objix_hdr_pix);
|
res = spiffs_obj_lu_find_id_and_span(fs, obj_id, 0, 0, &objix_hdr_pix);
|
||||||
@ -154,7 +154,7 @@ static s32_t ICACHE_FLASH_ATTR spiffs_delete_obj_lazy(spiffs *fs, spiffs_obj_id
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validates the given look up entry
|
// validates the given look up entry
|
||||||
static s32_t ICACHE_FLASH_ATTR spiffs_lookup_check_validate(spiffs *fs, spiffs_obj_id lu_obj_id, spiffs_page_header *p_hdr,
|
static s32_t spiffs_lookup_check_validate(spiffs *fs, spiffs_obj_id lu_obj_id, spiffs_page_header *p_hdr,
|
||||||
spiffs_page_ix cur_pix, spiffs_block_ix cur_block, int cur_entry, int *reload_lu) {
|
spiffs_page_ix cur_pix, spiffs_block_ix cur_block, int cur_entry, int *reload_lu) {
|
||||||
u8_t delete_page = 0;
|
u8_t delete_page = 0;
|
||||||
s32_t res = SPIFFS_OK;
|
s32_t res = SPIFFS_OK;
|
||||||
@ -424,7 +424,7 @@ static s32_t ICACHE_FLASH_ATTR spiffs_lookup_check_validate(spiffs *fs, spiffs_o
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static s32_t ICACHE_FLASH_ATTR spiffs_lookup_check_v(spiffs *fs, spiffs_obj_id obj_id, spiffs_block_ix cur_block, int cur_entry,
|
static s32_t spiffs_lookup_check_v(spiffs *fs, spiffs_obj_id obj_id, spiffs_block_ix cur_block, int cur_entry,
|
||||||
u32_t user_data, void *user_p) {
|
u32_t user_data, void *user_p) {
|
||||||
s32_t res = SPIFFS_OK;
|
s32_t res = SPIFFS_OK;
|
||||||
spiffs_page_header p_hdr;
|
spiffs_page_header p_hdr;
|
||||||
@ -452,7 +452,7 @@ static s32_t ICACHE_FLASH_ATTR spiffs_lookup_check_v(spiffs *fs, spiffs_obj_id o
|
|||||||
|
|
||||||
// Scans all object look up. For each entry, corresponding page header is checked for validity.
|
// Scans all object look up. For each entry, corresponding page header is checked for validity.
|
||||||
// If an object index header page is found, this is also checked
|
// If an object index header page is found, this is also checked
|
||||||
s32_t ICACHE_FLASH_ATTR spiffs_lookup_consistency_check(spiffs *fs, u8_t check_all_objects) {
|
s32_t spiffs_lookup_consistency_check(spiffs *fs, u8_t check_all_objects) {
|
||||||
s32_t res = SPIFFS_OK;
|
s32_t res = SPIFFS_OK;
|
||||||
|
|
||||||
if (fs->check_cb_f) fs->check_cb_f(SPIFFS_CHECK_LOOKUP, SPIFFS_CHECK_PROGRESS, 0, 0);
|
if (fs->check_cb_f) fs->check_cb_f(SPIFFS_CHECK_LOOKUP, SPIFFS_CHECK_PROGRESS, 0, 0);
|
||||||
@ -485,7 +485,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_lookup_consistency_check(spiffs *fs, u8_t check_a
|
|||||||
// * x011 used, referenced only once, not index
|
// * x011 used, referenced only once, not index
|
||||||
// * x101 used, unreferenced, index
|
// * x101 used, unreferenced, index
|
||||||
// The working memory might not fit all pages so several scans might be needed
|
// The working memory might not fit all pages so several scans might be needed
|
||||||
static s32_t ICACHE_FLASH_ATTR spiffs_page_consistency_check_i(spiffs *fs) {
|
static s32_t spiffs_page_consistency_check_i(spiffs *fs) {
|
||||||
const u32_t bits = 4;
|
const u32_t bits = 4;
|
||||||
const spiffs_page_ix pages_per_scan = SPIFFS_CFG_LOG_PAGE_SZ(fs) * 8 / bits;
|
const spiffs_page_ix pages_per_scan = SPIFFS_CFG_LOG_PAGE_SZ(fs) * 8 / bits;
|
||||||
|
|
||||||
@ -822,7 +822,7 @@ static s32_t ICACHE_FLASH_ATTR spiffs_page_consistency_check_i(spiffs *fs) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Checks consistency amongst all pages and fixes irregularities
|
// Checks consistency amongst all pages and fixes irregularities
|
||||||
s32_t ICACHE_FLASH_ATTR spiffs_page_consistency_check(spiffs *fs) {
|
s32_t spiffs_page_consistency_check(spiffs *fs) {
|
||||||
if (fs->check_cb_f) fs->check_cb_f(SPIFFS_CHECK_PAGE, SPIFFS_CHECK_PROGRESS, 0, 0);
|
if (fs->check_cb_f) fs->check_cb_f(SPIFFS_CHECK_PAGE, SPIFFS_CHECK_PROGRESS, 0, 0);
|
||||||
s32_t res = spiffs_page_consistency_check_i(fs);
|
s32_t res = spiffs_page_consistency_check_i(fs);
|
||||||
if (res != SPIFFS_OK) {
|
if (res != SPIFFS_OK) {
|
||||||
@ -837,7 +837,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_page_consistency_check(spiffs *fs) {
|
|||||||
|
|
||||||
// searches for given object id in temporary object id index,
|
// searches for given object id in temporary object id index,
|
||||||
// returns the index or -1
|
// returns the index or -1
|
||||||
static int ICACHE_FLASH_ATTR spiffs_object_index_search(spiffs *fs, spiffs_obj_id obj_id) {
|
static int spiffs_object_index_search(spiffs *fs, spiffs_obj_id obj_id) {
|
||||||
int i;
|
int i;
|
||||||
spiffs_obj_id *obj_table = (spiffs_obj_id *)fs->work;
|
spiffs_obj_id *obj_table = (spiffs_obj_id *)fs->work;
|
||||||
obj_id &= ~SPIFFS_OBJ_ID_IX_FLAG;
|
obj_id &= ~SPIFFS_OBJ_ID_IX_FLAG;
|
||||||
@ -849,7 +849,7 @@ static int ICACHE_FLASH_ATTR spiffs_object_index_search(spiffs *fs, spiffs_obj_i
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32_t ICACHE_FLASH_ATTR spiffs_object_index_consistency_check_v(spiffs *fs, spiffs_obj_id obj_id, spiffs_block_ix cur_block,
|
s32_t spiffs_object_index_consistency_check_v(spiffs *fs, spiffs_obj_id obj_id, spiffs_block_ix cur_block,
|
||||||
int cur_entry, u32_t user_data, void *user_p) {
|
int cur_entry, u32_t user_data, void *user_p) {
|
||||||
s32_t res_c = SPIFFS_VIS_COUNTINUE;
|
s32_t res_c = SPIFFS_VIS_COUNTINUE;
|
||||||
s32_t res = SPIFFS_OK;
|
s32_t res = SPIFFS_OK;
|
||||||
@ -943,7 +943,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_object_index_consistency_check_v(spiffs *fs, spif
|
|||||||
// Scans for index pages. When an index page is found, corresponding index header is searched for.
|
// Scans for index pages. When an index page is found, corresponding index header is searched for.
|
||||||
// If no such page exists, the index page cannot be reached as no index header exists and must be
|
// If no such page exists, the index page cannot be reached as no index header exists and must be
|
||||||
// deleted.
|
// deleted.
|
||||||
s32_t ICACHE_FLASH_ATTR spiffs_object_index_consistency_check(spiffs *fs) {
|
s32_t spiffs_object_index_consistency_check(spiffs *fs) {
|
||||||
s32_t res = SPIFFS_OK;
|
s32_t res = SPIFFS_OK;
|
||||||
// impl note:
|
// impl note:
|
||||||
// fs->work is used for a temporary object index memory, listing found object ids and
|
// fs->work is used for a temporary object index memory, listing found object ids and
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
// Erases a logical block and updates the erase counter.
|
// Erases a logical block and updates the erase counter.
|
||||||
// If cache is enabled, all pages that might be cached in this block
|
// If cache is enabled, all pages that might be cached in this block
|
||||||
// is dropped.
|
// is dropped.
|
||||||
static s32_t ICACHE_FLASH_ATTR spiffs_gc_erase_block(
|
static s32_t spiffs_gc_erase_block(
|
||||||
spiffs *fs,
|
spiffs *fs,
|
||||||
spiffs_block_ix bix) {
|
spiffs_block_ix bix) {
|
||||||
s32_t res;
|
s32_t res;
|
||||||
@ -47,7 +47,7 @@ static s32_t ICACHE_FLASH_ATTR spiffs_gc_erase_block(
|
|||||||
// Searches for blocks where all entries are deleted - if one is found,
|
// Searches for blocks where all entries are deleted - if one is found,
|
||||||
// the block is erased. Compared to the non-quick gc, the quick one ensures
|
// the block is erased. Compared to the non-quick gc, the quick one ensures
|
||||||
// that no updates are needed on existing objects on pages that are erased.
|
// that no updates are needed on existing objects on pages that are erased.
|
||||||
s32_t ICACHE_FLASH_ATTR spiffs_gc_quick(
|
s32_t spiffs_gc_quick(
|
||||||
spiffs *fs) {
|
spiffs *fs) {
|
||||||
s32_t res = SPIFFS_OK;
|
s32_t res = SPIFFS_OK;
|
||||||
u32_t blocks = fs->block_count;
|
u32_t blocks = fs->block_count;
|
||||||
@ -111,7 +111,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_gc_quick(
|
|||||||
|
|
||||||
// Checks if garbaga collecting is necessary. If so a candidate block is found,
|
// Checks if garbaga collecting is necessary. If so a candidate block is found,
|
||||||
// cleansed and erased
|
// cleansed and erased
|
||||||
s32_t ICACHE_FLASH_ATTR spiffs_gc_check(
|
s32_t spiffs_gc_check(
|
||||||
spiffs *fs,
|
spiffs *fs,
|
||||||
u32_t len) {
|
u32_t len) {
|
||||||
s32_t res;
|
s32_t res;
|
||||||
@ -179,7 +179,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_gc_check(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Updates page statistics for a block that is about to be erased
|
// Updates page statistics for a block that is about to be erased
|
||||||
s32_t ICACHE_FLASH_ATTR spiffs_gc_erase_page_stats(
|
s32_t spiffs_gc_erase_page_stats(
|
||||||
spiffs *fs,
|
spiffs *fs,
|
||||||
spiffs_block_ix bix) {
|
spiffs_block_ix bix) {
|
||||||
s32_t res = SPIFFS_OK;
|
s32_t res = SPIFFS_OK;
|
||||||
@ -216,7 +216,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_gc_erase_page_stats(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Finds block candidates to erase
|
// Finds block candidates to erase
|
||||||
s32_t ICACHE_FLASH_ATTR spiffs_gc_find_candidate(
|
s32_t spiffs_gc_find_candidate(
|
||||||
spiffs *fs,
|
spiffs *fs,
|
||||||
spiffs_block_ix **block_candidates,
|
spiffs_block_ix **block_candidates,
|
||||||
int *candidate_count) {
|
int *candidate_count) {
|
||||||
@ -350,7 +350,7 @@ typedef struct {
|
|||||||
// repeat loop until end of object lookup
|
// repeat loop until end of object lookup
|
||||||
// scan object lookup again for remaining object index pages, move to new page in other block
|
// scan object lookup again for remaining object index pages, move to new page in other block
|
||||||
//
|
//
|
||||||
s32_t ICACHE_FLASH_ATTR spiffs_gc_clean(spiffs *fs, spiffs_block_ix bix) {
|
s32_t spiffs_gc_clean(spiffs *fs, spiffs_block_ix bix) {
|
||||||
s32_t res = SPIFFS_OK;
|
s32_t res = SPIFFS_OK;
|
||||||
u32_t entries_per_page = (SPIFFS_CFG_LOG_PAGE_SZ(fs) / sizeof(spiffs_obj_id));
|
u32_t entries_per_page = (SPIFFS_CFG_LOG_PAGE_SZ(fs) / sizeof(spiffs_obj_id));
|
||||||
int cur_entry = 0;
|
int cur_entry = 0;
|
||||||
|
@ -11,17 +11,17 @@
|
|||||||
static s32_t spiffs_fflush_cache(spiffs *fs, spiffs_file fh);
|
static s32_t spiffs_fflush_cache(spiffs *fs, spiffs_file fh);
|
||||||
|
|
||||||
#if SPIFFS_BUFFER_HELP
|
#if SPIFFS_BUFFER_HELP
|
||||||
u32_t ICACHE_FLASH_ATTR SPIFFS_buffer_bytes_for_filedescs(spiffs *fs, u32_t num_descs) {
|
u32_t SPIFFS_buffer_bytes_for_filedescs(spiffs *fs, u32_t num_descs) {
|
||||||
return num_descs * sizeof(spiffs_fd);
|
return num_descs * sizeof(spiffs_fd);
|
||||||
}
|
}
|
||||||
#if SPIFFS_CACHE
|
#if SPIFFS_CACHE
|
||||||
u32_t ICACHE_FLASH_ATTR SPIFFS_buffer_bytes_for_cache(spiffs *fs, u32_t num_pages) {
|
u32_t SPIFFS_buffer_bytes_for_cache(spiffs *fs, u32_t num_pages) {
|
||||||
return sizeof(spiffs_cache) + num_pages * (sizeof(spiffs_cache_page) + SPIFFS_CFG_LOG_PAGE_SZ(fs));
|
return sizeof(spiffs_cache) + num_pages * (sizeof(spiffs_cache_page) + SPIFFS_CFG_LOG_PAGE_SZ(fs));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
s32_t ICACHE_FLASH_ATTR SPIFFS_mount(spiffs *fs, spiffs_config *config, u8_t *work,
|
s32_t SPIFFS_mount(spiffs *fs, spiffs_config *config, u8_t *work,
|
||||||
u8_t *fd_space, u32_t fd_space_size,
|
u8_t *fd_space, u32_t fd_space_size,
|
||||||
void *cache, u32_t cache_size,
|
void *cache, u32_t cache_size,
|
||||||
spiffs_check_callback check_cb_f) {
|
spiffs_check_callback check_cb_f) {
|
||||||
@ -82,7 +82,7 @@ s32_t ICACHE_FLASH_ATTR SPIFFS_mount(spiffs *fs, spiffs_config *config, u8_t *wo
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR SPIFFS_unmount(spiffs *fs) {
|
void SPIFFS_unmount(spiffs *fs) {
|
||||||
if (!SPIFFS_CHECK_MOUNT(fs)) return;
|
if (!SPIFFS_CHECK_MOUNT(fs)) return;
|
||||||
SPIFFS_LOCK(fs);
|
SPIFFS_LOCK(fs);
|
||||||
int i;
|
int i;
|
||||||
@ -100,11 +100,11 @@ void ICACHE_FLASH_ATTR SPIFFS_unmount(spiffs *fs) {
|
|||||||
SPIFFS_UNLOCK(fs);
|
SPIFFS_UNLOCK(fs);
|
||||||
}
|
}
|
||||||
|
|
||||||
s32_t ICACHE_FLASH_ATTR SPIFFS_errno(spiffs *fs) {
|
s32_t SPIFFS_errno(spiffs *fs) {
|
||||||
return fs->errno;
|
return fs->errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32_t ICACHE_FLASH_ATTR SPIFFS_creat(spiffs *fs, const char *path, spiffs_mode mode) {
|
s32_t SPIFFS_creat(spiffs *fs, const char *path, spiffs_mode mode) {
|
||||||
SPIFFS_API_CHECK_MOUNT(fs);
|
SPIFFS_API_CHECK_MOUNT(fs);
|
||||||
SPIFFS_LOCK(fs);
|
SPIFFS_LOCK(fs);
|
||||||
spiffs_obj_id obj_id;
|
spiffs_obj_id obj_id;
|
||||||
@ -118,7 +118,7 @@ s32_t ICACHE_FLASH_ATTR SPIFFS_creat(spiffs *fs, const char *path, spiffs_mode m
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
spiffs_file ICACHE_FLASH_ATTR SPIFFS_open(spiffs *fs, const char *path, spiffs_flags flags, spiffs_mode mode) {
|
spiffs_file SPIFFS_open(spiffs *fs, const char *path, spiffs_flags flags, spiffs_mode mode) {
|
||||||
SPIFFS_API_CHECK_MOUNT(fs);
|
SPIFFS_API_CHECK_MOUNT(fs);
|
||||||
SPIFFS_LOCK(fs);
|
SPIFFS_LOCK(fs);
|
||||||
|
|
||||||
@ -175,7 +175,7 @@ spiffs_file ICACHE_FLASH_ATTR SPIFFS_open(spiffs *fs, const char *path, spiffs_f
|
|||||||
return fd->file_nbr;
|
return fd->file_nbr;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32_t ICACHE_FLASH_ATTR SPIFFS_read(spiffs *fs, spiffs_file fh, void *buf, u32_t len) {
|
s32_t SPIFFS_read(spiffs *fs, spiffs_file fh, void *buf, u32_t len) {
|
||||||
SPIFFS_API_CHECK_MOUNT(fs);
|
SPIFFS_API_CHECK_MOUNT(fs);
|
||||||
SPIFFS_LOCK(fs);
|
SPIFFS_LOCK(fs);
|
||||||
|
|
||||||
@ -220,7 +220,7 @@ s32_t ICACHE_FLASH_ATTR SPIFFS_read(spiffs *fs, spiffs_file fh, void *buf, u32_t
|
|||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
static s32_t ICACHE_FLASH_ATTR spiffs_hydro_write(spiffs *fs, spiffs_fd *fd, void *buf, u32_t offset, s32_t len) {
|
static s32_t spiffs_hydro_write(spiffs *fs, spiffs_fd *fd, void *buf, u32_t offset, s32_t len) {
|
||||||
s32_t res = SPIFFS_OK;
|
s32_t res = SPIFFS_OK;
|
||||||
s32_t remaining = len;
|
s32_t remaining = len;
|
||||||
if (fd->size != SPIFFS_UNDEFINED_LEN && offset < fd->size) {
|
if (fd->size != SPIFFS_UNDEFINED_LEN && offset < fd->size) {
|
||||||
@ -239,7 +239,7 @@ static s32_t ICACHE_FLASH_ATTR spiffs_hydro_write(spiffs *fs, spiffs_fd *fd, voi
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
s32_t ICACHE_FLASH_ATTR SPIFFS_write(spiffs *fs, spiffs_file fh, void *buf, u32_t len) {
|
s32_t SPIFFS_write(spiffs *fs, spiffs_file fh, void *buf, u32_t len) {
|
||||||
SPIFFS_API_CHECK_MOUNT(fs);
|
SPIFFS_API_CHECK_MOUNT(fs);
|
||||||
SPIFFS_LOCK(fs);
|
SPIFFS_LOCK(fs);
|
||||||
|
|
||||||
@ -357,7 +357,7 @@ s32_t ICACHE_FLASH_ATTR SPIFFS_write(spiffs *fs, spiffs_file fh, void *buf, u32_
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32_t ICACHE_FLASH_ATTR SPIFFS_lseek(spiffs *fs, spiffs_file fh, s32_t offs, int whence) {
|
s32_t SPIFFS_lseek(spiffs *fs, spiffs_file fh, s32_t offs, int whence) {
|
||||||
SPIFFS_API_CHECK_MOUNT(fs);
|
SPIFFS_API_CHECK_MOUNT(fs);
|
||||||
SPIFFS_LOCK(fs);
|
SPIFFS_LOCK(fs);
|
||||||
|
|
||||||
@ -401,7 +401,7 @@ s32_t ICACHE_FLASH_ATTR SPIFFS_lseek(spiffs *fs, spiffs_file fh, s32_t offs, int
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32_t ICACHE_FLASH_ATTR SPIFFS_remove(spiffs *fs, const char *path) {
|
s32_t SPIFFS_remove(spiffs *fs, const char *path) {
|
||||||
SPIFFS_API_CHECK_MOUNT(fs);
|
SPIFFS_API_CHECK_MOUNT(fs);
|
||||||
SPIFFS_LOCK(fs);
|
SPIFFS_LOCK(fs);
|
||||||
|
|
||||||
@ -434,7 +434,7 @@ s32_t ICACHE_FLASH_ATTR SPIFFS_remove(spiffs *fs, const char *path) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32_t ICACHE_FLASH_ATTR SPIFFS_fremove(spiffs *fs, spiffs_file fh) {
|
s32_t SPIFFS_fremove(spiffs *fs, spiffs_file fh) {
|
||||||
SPIFFS_API_CHECK_MOUNT(fs);
|
SPIFFS_API_CHECK_MOUNT(fs);
|
||||||
SPIFFS_LOCK(fs);
|
SPIFFS_LOCK(fs);
|
||||||
|
|
||||||
@ -461,7 +461,7 @@ s32_t ICACHE_FLASH_ATTR SPIFFS_fremove(spiffs *fs, spiffs_file fh) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static s32_t ICACHE_FLASH_ATTR spiffs_stat_pix(spiffs *fs, spiffs_page_ix pix, spiffs_file fh, spiffs_stat *s) {
|
static s32_t spiffs_stat_pix(spiffs *fs, spiffs_page_ix pix, spiffs_file fh, spiffs_stat *s) {
|
||||||
spiffs_page_object_ix_header objix_hdr;
|
spiffs_page_object_ix_header objix_hdr;
|
||||||
spiffs_obj_id obj_id;
|
spiffs_obj_id obj_id;
|
||||||
s32_t res =_spiffs_rd(fs, SPIFFS_OP_T_OBJ_IX | SPIFFS_OP_C_READ, fh,
|
s32_t res =_spiffs_rd(fs, SPIFFS_OP_T_OBJ_IX | SPIFFS_OP_C_READ, fh,
|
||||||
@ -482,7 +482,7 @@ static s32_t ICACHE_FLASH_ATTR spiffs_stat_pix(spiffs *fs, spiffs_page_ix pix, s
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32_t ICACHE_FLASH_ATTR SPIFFS_stat(spiffs *fs, const char *path, spiffs_stat *s) {
|
s32_t SPIFFS_stat(spiffs *fs, const char *path, spiffs_stat *s) {
|
||||||
SPIFFS_API_CHECK_MOUNT(fs);
|
SPIFFS_API_CHECK_MOUNT(fs);
|
||||||
SPIFFS_LOCK(fs);
|
SPIFFS_LOCK(fs);
|
||||||
|
|
||||||
@ -499,7 +499,7 @@ s32_t ICACHE_FLASH_ATTR SPIFFS_stat(spiffs *fs, const char *path, spiffs_stat *s
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32_t ICACHE_FLASH_ATTR SPIFFS_fstat(spiffs *fs, spiffs_file fh, spiffs_stat *s) {
|
s32_t SPIFFS_fstat(spiffs *fs, spiffs_file fh, spiffs_stat *s) {
|
||||||
SPIFFS_API_CHECK_MOUNT(fs);
|
SPIFFS_API_CHECK_MOUNT(fs);
|
||||||
SPIFFS_LOCK(fs);
|
SPIFFS_LOCK(fs);
|
||||||
|
|
||||||
@ -522,7 +522,7 @@ s32_t ICACHE_FLASH_ATTR SPIFFS_fstat(spiffs *fs, spiffs_file fh, spiffs_stat *s)
|
|||||||
|
|
||||||
// Checks if there are any cached writes for the object id associated with
|
// Checks if there are any cached writes for the object id associated with
|
||||||
// given filehandle. If so, these writes are flushed.
|
// given filehandle. If so, these writes are flushed.
|
||||||
static s32_t ICACHE_FLASH_ATTR spiffs_fflush_cache(spiffs *fs, spiffs_file fh) {
|
static s32_t spiffs_fflush_cache(spiffs *fs, spiffs_file fh) {
|
||||||
s32_t res = SPIFFS_OK;
|
s32_t res = SPIFFS_OK;
|
||||||
#if SPIFFS_CACHE_WR
|
#if SPIFFS_CACHE_WR
|
||||||
|
|
||||||
@ -552,7 +552,7 @@ static s32_t ICACHE_FLASH_ATTR spiffs_fflush_cache(spiffs *fs, spiffs_file fh) {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32_t ICACHE_FLASH_ATTR SPIFFS_fflush(spiffs *fs, spiffs_file fh) {
|
s32_t SPIFFS_fflush(spiffs *fs, spiffs_file fh) {
|
||||||
SPIFFS_API_CHECK_MOUNT(fs);
|
SPIFFS_API_CHECK_MOUNT(fs);
|
||||||
s32_t res = SPIFFS_OK;
|
s32_t res = SPIFFS_OK;
|
||||||
#if SPIFFS_CACHE_WR
|
#if SPIFFS_CACHE_WR
|
||||||
@ -565,7 +565,7 @@ s32_t ICACHE_FLASH_ATTR SPIFFS_fflush(spiffs *fs, spiffs_file fh) {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR SPIFFS_close(spiffs *fs, spiffs_file fh) {
|
void SPIFFS_close(spiffs *fs, spiffs_file fh) {
|
||||||
if (!SPIFFS_CHECK_MOUNT(fs)) {
|
if (!SPIFFS_CHECK_MOUNT(fs)) {
|
||||||
fs->errno = SPIFFS_ERR_NOT_MOUNTED;
|
fs->errno = SPIFFS_ERR_NOT_MOUNTED;
|
||||||
return;
|
return;
|
||||||
@ -580,7 +580,7 @@ void ICACHE_FLASH_ATTR SPIFFS_close(spiffs *fs, spiffs_file fh) {
|
|||||||
SPIFFS_UNLOCK(fs);
|
SPIFFS_UNLOCK(fs);
|
||||||
}
|
}
|
||||||
|
|
||||||
spiffs_DIR *ICACHE_FLASH_ATTR SPIFFS_opendir(spiffs *fs, const char *name, spiffs_DIR *d) {
|
spiffs_DIR *SPIFFS_opendir(spiffs *fs, const char *name, spiffs_DIR *d) {
|
||||||
if (!SPIFFS_CHECK_MOUNT(fs)) {
|
if (!SPIFFS_CHECK_MOUNT(fs)) {
|
||||||
fs->errno = SPIFFS_ERR_NOT_MOUNTED;
|
fs->errno = SPIFFS_ERR_NOT_MOUNTED;
|
||||||
return 0;
|
return 0;
|
||||||
@ -591,7 +591,7 @@ spiffs_DIR *ICACHE_FLASH_ATTR SPIFFS_opendir(spiffs *fs, const char *name, spiff
|
|||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
static s32_t ICACHE_FLASH_ATTR spiffs_read_dir_v(
|
static s32_t spiffs_read_dir_v(
|
||||||
spiffs *fs,
|
spiffs *fs,
|
||||||
spiffs_obj_id obj_id,
|
spiffs_obj_id obj_id,
|
||||||
spiffs_block_ix bix,
|
spiffs_block_ix bix,
|
||||||
@ -624,7 +624,7 @@ static s32_t ICACHE_FLASH_ATTR spiffs_read_dir_v(
|
|||||||
return SPIFFS_VIS_COUNTINUE;
|
return SPIFFS_VIS_COUNTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct spiffs_dirent *ICACHE_FLASH_ATTR SPIFFS_readdir(spiffs_DIR *d, struct spiffs_dirent *e) {
|
struct spiffs_dirent *SPIFFS_readdir(spiffs_DIR *d, struct spiffs_dirent *e) {
|
||||||
if (!SPIFFS_CHECK_MOUNT(d->fs)) {
|
if (!SPIFFS_CHECK_MOUNT(d->fs)) {
|
||||||
d->fs->errno = SPIFFS_ERR_NOT_MOUNTED;
|
d->fs->errno = SPIFFS_ERR_NOT_MOUNTED;
|
||||||
return 0;
|
return 0;
|
||||||
@ -657,12 +657,12 @@ struct spiffs_dirent *ICACHE_FLASH_ATTR SPIFFS_readdir(spiffs_DIR *d, struct spi
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32_t ICACHE_FLASH_ATTR SPIFFS_closedir(spiffs_DIR *d) {
|
s32_t SPIFFS_closedir(spiffs_DIR *d) {
|
||||||
SPIFFS_API_CHECK_MOUNT(d->fs);
|
SPIFFS_API_CHECK_MOUNT(d->fs);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32_t ICACHE_FLASH_ATTR SPIFFS_check(spiffs *fs) {
|
s32_t SPIFFS_check(spiffs *fs) {
|
||||||
s32_t res;
|
s32_t res;
|
||||||
SPIFFS_API_CHECK_MOUNT(fs);
|
SPIFFS_API_CHECK_MOUNT(fs);
|
||||||
SPIFFS_LOCK(fs);
|
SPIFFS_LOCK(fs);
|
||||||
@ -679,7 +679,7 @@ s32_t ICACHE_FLASH_ATTR SPIFFS_check(spiffs *fs) {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32_t ICACHE_FLASH_ATTR SPIFFS_eof(spiffs *fs, spiffs_file fh) {
|
s32_t SPIFFS_eof(spiffs *fs, spiffs_file fh) {
|
||||||
SPIFFS_API_CHECK_MOUNT(fs);
|
SPIFFS_API_CHECK_MOUNT(fs);
|
||||||
SPIFFS_LOCK(fs);
|
SPIFFS_LOCK(fs);
|
||||||
|
|
||||||
@ -698,7 +698,7 @@ s32_t ICACHE_FLASH_ATTR SPIFFS_eof(spiffs *fs, spiffs_file fh) {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32_t ICACHE_FLASH_ATTR SPIFFS_tell(spiffs *fs, spiffs_file fh) {
|
s32_t SPIFFS_tell(spiffs *fs, spiffs_file fh) {
|
||||||
SPIFFS_API_CHECK_MOUNT(fs);
|
SPIFFS_API_CHECK_MOUNT(fs);
|
||||||
SPIFFS_LOCK(fs);
|
SPIFFS_LOCK(fs);
|
||||||
|
|
||||||
@ -718,7 +718,7 @@ s32_t ICACHE_FLASH_ATTR SPIFFS_tell(spiffs *fs, spiffs_file fh) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if SPIFFS_TEST_VISUALISATION
|
#if SPIFFS_TEST_VISUALISATION
|
||||||
s32_t ICACHE_FLASH_ATTR SPIFFS_vis(spiffs *fs) {
|
s32_t SPIFFS_vis(spiffs *fs) {
|
||||||
s32_t res = SPIFFS_OK;
|
s32_t res = SPIFFS_OK;
|
||||||
SPIFFS_API_CHECK_MOUNT(fs);
|
SPIFFS_API_CHECK_MOUNT(fs);
|
||||||
SPIFFS_LOCK(fs);
|
SPIFFS_LOCK(fs);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include "spiffs.h"
|
#include "spiffs.h"
|
||||||
#include "spiffs_nucleus.h"
|
#include "spiffs_nucleus.h"
|
||||||
|
|
||||||
static s32_t ICACHE_FLASH_ATTR spiffs_page_data_check(spiffs *fs, spiffs_fd *fd, spiffs_page_ix pix, spiffs_span_ix spix) {
|
static s32_t spiffs_page_data_check(spiffs *fs, spiffs_fd *fd, spiffs_page_ix pix, spiffs_span_ix spix) {
|
||||||
s32_t res = SPIFFS_OK;
|
s32_t res = SPIFFS_OK;
|
||||||
if (pix == (spiffs_page_ix)-1) {
|
if (pix == (spiffs_page_ix)-1) {
|
||||||
// referring to page 0xffff...., bad object index
|
// referring to page 0xffff...., bad object index
|
||||||
@ -29,7 +29,7 @@ static s32_t ICACHE_FLASH_ATTR spiffs_page_data_check(spiffs *fs, spiffs_fd *fd,
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static s32_t ICACHE_FLASH_ATTR spiffs_page_index_check(spiffs *fs, spiffs_fd *fd, spiffs_page_ix pix, spiffs_span_ix spix) {
|
static s32_t spiffs_page_index_check(spiffs *fs, spiffs_fd *fd, spiffs_page_ix pix, spiffs_span_ix spix) {
|
||||||
s32_t res = SPIFFS_OK;
|
s32_t res = SPIFFS_OK;
|
||||||
if (pix == (spiffs_page_ix)-1) {
|
if (pix == (spiffs_page_ix)-1) {
|
||||||
// referring to page 0xffff...., bad object index
|
// referring to page 0xffff...., bad object index
|
||||||
@ -59,7 +59,7 @@ static s32_t ICACHE_FLASH_ATTR spiffs_page_index_check(spiffs *fs, spiffs_fd *fd
|
|||||||
|
|
||||||
#if !SPIFFS_CACHE
|
#if !SPIFFS_CACHE
|
||||||
|
|
||||||
s32_t ICACHE_FLASH_ATTR spiffs_phys_rd(
|
s32_t spiffs_phys_rd(
|
||||||
spiffs *fs,
|
spiffs *fs,
|
||||||
u32_t addr,
|
u32_t addr,
|
||||||
u32_t len,
|
u32_t len,
|
||||||
@ -67,7 +67,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_phys_rd(
|
|||||||
return fs->cfg.hal_read_f(addr, len, dst);
|
return fs->cfg.hal_read_f(addr, len, dst);
|
||||||
}
|
}
|
||||||
|
|
||||||
s32_t ICACHE_FLASH_ATTR spiffs_phys_wr(
|
s32_t spiffs_phys_wr(
|
||||||
spiffs *fs,
|
spiffs *fs,
|
||||||
u32_t addr,
|
u32_t addr,
|
||||||
u32_t len,
|
u32_t len,
|
||||||
@ -77,7 +77,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_phys_wr(
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
s32_t ICACHE_FLASH_ATTR spiffs_phys_cpy(
|
s32_t spiffs_phys_cpy(
|
||||||
spiffs *fs,
|
spiffs *fs,
|
||||||
spiffs_file fh,
|
spiffs_file fh,
|
||||||
u32_t dst,
|
u32_t dst,
|
||||||
@ -116,7 +116,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_phys_cpy(
|
|||||||
// @param user_p any pointer, passed to the callback visitor function
|
// @param user_p any pointer, passed to the callback visitor function
|
||||||
// @param block_ix reported block index where match was found
|
// @param block_ix reported block index where match was found
|
||||||
// @param lu_entry reported look up index where match was found
|
// @param lu_entry reported look up index where match was found
|
||||||
s32_t ICACHE_FLASH_ATTR spiffs_obj_lu_find_entry_visitor(
|
s32_t spiffs_obj_lu_find_entry_visitor(
|
||||||
spiffs *fs,
|
spiffs *fs,
|
||||||
spiffs_block_ix starting_block,
|
spiffs_block_ix starting_block,
|
||||||
int starting_lu_entry,
|
int starting_lu_entry,
|
||||||
@ -214,7 +214,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_obj_lu_find_entry_visitor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static s32_t ICACHE_FLASH_ATTR spiffs_obj_lu_scan_v(
|
static s32_t spiffs_obj_lu_scan_v(
|
||||||
spiffs *fs,
|
spiffs *fs,
|
||||||
spiffs_obj_id obj_id,
|
spiffs_obj_id obj_id,
|
||||||
spiffs_block_ix bix,
|
spiffs_block_ix bix,
|
||||||
@ -237,7 +237,7 @@ static s32_t ICACHE_FLASH_ATTR spiffs_obj_lu_scan_v(
|
|||||||
|
|
||||||
// Scans thru all obj lu and counts free, deleted and used pages
|
// Scans thru all obj lu and counts free, deleted and used pages
|
||||||
// Find the maximum block erase count
|
// Find the maximum block erase count
|
||||||
s32_t ICACHE_FLASH_ATTR spiffs_obj_lu_scan(
|
s32_t spiffs_obj_lu_scan(
|
||||||
spiffs *fs) {
|
spiffs *fs) {
|
||||||
s32_t res;
|
s32_t res;
|
||||||
spiffs_block_ix bix;
|
spiffs_block_ix bix;
|
||||||
@ -299,7 +299,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_obj_lu_scan(
|
|||||||
|
|
||||||
// Find free object lookup entry
|
// Find free object lookup entry
|
||||||
// Iterate over object lookup pages in each block until a free object id entry is found
|
// Iterate over object lookup pages in each block until a free object id entry is found
|
||||||
s32_t ICACHE_FLASH_ATTR spiffs_obj_lu_find_free(
|
s32_t spiffs_obj_lu_find_free(
|
||||||
spiffs *fs,
|
spiffs *fs,
|
||||||
spiffs_block_ix starting_block,
|
spiffs_block_ix starting_block,
|
||||||
int starting_lu_entry,
|
int starting_lu_entry,
|
||||||
@ -331,7 +331,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_obj_lu_find_free(
|
|||||||
|
|
||||||
// Find object lookup entry containing given id
|
// Find object lookup entry containing given id
|
||||||
// Iterate over object lookup pages in each block until a given object id entry is found
|
// Iterate over object lookup pages in each block until a given object id entry is found
|
||||||
s32_t ICACHE_FLASH_ATTR spiffs_obj_lu_find_id(
|
s32_t spiffs_obj_lu_find_id(
|
||||||
spiffs *fs,
|
spiffs *fs,
|
||||||
spiffs_block_ix starting_block,
|
spiffs_block_ix starting_block,
|
||||||
int starting_lu_entry,
|
int starting_lu_entry,
|
||||||
@ -347,7 +347,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_obj_lu_find_id(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static s32_t ICACHE_FLASH_ATTR spiffs_obj_lu_find_id_and_span_v(
|
static s32_t spiffs_obj_lu_find_id_and_span_v(
|
||||||
spiffs *fs,
|
spiffs *fs,
|
||||||
spiffs_obj_id obj_id,
|
spiffs_obj_id obj_id,
|
||||||
spiffs_block_ix bix,
|
spiffs_block_ix bix,
|
||||||
@ -373,7 +373,7 @@ static s32_t ICACHE_FLASH_ATTR spiffs_obj_lu_find_id_and_span_v(
|
|||||||
|
|
||||||
// Find object lookup entry containing given id and span index
|
// Find object lookup entry containing given id and span index
|
||||||
// Iterate over object lookup pages in each block until a given object id entry is found
|
// Iterate over object lookup pages in each block until a given object id entry is found
|
||||||
s32_t ICACHE_FLASH_ATTR spiffs_obj_lu_find_id_and_span(
|
s32_t spiffs_obj_lu_find_id_and_span(
|
||||||
spiffs *fs,
|
spiffs *fs,
|
||||||
spiffs_obj_id obj_id,
|
spiffs_obj_id obj_id,
|
||||||
spiffs_span_ix spix,
|
spiffs_span_ix spix,
|
||||||
@ -412,7 +412,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_obj_lu_find_id_and_span(
|
|||||||
|
|
||||||
// Find object lookup entry containing given id and span index in page headers only
|
// Find object lookup entry containing given id and span index in page headers only
|
||||||
// Iterate over object lookup pages in each block until a given object id entry is found
|
// Iterate over object lookup pages in each block until a given object id entry is found
|
||||||
s32_t ICACHE_FLASH_ATTR spiffs_obj_lu_find_id_and_span_by_phdr(
|
s32_t spiffs_obj_lu_find_id_and_span_by_phdr(
|
||||||
spiffs *fs,
|
spiffs *fs,
|
||||||
spiffs_obj_id obj_id,
|
spiffs_obj_id obj_id,
|
||||||
spiffs_span_ix spix,
|
spiffs_span_ix spix,
|
||||||
@ -452,7 +452,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_obj_lu_find_id_and_span_by_phdr(
|
|||||||
// Allocates a free defined page with given obj_id
|
// Allocates a free defined page with given obj_id
|
||||||
// Occupies object lookup entry and page
|
// Occupies object lookup entry and page
|
||||||
// data may be NULL; where only page header is stored, len and page_offs is ignored
|
// data may be NULL; where only page header is stored, len and page_offs is ignored
|
||||||
s32_t ICACHE_FLASH_ATTR spiffs_page_allocate_data(
|
s32_t spiffs_page_allocate_data(
|
||||||
spiffs *fs,
|
spiffs *fs,
|
||||||
spiffs_obj_id obj_id,
|
spiffs_obj_id obj_id,
|
||||||
spiffs_page_header *ph,
|
spiffs_page_header *ph,
|
||||||
@ -509,7 +509,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_page_allocate_data(
|
|||||||
|
|
||||||
// Moves a page from src to a free page and finalizes it. Updates page index. Page data is given in param page.
|
// Moves a page from src to a free page and finalizes it. Updates page index. Page data is given in param page.
|
||||||
// If page data is null, provided header is used for metainfo and page data is physically copied.
|
// If page data is null, provided header is used for metainfo and page data is physically copied.
|
||||||
s32_t ICACHE_FLASH_ATTR spiffs_page_move(
|
s32_t spiffs_page_move(
|
||||||
spiffs *fs,
|
spiffs *fs,
|
||||||
spiffs_file fh,
|
spiffs_file fh,
|
||||||
u8_t *page_data,
|
u8_t *page_data,
|
||||||
@ -571,7 +571,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_page_move(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Deletes a page and removes it from object lookup.
|
// Deletes a page and removes it from object lookup.
|
||||||
s32_t ICACHE_FLASH_ATTR spiffs_page_delete(
|
s32_t spiffs_page_delete(
|
||||||
spiffs *fs,
|
spiffs *fs,
|
||||||
spiffs_page_ix pix) {
|
spiffs_page_ix pix) {
|
||||||
s32_t res;
|
s32_t res;
|
||||||
@ -600,7 +600,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_page_delete(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create an object index header page with empty index and undefined length
|
// Create an object index header page with empty index and undefined length
|
||||||
s32_t ICACHE_FLASH_ATTR spiffs_object_create(
|
s32_t spiffs_object_create(
|
||||||
spiffs *fs,
|
spiffs *fs,
|
||||||
spiffs_obj_id obj_id,
|
spiffs_obj_id obj_id,
|
||||||
u8_t name[SPIFFS_OBJ_NAME_LEN],
|
u8_t name[SPIFFS_OBJ_NAME_LEN],
|
||||||
@ -655,7 +655,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_object_create(
|
|||||||
// new_objix_hdr_data may be null, if so the object index header page is loaded
|
// new_objix_hdr_data may be null, if so the object index header page is loaded
|
||||||
// name may be null, if so name is not changed
|
// name may be null, if so name is not changed
|
||||||
// size may be null, if so size is not changed
|
// size may be null, if so size is not changed
|
||||||
s32_t ICACHE_FLASH_ATTR spiffs_object_update_index_hdr(
|
s32_t spiffs_object_update_index_hdr(
|
||||||
spiffs *fs,
|
spiffs *fs,
|
||||||
spiffs_fd *fd,
|
spiffs_fd *fd,
|
||||||
spiffs_obj_id obj_id,
|
spiffs_obj_id obj_id,
|
||||||
@ -706,7 +706,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_object_update_index_hdr(
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR spiffs_cb_object_event(
|
void spiffs_cb_object_event(
|
||||||
spiffs *fs,
|
spiffs *fs,
|
||||||
spiffs_fd *fd,
|
spiffs_fd *fd,
|
||||||
int ev,
|
int ev,
|
||||||
@ -745,7 +745,7 @@ void ICACHE_FLASH_ATTR spiffs_cb_object_event(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Open object by id
|
// Open object by id
|
||||||
s32_t ICACHE_FLASH_ATTR spiffs_object_open_by_id(
|
s32_t spiffs_object_open_by_id(
|
||||||
spiffs *fs,
|
spiffs *fs,
|
||||||
spiffs_obj_id obj_id,
|
spiffs_obj_id obj_id,
|
||||||
spiffs_fd *fd,
|
spiffs_fd *fd,
|
||||||
@ -763,7 +763,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_object_open_by_id(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Open object by page index
|
// Open object by page index
|
||||||
s32_t ICACHE_FLASH_ATTR spiffs_object_open_by_page(
|
s32_t spiffs_object_open_by_page(
|
||||||
spiffs *fs,
|
spiffs *fs,
|
||||||
spiffs_page_ix pix,
|
spiffs_page_ix pix,
|
||||||
spiffs_fd *fd,
|
spiffs_fd *fd,
|
||||||
@ -801,7 +801,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_object_open_by_page(
|
|||||||
|
|
||||||
// Append to object
|
// Append to object
|
||||||
// keep current object index (header) page in fs->work buffer
|
// keep current object index (header) page in fs->work buffer
|
||||||
s32_t ICACHE_FLASH_ATTR spiffs_object_append(spiffs_fd *fd, u32_t offset, u8_t *data, u32_t len) {
|
s32_t spiffs_object_append(spiffs_fd *fd, u32_t offset, u8_t *data, u32_t len) {
|
||||||
spiffs *fs = fd->fs;
|
spiffs *fs = fd->fs;
|
||||||
s32_t res = SPIFFS_OK;
|
s32_t res = SPIFFS_OK;
|
||||||
u32_t written = 0;
|
u32_t written = 0;
|
||||||
@ -1032,7 +1032,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_object_append(spiffs_fd *fd, u32_t offset, u8_t *
|
|||||||
|
|
||||||
// Modify object
|
// Modify object
|
||||||
// keep current object index (header) page in fs->work buffer
|
// keep current object index (header) page in fs->work buffer
|
||||||
s32_t ICACHE_FLASH_ATTR spiffs_object_modify(spiffs_fd *fd, u32_t offset, u8_t *data, u32_t len) {
|
s32_t spiffs_object_modify(spiffs_fd *fd, u32_t offset, u8_t *data, u32_t len) {
|
||||||
spiffs *fs = fd->fs;
|
spiffs *fs = fd->fs;
|
||||||
s32_t res = SPIFFS_OK;
|
s32_t res = SPIFFS_OK;
|
||||||
u32_t written = 0;
|
u32_t written = 0;
|
||||||
@ -1231,7 +1231,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_object_modify(spiffs_fd *fd, u32_t offset, u8_t *
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static s32_t ICACHE_FLASH_ATTR spiffs_object_find_object_index_header_by_name_v(
|
static s32_t spiffs_object_find_object_index_header_by_name_v(
|
||||||
spiffs *fs,
|
spiffs *fs,
|
||||||
spiffs_obj_id obj_id,
|
spiffs_obj_id obj_id,
|
||||||
spiffs_block_ix bix,
|
spiffs_block_ix bix,
|
||||||
@ -1260,7 +1260,7 @@ static s32_t ICACHE_FLASH_ATTR spiffs_object_find_object_index_header_by_name_v(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Finds object index header page by name
|
// Finds object index header page by name
|
||||||
s32_t ICACHE_FLASH_ATTR spiffs_object_find_object_index_header_by_name(
|
s32_t spiffs_object_find_object_index_header_by_name(
|
||||||
spiffs *fs,
|
spiffs *fs,
|
||||||
u8_t name[SPIFFS_OBJ_NAME_LEN],
|
u8_t name[SPIFFS_OBJ_NAME_LEN],
|
||||||
spiffs_page_ix *pix) {
|
spiffs_page_ix *pix) {
|
||||||
@ -1295,7 +1295,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_object_find_object_index_header_by_name(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Truncates object to new size. If new size is null, object may be removed totally
|
// Truncates object to new size. If new size is null, object may be removed totally
|
||||||
s32_t ICACHE_FLASH_ATTR spiffs_object_truncate(
|
s32_t spiffs_object_truncate(
|
||||||
spiffs_fd *fd,
|
spiffs_fd *fd,
|
||||||
u32_t new_size,
|
u32_t new_size,
|
||||||
u8_t remove) {
|
u8_t remove) {
|
||||||
@ -1502,7 +1502,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_object_truncate(
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32_t ICACHE_FLASH_ATTR spiffs_object_read(
|
s32_t spiffs_object_read(
|
||||||
spiffs_fd *fd,
|
spiffs_fd *fd,
|
||||||
u32_t offset,
|
u32_t offset,
|
||||||
u32_t len,
|
u32_t len,
|
||||||
@ -1586,7 +1586,7 @@ typedef struct {
|
|||||||
u32_t compaction;
|
u32_t compaction;
|
||||||
} spiffs_free_obj_id_state;
|
} spiffs_free_obj_id_state;
|
||||||
|
|
||||||
static s32_t ICACHE_FLASH_ATTR spiffs_obj_lu_find_free_obj_id_bitmap_v(spiffs *fs, spiffs_obj_id id, spiffs_block_ix bix, int ix_entry,
|
static s32_t spiffs_obj_lu_find_free_obj_id_bitmap_v(spiffs *fs, spiffs_obj_id id, spiffs_block_ix bix, int ix_entry,
|
||||||
u32_t user_data, void *user_p) {
|
u32_t user_data, void *user_p) {
|
||||||
if (id != SPIFFS_OBJ_ID_FREE && id != SPIFFS_OBJ_ID_DELETED) {
|
if (id != SPIFFS_OBJ_ID_FREE && id != SPIFFS_OBJ_ID_DELETED) {
|
||||||
spiffs_obj_id min_obj_id = user_data;
|
spiffs_obj_id min_obj_id = user_data;
|
||||||
@ -1600,7 +1600,7 @@ static s32_t ICACHE_FLASH_ATTR spiffs_obj_lu_find_free_obj_id_bitmap_v(spiffs *f
|
|||||||
return SPIFFS_VIS_COUNTINUE;
|
return SPIFFS_VIS_COUNTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static s32_t ICACHE_FLASH_ATTR spiffs_obj_lu_find_free_obj_id_compact_v(spiffs *fs, spiffs_obj_id id, spiffs_block_ix bix, int ix_entry,
|
static s32_t spiffs_obj_lu_find_free_obj_id_compact_v(spiffs *fs, spiffs_obj_id id, spiffs_block_ix bix, int ix_entry,
|
||||||
u32_t user_data, void *user_p) {
|
u32_t user_data, void *user_p) {
|
||||||
if (id != SPIFFS_OBJ_ID_FREE && id != SPIFFS_OBJ_ID_DELETED && (id & SPIFFS_OBJ_ID_IX_FLAG)) {
|
if (id != SPIFFS_OBJ_ID_FREE && id != SPIFFS_OBJ_ID_DELETED && (id & SPIFFS_OBJ_ID_IX_FLAG)) {
|
||||||
s32_t res;
|
s32_t res;
|
||||||
@ -1629,7 +1629,7 @@ static s32_t ICACHE_FLASH_ATTR spiffs_obj_lu_find_free_obj_id_compact_v(spiffs *
|
|||||||
// object ids cannot fit into a work buffer, these are grouped. When a group containing free
|
// object ids cannot fit into a work buffer, these are grouped. When a group containing free
|
||||||
// object ids is found, the object lu is again scanned for object ids within group and bitmasked.
|
// object ids is found, the object lu is again scanned for object ids within group and bitmasked.
|
||||||
// Finally, the bitmasked is searched for a free id
|
// Finally, the bitmasked is searched for a free id
|
||||||
s32_t ICACHE_FLASH_ATTR spiffs_obj_lu_find_free_obj_id(spiffs *fs, spiffs_obj_id *obj_id) {
|
s32_t spiffs_obj_lu_find_free_obj_id(spiffs *fs, spiffs_obj_id *obj_id) {
|
||||||
s32_t res = SPIFFS_OK;
|
s32_t res = SPIFFS_OK;
|
||||||
u32_t max_objects = (SPIFFS_CFG_PHYS_SZ(fs) / (u32_t)SPIFFS_CFG_LOG_PAGE_SZ(fs)) / 2;
|
u32_t max_objects = (SPIFFS_CFG_PHYS_SZ(fs) / (u32_t)SPIFFS_CFG_LOG_PAGE_SZ(fs)) / 2;
|
||||||
spiffs_free_obj_id_state state;
|
spiffs_free_obj_id_state state;
|
||||||
@ -1720,7 +1720,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_obj_lu_find_free_obj_id(spiffs *fs, spiffs_obj_id
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32_t ICACHE_FLASH_ATTR spiffs_fd_find_new(spiffs *fs, spiffs_fd **fd) {
|
s32_t spiffs_fd_find_new(spiffs *fs, spiffs_fd **fd) {
|
||||||
int i;
|
int i;
|
||||||
spiffs_fd *fds = (spiffs_fd *)fs->fd_space;
|
spiffs_fd *fds = (spiffs_fd *)fs->fd_space;
|
||||||
for (i = 0; i < fs->fd_count; i++) {
|
for (i = 0; i < fs->fd_count; i++) {
|
||||||
@ -1734,7 +1734,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_fd_find_new(spiffs *fs, spiffs_fd **fd) {
|
|||||||
return SPIFFS_ERR_OUT_OF_FILE_DESCS;
|
return SPIFFS_ERR_OUT_OF_FILE_DESCS;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32_t ICACHE_FLASH_ATTR spiffs_fd_return(spiffs *fs, spiffs_file f) {
|
s32_t spiffs_fd_return(spiffs *fs, spiffs_file f) {
|
||||||
if (f <= 0 || f > fs->fd_count) {
|
if (f <= 0 || f > fs->fd_count) {
|
||||||
return SPIFFS_ERR_BAD_DESCRIPTOR;
|
return SPIFFS_ERR_BAD_DESCRIPTOR;
|
||||||
}
|
}
|
||||||
@ -1747,7 +1747,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_fd_return(spiffs *fs, spiffs_file f) {
|
|||||||
return SPIFFS_OK;
|
return SPIFFS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32_t ICACHE_FLASH_ATTR spiffs_fd_get(spiffs *fs, spiffs_file f, spiffs_fd **fd) {
|
s32_t spiffs_fd_get(spiffs *fs, spiffs_file f, spiffs_fd **fd) {
|
||||||
if (f <= 0 || f > fs->fd_count) {
|
if (f <= 0 || f > fs->fd_count) {
|
||||||
return SPIFFS_ERR_BAD_DESCRIPTOR;
|
return SPIFFS_ERR_BAD_DESCRIPTOR;
|
||||||
}
|
}
|
||||||
|
@ -82,6 +82,12 @@ void user_init(void)
|
|||||||
NODE_DBG("Can not init platform for modules.\n");
|
NODE_DBG("Can not init platform for modules.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!flash_init_data_written()){
|
||||||
|
NODE_ERR("Restore init data.\n");
|
||||||
|
flash_init_data_default();
|
||||||
|
}
|
||||||
|
|
||||||
#if defined( BUILD_WOFS )
|
#if defined( BUILD_WOFS )
|
||||||
romfs_init();
|
romfs_init();
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ static int romfs_num_fd;
|
|||||||
// Length of the 'file size' field for both ROMFS/WOFS
|
// Length of the 'file size' field for both ROMFS/WOFS
|
||||||
#define ROMFS_SIZE_LEN 4
|
#define ROMFS_SIZE_LEN 4
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR romfs_find_empty_fd(void)
|
static int romfs_find_empty_fd(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ static int ICACHE_FLASH_ATTR romfs_find_empty_fd(void)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR romfs_close_fd( int fd )
|
static void romfs_close_fd( int fd )
|
||||||
{
|
{
|
||||||
if(fd<0 || fd>=TOTAL_MAX_FDS)
|
if(fd<0 || fd>=TOTAL_MAX_FDS)
|
||||||
return;
|
return;
|
||||||
@ -49,7 +49,7 @@ static void ICACHE_FLASH_ATTR romfs_close_fd( int fd )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Helper function: read a byte from the FS
|
// Helper function: read a byte from the FS
|
||||||
static uint8_t ICACHE_FLASH_ATTR romfsh_read8( uint32_t addr, const FSDATA *pfs )
|
static uint8_t romfsh_read8( uint32_t addr, const FSDATA *pfs )
|
||||||
{
|
{
|
||||||
uint8_t temp;
|
uint8_t temp;
|
||||||
if( pfs->flags & ROMFS_FS_FLAG_DIRECT )
|
if( pfs->flags & ROMFS_FS_FLAG_DIRECT )
|
||||||
@ -59,13 +59,13 @@ static uint8_t ICACHE_FLASH_ATTR romfsh_read8( uint32_t addr, const FSDATA *pfs
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Helper function: return 1 if PFS reffers to a WOFS, 0 otherwise
|
// Helper function: return 1 if PFS reffers to a WOFS, 0 otherwise
|
||||||
static int ICACHE_FLASH_ATTR romfsh_is_wofs( const FSDATA* pfs )
|
static int romfsh_is_wofs( const FSDATA* pfs )
|
||||||
{
|
{
|
||||||
return ( pfs->flags & ROMFS_FS_FLAG_WO ) != 0;
|
return ( pfs->flags & ROMFS_FS_FLAG_WO ) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find the next file, returning FS_FILE_OK or FS_FILE_NOT_FOUND if there no file left.
|
// Find the next file, returning FS_FILE_OK or FS_FILE_NOT_FOUND if there no file left.
|
||||||
static uint8_t ICACHE_FLASH_ATTR romfs_next_file( uint32_t *start, char* fname, size_t len, size_t *act_len, FSDATA *pfs )
|
static uint8_t romfs_next_file( uint32_t *start, char* fname, size_t len, size_t *act_len, FSDATA *pfs )
|
||||||
{
|
{
|
||||||
uint32_t i, j, n;
|
uint32_t i, j, n;
|
||||||
uint32_t fsize;
|
uint32_t fsize;
|
||||||
@ -120,7 +120,7 @@ static uint8_t ICACHE_FLASH_ATTR romfs_next_file( uint32_t *start, char* fname,
|
|||||||
|
|
||||||
// Open the given file, returning one of FS_FILE_NOT_FOUND, FS_FILE_ALREADY_OPENED
|
// Open the given file, returning one of FS_FILE_NOT_FOUND, FS_FILE_ALREADY_OPENED
|
||||||
// or FS_FILE_OK
|
// or FS_FILE_OK
|
||||||
static uint8_t ICACHE_FLASH_ATTR romfs_open_file( const char* fname, FD* pfd, FSDATA *pfs, uint32_t *plast, uint32_t *pnameaddr )
|
static uint8_t romfs_open_file( const char* fname, FD* pfd, FSDATA *pfs, uint32_t *plast, uint32_t *pnameaddr )
|
||||||
{
|
{
|
||||||
uint32_t i, j, n;
|
uint32_t i, j, n;
|
||||||
char fsname[ MAX_FNAME_LENGTH + 1 ];
|
char fsname[ MAX_FNAME_LENGTH + 1 ];
|
||||||
@ -184,7 +184,7 @@ static uint8_t ICACHE_FLASH_ATTR romfs_open_file( const char* fname, FD* pfd, FS
|
|||||||
return FS_FILE_NOT_FOUND;
|
return FS_FILE_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR romfs_open( const char *path, int flags, int mode, void *pdata )
|
static int romfs_open( const char *path, int flags, int mode, void *pdata )
|
||||||
{
|
{
|
||||||
FD tempfs;
|
FD tempfs;
|
||||||
int i;
|
int i;
|
||||||
@ -295,7 +295,7 @@ static int ICACHE_FLASH_ATTR romfs_open( const char *path, int flags, int mode,
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ICACHE_FLASH_ATTR romfs_close( int fd, void *pdata )
|
static int romfs_close( int fd, void *pdata )
|
||||||
{
|
{
|
||||||
if(fd<0 || fd>=TOTAL_MAX_FDS)
|
if(fd<0 || fd>=TOTAL_MAX_FDS)
|
||||||
return 0;
|
return 0;
|
||||||
@ -320,7 +320,7 @@ static int ICACHE_FLASH_ATTR romfs_close( int fd, void *pdata )
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static _ssize_t ICACHE_FLASH_ATTR romfs_write( int fd, const void* ptr, size_t len, void *pdata )
|
static _ssize_t romfs_write( int fd, const void* ptr, size_t len, void *pdata )
|
||||||
{
|
{
|
||||||
if(fd<0 || fd>=TOTAL_MAX_FDS)
|
if(fd<0 || fd>=TOTAL_MAX_FDS)
|
||||||
return -1;
|
return -1;
|
||||||
@ -350,7 +350,7 @@ static _ssize_t ICACHE_FLASH_ATTR romfs_write( int fd, const void* ptr, size_t l
|
|||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
static _ssize_t ICACHE_FLASH_ATTR romfs_read( int fd, void* ptr, size_t len, void *pdata )
|
static _ssize_t romfs_read( int fd, void* ptr, size_t len, void *pdata )
|
||||||
{
|
{
|
||||||
if(fd<0 || fd>=TOTAL_MAX_FDS)
|
if(fd<0 || fd>=TOTAL_MAX_FDS)
|
||||||
return -1;
|
return -1;
|
||||||
@ -374,7 +374,7 @@ static _ssize_t ICACHE_FLASH_ATTR romfs_read( int fd, void* ptr, size_t len, voi
|
|||||||
}
|
}
|
||||||
|
|
||||||
// lseek
|
// lseek
|
||||||
static int ICACHE_FLASH_ATTR romfs_lseek( int fd, int off, int whence, void *pdata )
|
static int romfs_lseek( int fd, int off, int whence, void *pdata )
|
||||||
{
|
{
|
||||||
if(fd<0 || fd>=TOTAL_MAX_FDS)
|
if(fd<0 || fd>=TOTAL_MAX_FDS)
|
||||||
return -1;
|
return -1;
|
||||||
@ -409,7 +409,7 @@ static int ICACHE_FLASH_ATTR romfs_lseek( int fd, int off, int whence, void *pda
|
|||||||
// WOFS functions and instance descriptor for real hardware
|
// WOFS functions and instance descriptor for real hardware
|
||||||
|
|
||||||
#if defined( BUILD_WOFS )
|
#if defined( BUILD_WOFS )
|
||||||
static uint32_t ICACHE_FLASH_ATTR sim_wofs_write( const void *from, uint32_t toaddr, uint32_t size, const void *pdata )
|
static uint32_t sim_wofs_write( const void *from, uint32_t toaddr, uint32_t size, const void *pdata )
|
||||||
{
|
{
|
||||||
const FSDATA *pfsdata = ( const FSDATA* )pdata;
|
const FSDATA *pfsdata = ( const FSDATA* )pdata;
|
||||||
if(toaddr>=INTERNAL_FLASH_SIZE)
|
if(toaddr>=INTERNAL_FLASH_SIZE)
|
||||||
@ -421,7 +421,7 @@ static uint32_t ICACHE_FLASH_ATTR sim_wofs_write( const void *from, uint32_t toa
|
|||||||
return platform_flash_write( from, toaddr, size );
|
return platform_flash_write( from, toaddr, size );
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t ICACHE_FLASH_ATTR sim_wofs_read( void *to, uint32_t fromaddr, uint32_t size, const void *pdata )
|
static uint32_t sim_wofs_read( void *to, uint32_t fromaddr, uint32_t size, const void *pdata )
|
||||||
{
|
{
|
||||||
const FSDATA *pfsdata = ( const FSDATA* )pdata;
|
const FSDATA *pfsdata = ( const FSDATA* )pdata;
|
||||||
if(fromaddr>=INTERNAL_FLASH_SIZE)
|
if(fromaddr>=INTERNAL_FLASH_SIZE)
|
||||||
@ -445,7 +445,7 @@ static FSDATA wofs_fsdata =
|
|||||||
|
|
||||||
// WOFS formatting function
|
// WOFS formatting function
|
||||||
// Returns 1 if OK, 0 for error
|
// Returns 1 if OK, 0 for error
|
||||||
int ICACHE_FLASH_ATTR wofs_format( void )
|
int wofs_format( void )
|
||||||
{
|
{
|
||||||
uint32_t sect_first, sect_last;
|
uint32_t sect_first, sect_last;
|
||||||
FD tempfd;
|
FD tempfd;
|
||||||
@ -460,27 +460,27 @@ int ICACHE_FLASH_ATTR wofs_format( void )
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ICACHE_FLASH_ATTR wofs_open(const char *_name, int flags){
|
int wofs_open(const char *_name, int flags){
|
||||||
return romfs_open( _name, flags, 0, &wofs_fsdata );
|
return romfs_open( _name, flags, 0, &wofs_fsdata );
|
||||||
}
|
}
|
||||||
|
|
||||||
int ICACHE_FLASH_ATTR wofs_close( int fd ){
|
int wofs_close( int fd ){
|
||||||
return romfs_close( fd, &wofs_fsdata );
|
return romfs_close( fd, &wofs_fsdata );
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t ICACHE_FLASH_ATTR wofs_write( int fd, const void* ptr, size_t len ){
|
size_t wofs_write( int fd, const void* ptr, size_t len ){
|
||||||
return romfs_write( fd, ptr, len, &wofs_fsdata );
|
return romfs_write( fd, ptr, len, &wofs_fsdata );
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t ICACHE_FLASH_ATTR wofs_read( int fd, void* ptr, size_t len){
|
size_t wofs_read( int fd, void* ptr, size_t len){
|
||||||
return romfs_read( fd, ptr, len, &wofs_fsdata );
|
return romfs_read( fd, ptr, len, &wofs_fsdata );
|
||||||
}
|
}
|
||||||
|
|
||||||
int ICACHE_FLASH_ATTR wofs_lseek( int fd, int off, int whence ){
|
int wofs_lseek( int fd, int off, int whence ){
|
||||||
return romfs_lseek( fd, off, whence, &wofs_fsdata );
|
return romfs_lseek( fd, off, whence, &wofs_fsdata );
|
||||||
}
|
}
|
||||||
|
|
||||||
int ICACHE_FLASH_ATTR wofs_eof( int fd ){
|
int wofs_eof( int fd ){
|
||||||
if(fd<0 || fd>=TOTAL_MAX_FDS)
|
if(fd<0 || fd>=TOTAL_MAX_FDS)
|
||||||
return -1;
|
return -1;
|
||||||
FD* pfd = fd_table + fd;
|
FD* pfd = fd_table + fd;
|
||||||
@ -488,7 +488,7 @@ int ICACHE_FLASH_ATTR wofs_eof( int fd ){
|
|||||||
return pfd->offset == pfd->size;
|
return pfd->offset == pfd->size;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ICACHE_FLASH_ATTR wofs_getc( int fd ){
|
int wofs_getc( int fd ){
|
||||||
char c = EOF;
|
char c = EOF;
|
||||||
if(!wofs_eof(fd)){
|
if(!wofs_eof(fd)){
|
||||||
romfs_read( fd, &c, 1, &wofs_fsdata );
|
romfs_read( fd, &c, 1, &wofs_fsdata );
|
||||||
@ -497,19 +497,19 @@ int ICACHE_FLASH_ATTR wofs_getc( int fd ){
|
|||||||
return (int)c;
|
return (int)c;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ICACHE_FLASH_ATTR wofs_ungetc( int c, int fd ){
|
int wofs_ungetc( int c, int fd ){
|
||||||
return romfs_lseek( fd, -1, SEEK_CUR, &wofs_fsdata );
|
return romfs_lseek( fd, -1, SEEK_CUR, &wofs_fsdata );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find the next file, returning FS_FILE_OK or FS_FILE_NOT_FOUND if there no file left.
|
// Find the next file, returning FS_FILE_OK or FS_FILE_NOT_FOUND if there no file left.
|
||||||
uint8_t ICACHE_FLASH_ATTR wofs_next( uint32_t *start, char* fname, size_t len, size_t *act_len ){
|
uint8_t wofs_next( uint32_t *start, char* fname, size_t len, size_t *act_len ){
|
||||||
return romfs_next_file( start, fname, len, act_len, &wofs_fsdata );
|
return romfs_next_file( start, fname, len, act_len, &wofs_fsdata );
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // #ifdef BUILD_WOFS
|
#endif // #ifdef BUILD_WOFS
|
||||||
|
|
||||||
// Initialize both ROMFS and WOFS as needed
|
// Initialize both ROMFS and WOFS as needed
|
||||||
int ICACHE_FLASH_ATTR romfs_init( void )
|
int romfs_init( void )
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
@ -529,13 +529,13 @@ int ICACHE_FLASH_ATTR romfs_init( void )
|
|||||||
|
|
||||||
#else // #if defined( BUILD_ROMFS ) || defined( BUILD_WOFS )
|
#else // #if defined( BUILD_ROMFS ) || defined( BUILD_WOFS )
|
||||||
|
|
||||||
int ICACHE_FLASH_ATTR romfs_init( void )
|
int romfs_init( void )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // #if defined( BUILD_ROMFS ) || defined( BUILD_WOFS )
|
#endif // #if defined( BUILD_ROMFS ) || defined( BUILD_WOFS )
|
||||||
|
|
||||||
int ICACHE_FLASH_ATTR test_romfs()
|
int test_romfs()
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
int i, size;
|
int i, size;
|
||||||
|
@ -24,6 +24,8 @@ typedef struct{
|
|||||||
#define SPI_FLASH_SEC_SIZE 4096
|
#define SPI_FLASH_SEC_SIZE 4096
|
||||||
|
|
||||||
uint32 spi_flash_get_id(void);
|
uint32 spi_flash_get_id(void);
|
||||||
|
SpiFlashOpResult spi_flash_read_status(uint32 *status);
|
||||||
|
SpiFlashOpResult spi_flash_write_status(uint32 status_value);
|
||||||
SpiFlashOpResult spi_flash_erase_sector(uint16 sec);
|
SpiFlashOpResult spi_flash_erase_sector(uint16 sec);
|
||||||
SpiFlashOpResult spi_flash_write(uint32 des_addr, uint32 *src_addr, uint32 size);
|
SpiFlashOpResult spi_flash_write(uint32 des_addr, uint32 *src_addr, uint32 size);
|
||||||
SpiFlashOpResult spi_flash_read(uint32 src_addr, uint32 *des_addr, uint32 size);
|
SpiFlashOpResult spi_flash_read(uint32 src_addr, uint32 *des_addr, uint32 size);
|
||||||
|
@ -151,9 +151,9 @@ enum {
|
|||||||
STATION_GOT_IP
|
STATION_GOT_IP
|
||||||
};
|
};
|
||||||
|
|
||||||
enum dhcp_status{
|
enum dhcp_status {
|
||||||
DHCP_ENABLE,
|
DHCP_STOPPED,
|
||||||
DHCP_DISABLE
|
DHCP_STARTED
|
||||||
};
|
};
|
||||||
|
|
||||||
uint8 wifi_station_get_connect_status(void);
|
uint8 wifi_station_get_connect_status(void);
|
||||||
@ -201,7 +201,7 @@ struct dhcps_lease {
|
|||||||
|
|
||||||
struct station_info * wifi_softap_get_station_info(void);
|
struct station_info * wifi_softap_get_station_info(void);
|
||||||
void wifi_softap_free_station_info(void);
|
void wifi_softap_free_station_info(void);
|
||||||
bool wifi_station_get_ap_info(struct station_config config[]);
|
uint8 wifi_station_get_ap_info(struct station_config config[]);
|
||||||
|
|
||||||
bool wifi_softap_dhcps_start(void);
|
bool wifi_softap_dhcps_start(void);
|
||||||
bool wifi_softap_dhcps_stop(void);
|
bool wifi_softap_dhcps_stop(void);
|
||||||
|
@ -66,6 +66,41 @@ SECTIONS
|
|||||||
_dport0_data_end = ABSOLUTE(.);
|
_dport0_data_end = ABSOLUTE(.);
|
||||||
} >dport0_0_seg :dport0_0_phdr
|
} >dport0_0_seg :dport0_0_phdr
|
||||||
|
|
||||||
|
.irom0.text : ALIGN(4)
|
||||||
|
{
|
||||||
|
_irom0_text_start = ABSOLUTE(.);
|
||||||
|
*(.irom0.literal .irom.literal .irom.text.literal .irom0.text .irom.text)
|
||||||
|
*(.literal.* .text.*)
|
||||||
|
*(.rodata.text)
|
||||||
|
_irom0_text_end = ABSOLUTE(.);
|
||||||
|
_flash_used_end = ABSOLUTE(.);
|
||||||
|
} >irom0_0_seg :irom0_0_phdr
|
||||||
|
|
||||||
|
.text : ALIGN(4)
|
||||||
|
{
|
||||||
|
_stext = .;
|
||||||
|
_text_start = ABSOLUTE(.);
|
||||||
|
*(.entry.text)
|
||||||
|
*(.init.literal)
|
||||||
|
*(.init)
|
||||||
|
/* *(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*) */
|
||||||
|
*(.literal .text .iram0.text .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
|
||||||
|
*(.fini.literal)
|
||||||
|
*(.fini)
|
||||||
|
*(.gnu.version)
|
||||||
|
_text_end = ABSOLUTE(.);
|
||||||
|
_etext = .;
|
||||||
|
} >iram1_0_seg :iram1_0_phdr
|
||||||
|
|
||||||
|
.lit4 : ALIGN(4)
|
||||||
|
{
|
||||||
|
_lit4_start = ABSOLUTE(.);
|
||||||
|
*(*.lit4)
|
||||||
|
*(.lit4.*)
|
||||||
|
*(.gnu.linkonce.lit4.*)
|
||||||
|
_lit4_end = ABSOLUTE(.);
|
||||||
|
} >iram1_0_seg :iram1_0_phdr
|
||||||
|
|
||||||
.data : ALIGN(4)
|
.data : ALIGN(4)
|
||||||
{
|
{
|
||||||
_data_start = ABSOLUTE(.);
|
_data_start = ABSOLUTE(.);
|
||||||
@ -145,40 +180,6 @@ SECTIONS
|
|||||||
} >dram0_0_seg :dram0_0_bss_phdr
|
} >dram0_0_seg :dram0_0_bss_phdr
|
||||||
/* __stack = 0x3ffc8000; */
|
/* __stack = 0x3ffc8000; */
|
||||||
|
|
||||||
.text : ALIGN(4)
|
|
||||||
{
|
|
||||||
_stext = .;
|
|
||||||
_text_start = ABSOLUTE(.);
|
|
||||||
*(.entry.text)
|
|
||||||
*(.init.literal)
|
|
||||||
*(.init)
|
|
||||||
*(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
|
|
||||||
*(.fini.literal)
|
|
||||||
*(.fini)
|
|
||||||
*(.gnu.version)
|
|
||||||
_text_end = ABSOLUTE(.);
|
|
||||||
_etext = .;
|
|
||||||
} >iram1_0_seg :iram1_0_phdr
|
|
||||||
|
|
||||||
.lit4 : ALIGN(4)
|
|
||||||
{
|
|
||||||
_lit4_start = ABSOLUTE(.);
|
|
||||||
*(*.lit4)
|
|
||||||
*(.lit4.*)
|
|
||||||
*(.gnu.linkonce.lit4.*)
|
|
||||||
_lit4_end = ABSOLUTE(.);
|
|
||||||
} >iram1_0_seg :iram1_0_phdr
|
|
||||||
|
|
||||||
.irom0.text : ALIGN(4)
|
|
||||||
{
|
|
||||||
_crypt_fixed_start = ABSOLUTE(.);
|
|
||||||
*(.crypt_fixed)
|
|
||||||
_crypt_fixed_end = ABSOLUTE(.);
|
|
||||||
_irom0_text_start = ABSOLUTE(.);
|
|
||||||
*(.irom0.literal .irom.literal .irom.text.literal .irom0.text .irom.text)
|
|
||||||
_irom0_text_end = ABSOLUTE(.);
|
|
||||||
_flash_used_end = ABSOLUTE(.);
|
|
||||||
} >irom0_0_seg :irom0_0_phdr
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get ROM code address */
|
/* get ROM code address */
|
||||||
|
@ -16,6 +16,8 @@ PROVIDE ( SHA1Final = 0x4000b648 );
|
|||||||
PROVIDE ( SHA1Init = 0x4000b584 );
|
PROVIDE ( SHA1Init = 0x4000b584 );
|
||||||
PROVIDE ( SHA1Transform = 0x4000a364 );
|
PROVIDE ( SHA1Transform = 0x4000a364 );
|
||||||
PROVIDE ( SHA1Update = 0x4000b5a8 );
|
PROVIDE ( SHA1Update = 0x4000b5a8 );
|
||||||
|
PROVIDE ( SPI_read_status = 0x400043c8 );
|
||||||
|
PROVIDE ( SPI_write_status = 0x40004400 );
|
||||||
PROVIDE ( Wait_SPI_Idle = 0x4000448c );
|
PROVIDE ( Wait_SPI_Idle = 0x4000448c );
|
||||||
PROVIDE ( SPIEraseArea = 0x40004b44 );
|
PROVIDE ( SPIEraseArea = 0x40004b44 );
|
||||||
PROVIDE ( SPIEraseBlock = 0x400049b4 );
|
PROVIDE ( SPIEraseBlock = 0x400049b4 );
|
||||||
|
BIN
lib/libjson.a
BIN
lib/libjson.a
Binary file not shown.
BIN
lib/liblwip.a
BIN
lib/liblwip.a
Binary file not shown.
BIN
lib/libmain.a
BIN
lib/libmain.a
Binary file not shown.
Binary file not shown.
BIN
lib/libpp.a
BIN
lib/libpp.a
Binary file not shown.
BIN
lib/libssl.a
BIN
lib/libssl.a
Binary file not shown.
BIN
lib/libupgrade.a
BIN
lib/libupgrade.a
Binary file not shown.
BIN
lib/libwpa.a
BIN
lib/libwpa.a
Binary file not shown.
BIN
pre_build/0.9.5/nodemcu_20150106.bin
Normal file
BIN
pre_build/0.9.5/nodemcu_20150106.bin
Normal file
Binary file not shown.
BIN
pre_build/0.9.5/nodemcu_latest.bin
Normal file
BIN
pre_build/0.9.5/nodemcu_latest.bin
Normal file
Binary file not shown.
Binary file not shown.
BIN
pre_build/latest/nodemcu_latest.bin
Normal file
BIN
pre_build/latest/nodemcu_latest.bin
Normal file
Binary file not shown.
@ -18,7 +18,10 @@ elf_file = sys.argv[1]
|
|||||||
ver = sys.argv[2]
|
ver = sys.argv[2]
|
||||||
#print elf_file
|
#print elf_file
|
||||||
|
|
||||||
cmd = 'xt-nm -g ' + elf_file + ' > eagle.app.sym'
|
if os.getenv('XTENSA_CORE')=='lx106':
|
||||||
|
cmd = 'xt-nm -g ' + elf_file + ' > eagle.app.sym'
|
||||||
|
else:
|
||||||
|
cmd = 'xtensa-lx106-elf-nm -g ' + elf_file + ' > eagle.app.sym'
|
||||||
#print cmd
|
#print cmd
|
||||||
os.system(cmd)
|
os.system(cmd)
|
||||||
|
|
||||||
@ -60,7 +63,10 @@ for line in lines:
|
|||||||
rodata_start_addr = m.group(1)
|
rodata_start_addr = m.group(1)
|
||||||
print rodata_start_addr
|
print rodata_start_addr
|
||||||
|
|
||||||
cmd = 'genflashbin%s eagle.app.%s.text.bin '%(ver, ver)+entry_addr+' eagle.app.%s.data.bin '%(ver)+ data_start_addr+' eagle.app.%s.rodata.bin '%(ver)+rodata_start_addr
|
if os.getenv('XTENSA_CORE')=='lx106':
|
||||||
|
cmd = 'genflashbin%s eagle.app.%s.text.bin '%(ver, ver)+entry_addr+' eagle.app.%s.data.bin '%(ver)+ data_start_addr+' eagle.app.%s.rodata.bin '%(ver)+rodata_start_addr
|
||||||
|
else:
|
||||||
|
cmd = 'genflashbin%s eagle.app.%s.text.bin '%(ver, ver)+entry_addr+' eagle.app.%s.data.bin '%(ver)+ data_start_addr+' eagle.app.%s.rodata.bin '%(ver)+rodata_start_addr
|
||||||
|
|
||||||
print cmd
|
print cmd
|
||||||
os.system(cmd)
|
os.system(cmd)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user