Enabled property attribute test, fixed failure.

main
theraven 13 years ago
parent ef5f8b744d
commit aeb0c913b9

@ -4,11 +4,12 @@
set(TESTS set(TESTS
objc_msgSend.m
BlockImpTest.m BlockImpTest.m
PropertyAttributeTest.m
PropertyIntrospectionTest.m PropertyIntrospectionTest.m
ProtocolCreation.m ProtocolCreation.m
RuntimeTest.m RuntimeTest.m
objc_msgSend.m
) )
#ExceptionTest.m #ExceptionTest.m

@ -1,9 +1,14 @@
#include <stdio.h> #include <stdio.h>
#import <Foundation/NSObject.h>
#import <objc/runtime.h> #import <objc/runtime.h>
#include <string.h>
#include <assert.h> #include <assert.h>
@interface helloclass : NSObject { #ifdef __has_attribute
#if __has_attribute(objc_root_class)
__attribute__((objc_root_class))
#endif
#endif
@interface helloclass {
@private int varName; @private int varName;
} }
@property (readwrite,assign) int propName; @property (readwrite,assign) int propName;
@ -11,6 +16,7 @@
@implementation helloclass @implementation helloclass
@synthesize propName = varName; @synthesize propName = varName;
+ (id)class { return self; }
@end @end
int main() int main()

@ -400,6 +400,7 @@ PRIVATE const char *constructPropertyAttributes(objc_property_t property,
unsigned char *encoding = malloc(encodingSize); unsigned char *encoding = malloc(encodingSize);
// Set the leading 0 and the offset of the name // Set the leading 0 and the offset of the name
unsigned char *insert = encoding; unsigned char *insert = encoding;
BOOL needsComma = NO;
*(insert++) = 0; *(insert++) = 0;
*(insert++) = 0; *(insert++) = 0;
// Set the type encoding // Set the type encoding
@ -408,33 +409,39 @@ PRIVATE const char *constructPropertyAttributes(objc_property_t property,
*(insert++) = 'T'; *(insert++) = 'T';
memcpy(insert, typeEncoding, typeSize); memcpy(insert, typeEncoding, typeSize);
insert += typeSize; insert += typeSize;
needsComma = YES;
} }
// Set the flags // Set the flags
memcpy(insert, flags, i); memcpy(insert, flags, i);
insert += i; insert += i;
if ((property->attributes & OBJC_PR_getter) == OBJC_PR_getter) if ((property->attributes & OBJC_PR_getter) == OBJC_PR_getter)
{ {
if (i > 0) if (needsComma)
{ {
*(insert++) = ','; *(insert++) = ',';
} }
i++; i++;
needsComma = YES;
*(insert++) = 'G'; *(insert++) = 'G';
memcpy(insert, property->getter_name, getterLength); memcpy(insert, property->getter_name, getterLength);
insert += getterLength; insert += getterLength;
} }
if ((property->attributes & OBJC_PR_setter) == OBJC_PR_setter) if ((property->attributes & OBJC_PR_setter) == OBJC_PR_setter)
{ {
if (i > 0) if (needsComma)
{ {
*(insert++) = ','; *(insert++) = ',';
} }
i++; i++;
needsComma = YES;
*(insert++) = 'S'; *(insert++) = 'S';
memcpy(insert, property->setter_name, setterLength); memcpy(insert, property->setter_name, setterLength);
insert += setterLength; insert += setterLength;
} }
*(insert++) = ','; if (needsComma)
{
*(insert++) = ',';
}
*(insert++) = 'V'; *(insert++) = 'V';
// If the instance variable name is the same as the property name, then we // If the instance variable name is the same as the property name, then we
// use the same string for both, otherwise we write the ivar name in the // use the same string for both, otherwise we write the ivar name in the

Loading…
Cancel
Save