view dstep/coreservices/ae/AEDataModel.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 source

/**
 * 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.ae.AEDataModel;

//import dstep.AvailabilityMacros;
import dstep.coreservices.carboncore.CarbonCore;
import dstep.internal.Version;
import dstep.objc.bridge.TypeEncoding;

struct OpaqueAEDataStorageType;

struct AEDesc
{
	uint descriptorType;
	AEDataStorage dataHandle;
}


struct AEKeyDesc
{
	uint descKey;
	AEDesc descContent;
}

alias uint DescType;
alias uint AEKeyword;
alias OpaqueAEDataStorageType* AEDataStorageType;
alias AEDataStorageType* AEDataStorage;
alias AEDesc* AEDescPtr;
alias AEDesc AEDescList;
alias AEDescList AERecord;
alias AEDesc AEAddressDesc;
alias AERecord AppleEvent;
alias AppleEvent* AppleEventPtr;
alias short AEReturnID;
alias int AETransactionID;
alias uint AEEventClass;
alias uint AEEventID;
alias byte AEArrayType;
alias short AESendPriority;
alias int AESendMode;
alias AECoerceDescProcPtr AECoerceDescUPP;
alias AECoercePtrProcPtr AECoercePtrUPP;
alias AECoerceDescUPP AECoercionHandlerUPP;
alias AEDisposeExternalProcPtr AEDisposeExternalUPP;
alias AEEventHandlerProcPtr AEEventHandlerUPP;
alias AEArrayData* AEArrayDataPointer;

extern (C)
{
	alias void function (void*, int, int) AEDisposeExternalProcPtr;
	alias short function (uint, void*, int, uint, int, AEDesc*) AECoercePtrProcPtr;
	alias short function (AppleEvent*, AppleEvent*, int) AEEventHandlerProcPtr;
	alias short function (AEDesc*, uint, int, AEDesc*) AECoerceDescProcPtr;
}

//This is needed otherwise the enums will fail compiling with gdc
version (GNU)
{
	private
	{
		const __typeBoolean = getOSType!("bool");
		const __typeChar = getOSType!("TEXT");
		const __typeStyledUnicodeText = getOSType!("sutx");
		const __typeEncodedString = getOSType!("encs");
		const __typeUnicodeText = getOSType!("utxt");
		const __typeCString = getOSType!("cstr");
		const __typePString = getOSType!("pstr");
		const __typeUTF16ExternalRepresentation = getOSType!("ut16");
		const __typeUTF8Text = getOSType!("utf8");
		const __typeSInt16 = getOSType!("shor");
		const __typeUInt16 = getOSType!("ushr");
		const __typeSInt32 = getOSType!("long");
		const __typeUInt32 = getOSType!("magn");
		const __typeSInt64 = getOSType!("comp");
		const __typeUInt64 = getOSType!("ucom");
		const __typeIEEE32BitFloatingPoint = getOSType!("sing");
		const __typeIEEE64BitFloatingPoint = getOSType!("doub");
		const __type128BitFloatingPoint = getOSType!("ldbl");
		const __typeDecimalStruct = getOSType!("decm");
		const __typeAEList = getOSType!("list");
		const __typeAERecord = getOSType!("reco");
		const __typeAppleEvent = getOSType!("aevt");
		const __typeEventRecord = getOSType!("evrc");
		const __typeTrue = getOSType!("true");
		const __typeFalse = getOSType!("fals");
		const __typeAlias = getOSType!("alis");
		const __typeEnumerated = getOSType!("enum");
		const __typeType = getOSType!("type");
		const __typeAppParameters = getOSType!("appa");
		const __typeProperty = getOSType!("prop");
		const __typeFSRef = getOSType!("fsrf");
		const __typeFileURL = getOSType!("furl");
		const __typeKeyword = getOSType!("keyw");
		const __typeSectionH = getOSType!("sect");
		const __typeWildCard = getOSType!("****");
		const __typeApplSignature = getOSType!("sign");
		const __typeQDRectangle = getOSType!("qdrt");
		const __typeFixed = getOSType!("fixd");
		const __typeProcessSerialNumber = getOSType!("psn ");
		const __typeApplicationURL = getOSType!("aprl");
		const __typeNull = getOSType!("null");
		const __typeCFAttributedStringRef = getOSType!("cfas");
		const __typeCFMutableAttributedStringRef = getOSType!("cfaa");
		const __typeCFStringRef = getOSType!("cfst");
		const __typeCFMutableStringRef = getOSType!("cfms");
		const __typeCFArrayRef = getOSType!("cfar");
		const __typeCFMutableArrayRef = getOSType!("cfma");
		const __typeCFDictionaryRef = getOSType!("cfdc");
		const __typeCFMutableDictionaryRef = getOSType!("cfmd");
		const __typeCFNumberRef = getOSType!("cfnb");
		const __typeCFBooleanRef = getOSType!("cftf");
		const __typeCFTypeRef = getOSType!("cfty");
		const __typeKernelProcessID = getOSType!("kpid");
		const __typeMachPort = getOSType!("port");
		const __typeApplicationBundleID = getOSType!("bund");
		const __keyTransactionIDAttr = getOSType!("tran");
		const __keyReturnIDAttr = getOSType!("rtid");
		const __keyEventClassAttr = getOSType!("evcl");
		const __keyEventIDAttr = getOSType!("evid");
		const __keyAddressAttr = getOSType!("addr");
		const __keyOptionalKeywordAttr = getOSType!("optk");
		const __keyTimeoutAttr = getOSType!("timo");
		const __keyInteractLevelAttr = getOSType!("inte");
		const __keyEventSourceAttr = getOSType!("esrc");
		const __keyMissedKeywordAttr = getOSType!("miss");
		const __keyOriginalAddressAttr = getOSType!("from");
		const __keyAcceptTimeoutAttr = getOSType!("actm");
		const __keyReplyRequestedAttr = getOSType!("repq");
		const __kSOAP1999Schema = getOSType!("ss99");
		const __kSOAP2001Schema = getOSType!("ss01");
		const __keyUserNameAttr = getOSType!("unam");
		const __keyUserPasswordAttr = getOSType!("pass");
		const __keyDisableAuthenticationAttr = getOSType!("auth");
		const __keyXMLDebuggingAttr = getOSType!("xdbg");
		const __kAERPCClass = getOSType!("rpc ");
		const __kAEXMLRPCScheme = getOSType!("RPC2");
		const __kAESOAPScheme = getOSType!("SOAP");
		const __kAESharedScriptHandler = getOSType!("wscp");
		const __keyRPCMethodName = getOSType!("meth");
		const __keyRPCMethodParam = getOSType!("parm");
		const __keyRPCMethodParamOrder = getOSType!("/ord");
		const __keyAEPOSTHeaderData = getOSType!("phed");
		const __keyAEReplyHeaderData = getOSType!("rhed");
		const __keyAEXMLRequestData = getOSType!("xreq");
		const __keyAEXMLReplyData = getOSType!("xrep");
		const __keyAdditionalHTTPHeaders = getOSType!("ahed");
		const __keySOAPAction = getOSType!("sact");
		const __keySOAPMethodNameSpace = getOSType!("mspc");
		const __keySOAPMethodNameSpaceURI = getOSType!("mspu");
		const __keySOAPSchemaVersion = getOSType!("ssch");
		const __keySOAPStructureMetaData = getOSType!("/smd");
		const __keySOAPSMDNamespace = getOSType!("ssns");
		const __keySOAPSMDNamespaceURI = getOSType!("ssnu");
		const __keySOAPSMDType = getOSType!("sstp");
		const __kAEUseHTTPProxyAttr = getOSType!("xupr");
		const __kAEHTTPProxyPortAttr = getOSType!("xhtp");
		const __kAEHTTPProxyHostAttr = getOSType!("xhth");
		const __kAEUseSocksAttr = getOSType!("xscs");
		const __kAESocksProxyAttr = getOSType!("xsok");
		const __kAESocksHostAttr = getOSType!("xshs");
		const __kAESocksPortAttr = getOSType!("xshp");
		const __kAESocksUserAttr = getOSType!("xshu");
		const __kAESocksPasswordAttr = getOSType!("xshw");
	}
}

enum
{
	typeBoolean = getOSType!("bool"),
	typeChar = getOSType!("TEXT")
}

enum
{
	typeStyledUnicodeText = getOSType!("sutx"),
	typeEncodedString = getOSType!("encs"),
	typeUnicodeText = getOSType!("utxt"),
	typeCString = getOSType!("cstr"),
	typePString = getOSType!("pstr")
}

enum
{
	typeUTF16ExternalRepresentation = getOSType!("ut16"),
	typeUTF8Text = getOSType!("utf8")
}

enum
{
	typeSInt16 = getOSType!("shor"),
	typeUInt16 = getOSType!("ushr"),
	typeSInt32 = getOSType!("long"),
	typeUInt32 = getOSType!("magn"),
	typeSInt64 = getOSType!("comp"),
	typeUInt64 = getOSType!("ucom"),
	typeIEEE32BitFloatingPoint = getOSType!("sing"),
	typeIEEE64BitFloatingPoint = getOSType!("doub"),
	type128BitFloatingPoint = getOSType!("ldbl"),
	typeDecimalStruct = getOSType!("decm")
}

enum
{
	typeAEList = getOSType!("list"),
	typeAERecord = getOSType!("reco"),
	typeAppleEvent = getOSType!("aevt"),
	typeEventRecord = getOSType!("evrc"),
	typeTrue = getOSType!("true"),
	typeFalse = getOSType!("fals"),
	typeAlias = getOSType!("alis"),
	typeEnumerated = getOSType!("enum"),
	typeType = getOSType!("type"),
	typeAppParameters = getOSType!("appa"),
	typeProperty = getOSType!("prop"),
	typeFSRef = getOSType!("fsrf"),
	typeFileURL = getOSType!("furl"),
	typeKeyword = getOSType!("keyw"),
	typeSectionH = getOSType!("sect"),
	typeWildCard = getOSType!("****"),
	typeApplSignature = getOSType!("sign"),
	typeQDRectangle = getOSType!("qdrt"),
	typeFixed = getOSType!("fixd"),
	typeProcessSerialNumber = getOSType!("psn "),
	typeApplicationURL = getOSType!("aprl"),
	typeNull = getOSType!("null")
}

enum
{
	typeCFAttributedStringRef = getOSType!("cfas"),
	typeCFMutableAttributedStringRef = getOSType!("cfaa"),
	typeCFStringRef = getOSType!("cfst"),
	typeCFMutableStringRef = getOSType!("cfms"),
	typeCFArrayRef = getOSType!("cfar"),
	typeCFMutableArrayRef = getOSType!("cfma"),
	typeCFDictionaryRef = getOSType!("cfdc"),
	typeCFMutableDictionaryRef = getOSType!("cfmd"),
	typeCFNumberRef = getOSType!("cfnb"),
	typeCFBooleanRef = getOSType!("cftf"),
	typeCFTypeRef = getOSType!("cfty")
}

enum
{
	typeKernelProcessID = getOSType!("kpid"),
	typeMachPort = getOSType!("port")
}

enum
{
	typeApplicationBundleID = getOSType!("bund")
}

enum
{
	keyTransactionIDAttr = getOSType!("tran"),
	keyReturnIDAttr = getOSType!("rtid"),
	keyEventClassAttr = getOSType!("evcl"),
	keyEventIDAttr = getOSType!("evid"),
	keyAddressAttr = getOSType!("addr"),
	keyOptionalKeywordAttr = getOSType!("optk"),
	keyTimeoutAttr = getOSType!("timo"),
	keyInteractLevelAttr = getOSType!("inte"),
	keyEventSourceAttr = getOSType!("esrc"),
	keyMissedKeywordAttr = getOSType!("miss"),
	keyOriginalAddressAttr = getOSType!("from"),
	keyAcceptTimeoutAttr = getOSType!("actm"),
	keyReplyRequestedAttr = getOSType!("repq")
}

static if (D_LP64)
{
	enum : long
	{
		kAEDebugPOSTHeader = (1 << 0),
		kAEDebugReplyHeader = (1 << 1),
		kAEDebugXMLRequest = (1 << 2),
		kAEDebugXMLResponse = (1 << 3),
		kAEDebugXMLDebugAll = 0xFFFFFFFF
	}
}

else
{
	enum
	{
		kAEDebugPOSTHeader = (1 << 0),
		kAEDebugReplyHeader = (1 << 1),
		kAEDebugXMLRequest = (1 << 2),
		kAEDebugXMLResponse = (1 << 3),
		kAEDebugXMLDebugAll = 0xFFFFFFFF
	}
}

enum
{
	kSOAP1999Schema = getOSType!("ss99"),
	kSOAP2001Schema = getOSType!("ss01")
}

enum
{
	keyUserNameAttr = getOSType!("unam"),
	keyUserPasswordAttr = getOSType!("pass"),
	keyDisableAuthenticationAttr = getOSType!("auth"),
	keyXMLDebuggingAttr = getOSType!("xdbg"),
	kAERPCClass = getOSType!("rpc "),
	kAEXMLRPCScheme = getOSType!("RPC2"),
	kAESOAPScheme = getOSType!("SOAP"),
	kAESharedScriptHandler = getOSType!("wscp"),
	keyRPCMethodName = getOSType!("meth"),
	keyRPCMethodParam = getOSType!("parm"),
	keyRPCMethodParamOrder = getOSType!("/ord"),
	keyAEPOSTHeaderData = getOSType!("phed"),
	keyAEReplyHeaderData = getOSType!("rhed"),
	keyAEXMLRequestData = getOSType!("xreq"),
	keyAEXMLReplyData = getOSType!("xrep"),
	keyAdditionalHTTPHeaders = getOSType!("ahed"),
	keySOAPAction = getOSType!("sact"),
	keySOAPMethodNameSpace = getOSType!("mspc"),
	keySOAPMethodNameSpaceURI = getOSType!("mspu"),
	keySOAPSchemaVersion = getOSType!("ssch")
}

enum
{
	keySOAPStructureMetaData = getOSType!("/smd"),
	keySOAPSMDNamespace = getOSType!("ssns"),
	keySOAPSMDNamespaceURI = getOSType!("ssnu"),
	keySOAPSMDType = getOSType!("sstp")
}

enum
{
	kAEUseHTTPProxyAttr = getOSType!("xupr"),
	kAEHTTPProxyPortAttr = getOSType!("xhtp"),
	kAEHTTPProxyHostAttr = getOSType!("xhth")
}

enum
{
	kAESocks4Protocol = 4,
	kAESocks5Protocol = 5
}

enum
{
	kAEUseSocksAttr = getOSType!("xscs"),
	kAESocksProxyAttr = getOSType!("xsok"),
	kAESocksHostAttr = getOSType!("xshs"),
	kAESocksPortAttr = getOSType!("xshp"),
	kAESocksUserAttr = getOSType!("xshu"),
	kAESocksPasswordAttr = getOSType!("xshw")
}

enum
{
	kAEDescListFactorNone = 0,
	kAEDescListFactorType = 4,
	kAEDescListFactorTypeAndSize = 8
}

enum
{
	kAutoGenerateReturnID = -1,
	kAnyTransactionID = 0
}

enum
{
	kAEDataArray = 0,
	kAEPackedArray = 1,
	kAEDescArray = 3,
	kAEKeyDescArray = 4
}

enum
{
	kAEHandleArray = 2
}

enum
{
	kAENormalPriority = 0x00000000,
	kAEHighPriority = 0x00000001
}

enum
{
	kAENoReply = 0x00000001,
	kAEQueueReply = 0x00000002,
	kAEWaitReply = 0x00000003,
	kAEDontReconnect = 0x00000080,
	kAEWantReceipt = 0x00000200,
	kAENeverInteract = 0x00000010,
	kAECanInteract = 0x00000020,
	kAEAlwaysInteract = 0x00000030,
	kAECanSwitchLayer = 0x00000040,
	kAEDontRecord = 0x00001000,
	kAEDontExecute = 0x00002000,
	kAEProcessNonReplyEvents = 0x00008000
}

enum
{
	kAEDefaultTimeout = -1,
	kNoTimeOut = -2
}

union AEArrayData
{
	short[1] kAEDataArray;
	char[1] kAEPackedArray;
	Handle[1] kAEHandleArray;
	AEDesc[1] kAEDescArray;
	AEKeyDesc[1] kAEKeyDescArray;
}

extern (C)
{
	AECoerceDescUPP NewAECoerceDescUPP (AECoerceDescProcPtr userRoutine);
	AECoercePtrUPP NewAECoercePtrUPP (AECoercePtrProcPtr userRoutine);
	void DisposeAECoerceDescUPP (AECoerceDescUPP userUPP);
	void DisposeAECoercePtrUPP (AECoercePtrUPP userUPP);
	short InvokeAECoerceDescUPP (AEDesc* fromDesc, uint toType, int handlerRefcon, AEDesc* toDesc, AECoerceDescUPP userUPP);
	short InvokeAECoercePtrUPP (uint typeCode, void* dataPtr, int dataSize, uint toType, int handlerRefcon, AEDesc* result, AECoercePtrUPP userUPP);
	short AEInstallCoercionHandler (uint fromType, uint toType, AECoercionHandlerUPP handler, int handlerRefcon, ubyte fromTypeIsDesc, ubyte isSysHandler);
	short AERemoveCoercionHandler (uint fromType, uint toType, AECoercionHandlerUPP handler, ubyte isSysHandler);
	short AEGetCoercionHandler (uint fromType, uint toType, AECoercionHandlerUPP* handler, SRefCon* handlerRefcon, char* fromTypeIsDesc, ubyte isSysHandler);
	short AECoercePtr (uint typeCode, void* dataPtr, int dataSize, uint toType, AEDesc* result);
	short AECoerceDesc (AEDesc* theAEDesc, uint toType, AEDesc* result);
	void AEInitializeDesc (AEDesc* desc);
	short AECreateDesc (uint typeCode, void* dataPtr, int dataSize, AEDesc* result);
	short AEDisposeDesc (AEDesc* theAEDesc);
	short AEDuplicateDesc (AEDesc* theAEDesc, AEDesc* result);
	int AECreateDescFromExternalPtr (uint descriptorType, void* dataPtr, int dataLength, AEDisposeExternalUPP disposeCallback, int disposeRefcon, AEDesc* theDesc);
	short AECreateList (void* factoringPtr, int factoredSize, ubyte isRecord, AEDescList* resultList);
	short AECountItems (AEDescList* theAEDescList, long* theCount);
	short AEPutPtr (AEDescList* theAEDescList, int index, uint typeCode, void* dataPtr, int dataSize);
	short AEPutDesc (AEDescList* theAEDescList, int index, AEDesc* theAEDesc);
	short AEGetNthPtr (AEDescList* theAEDescList, int index, uint desiredType, AEKeyword* theAEKeyword, DescType* typeCode, void* dataPtr, int maximumSize, Size* actualSize);
	short AEGetNthDesc (AEDescList* theAEDescList, int index, uint desiredType, AEKeyword* theAEKeyword, AEDesc* result);
	short AESizeOfNthItem (AEDescList* theAEDescList, int index, DescType* typeCode, Size* dataSize);
	short AEGetArray (AEDescList* theAEDescList, byte arrayType, AEArrayDataPointer arrayPtr, int maximumSize, DescType* itemType, Size* itemSize, long* itemCount);
	short AEPutArray (AEDescList* theAEDescList, byte arrayType, AEArrayData* arrayPtr, uint itemType, int itemSize, int itemCount);
	short AEDeleteItem (AEDescList* theAEDescList, int index);
	ubyte AECheckIsRecord (AEDesc* theDesc);
	short AECreateAppleEvent (uint theAEEventClass, uint theAEEventID, AEAddressDesc* target, short returnID, int transactionID, AppleEvent* result);
	short AEPutParamPtr (AppleEvent* theAppleEvent, uint theAEKeyword, uint typeCode, void* dataPtr, int dataSize);
	short AEPutParamDesc (AppleEvent* theAppleEvent, uint theAEKeyword, AEDesc* theAEDesc);
	short AEGetParamPtr (AppleEvent* theAppleEvent, uint theAEKeyword, uint desiredType, DescType* actualType, void* dataPtr, int maximumSize, Size* actualSize);
	short AEGetParamDesc (AppleEvent* theAppleEvent, uint theAEKeyword, uint desiredType, AEDesc* result);
	short AESizeOfParam (AppleEvent* theAppleEvent, uint theAEKeyword, DescType* typeCode, Size* dataSize);
	short AEDeleteParam (AppleEvent* theAppleEvent, uint theAEKeyword);
	short AEGetAttributePtr (AppleEvent* theAppleEvent, uint theAEKeyword, uint desiredType, DescType* typeCode, void* dataPtr, int maximumSize, Size* actualSize);
	short AEGetAttributeDesc (AppleEvent* theAppleEvent, uint theAEKeyword, uint desiredType, AEDesc* result);
	short AESizeOfAttribute (AppleEvent* theAppleEvent, uint theAEKeyword, DescType* typeCode, Size* dataSize);
	short AEPutAttributePtr (AppleEvent* theAppleEvent, uint theAEKeyword, uint typeCode, void* dataPtr, int dataSize);
	short AEPutAttributeDesc (AppleEvent* theAppleEvent, uint theAEKeyword, AEDesc* theAEDesc);
	int AESizeOfFlattenedDesc (AEDesc* theAEDesc);
	int AEFlattenDesc (AEDesc* theAEDesc, char* buffer, int bufferSize, Size* actualSize);
	int AEUnflattenDesc (void* buffer, AEDesc* result);
	short AEGetDescData (AEDesc* theAEDesc, void* dataPtr, int maximumSize);
	int AEGetDescDataSize (AEDesc* theAEDesc);
	short AEReplaceDescData (uint typeCode, void* dataPtr, int dataSize, AEDesc* theAEDesc);
	int AEGetDescDataRange (AEDesc* dataDesc, void* buffer, int offset, int length);
	AEDisposeExternalUPP NewAEDisposeExternalUPP (AEDisposeExternalProcPtr userRoutine);
	AEEventHandlerUPP NewAEEventHandlerUPP (AEEventHandlerProcPtr userRoutine);
	void DisposeAEDisposeExternalUPP (AEDisposeExternalUPP userUPP);
	void DisposeAEEventHandlerUPP (AEEventHandlerUPP userUPP);
	void InvokeAEDisposeExternalUPP (void* dataPtr, int dataLength, int refcon, AEDisposeExternalUPP userUPP);
	short InvokeAEEventHandlerUPP (AppleEvent* theAppleEvent, AppleEvent* reply, int handlerRefcon, AEEventHandlerUPP userUPP);
}