diff --git a/configure b/configure index 2cd7d97fd..ff2ae667f 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #!/bin/sh -set -e +# set -e # install depes @@ -17,14 +17,15 @@ else fi # PYTHON=/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python + if [ ! "$PYTHON" ]; then echo "\nError: python 2.7 needs to be installed first\n"; - exit -1; + exit 1; fi if [ ! "`which node`" ]; then echo "\nError: nodejs needs to be installed first\n"; - exit -1; + exit 2; fi if [ "`which tsc`" = "" ]; then @@ -85,4 +86,4 @@ fi export PYTHON=$PYTHON -node tools/configure.js "$@" \ No newline at end of file +node tools/configure.js "$@" diff --git a/src/render/math.cc b/src/render/math.cc index c41dd6715..1e3e76ffb 100755 --- a/src/render/math.cc +++ b/src/render/math.cc @@ -787,8 +787,7 @@ namespace qk { } Mat4::Mat4(float value) { - constexpr float src = 0; - memset_pattern4(val, &src, 16); + memset(val, 0, 16 * 4); val[0] = value; val[5] = value; val[10] = value; diff --git a/src/render/math.h b/src/render/math.h index 4e64dc78f..74b8a43df 100755 --- a/src/render/math.h +++ b/src/render/math.h @@ -76,32 +76,40 @@ namespace qk { // ------------------------------------------ inline Vec operator+(const Vec& b) const { Vec c(*this); - for (int i = 0; i < LEN; i++) c.val[i] += b.val[i]; return c; + for (int i = 0; i < LEN; i++) c.val[i] += b.val[i]; + return c; } inline Vec operator-(const Vec& b) const { Vec c(*this); - for (int i = 0; i < LEN; i++) c.val[i] -= b.val[i]; return c; + for (int i = 0; i < LEN; i++) c.val[i] -= b.val[i]; + return c; } inline Vec operator*(const Vec& b) const { Vec c(*this); - for (int i = 0; i < LEN; i++) c.val[i] *= b.val[i]; return c; + for (int i = 0; i < LEN; i++) c.val[i] *= b.val[i]; + return c; } inline Vec operator/(const Vec& b) const { Vec c(*this); - for (int i = 0; i < LEN; i++) c.val[i] /= b.val[i]; return c; + for (int i = 0; i < LEN; i++) c.val[i] /= b.val[i]; + return c; } // ------------------------------------------ inline Vec& operator+=(const Vec& b) { - for (int i = 0; i < LEN; i++) val[i] += b.val[i]; return *this; + for (int i = 0; i < LEN; i++) val[i] += b.val[i]; + return *this; } inline Vec& operator-=(const Vec& b) { - for (int i = 0; i < LEN; i++) val[i] -= b.val[i]; return *this; + for (int i = 0; i < LEN; i++) val[i] -= b.val[i]; + return *this; } inline Vec& operator*=(const Vec& b) { - for (int i = 0; i < LEN; i++) val[i] *= b.val[i]; return *this; + for (int i = 0; i < LEN; i++) val[i] *= b.val[i]; + return *this; } inline Vec& operator/=(const Vec& b) { - for (int i = 0; i < LEN; i++) val[i] /= b.val[i]; return *this; + for (int i = 0; i < LEN; i++) val[i] /= b.val[i]; + return *this; } // ------------------------------------------ diff --git a/src/util/array.h b/src/util/array.h index b86dc9a96..bfd3f9369 100644 --- a/src/util/array.h +++ b/src/util/array.h @@ -33,6 +33,7 @@ #include "./object.h" #include "./iterator.h" +#include #include #include diff --git a/src/util/log.cc b/src/util/log.cc index dc168cbf9..0a54c8e78 100644 --- a/src/util/log.cc +++ b/src/util/log.cc @@ -186,9 +186,9 @@ namespace qk { Log::shared()->println(Log::kLog, Qk_ARCH_64BIT ? "%lu": "%llu", msg ); } - void log_println(size_t msg) { + /*void log_println(size_t msg) { Log::shared()->println(Log::kLog, Qk_ARCH_64BIT ? "%lu": "%llu", msg ); - } + }*/ void log_println(bool msg) { Log::shared()->log( msg ? "true\n": "false\n" ); diff --git a/src/util/macros.h b/src/util/macros.h index 0d98da41d..70a84116c 100644 --- a/src/util/macros.h +++ b/src/util/macros.h @@ -160,7 +160,9 @@ #endif #define Qk_DEBUG DEBUG +#if __cplusplus >= 201703L #define throw(...) +#endif #define Qk_Type_Check(Base, Sub) \ while (false) { *(static_cast(0)) = static_cast(0); } diff --git a/src/util/object.h b/src/util/object.h index c3f8cf99a..edbbbf467 100755 --- a/src/util/object.h +++ b/src/util/object.h @@ -34,6 +34,7 @@ #include "./macros.h" #include #include +#include namespace qk { struct Allocator; @@ -143,6 +144,19 @@ namespace qk { Qk_EXPORT void Release(Object* obj); Qk_EXPORT void Fatal(const char* file, uint32_t line, const char* func, const char* msg = 0, ...); + template struct object_traits_basic { // Object + static inline void Retain(T* obj) { qk::Retain(obj); } + static inline void Release(T* obj) { qk::Release(obj); } + }; + template struct object_traits_basic { // Other + static inline void Retain(T* obj) {} + static inline void Release(T* obj) { delete obj; } + }; + template struct object_traits_basic { //protocol + static inline void Retain(T* obj) { if (obj) qk::Retain(obj->asObject()); } + static inline void Release(T* obj) { if (obj) qk::Release(obj->asObject()); } + }; + template struct object_traits { typedef char __non[0]; @@ -161,21 +175,9 @@ namespace qk { static constexpr bool ref = (k == 2); static constexpr bool protocol = (k == 3); }; - template struct __inl { // Object - static inline void Retain(T* obj) { qk::Retain(obj); } - static inline void Release(T* obj) { qk::Release(obj); } - }; - template <> struct __inl<0> { // Other - static inline void Retain(T* obj) {} - static inline void Release(T* obj) { delete obj; } - }; - template <> struct __inl<3> { //protocol - static inline void Retain(T* obj) { if (obj) qk::Retain(obj->asObject()); } - static inline void Release(T* obj) { if (obj) qk::Release(obj->asObject()); } - }; typedef __is(0)) / sizeof(char))> is; - inline static void Retain(T* obj) { __inl::Retain(obj); } - inline static void Release(T* obj) { __inl::Release(obj); } + inline static void Retain(T* obj) { object_traits_basic::Retain(obj); } + inline static void Release(T* obj) { object_traits_basic::Release(obj); } }; template <> diff --git a/src/util/util.cc b/src/util/util.cc index dd9a59218..0869bb3d1 100755 --- a/src/util/util.cc +++ b/src/util/util.cc @@ -35,6 +35,8 @@ #if Qk_POSIX # include # include +# include +# include #endif #if Qk_MAC diff --git a/test/2/test2-str.cc b/test/2/test2-str.cc index a6be0ea33..e505e45b7 100644 --- a/test/2/test2-str.cc +++ b/test/2/test2-str.cc @@ -41,6 +41,7 @@ #include #include #include +#include const char test_big_char[] = { 1, 0, 0, 0 }; const int* test_big_int = (const int*)test_big_char; diff --git a/test/2/test2-thread.cc b/test/2/test2-thread.cc index f4cb30ce6..bc74b16da 100644 --- a/test/2/test2-thread.cc +++ b/test/2/test2-thread.cc @@ -28,7 +28,9 @@ * * ***** END LICENSE BLOCK ***** */ +#include #include +#include int test2_thread(int argc, char *argv[]) {