mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
Core: get_i
git-svn-id: svn://ultimatepp.org/upp/trunk@14594 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
1737746837
commit
ba695f9866
5 changed files with 63 additions and 6 deletions
|
|
@ -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 <typename T, __List##I(E__TL)> \
|
||||
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;
|
||||
|
|
|
|||
|
|
@ -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); }
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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; &]
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue