-CYTypedIdentifier *Decode_(CYPool &pool, struct sig::Type *type) {
- switch (type->primitive) {
- case sig::unknown_P: return $ CYTypedIdentifier($ CYTypeError());
-
- case sig::function_P: {
- _assert(type->data.signature.count != 0);
- CYTypedParameter *parameter(NULL);
- for (size_t i(type->data.signature.count - 1); i != 0; --i)
- parameter = $ CYTypedParameter(Decode(pool, type->data.signature.elements[i].type), parameter);
- return Decode(pool, type->data.signature.elements[0].type)->Modify($ CYTypeFunctionWith(parameter));
- } break;
-
- case sig::typename_P: return $ CYTypedIdentifier($ CYTypeVariable("Class"));
- case sig::union_P: _assert(false); break;
- case sig::string_P: return $ CYTypedIdentifier($ CYTypeVariable("char"), $ CYTypePointerTo());
- case sig::selector_P: return $ CYTypedIdentifier($ CYTypeVariable("SEL"));
-
- case sig::block_P: {
- if (type->data.signature.count == 0)
- return $ CYTypedIdentifier($ CYTypeVariable("NSBlock"), $ CYTypePointerTo());
- else {
- CYTypedParameter *parameter(NULL);
- for (size_t i(type->data.signature.count - 1); i != 0; --i)
- parameter = $ CYTypedParameter(Decode(pool, type->data.signature.elements[i].type), parameter);
- return Decode(pool, type->data.signature.elements[0].type)->Modify($ CYTypeBlockWith(parameter));
- }
- } break;
-
- case sig::object_P: {
- if (type->name == NULL)
- return $ CYTypedIdentifier($ CYTypeVariable("id"));
- else
- return $ CYTypedIdentifier($ CYTypeVariable(type->name), $ CYTypePointerTo());
- } break;
-
- case sig::boolean_P: return $ CYTypedIdentifier($ CYTypeVariable("bool"));
- case sig::uchar_P: return $ CYTypedIdentifier($ CYTypeUnsigned($ CYTypeVariable("char")));
- case sig::uint_P: return $ CYTypedIdentifier($ CYTypeUnsigned($ CYTypeVariable("int")));
- case sig::ulong_P: return $ CYTypedIdentifier($ CYTypeUnsigned($ CYTypeLong($ CYTypeVariable("int"))));
- case sig::ulonglong_P: return $ CYTypedIdentifier($ CYTypeUnsigned($ CYTypeLong($ CYTypeLong($ CYTypeVariable("int")))));
- case sig::ushort_P: return $ CYTypedIdentifier($ CYTypeUnsigned($ CYTypeShort($ CYTypeVariable("int"))));
- case sig::array_P: return Decode(pool, type->data.data.type)->Modify($ CYTypeArrayOf($D(type->data.data.size)));
-
- case sig::pointer_P: {
- CYTypedIdentifier *typed;
- if (type->data.data.type == NULL)
- typed = $ CYTypedIdentifier($ CYTypeVoid());
- else
- typed = Decode(pool, type->data.data.type);
- return typed->Modify($ CYTypePointerTo());
- } break;
-
- case sig::bit_P: _assert(false); break;
- case sig::char_P: return $ CYTypedIdentifier($ CYTypeVariable("char"));
- case sig::double_P: return $ CYTypedIdentifier($ CYTypeVariable("double"));
- case sig::float_P: return $ CYTypedIdentifier($ CYTypeVariable("float"));
- case sig::int_P: return $ CYTypedIdentifier($ CYTypeVariable("int"));
- case sig::long_P: return $ CYTypedIdentifier($ CYTypeLong($ CYTypeVariable("int")));
- case sig::longlong_P: return $ CYTypedIdentifier($ CYTypeLong($ CYTypeLong($ CYTypeVariable("int"))));
- case sig::short_P: return $ CYTypedIdentifier($ CYTypeShort($ CYTypeVariable("int")));
-
- case sig::void_P: return $ CYTypedIdentifier($ CYTypeVoid());
-
- case sig::struct_P: {
- _assert(type->name != NULL);
- return $ CYTypedIdentifier($ CYTypeVariable(type->name));
- } break;
- }
+namespace sig {
+
+template <>
+CYType *Primitive<bool>::Decode(CYPool &pool) const {
+ return $ CYType($ CYTypeVariable("bool"));
+}
+
+template <>
+CYType *Primitive<char>::Decode(CYPool &pool) const {
+ return $ CYType($ CYTypeCharacter(CYTypeNeutral));
+}
+
+template <>
+CYType *Primitive<double>::Decode(CYPool &pool) const {
+ return $ CYType($ CYTypeFloating(1));
+}
+
+template <>
+CYType *Primitive<float>::Decode(CYPool &pool) const {
+ return $ CYType($ CYTypeFloating(0));
+}
+
+template <>
+CYType *Primitive<long double>::Decode(CYPool &pool) const {
+ return $ CYType($ CYTypeFloating(2));
+}
+
+template <>
+CYType *Primitive<signed char>::Decode(CYPool &pool) const {
+ return $ CYType($ CYTypeCharacter(CYTypeSigned));
+}
+
+template <>
+CYType *Primitive<signed int>::Decode(CYPool &pool) const {
+ return $ CYType($ CYTypeIntegral(CYTypeSigned, 1));
+}
+
+#ifdef __SIZEOF_INT128__
+template <>
+CYType *Primitive<signed __int128>::Decode(CYPool &pool) const {
+ return $ CYType($ CYTypeInt128(CYTypeSigned));
+}
+#endif
+
+template <>
+CYType *Primitive<signed long int>::Decode(CYPool &pool) const {
+ return $ CYType($ CYTypeIntegral(CYTypeSigned, 2));
+}
+
+template <>
+CYType *Primitive<signed long long int>::Decode(CYPool &pool) const {
+ return $ CYType($ CYTypeIntegral(CYTypeSigned, 3));
+}
+
+template <>
+CYType *Primitive<signed short int>::Decode(CYPool &pool) const {
+ return $ CYType($ CYTypeIntegral(CYTypeSigned, 0));
+}
+
+template <>
+CYType *Primitive<unsigned char>::Decode(CYPool &pool) const {
+ return $ CYType($ CYTypeCharacter(CYTypeUnsigned));
+}
+
+template <>
+CYType *Primitive<unsigned int>::Decode(CYPool &pool) const {
+ return $ CYType($ CYTypeIntegral(CYTypeUnsigned, 1));
+}
+
+#ifdef __SIZEOF_INT128__
+template <>
+CYType *Primitive<unsigned __int128>::Decode(CYPool &pool) const {
+ return $ CYType($ CYTypeInt128(CYTypeUnsigned));
+}
+#endif
+
+template <>
+CYType *Primitive<unsigned long int>::Decode(CYPool &pool) const {
+ return $ CYType($ CYTypeIntegral(CYTypeUnsigned, 2));
+}
+
+template <>
+CYType *Primitive<unsigned long long int>::Decode(CYPool &pool) const {
+ return $ CYType($ CYTypeIntegral(CYTypeUnsigned, 3));
+}
+
+template <>
+CYType *Primitive<unsigned short int>::Decode(CYPool &pool) const {
+ return $ CYType($ CYTypeIntegral(CYTypeUnsigned, 0));
+}
+
+CYType *Void::Decode(CYPool &pool) const {
+ return $ CYType($ CYTypeVoid());
+}
+
+CYType *Unknown::Decode(CYPool &pool) const {
+ return $ CYType($ CYTypeError());
+}
+
+CYType *String::Decode(CYPool &pool) const {
+ return $ CYType($ CYTypeCharacter(CYTypeNeutral), $ CYTypePointerTo());
+}
+
+#ifdef CY_OBJECTIVEC
+CYType *Meta::Decode(CYPool &pool) const {
+ return $ CYType($ CYTypeVariable("Class"));
+}