Path: blob/master/thirdparty/metal-cpp/Foundation/NSAutoreleasePool.hpp
21082 views
//-------------------------------------------------------------------------------------------------------------------------------------------------------------1//2// Foundation/NSAutoreleasePool.hpp3//4// Copyright 2020-2024 Apple Inc.5//6// Licensed under the Apache License, Version 2.0 (the "License");7// you may not use this file except in compliance with the License.8// You may obtain a copy of the License at9//10// http://www.apache.org/licenses/LICENSE-2.011//12// Unless required by applicable law or agreed to in writing, software13// distributed under the License is distributed on an "AS IS" BASIS,14// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.15// See the License for the specific language governing permissions and16// limitations under the License.17//18//-------------------------------------------------------------------------------------------------------------------------------------------------------------1920#pragma once2122//-------------------------------------------------------------------------------------------------------------------------------------------------------------2324#include "NSDefines.hpp"25#include "NSObject.hpp"26#include "NSPrivate.hpp"27#include "NSTypes.hpp"2829//-------------------------------------------------------------------------------------------------------------------------------------------------------------3031namespace NS32{33class AutoreleasePool : public Object34{35public:36static AutoreleasePool* alloc();37AutoreleasePool* init();3839void drain();4041void addObject(Object* pObject);4243static void showPools();44};45}4647//-------------------------------------------------------------------------------------------------------------------------------------------------------------4849_NS_INLINE NS::AutoreleasePool* NS::AutoreleasePool::alloc()50{51return NS::Object::alloc<AutoreleasePool>(_NS_PRIVATE_CLS(NSAutoreleasePool));52}5354//-------------------------------------------------------------------------------------------------------------------------------------------------------------5556_NS_INLINE NS::AutoreleasePool* NS::AutoreleasePool::init()57{58return NS::Object::init<AutoreleasePool>();59}6061//-------------------------------------------------------------------------------------------------------------------------------------------------------------6263_NS_INLINE void NS::AutoreleasePool::drain()64{65Object::sendMessage<void>(this, _NS_PRIVATE_SEL(drain));66}6768//-------------------------------------------------------------------------------------------------------------------------------------------------------------6970_NS_INLINE void NS::AutoreleasePool::addObject(Object* pObject)71{72Object::sendMessage<void>(this, _NS_PRIVATE_SEL(addObject_), pObject);73}7475//-------------------------------------------------------------------------------------------------------------------------------------------------------------7677_NS_INLINE void NS::AutoreleasePool::showPools()78{79Object::sendMessage<void>(_NS_PRIVATE_CLS(NSAutoreleasePool), _NS_PRIVATE_SEL(showPools));80}8182//-------------------------------------------------------------------------------------------------------------------------------------------------------------838485