blob: 9c0831d8624319cc35983ff3c67b1a0dbed63fc2 [file] [log] [blame]
Jake Farrell9689d892011-12-06 01:07:17 +00001/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20/*
21 * TObjective-C.h is for supporting coexistence of both the ARC (Automatic
22 * Reference Counting) mode and the Non-ARC mode of Objective-C
23 * in the same source code.
24 *
25 * 2011/11/14 HIRANO Satoshi (AIST, Japan)
26 *
27 * Before:
28 *
29 * var = [aObject retain];
30 * [aObject release];
31 * [aObject autorelease];
32 * [super dealloc];
33 * CFFunction(obj);
34 *
35 * ARC and Non-ARC compatible:
36 *
37 * #import "TObjective-C.h"
38 * var = [aObject retain_stub];
39 * [aObject release_stub];
40 * [aObject autorelease_stub];
41 * [super dealloc_stub];
42 * CFFunction(bridge_stub obj);
43 *
44 * Don't use retain_stub for @property(retain).
45 * Use NSAutoreleasePool like this:
46 * #if __has_feature(objc_arc)
47 * @autoreleasepool {
48 * // code
49 * }
50 * #else
51 * NSAutoReleasePool *pool = [[NSAutoReleasePool alloc] init...
52 * // code
53 * [pool release];
54 * #endif
55 */
56
57
58#if !defined(retain_stub)
59#if __has_feature(objc_arc)
60#define retain_stub self
61#define autorelease_stub self
62#define release_stub self
63#define dealloc_stub self
64#define bridge_stub __bridge
65#else
66#define retain_stub retain
67#define autorelease_stub autorelease
68#define release_stub release
69#define dealloc_stub dealloc
70#define bridge_stub
71#endif
72#endif