All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH v2] package/lua: add options for coercion between number and string
@ 2023-01-18 15:46 Francois Perrad
  2023-01-18 21:23 ` Yann E. MORIN
  0 siblings, 1 reply; 2+ messages in thread
From: Francois Perrad @ 2023-01-18 15:46 UTC (permalink / raw)
  To: buildroot

the default behavior of Lua 5.3/5.4 interperter
(and the only way with Lua 5.1) is the automatic coercion.

this default behavior could change in future version (ie. Lua 5.5).

disabling automatic coercion increases the performance of the interpreter.

currently, using automatic coercion is not a good/recommended practice,
but there are no way (expect testing) to say if a Lua module relies on it.

Signed-off-by: Francois Perrad <francois.perrad@gadz.org>
---
 package/lua/Config.in | 14 ++++++++++++++
 package/lua/lua.mk    |  8 ++++++++
 2 files changed, 22 insertions(+)

diff --git a/package/lua/Config.in b/package/lua/Config.in
index 309dd6eec..ac30cfdde 100644
--- a/package/lua/Config.in
+++ b/package/lua/Config.in
@@ -41,6 +41,20 @@ config BR2_PACKAGE_LUA_32BITS
 	  default 64 bit type. This option is particularly attractive
 	  for small machines and embedded systems.
 
+config BR2_PACKAGE_LUA_CVT_N2S
+	bool "automatic coercion from number to string"
+	default y
+	help
+	  If unsure, say y, this is the default behavior of the Lua
+	  interpreter. See LUA_NOCVTN2S in luaconf.h
+
+config BR2_PACKAGE_LUA_CVT_S2N
+	bool "automatic coercion from string to number"
+	default y
+	help
+	  If unsure, say y, this is the default behavior of the Lua
+	  interpreter. See LUA_NOCVTN2S in luaconf.h
+
 endif
 
 choice
diff --git a/package/lua/lua.mk b/package/lua/lua.mk
index 01b554eb6..16086e7bf 100644
--- a/package/lua/lua.mk
+++ b/package/lua/lua.mk
@@ -31,6 +31,14 @@ else ifeq ($(BR2_PACKAGE_LUA_5_3),y)
 LUA_CFLAGS += -DLUA_COMPAT_5_2
 endif
 
+ifeq ($(BR2_PACKAGE_LUA_CVT_N2S),)
+LUA_CFLAGS += -DLUA_NOCVTN2S
+endif
+
+ifeq ($(BR2_PACKAGE_LUA_CVT_S2N),)
+LUA_CFLAGS += -DLUA_NOCVTS2N
+endif
+
 ifeq ($(BR2_STATIC_LIBS),y)
 LUA_BUILDMODE = static
 else
-- 
2.37.2

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-01-18 21:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-18 15:46 [Buildroot] [PATCH v2] package/lua: add options for coercion between number and string Francois Perrad
2023-01-18 21:23 ` Yann E. MORIN

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.