-CYTypedIdentifier *Decode_(CYPool &pool, struct sig::Type *type) {
- switch (type->primitive) {
- 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($V("Class"));
- case sig::union_P: _assert(false); break;
- case sig::string_P: return $ CYTypedIdentifier($V("char"), $ CYTypePointerTo());
- case sig::selector_P: return $ CYTypedIdentifier($V("SEL"));
- case sig::block_P: _assert(false); break;
-
- case sig::object_P: {
- if (type->name == NULL)
- return $ CYTypedIdentifier($V("id"));
- else
- return $ CYTypedIdentifier($V(type->name), $ CYTypePointerTo());
- } break;
-
- case sig::boolean_P: return $ CYTypedIdentifier($V("bool"));
- case sig::uchar_P: return $ CYTypedIdentifier($V("uchar"));
- case sig::uint_P: return $ CYTypedIdentifier($V("uint"));
- case sig::ulong_P: return $ CYTypedIdentifier($V("ulong"));
- case sig::ulonglong_P: return $ CYTypedIdentifier($V("ulonglong"));
- case sig::ushort_P: return $ CYTypedIdentifier($V("ushort"));
- case sig::array_P: return Decode(pool, type->data.data.type)->Modify($ CYTypeArrayOf($D(type->data.data.size)));
-
- // XXX: once again, the issue of void here is incorrect
- case sig::pointer_P: {
- CYTypedIdentifier *typed;
- if (type->data.data.type == NULL)
- typed = $ CYTypedIdentifier($V("void"));
- 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($V("char"));
- case sig::double_P: return $ CYTypedIdentifier($V("double"));
- case sig::float_P: return $ CYTypedIdentifier($V("float"));
- case sig::int_P: return $ CYTypedIdentifier($V("int"));
- case sig::long_P: return $ CYTypedIdentifier($V("long"));
- case sig::longlong_P: return $ CYTypedIdentifier($V("longlong"));
- case sig::short_P: return $ CYTypedIdentifier($V("short"));
-
- // XXX: this happens to work, but is totally wrong
- case sig::void_P: return $ CYTypedIdentifier($V("void"));
-
- case sig::struct_P: {
- _assert(type->name != NULL);
- return $ CYTypedIdentifier($V(type->name));
- } break;
- }
+namespace sig {
+
+template <>
+CYTypedIdentifier *Primitive<bool>::Decode(CYPool &pool) const {
+ return $ CYTypedIdentifier($ CYTypeVariable("bool"));
+}
+
+template <>
+CYTypedIdentifier *Primitive<char>::Decode(CYPool &pool) const {
+ return $ CYTypedIdentifier($ CYTypeCharacter(CYTypeNeutral));
+}
+
+template <>
+CYTypedIdentifier *Primitive<double>::Decode(CYPool &pool) const {
+ return $ CYTypedIdentifier($ CYTypeVariable("double"));
+}
+
+template <>
+CYTypedIdentifier *Primitive<float>::Decode(CYPool &pool) const {
+ return $ CYTypedIdentifier($ CYTypeVariable("float"));
+}
+
+template <>
+CYTypedIdentifier *Primitive<signed char>::Decode(CYPool &pool) const {
+ return $ CYTypedIdentifier($ CYTypeCharacter(CYTypeSigned));
+}
+
+template <>
+CYTypedIdentifier *Primitive<signed int>::Decode(CYPool &pool) const {
+ return $ CYTypedIdentifier($ CYTypeIntegral(CYTypeSigned, 1));
+}
+
+template <>
+CYTypedIdentifier *Primitive<signed long int>::Decode(CYPool &pool) const {
+ return $ CYTypedIdentifier($ CYTypeIntegral(CYTypeSigned, 2));
+}
+
+template <>
+CYTypedIdentifier *Primitive<signed long long int>::Decode(CYPool &pool) const {
+ return $ CYTypedIdentifier($ CYTypeIntegral(CYTypeSigned, 3));
+}
+
+template <>
+CYTypedIdentifier *Primitive<signed short int>::Decode(CYPool &pool) const {
+ return $ CYTypedIdentifier($ CYTypeIntegral(CYTypeSigned, 0));
+}
+
+template <>
+CYTypedIdentifier *Primitive<unsigned char>::Decode(CYPool &pool) const {
+ return $ CYTypedIdentifier($ CYTypeCharacter(CYTypeUnsigned));
+}
+
+template <>
+CYTypedIdentifier *Primitive<unsigned int>::Decode(CYPool &pool) const {
+ return $ CYTypedIdentifier($ CYTypeIntegral(CYTypeUnsigned, 1));
+}
+
+template <>
+CYTypedIdentifier *Primitive<unsigned long int>::Decode(CYPool &pool) const {
+ return $ CYTypedIdentifier($ CYTypeIntegral(CYTypeUnsigned, 2));
+}
+
+template <>
+CYTypedIdentifier *Primitive<unsigned long long int>::Decode(CYPool &pool) const {
+ return $ CYTypedIdentifier($ CYTypeIntegral(CYTypeUnsigned, 3));
+}
+
+template <>
+CYTypedIdentifier *Primitive<unsigned short int>::Decode(CYPool &pool) const {
+ return $ CYTypedIdentifier($ CYTypeIntegral(CYTypeUnsigned, 0));
+}