/[svn]/gigedit/trunk/src/gigedit/MacHelper.mm
ViewVC logotype

Contents of /gigedit/trunk/src/gigedit/MacHelper.mm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3068 - (show annotations) (download)
Mon Jan 2 22:13:01 2017 UTC (7 years, 3 months ago) by schoenebeck
File size: 1201 byte(s)
- Preparations for Xcode project update.

1 /*
2 Copyright (c) 2013 - 2017 Christian Schoenebeck
3
4 This file is part of "gigedit" and released under the terms of the
5 GNU General Public License version 2.
6 */
7
8 #import "MacHelper.h"
9 #import <Cocoa/Cocoa.h>
10 #import <stdio.h>
11
12 #if __clang__
13 # define HAS_OBJC_ARC __has_feature(objc_arc)
14 #else
15 # define HAS_OBJC_ARC 0
16 #endif
17
18 @interface MacHelper : NSObject {
19 @public
20 void (*m_fn)(void* info);
21 void* m_info;
22 }
23 @end
24
25 @implementation MacHelper
26
27 - (id)init {
28 if ((self = [super init])) {
29 m_fn = nil;
30 m_info = nil;
31 }
32 return self;
33 }
34
35 - (void)runCFunc {
36 (*m_fn)(m_info);
37 }
38
39 @end
40
41 #if defined(__cplusplus)
42 extern "C" {
43 #endif // __cplusplus
44
45 void macHelperRunCFuncOnMainThread(void (*fn)(void* info), void* info) {
46 MacHelper* obj = [[MacHelper alloc] init];
47 obj->m_fn = fn;
48 obj->m_info = info;
49 printf("perfoming selector on main thread ...\n"); fflush(stdout);
50 [obj performSelectorOnMainThread:@selector(runCFunc) withObject:obj waitUntilDone:NO];
51 printf("Selector scheduled async. (on main thread).\n"); fflush(stdout);
52 #if !HAS_OBJC_ARC
53 [obj release];
54 #endif
55 }
56
57 #if defined(__cplusplus)
58 }
59 #endif // __cplusplus

  ViewVC Help
Powered by ViewVC