[Tarantool-patches] [PATCH 3/4] lua: split serializer functions into sections

Alexander Turenko alexander.turenko at tarantool.org
Wed Jun 23 22:12:41 MSK 2021


And added a general comment about the compilation unit. Everything is to
simplify reading.

Part of #3228
---
 src/lua/serializer.c |  8 ++++++++
 src/lua/serializer.h | 23 +++++++++++++++++++++++
 2 files changed, 31 insertions(+)

diff --git a/src/lua/serializer.c b/src/lua/serializer.c
index 38b7dd8b9..8db6746a3 100644
--- a/src/lua/serializer.c
+++ b/src/lua/serializer.c
@@ -51,6 +51,8 @@ int luaL_array_metatable_ref = LUA_REFNIL;
 extern uint32_t CTID_UUID;
 extern uint32_t CTID_DECIMAL;
 
+/* {{{ luaL_serializer manipulations */
+
 #define OPTION(type, name, defvalue) { #name, \
 	offsetof(struct luaL_serializer, name), type, defvalue}
 /**
@@ -238,6 +240,10 @@ luaL_newserializer(struct lua_State *L, const char *modname,
 	return serializer;
 }
 
+/* }}} luaL_serializer manipulations */
+
+/* {{{ Fill luaL_field */
+
 static int
 lua_gettable_wrapper(lua_State *L)
 {
@@ -617,6 +623,8 @@ luaL_convertfield(struct lua_State *L, struct luaL_serializer *cfg, int idx,
 		   lua_typename(L, lua_type(L, idx)));
 }
 
+/* }}} Fill luaL_field */
+
 int
 tarantool_lua_serializer_init(struct lua_State *L)
 {
diff --git a/src/lua/serializer.h b/src/lua/serializer.h
index e29d802bb..0c473c8da 100644
--- a/src/lua/serializer.h
+++ b/src/lua/serializer.h
@@ -31,6 +31,17 @@
  * SUCH DAMAGE.
  */
 
+/**
+ * A set of helpers for converting Lua values into another
+ * representation.
+ *
+ * <struct luaL_serializer> is the serializer object: options and
+ * options inheritance.
+ *
+ * <struct luaL_field> is a Lua value descriptor, which
+ * characterizes the value.
+ */
+
 #if defined(__cplusplus)
 extern "C" {
 #endif /* defined(__cplusplus) */
@@ -56,6 +67,8 @@ struct tt_uuid;
 extern int luaL_map_metatable_ref;
 extern int luaL_array_metatable_ref;
 
+/* {{{ luaL_serializer manipulations */
+
 /**
  * Common configuration options for Lua serializers (MsgPack, YAML, JSON)
  */
@@ -192,6 +205,10 @@ void
 luaL_serializer_parse_options(struct lua_State *l,
 			      struct luaL_serializer *cfg);
 
+/* }}} luaL_serializer manipulations */
+
+/* {{{ Fill luaL_field */
+
 /** A single value on the Lua stack. */
 struct luaL_field {
 	union {
@@ -303,6 +320,10 @@ luaL_checkfield(struct lua_State *L, struct luaL_serializer *cfg, int idx,
 	luaL_convertfield(L, cfg, idx, field);
 }
 
+/* }}} Fill luaL_field */
+
+/* {{{ Set map / array hint */
+
 /**
  * Push Lua Table with __serialize = 'map' hint onto the stack.
  * Tables with __serialize hint are properly handled by all serializers.
@@ -335,6 +356,8 @@ luaL_setarrayhint(struct lua_State *L, int idx)
 	lua_setmetatable(L, idx);
 }
 
+/* }}} Set map / array hint */
+
 static inline void
 luaL_checkfinite(struct lua_State *L, struct luaL_serializer *cfg,
 		 lua_Number number)
-- 
2.31.1



More information about the Tarantool-patches mailing list