Mac-Carbon

 view release on metacpan or  search on metacpan

AppleEvents/AppleEvents.xs  view on Meta::CPAN

MacOSRet
AEPutDesc(theAEDescList, index, theAEDesc)
	AEDesc	&theAEDescList
	long		index
	AEDesc	&theAEDesc


=item AEPutKey DESCLIST, KEY, TYPE, HANDLE

=item AEPutKeyDesc DESCLIST, KEY, DESC

Add a descriptor record and a keyword to an AE record. AEPutKey will manufacture the 
record to add it to the AE record.
Return zero if an error was detected.

=cut
MacOSRet
AEPutKey(theAERecord, theAEKeyword, typeCode, data)
	AEDesc	&theAERecord
	OSType	theAEKeyword
	OSType	typeCode
	SV *		data
	CODE:
	{
		char *	dataPtr;
		STRLEN	dataSize;
		
		dataPtr		=	SvPV(data, dataSize);
		ConvertFourCharCode(typeCode, dataPtr);

		RETVAL	=	AEPutKeyPtr(&theAERecord, theAEKeyword, typeCode, dataPtr, dataSize);
		ConvertFourCharCode(typeCode, dataPtr);
	}
	OUTPUT:
	RETVAL


MacOSRet
AEPutKeyDesc(theAERecord, theAEKeyword, theAEDesc)
	AEDesc	&theAERecord
	OSType	theAEKeyword
	AEDesc	&theAEDesc

=item AEGetNthDesc DESCLIST, INDEX [, TYPE]

The AEGetNthDesc function returns a specified descriptor record from a specified
descriptor list. The result is an AEDesc object and the keyword from a keyword
specified list.

	($Desc, $Key) = AEGetNthDesc($DescList, $i);
	if ( defined $Desc ) {
		# do something productive
	}

=cut
void
AEGetNthDesc(theAEDescList, index, desiredType=typeWildCard)
	AEDesc	&theAEDescList
	long		index
	OSType	desiredType
	PPCODE:
	{
		OSType 	kw;
		AEDesc	desc;
		
		AEFail(AEGetNthDesc(&theAEDescList, index, desiredType, &kw, &desc));
		XS_XPUSH(AEDesc, desc);
		if (GIMME == G_ARRAY && kw != typeWildCard) {
			XS_XPUSH(OSType, kw);
		}
	}

=item AEGetKeyDesc DESCLIST, KEY [, TYPE]

The AEGetKeyDesc function returns a keyword-specified descriptor record from
a specified descriptor record.	The result is an AEDesc object.

=cut
AEDesc
AEGetKeyDesc(theAEDescList, theAEKeyword, desiredType=typeWildCard)
	AEDesc	&theAEDescList
	OSType	theAEKeyword
	OSType	desiredType
	CODE:
	AEFail(AEGetKeyDesc(&theAEDescList, theAEKeyword, desiredType, &RETVAL));
	OUTPUT:
	RETVAL

=item AEDeleteItem DESCLIST, INDEX

Delete a descriptor record from a descriptor list. All subsequent descriptor
records will then move up one place.

=cut
MacOSRet
AEDeleteItem(theAEDescList, index)
	AEDesc	&theAEDescList
	long		index

=item AEPutParam EVENT, KEY, TYPE, HANDLE

=item AEPutParamDesc EVENT, KEY, DESC

Add a descriptor record and a keyword to an Apple event as an Apple event
parameter. AEPutParam creates the descriptor record.

=cut
MacOSRet
AEPutParam(theAppleEvent, theAEKeyword, typeCode, data)
	AEDesc	&theAppleEvent
	OSType	theAEKeyword
	OSType	typeCode
	SV *		data
	CODE:
	{
		char *	dataPtr;
		STRLEN	dataSize;
		
		dataPtr 	= 	SvPV(data, dataSize);
		ConvertFourCharCode(typeCode, dataPtr);

AppleEvents/AppleEvents.xs  view on Meta::CPAN

event ID, and whether the handler is to be added to the system Apple event
dispatch table or your application's Apple event dispatch table. You can also
specify a reference constant that the Apple Event Manager passes to your handler
whenever your handler processes an Apple event.

	if (!AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments, 'OpenDocument', 0) ) {
		# an error occurred.
	}

A much more uniform (and Perl-ish) method is available using the hash arrays
%AppleEvent and %SysAppleEvent to bind handlers to event types.

	$AppleEvent{kCoreEventClass, kAEOpenDocuments} = 'OpenDocument';
	...
	delete $AppleEvent{kCoreEventClass, kAEOpenDocuments};

=cut
MacOSRet
AEInstallEventHandler(theAEEventClass, theAEEventID, handler, handlerRefcon, isSysHandler=0)
	OSType	theAEEventClass
	OSType	theAEEventID
	SV *		handler
	SV *		handlerRefcon
	Boolean	isSysHandler
	CODE:
	{
		RETVAL = PAEInstallEventHandler(theAEEventClass, theAEEventID, handler, handlerRefcon, isSysHandler);
	}
	OUTPUT:
	RETVAL

=item AERemoveEventHandler CLASS, EVENTID [, SYSTEM]

The AERemoveEventHandler function removes the Apple event dispatch table entry
you specify in the parameters CLASS, EVENTID, and SYSTEM. 

=cut
MacOSRet
AERemoveEventHandler(theAEEventClass, theAEEventID, isSysHandler=0)
	OSType	theAEEventClass
	OSType	theAEEventID
	Boolean	isSysHandler
	CODE:
	RETVAL = PAERemoveEventHandler(theAEEventClass, theAEEventID, isSysHandler);
	OUTPUT:
	RETVAL

