#pragma once #include "lua.h" namespace lua { class BufferWrapper : public BaseLuaObject { public: static ExportedFunctions exportedFunctions() { return {{"length", static_luaLength}, {"getBytes", static_luaGetBytes}, {"setBytes", static_luaSetBytes}}; } private: DECLARE_LUA_FUNCTION(BufferWrapper, luaLength); DECLARE_LUA_FUNCTION(BufferWrapper, luaGetBytes); DECLARE_LUA_FUNCTION(BufferWrapper, luaSetBytes); }; class HeaderMapIterator : public BaseLuaObject { public: static ExportedFunctions exportedFunctions() { return {}; } DECLARE_LUA_CLOSURE(HeaderMapIterator, luaPairsIterator); }; class HeaderMapWrapper : public BaseLuaObject { public: static ExportedFunctions exportedFunctions() { return { { "add", static_luaAdd }, { "get", static_luaGet }, { "__pairs", static_luaPairs }, }; } private: DECLARE_LUA_FUNCTION(HeaderMapWrapper, luaAdd); DECLARE_LUA_FUNCTION(HeaderMapWrapper, luaGet); DECLARE_LUA_FUNCTION(HeaderMapWrapper, luaPairs); LuaDeathRef iterator_; }; class MetadataMapIterator : public BaseLuaObject { public: static ExportedFunctions exportedFunctions() { return {}; } DECLARE_LUA_CLOSURE(MetadataMapIterator, luaPairsIterator); }; class MetadataMapWrapper : public BaseLuaObject { public: static ExportedFunctions exportedFunctions() { return {{"get", static_luaGet}, {"__pairs", static_luaPairs}}; } private: DECLARE_LUA_FUNCTION(MetadataMapWrapper, luaGet); DECLARE_LUA_FUNCTION(MetadataMapWrapper, luaPairs); LuaDeathRef iterator_; }; class StreamInfoWrapper : public BaseLuaObject { public: static ExportedFunctions exportedFunctions() { return { { "protocol", static_luaProtocol }, { "dynamicMetadata", static_luaDynamicMetadata }, { "downstreamLocalAddress", static_luaDownstreamLocalAddress }, { "downstreamDirectRemoteAddress", static_luaDownstreamDirectRemoteAddress }, { "downstreamSslConnection", static_luaDownstreamSslConnection }, { "requestedServerName", static_luaRequestedServerName } }; } private: DECLARE_LUA_FUNCTION(StreamInfoWrapper, luaProtocol); DECLARE_LUA_FUNCTION(StreamInfoWrapper, luaDynamicMetadata); DECLARE_LUA_FUNCTION(StreamInfoWrapper, luaDownstreamSslConnection); DECLARE_LUA_FUNCTION(StreamInfoWrapper, luaDownstreamLocalAddress); DECLARE_LUA_FUNCTION(StreamInfoWrapper, luaDownstreamDirectRemoteAddress); DECLARE_LUA_FUNCTION(StreamInfoWrapper, luaRequestedServerName); }; class StreamHandleWrapper : public BaseLuaObject { public: static ExportedFunctions exportedFunctions() { return { { "headers", static_luaHeaders }, { "body", static_luaBody }, { "bodyChunks", static_luaBodyChunks }, { "metadata", static_luaMetadata }, { "streamInfo", static_luaStreamInfo }, { "logTrace", static_luaLogTrace }, { "logDebug", static_luaLogDebug }, { "logInfo", static_luaLogInfo }, { "logWarn", static_luaLogWarn }, { "logErr", static_luaLogErr }, { "logCritical", static_luaLogCritical }, { "httpCall", static_luaHttpCall }, { "respond", static_luaRespond }, }; } private: DECLARE_LUA_FUNCTION(StreamHandleWrapper, luaHeaders); DECLARE_LUA_FUNCTION(StreamHandleWrapper, luaBody); DECLARE_LUA_FUNCTION(StreamHandleWrapper, luaBodyChunks); DECLARE_LUA_CLOSURE(StreamHandleWrapper, luaBodyIterator); DECLARE_LUA_FUNCTION(StreamHandleWrapper, luaMetadata); DECLARE_LUA_FUNCTION(StreamHandleWrapper, luaStreamInfo); DECLARE_LUA_FUNCTION(StreamHandleWrapper, luaLogTrace); DECLARE_LUA_FUNCTION(StreamHandleWrapper, luaLogDebug); DECLARE_LUA_FUNCTION(StreamHandleWrapper, luaLogInfo); DECLARE_LUA_FUNCTION(StreamHandleWrapper, luaLogWarn); DECLARE_LUA_FUNCTION(StreamHandleWrapper, luaLogErr); DECLARE_LUA_FUNCTION(StreamHandleWrapper, luaLogCritical); DECLARE_LUA_FUNCTION(StreamHandleWrapper, luaHttpCall); DECLARE_LUA_FUNCTION(StreamHandleWrapper, luaRespond); LuaDeathRef headers_wrapper_; LuaDeathRef metadata_wrapper_; LuaDeathRef stream_info_wrapper_; }; }