예제 #1
0
void AECoreClass::ExtractData(const AEDesc *source, AEDesc *data)
{
	OSErr		err = noErr;
	StAEDesc		temp;
	DescType		dispatchClass;
		
	if ((source->descriptorType == typeNull) || (source->dataHandle == nil))
		ThrowIfOSErr(errAENoSuchObject);
	
	// If it's an object specifier, resolve into a token
	// Otherwise, just copy it
	
	if (source->descriptorType == typeObjectSpecifier) 
	{
		err = AEResolve(source, kAEIDoMinimum, &temp);
	}
	else
	{
		err = AEDuplicateDesc(source, &temp);
	}
	ThrowIfOSErr(err);
	
	// Next, determine which object should handle it, if any. 
	// If it's a property token, get the dispatch class. 
	// Otherwise, just get the descriptorType. 
	
	if (temp.descriptorType == typeProperty)
	{
		ConstAETokenDesc	tokenDesc(&temp);
		dispatchClass = tokenDesc.GetDispatchClass();
	}
	else
		dispatchClass = temp.descriptorType;
	
	// If it's a property token, get the data it refers to,
	// otherwise duplicate it and return
		
	AEDispatchHandler*	handler = GetDispatchHandler(dispatchClass);
	if (handler)
	{
		/*
		case cApplication:
			// why?
			ThrowIfOSErr(errAEEventNotHandled);
			break;
		*/
		handler->GetDataFromListOrObject(&temp, nil, data);
	}
	else
	{
		err = AEDuplicateDesc(&temp, data);
		ThrowIfOSErr(err);
	}
}
예제 #2
0
static PyObject *AEDesc_AEResolve(AEDescObject *_self, PyObject *_args)
{
	PyObject *_res = NULL;
	OSErr _err;
	short callbackFlags;
	AEDesc theToken;
#ifndef AEResolve
	PyMac_PRECHECK(AEResolve);
#endif
	if (!PyArg_ParseTuple(_args, "h",
	                      &callbackFlags))
		return NULL;
	_err = AEResolve(&_self->ob_itself,
	                 callbackFlags,
	                 &theToken);
	if (_err != noErr) return PyMac_Error(_err);
	_res = Py_BuildValue("O&",
	                     AEDesc_New, &theToken);
	return _res;
}