-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated Get method to support multiple keys
- Values can now be fetched from Lua stack, in batches, either by index, name or both.
- Loading branch information
Showing
9 changed files
with
255 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#pragma once | ||
|
||
#ifndef STACK_GUARD_H | ||
#define STACK_GUARD_H | ||
|
||
#include "moon/moon.h" | ||
|
||
#define BEGIN_STACK_GUARD \ | ||
int stack_top_begin{0}; \ | ||
int stack_top_end{0}; \ | ||
{ \ | ||
StackGuard guard{stack_top_begin, stack_top_end}; | ||
|
||
#define END_STACK_GUARD \ | ||
} \ | ||
REQUIRE(stack_top_begin == stack_top_end); | ||
|
||
#define CHECK_STACK_GUARD REQUIRE(guard.Check()); | ||
|
||
class StackGuard { | ||
public: | ||
StackGuard(int& begin, int& end) : m_begin(begin), m_end(end) { m_begin = Moon::GetTop(); } | ||
|
||
~StackGuard() { m_end = Moon::GetTop(); } | ||
|
||
[[nodiscard]] inline bool Check() const { return Moon::GetTop() == m_begin; } | ||
|
||
private: | ||
int& m_begin; | ||
int& m_end; | ||
}; | ||
|
||
struct LoggerSetter { | ||
LoggerSetter(std::string& info, std::string& warning, std::string& error) : m_info(info), m_warning(warning), m_error(error) { | ||
m_info.clear(); | ||
m_warning.clear(); | ||
m_error.clear(); | ||
Moon::SetLogger([this](moon::Logger::Level level, const auto& msg) { | ||
switch (level) { | ||
case moon::Logger::Level::Info: | ||
m_info = msg; | ||
break; | ||
case moon::Logger::Level::Warning: | ||
m_warning = msg; | ||
break; | ||
case moon::Logger::Level::Error: | ||
m_error = msg; | ||
break; | ||
} | ||
}); | ||
} | ||
|
||
inline const std::string& GetInfo() const { return m_info; } | ||
|
||
inline const std::string& GetWarning() const { return m_warning; } | ||
|
||
inline const std::string& GetError() const { return m_error; } | ||
|
||
inline bool NoErrors() const { return m_error.empty(); } | ||
|
||
private: | ||
std::string& m_info; | ||
std::string& m_warning; | ||
std::string& m_error; | ||
}; | ||
|
||
#endif |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.