diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dstep/coreservices/carboncore/Components.d	Sat Aug 01 15:03:28 2009 +0200
@@ -0,0 +1,374 @@
+/**
+ * Copyright: Copyright (c) 2009 Jacob Carlborg.
+ * Authors: Jacob Carlborg
+ * Version: Initial created: Jul 21, 2009 
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0)
+ */
+module dstep.coreservices.carboncore.Components;
+
+//import dstep.AvailabilityMacros;
+import dstep.coreservices.carboncore.Files;
+import dstep.coreservices.carboncore.MacErrors;
+import dstep.coreservices.carboncore.MacTypes;
+import dstep.coreservices.carboncore.MixedMode;
+import dstep.coreservices.carboncore.Resources;
+import dstep.internal.Version;
+import dstep.objc.bridge.TypeEncoding;
+
+alias ComponentResource* ComponentResourcePtr;
+alias ComponentResourcePtr* ComponentResourceHandle;
+alias ExtComponentResource* ExtComponentResourcePtr;
+alias ExtComponentResourcePtr* ExtComponentResourceHandle;
+alias ComponentRecord* Component;
+alias ComponentInstanceRecord* ComponentInstance;
+alias RegisteredComponentRecord* RegisteredComponentRecordPtr;
+alias RegisteredComponentInstanceRecord* RegisteredComponentInstanceRecordPtr;
+alias int ComponentResult;
+alias uint CSComponentsThreadMode;
+alias ComponentMPWorkFunctionHeaderRecord* ComponentMPWorkFunctionHeaderRecordPtr;
+alias ComponentMPWorkFunctionProcPtr ComponentMPWorkFunctionUPP;
+alias ComponentRoutineProcPtr ComponentRoutineUPP;
+alias GetMissingComponentResourceProcPtr GetMissingComponentResourceUPP;
+alias UniversalProcPtr ComponentFunctionUPP;
+
+extern (C)
+{
+	alias short function (Component, uint, short, void*, Handle*) GetMissingComponentResourceProcPtr;
+	alias int function (void*, ComponentMPWorkFunctionHeaderRecordPtr) ComponentMPWorkFunctionProcPtr;
+	alias int function (ComponentParameters*, Handle) ComponentRoutineProcPtr;
+}
+
+// This is needed otherwise the enums will fail compiling with gdc
+version (GNU)
+{
+	private
+	{
+		const __kAppleManufacturer = getOSType!("appl");
+		const __kComponentResourceType = getOSType!("thng");
+		const __kComponentAliasResourceType = getOSType!("thga");
+
+	}
+}
+
+enum
+{
+	kAppleManufacturer = getOSType!("appl"),
+	kComponentResourceType = getOSType!("thng"),
+	kComponentAliasResourceType = getOSType!("thga")
+}
+
+enum
+{
+	kAnyComponentType = 0,
+	kAnyComponentSubType = 0,
+	kAnyComponentManufacturer = 0,
+	kAnyComponentFlagsMask = 0
+}
+
+static if (D_LP64)
+{
+	enum : long
+	{
+		cmpThreadSafe = 1L << 28,
+		cmpIsMissing = 1L << 29,
+		cmpWantsRegisterMessage = 1L << 31
+	}
+}
+
+else
+{
+	enum
+	{
+		cmpThreadSafe = 1 << 28,
+		cmpIsMissing = 1 << 29,
+		cmpWantsRegisterMessage = 1 << 31
+	}
+}
+
+enum
+{
+	kComponentOpenSelect = -1,
+	kComponentCloseSelect = -2,
+	kComponentCanDoSelect = -3,
+	kComponentVersionSelect = -4,
+	kComponentRegisterSelect = -5,
+	kComponentTargetSelect = -6,
+	kComponentUnregisterSelect = -7,
+	kComponentGetMPWorkFunctionSelect = -8,
+	kComponentExecuteWiredActionSelect = -9,
+	kComponentGetPublicResourceSelect = -10
+}
+
+enum
+{
+	componentDoAutoVersion = (1 << 0),
+	componentWantsUnregister = (1 << 1),
+	componentAutoVersionIncludeFlags = (1 << 2),
+	componentHasMultiplePlatforms = (1 << 3),
+	componentLoadResident = (1 << 4)
+}
+
+enum
+{
+	defaultComponentIdentical = 0,
+	defaultComponentAnyFlags = 1,
+	defaultComponentAnyManufacturer = 2,
+	defaultComponentAnySubType = 4,
+	defaultComponentAnyFlagsAnyManufacturer = (defaultComponentAnyFlags + defaultComponentAnyManufacturer),
+	defaultComponentAnyFlagsAnyManufacturerAnySubType = (defaultComponentAnyFlags + defaultComponentAnyManufacturer + defaultComponentAnySubType)
+}
+
+enum
+{
+	registerComponentGlobal = 1,
+	registerComponentNoDuplicates = 2,
+	registerComponentAfterExisting = 4,
+	registerComponentAliasesOnly = 8
+}
+
+enum
+{
+	platform68k = 1,
+	platformPowerPC = 2,
+	platformInterpreted = 3,
+	platformWin32 = 4,
+	platformPowerPCNativeEntryPoint = 5,
+	platformIA32NativeEntryPoint = 6,
+	platformPowerPC64NativeEntryPoint = 7,
+	platformX86_64NativeEntryPoint = 8
+}
+
+enum
+{
+	platformIRIXmips = 1000,
+	platformSunOSsparc = 1100,
+	platformSunOSintel = 1101,
+	platformLinuxppc = 1200,
+	platformLinuxintel = 1201,
+	platformAIXppc = 1300,
+	platformNeXTIntel = 1400,
+	platformNeXTppc = 1401,
+	platformNeXTsparc = 1402,
+	platformNeXT68k = 1403,
+	platformMacOSx86 = 1500
+}
+
+enum
+{
+	mpWorkFlagDoWork = (1 << 0),
+	mpWorkFlagDoCompletion = (1 << 1),
+	mpWorkFlagCopyWorkBlock = (1 << 2),
+	mpWorkFlagDontBlock = (1 << 3),
+	mpWorkFlagGetProcessorCount = (1 << 4),
+	mpWorkFlagGetIsRunning = (1 << 6)
+}
+
+enum
+{
+	cmpAliasNoFlags = 0,
+	cmpAliasOnlyThisFile = 1
+}
+
+enum
+{
+	kCSAcceptAllComponentsMode = 0,
+	kCSAcceptThreadSafeComponentsOnlyMode = 1
+}
+
+enum
+{
+	uppComponentFunctionImplementedProcInfo = 0x000002F0,
+	uppGetComponentVersionProcInfo = 0x000000F0,
+	uppComponentSetTargetProcInfo = 0x000003F0,
+	uppCallComponentOpenProcInfo = 0x000003F0,
+	uppCallComponentCloseProcInfo = 0x000003F0,
+	uppCallComponentCanDoProcInfo = 0x000002F0,
+	uppCallComponentVersionProcInfo = 0x000000F0,
+	uppCallComponentRegisterProcInfo = 0x000000F0,
+	uppCallComponentTargetProcInfo = 0x000003F0,
+	uppCallComponentUnregisterProcInfo = 0x000000F0,
+	uppCallComponentGetMPWorkFunctionProcInfo = 0x00000FF0,
+	uppCallComponentGetPublicResourceProcInfo = 0x00003BF0
+}
+
+struct ComponentDescription
+{
+	uint componentType;
+	uint componentSubType;
+	uint componentManufacturer;
+	uint componentFlags;
+	uint componentFlagsMask;
+}
+
+
+struct ResourceSpec
+{
+	uint resType;
+	short resID;
+}
+
+
+struct ComponentResource
+{
+	ComponentDescription cd;
+	ResourceSpec component;
+	ResourceSpec componentName;
+	ResourceSpec componentInfo;
+	ResourceSpec componentIcon;
+}
+
+
+struct ComponentPlatformInfo
+{
+	int componentFlags;
+	ResourceSpec component;
+	short platformType;
+}
+
+
+struct ComponentResourceExtension
+{
+	int componentVersion;
+	int componentRegisterFlags;
+	short componentIconFamily;
+}
+
+
+struct ComponentPlatformInfoArray
+{
+	int count;
+	ComponentPlatformInfo* platformArray;
+}
+
+
+struct ExtComponentResource
+{
+	ComponentDescription cd;
+	ResourceSpec component;
+	ResourceSpec componentName;
+	ResourceSpec componentInfo;
+	ResourceSpec componentIcon;
+	int componentVersion;
+	int componentRegisterFlags;
+	short componentIconFamily;
+	int count;
+	ComponentPlatformInfo* platformArray;
+}
+
+
+struct ComponentAliasResource
+{
+	ComponentResource cr;
+	ComponentDescription aliasCD;
+}
+
+
+struct ComponentParameters
+{
+	ubyte flags;
+	ubyte paramSize;
+	short what;
+	uint padding;
+	long* params;
+}
+
+
+struct ComponentRecord
+{
+	long* data;
+}
+
+
+struct ComponentInstanceRecord
+{
+	long* data;
+}
+
+
+struct RegisteredComponentRecord
+{
+	long* data;
+}
+
+
+struct RegisteredComponentInstanceRecord
+{
+	long* data;
+}
+
+
+struct ComponentMPWorkFunctionHeaderRecord
+{
+	uint headerSize;
+	uint recordSize;
+	uint workFlags;
+	ushort processorCount;
+	ubyte unused;
+	ubyte isRunning;
+}
+
+extern (C)
+{
+	void CSSetComponentsThreadMode (uint mode);
+	uint CSGetComponentsThreadMode ();
+	ComponentFunctionUPP NewComponentFunctionUPP (ProcPtr userRoutine, uint procInfo);
+	void DisposeComponentFunctionUPP (ComponentFunctionUPP userUPP);
+	Component RegisterComponent (ComponentDescription* cd, ComponentRoutineUPP componentEntryPoint, short global, Handle componentName, Handle componentInfo, Handle componentIcon);
+	Component RegisterComponentResource (ComponentResourceHandle cr, short global);
+	short UnregisterComponent (Component aComponent);
+	Component FindNextComponent (Component aComponent, ComponentDescription* looking);
+	int CountComponents (ComponentDescription* looking);
+	short GetComponentInfo (Component aComponent, ComponentDescription* cd, Handle componentName, Handle componentInfo, Handle componentIcon);
+	int GetComponentListModSeed ();
+	int GetComponentTypeModSeed (uint componentType);
+	short OpenAComponent (Component aComponent, ComponentInstance* ci);
+	ComponentInstance OpenComponent (Component aComponent);
+	short CloseComponent (ComponentInstance aComponentInstance);
+	short GetComponentInstanceError (ComponentInstance aComponentInstance);
+	Component ResolveComponentAlias (Component aComponent);
+	short GetComponentPublicResource (Component aComponent, uint resourceType, short resourceID, Handle* theResource);
+	short GetComponentPublicResourceList (uint resourceType, short resourceID, int flags, ComponentDescription* cd, GetMissingComponentResourceUPP missingProc, void* refCon, void* atomContainerPtr);
+	short GetComponentPublicIndString (Component aComponent, ubyte[256] theString, short strListID, short index);
+	void SetComponentInstanceError (ComponentInstance aComponentInstance, short theError);
+	int GetComponentRefcon (Component aComponent);
+	void SetComponentRefcon (Component aComponent, int theRefcon);
+	short OpenComponentResFile (Component aComponent);
+	short OpenAComponentResFile (Component aComponent, ResFileRefNum* resRef);
+	short CloseComponentResFile (short refnum);
+	short GetComponentResource (Component aComponent, uint resType, short resID, Handle* theResource);
+	short GetComponentIndString (Component aComponent, ubyte[256] theString, short strListID, short index);
+	Handle GetComponentInstanceStorage (ComponentInstance aComponentInstance);
+	void SetComponentInstanceStorage (ComponentInstance aComponentInstance, Handle theStorage);
+	int CountComponentInstances (Component aComponent);
+	int CallComponentFunction (ComponentParameters* params, ComponentFunctionUPP func);
+	int CallComponentFunctionWithStorage (Handle storage, ComponentParameters* params, ComponentFunctionUPP func);
+	int CallComponentFunctionWithStorageProcInfo (Handle storage, ComponentParameters* params, ProcPtr func, uint funcProcInfo);
+	int DelegateComponentCall (ComponentParameters* originalParams, ComponentInstance ci);
+	short SetDefaultComponent (Component aComponent, short flags);
+	ComponentInstance OpenDefaultComponent (uint componentType, uint componentSubType);
+	short OpenADefaultComponent (uint componentType, uint componentSubType, ComponentInstance* ci);
+	Component CaptureComponent (Component capturedComponent, Component capturingComponent);
+	short UncaptureComponent (Component aComponent);
+	int RegisterComponentResourceFile (short resRefNum, short global);
+	short RegisterComponentFileRef (FSRef* ref_, short global);
+	short RegisterComponentFileRefEntries (FSRef* ref_, short global, ComponentDescription* toRegister, uint registerCount);
+	int CallComponentOpen (ComponentInstance ci, ComponentInstance self);
+	int CallComponentClose (ComponentInstance ci, ComponentInstance self);
+	int CallComponentCanDo (ComponentInstance ci, short ftnNumber);
+	int CallComponentVersion (ComponentInstance ci);
+	int CallComponentRegister (ComponentInstance ci);
+	int CallComponentTarget (ComponentInstance ci, ComponentInstance target);
+	int CallComponentUnregister (ComponentInstance ci);
+	int CallComponentGetMPWorkFunction (ComponentInstance ci, ComponentMPWorkFunctionUPP* workFunction, void** refCon);
+	int CallComponentGetPublicResource (ComponentInstance ci, uint resourceType, short resourceID, Handle* resource);
+	int CallComponentDispatch (ComponentParameters* cp);
+	ComponentMPWorkFunctionUPP NewComponentMPWorkFunctionUPP (ComponentMPWorkFunctionProcPtr userRoutine);
+	ComponentRoutineUPP NewComponentRoutineUPP (ComponentRoutineProcPtr userRoutine);
+	GetMissingComponentResourceUPP NewGetMissingComponentResourceUPP (GetMissingComponentResourceProcPtr userRoutine);
+	void DisposeComponentMPWorkFunctionUPP (ComponentMPWorkFunctionUPP userUPP);
+	void DisposeComponentRoutineUPP (ComponentRoutineUPP userUPP);
+	void DisposeGetMissingComponentResourceUPP (GetMissingComponentResourceUPP userUPP);
+	int InvokeComponentMPWorkFunctionUPP (void* globalRefCon, ComponentMPWorkFunctionHeaderRecordPtr header, ComponentMPWorkFunctionUPP userUPP);
+	int InvokeComponentRoutineUPP (ComponentParameters* cp, Handle componentStorage, ComponentRoutineUPP userUPP);
+	short InvokeGetMissingComponentResourceUPP (Component c, uint resType, short resID, void* refCon, Handle* resource, GetMissingComponentResourceUPP userUPP);
+}
\ No newline at end of file