Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lua: support metatable to save table type #7891

Merged
merged 2 commits into from
Sep 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion include/fluent-bit/flb_lua.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,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 @@ -47,6 +48,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
Loading