[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] Changes to emacs/src/mac.c
From: |
YAMAMOTO Mitsuharu |
Subject: |
[Emacs-diffs] Changes to emacs/src/mac.c |
Date: |
Fri, 05 May 2006 06:44:01 +0000 |
Index: emacs/src/mac.c
diff -u emacs/src/mac.c:1.58 emacs/src/mac.c:1.59
--- emacs/src/mac.c:1.58 Mon May 1 01:11:28 2006
+++ emacs/src/mac.c Fri May 5 06:44:01 2006
@@ -272,7 +272,7 @@
static Lisp_Object
mac_aelist_to_lisp (desc_list)
- AEDescList *desc_list;
+ const AEDescList *desc_list;
{
OSErr err;
long count;
@@ -337,7 +337,7 @@
Lisp_Object
mac_aedesc_to_lisp (desc)
- AEDesc *desc;
+ const AEDesc *desc;
{
OSErr err = noErr;
DescType desc_type = desc->descriptorType;
@@ -665,33 +665,46 @@
}
#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;
@@ -721,19 +734,88 @@
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 */
/***********************************************************************
Conversion between Lisp and Core Foundation objects
- [Emacs-diffs] Changes to emacs/src/mac.c,
YAMAMOTO Mitsuharu <=