pip static initializer
This commit is contained in:
@@ -3,8 +3,8 @@ cmake_policy(SET CMP0017 NEW) # need include() with .cmake
|
|||||||
project(pip)
|
project(pip)
|
||||||
set(pip_MAJOR 2)
|
set(pip_MAJOR 2)
|
||||||
set(pip_MINOR 7)
|
set(pip_MINOR 7)
|
||||||
set(pip_REVISION 0)
|
set(pip_REVISION 1)
|
||||||
set(pip_SUFFIX _beta)
|
set(pip_SUFFIX )
|
||||||
set(pip_COMPANY SHS)
|
set(pip_COMPANY SHS)
|
||||||
set(pip_DOMAIN org.SHS)
|
set(pip_DOMAIN org.SHS)
|
||||||
|
|
||||||
|
|||||||
@@ -94,6 +94,25 @@
|
|||||||
//! Macro is defined when PIP can use "rt" library for "PITimer::ThreadRT" timers implementation
|
//! Macro is defined when PIP can use "rt" library for "PITimer::ThreadRT" timers implementation
|
||||||
# define PIP_TIMER_RT
|
# define PIP_TIMER_RT
|
||||||
|
|
||||||
|
//! Macro to declare private section, export is optional
|
||||||
|
# define PRIVATE_DECLARATION(export)
|
||||||
|
|
||||||
|
//! Macro to start definition of private section
|
||||||
|
# define PRIVATE_DEFINITION_START(Class)
|
||||||
|
|
||||||
|
//! Macro to end definition of private section
|
||||||
|
# define PRIVATE_DEFINITION_END(Class)
|
||||||
|
|
||||||
|
//! Macro to access private section by pointer
|
||||||
|
# define PRIVATE
|
||||||
|
|
||||||
|
//! Macro to start static initializer
|
||||||
|
# define STATIC_INITIALIZER_BEGIN
|
||||||
|
|
||||||
|
//! Macro to end static initializer
|
||||||
|
# define STATIC_INITIALIZER_END
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
@@ -217,10 +236,29 @@
|
|||||||
#define PRIVATE (__privateinitializer__.p)
|
#define PRIVATE (__privateinitializer__.p)
|
||||||
#define PRIVATEWB __privateinitializer__.p
|
#define PRIVATEWB __privateinitializer__.p
|
||||||
|
|
||||||
|
|
||||||
#define NO_COPY_CLASS(name) \
|
#define NO_COPY_CLASS(name) \
|
||||||
name(const name&) = delete; \
|
name(const name&) = delete; \
|
||||||
name& operator=(const name&) = delete;
|
name& operator=(const name&) = delete;
|
||||||
|
|
||||||
|
|
||||||
|
#define _PIP_ADD_COUNTER_WS(a, cnt) a##cnt
|
||||||
|
#define _PIP_ADD_COUNTER_WF(a, cnt) _PIP_ADD_COUNTER_WS(a, cnt)
|
||||||
|
#define _PIP_ADD_COUNTER(a) _PIP_ADD_COUNTER_WF(a, __COUNTER__)
|
||||||
|
|
||||||
|
|
||||||
|
#define STATIC_INITIALIZER_BEGIN \
|
||||||
|
class { \
|
||||||
|
class _Initializer_ { \
|
||||||
|
public: \
|
||||||
|
_Initializer_() {
|
||||||
|
|
||||||
|
#define STATIC_INITIALIZER_END \
|
||||||
|
} \
|
||||||
|
} _initializer_; \
|
||||||
|
} _PIP_ADD_COUNTER(_pip_initializer_);
|
||||||
|
|
||||||
|
|
||||||
#ifdef FREERTOS
|
#ifdef FREERTOS
|
||||||
# define PIP_MIN_MSLEEP 10.
|
# define PIP_MIN_MSLEEP 10.
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -44,10 +44,19 @@
|
|||||||
# define ADD_NEW_TO_COLLECTION(group, class)
|
# define ADD_NEW_TO_COLLECTION(group, class)
|
||||||
|
|
||||||
#else
|
#else
|
||||||
# define ADD_TO_COLLECTION(group, object) static PICollection::CollectionAdder __##group##_##__LINE__##_##adder##__(#group, object, false);
|
|
||||||
# define ADD_TO_COLLECTION_WITH_NAME(group, object, name) static PICollection::CollectionAdder __##group##_##__LINE__##_##adder##__(#group, object, #name, false);
|
# define ADD_TO_COLLECTION(group, object) \
|
||||||
# define ADD_NEW_TO_COLLECTION(group, class) static PICollection::CollectionAdder __##group##_##class##_##adder##__(#group, new class(), true);
|
static PICollection::CollectionAdder _PIP_ADD_COUNTER(_collection_adder_)(#group, object, false);
|
||||||
# define ADD_NEW_TO_COLLECTION_WITH_NAME(group, class, name) static PICollection::CollectionAdder __##group##_##class##_##adder##__(#group, new class(), #name, true);
|
|
||||||
|
# define ADD_TO_COLLECTION_WITH_NAME(group, object, name) \
|
||||||
|
static PICollection::CollectionAdder _PIP_ADD_COUNTER(_collection_adder_)(#group, object, #name, false);
|
||||||
|
|
||||||
|
# define ADD_NEW_TO_COLLECTION(group, class) \
|
||||||
|
static PICollection::CollectionAdder _PIP_ADD_COUNTER(_collection_adder_)(#group, new class(), true);
|
||||||
|
|
||||||
|
# define ADD_NEW_TO_COLLECTION_WITH_NAME(group, class, name) \
|
||||||
|
static PICollection::CollectionAdder _PIP_ADD_COUNTER(_collection_adder_)(#group, new class(), #name, true);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class PIP_EXPORT PICollection
|
class PIP_EXPORT PICollection
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ public:
|
|||||||
static PIInit * __instance__;
|
static PIInit * __instance__;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static __PIInit_Initializer__ __piinit_initializer__;
|
||||||
|
|
||||||
|
|
||||||
class PIP_EXPORT PIInit {
|
class PIP_EXPORT PIInit {
|
||||||
friend class __PIInit_Initializer__;
|
friend class __PIInit_Initializer__;
|
||||||
@@ -67,7 +69,5 @@ private:
|
|||||||
char * file_charset;
|
char * file_charset;
|
||||||
};
|
};
|
||||||
|
|
||||||
static __PIInit_Initializer__ __piinit_initializer__;
|
|
||||||
|
|
||||||
|
|
||||||
#endif // PIINIT_H
|
#endif // PIINIT_H
|
||||||
|
|||||||
@@ -257,112 +257,92 @@
|
|||||||
|
|
||||||
|
|
||||||
#define EH_INIT0(ret, name) \
|
#define EH_INIT0(ret, name) \
|
||||||
class __##name##0_Initializer__ { \
|
STATIC_INITIALIZER_BEGIN \
|
||||||
public: \
|
PIMutexLocker ml(__meta_mutex()); \
|
||||||
__##name##0_Initializer__() { \
|
__MetaData & eh(__meta_data()[__classNameIDS()]); \
|
||||||
PIMutexLocker ml(__meta_mutex()); \
|
void * fp = (void*)(ret(*)(void*))__stat_eh_##name##__; \
|
||||||
__MetaData & eh(__meta_data()[__classNameIDS()]); \
|
void * fpV = fp; \
|
||||||
void * fp = (void*)(ret(*)(void*))__stat_eh_##name##__; \
|
if (eh.eh_set[fp]) return; \
|
||||||
void * fpV = fp; \
|
eh.eh_set << fp; \
|
||||||
if (eh.eh_set[fp]) return; \
|
__MetaFunc & f(eh.eh_func[fp]); \
|
||||||
eh.eh_set << fp; \
|
f.scope = __classNameS(); \
|
||||||
__MetaFunc & f(eh.eh_func[fp]); \
|
f.func_name = PIStringAscii(#name); \
|
||||||
f.scope = __classNameS(); \
|
f.addr = fp; \
|
||||||
f.func_name = PIStringAscii(#name); \
|
f.addrV = fpV; \
|
||||||
f.addr = fp; \
|
f.type_ret = PIStringAscii(#ret); \
|
||||||
f.addrV = fpV; \
|
STATIC_INITIALIZER_END
|
||||||
f.type_ret = PIStringAscii(#ret); \
|
|
||||||
} \
|
|
||||||
}; \
|
|
||||||
__##name##0_Initializer__ __##name##0_init__; \
|
|
||||||
|
|
||||||
#define EH_INIT1(ret, name, a0, n0) \
|
#define EH_INIT1(ret, name, a0, n0) \
|
||||||
class __##name##1##n0##_Initializer__ { \
|
STATIC_INITIALIZER_BEGIN \
|
||||||
public: \
|
PIMutexLocker ml(__meta_mutex()); \
|
||||||
__##name##1##n0##_Initializer__() { \
|
__MetaData & eh(__meta_data()[__classNameIDS()]); \
|
||||||
PIMutexLocker ml(__meta_mutex()); \
|
void * fp = (void*)(ret(*)(void*, a0))__stat_eh_##name##__; \
|
||||||
__MetaData & eh(__meta_data()[__classNameIDS()]); \
|
void * fpV = (void*)(ret(*)(void*, const PIVariant &))__stat_eh_v_##name##__; \
|
||||||
void * fp = (void*)(ret(*)(void*, a0))__stat_eh_##name##__; \
|
if (eh.eh_set[fp]) return; \
|
||||||
void * fpV = (void*)(ret(*)(void*, const PIVariant &))__stat_eh_v_##name##__; \
|
eh.eh_set << fp; \
|
||||||
if (eh.eh_set[fp]) return; \
|
__MetaFunc & f(eh.eh_func[fp]); \
|
||||||
eh.eh_set << fp; \
|
f.scope = __classNameS(); \
|
||||||
__MetaFunc & f(eh.eh_func[fp]); \
|
f.func_name = PIStringAscii(#name); \
|
||||||
f.scope = __classNameS(); \
|
f.addr = fp; \
|
||||||
f.func_name = PIStringAscii(#name); \
|
f.addrV = fpV; \
|
||||||
f.addr = fp; \
|
f.type_ret = PIStringAscii(#ret); \
|
||||||
f.addrV = fpV; \
|
f.types << PIObject::simplifyType(#a0); \
|
||||||
f.type_ret = PIStringAscii(#ret); \
|
f.names << PIStringAscii(#n0); \
|
||||||
f.types << PIObject::simplifyType(#a0); \
|
STATIC_INITIALIZER_END
|
||||||
f.names << PIStringAscii(#n0); \
|
|
||||||
} \
|
|
||||||
}; \
|
|
||||||
__##name##1##n0##_Initializer__ __##name##1##n0##_init__; \
|
|
||||||
|
|
||||||
#define EH_INIT2(ret, name, a0, n0, a1, n1) \
|
#define EH_INIT2(ret, name, a0, n0, a1, n1) \
|
||||||
class __##name##2##n0##n1##_Initializer__ { \
|
STATIC_INITIALIZER_BEGIN \
|
||||||
public: \
|
PIMutexLocker ml(__meta_mutex()); \
|
||||||
__##name##2##n0##n1##_Initializer__() { \
|
__MetaData & eh(__meta_data()[__classNameIDS()]); \
|
||||||
PIMutexLocker ml(__meta_mutex()); \
|
void * fp = (void*)(ret(*)(void*, a0, a1))__stat_eh_##name##__; \
|
||||||
__MetaData & eh(__meta_data()[__classNameIDS()]); \
|
void * fpV = (void*)(ret(*)(void*, const PIVariant &, const PIVariant &))__stat_eh_v_##name##__; \
|
||||||
void * fp = (void*)(ret(*)(void*, a0, a1))__stat_eh_##name##__; \
|
if (eh.eh_set[fp]) return; \
|
||||||
void * fpV = (void*)(ret(*)(void*, const PIVariant &, const PIVariant &))__stat_eh_v_##name##__; \
|
eh.eh_set << fp; \
|
||||||
if (eh.eh_set[fp]) return; \
|
__MetaFunc & f(eh.eh_func[fp]); \
|
||||||
eh.eh_set << fp; \
|
f.scope = __classNameS(); \
|
||||||
__MetaFunc & f(eh.eh_func[fp]); \
|
f.func_name = PIStringAscii(#name); \
|
||||||
f.scope = __classNameS(); \
|
f.addr = fp; \
|
||||||
f.func_name = PIStringAscii(#name); \
|
f.addrV = fpV; \
|
||||||
f.addr = fp; \
|
f.type_ret = PIStringAscii(#ret); \
|
||||||
f.addrV = fpV; \
|
f.types << PIObject::simplifyType(#a0) << PIObject::simplifyType(#a1); \
|
||||||
f.type_ret = PIStringAscii(#ret); \
|
f.names << PIStringAscii(#n0) << PIStringAscii(#n1); \
|
||||||
f.types << PIObject::simplifyType(#a0) << PIObject::simplifyType(#a1); \
|
STATIC_INITIALIZER_END
|
||||||
f.names << PIStringAscii(#n0) << PIStringAscii(#n1); \
|
|
||||||
} \
|
|
||||||
}; \
|
|
||||||
__##name##2##n0##n1##_Initializer__ __##name##2##n0##n1##_init__; \
|
|
||||||
|
|
||||||
#define EH_INIT3(ret, name, a0, n0, a1, n1, a2, n2) \
|
#define EH_INIT3(ret, name, a0, n0, a1, n1, a2, n2) \
|
||||||
class __##name##3##n0##n1##n2##_Initializer__ { \
|
STATIC_INITIALIZER_BEGIN \
|
||||||
public: \
|
PIMutexLocker ml(__meta_mutex()); \
|
||||||
__##name##3##n0##n1##n2##_Initializer__() { \
|
__MetaData & eh(__meta_data()[__classNameIDS()]); \
|
||||||
PIMutexLocker ml(__meta_mutex()); \
|
void * fp = (void*)(ret(*)(void*, a0, a1, a2))__stat_eh_##name##__; \
|
||||||
__MetaData & eh(__meta_data()[__classNameIDS()]); \
|
void * fpV = (void*)(ret(*)(void*, const PIVariant &, const PIVariant &, const PIVariant &))__stat_eh_v_##name##__; \
|
||||||
void * fp = (void*)(ret(*)(void*, a0, a1, a2))__stat_eh_##name##__; \
|
if (eh.eh_set[fp]) return; \
|
||||||
void * fpV = (void*)(ret(*)(void*, const PIVariant &, const PIVariant &, const PIVariant &))__stat_eh_v_##name##__; \
|
eh.eh_set << fp; \
|
||||||
if (eh.eh_set[fp]) return; \
|
__MetaFunc & f(eh.eh_func[fp]); \
|
||||||
eh.eh_set << fp; \
|
f.scope = __classNameS(); \
|
||||||
__MetaFunc & f(eh.eh_func[fp]); \
|
f.func_name = PIStringAscii(#name); \
|
||||||
f.scope = __classNameS(); \
|
f.addr = fp; \
|
||||||
f.func_name = PIStringAscii(#name); \
|
f.addrV = fpV; \
|
||||||
f.addr = fp; \
|
f.type_ret = PIStringAscii(#ret); \
|
||||||
f.addrV = fpV; \
|
f.types << PIObject::simplifyType(#a0) << PIObject::simplifyType(#a1) << PIObject::simplifyType(#a2); \
|
||||||
f.type_ret = PIStringAscii(#ret); \
|
f.names << PIStringAscii(#n0) << PIStringAscii(#n1) << PIStringAscii(#n2); \
|
||||||
f.types << PIObject::simplifyType(#a0) << PIObject::simplifyType(#a1) << PIObject::simplifyType(#a2); \
|
STATIC_INITIALIZER_END
|
||||||
f.names << PIStringAscii(#n0) << PIStringAscii(#n1) << PIStringAscii(#n2); \
|
|
||||||
} \
|
|
||||||
}; \
|
|
||||||
__##name##3##n0##n1##n2##_Initializer__ __##name##3##n0##n1##n2##_init__; \
|
|
||||||
|
|
||||||
#define EH_INIT4(ret, name, a0, n0, a1, n1, a2, n2, a3, n3) \
|
#define EH_INIT4(ret, name, a0, n0, a1, n1, a2, n2, a3, n3) \
|
||||||
class __##name##4##n0##n1##n2##n3##_Initializer__ { \
|
STATIC_INITIALIZER_BEGIN \
|
||||||
public: \
|
PIMutexLocker ml(__meta_mutex()); \
|
||||||
__##name##4##n0##n1##n2##n3##_Initializer__() { \
|
__MetaData & eh(__meta_data()[__classNameIDS()]); \
|
||||||
PIMutexLocker ml(__meta_mutex()); \
|
void * fp = (void*)(ret(*)(void*, a0, a1, a2, a3))__stat_eh_##name##__; \
|
||||||
__MetaData & eh(__meta_data()[__classNameIDS()]); \
|
void * fpV = (void*)(ret(*)(void*, const PIVariant &, const PIVariant &, const PIVariant &, const PIVariant &))__stat_eh_v_##name##__; \
|
||||||
void * fp = (void*)(ret(*)(void*, a0, a1, a2, a3))__stat_eh_##name##__; \
|
if (eh.eh_set[fp]) return; \
|
||||||
void * fpV = (void*)(ret(*)(void*, const PIVariant &, const PIVariant &, const PIVariant &, const PIVariant &))__stat_eh_v_##name##__; \
|
eh.eh_set << fp; \
|
||||||
if (eh.eh_set[fp]) return; \
|
__MetaFunc & f(eh.eh_func[fp]); \
|
||||||
eh.eh_set << fp; \
|
f.scope = __classNameS(); \
|
||||||
__MetaFunc & f(eh.eh_func[fp]); \
|
f.func_name = PIStringAscii(#name); \
|
||||||
f.scope = __classNameS(); \
|
f.addr = fp; \
|
||||||
f.func_name = PIStringAscii(#name); \
|
f.addrV = fpV; \
|
||||||
f.addr = fp; \
|
f.type_ret = PIStringAscii(#ret); \
|
||||||
f.addrV = fpV; \
|
f.types << PIObject::simplifyType(#a0) << PIObject::simplifyType(#a1) << PIObject::simplifyType(#a2) << PIObject::simplifyType(#a3); \
|
||||||
f.type_ret = PIStringAscii(#ret); \
|
f.names << PIStringAscii(#n0) << PIStringAscii(#n1) << PIStringAscii(#n2) << PIStringAscii(#n3); \
|
||||||
f.types << PIObject::simplifyType(#a0) << PIObject::simplifyType(#a1) << PIObject::simplifyType(#a2) << PIObject::simplifyType(#a3); \
|
STATIC_INITIALIZER_END
|
||||||
f.names << PIStringAscii(#n0) << PIStringAscii(#n1) << PIStringAscii(#n2) << PIStringAscii(#n3); \
|
|
||||||
} \
|
|
||||||
}; \
|
|
||||||
__##name##4##n0##n1##n2##n3##_Initializer__ __##name##4##n0##n1##n2##n3##_init__; \
|
|
||||||
|
|
||||||
|
|
||||||
#define EVENT_HANDLER0(ret, name) \
|
#define EVENT_HANDLER0(ret, name) \
|
||||||
|
|||||||
Reference in New Issue
Block a user