|
|
|
@ -6,6 +6,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
#pragma GCC diagnostic ignored "-Wobjc-property-no-attribute"
|
|
|
|
#pragma GCC diagnostic ignored "-Wobjc-property-no-attribute"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Clang < 3 doesn't exist usefully, so we can skip tests for it. Clang 3.5
|
|
|
|
|
|
|
|
// adds proper metadata for weak properties, earlier ones don't, so don't fail
|
|
|
|
|
|
|
|
// the tests because of known compiler bugs.
|
|
|
|
|
|
|
|
#ifndef __clang_minor__
|
|
|
|
|
|
|
|
#define WEAK_ATTR ATTR("W", ""),
|
|
|
|
|
|
|
|
#define WEAK_STR "W,"
|
|
|
|
|
|
|
|
#elif (__clang_major__ < 4) && (__clang_minor__ < 5)
|
|
|
|
|
|
|
|
#define WEAK_ATTR
|
|
|
|
|
|
|
|
#define WEAK_STR
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
#define WEAK_ATTR ATTR("W", ""),
|
|
|
|
|
|
|
|
#define WEAK_STR "W,"
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
enum FooManChu { FOO, MAN, CHU };
|
|
|
|
enum FooManChu { FOO, MAN, CHU };
|
|
|
|
struct YorkshireTeaStruct { int pot; signed char lady; };
|
|
|
|
struct YorkshireTeaStruct { int pot; signed char lady; };
|
|
|
|
typedef struct YorkshireTeaStruct YorkshireTeaStructType;
|
|
|
|
typedef struct YorkshireTeaStruct YorkshireTeaStructType;
|
|
|
|
@ -281,7 +295,7 @@ static BOOL testPropertyForProperty_alt(objc_property_t p,
|
|
|
|
attrsList = property_copyAttributeList(p, NULL);
|
|
|
|
attrsList = property_copyAttributeList(p, NULL);
|
|
|
|
OPT_ASSERT(0 != attrsList);
|
|
|
|
OPT_ASSERT(0 != attrsList);
|
|
|
|
objc_property_attribute_t *ra;
|
|
|
|
objc_property_attribute_t *ra;
|
|
|
|
for (attrsCount = 0, ra = attrsList; ra->name != NULL; attrsCount++, ra++) {}
|
|
|
|
for (attrsCount = 0, ra = attrsList; (ra->name != NULL) && (attrsCount < size); attrsCount++, ra++) {}
|
|
|
|
OPT_ASSERT(attrsCount == size);
|
|
|
|
OPT_ASSERT(attrsCount == size);
|
|
|
|
free(attrsList);
|
|
|
|
free(attrsList);
|
|
|
|
for (unsigned int index=0; index<size; index++) {
|
|
|
|
for (unsigned int index=0; index<size; index++) {
|
|
|
|
@ -384,45 +398,44 @@ static void testAddPropertyForClass(Class testClass)
|
|
|
|
ATTR("R", ""),
|
|
|
|
ATTR("R", ""),
|
|
|
|
ATTR("&", ""),
|
|
|
|
ATTR("&", ""),
|
|
|
|
ATTR("C", ""),
|
|
|
|
ATTR("C", ""),
|
|
|
|
ATTR("W", ""),
|
|
|
|
WEAK_ATTR
|
|
|
|
ATTR("D", ""),
|
|
|
|
ATTR("D", ""),
|
|
|
|
ATTR("V", "backingIvar"))));
|
|
|
|
ATTR("V", "backingIvar"))));
|
|
|
|
testPropertyForProperty(class_getProperty(testClass, "addProperty4"),
|
|
|
|
testPropertyForProperty(class_getProperty(testClass, "addProperty4"),
|
|
|
|
"addProperty4", "T@,R,&,C,W,D,VbackingIvar", ATTRS(ATTR("T", "@"),
|
|
|
|
"addProperty4", "T@,R,&,C," WEAK_STR "D,VbackingIvar", ATTRS(ATTR("T", "@"),
|
|
|
|
ATTR("R", ""),
|
|
|
|
ATTR("R", ""),
|
|
|
|
ATTR("&", ""),
|
|
|
|
ATTR("&", ""),
|
|
|
|
ATTR("C", ""),
|
|
|
|
ATTR("C", ""),
|
|
|
|
ATTR("W", ""),
|
|
|
|
WEAK_ATTR
|
|
|
|
ATTR("D", ""),
|
|
|
|
ATTR("D", ""),
|
|
|
|
ATTR("V", "backingIvar")));
|
|
|
|
ATTR("V", "backingIvar")));
|
|
|
|
|
|
|
|
|
|
|
|
assert(class_addProperty(testClass, "addProperty5", ATTRS(ATTR("T", "@"),
|
|
|
|
assert(class_addProperty(testClass, "addProperty5", ATTRS(ATTR("T", "@"),
|
|
|
|
ATTR("D", ""),
|
|
|
|
ATTR("D", ""),
|
|
|
|
ATTR("W", ""),
|
|
|
|
WEAK_ATTR
|
|
|
|
ATTR("C", ""),
|
|
|
|
ATTR("C", ""),
|
|
|
|
ATTR("&", ""),
|
|
|
|
ATTR("&", ""),
|
|
|
|
ATTR("R", ""),
|
|
|
|
ATTR("R", ""),
|
|
|
|
ATTR("V", "backingIvar"))));
|
|
|
|
ATTR("V", "backingIvar"))));
|
|
|
|
// The only concession to MacOS X is that we reorder the attributes string
|
|
|
|
// The only concession to MacOS X is that we reorder the attributes string
|
|
|
|
#if __APPLE__
|
|
|
|
if (!testPropertyForProperty_alt(class_getProperty(testClass, "addProperty5"),
|
|
|
|
testPropertyForProperty(class_getProperty(testClass, "addProperty5"),
|
|
|
|
"addProperty5", "T@,D," WEAK_STR "C,&,R,VbackingIvar", ATTRS(ATTR("T", "@"),
|
|
|
|
"addProperty5", "T@,D,W,C,&,R,VbackingIvar", ATTRS(ATTR("T", "@"),
|
|
|
|
|
|
|
|
ATTR("R", ""),
|
|
|
|
|
|
|
|
ATTR("&", ""),
|
|
|
|
|
|
|
|
ATTR("C", ""),
|
|
|
|
|
|
|
|
ATTR("W", ""),
|
|
|
|
|
|
|
|
ATTR("D", ""),
|
|
|
|
ATTR("D", ""),
|
|
|
|
ATTR("V", "backingIvar")));
|
|
|
|
WEAK_ATTR
|
|
|
|
#else
|
|
|
|
|
|
|
|
testPropertyForProperty(class_getProperty(testClass, "addProperty5"),
|
|
|
|
|
|
|
|
"addProperty5", "T@,R,&,C,W,D,VbackingIvar", ATTRS(ATTR("T", "@"),
|
|
|
|
|
|
|
|
ATTR("R", ""),
|
|
|
|
|
|
|
|
ATTR("&", ""),
|
|
|
|
|
|
|
|
ATTR("C", ""),
|
|
|
|
ATTR("C", ""),
|
|
|
|
ATTR("W", ""),
|
|
|
|
ATTR("&", ""),
|
|
|
|
ATTR("D", ""),
|
|
|
|
ATTR("R", ""),
|
|
|
|
ATTR("V", "backingIvar")));
|
|
|
|
ATTR("V", "backingIvar")), NO))
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
|
|
|
|
testPropertyForProperty(class_getProperty(testClass, "addProperty5"),
|
|
|
|
|
|
|
|
"addProperty5", "T@,R,&,C," WEAK_STR "D,VbackingIvar", ATTRS(ATTR("T", "@"),
|
|
|
|
|
|
|
|
ATTR("R", ""),
|
|
|
|
|
|
|
|
ATTR("&", ""),
|
|
|
|
|
|
|
|
ATTR("C", ""),
|
|
|
|
|
|
|
|
WEAK_ATTR
|
|
|
|
|
|
|
|
ATTR("D", ""),
|
|
|
|
|
|
|
|
ATTR("V", "backingIvar")));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
assert(class_addProperty(testClass, "replaceProperty", ATTRS(ATTR("T", "@"))));
|
|
|
|
assert(class_addProperty(testClass, "replaceProperty", ATTRS(ATTR("T", "@"))));
|
|
|
|
testPropertyForProperty(class_getProperty(testClass, "replaceProperty"),
|
|
|
|
testPropertyForProperty(class_getProperty(testClass, "replaceProperty"),
|
|
|
|
@ -546,24 +559,27 @@ int main(void)
|
|
|
|
ATTR("N", ""),
|
|
|
|
ATTR("N", ""),
|
|
|
|
ATTR("V", "intNonatomic")));
|
|
|
|
ATTR("V", "intNonatomic")));
|
|
|
|
testProperty("idReadonlyCopyNonatomic", "T@,R,C,N,VidReadonlyCopyNonatomic", ATTRS(ATTR("T", "@"),
|
|
|
|
testProperty("idReadonlyCopyNonatomic", "T@,R,C,N,VidReadonlyCopyNonatomic", ATTRS(ATTR("T", "@"),
|
|
|
|
|
|
|
|
ATTR("C", ""),
|
|
|
|
ATTR("R", ""),
|
|
|
|
ATTR("R", ""),
|
|
|
|
ATTR("N", ""),
|
|
|
|
ATTR("N", ""),
|
|
|
|
ATTR("V", "idReadonlyCopyNonatomic")));
|
|
|
|
ATTR("V", "idReadonlyCopyNonatomic")));
|
|
|
|
testProperty("idReadonlyRetainNonatomic", "T@,R,&,N,VidReadonlyRetainNonatomic", ATTRS(ATTR("T", "@"),
|
|
|
|
testProperty("idReadonlyRetainNonatomic", "T@,R,&,N,VidReadonlyRetainNonatomic", ATTRS(ATTR("T", "@"),
|
|
|
|
ATTR("R", ""),
|
|
|
|
ATTR("R", ""),
|
|
|
|
|
|
|
|
ATTR("&", ""),
|
|
|
|
ATTR("N", ""),
|
|
|
|
ATTR("N", ""),
|
|
|
|
ATTR("V", "idReadonlyRetainNonatomic")));
|
|
|
|
ATTR("V", "idReadonlyRetainNonatomic")));
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* The weak attribute was not present for earlier versions of clang, so we test
|
|
|
|
* The weak attribute was not present for earlier versions of clang, so we test
|
|
|
|
* for all variants that the compiler may produce.
|
|
|
|
* for all variants that the compiler may produce.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
if (!testProperty_alt("idReadonlyWeakNonatomic", "T@,R,W,N,VidReadonlyWeakNonatomic", ATTRS(ATTR("T", "@"),
|
|
|
|
if (!testProperty_alt("idReadonlyWeakNonatomic", "T@,R," WEAK_STR "N,VidReadonlyWeakNonatomic", ATTRS(ATTR("T", "@"),
|
|
|
|
ATTR("R", ""),
|
|
|
|
ATTR("R", ""),
|
|
|
|
ATTR("N", ""),
|
|
|
|
ATTR("N", ""),
|
|
|
|
ATTR("V", "idReadonlyWeakNonatomic")), NO))
|
|
|
|
ATTR("V", "idReadonlyWeakNonatomic")), NO))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
testProperty("idReadonlyWeakNonatomic", "T@,R,N,VidReadonlyWeakNonatomic", ATTRS(ATTR("T", "@"),
|
|
|
|
testProperty("idReadonlyWeakNonatomic", "T@,R," WEAK_STR "N,VidReadonlyWeakNonatomic", ATTRS(ATTR("T", "@"),
|
|
|
|
ATTR("R", ""),
|
|
|
|
ATTR("R", ""),
|
|
|
|
|
|
|
|
WEAK_ATTR
|
|
|
|
ATTR("N", ""),
|
|
|
|
ATTR("N", ""),
|
|
|
|
ATTR("V", "idReadonlyWeakNonatomic")));
|
|
|
|
ATTR("V", "idReadonlyWeakNonatomic")));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -622,15 +638,18 @@ int main(void)
|
|
|
|
ATTR("N", "")));
|
|
|
|
ATTR("N", "")));
|
|
|
|
testPropertyForProtocol(testProto, "idReadonlyCopyNonatomic", "T@,R,C,N", ATTRS(ATTR("T", "@"),
|
|
|
|
testPropertyForProtocol(testProto, "idReadonlyCopyNonatomic", "T@,R,C,N", ATTRS(ATTR("T", "@"),
|
|
|
|
ATTR("R", ""),
|
|
|
|
ATTR("R", ""),
|
|
|
|
|
|
|
|
ATTR("C", ""),
|
|
|
|
ATTR("N", "")));
|
|
|
|
ATTR("N", "")));
|
|
|
|
testPropertyForProtocol(testProto, "idReadonlyRetainNonatomic", "T@,R,&,N", ATTRS(ATTR("T", "@"),
|
|
|
|
testPropertyForProtocol(testProto, "idReadonlyRetainNonatomic", "T@,R,&,N", ATTRS(ATTR("T", "@"),
|
|
|
|
ATTR("R", ""),
|
|
|
|
ATTR("R", ""),
|
|
|
|
|
|
|
|
ATTR("&", ""),
|
|
|
|
ATTR("N", "")));
|
|
|
|
ATTR("N", "")));
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* Again, different clang versions emit slightly different property declarations.
|
|
|
|
* Again, different clang versions emit slightly different property declarations.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
if (!testPropertyForProtocol_alt(testProto, "idReadonlyWeakNonatomic", "T@,R,W,N", ATTRS(ATTR("T", "@"),
|
|
|
|
if (!testPropertyForProtocol_alt(testProto, "idReadonlyWeakNonatomic", "T@,R," WEAK_STR "N", ATTRS(ATTR("T", "@"),
|
|
|
|
ATTR("R", ""),
|
|
|
|
ATTR("R", ""),
|
|
|
|
|
|
|
|
WEAK_ATTR
|
|
|
|
ATTR("N", "")), NO))
|
|
|
|
ATTR("N", "")), NO))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|