Avi Drissman | dfd88085 | 2022-09-15 20:11:09 | [diff] [blame] | 1 | // Copyright 2006-2008 The Chromium Authors |
mmentovai@google.com | 49df602 | 2008-08-27 19:03:43 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
erikkay@google.com | ed2f233 | 2008-08-20 15:59:49 | [diff] [blame] | 4 | |
jeremy@chromium.org | 23887f04 | 2008-12-02 19:20:15 | [diff] [blame] | 5 | #include "platform_test.h" |
erikkay@google.com | ed2f233 | 2008-08-20 15:59:49 | [diff] [blame] | 6 | |
Avi Drissman | 35fc96c8 | 2023-07-27 17:13:39 | [diff] [blame] | 7 | // /!\ WARNING! |
| 8 | // |
| 9 | // Chromium compiles this file as ARC, but other dependencies pull it in and |
| 10 | // compile it as non-ARC. Be sure that this file compiles correctly with either |
| 11 | // build setting. |
| 12 | // |
| 13 | // /!\ WARNING! |
Avi Drissman | 3a2c390 | 2023-06-08 23:45:31 | [diff] [blame] | 14 | |
Avi Drissman | 491617c | 2023-04-13 17:33:15 | [diff] [blame] | 15 | // Note that this uses the direct runtime interface to the autorelease pool. |
| 16 | // https://clang.llvm.org/docs/AutomaticReferenceCounting.html#runtime-support |
Avi Drissman | 35fc96c8 | 2023-07-27 17:13:39 | [diff] [blame] | 17 | // This is so this can work correctly whether or not it's compiled for ARC. |
erikkay@google.com | ed2f233 | 2008-08-20 15:59:49 | [diff] [blame] | 18 | |
Avi Drissman | 491617c | 2023-04-13 17:33:15 | [diff] [blame] | 19 | extern "C" { |
| 20 | void* objc_autoreleasePoolPush(void); |
| 21 | void objc_autoreleasePoolPop(void* pool); |
erikkay@google.com | ed2f233 | 2008-08-20 15:59:49 | [diff] [blame] | 22 | } |
| 23 | |
Avi Drissman | 491617c | 2023-04-13 17:33:15 | [diff] [blame] | 24 | PlatformTest::PlatformTest() : autorelease_pool_(objc_autoreleasePoolPush()) {} |
| 25 | |
mark@chromium.org | c77043fc | 2009-08-20 22:37:59 | [diff] [blame] | 26 | PlatformTest::~PlatformTest() { |
Avi Drissman | 491617c | 2023-04-13 17:33:15 | [diff] [blame] | 27 | objc_autoreleasePoolPop(autorelease_pool_); |
erikkay@google.com | ed2f233 | 2008-08-20 15:59:49 | [diff] [blame] | 28 | } |