mirror of
https://github.com/GorgonMeducer/perf_counter.git
synced 2025-01-31 19:33:04 +08:00
use __typeof__ to simplify with and foreach
This commit is contained in:
parent
6767a00bfd
commit
4073b907cc
@ -153,40 +153,7 @@
|
|||||||
<Name>(105=150,186,829,544,0)(106=-1,-1,-1,-1,0)(107=180,218,520,403,0)</Name>
|
<Name>(105=150,186,829,544,0)(106=-1,-1,-1,-1,0)(107=180,218,520,403,0)</Name>
|
||||||
</SetRegEntry>
|
</SetRegEntry>
|
||||||
</TargetDriverDllRegistry>
|
</TargetDriverDllRegistry>
|
||||||
<Breakpoint>
|
<Breakpoint/>
|
||||||
<Bp>
|
|
||||||
<Number>0</Number>
|
|
||||||
<Type>0</Type>
|
|
||||||
<LineNumber>151</LineNumber>
|
|
||||||
<EnabledFlag>1</EnabledFlag>
|
|
||||||
<Address>16362</Address>
|
|
||||||
<ByteObject>0</ByteObject>
|
|
||||||
<HtxType>0</HtxType>
|
|
||||||
<ManyObjects>0</ManyObjects>
|
|
||||||
<SizeOfObject>0</SizeOfObject>
|
|
||||||
<BreakByAccess>0</BreakByAccess>
|
|
||||||
<BreakIfRCount>1</BreakIfRCount>
|
|
||||||
<Filename><1>.\main.c</Filename>
|
|
||||||
<ExecCommand></ExecCommand>
|
|
||||||
<Expression>\\example\main.c\151</Expression>
|
|
||||||
</Bp>
|
|
||||||
<Bp>
|
|
||||||
<Number>1</Number>
|
|
||||||
<Type>0</Type>
|
|
||||||
<LineNumber>158</LineNumber>
|
|
||||||
<EnabledFlag>1</EnabledFlag>
|
|
||||||
<Address>0</Address>
|
|
||||||
<ByteObject>0</ByteObject>
|
|
||||||
<HtxType>0</HtxType>
|
|
||||||
<ManyObjects>0</ManyObjects>
|
|
||||||
<SizeOfObject>0</SizeOfObject>
|
|
||||||
<BreakByAccess>0</BreakByAccess>
|
|
||||||
<BreakIfRCount>0</BreakIfRCount>
|
|
||||||
<Filename><1>.\main.c</Filename>
|
|
||||||
<ExecCommand></ExecCommand>
|
|
||||||
<Expression></Expression>
|
|
||||||
</Bp>
|
|
||||||
</Breakpoint>
|
|
||||||
<WatchWindow1>
|
<WatchWindow1>
|
||||||
<Ww>
|
<Ww>
|
||||||
<count>0</count>
|
<count>0</count>
|
||||||
|
@ -142,7 +142,7 @@ int main (void)
|
|||||||
|
|
||||||
/*! demo of __cycleof__() operation */
|
/*! demo of __cycleof__() operation */
|
||||||
__cycleof__() {
|
__cycleof__() {
|
||||||
foreach(example_lv0_t, s_tItem, ptItem) {
|
foreach(s_tItem) {
|
||||||
printf("Processing item with ID = %d\r\n", _->chID);
|
printf("Processing item with ID = %d\r\n", _->chID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -164,7 +164,7 @@ int main (void)
|
|||||||
_->hwB = 2;
|
_->hwB = 2;
|
||||||
_->chC = 3;
|
_->chC = 3;
|
||||||
|
|
||||||
with(example_lv1_t, &pitem->tLV1) {
|
with(&pitem->tLV1) {
|
||||||
_->wLV1A = 4;
|
_->wLV1A = 4;
|
||||||
_->hwLV1B = 5;
|
_->hwLV1B = 5;
|
||||||
_->chLV1C = 6;
|
_->chLV1C = 6;
|
||||||
|
@ -257,6 +257,9 @@ extern "C" {
|
|||||||
#undef __with3
|
#undef __with3
|
||||||
#undef with
|
#undef with
|
||||||
|
|
||||||
|
#define __with1(__addr) \
|
||||||
|
using(__typeof__(*__addr) *_=(__addr))
|
||||||
|
|
||||||
#define __with2(__type, __addr) \
|
#define __with2(__type, __addr) \
|
||||||
using(__type *_=(__addr))
|
using(__type *_=(__addr))
|
||||||
#define __with3(__type, __addr, __item) \
|
#define __with3(__type, __addr, __item) \
|
||||||
@ -278,6 +281,13 @@ extern "C" {
|
|||||||
#undef foreach3
|
#undef foreach3
|
||||||
#undef foreach
|
#undef foreach
|
||||||
|
|
||||||
|
#define foreach1(__array) \
|
||||||
|
using(__typeof__(__array[0]) *_ = __array) \
|
||||||
|
for ( uint_fast32_t SAFE_NAME(count) = dimof(__array); \
|
||||||
|
SAFE_NAME(count) > 0; \
|
||||||
|
_++, SAFE_NAME(count)-- \
|
||||||
|
)
|
||||||
|
|
||||||
#define foreach2(__type, __array) \
|
#define foreach2(__type, __array) \
|
||||||
using(__type *_ = __array) \
|
using(__type *_ = __array) \
|
||||||
for ( uint_fast32_t SAFE_NAME(count) = dimof(__array); \
|
for ( uint_fast32_t SAFE_NAME(count) = dimof(__array); \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user