__PIP_TYPENAME_DECLARE
This commit is contained in:
@@ -231,7 +231,36 @@ extern char ** environ;
|
|||||||
# if PIP_HAS_RTTI
|
# if PIP_HAS_RTTI
|
||||||
# define __PIP_TYPENAME__(T) typeid(T).name()
|
# define __PIP_TYPENAME__(T) typeid(T).name()
|
||||||
# else
|
# else
|
||||||
# define __PIP_TYPENAME__(T) "?"
|
template<typename T>
|
||||||
|
inline const char * __pip_typename__() {
|
||||||
|
static_assert(false, "this type must declare typename via __PIP_TYPENAME_DECLARE");
|
||||||
|
return "?";
|
||||||
|
}
|
||||||
|
|
||||||
|
# define __PIP_TYPENAME_DECLARE(T, NAME) \
|
||||||
|
template<> \
|
||||||
|
inline const char * __pip_typename__<T>() { \
|
||||||
|
return NAME; \
|
||||||
|
}
|
||||||
|
|
||||||
|
__PIP_TYPENAME_DECLARE(bool, "bool")
|
||||||
|
__PIP_TYPENAME_DECLARE(char, "char")
|
||||||
|
__PIP_TYPENAME_DECLARE(signed char, "signed char")
|
||||||
|
__PIP_TYPENAME_DECLARE(unsigned char, "unsigned char")
|
||||||
|
__PIP_TYPENAME_DECLARE(short, "short")
|
||||||
|
__PIP_TYPENAME_DECLARE(unsigned short, "unsigned short")
|
||||||
|
__PIP_TYPENAME_DECLARE(int, "int")
|
||||||
|
__PIP_TYPENAME_DECLARE(unsigned int, "unsigned int")
|
||||||
|
__PIP_TYPENAME_DECLARE(long, "long")
|
||||||
|
__PIP_TYPENAME_DECLARE(unsigned long, "unsigned long")
|
||||||
|
__PIP_TYPENAME_DECLARE(long long, "long long")
|
||||||
|
__PIP_TYPENAME_DECLARE(unsigned long long, "unsigned long long")
|
||||||
|
__PIP_TYPENAME_DECLARE(float, "float")
|
||||||
|
__PIP_TYPENAME_DECLARE(double, "double")
|
||||||
|
__PIP_TYPENAME_DECLARE(long double, "long double")
|
||||||
|
__PIP_TYPENAME_DECLARE(void, "void")
|
||||||
|
|
||||||
|
# define __PIP_TYPENAME__(T) __pip_typename__<T>()
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# ifdef CC_GCC
|
# ifdef CC_GCC
|
||||||
|
|||||||
@@ -381,4 +381,9 @@ inline PIGeoPosition operator*(const PIGeoPosition & left, const int & scale) {
|
|||||||
return operator*(double(scale), left);
|
return operator*(double(scale), left);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if !PIP_HAS_RTTI
|
||||||
|
__PIP_TYPENAME_DECLARE(PIGeoPosition, "PIGeoPosition")
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // PIGEOPOSITION_H
|
#endif // PIGEOPOSITION_H
|
||||||
|
|||||||
@@ -210,4 +210,12 @@ typedef PILine<float> PILinef;
|
|||||||
//! \~russian Псевдоним отрезка с координатами типа `double`.
|
//! \~russian Псевдоним отрезка с координатами типа `double`.
|
||||||
typedef PILine<double> PILined;
|
typedef PILine<double> PILined;
|
||||||
|
|
||||||
|
|
||||||
|
#if !PIP_HAS_RTTI
|
||||||
|
__PIP_TYPENAME_DECLARE(PILined, "PILined")
|
||||||
|
__PIP_TYPENAME_DECLARE(PILinei, "PILinei")
|
||||||
|
__PIP_TYPENAME_DECLARE(PILinef, "PILinef")
|
||||||
|
__PIP_TYPENAME_DECLARE(PILineu, "PILineu")
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // PILINE_H
|
#endif // PILINE_H
|
||||||
|
|||||||
@@ -186,4 +186,11 @@ inline bool PIMathFloatNullCompare(const T v) {
|
|||||||
return (abs(v) < float(1E-200));
|
return (abs(v) < float(1E-200));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if !PIP_HAS_RTTI
|
||||||
|
__PIP_TYPENAME_DECLARE(complexf, "complexf")
|
||||||
|
__PIP_TYPENAME_DECLARE(complexd, "complexd")
|
||||||
|
__PIP_TYPENAME_DECLARE(complexld, "complexld")
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // PIMATHCOMPLEX_H
|
#endif // PIMATHCOMPLEX_H
|
||||||
|
|||||||
@@ -1652,6 +1652,12 @@ PIMathMatrix<complex<T>> hermitian(const PIMathMatrix<complex<T>> & m) {
|
|||||||
return ret.transposed();
|
return ret.transposed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if !PIP_HAS_RTTI
|
||||||
|
__PIP_TYPENAME_DECLARE(PIMathMatrixd, "PIMathMatrixd")
|
||||||
|
__PIP_TYPENAME_DECLARE(PIMathMatrixi, "PIMathMatrixi")
|
||||||
|
#endif
|
||||||
|
|
||||||
#undef PIMM_FOR
|
#undef PIMM_FOR
|
||||||
#undef PIMM_FOR_A
|
#undef PIMM_FOR_A
|
||||||
#undef PIMM_FOR_C
|
#undef PIMM_FOR_C
|
||||||
|
|||||||
@@ -909,4 +909,10 @@ typedef PIMathVector<int> PIMathVectori;
|
|||||||
//! \~russian Динамический вектор из \c double.
|
//! \~russian Динамический вектор из \c double.
|
||||||
typedef PIMathVector<double> PIMathVectord;
|
typedef PIMathVector<double> PIMathVectord;
|
||||||
|
|
||||||
|
|
||||||
|
#if !PIP_HAS_RTTI
|
||||||
|
__PIP_TYPENAME_DECLARE(PIMathVectord, "PIMathVectord")
|
||||||
|
__PIP_TYPENAME_DECLARE(PIMathVectori, "PIMathVectori")
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // PIMATHVECTOR_H
|
#endif // PIMATHVECTOR_H
|
||||||
|
|||||||
@@ -286,4 +286,12 @@ typedef PIPoint<float> PIPointf;
|
|||||||
//! \~russian Псевдоним точки с координатами типа `double`.
|
//! \~russian Псевдоним точки с координатами типа `double`.
|
||||||
typedef PIPoint<double> PIPointd;
|
typedef PIPoint<double> PIPointd;
|
||||||
|
|
||||||
|
|
||||||
|
#if !PIP_HAS_RTTI
|
||||||
|
__PIP_TYPENAME_DECLARE(PIPointd, "PIPointd")
|
||||||
|
__PIP_TYPENAME_DECLARE(PIPointi, "PIPointi")
|
||||||
|
__PIP_TYPENAME_DECLARE(PIPointf, "PIPointf")
|
||||||
|
__PIP_TYPENAME_DECLARE(PIPointu, "PIPointu")
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // PIPOINT_H
|
#endif // PIPOINT_H
|
||||||
|
|||||||
@@ -444,4 +444,12 @@ typedef PIRect<float> PIRectf;
|
|||||||
//! \~russian Псевдоним прямоугольника с координатами типа `double`.
|
//! \~russian Псевдоним прямоугольника с координатами типа `double`.
|
||||||
typedef PIRect<double> PIRectd;
|
typedef PIRect<double> PIRectd;
|
||||||
|
|
||||||
|
|
||||||
|
#if !PIP_HAS_RTTI
|
||||||
|
__PIP_TYPENAME_DECLARE(PIRectd, "PIRectd")
|
||||||
|
__PIP_TYPENAME_DECLARE(PIRecti, "PIRecti")
|
||||||
|
__PIP_TYPENAME_DECLARE(PIRectf, "PIRectf")
|
||||||
|
__PIP_TYPENAME_DECLARE(PIRectu, "PIRectu")
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // PIRECT_H
|
#endif // PIRECT_H
|
||||||
|
|||||||
@@ -270,4 +270,9 @@ inline bool operator<=(ushort v, const PIChar & c) {
|
|||||||
return (PIChar(v) <= c);
|
return (PIChar(v) <= c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if !PIP_HAS_RTTI
|
||||||
|
__PIP_TYPENAME_DECLARE(PIChar, "PIChar")
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // PICHAR_H
|
#endif // PICHAR_H
|
||||||
|
|||||||
@@ -2052,4 +2052,8 @@ inline PIString piStringify(const T & v) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if !PIP_HAS_RTTI
|
||||||
|
__PIP_TYPENAME_DECLARE(PIString, "PIString")
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // PISTRING_H
|
#endif // PISTRING_H
|
||||||
|
|||||||
@@ -216,4 +216,9 @@ inline PICout operator<<(PICout s, const PIStringList & v) {
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if !PIP_HAS_RTTI
|
||||||
|
__PIP_TYPENAME_DECLARE(PIStringList, "PIStringList")
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // PISTRINGLIST_H
|
#endif // PISTRINGLIST_H
|
||||||
|
|||||||
@@ -309,4 +309,9 @@ private:
|
|||||||
//! \~russian Оператор вывода в \a PICout
|
//! \~russian Оператор вывода в \a PICout
|
||||||
PIP_EXPORT PICout operator<<(PICout s, const PIBitArray & ba);
|
PIP_EXPORT PICout operator<<(PICout s, const PIBitArray & ba);
|
||||||
|
|
||||||
|
|
||||||
|
#if !PIP_HAS_RTTI
|
||||||
|
__PIP_TYPENAME_DECLARE(PIBitArray, "PIBitArray")
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // PIBITARRAY_H
|
#endif // PIBITARRAY_H
|
||||||
|
|||||||
@@ -1362,4 +1362,8 @@ T piDeserialize(const PIByteArray & data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if !PIP_HAS_RTTI
|
||||||
|
__PIP_TYPENAME_DECLARE(PIByteArray, "PIByteArray")
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // PIBYTEARRAY_H
|
#endif // PIBYTEARRAY_H
|
||||||
|
|||||||
@@ -404,4 +404,10 @@ inline bool operator>=(const PIDateTime & t0, const PIDateTime & t1) {
|
|||||||
PIP_EXPORT PICout operator<<(PICout s, const PIDateTime & v);
|
PIP_EXPORT PICout operator<<(PICout s, const PIDateTime & v);
|
||||||
|
|
||||||
|
|
||||||
|
#if !PIP_HAS_RTTI
|
||||||
|
__PIP_TYPENAME_DECLARE(PITime, "PITime")
|
||||||
|
__PIP_TYPENAME_DECLARE(PIDate, "PIDate")
|
||||||
|
__PIP_TYPENAME_DECLARE(PIDateTime, "PIDateTime")
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // PIDATETIME_H
|
#endif // PIDATETIME_H
|
||||||
|
|||||||
@@ -141,4 +141,8 @@ inline PICout operator<<(PICout s, const PINetworkAddress & v) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if !PIP_HAS_RTTI
|
||||||
|
__PIP_TYPENAME_DECLARE(PINetworkAddress, "PINetworkAddress")
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // PINETWORKADDRESS_H
|
#endif // PINETWORKADDRESS_H
|
||||||
|
|||||||
@@ -520,4 +520,9 @@ private:
|
|||||||
PISystemTime t_st;
|
PISystemTime t_st;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#if !PIP_HAS_RTTI
|
||||||
|
__PIP_TYPENAME_DECLARE(PISystemTime, "PISystemTime")
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // PITIME_H
|
#endif // PITIME_H
|
||||||
|
|||||||
@@ -27,11 +27,6 @@
|
|||||||
|
|
||||||
#include "pistring.h"
|
#include "pistring.h"
|
||||||
|
|
||||||
#include <typeinfo>
|
|
||||||
#if !defined(__GXX_RTTI__) && !defined(__RTTI__)
|
|
||||||
# include "pivariant.h"
|
|
||||||
#endif // !defined(__GXX_RTTI__) && !defined(__RTTI__)
|
|
||||||
|
|
||||||
|
|
||||||
class __VariantFunctionsBase__ {
|
class __VariantFunctionsBase__ {
|
||||||
public:
|
public:
|
||||||
@@ -52,21 +47,10 @@ public:
|
|||||||
static __VariantFunctions__<T> ret;
|
static __VariantFunctions__<T> ret;
|
||||||
return &ret;
|
return &ret;
|
||||||
}
|
}
|
||||||
#if !defined(__GXX_RTTI__) && !defined(__RTTI__)
|
|
||||||
PIString typeName() const final {
|
PIString typeName() const final {
|
||||||
static PIString ret(PIVariant::fromValue<T>(T()).typeName());
|
static PIString ret(__PIP_TYPENAME__(T));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
PIString typeName() const final {
|
|
||||||
# if defined(__GXX_RTTI__) || defined(__RTTI__)
|
|
||||||
static PIString ret(typeid(T).name());
|
|
||||||
# else
|
|
||||||
static PIString ret("unknown");
|
|
||||||
# endif
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
#endif // !defined(__GXX_RTTI__) && !defined(__RTTI__)
|
|
||||||
uint hash() const final {
|
uint hash() const final {
|
||||||
static uint ret = typeName().hash();
|
static uint ret = typeName().hash();
|
||||||
return ret;
|
return ret;
|
||||||
@@ -198,10 +182,18 @@ public:
|
|||||||
static uint ret = typeName().hash(); \
|
static uint ret = typeName().hash(); \
|
||||||
return ret; \
|
return ret; \
|
||||||
} \
|
} \
|
||||||
void newT(void *& ptr, const void * value) final { ptr = (void *)(new Type(*(const Type *)value)); } \
|
void newT(void *& ptr, const void * value) final { \
|
||||||
void newNullT(void *& ptr) final { ptr = (void *)(new Type()); } \
|
ptr = (void *)(new Type(*(const Type *)value)); \
|
||||||
void assignT(void *& ptr, const void * value) final { *(Type *)ptr = *(const Type *)value; } \
|
} \
|
||||||
void deleteT(void *& ptr) final { delete (Type *)(ptr); } \
|
void newNullT(void *& ptr) final { \
|
||||||
|
ptr = (void *)(new Type()); \
|
||||||
|
} \
|
||||||
|
void assignT(void *& ptr, const void * value) final { \
|
||||||
|
*(Type *)ptr = *(const Type *)value; \
|
||||||
|
} \
|
||||||
|
void deleteT(void *& ptr) final { \
|
||||||
|
delete (Type *)(ptr); \
|
||||||
|
} \
|
||||||
};
|
};
|
||||||
|
|
||||||
REGISTER_PIVARIANTSIMPLE(std::function<void(void *)>)
|
REGISTER_PIVARIANTSIMPLE(std::function<void(void *)>)
|
||||||
|
|||||||
Reference in New Issue
Block a user