]>
Commit | Line | Data |
---|---|---|
bd3239d2 MF |
1 | class QString { public: inline QString(const int i);}; |
2 | class QGenericArgument {}; | |
3 | class ExtensionOption {}; | |
4 | template< typename T2 > struct if_ { | |
5 | typedef T2 type; | |
6 | }; | |
7 | template <typename T> struct c_imp { | |
8 | typedef const T& param_type; | |
9 | }; | |
10 | template <typename T> struct call_traits { | |
11 | typedef typename c_imp< T >::param_type param_type; | |
12 | }; | |
13 | class object; | |
14 | template <class T> struct rvalue_from_python_storage {}; | |
15 | template <class T> struct rvalue_from_python_data : rvalue_from_python_storage<T> { | |
16 | ~rvalue_from_python_data(); | |
17 | }; | |
18 | template <class T> struct extract_rvalue { | |
19 | typedef typename if_<typename call_traits<T>::param_type >::type result_type; | |
20 | mutable rvalue_from_python_data<T> m_data; | |
21 | }; | |
22 | template <class T> struct select_extract { | |
23 | typedef typename if_< extract_rvalue<T> >::type type; | |
24 | }; | |
25 | ||
26 | template <class T> struct extract : select_extract<T>::type { | |
27 | private: typedef typename select_extract<T>::type base; | |
28 | public: typedef typename base::result_type result_type; | |
29 | operator result_type() const {} | |
30 | extract(object const&); | |
31 | }; | |
32 | ||
33 | template <class Key, class T> class QHash { | |
34 | public: inline QHash() {} | |
35 | T &operator[](const Key &key); | |
36 | }; | |
37 | class type_details { | |
38 | typedef QGenericArgument(*func_python_to_cpp_type)(const object&); | |
39 | public: | |
40 | template<typename T> static type_details* create_value_type_details() { | |
41 | type_details* self = new type_details(); | |
42 | self->m_func_python_to_cpp = &python_to_value_type<T>; | |
43 | } | |
44 | func_python_to_cpp_type m_func_python_to_cpp; | |
45 | template <class T> static QGenericArgument python_to_value_type(const object& obj) { | |
46 | T* val = new T(extract<T>(obj)); | |
47 | } | |
48 | }; | |
49 | class type_manager { | |
50 | public: static type_manager& instance(); | |
51 | template<typename T> void register_value_type() { | |
52 | m_type_map[0] = type_details::create_value_type_details<T>(); | |
53 | } | |
54 | QHash<QString, type_details* > m_type_map; | |
55 | }; | |
56 | void foo() { | |
57 | type_manager::instance().register_value_type<ExtensionOption >(); | |
58 | } |