From daf9976eab66d3008d45367a12162b83a73bf885 Mon Sep 17 00:00:00 2001 From: theraven Date: Mon, 22 Aug 2011 13:11:43 +0000 Subject: [PATCH] Fix type encoding of blocks. --- encoding2.c | 21 +++++++++++++++++++++ type_encoding_cases.h | 2 ++ 2 files changed, 23 insertions(+) diff --git a/encoding2.c b/encoding2.c index dd85288..9591c7c 100644 --- a/encoding2.c +++ b/encoding2.c @@ -161,8 +161,19 @@ static const char *sizeof_type(const char *type, size_t *size) *size += (sizeof(typeName) * 8);\ return type + 1;\ } +#define SKIP_ID 1 #define NON_INTEGER_TYPES 1 #include "type_encoding_cases.h" + case '@': + { + round_up(size, (alignof(id) * 8)); + *size += (sizeof(id) * 8); + if (*(type+1) == '?') + { + type++; + } + return type + 1; + } case '?': case 'v': return type+1; case 'j': @@ -252,7 +263,17 @@ static const char *alignof_type(const char *type, size_t *align) return type + 1;\ } #define NON_INTEGER_TYPES 1 +#define SKIP_ID 1 #include "type_encoding_cases.h" + case '@': + { + *align = max((alignof(id) * 8), *align);\ + if (*(type+1) == '?') + { + type++; + } + return type + 1; + } case '?': case 'v': return type+1; case 'j': diff --git a/type_encoding_cases.h b/type_encoding_cases.h index ab60079..36ab516 100644 --- a/type_encoding_cases.h +++ b/type_encoding_cases.h @@ -25,7 +25,9 @@ APPLY_TYPE(unsigned long long, unsignedLongLong, UnsignedLongLong, 'Q') #ifdef NON_INTEGER_TYPES #undef NON_INTEGER_TYPES APPLY_TYPE(_Bool, bool, Bool, 'B') +#ifndef SKIP_ID APPLY_TYPE(id, object, Object, '@') +#endif APPLY_TYPE(Class, class, Class, '#') APPLY_TYPE(SEL, selector, Selector, ':') APPLY_TYPE(char*, cString, CString, '*')