diff --git a/uppsrc/Core/Defs.h b/uppsrc/Core/Defs.h index f7f43032f..e3ca56bb9 100644 --- a/uppsrc/Core/Defs.h +++ b/uppsrc/Core/Defs.h @@ -329,6 +329,50 @@ __Expand40(E__NFBody) #undef E__NFBody //$+ +//$-T get_i(int i, const T& p0, const T1& p1, ...); +#define E__TL(I) typename COMBINE(T, I) +#define E__NFList(I) COMBINE(p, I) +#define E__NFValue(I) const COMBINE(T, I)& COMBINE(p, I) + +#define E__NFBody(I) \ +template \ +T get_i(int i, const T& p0, __List##I(E__NFValue)) \ +{ \ + T list[] = { p0, \ + __List##I(E__NFList) \ + }; \ + return list[clamp(i, 0, __countof(list) - 1)]; \ +} + +__Expand40(E__NFBody) + +#undef E__TL +#undef E__NFList +#undef E__NFValue +#undef E__NFBody +//$+ + +//$-const char *get_i(int i, const char *p0, const char *p1, ...); +#define E__NFList(I) COMBINE(p, I) +#define E__NFValue(I) const char *COMBINE(p, I) + +#define E__NFBody(I) \ +inline const char *get_i(int i, const char *p0, __List##I(E__NFValue)) \ +{ \ + const char *list[] = { p0, \ + __List##I(E__NFList) \ + }; \ + return list[clamp(i, 0, __countof(list) - 1)]; \ +} + +__Expand40(E__NFBody) + +#undef E__TL +#undef E__NFList +#undef E__NFValue +#undef E__NFBody +//$+ + typedef unsigned char byte; typedef signed char int8; typedef unsigned char uint8; diff --git a/uppsrc/Core/Ops.h b/uppsrc/Core/Ops.h index cdf6232f4..8eb1e9fdc 100644 --- a/uppsrc/Core/Ops.h +++ b/uppsrc/Core/Ops.h @@ -26,8 +26,9 @@ inline void Poke64be(const void *ptr, int64 val) { Poke32be(ptr, HIDWORD(val) #ifdef CPU_LITTLE_ENDIAN -#define MAKE2B(b0, b1) MAKEWORD(b0, b1); -#define MAKE4B(b0, b1, b2, b3) MAKELONG(MAKEWORD(b0, b1), MAKEWORD(b2, b3)) +#define MAKE2B(b0, b1) MAKEWORD(b0, b1) +#define MAKE4B(b0, b1, b2, b3) MAKELONG(MAKEWORD(b0, b1), MAKEWORD(b2, b3)) +#define MAKE8B(b0, b1, b2, b3, b4, b5, b6, b7) MAKEQWORD(MAKE4B(b0, b1, b2, b3), MAKE4B(b4, b5, b6, b7)) inline int Peek16(const void *ptr) { return Peek16le(ptr); } inline int Peek32(const void *ptr) { return Peek32le(ptr); } @@ -39,8 +40,9 @@ inline void Poke64(const void *ptr, int64 val) { Poke64le(ptr, val); } #else -#define MAKE2B(b0, b1) MAKEWORD(b1, b0); -#define MAKE4B(b0, b1, b2, b3) MAKELONG(MAKEWORD(b2, b3), MAKEWORD(b0, b1)) +#define MAKE2B(b0, b1) MAKEWORD(b1, b0); +#define MAKE4B(b0, b1, b2, b3) MAKELONG(MAKEWORD(b2, b3), MAKEWORD(b0, b1)) +#define MAKE8B(b0, b1, b2, b3, b4, b5, b6, b7) MAKEQWORD(MAKE4B(b7, b6, b5, b4), MAKE4B(b3, b2, b1, b0)) inline int Peek16(const void *ptr) { return Peek16be(ptr); } inline int Peek32(const void *ptr) { return Peek32be(ptr); } diff --git a/uppsrc/Core/String.h b/uppsrc/Core/String.h index 11fa996bd..8e5a4df9c 100644 --- a/uppsrc/Core/String.h +++ b/uppsrc/Core/String.h @@ -280,7 +280,7 @@ public: bool IsEqual(const String0& s) const { uint64 q1 = q[1]; uint64 sq1 = s.q[1]; - return q1 == sq1 && q[0] == s.q[0] || ((q1 | sq1) & I64(0x00ff000000000000)) && LEq(s); + return q1 == sq1 && q[0] == s.q[0] || ((q1 | sq1) & MAKE8B(0,0,0,0,0,0,255,0)) && LEq(s); } bool IsEqual(const char *s) const; diff --git a/uppsrc/Core/src.tpp/AppEnv_en-us.tpp b/uppsrc/Core/src.tpp/AppEnv_en-us.tpp index 1817dda70..06235c0b0 100644 --- a/uppsrc/Core/src.tpp/AppEnv_en-us.tpp +++ b/uppsrc/Core/src.tpp/AppEnv_en-us.tpp @@ -263,6 +263,17 @@ the second argument of pair. If no match is found, returns the last argument [%-*@3 def].&] [s3;%% &] [s4; &] +[s5;:Upp`:`:get`_i`(int`,const T`&`,const T1`&`,`.`.`.`): T_[* get`_i]([@(0.0.255) int]_[*@3 i +], [@(0.0.255) const]_T[@(0.0.255) `&]_[*/@3 p][*@3 0], [@(0.0.255) const]_T1[@(0.0.255) `&]_ +[*/@3 p][*@3 1], ...)&] +[s5;:Upp`:`:get`_i`(int`,const char`*`,const char`*`,`.`.`.`): [@(0.0.255) const]_[@(0.0.255) c +har]_`*[* get`_i]([@(0.0.255) int]_[*@3 i], [@(0.0.255) const]_[@(0.0.255) char]_`*[*@3 p0], +[@(0.0.255) const]_[@(0.0.255) char]_`*[*@3 p1], ...)&] +[s2;%% Returns parameter [%-*/@3 p][%-*@3 i]. If [%-*@3 i] is negative, +returns [%-*/@3 p][%-*@3 0], if it is greater then the last parameter, +returns the last parameter.&] +[s3;%% &] +[s4; &] [s5;:CpuSSE`(`): [@(0.0.255) bool]_[* CpuSSE]()&] [s2;%% Returns true if CPU has SSE support.&] [s3; &] diff --git a/uppsrc/Draw/MakeCache.cpp b/uppsrc/Draw/MakeCache.cpp index 845734244..9d962a382 100644 --- a/uppsrc/Draw/MakeCache.cpp +++ b/uppsrc/Draw/MakeCache.cpp @@ -26,7 +26,7 @@ struct scImageMaker : ValueMaker { }; void SysImageRealized(const Image& img) -{ // Pixel data copied to host platform, no need to keep pixels data in cache if it is Fpaintonly kind +{ // Pixel data copied to host platform, no need to keep pixels data in cache if it is paintonly kind if(!IsValueCacheActive()) return; LLOG("SysImageRealized " << img.GetSize());