=item AEGetEventHandler CLASS, EVENTID [, SYSTEM]

The AEGetEventHandler function returns the handler and handlerrefcon for
the specified class and event. 

	($proc, $refcon) = AEGetEventHandler("aevt", "oapp");

=cut
void
AEGetEventHandler(theAEEventClass, theAEEventID, isSysHandler=0)
	OSType	theAEEventClass
	OSType	theAEEventID
	Boolean	isSysHandler
	PPCODE:
	{
		SV * handler = sv_newmortal();
		SV * refCon  = sv_newmortal();
		
		AEFail(
			PAEGetEventHandler(
				theAEEventClass, theAEEventID, handler, refCon, isSysHandler));
		XPUSHs(handler);
		if (GIMME == G_ARRAY) {
			XPUSHs(refCon);
		}
	}

=item AEManagerInfo KEY

Obtain information about the version of the Apple Event Manager currently
available or the number of processes that are currently recording Apple events. 
The result is C<undef> if an error occurred.

=back

=cut
SysRetLong
AEManagerInfo(keyWord)
	OSType	keyWord
	CODE:
	AEFail(AEManagerInfo(keyWord, &RETVAL));
	OUTPUT:
	RETVAL


=head2 AEGizmos Build/Print

The Apple Event Gizmos were developed by Jens Peter Alfke at Apple as a vastly
speeded up AE library. Consult the AEGizmo documentation for details of usage
of the library. The Build/Print facility uses a formatting convention similar
to scanf/printf to put things together.

=over 4

=item AEBuild FORMAT, PARM, ...

Build an AppleEvent descriptor using the format per the Gizmo documentation
and return it.

=cut
AEDesc
AEBuild(format, ...)
	char *	format
	CODE:
	{
		int	item = 1;
		char *formscan = format;
		
		PAEClearArgs();
		for (;item<items;++item) 
			if (!PAEDoNextParam(&formscan, ST(item)))
				croak("Too many arguments to AEBuild()");
			
		if (PAENextParam(&formscan))

AppleEvents/AppleEvents.xs  view on Meta::CPAN

#endif
	}
	OUTPUT:
	RETVAL

=item AESubDescToDesc SUBDESC, DESIREDTYPE

B<Mac OS only.>

Translate the subdescriptor back to a descriptor of the desired type.

=cut
AEDesc
AESubDescToDesc(subdesc, desiredType=typeWildCard)
	AESubDesc	&subdesc
	OSType		desiredType
	CODE:
#ifndef MACOS_TRADITIONAL
	croak("Usage: Mac::AppleEvents::AESubDescToDesc unsupported in Carbon");
#else
	AEFail(AESubDescToDesc(&subdesc, desiredType, &RETVAL));
#endif
	OUTPUT:
	RETVAL

=item AECountSubDescItems SUBDESC

B<Mac OS only.>

Counts the number of subdescriptor items.

=cut
long
AECountSubDescItems(subdesc)
	AESubDesc	&subdesc
	CODE:
	{
#ifndef MACOS_TRADITIONAL
	croak("Usage: Mac::AppleEvents::AECountSubDescItems unsupported in Carbon");
#else
		RETVAL = AECountSubDescItems(&subdesc);
		if (RETVAL < 0)
			AEFail((OSErr) RETVAL);
#endif
	}
	OUTPUT:
	RETVAL	

=item AEGetNthSubDesc SUBDESC,INDEX

B<Mac OS only.>

Returns the item INDEX of the subdescriptor and its type if the subdescriptor
represented a record and not a list.

=cut
void
AEGetNthSubDesc(subdesc,index)
	AESubDesc	&subdesc
	long			index
	PPCODE:
	{
#ifndef MACOS_TRADITIONAL
	croak("Usage: Mac::AppleEvents::AEGetNthSubDesc unsupported in Carbon");
#else
		OSType		kw;
		AESubDesc	sub;
		
		AEFail(AEGetNthSubDesc(&subdesc, index, &kw, &sub));
		XS_XPUSH(AESubDesc, sub);
		if (GIMME == G_ARRAY && kw != typeWildCard) {
			XS_XPUSH(OSType, kw);
		}
#endif
	}

=item AEGetKeySubDesc SUBDESC,KW

B<Mac OS only.>

Returns the keyword indexed item from the subdescriptor.

=back

=cut
AESubDesc
AEGetKeySubDesc(subdesc,kw)
	AESubDesc	&subdesc
	OSType		kw
	CODE:
#ifndef MACOS_TRADITIONAL
	croak("Usage: Mac::AppleEvents::AEGetKeySubDesc unsupported in Carbon");
#else
	AEFail(AEGetKeySubDesc(&subdesc, kw, &RETVAL));
#endif
	OUTPUT:
	RETVAL

MODULE = Mac::AppleEvents	PACKAGE = AEStream 

=head2 AEStream

The Apple Event Gizmos streams approach uses a streaming model for building 
a sequence of descriptors.

=over 4

=item new AEStream

=item AEStream::Open 

Return a new AEStream.

=cut
AEStream
Open()
	CODE:
#ifdef MACOS_TRADITIONAL
	AEFail(AEStream_Open(&RETVAL));
#else
	RETVAL = AEStream_Open();



( run in 0.582 second using v1.01-cache-2.11-cpan-5511b514fd6 )