[DEV/DEBUG] No stl start to work (add manual type declaration (NO RTTI))
This commit is contained in:
parent
ac23f7b934
commit
a9ca40d880
@ -10,6 +10,8 @@
|
||||
#include <etk/debug.hpp>
|
||||
#include <etk/stdTools.hpp>
|
||||
#include <etk/String.hpp>
|
||||
#include <etk/typeInfo.hpp>
|
||||
|
||||
|
||||
class ColorList {
|
||||
public:
|
||||
@ -17,6 +19,16 @@ class ColorList {
|
||||
etk::Color<> color;
|
||||
};
|
||||
|
||||
|
||||
ETK_DECLARE_TYPE(etk::Color<uint8_t,4>);
|
||||
ETK_DECLARE_TYPE(etk::Color<double,4>);
|
||||
ETK_DECLARE_TYPE(etk::Color<float,4>);
|
||||
ETK_DECLARE_TYPE(etk::Color<uint32_t,4>);
|
||||
ETK_DECLARE_TYPE(etk::Color<uint8_t,3>);
|
||||
ETK_DECLARE_TYPE(etk::Color<double,3>);
|
||||
ETK_DECLARE_TYPE(etk::Color<float,3>);
|
||||
ETK_DECLARE_TYPE(etk::Color<uint32_t,3>);
|
||||
|
||||
static int32_t getColorSize();
|
||||
static const ColorList* getColorList();
|
||||
|
||||
|
@ -7,6 +7,8 @@
|
||||
*/
|
||||
|
||||
#include <etk/Number.hpp>
|
||||
#include <etk/typeInfo.hpp>
|
||||
ETK_DECLARE_TYPE(etk::Number);
|
||||
|
||||
etk::Number::Number() :
|
||||
m_negative(false),
|
||||
|
@ -8,9 +8,10 @@
|
||||
#include <etk/archive/Archive.hpp>
|
||||
#include <etk/archive/Zip.hpp>
|
||||
#include <etk/debug.hpp>
|
||||
#include <etk/typeInfo.hpp>
|
||||
|
||||
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);
|
||||
|
@ -9,6 +9,9 @@
|
||||
#include <etk/archive/Zip.hpp>
|
||||
#include <etk/types.hpp>
|
||||
#include <etk/debug.hpp>
|
||||
#include <etk/typeInfo.hpp>
|
||||
|
||||
ETK_DECLARE_TYPE(etk::archive::Zip);
|
||||
|
||||
etk::archive::Zip::Zip(const etk::String& _fileName, uint64_t _offset) :
|
||||
etk::Archive(_fileName),
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <etk/debug.hpp>
|
||||
#include <elog/elog.hpp>
|
||||
#include <etk/os/FSNode.hpp>
|
||||
#include <etk/typeInfo.hpp>
|
||||
|
||||
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)");
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,9 @@
|
||||
*/
|
||||
|
||||
#include <etk/math/Matrix2x2.hpp>
|
||||
#include <etk/typeInfo.hpp>
|
||||
|
||||
ETK_DECLARE_TYPE(etk::Matrix2x2);
|
||||
|
||||
etk::Stream& etk::operator <<(etk::Stream& _os, const etk::Matrix2x2& _obj) {
|
||||
_os << "{";
|
||||
|
@ -5,6 +5,9 @@
|
||||
*/
|
||||
|
||||
#include <etk/math/Matrix2x3.hpp>
|
||||
#include <etk/typeInfo.hpp>
|
||||
|
||||
ETK_DECLARE_TYPE(etk::Matrix2x3);
|
||||
|
||||
etk::Stream& etk::operator <<(etk::Stream& _os, const etk::Matrix2x3& _obj) {
|
||||
_os << "{";
|
||||
|
@ -5,7 +5,8 @@
|
||||
*/
|
||||
|
||||
#include <etk/math/Matrix3x3.hpp>
|
||||
|
||||
#include <etk/typeInfo.hpp>
|
||||
ETK_DECLARE_TYPE(etk::Matrix3x3);
|
||||
|
||||
etk::Stream& etk::operator <<(etk::Stream& _os, const etk::Matrix3x3& _obj) {
|
||||
_os << "{";
|
||||
|
@ -8,6 +8,9 @@
|
||||
#include <etk/math/Matrix4x4.hpp>
|
||||
#include <etk/debug.hpp>
|
||||
#include <cmath>
|
||||
#include <etk/typeInfo.hpp>
|
||||
|
||||
ETK_DECLARE_TYPE(etk::Matrix4x4);
|
||||
|
||||
void etk::Matrix4x4::identity() {
|
||||
for(int32_t iii=0; iii<4*4 ; iii++) {
|
||||
|
@ -5,6 +5,9 @@
|
||||
*/
|
||||
|
||||
#include <etk/math/Quaternion.hpp>
|
||||
#include <etk/typeInfo.hpp>
|
||||
|
||||
ETK_DECLARE_TYPE(etk::Quaternion);
|
||||
|
||||
etk::Stream& etk::operator <<(etk::Stream &_os, const etk::Quaternion& _obj) {
|
||||
_os << "(";
|
||||
|
@ -5,8 +5,9 @@
|
||||
*/
|
||||
#include <etk/types.hpp>
|
||||
#include <etk/math/Transform3D.hpp>
|
||||
#include <etk/typeInfo.hpp>
|
||||
|
||||
|
||||
ETK_DECLARE_TYPE(etk::Transform3D);
|
||||
|
||||
etk::Transform3D::Transform3D():
|
||||
m_position(vec3(0.0, 0.0, 0.0)),
|
||||
|
@ -7,6 +7,12 @@
|
||||
#include <etk/math/Vector2D.hpp>
|
||||
#include <etk/stdTools.hpp>
|
||||
#include <etk/debug.hpp>
|
||||
#include <etk/typeInfo.hpp>
|
||||
|
||||
ETK_DECLARE_TYPE(etk::Vector2D<int32_t>);
|
||||
ETK_DECLARE_TYPE(etk::Vector2D<float>);
|
||||
ETK_DECLARE_TYPE(etk::Vector2D<uint32_t>);
|
||||
ETK_DECLARE_TYPE(etk::Vector2D<bool>);
|
||||
|
||||
etk::Stream& etk::operator <<(etk::Stream& _os, const etk::Vector2D<int32_t>& _obj) {
|
||||
_os << "(";
|
||||
|
@ -7,6 +7,12 @@
|
||||
#include <etk/math/Vector3D.hpp>
|
||||
#include <etk/stdTools.hpp>
|
||||
#include <etk/debug.hpp>
|
||||
#include <etk/typeInfo.hpp>
|
||||
|
||||
ETK_DECLARE_TYPE(etk::Vector3D<int32_t>);
|
||||
ETK_DECLARE_TYPE(etk::Vector3D<float>);
|
||||
ETK_DECLARE_TYPE(etk::Vector3D<uint32_t>);
|
||||
ETK_DECLARE_TYPE(etk::Vector3D<bool>);
|
||||
|
||||
etk::Stream& etk::operator <<(etk::Stream& _os, const etk::Vector3D<int32_t>& _obj) {
|
||||
_os << "(";
|
||||
|
@ -5,6 +5,13 @@
|
||||
*/
|
||||
|
||||
#include <etk/math/Vector4D.hpp>
|
||||
#include <etk/typeInfo.hpp>
|
||||
#include <etk/String.hpp>
|
||||
|
||||
ETK_DECLARE_TYPE(etk::Vector4D<int32_t>);
|
||||
ETK_DECLARE_TYPE(etk::Vector4D<float>);
|
||||
ETK_DECLARE_TYPE(etk::Vector4D<uint32_t>);
|
||||
ETK_DECLARE_TYPE(etk::Vector4D<bool>);
|
||||
|
||||
etk::Stream& etk::operator <<(etk::Stream &_os, const etk::Vector4D<int32_t>& _obj) {
|
||||
_os << "(";
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include <etk/debug.hpp>
|
||||
#include <etk/Map.hpp>
|
||||
#include <ethread/Mutex.hpp>
|
||||
#include <etk/typeInfo.hpp>
|
||||
#ifdef __TARGET_OS__Windows
|
||||
#include <tchar.h>
|
||||
#include <windows.h>
|
||||
@ -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<etk::String> getListDrive() {
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#include <etk/os/FSNodeRight.hpp>
|
||||
#include <etk/stdTools.hpp>
|
||||
#include <etk/typeInfo.hpp>
|
||||
|
||||
// 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) {
|
||||
|
||||
|
@ -0,0 +1,3 @@
|
||||
|
||||
#include <etk/types.hpp>
|
||||
|
46
etk/typeInfo.cpp
Normal file
46
etk/typeInfo.cpp
Normal file
@ -0,0 +1,46 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <etk/typeInfo.hpp>
|
||||
#include <etk/String.hpp>
|
||||
#include <etk/UString.hpp>
|
||||
#include <etk/Stream.hpp>
|
||||
|
||||
static etk::Vector<const char*>& getListType() {
|
||||
static etk::Vector<const char*> s_list;
|
||||
return s_list;
|
||||
}
|
||||
|
||||
const etk::Vector<const char*>& 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);
|
||||
|
53
etk/typeInfo.hpp
Normal file
53
etk/typeInfo.hpp
Normal file
@ -0,0 +1,53 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <etk/types.hpp>
|
||||
#include <etk/Vector.hpp>
|
||||
|
||||
#pragma once
|
||||
// in header
|
||||
template<typename T>
|
||||
struct TypeParseTraits
|
||||
{ static const char* name; };
|
||||
|
||||
// in c-file
|
||||
#define REGISTER_PARSE_TYPE(X) \
|
||||
template <> const char* TypeParseTraits<X>::name = #X
|
||||
|
||||
|
||||
namespace etk {
|
||||
template<typename ETK_TYPE>
|
||||
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<const char*>& 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
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user