VirtualBox

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

Last change on this file since 30122 was 30122, checked in by vboxsync, 15 years ago

FE/Qt4-OSX/Global: Split the event handling methods and the Qt methods for usage without Qt.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 1.8 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#ifdef __OBJC__
39
40/* Global includes */
41#import <Foundation/NSAutoreleasePool.h>
42
43/* Helper class for automatic creation & destroying of a cocoa auto release
44 pool. */
45class CocoaAutoreleasePool
46{
47public:
48 inline CocoaAutoreleasePool()
49 {
50 mPool = [[NSAutoreleasePool alloc] init];
51 }
52 inline ~CocoaAutoreleasePool()
53 {
54 [mPool release];
55 }
56
57private:
58 NSAutoreleasePool *mPool;
59};
60
61#endif /* __OBJC__ */
62
63#endif /* __VBoxCocoa_h__ */
64
Note: See TracBrowser for help on using the repository browser.

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