1 #ifndef PYTHONIC_BUILTIN_TYPE_HPP
2 #define PYTHONIC_BUILTIN_TYPE_HPP
3 
4 #include "pythonic/include/builtins/type.hpp"
5 
6 #include "pythonic/utils/functor.hpp"
7 
8 #include "pythonic/builtins/bool_.hpp"
9 #include "pythonic/builtins/int_.hpp"
10 #include "pythonic/builtins/float_.hpp"
11 #include "pythonic/builtins/complex.hpp"
12 #include "pythonic/builtins/set.hpp"
13 #include "pythonic/builtins/str.hpp"
14 #include "pythonic/builtins/list.hpp"
15 #include "pythonic/builtins/dict.hpp"
16 #include "pythonic/builtins/tuple.hpp"
17 #include "pythonic/numpy/array.hpp"
18 #include "pythonic/numpy/byte.hpp"
19 #include "pythonic/numpy/ubyte.hpp"
20 #include "pythonic/numpy/short_.hpp"
21 #include "pythonic/numpy/ushort.hpp"
22 #include "pythonic/numpy/intc.hpp"
23 #include "pythonic/numpy/uintc.hpp"
24 #include "pythonic/numpy/int_.hpp"
25 #include "pythonic/numpy/uint.hpp"
26 #include "pythonic/numpy/longlong.hpp"
27 #include "pythonic/numpy/ulonglong.hpp"
28 #include "pythonic/numpy/float32.hpp"
29 #include "pythonic/numpy/float128.hpp"
30 
31 PYTHONIC_NS_BEGIN
32 
33 namespace builtins
34 {
35   template <>
36   struct type_functor<bool> {
37     using type = functor::bool_;
38   };
39   template <>
40   struct type_functor<double> {
41     using type = functor::float_;
42   };
43   template <>
44   struct type_functor<types::str> {
45     using type = functor::str;
46   };
47   template <class T>
48   struct type_functor<std::complex<T>> {
49     using type = functor::complex;
50   };
51   template <>
52   struct type_functor<types::empty_set> {
53     using type = functor::set;
54   };
55   template <class T>
56   struct type_functor<types::set<T>> {
57     using type = functor::set;
58   };
59   template <>
60   struct type_functor<types::empty_list> {
61     using type = functor::list;
62   };
63   template <class T>
64   struct type_functor<types::list<T>> {
65     using type = functor::list;
66   };
67   template <class T, size_t N>
68   struct type_functor<types::static_list<T, N>> {
69     using type = functor::list;
70   };
71   template <>
72   struct type_functor<types::empty_dict> {
73     using type = functor::dict;
74   };
75   template <class K, class V>
76   struct type_functor<types::dict<K, V>> {
77     using type = functor::dict;
78   };
79   template <class... Tys>
80   struct type_functor<std::tuple<Tys...>> {
81     using type = functor::tuple;
82   };
83   template <class T, size_t N>
84   struct type_functor<types::array<T, N>> {
85     using type = functor::tuple;
86   };
87   template <class T, class pS>
88   struct type_functor<types::ndarray<T, pS>> {
89     using type = numpy::functor::array;
90   };
91   template <>
92   struct type_functor<signed char> {
93     using type = numpy::functor::byte;
94   };
95   template <>
96   struct type_functor<unsigned char> {
97     using type = numpy::functor::ubyte;
98   };
99   template <>
100   struct type_functor<short> {
101     using type = numpy::functor::short_;
102   };
103   template <>
104   struct type_functor<unsigned short> {
105     using type = numpy::functor::ushort;
106   };
107   template <>
108   struct type_functor<int> {
109     using type = numpy::functor::intc;
110   };
111   template <>
112   struct type_functor<unsigned int> {
113     using type = numpy::functor::uintc;
114   };
115   template <>
116   struct type_functor<long> {
117     using type = numpy::functor::int_;
118   };
119   template <>
120   struct type_functor<unsigned long> {
121     using type = numpy::functor::uint;
122   };
123   template <>
124   struct type_functor<long long> {
125     using type = numpy::functor::longlong;
126   };
127   template <>
128   struct type_functor<unsigned long long> {
129     using type = numpy::functor::ulonglong;
130   };
131   template <>
132   struct type_functor<float> {
133     using type = numpy::functor::float32;
134   };
135   template <>
136   struct type_functor<long double> {
137     using type = numpy::functor::float128;
138   };
139 
140   template <class T>
type(T const &)141   typename type_functor<T>::type type(T const &)
142   {
143     return {};
144   }
145 }
146 PYTHONIC_NS_END
147 
148 #endif
149