Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(120)

Side by Side Diff: Source/WebCore/platform/mac/SoftLinking.h

Issue 13713003: Remove all of WebCore/platform/mac which is not mentioned in WebCore.gypi. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Added back a couple needed headers Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/WebCore/platform/mac/SharedTimerMac.mm ('k') | Source/WebCore/platform/mac/SoundMac.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2007 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
14 * its contributors may be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29 #import <wtf/Assertions.h>
30 #import <dlfcn.h>
31
32 #define SOFT_LINK_LIBRARY(lib) \
33 static void* lib##Library() \
34 { \
35 static void* dylib = dlopen("/usr/lib/" #lib ".dylib", RTLD_NOW); \
36 ASSERT_WITH_MESSAGE(dylib, "%s", dlerror()); \
37 return dylib; \
38 }
39
40 #define SOFT_LINK_FRAMEWORK(framework) \
41 static void* framework##Library() \
42 { \
43 static void* frameworkLibrary = dlopen("/System/Library/Frameworks/" #fr amework ".framework/" #framework, RTLD_NOW); \
44 ASSERT_WITH_MESSAGE(frameworkLibrary, "%s", dlerror()); \
45 return frameworkLibrary; \
46 }
47
48 #define SOFT_LINK_FRAMEWORK_OPTIONAL(framework) \
49 static void* framework##Library() \
50 { \
51 static void* frameworkLibrary = dlopen("/System/Library/Frameworks/" #fr amework ".framework/" #framework, RTLD_NOW); \
52 return frameworkLibrary; \
53 }
54
55 #define SOFT_LINK_STAGED_FRAMEWORK_OPTIONAL(framework, unstagedLocation, version ) \
56 static void* framework##Library() \
57 { \
58 static void* frameworkLibrary = ^{ \
59 void* result = dlopen("/System/Library/" #unstagedLocation "/" #fram ework ".framework/Versions/" #version "/" #framework, RTLD_LAZY); \
60 if (!result) \
61 result = dlopen("/System/Library/StagedFrameworks/Safari/" #fram ework ".framework/Versions/" #version "/" #framework, RTLD_LAZY); \
62 return result; \
63 }(); \
64 return frameworkLibrary; \
65 }
66
67 #define SOFT_LINK_FRAMEWORK_IN_CORESERVICES_UMBRELLA(framework) \
68 static void* framework##Library() \
69 { \
70 static void* frameworkLibrary = dlopen("/System/Library/Frameworks/CoreS ervices.framework/Frameworks/" #framework ".framework/" #framework, RTLD_NOW); \
71 ASSERT_WITH_MESSAGE(frameworkLibrary, "%s", dlerror()); \
72 return frameworkLibrary; \
73 }
74
75 #define SOFT_LINK(framework, functionName, resultType, parameterDeclarations, pa rameterNames) \
76 static resultType init##functionName parameterDeclarations; \
77 static resultType (*softLink##functionName) parameterDeclarations = init##fu nctionName; \
78 \
79 static resultType init##functionName parameterDeclarations \
80 { \
81 softLink##functionName = (resultType (*) parameterDeclarations) dlsym(fr amework##Library(), #functionName); \
82 ASSERT_WITH_MESSAGE(softLink##functionName, "%s", dlerror()); \
83 return softLink##functionName parameterNames; \
84 }\
85 \
86 inline resultType functionName parameterDeclarations \
87 {\
88 return softLink##functionName parameterNames; \
89 }
90
91 /* callingConvention is unused on Mac but is here to keep the macro prototype th e same between Mac and Windows. */
92 #define SOFT_LINK_OPTIONAL(framework, functionName, resultType, callingConventio n, parameterDeclarations) \
93 typedef resultType (*functionName##PtrType) parameterDeclarations; \
94 \
95 static functionName##PtrType functionName##Ptr() \
96 { \
97 static functionName##PtrType ptr = reinterpret_cast<functionName##PtrTyp e>(dlsym(framework##Library(), #functionName)); \
98 return ptr; \
99 }
100
101 #define SOFT_LINK_CLASS(framework, className) \
102 static Class init##className(); \
103 static Class (*get##className##Class)() = init##className; \
104 static Class class##className; \
105 \
106 static Class className##Function() \
107 { \
108 return class##className; \
109 }\
110 \
111 static Class init##className() \
112 { \
113 framework##Library(); \
114 class##className = objc_getClass(#className); \
115 ASSERT(class##className); \
116 get##className##Class = className##Function; \
117 return class##className; \
118 }
119
120 #define SOFT_LINK_POINTER(framework, name, type) \
121 static type init##name(); \
122 static type (*get##name)() = init##name; \
123 static type pointer##name; \
124 \
125 static type name##Function() \
126 { \
127 return pointer##name; \
128 }\
129 \
130 static type init##name() \
131 { \
132 void** pointer = static_cast<void**>(dlsym(framework##Library(), #name)) ; \
133 ASSERT_WITH_MESSAGE(pointer, "%s", dlerror()); \
134 pointer##name = static_cast<type>(*pointer); \
135 get##name = name##Function; \
136 return pointer##name; \
137 }
138
139 #define SOFT_LINK_POINTER_OPTIONAL(framework, name, type) \
140 static type init##name(); \
141 static type (*get##name)() = init##name; \
142 static type pointer##name; \
143 \
144 static type name##Function() \
145 { \
146 return pointer##name; \
147 }\
148 \
149 static type init##name() \
150 { \
151 void** pointer = static_cast<void**>(dlsym(framework##Library(), #name)) ; \
152 if (pointer) \
153 pointer##name = static_cast<type>(*pointer); \
154 get##name = name##Function; \
155 return pointer##name; \
156 }
157
158 #define SOFT_LINK_CONSTANT(framework, name, type) \
159 static type init##name(); \
160 static type (*get##name)() = init##name; \
161 static type constant##name; \
162 \
163 static type name##Function() \
164 { \
165 return constant##name; \
166 }\
167 \
168 static type init##name() \
169 { \
170 void* constant = dlsym(framework##Library(), #name); \
171 ASSERT_WITH_MESSAGE(constant, "%s", dlerror()); \
172 constant##name = *static_cast<type*>(constant); \
173 get##name = name##Function; \
174 return constant##name; \
175 }
OLDNEW
« no previous file with comments | « Source/WebCore/platform/mac/SharedTimerMac.mm ('k') | Source/WebCore/platform/mac/SoundMac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698