本文整理汇总了C++中AECreateDesc函数的典型用法代码示例。如果您正苦于以下问题:C++ AECreateDesc函数的具体用法?C++ AECreateDesc怎么用?C++ AECreateDesc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了AECreateDesc函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: newdescwithhandle
boolean newdescwithhandle (AEDesc *desc, DescType typeCode, Handle h) {
/*
PBS 03/14/02: Create a new AEDesc with the given type and value.
*/
OSErr err = noErr;
long len = gethandlesize (h);
AEInitializeDescInline (desc);
if (h == nil)
err = AECreateDesc (typeCode, nil, 0, desc);
else {
lockhandle (h);
err = AECreateDesc (typeCode, *h, len, desc);
unlockhandle (h);
} /*else*/
return (err == noErr);
} /*newdescwithhandle*/
示例2: DestoryWacomContext
// DestoryWacomContext
//
// This function will instruct the Tablet Driver to delete a context that your
// application created. Please be nice and destroy all contexts you create
// before your application quits.
//
// parameters: UInt32 contextID - The ID returned to you when you created the
// context.
//
// returns: a contextID and noErr on success, else an AE error code
//////////////////////////////////////////////////////////////////////////////
OSErr DestoryWacomContext(UInt32 contextID)
{
AEDesc driverTarget,nullDesc,keyData,tObjSpecifier;
AppleEvent aeSend;
OSErr err;
err = GetTabletDriverTarget(&driverTarget);
if(err)
{
return err;
}
err = AECreateAppleEvent(kAECoreSuite,
kAEDelete,
&driverTarget,
kAutoGenerateReturnID,
kAnyTransactionID,
&aeSend);
// Now tell the AE what to destroy
//Create NULL AEDesc, this will signify the end of the AEDesc Chain
AEInitializeDesc(&nullDesc);
err = AECreateDesc( typeNull, NULL, NULL, &nullDesc );
AEInitializeDesc(&keyData);
err = AECreateDesc( typeUInt32,
&contextID, // This is the context ID we want to destroy
sizeof(contextID),
&keyData );
err = CreateObjSpecifier(cContext, // We want to destroy a context
&nullDesc, // This is the last item in the chain
formUniqueID, // use id to determine which context to destroy
&keyData, // This is the Context ID descriptor created above
TRUE, // delete the nullDesc, and KeyData descriptor for us
&tObjSpecifier); // The created descriptor which says that we want to delete Context X
err = AEPutParamDesc( &aeSend, keyDirectObject, &tObjSpecifier);
// Finally send the event
err = AESend(&aeSend, // The complete AE we created above
NULL, // Don't need a reply
kAEWaitReply,
kAEHighPriority,
kDefaultTimeOut,
NULL,
NULL);
AEDisposeDesc(&tObjSpecifier);
AEDisposeDesc(&aeSend);
示例3: SendAppleEventToSystemProcess
OSStatus SendAppleEventToSystemProcess(AEEventID eventToSendID)
{
AEAddressDesc targetDesc;
static const ProcessSerialNumber kPSNOfSystemProcess = {0, kSystemProcess };
AppleEvent eventReply = {typeNull, NULL};
AppleEvent eventToSend = {typeNull, NULL};
OSStatus status = AECreateDesc(typeProcessSerialNumber,
&kPSNOfSystemProcess, sizeof(kPSNOfSystemProcess), &targetDesc);
if (status != noErr)
return status;
status = AECreateAppleEvent(kCoreEventClass, eventToSendID,
&targetDesc, kAutoGenerateReturnID, kAnyTransactionID, &eventToSend);
AEDisposeDesc(&targetDesc);
if (status != noErr)
return status;
status = AESendMessage(&eventToSend, &eventReply, kAENormalPriority, kAEDefaultTimeout);
AEDisposeDesc(&eventToSend);
if (status != noErr)
return status;
AEDisposeDesc(&eventReply);
return status;
}
示例4: PyMac_PRECHECK
static PyObject *AE_AECreateDesc(PyObject *_self, PyObject *_args)
{
PyObject *_res = NULL;
OSErr _err;
DescType typeCode;
char *dataPtr__in__;
long dataPtr__len__;
int dataPtr__in_len__;
AEDesc result;
#ifndef AECreateDesc
PyMac_PRECHECK(AECreateDesc);
#endif
if (!PyArg_ParseTuple(_args, "O&s#",
PyMac_GetOSType, &typeCode,
&dataPtr__in__, &dataPtr__in_len__))
return NULL;
dataPtr__len__ = dataPtr__in_len__;
_err = AECreateDesc(typeCode,
dataPtr__in__, dataPtr__len__,
&result);
if (_err != noErr) return PyMac_Error(_err);
_res = Py_BuildValue("O&",
AEDesc_New, &result);
return _res;
}
示例5: BigSendAppleEvent
OSErr BigSendAppleEvent(TargetID *targ,AEEventClass aeClass,AEEventID aeID,Ptr *data,short dataLen,DescType dataType,Boolean returnData,Boolean checkForHandlerErr)
{
AEAddressDesc targDesc={typeNull, nil}; // Desc for target
AppleEvent appOut={typeNull, nil},appIn={typeNull, nil};
short sendMode=kAENeverInteract;
OSErr err;
if (returnData || checkForHandlerErr)
sendMode+=kAEWaitReply;
else
sendMode+=kAENoReply;
// Create the address desriptor
err=AECreateDesc(typeTargetID,(Ptr)targ,sizeof(TargetID), &targDesc);
if (err)
return err;
// now create the apple event which will be sent
err=AECreateAppleEvent(aeClass,aeID,&targDesc,kAutoGenerateReturnID,kAnyTransactionID,&appOut);
if (err)
{
AEDisposeDesc(&targDesc);
return err;
}
if (data && *data)
{
err=AEPutParamPtr(&appOut,keyDirectObject,typeChar,*data,dataLen);
DisposePtr(*data);
*data=0L;
if (err)
{
AEDisposeDesc(&appOut);
AEDisposeDesc(&targDesc);
}
}
// Send the apple event
err=AESend(&appOut,&appIn,sendMode,kAENormalPriority,kAEDefaultTimeout,0L,0L);
if (err)
{
AEDisposeDesc(&appOut); // get rid of the apple events
AEDisposeDesc(&appIn);
AEDisposeDesc(&targDesc); // and the address descriptor
}
if (returnData) // get info from reply event
err=FetchParamAnySize(keyDirectObject,&appIn,data,dataType);
// Get the error returned if any
if (!err && checkForHandlerErr)
err=FetchAEErr(&appIn);
// The apple event has been sent, dispose of descriptors
AEDisposeDesc(&appOut); // get rid of the apple events
AEDisposeDesc(&appIn);
AEDisposeDesc(&targDesc); // and the address descriptor
return err;
}
示例6: IACnewsystemverb
Boolean IACnewsystemverb (OSType vclass, OSType vtoken, AppleEvent *event) {
/*
6/29/92 DW: special entry point for messages sent to system event handlers.
implementation detail: this is accomplished by sending the message to ourself.
*/
AEAddressDesc adr;
OSErr ec;
ProcessSerialNumber psn;
psn.highLongOfPSN = 0;
psn.lowLongOfPSN = kCurrentProcess;
AECreateDesc (typeProcessSerialNumber, (Ptr) &psn, sizeof (psn), &adr);
ec = AECreateAppleEvent (
vclass, vtoken, &adr, kAutoGenerateReturnID, kAnyTransactionID, event);
AEDisposeDesc (&adr);
IACglobals.errorcode = ec;
return (ec == noErr);
} /*IACnewsystemverb*/
示例7: StopRecorder
void StopRecorder(PRECORDER_PARM prec)
{
OSAEvent theOSAEvent; /* the apple event you are generating */
AEAddressDesc targetaddr; /* the address descriptor for target app */
PID thePID;
OSErr rc = noErr;
if (prec->recording)
{
rc = AERemoveEventHandler( kCoreEventClass,
kAENotifyRecording,
(AEEventHandlerUPP)RawEventRecordingProc,
FALSE );
pmassert(prec->pmp->hab, rc == noErr );
prec->recording = FALSE;
rc = AEGetPID(APP_NAME, &thePID);
rc = AECreateDesc(typePID, &thePID, sizeof(thePID), &targetaddr);
rc = AECreateOSAEvent(kCoreEventClass,
kAEStopRecording,
&targetaddr,
kAutoGenerateReturnID,
kAnyTransactionID,
&theOSAEvent);
rc = AESend(&theOSAEvent,
NULL,
kAENoReply,
kAENormalPriority,
kAEDefaultTimeout,
NULL,
NULL);
}
}
示例8: putMissingValueToReply
OSErr putMissingValueToReply(AppleEvent *reply)
{
const static DescType missingValue = cMissingValue;
OSErr err;
AEDesc resultDesc;
AECreateDesc(typeType, &missingValue, sizeof(missingValue), &resultDesc);
err=AEPutParamDesc(reply, keyAEResult, &resultDesc);
AEDisposeDesc(&resultDesc);
return err;
}
示例9: error
/* LowRunAppleScript compiles and runs an AppleScript
provided as text in the buffer pointed to by text. textLength
bytes will be compiled from this buffer and run as an AppleScript
using all of the default environment and execution settings. resultData
must be non-NULL, and should have been previously initialised, for example
with _hs_initNull. The result returned by the execution
command will be returned as typeUTF8Text in this descriptor record
(or typeNull if there is no result information). If the function
returns errOSAScriptError, then resultData will be set to a
descriptive error message describing the error (if one is
available). */
OSStatus LowRunAppleScript(const void* text, long textLength, AEDesc *resultData) {
ComponentInstance theComponent;
AEDesc scriptTextDesc;
OSStatus err;
OSAID scriptID, resultID;
/* set up locals to a known state */
theComponent = NULL;
AECreateDesc(typeNull, NULL, 0, &scriptTextDesc);
scriptID = kOSANullScript;
resultID = kOSANullScript;
/* open the scripting component */
theComponent = OpenDefaultComponent(kOSAComponentType,
typeAppleScript);
if (theComponent == NULL) { err = paramErr; goto bail; }
/* put the script text into an aedesc */
err = AECreateDesc(typeUTF8Text, text, textLength, &scriptTextDesc);
if (err != noErr) goto bail;
/* compile the script */
err = OSACompile(theComponent, &scriptTextDesc,
kOSAModeNull, &scriptID);
if (err != noErr) goto bail;
/* run the script/get the result */
err = OSAExecute(theComponent, scriptID, kOSANullScript,
kOSAModeNull, &resultID);
if (resultData != NULL) {
if (err == noErr && resultID != kOSANullScript) {
OSADisplay(theComponent, resultID, typeUTF8Text,
kOSAModeNull, resultData);
}
}
bail:
if (err == errOSAScriptError) {
AECreateDesc(typeNull, NULL, 0, resultData);
OSAScriptError(theComponent, kOSAErrorMessage, typeUTF8Text, resultData);
}
AEDisposeDesc(&scriptTextDesc);
if (scriptID != kOSANullScript) OSADispose(theComponent, scriptID);
if (resultID != kOSANullScript) OSADispose(theComponent, resultID);
if (theComponent != NULL) CloseComponent(theComponent);
return err;
}
示例10: SendOpenAE
OSStatus SendOpenAE( AEDescList list )
{
OSStatus err;
AEAddressDesc theAddress;
AppleEvent dummyReply;
AppleEvent theEvent;
theAddress.descriptorType = typeNull;
theAddress.dataHandle = NULL;
dummyReply.descriptorType = typeNull;
dummyReply.dataHandle = NULL;
theEvent.descriptorType = typeNull;
theEvent.dataHandle = NULL;
do {
ProcessSerialNumber psn;
err = GetCurrentProcess(&psn);
if ( err != noErr) break;
err =AECreateDesc(typeProcessSerialNumber, &psn, sizeof(ProcessSerialNumber), &theAddress);
if ( err != noErr) break;
err = AECreateAppleEvent(kCoreEventClass, kAEOpenDocuments, &theAddress, kAutoGenerateReturnID, kAnyTransactionID, &theEvent);
if ( err != noErr) break;
err = AEPutParamDesc(&theEvent, keyDirectObject, &list);
if ( err != noErr) break;
err = AESend(&theEvent, &dummyReply, kAENoReply, kAENormalPriority, kAEDefaultTimeout, NULL, NULL);
if ( err != noErr) break;
} while (false);
if ( theAddress.dataHandle != NULL )
{
AEDisposeDesc( &theAddress );
}
if ( dummyReply.dataHandle != NULL )
{
AEDisposeDesc( &dummyReply );
}
if ( theEvent.dataHandle != NULL )
{
AEDisposeDesc( &theEvent );
}
return err;
}
示例11: AEDescCreateUnicodeText
OSErr AEDescCreateUnicodeText(CFStringRef string, AEDesc* outDescPtr)
{
OSErr err = noErr;
DescType resultType = typeUnicodeText;
UniCharCount length = CFStringGetLength(string);
const UniChar *constBuff = CFStringGetCharactersPtr(string);
if (constBuff == NULL) {
UniChar *buffer;
buffer = malloc(sizeof(UniChar)*length);
CFStringGetCharacters(string, CFRangeMake(0, length), buffer);
err = AECreateDesc(resultType, buffer, sizeof(UniChar)*length, outDescPtr);
free(buffer);
}
else {
err=AECreateDesc(resultType, constBuff, length*sizeof(UniChar), outDescPtr);
}
return err;
}
示例12: AddIDToAEList
// NOTE: AELists have 1-based indexes
OSErr AddIDToAEList(unsigned int id_num, long index, DescType object_type, AEDescList* list)
{
AEDesc item_desc;
AECreateDesc(typeNull, NULL, 0, &item_desc);
OSStatus err = CreateAEDescFromID(id_num, object_type, &item_desc);
if (noErr == err)
{
err = AEPutDesc(list, index, &item_desc);
AEDisposeDesc(&item_desc);
}
return err;
}
示例13: AEDescCreateUTF8Text
OSErr AEDescCreateUTF8Text(CFStringRef string, AEDesc* outDescPtr)
{
OSErr err = noErr;
CFStringEncoding kEncoding = kCFStringEncodingUTF8;
DescType resultType = typeUTF8Text;
const char *constBuff = CFStringGetCStringPtr(string, kEncoding);
if (constBuff == NULL) {
char *buffer;
CFIndex charLen = CFStringGetLength(string);
CFIndex maxLen = CFStringGetMaximumSizeForEncoding(charLen, kEncoding)+1; // +1 is for null termination.
buffer = malloc(sizeof(char)*maxLen);
CFStringGetCString(string, buffer, maxLen, kEncoding);
err = AECreateDesc(resultType, buffer, strlen(buffer), outDescPtr);
free(buffer);
}
else {
err=AECreateDesc(resultType, constBuff, strlen(constBuff), outDescPtr);
}
return err;
}
示例14: putAliasToReply
OSErr putAliasToReply(AliasHandle inAlias, AppleEvent *reply)
{
OSErr err;
AEDesc resultDesc;
HLock((Handle)inAlias);
err = AECreateDesc(typeAlias, (Ptr) (*inAlias),
GetHandleSize((Handle) inAlias), &resultDesc);
HUnlock((Handle)inAlias);
err=AEPutParamDesc(reply, keyAEResult, &resultDesc);
AEDisposeDesc(&resultDesc);
return err;
}
示例15: AEDescCreateWithCFURL
OSErr AEDescCreateWithCFURL(CFURLRef url, AEDesc* outDescPtr)
{
OSStatus err;
CFDataRef data = CFURLCreateData(kCFAllocatorDefault, url, kCFStringEncodingUTF8, true);
if (data != NULL) {
err = AECreateDesc('furl', CFDataGetBytePtr(data),
CFDataGetLength(data), outDescPtr);
CFRelease(data);
} else {
err = kCFURLErrorUnknown;
}
return err;
}