VirtualBox

source: vbox/trunk/include/VBox/VBoxCocoa.h@ 31241

Last change on this file since 31241 was 30126, checked in by vboxsync, 14 years ago

OpenGL-OSX: use new VBoxCocoa.h include file

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 1.9 KB
Line 
1/** @file
2 *
3 * VBoxCocoa Helper
4 */
5
6/*
7 * Copyright (C) 2009-2010 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifndef __VBoxCocoa_h__
19#define __VBoxCocoa_h__
20
21/* Macro which add a typedef of the given Cocoa class in an appropriate form
22 * for the current context. This means void* in the C/CPP context and
23 * NSWhatever* in the ObjC/ObjCPP context. Use
24 * NativeNSWhateverRef/ConstNativeNSWhateverRef when you reference the Cocoa
25 * type somewhere. The use of this prevents extensive casting of void* to the
26 * right type in the Cocoa context. */
27#ifdef __OBJC__
28#define ADD_COCOA_NATIVE_REF(CocoaClass) \
29@class CocoaClass; \
30typedef CocoaClass *Native##CocoaClass##Ref; \
31typedef const CocoaClass *ConstNative##CocoaClass##Ref
32#else /* __OBJC__ */
33#define ADD_COCOA_NATIVE_REF(CocoaClass) \
34typedef void *Native##CocoaClass##Ref; \
35typedef const void *ConstNative##CocoaClass##Ref
36#endif /* __OBJC__ */
37
38/* Check for OBJC++ */
39#if defined(__OBJC__) && defined (__cplusplus)
40
41/* Global includes */
42#import <Foundation/NSAutoreleasePool.h>
43
44/* Helper class for automatic creation & destroying of a cocoa auto release
45 pool. */
46class CocoaAutoreleasePool
47{
48public:
49 inline CocoaAutoreleasePool()
50 {
51 mPool = [[NSAutoreleasePool alloc] init];
52 }
53 inline ~CocoaAutoreleasePool()
54 {
55 [mPool release];
56 }
57
58private:
59 NSAutoreleasePool *mPool;
60};
61
62#endif /* __OBJC__ */
63
64#endif /* __VBoxCocoa_h__ */
65
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette