emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r111531: * src/lisp.h (XSAVE_POINTER,


From: Dmitry Antipov
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r111531: * src/lisp.h (XSAVE_POINTER, XSAVE_INTEGER): Change to allow extraction
Date: Tue, 15 Jan 2013 13:22:25 +0400
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 111531
committer: Dmitry Antipov <address@hidden>
branch nick: trunk
timestamp: Tue 2013-01-15 13:22:25 +0400
message:
  * src/lisp.h (XSAVE_POINTER, XSAVE_INTEGER): Change to allow extraction
  from any Lisp_Save_Value slot.  Add type checking.
  * src/alloc.c, src/dired.c, src/editfns.c, src/fileio.c, src/ftfont.c:
  * src/gtkutil.c, src/keymap.c, src/lread.c, src/nsterm.h, src/nsmenu.c:
  * src/xfns.c, src/xmenu.c, src/xselect.c: All users changed.
  * admin/coccinelle/xsave.cocci: Semantic patch to adjust users of
  XSAVE_POINTER and XSAVE_INTEGER macros.
added:
  admin/coccinelle/xsave.cocci
modified:
  admin/ChangeLog
  src/ChangeLog
  src/alloc.c
  src/dired.c
  src/editfns.c
  src/fileio.c
  src/font.c
  src/ftfont.c
  src/gtkutil.c
  src/keymap.c
  src/lisp.h
  src/lread.c
  src/nsmenu.m
  src/nsterm.h
  src/xfns.c
  src/xmenu.c
  src/xselect.c
=== modified file 'admin/ChangeLog'
--- a/admin/ChangeLog   2013-01-10 03:43:02 +0000
+++ b/admin/ChangeLog   2013-01-15 09:22:25 +0000
@@ -1,3 +1,8 @@
+2013-01-15  Dmitry Antipov  <address@hidden>
+
+       * coccinelle/xsave.cocci: Semantic patch to adjust users of
+       XSAVE_POINTER and XSAVE_INTEGER macros.
+
 2013-01-03  Glenn Morris  <address@hidden>
 
        * check-doc-strings: Update for CVS->bzr, moved lispref/ directory.

=== added file 'admin/coccinelle/xsave.cocci'
--- a/admin/coccinelle/xsave.cocci      1970-01-01 00:00:00 +0000
+++ b/admin/coccinelle/xsave.cocci      2013-01-15 09:22:25 +0000
@@ -0,0 +1,11 @@
+// Adjust users of XSAVE_POINTER and XSAVE_INTEGER.
+@@
+expression E;
+@@
+(
+- XSAVE_POINTER (E)
++ XSAVE_POINTER (E, 0)
+|
+- XSAVE_INTEGER (E)
++ XSAVE_INTEGER (E, 1)
+)

=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2013-01-15 08:38:07 +0000
+++ b/src/ChangeLog     2013-01-15 09:22:25 +0000
@@ -1,5 +1,13 @@
 2013-01-15  Dmitry Antipov  <address@hidden>
 
+       * lisp.h (XSAVE_POINTER, XSAVE_INTEGER): Change to allow
+       extraction from any Lisp_Save_Value slot.  Add type checking.
+       * alloc.c, dired.c, editfns.c, fileio.c, ftfont.c, gtkutil.c:
+       * keymap.c, lread.c, nsterm.h, nsmenu.c, xfns.c, xmenu.c:
+       * xselect.c: All users changed.
+
+2013-01-15  Dmitry Antipov  <address@hidden>
+
        Some convenient bits to deal with Lisp_Save_Values.
        * lisp.h (XSAVE_OBJECT): New macro to extract saved objects.
        (allocate_misc): Remove prototype.

=== modified file 'src/alloc.c'
--- a/src/alloc.c       2013-01-15 08:38:07 +0000
+++ b/src/alloc.c       2013-01-15 09:22:25 +0000
@@ -3420,7 +3420,7 @@
 void
 free_save_value (Lisp_Object save)
 {
-  xfree (XSAVE_POINTER (save));
+  xfree (XSAVE_POINTER (save, 0));
   free_misc (save);
 }
 

=== modified file 'src/dired.c'
--- a/src/dired.c       2013-01-14 17:46:14 +0000
+++ b/src/dired.c       2013-01-15 09:22:25 +0000
@@ -78,7 +78,7 @@
 static Lisp_Object
 directory_files_internal_unwind (Lisp_Object dh)
 {
-  DIR *d = XSAVE_POINTER (dh);
+  DIR *d = XSAVE_POINTER (dh, 0);
   block_input ();
   closedir (d);
   unblock_input ();

=== modified file 'src/editfns.c'
--- a/src/editfns.c     2013-01-15 08:38:07 +0000
+++ b/src/editfns.c     2013-01-15 09:22:25 +0000
@@ -4254,7 +4254,7 @@
            memcpy (buf, initial_buffer, used);
          }
        else
-         XSAVE_POINTER (buf_save_value) = buf = xrealloc (buf, bufsize);
+         XSAVE_POINTER (buf_save_value, 0) = buf = xrealloc (buf, bufsize);
 
        p = buf + used;
       }

=== modified file 'src/fileio.c'
--- a/src/fileio.c      2013-01-14 17:46:14 +0000
+++ b/src/fileio.c      2013-01-15 09:22:25 +0000
@@ -5507,7 +5507,7 @@
 do_auto_save_unwind (Lisp_Object arg)  /* used as unwind-protect function */
 
 {
-  FILE *stream = XSAVE_POINTER (arg);
+  FILE *stream = XSAVE_POINTER (arg, 0);
   auto_saving = 0;
   if (stream != NULL)
     {

=== modified file 'src/font.c'
--- a/src/font.c        2013-01-14 09:55:21 +0000
+++ b/src/font.c        2013-01-15 09:22:25 +0000
@@ -1857,7 +1857,7 @@
   OTF *otf;
 
   if (! NILP (val))
-    otf = XSAVE_POINTER (XCDR (val));
+    otf = XSAVE_POINTER (XCDR (val), 0);
   else
     {
       otf = STRINGP (file) ? OTF_open (SSDATA (file)) : NULL;

=== modified file 'src/ftfont.c'
--- a/src/ftfont.c      2013-01-14 09:55:21 +0000
+++ b/src/ftfont.c      2013-01-15 09:22:25 +0000
@@ -400,7 +400,7 @@
   else
     {
       val = XCDR (cache);
-      cache_data = XSAVE_POINTER (val);
+      cache_data = XSAVE_POINTER (val, 0);
     }
 
   if (cache_for == FTFONT_CACHE_FOR_ENTITY)
@@ -466,7 +466,7 @@
 
   cache = ftfont_lookup_cache (entity, FTFONT_CACHE_FOR_CHARSET);
   val = XCDR (cache);
-  cache_data = XSAVE_POINTER (val);
+  cache_data = XSAVE_POINTER (val, 0);
   return cache_data->fc_charset;
 }
 
@@ -1198,9 +1198,9 @@
   filename = XCAR (val);
   idx = XCDR (val);
   val = XCDR (cache);
-  cache_data = XSAVE_POINTER (XCDR (cache));
+  cache_data = XSAVE_POINTER (XCDR (cache), 0);
   ft_face = cache_data->ft_face;
-  if (XSAVE_INTEGER (val) > 0)
+  if (XSAVE_INTEGER (val, 1) > 0)
     {
       /* FT_Face in this cache is already used by the different size.  */
       if (FT_New_Size (ft_face, &ft_size) != 0)
@@ -1211,13 +1211,13 @@
          return Qnil;
        }
     }
-  XSAVE_INTEGER (val)++;
+  XSAVE_INTEGER (val, 1)++;
   size = XINT (AREF (entity, FONT_SIZE_INDEX));
   if (size == 0)
     size = pixel_size;
   if (FT_Set_Pixel_Sizes (ft_face, size, size) != 0)
     {
-      if (XSAVE_INTEGER (val) == 0)
+      if (XSAVE_INTEGER (val, 1) == 0)
        FT_Done_Face (ft_face);
       return Qnil;
     }
@@ -1326,10 +1326,10 @@
   cache = ftfont_lookup_cache (val, FTFONT_CACHE_FOR_FACE);
   eassert (CONSP (cache));
   val = XCDR (cache);
-  (XSAVE_INTEGER (val))--;
-  if (XSAVE_INTEGER (val) == 0)
+  XSAVE_INTEGER (val, 1)--;
+  if (XSAVE_INTEGER (val, 1) == 0)
     {
-      struct ftfont_cache_data *cache_data = XSAVE_POINTER (val);
+      struct ftfont_cache_data *cache_data = XSAVE_POINTER (val, 0);
 
       FT_Done_Face (cache_data->ft_face);
 #ifdef HAVE_LIBOTF

=== modified file 'src/gtkutil.c'
--- a/src/gtkutil.c     2013-01-14 17:46:14 +0000
+++ b/src/gtkutil.c     2013-01-15 09:22:25 +0000
@@ -1650,7 +1650,7 @@
 static Lisp_Object
 pop_down_dialog (Lisp_Object arg)
 {
-  struct xg_dialog_data *dd = XSAVE_POINTER (arg);
+  struct xg_dialog_data *dd = XSAVE_POINTER (arg, 0);
 
   block_input ();
   if (dd->w) gtk_widget_destroy (dd->w);

=== modified file 'src/keymap.c'
--- a/src/keymap.c      2013-01-14 17:46:14 +0000
+++ b/src/keymap.c      2013-01-15 09:22:25 +0000
@@ -565,14 +565,14 @@
 {
   if (!NILP (val))
     {
-      map_keymap_function_t fun = XSAVE_POINTER (XCAR (args));
+      map_keymap_function_t fun = XSAVE_POINTER (XCAR (args), 0);
       args = XCDR (args);
       /* If the key is a range, make a copy since map_char_table modifies
         it in place.  */
       if (CONSP (key))
        key = Fcons (XCAR (key), XCDR (key));
       map_keymap_item (fun, XCDR (args), key, val,
-                      XSAVE_POINTER (XCAR (args)));
+                      XSAVE_POINTER (XCAR (args), 0));
     }
 }
 

=== modified file 'src/lisp.h'
--- a/src/lisp.h        2013-01-15 08:38:07 +0000
+++ b/src/lisp.h        2013-01-15 09:22:25 +0000
@@ -1413,15 +1413,21 @@
     } data[4];
   };
 
