Skip to content

Commit

Permalink
lua: support metatable to save table type
Browse files Browse the repository at this point in the history
Signed-off-by: Takahiro Yamashita <[email protected]>
  • Loading branch information
nokute78 authored and edsiper committed Sep 23, 2023
1 parent af081bf commit 7ebe7a2
Show file tree
Hide file tree
Showing 2 changed files with 239 additions and 60 deletions.
24 changes: 23 additions & 1 deletion include/fluent-bit/flb_lua.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@

enum flb_lua_l2c_type_enum {
FLB_LUA_L2C_TYPE_INT,
FLB_LUA_L2C_TYPE_ARRAY
FLB_LUA_L2C_TYPE_ARRAY,
FLB_LUA_L2C_TYPE_MAP
};

struct flb_lua_l2c_type {
Expand All @@ -50,6 +51,27 @@ struct flb_lua_l2c_config {
struct mk_list l2c_types; /* data types (lua -> C) */
};


/*
* Metatable for Lua table.
* https://www.lua.org/manual/5.1/manual.html#2.8
*/
struct flb_lua_metadata {
int initialized;
int data_type; /* Map or Array */
};

static inline int flb_lua_metadata_init(struct flb_lua_metadata *meta)
{
if (meta == NULL) {
return -1;
}
meta->initialized = FLB_TRUE;
meta->data_type = -1;

return 0;
}

/* convert from negative index to positive index */
static inline int flb_lua_absindex(lua_State *l , int index)
{
Expand Down
Loading

0 comments on commit 7ebe7a2

Please sign in to comment.