static Lisp_Object
mac_aelist_to_lisp (desc_list)
- AEDescList *desc_list;
+ const AEDescList *desc_list;
{
OSErr err;
long count;
Lisp_Object
mac_aedesc_to_lisp (desc)
- AEDesc *desc;
+ const AEDesc *desc;
{
OSErr err = noErr;
DescType desc_type = desc->descriptorType;
}
#if TARGET_API_MAC_CARBON
-OSErr
-create_apple_event_from_event_ref (event, num_params, names, types, result)
- EventRef event;
- UInt32 num_params;
- EventParamName *names;
- EventParamType *types;
+static OSErr
+create_apple_event (class, id, result)
+ AEEventClass class;
+ AEEventID id;
AppleEvent *result;
{
OSErr err;
static const ProcessSerialNumber psn = {0, kCurrentProcess};
AEAddressDesc address_desc;
- UInt32 i, size;
- CFStringRef string;
- CFDataRef data;
- char *buf;
err = AECreateDesc (typeProcessSerialNumber, &psn,
sizeof (ProcessSerialNumber), &address_desc);
if (err == noErr)
{
- err = AECreateAppleEvent (0, 0, /* Dummy class and ID. */
+ err = AECreateAppleEvent (class, id,
&address_desc, /* NULL is not allowed
on Mac OS Classic. */
kAutoGenerateReturnID,
kAnyTransactionID, result);
AEDisposeDesc (&address_desc);
}
+
+ return err;
+}
+
+OSErr
+create_apple_event_from_event_ref (event, num_params, names, types, result)
+ EventRef event;
+ UInt32 num_params;
+ EventParamName *names;
+ EventParamType *types;
+ AppleEvent *result;
+{
+ OSErr err;
+ UInt32 i, size;
+ CFStringRef string;
+ CFDataRef data;
+ char *buf = NULL;
+
+ err = create_apple_event (0, 0, result); /* Dummy class and ID. */
if (err != noErr)
return err;
0, &size, NULL);
if (err != noErr)
break;
- buf = xmalloc (size);
+ buf = xrealloc (buf, size);
err = GetEventParameter (event, names[i], types[i], NULL,
size, NULL, buf);
if (err == noErr)
AEPutParamPtr (result, names[i], types[i], buf, size);
- xfree (buf);
break;
}
+ if (buf)
+ xfree (buf);
return noErr;
}
-#endif
+OSErr
+create_apple_event_from_drag_ref (drag, num_types, types, result)
+ DragRef drag;
+ UInt32 num_types;
+ FlavorType *types;
+ AppleEvent *result;
+{
+ OSErr err;
+ UInt16 num_items;
+ AppleEvent items;
+ long index;
+ char *buf = NULL;
+
+ err = CountDragItems (drag, &num_items);
+ if (err != noErr)
+ return err;
+ err = AECreateList (NULL, 0, false, &items);
+ if (err != noErr)
+ return err;
+
+ for (index = 1; index <= num_items; index++)
+ {
+ ItemReference item;
+ DescType desc_type = typeNull;
+ Size size;
+
+ err = GetDragItemReferenceNumber (drag, index, &item);
+ if (err == noErr)
+ {
+ int i;
+
+ for (i = 0; i < num_types; i++)
+ {
+ err = GetFlavorDataSize (drag, item, types[i], &size);
+ if (err == noErr)
+ {
+ buf = xrealloc (buf, size);
+ err = GetFlavorData (drag, item, types[i], buf, &size, 0);
+ }
+ if (err == noErr)
+ {
+ desc_type = types[i];
+ break;
+ }
+ }
+ }
+ err = AEPutPtr (&items, index, desc_type,
+ desc_type != typeNull ? buf : NULL,
+ desc_type != typeNull ? size : 0);
+ if (err != noErr)
+ break;
+ }
+ if (buf)
+ xfree (buf);
+
+ if (err == noErr)
+ {
+ err = create_apple_event (0, 0, result); /* Dummy class and ID. */
+ if (err == noErr)
+ err = AEPutParamDesc (result, keyDirectObject, &items);
+ if (err != noErr)
+ AEDisposeDesc (result);
+ }
+
+ AEDisposeDesc (&items);
+
+ return err;
+}
+#endif /* TARGET_API_MAC_CARBON */
\f
/***********************************************************************
Conversion between Lisp and Core Foundation objects