From 01852606c8f45ffca6fb7cba95478b33f55c6641 Mon Sep 17 00:00:00 2001 From: Sandu Liviu Catalin Date: Sat, 9 Jul 2016 22:48:42 +0300 Subject: [PATCH] Implement double when binding constants with Sqrat. Minor chnage in buffer when throwing an exception. --- include/sqrat/sqratConst.h | 14 ++++++++++++++ shared/Base/Buffer.cpp | 4 ++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/include/sqrat/sqratConst.h b/include/sqrat/sqratConst.h index 22067828..5d0572a0 100644 --- a/include/sqrat/sqratConst.h +++ b/include/sqrat/sqratConst.h @@ -115,6 +115,20 @@ public: return *this; } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + /// Binds an enumeration value + /// + /// \param name Name of the value as it will appear in Squirrel + /// \param val Value to bind + /// + /// \return The Enumeration itself so the call can be chained + /// + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + virtual Enumeration& Const(const SQChar* name, const double val) { + BindValue(name, val, false); + return *this; + } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// Binds an enumeration value /// diff --git a/shared/Base/Buffer.cpp b/shared/Base/Buffer.cpp index a12e7e2a..9b8c3177 100644 --- a/shared/Base/Buffer.cpp +++ b/shared/Base/Buffer.cpp @@ -31,7 +31,7 @@ inline unsigned int NextPow2(unsigned int num) void ThrowMemExcept(const char * msg, ...) { // Exception messages should be concise - char buffer[256]; + SQChar buffer[256]; // Variable arguments structure va_list args; // Get the specified arguments @@ -41,7 +41,7 @@ void ThrowMemExcept(const char * msg, ...) // Check for formatting errors if (ret < 0) { - throw Sqrat::Exception("Unknown memory error"); + throw Sqrat::Exception(_SC("Unknown memory error")); } // Throw the actual exception throw Sqrat::Exception(buffer);