comparison dstep/coreservices/carboncore/Components.d @ 11:07194b026fa4

Added bindings to a couple of frameworks, new license + some other things
author Jacob Carlborg <doob@me.com>
date Sat, 01 Aug 2009 15:03:28 +0200
parents
children
comparison
equal deleted inserted replaced
10:27e00625790b 11:07194b026fa4
1 /**
2 * Copyright: Copyright (c) 2009 Jacob Carlborg.
3 * Authors: Jacob Carlborg
4 * Version: Initial created: Jul 21, 2009
5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0)
6 */
7 module dstep.coreservices.carboncore.Components;
8
9 //import dstep.AvailabilityMacros;
10 import dstep.coreservices.carboncore.Files;
11 import dstep.coreservices.carboncore.MacErrors;
12 import dstep.coreservices.carboncore.MacTypes;
13 import dstep.coreservices.carboncore.MixedMode;
14 import dstep.coreservices.carboncore.Resources;
15 import dstep.internal.Version;
16 import dstep.objc.bridge.TypeEncoding;
17
18 alias ComponentResource* ComponentResourcePtr;
19 alias ComponentResourcePtr* ComponentResourceHandle;
20 alias ExtComponentResource* ExtComponentResourcePtr;
21 alias ExtComponentResourcePtr* ExtComponentResourceHandle;
22 alias ComponentRecord* Component;
23 alias ComponentInstanceRecord* ComponentInstance;
24 alias RegisteredComponentRecord* RegisteredComponentRecordPtr;
25 alias RegisteredComponentInstanceRecord* RegisteredComponentInstanceRecordPtr;
26 alias int ComponentResult;
27 alias uint CSComponentsThreadMode;
28 alias ComponentMPWorkFunctionHeaderRecord* ComponentMPWorkFunctionHeaderRecordPtr;
29 alias ComponentMPWorkFunctionProcPtr ComponentMPWorkFunctionUPP;
30 alias ComponentRoutineProcPtr ComponentRoutineUPP;
31 alias GetMissingComponentResourceProcPtr GetMissingComponentResourceUPP;
32 alias UniversalProcPtr ComponentFunctionUPP;
33
34 extern (C)
35 {
36 alias short function (Component, uint, short, void*, Handle*) GetMissingComponentResourceProcPtr;
37 alias int function (void*, ComponentMPWorkFunctionHeaderRecordPtr) ComponentMPWorkFunctionProcPtr;
38 alias int function (ComponentParameters*, Handle) ComponentRoutineProcPtr;
39 }
40
41 // This is needed otherwise the enums will fail compiling with gdc
42 version (GNU)
43 {
44 private
45 {
46 const __kAppleManufacturer = getOSType!("appl");
47 const __kComponentResourceType = getOSType!("thng");
48 const __kComponentAliasResourceType = getOSType!("thga");
49
50 }
51 }
52
53 enum
54 {
55 kAppleManufacturer = getOSType!("appl"),
56 kComponentResourceType = getOSType!("thng"),
57 kComponentAliasResourceType = getOSType!("thga")
58 }
59
60 enum
61 {
62 kAnyComponentType = 0,
63 kAnyComponentSubType = 0,
64 kAnyComponentManufacturer = 0,
65 kAnyComponentFlagsMask = 0
66 }
67
68 static if (D_LP64)
69 {
70 enum : long
71 {
72 cmpThreadSafe = 1L << 28,
73 cmpIsMissing = 1L << 29,
74 cmpWantsRegisterMessage = 1L << 31
75 }
76 }
77
78 else
79 {
80 enum
81 {
82 cmpThreadSafe = 1 << 28,
83 cmpIsMissing = 1 << 29,
84 cmpWantsRegisterMessage = 1 << 31
85 }
86 }
87
88 enum
89 {
90 kComponentOpenSelect = -1,
91 kComponentCloseSelect = -2,
92 kComponentCanDoSelect = -3,
93 kComponentVersionSelect = -4,
94 kComponentRegisterSelect = -5,
95 kComponentTargetSelect = -6,
96 kComponentUnregisterSelect = -7,
97 kComponentGetMPWorkFunctionSelect = -8,
98 kComponentExecuteWiredActionSelect = -9,
99 kComponentGetPublicResourceSelect = -10
100 }
101
102 enum
103 {
104 componentDoAutoVersion = (1 << 0),
105 componentWantsUnregister = (1 << 1),
106 componentAutoVersionIncludeFlags = (1 << 2),
107 componentHasMultiplePlatforms = (1 << 3),
108 componentLoadResident = (1 << 4)
109 }
110
111 enum
112 {
113 defaultComponentIdentical = 0,
114 defaultComponentAnyFlags = 1,
115 defaultComponentAnyManufacturer = 2,
116 defaultComponentAnySubType = 4,
117 defaultComponentAnyFlagsAnyManufacturer = (defaultComponentAnyFlags + defaultComponentAnyManufacturer),
118 defaultComponentAnyFlagsAnyManufacturerAnySubType = (defaultComponentAnyFlags + defaultComponentAnyManufacturer + defaultComponentAnySubType)
119 }
120
121 enum
122 {
123 registerComponentGlobal = 1,
124 registerComponentNoDuplicates = 2,
125 registerComponentAfterExisting = 4,
126 registerComponentAliasesOnly = 8
127 }
128
129 enum
130 {
131 platform68k = 1,
132 platformPowerPC = 2,
133 platformInterpreted = 3,
134 platformWin32 = 4,
135 platformPowerPCNativeEntryPoint = 5,
136 platformIA32NativeEntryPoint = 6,
137 platformPowerPC64NativeEntryPoint = 7,
138 platformX86_64NativeEntryPoint = 8
139 }
140
141 enum
142 {
143 platformIRIXmips = 1000,
144 platformSunOSsparc = 1100,
145 platformSunOSintel = 1101,
146 platformLinuxppc = 1200,
147 platformLinuxintel = 1201,
148 platformAIXppc = 1300,
149 platformNeXTIntel = 1400,
150 platformNeXTppc = 1401,
151 platformNeXTsparc = 1402,
152 platformNeXT68k = 1403,
153 platformMacOSx86 = 1500
154 }
155
156 enum
157 {
158 mpWorkFlagDoWork = (1 << 0),
159 mpWorkFlagDoCompletion = (1 << 1),
160 mpWorkFlagCopyWorkBlock = (1 << 2),
161 mpWorkFlagDontBlock = (1 << 3),
162 mpWorkFlagGetProcessorCount = (1 << 4),
163 mpWorkFlagGetIsRunning = (1 << 6)
164 }
165
166 enum
167 {
168 cmpAliasNoFlags = 0,
169 cmpAliasOnlyThisFile = 1
170 }
171
172 enum
173 {
174 kCSAcceptAllComponentsMode = 0,
175 kCSAcceptThreadSafeComponentsOnlyMode = 1
176 }
177
178 enum
179 {
180 uppComponentFunctionImplementedProcInfo = 0x000002F0,
181 uppGetComponentVersionProcInfo = 0x000000F0,
182 uppComponentSetTargetProcInfo = 0x000003F0,
183 uppCallComponentOpenProcInfo = 0x000003F0,
184 uppCallComponentCloseProcInfo = 0x000003F0,
185 uppCallComponentCanDoProcInfo = 0x000002F0,
186 uppCallComponentVersionProcInfo = 0x000000F0,
187 uppCallComponentRegisterProcInfo = 0x000000F0,
188 uppCallComponentTargetProcInfo = 0x000003F0,
189 uppCallComponentUnregisterProcInfo = 0x000000F0,
190 uppCallComponentGetMPWorkFunctionProcInfo = 0x00000FF0,
191 uppCallComponentGetPublicResourceProcInfo = 0x00003BF0
192 }
193
194 struct ComponentDescription
195 {
196 uint componentType;
197 uint componentSubType;
198 uint componentManufacturer;
199 uint componentFlags;
200 uint componentFlagsMask;
201 }
202
203
204 struct ResourceSpec
205 {
206 uint resType;
207 short resID;
208 }
209
210
211 struct ComponentResource
212 {
213 ComponentDescription cd;
214 ResourceSpec component;
215 ResourceSpec componentName;
216 ResourceSpec componentInfo;
217 ResourceSpec componentIcon;
218 }
219
220
221 struct ComponentPlatformInfo
222 {
223 int componentFlags;
224 ResourceSpec component;
225 short platformType;
226 }
227
228
229 struct ComponentResourceExtension
230 {
231 int componentVersion;
232 int componentRegisterFlags;
233 short componentIconFamily;
234 }
235
236
237 struct ComponentPlatformInfoArray
238 {
239 int count;
240 ComponentPlatformInfo* platformArray;
241 }
242
243
244 struct ExtComponentResource
245 {
246 ComponentDescription cd;
247 ResourceSpec component;
248 ResourceSpec componentName;
249 ResourceSpec componentInfo;
250 ResourceSpec componentIcon;
251 int componentVersion;
252 int componentRegisterFlags;
253 short componentIconFamily;
254 int count;
255 ComponentPlatformInfo* platformArray;
256 }
257
258
259 struct ComponentAliasResource
260 {
261 ComponentResource cr;
262 ComponentDescription aliasCD;
263 }
264
265
266 struct ComponentParameters
267 {
268 ubyte flags;
269 ubyte paramSize;
270 short what;
271 uint padding;
272 long* params;
273 }
274
275
276 struct ComponentRecord
277 {
278 long* data;
279 }
280
281
282 struct ComponentInstanceRecord
283 {
284 long* data;
285 }
286
287
288 struct RegisteredComponentRecord
289 {
290 long* data;
291 }
292
293
294 struct RegisteredComponentInstanceRecord
295 {
296 long* data;
297 }
298
299
300 struct ComponentMPWorkFunctionHeaderRecord
301 {
302 uint headerSize;
303 uint recordSize;
304 uint workFlags;
305 ushort processorCount;
306 ubyte unused;
307 ubyte isRunning;
308 }
309
310 extern (C)
311 {
312 void CSSetComponentsThreadMode (uint mode);
313 uint CSGetComponentsThreadMode ();
314 ComponentFunctionUPP NewComponentFunctionUPP (ProcPtr userRoutine, uint procInfo);
315 void DisposeComponentFunctionUPP (ComponentFunctionUPP userUPP);
316 Component RegisterComponent (ComponentDescription* cd, ComponentRoutineUPP componentEntryPoint, short global, Handle componentName, Handle componentInfo, Handle componentIcon);
317 Component RegisterComponentResource (ComponentResourceHandle cr, short global);
318 short UnregisterComponent (Component aComponent);
319 Component FindNextComponent (Component aComponent, ComponentDescription* looking);
320 int CountComponents (ComponentDescription* looking);
321 short GetComponentInfo (Component aComponent, ComponentDescription* cd, Handle componentName, Handle componentInfo, Handle componentIcon);
322 int GetComponentListModSeed ();
323 int GetComponentTypeModSeed (uint componentType);
324 short OpenAComponent (Component aComponent, ComponentInstance* ci);
325 ComponentInstance OpenComponent (Component aComponent);
326 short CloseComponent (ComponentInstance aComponentInstance);
327 short GetComponentInstanceError (ComponentInstance aComponentInstance);
328 Component ResolveComponentAlias (Component aComponent);
329 short GetComponentPublicResource (Component aComponent, uint resourceType, short resourceID, Handle* theResource);
330 short GetComponentPublicResourceList (uint resourceType, short resourceID, int flags, ComponentDescription* cd, GetMissingComponentResourceUPP missingProc, void* refCon, void* atomContainerPtr);
331 short GetComponentPublicIndString (Component aComponent, ubyte[256] theString, short strListID, short index);
332 void SetComponentInstanceError (ComponentInstance aComponentInstance, short theError);
333 int GetComponentRefcon (Component aComponent);
334 void SetComponentRefcon (Component aComponent, int theRefcon);
335 short OpenComponentResFile (Component aComponent);
336 short OpenAComponentResFile (Component aComponent, ResFileRefNum* resRef);
337 short CloseComponentResFile (short refnum);
338 short GetComponentResource (Component aComponent, uint resType, short resID, Handle* theResource);
339 short GetComponentIndString (Component aComponent, ubyte[256] theString, short strListID, short index);
340 Handle GetComponentInstanceStorage (ComponentInstance aComponentInstance);
341 void SetComponentInstanceStorage (ComponentInstance aComponentInstance, Handle theStorage);
342 int CountComponentInstances (Component aComponent);
343 int CallComponentFunction (ComponentParameters* params, ComponentFunctionUPP func);
344 int CallComponentFunctionWithStorage (Handle storage, ComponentParameters* params, ComponentFunctionUPP func);
345 int CallComponentFunctionWithStorageProcInfo (Handle storage, ComponentParameters* params, ProcPtr func, uint funcProcInfo);
346 int DelegateComponentCall (ComponentParameters* originalParams, ComponentInstance ci);
347 short SetDefaultComponent (Component aComponent, short flags);
348 ComponentInstance OpenDefaultComponent (uint componentType, uint componentSubType);
349 short OpenADefaultComponent (uint componentType, uint componentSubType, ComponentInstance* ci);
350 Component CaptureComponent (Component capturedComponent, Component capturingComponent);
351 short UncaptureComponent (Component aComponent);
352 int RegisterComponentResourceFile (short resRefNum, short global);
353 short RegisterComponentFileRef (FSRef* ref_, short global);
354 short RegisterComponentFileRefEntries (FSRef* ref_, short global, ComponentDescription* toRegister, uint registerCount);
355 int CallComponentOpen (ComponentInstance ci, ComponentInstance self);
356 int CallComponentClose (ComponentInstance ci, ComponentInstance self);
357 int CallComponentCanDo (ComponentInstance ci, short ftnNumber);
358 int CallComponentVersion (ComponentInstance ci);
359 int CallComponentRegister (ComponentInstance ci);
360 int CallComponentTarget (ComponentInstance ci, ComponentInstance target);
361 int CallComponentUnregister (ComponentInstance ci);
362 int CallComponentGetMPWorkFunction (ComponentInstance ci, ComponentMPWorkFunctionUPP* workFunction, void** refCon);
363 int CallComponentGetPublicResource (ComponentInstance ci, uint resourceType, short resourceID, Handle* resource);
364 int CallComponentDispatch (ComponentParameters* cp);
365 ComponentMPWorkFunctionUPP NewComponentMPWorkFunctionUPP (ComponentMPWorkFunctionProcPtr userRoutine);
366 ComponentRoutineUPP NewComponentRoutineUPP (ComponentRoutineProcPtr userRoutine);
367 GetMissingComponentResourceUPP NewGetMissingComponentResourceUPP (GetMissingComponentResourceProcPtr userRoutine);
368 void DisposeComponentMPWorkFunctionUPP (ComponentMPWorkFunctionUPP userUPP);
369 void DisposeComponentRoutineUPP (ComponentRoutineUPP userUPP);
370 void DisposeGetMissingComponentResourceUPP (GetMissingComponentResourceUPP userUPP);
371 int InvokeComponentMPWorkFunctionUPP (void* globalRefCon, ComponentMPWorkFunctionHeaderRecordPtr header, ComponentMPWorkFunctionUPP userUPP);
372 int InvokeComponentRoutineUPP (ComponentParameters* cp, Handle componentStorage, ComponentRoutineUPP userUPP);
373 short InvokeGetMissingComponentResourceUPP (Component c, uint resType, short resID, void* refCon, Handle* resource, GetMissingComponentResourceUPP userUPP);
374 }