]> granicus.if.org Git - pdns/commitdiff
LuaWrapper: Add support for handling specialized unordered map as tables
authorRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 28 Jun 2018 09:04:49 +0000 (11:04 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 28 Jun 2018 09:04:49 +0000 (11:04 +0200)
ext/luawrapper/include/LuaContext.hpp

index fd22605c486ce383258bd8e9bfcd31337db24cd3..50fb4513e7d33f5f9a3b8de0988a2383152e3153 100644 (file)
@@ -2113,12 +2113,12 @@ struct LuaContext::Pusher<std::map<TKey,TValue>> {
 };
 
 // unordered_maps
-template<typename TKey, typename TValue>
-struct LuaContext::Pusher<std::unordered_map<TKey,TValue>> {
+template<typename TKey, typename TValue, typename THash, typename TKeyEqual>
+struct LuaContext::Pusher<std::unordered_map<TKey,TValue,THash,TKeyEqual>> {
     static const int minSize = 1;
     static const int maxSize = 1;
 
-    static PushedObject push(lua_State* state, const std::unordered_map<TKey,TValue>& value) noexcept {
+    static PushedObject push(lua_State* state, const std::unordered_map<TKey,TValue,THash,TKeyEqual>& value) noexcept {
         static_assert(Pusher<typename std::decay<TKey>::type>::minSize == 1 && Pusher<typename std::decay<TKey>::type>::maxSize == 1, "Can't push multiple elements for a table key");
         static_assert(Pusher<typename std::decay<TValue>::type>::minSize == 1 && Pusher<typename std::decay<TValue>::type>::maxSize == 1, "Can't push multiple elements for a table value");
         
@@ -2777,16 +2777,16 @@ struct LuaContext::Reader<std::map<TKey,TValue>>
 };
 
 // unordered_map
-template<typename TKey, typename TValue>
-struct LuaContext::Reader<std::unordered_map<TKey,TValue>>
+template<typename TKey, typename TValue, typename THash, typename TKeyEqual>
+struct LuaContext::Reader<std::unordered_map<TKey,TValue,THash,TKeyEqual>>
 {
     static auto read(lua_State* state, int index)
-        -> boost::optional<std::unordered_map<TKey,TValue>>
+        -> boost::optional<std::unordered_map<TKey,TValue,THash,TKeyEqual>>
     {
         if (!lua_istable(state, index))
             return boost::none;
 
-        std::unordered_map<TKey,TValue> result;
+        std::unordered_map<TKey,TValue,THash,TKeyEqual> result;
 
         // we traverse the table at the top of the stack
         lua_pushnil(state);     // first key