diff options
Diffstat (limited to 'libobjc')
-rw-r--r-- | libobjc/ChangeLog | 10 | ||||
-rw-r--r-- | libobjc/encoding.c | 79 | ||||
-rw-r--r-- | libobjc/objc/encoding.h | 2 | ||||
-rw-r--r-- | libobjc/objc/objc-api.h | 12 |
4 files changed, 97 insertions, 6 deletions
diff --git a/libobjc/ChangeLog b/libobjc/ChangeLog index f9d9925..029b0a3 100644 --- a/libobjc/ChangeLog +++ b/libobjc/ChangeLog @@ -1,5 +1,15 @@ 2010-09-26 Nicola Pero <nicola.pero@meta-innovation.com> + * encoding.c (objc_sizeof_type): Added support for vector type and + for double long types. + (objc_alignof_type): Same change. + (objc_skip_typespec): Same change. + * objc/encoding.h (_C_GCINVISIBLE): Use '|' for _C_GCINVISIBLE + instead of '!' since '!' is already used for _C_VECTOR. + * objc/objc-api.h (_C_LNG_DBL): Added. + +2010-09-26 Nicola Pero <nicola.pero@meta-innovation.com> + * libobjc_entry.c: File removed. 2010-09-26 Kai Tietz <kai.tietz@onevision.com> diff --git a/libobjc/encoding.c b/libobjc/encoding.c index 35c9552..d417b87 100644 --- a/libobjc/encoding.c +++ b/libobjc/encoding.c @@ -148,6 +148,8 @@ objc_sizeof_type (const char *type) /* Skip the variable name if any */ if (*type == '"') { + /* FIXME: How do we know we won't read beyond the end of the + string. Here and in the rest of the file! */ for (type++; *type++ != '"';) /* do nothing */; } @@ -217,6 +219,10 @@ objc_sizeof_type (const char *type) return sizeof (double); break; + case _C_LNG_DBL: + return sizeof (long double); + break; + case _C_VOID: return sizeof (void); break; @@ -236,6 +242,19 @@ objc_sizeof_type (const char *type) } break; + case _C_VECTOR: + { + /* Skip the '!'. */ + type++; + /* Skip the '['. */ + type++; + + /* The size in bytes is the following number. */ + int size = atoi (type); + return size; + } + break; + case _C_BFLD: { /* The new encoding of bitfields is: b 'position' 'type' 'size' */ @@ -318,6 +337,10 @@ objc_sizeof_type (const char *type) case _C_DBL: return sizeof (_Complex double); break; + + case _C_LNG_DBL: + return sizeof (_Complex long double); + break; default: { @@ -418,6 +441,10 @@ objc_alignof_type (const char *type) return __alignof__ (double); break; + case _C_LNG_DBL: + return __alignof__ (long double); + break; + case _C_PTR: case _C_ATOM: case _C_CHARPTR: @@ -429,6 +456,23 @@ objc_alignof_type (const char *type) /* do nothing */; return objc_alignof_type (type); + case _C_VECTOR: + { + /* Skip the '!'. */ + type++; + /* Skip the '['. */ + type++; + + /* Skip the size. */ + while (isdigit ((unsigned char)*type)) + type++; + + /* Skip the ','. */ + type++; + + /* The alignment in bytes is the following number. */ + return atoi (type); + } case _C_STRUCT_B: case _C_UNION_B: { @@ -496,6 +540,10 @@ objc_alignof_type (const char *type) case _C_DBL: return __alignof__ (_Complex double); break; + + case _C_LNG_DBL: + return __alignof__ (_Complex long double); + break; default: { @@ -631,6 +679,7 @@ objc_skip_typespec (const char *type) case _C_ULNG_LNG: case _C_FLT: case _C_DBL: + case _C_LNG_DBL: case _C_VOID: case _C_UNDEF: return ++type; @@ -642,7 +691,6 @@ objc_skip_typespec (const char *type) case _C_ARY_B: /* skip digits, typespec and closing ']' */ - while (isdigit ((unsigned char)*++type)) ; type = objc_skip_typespec (type); @@ -654,6 +702,30 @@ objc_skip_typespec (const char *type) return 0; } + case _C_VECTOR: + /* Skip '!' */ + type++; + /* Skip '[' */ + type++; + /* Skip digits (size) */ + while (isdigit ((unsigned char)*type)) + type++; + /* Skip ',' */ + type++; + /* Skip digits (alignment) */ + while (isdigit ((unsigned char)*type)) + type++; + /* Skip typespec. */ + type = objc_skip_typespec (type); + /* Skip closing ']'. */ + if (*type == _C_ARY_E) + return ++type; + else + { + _objc_abort ("bad vector type %s\n", type); + return 0; + } + case _C_BFLD: /* The new encoding of bitfields is: b 'position' 'type' 'size' */ while (isdigit ((unsigned char)*++type)) @@ -700,6 +772,8 @@ objc_skip_typespec (const char *type) /* Skip an offset as part of a method encoding. This is prepended by a '+' if the argument is passed in registers. + + FIXME: The compiler never generates '+'. */ const char * objc_skip_offset (const char *type) @@ -883,7 +957,7 @@ objc_get_type_qualifiers (const char *type) the presence of bitfields inside the structure. */ void objc_layout_structure (const char *type, - struct objc_struct_layout *layout) + struct objc_struct_layout *layout) { const char *ntype; @@ -979,6 +1053,7 @@ objc_layout_structure_next_member (struct objc_struct_layout *layout) bfld_field_size = atoi (objc_skip_typespec (bfld_type)); } + /* The following won't work for vectors. */ #ifdef BIGGEST_FIELD_ALIGNMENT desired_align = MIN (desired_align, BIGGEST_FIELD_ALIGNMENT); #endif diff --git a/libobjc/objc/encoding.h b/libobjc/objc/encoding.h index 0deae5f..177ef72 100644 --- a/libobjc/objc/encoding.h +++ b/libobjc/objc/encoding.h @@ -42,7 +42,7 @@ extern "C" { #define _C_BYCOPY 'O' #define _C_BYREF 'R' #define _C_ONEWAY 'V' -#define _C_GCINVISIBLE '!' +#define _C_GCINVISIBLE '|' #define _F_CONST 0x01 #define _F_IN 0x01 diff --git a/libobjc/objc/objc-api.h b/libobjc/objc/objc-api.h index 9903739..be433cb 100644 --- a/libobjc/objc/objc-api.h +++ b/libobjc/objc/objc-api.h @@ -68,13 +68,13 @@ struct objc_method_description #define _C_ULNG_LNG 'Q' #define _C_FLT 'f' #define _C_DBL 'd' +#define _C_LNG_DBL 'D' #define _C_BFLD 'b' -#define _C_BOOL 'B' +#define _C_BOOL 'B' #define _C_VOID 'v' #define _C_UNDEF '?' #define _C_PTR '^' #define _C_CHARPTR '*' -#define _C_ATOM '%' #define _C_ARY_B '[' #define _C_ARY_E ']' #define _C_UNION_B '(' @@ -82,7 +82,13 @@ struct objc_method_description #define _C_STRUCT_B '{' #define _C_STRUCT_E '}' #define _C_VECTOR '!' -#define _C_COMPLEX 'j' +#define _C_COMPLEX 'j' + +/* The following one is never generated by the compiler. You can + treat it as equivalent to "*". +*/ +#define _C_ATOM '%' + #include "deprecated/objc_error.h" |