Commit 492b9c4
committed
ui_cocoa: converge HAVE_COCOA and HAVE_COCOA_METAL on ARC/MRR
21 preprocessor blocks in ui_cocoa.m guarded [... release] and
[... autorelease] calls behind `#ifndef HAVE_COCOA_METAL`. Plus
one -dealloc override gated on the same. This was using
HAVE_COCOA_METAL as a proxy for "are we compiled under ARC?".
The proxy is brittle:
Build target ARC? MRR?
qb/make (any) no YES (ui_cocoa.m always MRR;
only metal.m + mfi_joypad.m
get -fobjc-arc per Makefile
lines 275-276)
RetroArch.xcodeproj YES no (BaseConfig.xcconfig:182
RetroArch_Metal.xcodeproj YES no CLANG_ENABLE_OBJC_ARC=YES
RetroArch_OSX107.xcodeproj YES no cascades down)
RetroArch_PPC.xcodeproj no YES (explicit override to NO)
The HAVE_COCOA_METAL-based guard happens to be right for 3 of
these 5 by coincidence (Metal xcodeproj + PPC xcodeproj + qb/make),
but wrong for the two that flip the correlation. The clang-
documented discriminator is __has_feature(objc_arc), which is
exactly true under ARC and false under MRR regardless of other
build options.
Add three macros in cocoa_defines.h that expand to the right thing
either way:
RARCH_RELEASE(x) [(x) release] / ((void)0) under ARC
RARCH_AUTORELEASE(x) [(x) autorelease] / ((void)0) under ARC
RARCH_SUPER_DEALLOC() [super dealloc] / ((void)0) under ARC
Wrapped in the standard __has_feature polyfill so GCC 4.0 (Xcode
3.1, which predates ARC and __has_feature both) falls through to
the MRR branch, which is correct.
Replace 21 conditional release/autorelease blocks with unconditional
macro calls. Gate the -dealloc override on #if !__has_feature
(objc_arc) instead of #ifndef HAVE_COCOA_METAL - ARC auto-generates
-dealloc from strong ivars and forbids explicit overrides that just
call [super dealloc], so the method stays conditional but on the
correct axis.
The one remaining #ifndef HAVE_COCOA_METAL site (now line 646,
the addSubview:[CocoaView get] / makeFirstResponder: block) is a
legitimate platform branch - Metal installs CocoaView via
apple_platform.renderView through a different codepath - and
stays put.
Net change: -10 LoC, -21 preprocessor blocks, zero runtime
behaviour change on any of the five build configurations.1 parent 623d387 commit 492b9c4
2 files changed
Lines changed: 63 additions & 73 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
76 | 105 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
609 | 609 | | |
610 | 610 | | |
611 | 611 | | |
612 | | - | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
613 | 616 | | |
614 | 617 | | |
615 | | - | |
616 | | - | |
| 618 | + | |
| 619 | + | |
617 | 620 | | |
618 | 621 | | |
619 | 622 | | |
| |||
1119 | 1122 | | |
1120 | 1123 | | |
1121 | 1124 | | |
1122 | | - | |
1123 | | - | |
1124 | | - | |
| 1125 | + | |
1125 | 1126 | | |
1126 | 1127 | | |
1127 | 1128 | | |
| |||
1140 | 1141 | | |
1141 | 1142 | | |
1142 | 1143 | | |
1143 | | - | |
1144 | | - | |
1145 | | - | |
1146 | | - | |
| 1144 | + | |
| 1145 | + | |
1147 | 1146 | | |
1148 | 1147 | | |
1149 | 1148 | | |
| |||
1157 | 1156 | | |
1158 | 1157 | | |
1159 | 1158 | | |
1160 | | - | |
1161 | | - | |
1162 | | - | |
| 1159 | + | |
1163 | 1160 | | |
1164 | 1161 | | |
1165 | 1162 | | |
| |||
1181 | 1178 | | |
1182 | 1179 | | |
1183 | 1180 | | |
1184 | | - | |
1185 | | - | |
1186 | | - | |
1187 | | - | |
| 1181 | + | |
| 1182 | + | |
1188 | 1183 | | |
1189 | 1184 | | |
1190 | 1185 | | |
1191 | 1186 | | |
1192 | 1187 | | |
1193 | | - | |
1194 | | - | |
1195 | | - | |
| 1188 | + | |
1196 | 1189 | | |
1197 | 1190 | | |
1198 | 1191 | | |
| |||
1209 | 1202 | | |
1210 | 1203 | | |
1211 | 1204 | | |
1212 | | - | |
1213 | | - | |
1214 | | - | |
1215 | | - | |
| 1205 | + | |
| 1206 | + | |
1216 | 1207 | | |
1217 | 1208 | | |
1218 | 1209 | | |
| |||
1227 | 1218 | | |
1228 | 1219 | | |
1229 | 1220 | | |
1230 | | - | |
1231 | | - | |
1232 | | - | |
1233 | | - | |
| 1221 | + | |
| 1222 | + | |
1234 | 1223 | | |
1235 | 1224 | | |
1236 | 1225 | | |
| |||
1241 | 1230 | | |
1242 | 1231 | | |
1243 | 1232 | | |
1244 | | - | |
1245 | | - | |
1246 | | - | |
1247 | | - | |
| 1233 | + | |
| 1234 | + | |
1248 | 1235 | | |
1249 | 1236 | | |
1250 | 1237 | | |
| |||
1257 | 1244 | | |
1258 | 1245 | | |
1259 | 1246 | | |
1260 | | - | |
1261 | | - | |
1262 | | - | |
1263 | | - | |
| 1247 | + | |
| 1248 | + | |
1264 | 1249 | | |
1265 | 1250 | | |
1266 | 1251 | | |
| |||
1271 | 1256 | | |
1272 | 1257 | | |
1273 | 1258 | | |
1274 | | - | |
1275 | | - | |
1276 | | - | |
| 1259 | + | |
1277 | 1260 | | |
1278 | 1261 | | |
1279 | 1262 | | |
| |||
1282 | 1265 | | |
1283 | 1266 | | |
1284 | 1267 | | |
1285 | | - | |
1286 | | - | |
1287 | | - | |
| 1268 | + | |
1288 | 1269 | | |
1289 | 1270 | | |
1290 | 1271 | | |
| |||
1311 | 1292 | | |
1312 | 1293 | | |
1313 | 1294 | | |
1314 | | - | |
1315 | | - | |
1316 | | - | |
1317 | | - | |
| 1295 | + | |
| 1296 | + | |
1318 | 1297 | | |
1319 | 1298 | | |
1320 | 1299 | | |
| |||
1327 | 1306 | | |
1328 | 1307 | | |
1329 | 1308 | | |
1330 | | - | |
1331 | | - | |
1332 | | - | |
| 1309 | + | |
1333 | 1310 | | |
1334 | 1311 | | |
1335 | 1312 | | |
| |||
1345 | 1322 | | |
1346 | 1323 | | |
1347 | 1324 | | |
1348 | | - | |
1349 | | - | |
1350 | | - | |
| 1325 | + | |
1351 | 1326 | | |
1352 | 1327 | | |
1353 | 1328 | | |
| |||
1362 | 1337 | | |
1363 | 1338 | | |
1364 | 1339 | | |
1365 | | - | |
1366 | | - | |
1367 | | - | |
| 1340 | + | |
1368 | 1341 | | |
1369 | 1342 | | |
1370 | 1343 | | |
1371 | 1344 | | |
1372 | 1345 | | |
1373 | | - | |
1374 | | - | |
1375 | | - | |
| 1346 | + | |
1376 | 1347 | | |
1377 | 1348 | | |
1378 | 1349 | | |
1379 | 1350 | | |
1380 | 1351 | | |
1381 | | - | |
1382 | | - | |
1383 | | - | |
| 1352 | + | |
1384 | 1353 | | |
1385 | 1354 | | |
1386 | 1355 | | |
1387 | 1356 | | |
1388 | 1357 | | |
1389 | | - | |
1390 | | - | |
1391 | | - | |
| 1358 | + | |
1392 | 1359 | | |
1393 | 1360 | | |
1394 | 1361 | | |
1395 | 1362 | | |
1396 | 1363 | | |
1397 | | - | |
1398 | | - | |
1399 | | - | |
| 1364 | + | |
1400 | 1365 | | |
1401 | 1366 | | |
1402 | 1367 | | |
1403 | 1368 | | |
1404 | 1369 | | |
1405 | | - | |
1406 | | - | |
1407 | | - | |
| 1370 | + | |
1408 | 1371 | | |
1409 | 1372 | | |
1410 | | - | |
1411 | | - | |
1412 | | - | |
| 1373 | + | |
1413 | 1374 | | |
1414 | 1375 | | |
1415 | 1376 | | |
| |||
0 commit comments