-/* Compatibility macro to set and extract saved pointer.  */
+/* Macro to set and extract Nth saved pointer.  Type
+   checking is ugly because it's used as an lvalue.  */
 
-#define XSAVE_POINTER(obj) XSAVE_VALUE (obj)->data[0].pointer
+#define XSAVE_POINTER(obj, n)                                  \
+  XSAVE_VALUE (obj)->data[(eassert (XSAVE_VALUE (obj)->type    \
+    ## n == SAVE_POINTER), n)].pointer
 
 /* Likewise for the saved integer.  */
 
-#define XSAVE_INTEGER(obj) XSAVE_VALUE (obj)->data[1].integer
+#define XSAVE_INTEGER(obj, n)                                  \
+  XSAVE_VALUE (obj)->data[(eassert (XSAVE_VALUE (obj)->type    \
+    ## n == SAVE_INTEGER), n)].integer
 
-/* Macro to extract Nth saved object.  */
+/* Macro to extract Nth saved object.  This is never used as
+   an lvalue, so we can do more convenient type checking.  */
 
 #define XSAVE_OBJECT(obj, n)                                   \
   (eassert (XSAVE_VALUE (obj)->type ## n == SAVE_OBJECT),      \

=== modified file 'src/lread.c'
--- a/src/lread.c       2013-01-14 17:46:14 +0000
+++ b/src/lread.c       2013-01-15 09:22:25 +0000
@@ -1357,7 +1357,7 @@
 static Lisp_Object
 load_unwind (Lisp_Object arg)  /* Used as unwind-protect function in load.  */
 {
-  FILE *stream = XSAVE_POINTER (arg);
+  FILE *stream = XSAVE_POINTER (arg, 0);
   if (stream != NULL)
     {
       block_input ();

=== modified file 'src/nsmenu.m'
--- a/src/nsmenu.m      2013-01-14 17:46:14 +0000
+++ b/src/nsmenu.m      2013-01-15 09:22:25 +0000
@@ -1347,7 +1347,7 @@
 static Lisp_Object
 pop_down_menu (Lisp_Object arg)
 {
-  struct Popdown_data *unwind_data = XSAVE_POINTER (arg);
+  struct Popdown_data *unwind_data = XSAVE_POINTER (arg, 0);
 
   block_input ();
   if (popup_activated_flag)

=== modified file 'src/nsterm.h'
--- a/src/nsterm.h      2013-01-14 09:55:21 +0000
+++ b/src/nsterm.h      2013-01-15 09:22:25 +0000
@@ -675,9 +675,9 @@
 #define FRAME_FONT(f) ((f)->output_data.ns->font)
 
 #ifdef __OBJC__
-#define XNS_SCROLL_BAR(vec) ((id) XSAVE_POINTER (vec))
+#define XNS_SCROLL_BAR(vec) ((id) XSAVE_POINTER (vec, 0))
 #else
-#define XNS_SCROLL_BAR(vec) XSAVE_POINTER (vec)
+#define XNS_SCROLL_BAR(vec) XSAVE_POINTER (vec, 0)
 #endif
 
 /* Compute pixel size for vertical scroll bars */

=== modified file 'src/xfns.c'
--- a/src/xfns.c        2013-01-14 17:46:14 +0000
+++ b/src/xfns.c        2013-01-15 09:22:25 +0000
@@ -5292,7 +5292,7 @@
 static Lisp_Object
 clean_up_file_dialog (Lisp_Object arg)
 {
-  Widget dialog = XSAVE_POINTER (arg);
+  Widget dialog = XSAVE_POINTER (arg, 0);
 
   /* Clean up.  */
   block_input ();

=== modified file 'src/xmenu.c'
--- a/src/xmenu.c       2013-01-14 17:46:14 +0000
+++ b/src/xmenu.c       2013-01-15 09:22:25 +0000
@@ -1413,7 +1413,7 @@
 {
   popup_activated_flag = 0;
   block_input ();
-  gtk_widget_destroy (GTK_WIDGET (XSAVE_POINTER (arg)));
+  gtk_widget_destroy (GTK_WIDGET (XSAVE_POINTER (arg, 0)));
   unblock_input ();
   return Qnil;
 }
@@ -1610,7 +1610,7 @@
 static Lisp_Object
 cleanup_widget_value_tree (Lisp_Object arg)
 {
-  free_menubar_widget_value_tree (XSAVE_POINTER (arg));
+  free_menubar_widget_value_tree (XSAVE_POINTER (arg, 0));
   return Qnil;
 }
 
@@ -2236,8 +2236,8 @@
 static Lisp_Object
 pop_down_menu (Lisp_Object arg)
 {
-  FRAME_PTR f = XSAVE_POINTER (Fcar (arg));
-  XMenu *menu = XSAVE_POINTER (Fcdr (arg));
+  FRAME_PTR f = XSAVE_POINTER (Fcar (arg), 0);
+  XMenu *menu = XSAVE_POINTER (Fcdr (arg), 0);
 
   block_input ();
 #ifndef MSDOS

=== modified file 'src/xselect.c'
--- a/src/xselect.c     2013-01-14 09:55:21 +0000
+++ b/src/xselect.c     2013-01-15 09:22:25 +0000
@@ -1120,7 +1120,7 @@
 static Lisp_Object
 wait_for_property_change_unwind (Lisp_Object loc)
 {
-  struct prop_location *location = XSAVE_POINTER (loc);
+  struct prop_location *location = XSAVE_POINTER (loc, 0);
 
   unexpect_property_change (location);
   if (location == property_change_reply_object)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]