pip static initializer
This commit is contained in:
@@ -3,8 +3,8 @@ cmake_policy(SET CMP0017 NEW) # need include() with .cmake
|
||||
project(pip)
|
||||
set(pip_MAJOR 2)
|
||||
set(pip_MINOR 7)
|
||||
set(pip_REVISION 0)
|
||||
set(pip_SUFFIX _beta)
|
||||
set(pip_REVISION 1)
|
||||
set(pip_SUFFIX )
|
||||
set(pip_COMPANY SHS)
|
||||
set(pip_DOMAIN org.SHS)
|
||||
|
||||
|
||||
@@ -94,6 +94,25 @@
|
||||
//! Macro is defined when PIP can use "rt" library for "PITimer::ThreadRT" timers implementation
|
||||
# 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
|
||||
|
||||
#include <functional>
|
||||
@@ -217,10 +236,29 @@
|
||||
#define PRIVATE (__privateinitializer__.p)
|
||||
#define PRIVATEWB __privateinitializer__.p
|
||||
|
||||
|
||||
#define NO_COPY_CLASS(name) \
|
||||
name(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
|
||||
# define PIP_MIN_MSLEEP 10.
|
||||
#else
|
||||
|
||||
@@ -44,10 +44,19 @@
|
||||
# define ADD_NEW_TO_COLLECTION(group, class)
|
||||
|
||||
#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_NEW_TO_COLLECTION(group, class) static PICollection::CollectionAdder __##group##_##class##_##adder##__(#group, new class(), true);
|
||||
# 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(group, object) \
|
||||
static PICollection::CollectionAdder _PIP_ADD_COUNTER(_collection_adder_)(#group, object, false);
|
||||
|
||||
# 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
|
||||
|
||||
class PIP_EXPORT PICollection
|
||||
|
||||
@@ -38,6 +38,8 @@ public:
|
||||
static PIInit * __instance__;
|
||||
};
|
||||
|
||||
static __PIInit_Initializer__ __piinit_initializer__;
|
||||
|
||||
|
||||
class PIP_EXPORT PIInit {
|
||||
friend class __PIInit_Initializer__;
|
||||
@@ -67,7 +69,5 @@ private:
|
||||
char * file_charset;
|
||||
};
|
||||
|
||||
static __PIInit_Initializer__ __piinit_initializer__;
|
||||
|
||||
|
||||
#endif // PIINIT_H
|
||||
|
||||
@@ -257,9 +257,7 @@
|
||||
|
||||
|
||||
#define EH_INIT0(ret, name) \
|
||||
class __##name##0_Initializer__ { \
|
||||
public: \
|
||||
__##name##0_Initializer__() { \
|
||||
STATIC_INITIALIZER_BEGIN \
|
||||
PIMutexLocker ml(__meta_mutex()); \
|
||||
__MetaData & eh(__meta_data()[__classNameIDS()]); \
|
||||
void * fp = (void*)(ret(*)(void*))__stat_eh_##name##__; \
|
||||
@@ -272,14 +270,10 @@
|
||||
f.addr = fp; \
|
||||
f.addrV = fpV; \
|
||||
f.type_ret = PIStringAscii(#ret); \
|
||||
} \
|
||||
}; \
|
||||
__##name##0_Initializer__ __##name##0_init__; \
|
||||
STATIC_INITIALIZER_END
|
||||
|
||||
#define EH_INIT1(ret, name, a0, n0) \
|
||||
class __##name##1##n0##_Initializer__ { \
|
||||
public: \
|
||||
__##name##1##n0##_Initializer__() { \
|
||||
STATIC_INITIALIZER_BEGIN \
|
||||
PIMutexLocker ml(__meta_mutex()); \
|
||||
__MetaData & eh(__meta_data()[__classNameIDS()]); \
|
||||
void * fp = (void*)(ret(*)(void*, a0))__stat_eh_##name##__; \
|
||||
@@ -294,14 +288,10 @@
|
||||
f.type_ret = PIStringAscii(#ret); \
|
||||
f.types << PIObject::simplifyType(#a0); \
|
||||
f.names << PIStringAscii(#n0); \
|
||||
} \
|
||||
}; \
|
||||
__##name##1##n0##_Initializer__ __##name##1##n0##_init__; \
|
||||
STATIC_INITIALIZER_END
|
||||
|
||||
#define EH_INIT2(ret, name, a0, n0, a1, n1) \
|
||||
class __##name##2##n0##n1##_Initializer__ { \
|
||||
public: \
|
||||
__##name##2##n0##n1##_Initializer__() { \
|
||||
STATIC_INITIALIZER_BEGIN \
|
||||
PIMutexLocker ml(__meta_mutex()); \
|
||||
__MetaData & eh(__meta_data()[__classNameIDS()]); \
|
||||
void * fp = (void*)(ret(*)(void*, a0, a1))__stat_eh_##name##__; \
|
||||
@@ -316,14 +306,10 @@
|
||||
f.type_ret = PIStringAscii(#ret); \
|
||||
f.types << PIObject::simplifyType(#a0) << PIObject::simplifyType(#a1); \
|
||||
f.names << PIStringAscii(#n0) << PIStringAscii(#n1); \
|
||||
} \
|
||||
}; \
|
||||
__##name##2##n0##n1##_Initializer__ __##name##2##n0##n1##_init__; \
|
||||
STATIC_INITIALIZER_END
|
||||
|
||||
#define EH_INIT3(ret, name, a0, n0, a1, n1, a2, n2) \
|
||||
class __##name##3##n0##n1##n2##_Initializer__ { \
|
||||
public: \
|
||||
__##name##3##n0##n1##n2##_Initializer__() { \
|
||||
STATIC_INITIALIZER_BEGIN \
|
||||
PIMutexLocker ml(__meta_mutex()); \
|
||||
__MetaData & eh(__meta_data()[__classNameIDS()]); \
|
||||
void * fp = (void*)(ret(*)(void*, a0, a1, a2))__stat_eh_##name##__; \
|
||||
@@ -338,14 +324,10 @@
|
||||
f.type_ret = PIStringAscii(#ret); \
|
||||
f.types << PIObject::simplifyType(#a0) << PIObject::simplifyType(#a1) << PIObject::simplifyType(#a2); \
|
||||
f.names << PIStringAscii(#n0) << PIStringAscii(#n1) << PIStringAscii(#n2); \
|
||||
} \
|
||||
}; \
|
||||
__##name##3##n0##n1##n2##_Initializer__ __##name##3##n0##n1##n2##_init__; \
|
||||
STATIC_INITIALIZER_END
|
||||
|
||||
#define EH_INIT4(ret, name, a0, n0, a1, n1, a2, n2, a3, n3) \
|
||||
class __##name##4##n0##n1##n2##n3##_Initializer__ { \
|
||||
public: \
|
||||
__##name##4##n0##n1##n2##n3##_Initializer__() { \
|
||||
STATIC_INITIALIZER_BEGIN \
|
||||
PIMutexLocker ml(__meta_mutex()); \
|
||||
__MetaData & eh(__meta_data()[__classNameIDS()]); \
|
||||
void * fp = (void*)(ret(*)(void*, a0, a1, a2, a3))__stat_eh_##name##__; \
|
||||
@@ -360,9 +342,7 @@
|
||||
f.type_ret = PIStringAscii(#ret); \
|
||||
f.types << PIObject::simplifyType(#a0) << PIObject::simplifyType(#a1) << PIObject::simplifyType(#a2) << PIObject::simplifyType(#a3); \
|
||||
f.names << PIStringAscii(#n0) << PIStringAscii(#n1) << PIStringAscii(#n2) << PIStringAscii(#n3); \
|
||||
} \
|
||||
}; \
|
||||
__##name##4##n0##n1##n2##n3##_Initializer__ __##name##4##n0##n1##n2##n3##_init__; \
|
||||
STATIC_INITIALIZER_END
|
||||
|
||||
|
||||
#define EVENT_HANDLER0(ret, name) \
|
||||
|
||||
Reference in New Issue
Block a user