the String class instead of the stack for logging, and get rid of the old and useless BitField class.legacy
| @@ -9,21 +9,19 @@ liblol_a_SOURCES = \ | |||
| core.h tiler.cpp tiler.h dict.cpp dict.h \ | |||
| audio.cpp audio.h scene.cpp scene.h font.cpp font.h layer.cpp layer.h \ | |||
| map.cpp map.h entity.cpp entity.h ticker.cpp ticker.h lolgl.h \ | |||
| tileset.cpp tileset.h forge.cpp forge.h video.cpp video.h log.cpp log.h \ | |||
| timer.cpp timer.h bitfield.h profiler.cpp profiler.h \ | |||
| tileset.cpp tileset.h forge.cpp forge.h video.cpp video.h \ | |||
| world.cpp world.h sample.cpp sample.h sampler.cpp sampler.h \ | |||
| text.cpp text.h emitter.cpp emitter.h numeric.h \ | |||
| profiler.cpp profiler.h text.cpp text.h emitter.cpp emitter.h numeric.h \ | |||
| worldentity.cpp worldentity.h gradient.cpp gradient.h gradient.lolfx \ | |||
| platform.cpp platform.h sprite.cpp sprite.h camera.cpp camera.h \ | |||
| \ | |||
| lol/unit.h lol/debug.h \ | |||
| lol/base/types.h lol/base/array.h lol/base/string.h lol/base/hash.h \ | |||
| lol/base/map.h \ | |||
| lol/math/vector.h lol/math/half.h lol/math/real.h lol/math/remez.h \ | |||
| lol/math/math.h \ | |||
| lol/math/geometry.h \ | |||
| lol/sys/init.h \ | |||
| lol/math/math.h lol/math/geometry.h \ | |||
| lol/sys/init.h lol/sys/log.h lol/sys/thread.h lol/sys/timer.h \ | |||
| lol/image/color.h \ | |||
| lol/unit.h lol/debug.h \ | |||
| \ | |||
| generated/location.hh generated/position.hh generated/stack.hh \ | |||
| \ | |||
| @@ -71,8 +69,8 @@ liblol_a_SOURCES = \ | |||
| \ | |||
| mesh/mesh.cpp mesh/mesh.h \ | |||
| \ | |||
| sys/init.cpp \ | |||
| sys/threadbase.h sys/thread.h \ | |||
| sys/init.cpp sys/log.cpp sys/timer.cpp \ | |||
| sys/threadbase.h \ | |||
| \ | |||
| image/image.cpp image/image.h image/image-private.h \ | |||
| image/codec/gdiplus-image.cpp \ | |||
| @@ -1,55 +0,0 @@ | |||
| // | |||
| // Lol Engine | |||
| // | |||
| // Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> | |||
| // This program is free software; you can redistribute it and/or | |||
| // modify it under the terms of the Do What The Fuck You Want To | |||
| // Public License, Version 2, as published by Sam Hocevar. See | |||
| // http://www.wtfpl.net/ for more details. | |||
| // | |||
| // | |||
| // The BitField class | |||
| // ------------------ | |||
| // | |||
| #if !defined __LOL_BITFIELD_H__ | |||
| #define __LOL_BITFIELD_H__ | |||
| #include <stdint.h> | |||
| namespace lol | |||
| { | |||
| template class BitField<unsigned int COUNT> | |||
| { | |||
| public: | |||
| BitField() | |||
| { | |||
| memset(bits, 0, sizeof(bits)); | |||
| } | |||
| inline unsigned int IsSet(unsigned int index) | |||
| { | |||
| return bits[index / 32] & (1 << (index & 31)); | |||
| } | |||
| inline void Set(unsigned int index) | |||
| { | |||
| bits[index / 32] |= (1 << (index & 31)); | |||
| } | |||
| inline void Unset(unsigned int index) | |||
| { | |||
| bits[index / 32] &= ~(1 << (index & 31)); | |||
| } | |||
| private: | |||
| uint32_t bits[(COUNT + 31) / 32]; | |||
| }; | |||
| } /* namespace lol */ | |||
| #endif // __LOL_BITFIELD_H__ | |||
| @@ -89,15 +89,15 @@ static inline int isnan(float f) | |||
| #include <lol/math/geometry.h> | |||
| #include <lol/sys/init.h> | |||
| #include <lol/sys/log.h> | |||
| #include <lol/sys/thread.h> | |||
| #include <lol/sys/timer.h> | |||
| #include <lol/image/color.h> | |||
| #include "numeric.h" | |||
| #include "timer.h" | |||
| // Static classes | |||
| #include "log.h" | |||
| #include "platform.h" | |||
| #include "video.h" | |||
| #include "audio.h" | |||
| @@ -1,7 +1,7 @@ | |||
| // | |||
| // Lol Engine | |||
| // | |||
| // Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> | |||
| // Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net> | |||
| // This program is free software; you can redistribute it and/or | |||
| // modify it under the terms of the Do What The Fuck You Want To | |||
| // Public License, Version 2, as published by Sam Hocevar. See | |||
| @@ -14,8 +14,8 @@ | |||
| // The central logging system. | |||
| // | |||
| #if !defined __LOL_LOG_H__ | |||
| #define __LOL_LOG_H__ | |||
| #if !defined __LOL_SYS_LOG_H__ | |||
| #define __LOL_SYS_LOG_H__ | |||
| #include <stdint.h> | |||
| #include <cstdarg> | |||
| @@ -51,5 +51,5 @@ private: | |||
| } /* namespace lol */ | |||
| #endif // __LOL_LOG_H__ | |||
| #endif // __LOL_SYS_LOG_H__ | |||
| @@ -1,7 +1,7 @@ | |||
| // | |||
| // Lol Engine | |||
| // | |||
| // Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> | |||
| // Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net> | |||
| // This program is free software; you can redistribute it and/or | |||
| // modify it under the terms of the Do What The Fuck You Want To | |||
| // Public License, Version 2, as published by Sam Hocevar. See | |||
| @@ -13,8 +13,8 @@ | |||
| // --------------- | |||
| // | |||
| #if !defined __LOL_TIMER_H__ | |||
| #define __LOL_TIMER_H__ | |||
| #if !defined __LOL_SYS_TIMER_H__ | |||
| #define __LOL_SYS_TIMER_H__ | |||
| namespace lol | |||
| { | |||
| @@ -37,5 +37,5 @@ private: | |||
| } /* namespace lol */ | |||
| #endif // __LOL_TIMER_H__ | |||
| #endif // __LOL_SYS_TIMER_H__ | |||
| @@ -272,7 +272,6 @@ | |||
| <ClCompile Include="input\keyboard.cpp" /> | |||
| <ClCompile Include="input\stick.cpp" /> | |||
| <ClCompile Include="layer.cpp" /> | |||
| <ClCompile Include="log.cpp" /> | |||
| <ClCompile Include="map.cpp" /> | |||
| <ClCompile Include="math\geometry.cpp" /> | |||
| <ClCompile Include="math\half.cpp" /> | |||
| @@ -294,6 +293,8 @@ | |||
| <ClCompile Include="scene.cpp" /> | |||
| <ClCompile Include="sprite.cpp" /> | |||
| <ClCompile Include="sys\init.cpp" /> | |||
| <ClCompile Include="sys\log.cpp" /> | |||
| <ClCompile Include="sys\timer.cpp" /> | |||
| <ClCompile Include="text.cpp" /> | |||
| <ClCompile Include="ticker.cpp" /> | |||
| <ClCompile Include="tiler.cpp" /> | |||
| @@ -306,7 +307,6 @@ | |||
| <ItemGroup> | |||
| <ClInclude Include="application\application.h" /> | |||
| <ClInclude Include="audio.h" /> | |||
| <ClInclude Include="bitfield.h" /> | |||
| <ClInclude Include="bullet\btBulletCollisionCommon.h" /> | |||
| <ClInclude Include="bullet\btBulletDynamicsCommon.h" /> | |||
| <ClInclude Include="bullet\Bullet-C-Api.h" /> | |||
| @@ -584,7 +584,6 @@ | |||
| <ClInclude Include="input\keyboard.h" /> | |||
| <ClInclude Include="input\stick.h" /> | |||
| <ClInclude Include="layer.h" /> | |||
| <ClInclude Include="log.h" /> | |||
| <ClInclude Include="loldebug.h" /> | |||
| <ClInclude Include="lolgl.h" /> | |||
| <ClInclude Include="lol\base\array.h" /> | |||
| @@ -601,7 +600,9 @@ | |||
| <ClInclude Include="lol\math\remez.h" /> | |||
| <ClInclude Include="lol\math\vector.h" /> | |||
| <ClInclude Include="lol\sys\init.h" /> | |||
| <ClInclude Include="lol\sys\log.h" /> | |||
| <ClInclude Include="lol\sys\thread.h" /> | |||
| <ClInclude Include="lol\sys\timer.h" /> | |||
| <ClInclude Include="lol\unit.h" /> | |||
| <ClInclude Include="mesh\mesh.h" /> | |||
| <ClInclude Include="map.h" /> | |||
| @@ -192,9 +192,6 @@ | |||
| <ClCompile Include="ticker.cpp"> | |||
| <Filter>...</Filter> | |||
| </ClCompile> | |||
| <ClCompile Include="log.cpp"> | |||
| <Filter>...</Filter> | |||
| </ClCompile> | |||
| <ClCompile Include="map.cpp"> | |||
| <Filter>...</Filter> | |||
| </ClCompile> | |||
| @@ -752,9 +749,6 @@ | |||
| <ClInclude Include="audio.h"> | |||
| <Filter>...</Filter> | |||
| </ClInclude> | |||
| <ClInclude Include="bitfield.h"> | |||
| <Filter>...</Filter> | |||
| </ClInclude> | |||
| <ClInclude Include="camera.h"> | |||
| <Filter>...</Filter> | |||
| </ClInclude> | |||
| @@ -785,9 +779,6 @@ | |||
| <ClInclude Include="layer.h"> | |||
| <Filter>...</Filter> | |||
| </ClInclude> | |||
| <ClInclude Include="log.h"> | |||
| <Filter>...</Filter> | |||
| </ClInclude> | |||
| <ClInclude Include="loldebug.h"> | |||
| <Filter>...</Filter> | |||
| </ClInclude> | |||
| @@ -1675,4 +1666,4 @@ | |||
| <Filter>gpu</Filter> | |||
| </None> | |||
| </ItemGroup> | |||
| </Project> | |||
| </Project> | |||
| @@ -82,11 +82,8 @@ void Log::Helper(MessageType type, char const *fmt, va_list ap) | |||
| ANDROID_LOG_ERROR | |||
| }; | |||
| char buf[4096]; | |||
| vsnprintf(buf, 4095, fmt, ap); | |||
| buf[4095] = '\0'; | |||
| __android_log_print(prio[type], "LOL", "[%d] %s", (int)gettid(), buf); | |||
| String buf = String::Printf(fmt, ap); | |||
| __android_log_print(prio[type], "LOL", "[%d] %s", (int)gettid(), &buf[0]); | |||
| #else | |||
| char const *prefix[] = | |||
| @@ -98,12 +95,8 @@ void Log::Helper(MessageType type, char const *fmt, va_list ap) | |||
| }; | |||
| # if defined _WIN32 | |||
| char buf[4096]; | |||
| vsnprintf(buf, 4095, fmt, ap); | |||
| buf[4095] = '\0'; | |||
| OutputDebugString(prefix[type]); | |||
| OutputDebugString(": "); | |||
| OutputDebugString(buf); | |||
| String buf = String(prefix[type]) + ": " + String::Printf(fmt, ap); | |||
| OutputDebugString(&buf[0]); | |||
| # else | |||
| fprintf(stderr, "%s: ", prefix[type]); | |||
| vfprintf(stderr, fmt, ap); | |||