xo-reflect: + reflect builtin c++ types (int ..) automatically
This commit is contained in:
parent
05c94a3105
commit
57a75e380f
2 changed files with 30 additions and 0 deletions
|
|
@ -200,6 +200,8 @@ namespace xo {
|
|||
|
||||
/** print table of reflected types to os **/
|
||||
static void print_reflected_types(std::ostream & os);
|
||||
/** print table of function types to os **/
|
||||
static void print_function_types(std::ostream & os);
|
||||
|
||||
TypeId id() const { return id_; }
|
||||
const std::type_info * native_typeinfo() const { return native_typeinfo_; }
|
||||
|
|
@ -470,6 +472,19 @@ namespace xo {
|
|||
return os;
|
||||
}
|
||||
|
||||
class TypeDescrTable {
|
||||
public:
|
||||
TypeDescrTable * instance() { return &s_instance; }
|
||||
|
||||
private:
|
||||
/** initialize with builtin atomic types:
|
||||
* float, double, char, short, int, long, bool
|
||||
**/
|
||||
TypeDescrTable();
|
||||
|
||||
private:
|
||||
static TypeDescrTable s_instance;
|
||||
};
|
||||
} /*namespace reflect*/
|
||||
} /*namespace xo*/
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
#include "TypeDescr.hpp"
|
||||
#include "TaggedPtr.hpp"
|
||||
#include "TypeDescrExtra.hpp"
|
||||
#include "Reflect.hpp"
|
||||
#include "atomic/AtomicTdx.hpp"
|
||||
#include "function/FunctionTdx.hpp"
|
||||
#include "xo/indentlog/scope.hpp"
|
||||
|
|
@ -301,6 +302,20 @@ namespace xo {
|
|||
this->complete_flag_ = true;
|
||||
this->tdextra_ = std::move(tdx);
|
||||
} /*assign_tdextra*/
|
||||
|
||||
TypeDescrTable::TypeDescrTable() {
|
||||
Reflect::require<bool>();
|
||||
Reflect::require<char>();
|
||||
Reflect::require<short>();
|
||||
Reflect::require<int>();
|
||||
Reflect::require<long>();
|
||||
Reflect::require<long long>();
|
||||
Reflect::require<float>();
|
||||
Reflect::require<double>();
|
||||
} /*ctor*/
|
||||
|
||||
TypeDescrTable
|
||||
TypeDescrTable::s_instance;
|
||||
} /*namespace reflect*/
|
||||
} /*namespace xo*/
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue