Use "ASET (a, i, v)" rather than "AREF (a, i) = v".
[bpt/emacs.git] / src / keyboard.c
index d14d510..663a395 100644 (file)
@@ -5551,7 +5551,7 @@ make_lispy_event (struct input_event *event)
            mouse_syms = larger_vector (mouse_syms, incr, -1);
          }
 
-       start_pos_ptr = &AREF (button_down_location, button);
+       start_pos_ptr = aref_addr (button_down_location, button);
        start_pos = *start_pos_ptr;
        *start_pos_ptr = Qnil;
 
@@ -5959,7 +5959,7 @@ make_lispy_event (struct input_event *event)
            mouse_syms = larger_vector (mouse_syms, incr, -1);
          }
 
-       start_pos_ptr = &AREF (button_down_location, button);
+       start_pos_ptr = aref_addr (button_down_location, button);
        start_pos = *start_pos_ptr;
 
        position = make_lispy_position (f, event->x, event->y,
@@ -7525,8 +7525,8 @@ menu_bar_items (Lisp_Object old)
            tem2 = AREF (menu_bar_items_vector, i + 2);
            tem3 = AREF (menu_bar_items_vector, i + 3);
            if (end > i + 4)
-             memmove (&AREF (menu_bar_items_vector, i),
-                      &AREF (menu_bar_items_vector, i + 4),
+             memmove (aref_addr (menu_bar_items_vector, i),
+                      aref_addr (menu_bar_items_vector, i + 4),
                       (end - i - 4) * sizeof (Lisp_Object));
            ASET (menu_bar_items_vector, end - 4, tem0);
            ASET (menu_bar_items_vector, end - 3, tem1);
@@ -7575,8 +7575,8 @@ menu_bar_item (Lisp_Object key, Lisp_Object item, Lisp_Object dummy1, void *dumm
        if (EQ (key, AREF (menu_bar_items_vector, i)))
          {
            if (menu_bar_items_index > i + 4)
-             memmove (&AREF (menu_bar_items_vector, i),
-                      &AREF (menu_bar_items_vector, i + 4),
+             memmove (aref_addr (menu_bar_items_vector, i),
+                      aref_addr (menu_bar_items_vector, i + 4),
                       (menu_bar_items_index - i - 4) * sizeof (Lisp_Object));
            menu_bar_items_index -= 4;
          }
@@ -8096,6 +8096,14 @@ process_tool_bar_item (Lisp_Object key, Lisp_Object def, Lisp_Object data, void
   UNGCPRO;
 }
 
+/* Access slot with index IDX of vector tool_bar_item_properties.  */
+#define PROP(IDX) AREF (tool_bar_item_properties, (IDX))
+static inline void
+set_prop (ptrdiff_t idx, Lisp_Object val)
+{
+  ASET (tool_bar_item_properties, idx, val);
+}
+
 
 /* Parse a tool bar item specification ITEM for key KEY and return the
    result in tool_bar_item_properties.  Value is zero if ITEM is
@@ -8146,9 +8154,6 @@ process_tool_bar_item (Lisp_Object key, Lisp_Object def, Lisp_Object data, void
 static int
 parse_tool_bar_item (Lisp_Object key, Lisp_Object item)
 {
-  /* Access slot with index IDX of vector tool_bar_item_properties.  */
-#define PROP(IDX) AREF (tool_bar_item_properties, (IDX))
-
   Lisp_Object filter = Qnil;
   Lisp_Object caption;
   int i, have_label = 0;
@@ -8172,15 +8177,15 @@ parse_tool_bar_item (Lisp_Object key, Lisp_Object item)
   if (VECTORP (tool_bar_item_properties))
     {
       for (i = 0; i < TOOL_BAR_ITEM_NSLOTS; ++i)
-       PROP (i) = Qnil;
+       set_prop (i, Qnil);
     }
   else
     tool_bar_item_properties
       = Fmake_vector (make_number (TOOL_BAR_ITEM_NSLOTS), Qnil);
 
   /* Set defaults.  */
-  PROP (TOOL_BAR_ITEM_KEY) = key;
-  PROP (TOOL_BAR_ITEM_ENABLED_P) = Qt;
+  set_prop (TOOL_BAR_ITEM_KEY, key);
+  set_prop (TOOL_BAR_ITEM_ENABLED_P, Qt);
 
   /* Get the caption of the item.  If the caption is not a string,
      evaluate it to get a string.  If we don't get a string, skip this
@@ -8192,7 +8197,7 @@ parse_tool_bar_item (Lisp_Object key, Lisp_Object item)
       if (!STRINGP (caption))
        return 0;
     }
-  PROP (TOOL_BAR_ITEM_CAPTION) = caption;
+  set_prop (TOOL_BAR_ITEM_CAPTION, caption);
 
   /* If the rest following the caption is not a list, the menu item is
      either a separator, or invalid.  */
@@ -8201,7 +8206,7 @@ parse_tool_bar_item (Lisp_Object key, Lisp_Object item)
     {
       if (menu_separator_name_p (SSDATA (caption)))
        {
-         PROP (TOOL_BAR_ITEM_TYPE) = Qt;
+         set_prop (TOOL_BAR_ITEM_TYPE, Qt);
 #if !defined (USE_GTK) && !defined (HAVE_NS)
          /* If we use build_desired_tool_bar_string to render the
             tool bar, the separator is rendered as an image.  */
@@ -8217,7 +8222,7 @@ parse_tool_bar_item (Lisp_Object key, Lisp_Object item)
     }
 
   /* Store the binding.  */
-  PROP (TOOL_BAR_ITEM_BINDING) = XCAR (item);
+  set_prop (TOOL_BAR_ITEM_BINDING, XCAR (item));
   item = XCDR (item);
 
   /* Ignore cached key binding, if any.  */
@@ -8236,9 +8241,9 @@ parse_tool_bar_item (Lisp_Object key, Lisp_Object item)
        {
          /* `:enable FORM'.  */
          if (!NILP (Venable_disabled_menus_and_buttons))
-           PROP (TOOL_BAR_ITEM_ENABLED_P) = Qt;
+           set_prop (TOOL_BAR_ITEM_ENABLED_P, Qt);
          else
-           PROP (TOOL_BAR_ITEM_ENABLED_P) = value;
+           set_prop (TOOL_BAR_ITEM_ENABLED_P, value);
        }
       else if (EQ (ikey, QCvisible))
        {
@@ -8249,17 +8254,16 @@ parse_tool_bar_item (Lisp_Object key, Lisp_Object item)
        }
       else if (EQ (ikey, QChelp))
         /* `:help HELP-STRING'.  */
-        PROP (TOOL_BAR_ITEM_HELP) = value;
+        set_prop (TOOL_BAR_ITEM_HELP, value);
       else if (EQ (ikey, QCvert_only))
         /* `:vert-only t/nil'.  */
-        PROP (TOOL_BAR_ITEM_VERT_ONLY) = value;
+        set_prop (TOOL_BAR_ITEM_VERT_ONLY, value);
       else if (EQ (ikey, QClabel))
         {
           const char *bad_label = "!!?GARBLED ITEM?!!";
           /* `:label LABEL-STRING'.  */
-          PROP (TOOL_BAR_ITEM_LABEL) = STRINGP (value)
-            ? value
-            : build_string (bad_label);
+          set_prop (TOOL_BAR_ITEM_LABEL,
+                   STRINGP (value) ? value : build_string (bad_label));
           have_label = 1;
         }
       else if (EQ (ikey, QCfilter))
@@ -8274,8 +8278,8 @@ parse_tool_bar_item (Lisp_Object key, Lisp_Object item)
          selected = XCDR (value);
          if (EQ (type, QCtoggle) || EQ (type, QCradio))
            {
-             PROP (TOOL_BAR_ITEM_SELECTED_P) = selected;
-             PROP (TOOL_BAR_ITEM_TYPE) = type;
+             set_prop (TOOL_BAR_ITEM_SELECTED_P, selected);
+             set_prop (TOOL_BAR_ITEM_TYPE, type);
            }
        }
       else if (EQ (ikey, QCimage)
@@ -8283,10 +8287,10 @@ parse_tool_bar_item (Lisp_Object key, Lisp_Object item)
                   || (VECTORP (value) && ASIZE (value) == 4)))
        /* Value is either a single image specification or a vector
           of 4 such specifications for the different button states.  */
-       PROP (TOOL_BAR_ITEM_IMAGES) = value;
+       set_prop (TOOL_BAR_ITEM_IMAGES, value);
       else if (EQ (ikey, QCrtl))
         /* ':rtl STRING' */
-       PROP (TOOL_BAR_ITEM_RTL_IMAGE) = value;
+       set_prop (TOOL_BAR_ITEM_RTL_IMAGE, value);
     }
 
 
@@ -8328,18 +8332,19 @@ parse_tool_bar_item (Lisp_Object key, Lisp_Object item)
 
       new_lbl = Fupcase_initials (build_string (label));
       if (SCHARS (new_lbl) <= tool_bar_max_label_size)
-        PROP (TOOL_BAR_ITEM_LABEL) = new_lbl;
+        set_prop (TOOL_BAR_ITEM_LABEL, new_lbl);
       else
-        PROP (TOOL_BAR_ITEM_LABEL) = empty_unibyte_string;
+        set_prop (TOOL_BAR_ITEM_LABEL, empty_unibyte_string);
       xfree (buf);
     }
 
   /* If got a filter apply it on binding.  */
   if (!NILP (filter))
-    PROP (TOOL_BAR_ITEM_BINDING)
-      = menu_item_eval_property (list2 (filter,
-                                       list2 (Qquote,
-                                              PROP (TOOL_BAR_ITEM_BINDING))));
+    set_prop (TOOL_BAR_ITEM_BINDING,
+             (menu_item_eval_property
+              (list2 (filter,
+                      list2 (Qquote,
+                             PROP (TOOL_BAR_ITEM_BINDING))))));
 
   /* See if the binding is a keymap.  Give up if it is.  */
   if (CONSP (get_keymap (PROP (TOOL_BAR_ITEM_BINDING), 0, 1)))
@@ -8347,13 +8352,13 @@ parse_tool_bar_item (Lisp_Object key, Lisp_Object item)
 
   /* Enable or disable selection of item.  */
   if (!EQ (PROP (TOOL_BAR_ITEM_ENABLED_P), Qt))
-    PROP (TOOL_BAR_ITEM_ENABLED_P)
-      = menu_item_eval_property (PROP (TOOL_BAR_ITEM_ENABLED_P));
+    set_prop (TOOL_BAR_ITEM_ENABLED_P,
+             menu_item_eval_property (PROP (TOOL_BAR_ITEM_ENABLED_P)));
 
   /* Handle radio buttons or toggle boxes.  */
   if (!NILP (PROP (TOOL_BAR_ITEM_SELECTED_P)))
-    PROP (TOOL_BAR_ITEM_SELECTED_P)
-      = menu_item_eval_property (PROP (TOOL_BAR_ITEM_SELECTED_P));
+    set_prop (TOOL_BAR_ITEM_SELECTED_P,
+             menu_item_eval_property (PROP (TOOL_BAR_ITEM_SELECTED_P)));
 
   return 1;