diff --git a/etk/Color.cpp b/etk/Color.cpp index 21a1bd4..adccb0b 100644 --- a/etk/Color.cpp +++ b/etk/Color.cpp @@ -10,6 +10,8 @@ #include #include #include +#include + class ColorList { public: @@ -17,6 +19,16 @@ class ColorList { etk::Color<> color; }; + +ETK_DECLARE_TYPE(etk::Color); +ETK_DECLARE_TYPE(etk::Color); +ETK_DECLARE_TYPE(etk::Color); +ETK_DECLARE_TYPE(etk::Color); +ETK_DECLARE_TYPE(etk::Color); +ETK_DECLARE_TYPE(etk::Color); +ETK_DECLARE_TYPE(etk::Color); +ETK_DECLARE_TYPE(etk::Color); + static int32_t getColorSize(); static const ColorList* getColorList(); diff --git a/etk/Number.cpp b/etk/Number.cpp index 045f62a..271676c 100644 --- a/etk/Number.cpp +++ b/etk/Number.cpp @@ -7,6 +7,8 @@ */ #include +#include +ETK_DECLARE_TYPE(etk::Number); etk::Number::Number() : m_negative(false), diff --git a/etk/archive/Archive.cpp b/etk/archive/Archive.cpp index 9a31061..8a31173 100644 --- a/etk/archive/Archive.cpp +++ b/etk/archive/Archive.cpp @@ -8,9 +8,10 @@ #include #include #include +#include static const etk::ArchiveContent g_error; - +ETK_DECLARE_TYPE(etk::Archive); const etk::String& etk::Archive::getName(size_t _id) const { ethread::UniqueLock lock(m_mutex); diff --git a/etk/archive/Zip.cpp b/etk/archive/Zip.cpp index 2c75789..6dd3655 100644 --- a/etk/archive/Zip.cpp +++ b/etk/archive/Zip.cpp @@ -9,6 +9,9 @@ #include #include #include +#include + +ETK_DECLARE_TYPE(etk::archive::Zip); etk::archive::Zip::Zip(const etk::String& _fileName, uint64_t _offset) : etk::Archive(_fileName), diff --git a/etk/etk.cpp b/etk/etk.cpp index db84391..041dede 100644 --- a/etk/etk.cpp +++ b/etk/etk.cpp @@ -10,6 +10,7 @@ #include #include #include +#include static int32_t nbTimeInit = 0; @@ -67,6 +68,10 @@ void etk::init(int _argc, const char** _argv) { TK_ERROR("Can not parse the argument : '" << data << "'"); } } + TK_INFO("ETK List of declared Types:"); + for (auto &it: etk::getListDeclaredType()) { + TK_INFO(" - " << it); + } TK_INFO("ETK system init (END)"); } diff --git a/etk/math/Matrix2x2.cpp b/etk/math/Matrix2x2.cpp index 0817c7f..f63706b 100644 --- a/etk/math/Matrix2x2.cpp +++ b/etk/math/Matrix2x2.cpp @@ -5,6 +5,9 @@ */ #include +#include + +ETK_DECLARE_TYPE(etk::Matrix2x2); etk::Stream& etk::operator <<(etk::Stream& _os, const etk::Matrix2x2& _obj) { _os << "{"; diff --git a/etk/math/Matrix2x3.cpp b/etk/math/Matrix2x3.cpp index bd267ee..5880b9d 100644 --- a/etk/math/Matrix2x3.cpp +++ b/etk/math/Matrix2x3.cpp @@ -5,6 +5,9 @@ */ #include +#include + +ETK_DECLARE_TYPE(etk::Matrix2x3); etk::Stream& etk::operator <<(etk::Stream& _os, const etk::Matrix2x3& _obj) { _os << "{"; diff --git a/etk/math/Matrix3x3.cpp b/etk/math/Matrix3x3.cpp index 0329621..d38957b 100644 --- a/etk/math/Matrix3x3.cpp +++ b/etk/math/Matrix3x3.cpp @@ -5,7 +5,8 @@ */ #include - +#include +ETK_DECLARE_TYPE(etk::Matrix3x3); etk::Stream& etk::operator <<(etk::Stream& _os, const etk::Matrix3x3& _obj) { _os << "{"; diff --git a/etk/math/Matrix4x4.cpp b/etk/math/Matrix4x4.cpp index 2e4ff7a..d1618e7 100644 --- a/etk/math/Matrix4x4.cpp +++ b/etk/math/Matrix4x4.cpp @@ -8,6 +8,9 @@ #include #include #include +#include + +ETK_DECLARE_TYPE(etk::Matrix4x4); void etk::Matrix4x4::identity() { for(int32_t iii=0; iii<4*4 ; iii++) { diff --git a/etk/math/Quaternion.cpp b/etk/math/Quaternion.cpp index 270f6bd..e4368e1 100644 --- a/etk/math/Quaternion.cpp +++ b/etk/math/Quaternion.cpp @@ -5,6 +5,9 @@ */ #include +#include + +ETK_DECLARE_TYPE(etk::Quaternion); etk::Stream& etk::operator <<(etk::Stream &_os, const etk::Quaternion& _obj) { _os << "("; diff --git a/etk/math/Transform3D.cpp b/etk/math/Transform3D.cpp index a36f3a6..440e6de 100644 --- a/etk/math/Transform3D.cpp +++ b/etk/math/Transform3D.cpp @@ -5,8 +5,9 @@ */ #include #include +#include - +ETK_DECLARE_TYPE(etk::Transform3D); etk::Transform3D::Transform3D(): m_position(vec3(0.0, 0.0, 0.0)), diff --git a/etk/math/Vector2D.cpp b/etk/math/Vector2D.cpp index 11dbc44..8ce4df0 100644 --- a/etk/math/Vector2D.cpp +++ b/etk/math/Vector2D.cpp @@ -7,6 +7,12 @@ #include #include #include +#include + +ETK_DECLARE_TYPE(etk::Vector2D); +ETK_DECLARE_TYPE(etk::Vector2D); +ETK_DECLARE_TYPE(etk::Vector2D); +ETK_DECLARE_TYPE(etk::Vector2D); etk::Stream& etk::operator <<(etk::Stream& _os, const etk::Vector2D& _obj) { _os << "("; diff --git a/etk/math/Vector3D.cpp b/etk/math/Vector3D.cpp index 1ab77c0..b32ff70 100644 --- a/etk/math/Vector3D.cpp +++ b/etk/math/Vector3D.cpp @@ -7,6 +7,12 @@ #include #include #include +#include + +ETK_DECLARE_TYPE(etk::Vector3D); +ETK_DECLARE_TYPE(etk::Vector3D); +ETK_DECLARE_TYPE(etk::Vector3D); +ETK_DECLARE_TYPE(etk::Vector3D); etk::Stream& etk::operator <<(etk::Stream& _os, const etk::Vector3D& _obj) { _os << "("; diff --git a/etk/math/Vector4D.cpp b/etk/math/Vector4D.cpp index f06dc03..4545762 100644 --- a/etk/math/Vector4D.cpp +++ b/etk/math/Vector4D.cpp @@ -5,6 +5,13 @@ */ #include +#include +#include + +ETK_DECLARE_TYPE(etk::Vector4D); +ETK_DECLARE_TYPE(etk::Vector4D); +ETK_DECLARE_TYPE(etk::Vector4D); +ETK_DECLARE_TYPE(etk::Vector4D); etk::Stream& etk::operator <<(etk::Stream &_os, const etk::Vector4D& _obj) { _os << "("; diff --git a/etk/os/FSNode.cpp b/etk/os/FSNode.cpp index a725d60..0c4db29 100644 --- a/etk/os/FSNode.cpp +++ b/etk/os/FSNode.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #ifdef __TARGET_OS__Windows #include #include @@ -37,6 +38,7 @@ extern "C" { #define TK_DBG_MODE TK_VERBOSE //#define TK_DBG_MODE TK_DEBUG +ETK_DECLARE_TYPE(etk::FSNode); #ifdef __TARGET_OS__Windows static etk::Vector getListDrive() { diff --git a/etk/os/FSNodeRight.cpp b/etk/os/FSNodeRight.cpp index 4e0ca02..f20606c 100644 --- a/etk/os/FSNodeRight.cpp +++ b/etk/os/FSNodeRight.cpp @@ -7,6 +7,7 @@ #include #include +#include // Right Flags : enum { @@ -21,6 +22,8 @@ enum { right_user_read = 1 << 8, }; +ETK_DECLARE_TYPE(etk::FSNodeRight); + etk::FSNodeRight::FSNodeRight(int16_t _newRight) : m_rights(_newRight&0x01FF) { diff --git a/etk/stdTools.cpp b/etk/stdTools.cpp index e69de29..47d1cd0 100644 --- a/etk/stdTools.cpp +++ b/etk/stdTools.cpp @@ -0,0 +1,3 @@ + +#include + diff --git a/etk/typeInfo.cpp b/etk/typeInfo.cpp new file mode 100644 index 0000000..c2eddba --- /dev/null +++ b/etk/typeInfo.cpp @@ -0,0 +1,46 @@ +/** @file + * @author Edouard DUPIN + * @copyright 2011, Edouard DUPIN, all right reserved + * @license MPL v2.0 (see license file) + */ + +#include +#include +#include +#include + +static etk::Vector& getListType() { + static etk::Vector s_list; + return s_list; +} + +const etk::Vector& etk::getListDeclaredType() { + return getListType(); +} + +size_t etk::addType(const char* _name) { + getListType().pushBack(_name); + return getListType().size(); +} + + +// declare all type of etk-base ... +ETK_DECLARE_TYPE(int8_t); +ETK_DECLARE_TYPE(int16_t); +ETK_DECLARE_TYPE(int32_t); +ETK_DECLARE_TYPE(int64_t); +ETK_DECLARE_TYPE(uint8_t); +ETK_DECLARE_TYPE(uint16_t); +ETK_DECLARE_TYPE(uint32_t); +ETK_DECLARE_TYPE(uint64_t); + +ETK_DECLARE_TYPE(char32_t); +ETK_DECLARE_TYPE(bool); +ETK_DECLARE_TYPE(float); +ETK_DECLARE_TYPE(double); + +ETK_DECLARE_TYPE(etk::String); +ETK_DECLARE_TYPE(etk::UString); +ETK_DECLARE_TYPE(etk::Stream); +ETK_DECLARE_TYPE(etk::NullPtr); + diff --git a/etk/typeInfo.hpp b/etk/typeInfo.hpp new file mode 100644 index 0000000..dfe2fec --- /dev/null +++ b/etk/typeInfo.hpp @@ -0,0 +1,53 @@ +/** @file + * @author Edouard DUPIN + * @copyright 2011, Edouard DUPIN, all right reserved + * @license MPL v2.0 (see license file) + */ + +#include +#include + +#pragma once +// in header +template +struct TypeParseTraits +{ static const char* name; }; + +// in c-file +#define REGISTER_PARSE_TYPE(X) \ + template <> const char* TypeParseTraits::name = #X + + +namespace etk { + template + class TypeTraitInfo { + public: + // Name of the Type + static const char* m_name; + // Size of the type + static const size_t m_size; + // Dynamic Usnique ID of the Type + static const size_t m_id; + }; + /** + * @brief Get list of all type declared in this software. + * @return A static list of all register type in the system. + */ + const etk::Vector& getListDeclaredType(); + /** + * @brief Add an element declared type in the system database. + * @param[in] Name of the type + * @return The Id of the Object (new unique ID) + */ + size_t addType(const char* _name); +} + +#define ETK_DECLARE_TYPE(...) template<> \ + const char* etk::TypeTraitInfo<__VA_ARGS__>::m_name = #__VA_ARGS__; \ + template<> const size_t etk::TypeTraitInfo<__VA_ARGS__>::m_size = sizeof(__VA_ARGS__); \ + template<> const size_t etk::TypeTraitInfo<__VA_ARGS__>::m_id = etk::addType(#__VA_ARGS__); + +#define ETK_GET_TYPE_NAME(...) etk::TypeTraitInfo<__VA_ARGS__>::m_name +#define ETK_GET_TYPE_SIZE(...) etk::TypeTraitInfo<__VA_ARGS__>::m_size +#define ETK_GET_TYPE_ID(...) etk::TypeTraitInfo<__VA_ARGS__>::m_id + diff --git a/lutin_etk-base.py b/lutin_etk-base.py index fac5330..bb05c6e 100644 --- a/lutin_etk-base.py +++ b/lutin_etk-base.py @@ -35,6 +35,7 @@ def configure(target, my_module): 'etk/Stream.cpp', 'etk/Function.cpp', 'etk/Allocator.cpp', + 'etk/typeInfo.cpp', ]) my_module.add_header_file([ @@ -52,6 +53,7 @@ def configure(target, my_module): 'etk/typeTrait.hpp', 'etk/Function.hpp', 'etk/NullPtr.hpp', + 'etk/typeInfo.hpp', ]) # build in C++ mode diff --git a/lutin_etk.py b/lutin_etk.py index 6f97129..14abe1b 100644 --- a/lutin_etk.py +++ b/lutin_etk.py @@ -81,6 +81,9 @@ def configure(target, my_module): 'ememory', 'etk-base', ]) + # TODO: Remove this ==> when ready to remove dependency with stl: + my_module.add_depend(['cxx']) + # add some optionnal libraries my_module.add_optionnal_depend('minizip', ["c++", "-DETK_BUILD_MINIZIP"]) my_module.add_optionnal_depend('linearmath', ["c", "-DETK_BUILD_LINEARMATH"], export=True)