From 31b4dd820c3009ab2879e035e9113aafa5a9caef Mon Sep 17 00:00:00 2001 From: ThePhD Date: Thu, 16 Mar 2017 03:36:15 -0400 Subject: [PATCH] silence some crap warnings and fix the inversion of the branches in the usertype metatable because I'm a dumb --- examples/usertype_bitfields.cpp | 2 +- sol/usertype_metatable.hpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/usertype_bitfields.cpp b/examples/usertype_bitfields.cpp index 271045ba..ad8e9628 100644 --- a/examples/usertype_bitfields.cpp +++ b/examples/usertype_bitfields.cpp @@ -112,7 +112,7 @@ struct __attribute__((packed, aligned(1))) flags_t { uint8_t Z : 1; uint8_t S : 1; uint16_t D : 14; -} flags{}; +} flags{0, 0, 0, 0, 0, 0, 0, 0, 0}; int main() { std::cout << "=== usertype_bitfields example ===" << std::endl; diff --git a/sol/usertype_metatable.hpp b/sol/usertype_metatable.hpp index 02cd8586..8210fc05 100644 --- a/sol/usertype_metatable.hpp +++ b/sol/usertype_metatable.hpp @@ -184,14 +184,14 @@ namespace sol { std::string accessor = stack::get(L, 2); auto preexistingit = mapping.find(accessor); if (preexistingit == mapping.cend()) { + runtime.emplace_back(L, 3); + mapping.emplace_hint(mapping.cend(), accessor, call_information(&runtime_object_call, &runtime_object_call, target)); + } + else { target = preexistingit->second.runtime_target; runtime[target] = sol::object(L, 3); preexistingit->second = call_information(&runtime_object_call, &runtime_object_call, target); } - else { - runtime.emplace_back(L, 3); - mapping.emplace_hint(mapping.cend(), accessor, call_information(&runtime_object_call, &runtime_object_call, target)); - } } for (std::size_t i = 0; i < 4; lua_pop(L, 1), ++i) { const char* metakey = nullptr;