| 1 |
/* Additional testing for the NeXT runtime. Encoding in -m64 mode */ |
| 2 |
|
| 3 |
/* { dg-do run { target *-*-darwin* } } */ |
| 4 |
/* { dg-require-effective-target lp64 } */ |
| 5 |
/* { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } */ |
| 6 |
/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */ |
| 7 |
/* { dg-additional-options "-framework Foundation" } */ |
| 8 |
|
| 9 |
#include <stdbool.h> |
| 10 |
#include <string.h> |
| 11 |
#include <stdlib.h> |
| 12 |
#include <stdio.h> |
| 13 |
#include "../objc-obj-c++-shared/F-NSObject.h" |
| 14 |
#include "../objc-obj-c++-shared/CF-CFString.h" |
| 15 |
#include "../objc-obj-c++-shared/runtime.h" |
| 16 |
|
| 17 |
void CHECK_IF(const char *s1, const char *s2) |
| 18 |
{ |
| 19 |
if (strcmp(s1,s2) != 0) { |
| 20 |
printf ("'%s'\n'%s'\n",s1,s2); |
| 21 |
abort (); |
| 22 |
} |
| 23 |
} |
| 24 |
|
| 25 |
@class NSDictionary, NSFont, NSError, _NSATSTypesetterGuts, NSString, NSMenu, NSArray; |
| 26 |
|
| 27 |
struct FSRef { |
| 28 |
UInt8 hidden[80]; |
| 29 |
}; |
| 30 |
typedef struct FSRef FSRef; |
| 31 |
|
| 32 |
typedef struct _NSPoint { |
| 33 |
float x; |
| 34 |
float y; |
| 35 |
} NSPoint; |
| 36 |
|
| 37 |
typedef struct _NSSize { |
| 38 |
float width; |
| 39 |
float height; |
| 40 |
} NSSize; |
| 41 |
|
| 42 |
typedef struct _NSRect { |
| 43 |
NSPoint origin; |
| 44 |
NSSize size; |
| 45 |
} NSRect; |
| 46 |
|
| 47 |
typedef struct _NSRange { |
| 48 |
unsigned int location; |
| 49 |
unsigned int length; |
| 50 |
} NSRange; |
| 51 |
|
| 52 |
typedef const char *NXAtom; |
| 53 |
|
| 54 |
typedef struct { |
| 55 |
NSDictionary *_attributes; |
| 56 |
NSFont *_font; |
| 57 |
CFIndex _characterLength; |
| 58 |
CFIndex _nominalGlyphLocation; |
| 59 |
const CFIndex *p; |
| 60 |
float _defaultLineHeight; |
| 61 |
float _defaultBaselineOffset; |
| 62 |
float _horizExpansion; |
| 63 |
float _baselineDelta; |
| 64 |
NSRect _attachmentBBox; |
| 65 |
long ll, *llp; |
| 66 |
unsigned long ull, *ullp; |
| 67 |
id a; |
| 68 |
const id a1; |
| 69 |
const struct objc_object *a2; |
| 70 |
SEL b; |
| 71 |
const SEL b1; |
| 72 |
const struct objc_selector *b2; |
| 73 |
const char *str1; |
| 74 |
char *str2; |
| 75 |
char *const str3; |
| 76 |
const char *const str4; |
| 77 |
struct { |
| 78 |
unsigned int _isAttachmentRun:1; |
| 79 |
unsigned int _hasPositionalStake:1; |
| 80 |
unsigned int _isDefaultFace:1; |
| 81 |
unsigned int _hasCombiningMarks:1; |
| 82 |
unsigned int _isScreenFont:1; |
| 83 |
unsigned int _reserved:27; |
| 84 |
} _rFlags; |
| 85 |
} NSATSGlyphStorageRun; |
| 86 |
|
| 87 |
typedef struct __CFSet *CFMutableSetRef; |
| 88 |
typedef const struct __CTLine * CTLineRef; |
| 89 |
typedef const struct __NSAppleEventManagerSuspension* NSAppleEventManagerSuspensionID; |
| 90 |
|
| 91 |
struct ComponentInstanceRecord { |
| 92 |
long data[1]; |
| 93 |
}; |
| 94 |
typedef struct ComponentInstanceRecord ComponentInstanceRecord; |
| 95 |
typedef ComponentInstanceRecord *ComponentInstance; |
| 96 |
|
| 97 |
typedef NSString *(*NSErrorUserInfoFormatterFunc)(id objToBeDisplayed, NSError *err, char modifier); |
| 98 |
typedef struct { |
| 99 |
NSErrorUserInfoFormatterFunc formatterFunc; |
| 100 |
NSString *userInfoKey; |
| 101 |
unsigned int parameterMask; |
| 102 |
} NSErrorUserInfoFormatter; |
| 103 |
|
| 104 |
typedef NSObject MyObj; |
| 105 |
typedef NSObject *MyPtr; |
| 106 |
|
| 107 |
@interface Foo: NSObject { |
| 108 |
NSATSGlyphStorageRun r; |
| 109 |
} |
| 110 |
- (NSError *)_errorWithOSStatus:(OSStatus)inOSStatus ref1:(const FSRef *)inRef1 ref2:(const struct FSRef *)inRef2 |
| 111 |
reading:(BOOL)inReadingNotWriting; |
| 112 |
- (const NSATSGlyphStorageRun *)_attributeRunForCharacterAtIndex:(const CFIndex)charIndex; |
| 113 |
- (const _NSATSTypesetterGuts *)_getATSTypesetterGuts:(const struct objc_selector *)sel; |
| 114 |
- (void)resumeWithSuspensionID:(NSAppleEventManagerSuspensionID)suspensionID and:(const CFIndex *)status; |
| 115 |
- (const id)anotherMeth:(const SEL)sel and:(const Foo *)foo and:(const struct objc_object *)obj; |
| 116 |
- (id)str1:(const char *)str1 str2:(char *)str2 str3:(char *const)str3 str4:(const char *const)str4; |
| 117 |
- (oneway void)foo1:(Foo *)foo1 foo2:(const Foo *)foo2 foo3:(Foo *const)foo3 foo4:(const Foo *const)foo4; |
| 118 |
- (in const char *)sel1:(const SEL)sel1 id1:(const id)id1; |
| 119 |
- (inout id)obj1:(const MyPtr)obj1 obj2:(NSObject *const)obj2 obj3:(MyObj *const)obj3; |
| 120 |
+ (ComponentInstance)_defaultScriptingComponent; |
| 121 |
- (NSString *)_formatCocoaErrorString:(NSString *)formatString parameters:(const char *)parameters |
| 122 |
applicableFormatters:(NSErrorUserInfoFormatter **)formatters count:(int)numFormatters; |
| 123 |
- (NSErrorUserInfoFormatter *)formatter_func:(id)obj run:(const NSATSGlyphStorageRun **)run; |
| 124 |
- (BOOL)_forgetWord:(bycopy in NSString *)word inDictionary:(bycopy in NSString *)language; |
| 125 |
- (void)_registerServicesMenu:(NSMenu *)servicesMenu withSendTypes:(const NXAtom *)sendTypes |
| 126 |
andReturnTypes:(const NXAtom *)returnTypes addToList:(BOOL)addToList; |
| 127 |
+ (CFMutableSetRef *)_proxySharePointer; |
| 128 |
- (NSRange)_checkGrammarInString:(in NSString *)stringToCheck language:(bycopy in NSString *)language details:(bycopy out NSArray **)details; |
| 129 |
- (bool)_resolvePositionalStakeGlyphsForLineFragment:(CTLineRef)line lineFragmentRect:(NSRect)lineFragmentRect |
| 130 |
minPosition:(float)minPosition maxPosition:(float)maxPosition maxLineFragmentWidth:(float)maxLineFragmentWidth |
| 131 |
breakHint:(CFIndex *)charIndex; |
| 132 |
+ (BOOL)findVoiceByIdentifier:(NSString *)identifier returningCreator:(OSType *)returnedCreator returningID:(OSType *)returnedID; |
| 133 |
@end |
| 134 |
|
| 135 |
NSRange globalRange; |
| 136 |
|
| 137 |
@implementation Foo |
| 138 |
- (NSError *)_errorWithOSStatus:(OSStatus)inOSStatus ref1:(const FSRef *)inRef1 ref2:(const struct FSRef *)inRef2 |
| 139 |
reading:(BOOL)inReadingNotWriting { |
| 140 |
return (NSError *)self; |
| 141 |
} |
| 142 |
- (const NSATSGlyphStorageRun *)_attributeRunForCharacterAtIndex:(CFIndex)charIndex { |
| 143 |
return (const NSATSGlyphStorageRun *)self; |
| 144 |
} |
| 145 |
- (const _NSATSTypesetterGuts *)_getATSTypesetterGuts:(const struct objc_selector *)sel { |
| 146 |
return (const _NSATSTypesetterGuts *)self; |
| 147 |
} |
| 148 |
- (void)resumeWithSuspensionID:(NSAppleEventManagerSuspensionID)suspensionID and:(const CFIndex *)status { |
| 149 |
} |
| 150 |
- (const id)anotherMeth:(const SEL)sel and:(const Foo *)foo and:(const struct objc_object *)obj { |
| 151 |
return (const id)self; |
| 152 |
} |
| 153 |
- (id)str1:(const char *)str1 str2:(char *)str2 str3:(char *const)str3 str4:(const char *const)str4 { |
| 154 |
return self; |
| 155 |
} |
| 156 |
- (oneway void)foo1:(Foo *)foo1 foo2:(const Foo *)foo2 foo3:(Foo *const)foo3 foo4:(const Foo *const)foo4 { |
| 157 |
} |
| 158 |
- (in const char *)sel1:(const SEL)sel1 id1:(const id)id1 { |
| 159 |
return "Hello"; |
| 160 |
} |
| 161 |
- (inout id)obj1:(const MyPtr)obj1 obj2:(NSObject *const)obj2 obj3:(MyObj *const)obj3 { |
| 162 |
return self; |
| 163 |
} |
| 164 |
+ (ComponentInstance)_defaultScriptingComponent { |
| 165 |
return (ComponentInstance)0; |
| 166 |
} |
| 167 |
- (NSString *)_formatCocoaErrorString:(NSString *)formatString parameters:(const char *)parameters |
| 168 |
applicableFormatters:(NSErrorUserInfoFormatter **)formatters count:(int)numFormatters { |
| 169 |
return (NSString *)self; |
| 170 |
} |
| 171 |
- (NSErrorUserInfoFormatter *)formatter_func:(id)obj run:(const NSATSGlyphStorageRun **)run { |
| 172 |
return (NSErrorUserInfoFormatter *)0; |
| 173 |
} |
| 174 |
- (BOOL)_forgetWord:(bycopy in NSString *)word inDictionary:(bycopy in NSString *)language { |
| 175 |
return YES; |
| 176 |
} |
| 177 |
- (void)_registerServicesMenu:(NSMenu *)servicesMenu withSendTypes:(const NXAtom *)sendTypes |
| 178 |
andReturnTypes:(const NXAtom *)returnTypes addToList:(BOOL)addToList { |
| 179 |
} |
| 180 |
+ (CFMutableSetRef *)_proxySharePointer { |
| 181 |
return (CFMutableSetRef *)0; |
| 182 |
} |
| 183 |
- (NSRange)_checkGrammarInString:(in NSString *)stringToCheck language:(bycopy in NSString *)language details:(bycopy out NSArray **)details { |
| 184 |
return globalRange; |
| 185 |
} |
| 186 |
- (bool)_resolvePositionalStakeGlyphsForLineFragment:(CTLineRef)line lineFragmentRect:(NSRect)lineFragmentRect |
| 187 |
minPosition:(float)minPosition maxPosition:(float)maxPosition maxLineFragmentWidth:(float)maxLineFragmentWidth |
| 188 |
breakHint:(CFIndex *)charIndex { |
| 189 |
return false; |
| 190 |
} |
| 191 |
+ (BOOL)findVoiceByIdentifier:(NSString *)identifier returningCreator:(OSType *)returnedCreator returningID:(OSType *)returnedID { |
| 192 |
return NO; |
| 193 |
} |
| 194 |
@end |
| 195 |
|
| 196 |
/* FIXME: we produce different output c.f. the system compiler on OSX10.6+ */ |
| 197 |
|
| 198 |
int main(void) { |
| 199 |
Class fooClass = objc_getClass ("Foo"); |
| 200 |
Method meth; |
| 201 |
Ivar *ivars; |
| 202 |
unsigned int ivar_count; |
| 203 |
Ivar ivar; |
| 204 |
|
| 205 |
meth = class_getInstanceMethod (fooClass, @selector(_errorWithOSStatus:ref1:ref2:reading:)); |
| 206 |
CHECK_IF (method_getTypeEncoding(meth), "@40@0:8i16r^{FSRef=[80C]}20r^{FSRef=[80C]}28c36"); |
| 207 |
|
| 208 |
meth = class_getInstanceMethod (fooClass, @selector(_attributeRunForCharacterAtIndex:)); |
| 209 |
CHECK_IF (method_getTypeEncoding (meth), "r^{?=@@qq^qffff{_NSRect={_NSPoint=ff}{_NSSize=ff}}q^qQ^Q@@@:::****{?=b1b1b1b1b1b27}}24@0:8q16"); |
| 210 |
/* clang produces: r^{?=@@qq^qffff{_NSRect={_NSPoint=ff}{_NSSize=ff}}q^qQ^Q@@@::^{objc_selector}****{?=b1b1b1b1b1b27}}24@0:8q16 */ |
| 211 |
|
| 212 |
meth = class_getInstanceMethod (fooClass, @selector(_getATSTypesetterGuts:)); |
| 213 |
CHECK_IF (method_getTypeEncoding (meth), "r@24@0:8r:16"); |
| 214 |
/* "@24@0:8r^{objc_selector=}16" */ |
| 215 |
|
| 216 |
meth = class_getInstanceMethod (fooClass, @selector(resumeWithSuspensionID:and:)); |
| 217 |
CHECK_IF (method_getTypeEncoding (meth), "v32@0:8^{__NSAppleEventManagerSuspension=}16r^q24"); |
| 218 |
|
| 219 |
meth = class_getInstanceMethod (fooClass, @selector(anotherMeth:and:and:)); |
| 220 |
CHECK_IF (method_getTypeEncoding (meth), "r@40@0:8r:16r@24r@32"); |
| 221 |
|
| 222 |
meth = class_getInstanceMethod (fooClass, @selector(str1:str2:str3:str4:)); |
| 223 |
CHECK_IF (method_getTypeEncoding (meth), "@48@0:8r*16*24*32r*40"); |
| 224 |
|
| 225 |
meth = class_getInstanceMethod (fooClass, @selector(foo1:foo2:foo3:foo4:)); |
| 226 |
CHECK_IF (method_getTypeEncoding (meth), "Vv48@0:8@16r@24@32r@40"); |
| 227 |
|
| 228 |
meth = class_getInstanceMethod (fooClass, @selector(sel1:id1:)); |
| 229 |
CHECK_IF (method_getTypeEncoding (meth), "rn*32@0:8r:16r@24"); |
| 230 |
|
| 231 |
meth = class_getInstanceMethod (fooClass, @selector(obj1:obj2:obj3:)); |
| 232 |
CHECK_IF (method_getTypeEncoding (meth), "N@40@0:8r@16@24^{NSObject=#}32"); |
| 233 |
|
| 234 |
meth = class_getClassMethod (fooClass, @selector(_defaultScriptingComponent)); |
| 235 |
CHECK_IF (method_getTypeEncoding (meth), "^{ComponentInstanceRecord=[1q]}16@0:8"); |
| 236 |
|
| 237 |
meth = class_getInstanceMethod (fooClass, @selector(_formatCocoaErrorString:parameters:applicableFormatters:count:)); |
| 238 |
CHECK_IF (method_getTypeEncoding (meth), "@44@0:8@16r*24^^{?}32i40"); |
| 239 |
|
| 240 |
meth = class_getInstanceMethod (fooClass, @selector(formatter_func:run:)); |
| 241 |
CHECK_IF (method_getTypeEncoding (meth), "^{?=^?@I}32@0:8@16r^^{?}24"); |
| 242 |
|
| 243 |
meth = class_getInstanceMethod (fooClass, @selector(_forgetWord:inDictionary:)); |
| 244 |
CHECK_IF (method_getTypeEncoding (meth), "c32@0:8nO@16nO@24"); |
| 245 |
|
| 246 |
meth = class_getInstanceMethod (fooClass, @selector(_registerServicesMenu:withSendTypes:andReturnTypes:addToList:)); |
| 247 |
CHECK_IF (method_getTypeEncoding (meth), "v44@0:8@16r^*24r^*32c40"); |
| 248 |
|
| 249 |
meth = class_getClassMethod (fooClass, @selector(_proxySharePointer)); |
| 250 |
CHECK_IF (method_getTypeEncoding (meth), "^^{__CFSet}16@0:8"); |
| 251 |
|
| 252 |
meth = class_getInstanceMethod (fooClass, @selector(_checkGrammarInString:language:details:)); |
| 253 |
CHECK_IF (method_getTypeEncoding (meth), "{_NSRange=II}40@0:8n@16nO@24oO^@32"); |
| 254 |
|
| 255 |
meth = class_getInstanceMethod (fooClass, @selector(_resolvePositionalStakeGlyphsForLineFragment:lineFragmentRect:minPosition:maxPosition:maxLineFragmentWidth:breakHint:)); |
| 256 |
CHECK_IF (method_getTypeEncoding (meth), "B60@0:8^{__CTLine=}16{_NSRect={_NSPoint=ff}{_NSSize=ff}}24f40f44f48^q52"); |
| 257 |
|
| 258 |
meth = class_getClassMethod (fooClass, @selector(findVoiceByIdentifier:returningCreator:returningID:)); |
| 259 |
CHECK_IF (method_getTypeEncoding (meth), "c40@0:8@16^I24^I32"); |
| 260 |
|
| 261 |
ivars = class_copyIvarList (fooClass, &ivar_count); |
| 262 |
if (ivar_count != 1) { |
| 263 |
abort (); |
| 264 |
} |
| 265 |
|
| 266 |
ivar = ivars[0]; |
| 267 |
CHECK_IF (ivar_getName(ivar), "r"); |
| 268 |
CHECK_IF (ivar_getTypeEncoding(ivar), |
| 269 |
"{?=\"_attributes\"@\"NSDictionary\"\"_font\"@\"NSFont\"\"_characterLength\"" |
| 270 |
"q\"_nominalGlyphLocation\"q\"p\"^q\"_defaultLineHeight\"f\"_defaultBaselineOffset\"" |
| 271 |
"f\"_horizExpansion\"f\"_baselineDelta\"f\"_attachmentBBox\"{_NSRect=\"origin\"" |
| 272 |
"{_NSPoint=\"x\"f\"y\"f}\"size\"{_NSSize=\"width\"f\"height\"f}}\"ll\"q\"llp\"^q\"ull\"" |
| 273 |
"Q\"ullp\"^Q\"a\"@\"a1\"@\"a2\"@\"b\":\"b1\":\"b2\":\"str1\"*\"str2\"*\"str3\"*\"str4\"" |
| 274 |
"*\"_rFlags\"{?=\"_isAttachmentRun\"b1\"_hasPositionalStake\"b1\"_isDefaultFace\"" |
| 275 |
"b1\"_hasCombiningMarks\"b1\"_isScreenFont\"b1\"_reserved\"b27}}"); |
| 276 |
/*"{?=\"_attributes\"@\"NSDictionary\"\"_font\"@\"NSFont\"\"_characterLength\"q\"_nominalGlyphLocation\"q\"p\"^q\"_defaultLineHeight\"f\"_defaultBaselineOffset\"f\"_horizExpansion\"f\"_baselineDelta\"f\"_attachmentBBox\"{_NSRect=\"origin\"{_NSPoint=\"x\"f\"y\"f}\"size\"{_NSSize=\"width\"f\"height\"f}}\"ll\"q\"llp\"^q\"ull\"Q\"ullp\"^Q\"a\"@\"a1\"@\"a2\"@\"b\":\"b1\":\"b2\"^{objc_selector}\"str1\"*\"str2\"*\"str3\"*\"str4\"*\"_rFlags\"{?=\"_isAttachmentRun\"b1\"_hasPositionalStake\"b1\"_isDefaultFace\"b1\"_hasCombiningMarks\"b1\"_isScreenFont\"b1\"_reserved\"b27}}"*/ |
| 277 |
return 0; |
| 278 |
} |