+2012-08-01 Paul Eggert <eggert@cs.ucla.edu>
+
+ Use "ASET (a, i, v)" rather than "AREF (a, i) = v".
+ This how ASET and AREF are supposed to work, and makes
+ it easier to think about future improvements. See
+ <http://lists.gnu.org/archive/html/emacs-devel/2012-08/msg00026.html>.
+ * charset.h (set_charset_attr): New function.
+ All lvalue-style uses of CHARSET_DECODER etc. changed to use it.
+ * lisp.h (ASET): Rewrite so as not to use AREF in an lvalue style.
+ (aref_addr): New function. All uses of &AREF(...) changed.
+ (set_hash_key, set_hash_value, set_hash_next, set_hash_hash)
+ (set_hash_index): New functions. All lvalue-style uses of
+ HASH_KEY etc. changed.
+ * keyboard.c (set_prop): New function. All lvalue-style uses
+ of PROP changed.
+
2012-08-01 Alp Aker <alp.tekin.aker@gmail.com>
* nsterm.m (ns_set_vertical_scroll_bar, ns_redeem_scroll_bar)
{
int n = CODE_POINT_TO_INDEX (charset, max_code) + 1;
- vec = CHARSET_DECODER (charset)
- = Fmake_vector (make_number (n), make_number (-1));
+ vec = Fmake_vector (make_number (n), make_number (-1));
+ set_charset_attr (charset, charset_decoder, vec);
}
else
{
else
{
table = Fmake_char_table (Qnil, Qnil);
- if (charset->method == CHARSET_METHOD_MAP)
- CHARSET_ENCODER (charset) = table;
- else
- CHARSET_DEUNIFIER (charset) = table;
+ set_charset_attr (charset,
+ (charset->method == CHARSET_METHOD_MAP
+ ? charset_encoder : charset_deunifier),
+ table);
}
}
else
{
new_definition_p = 0;
id = XFASTINT (CHARSET_SYMBOL_ID (args[charset_arg_name]));
- HASH_VALUE (hash_table, charset.hash_index) = attrs;
+ set_hash_value (hash_table, charset.hash_index, attrs);
}
else
{
Lisp_Object attrs;
CHECK_CHARSET_GET_ATTR (charset, attrs);
- CHARSET_ATTR_PLIST (attrs) = plist;
+ ASET (attrs, charset_plist, plist);
return plist;
}
{
if (! STRINGP (unify_map) && ! VECTORP (unify_map))
signal_error ("Bad unify-map", unify_map);
- CHARSET_UNIFY_MAP (cs) = unify_map;
+ set_charset_attr (cs, charset_unify_map, unify_map);
}
if (NILP (Vchar_unify_table))
Vchar_unify_table = Fmake_char_table (Qnil, Qnil);
#define CHARSET_DEUNIFIER(charset) \
(CHARSET_ATTR_DEUNIFIER (CHARSET_ATTRIBUTES (charset)))
+static inline void
+set_charset_attr (struct charset *charset, enum charset_attr_index idx,
+ Lisp_Object val)
+{
+ ASET (CHARSET_ATTRIBUTES (charset), idx, val);
+}
+
/* Nonzero if OBJ is a valid charset symbol. */
#define CHARSETP(obj) (CHARSET_SYMBOL_HASH_INDEX (obj) >= 0)
CODING_GET_INFO (coding, attrs, charset_list);
if (! EQ (charset_list, Vemacs_mule_charset_list))
{
- CODING_ATTR_CHARSET_LIST (attrs)
- = charset_list = Vemacs_mule_charset_list;
+ charset_list = Vemacs_mule_charset_list;
+ ASET (attrs, coding_attr_charset_list, charset_list);
}
while (charbuf < charbuf_end)
if ((flags & CODING_ISO_FLAG_FULL_SUPPORT)
&& ! EQ (charset_list, Viso_2022_charset_list))
{
- CODING_ATTR_CHARSET_LIST (attrs)
- = charset_list = Viso_2022_charset_list;
+ charset_list = Viso_2022_charset_list;
+ ASET (attrs, coding_attr_charset_list, charset_list);
ASET (attrs, coding_attr_safe_charsets, Qnil);
}
name = args[coding_arg_name];
CHECK_SYMBOL (name);
- CODING_ATTR_BASE_NAME (attrs) = name;
+ ASET (attrs, coding_attr_base_name, name);
val = args[coding_arg_mnemonic];
if (! STRINGP (val))
CHECK_CHARACTER (val);
- CODING_ATTR_MNEMONIC (attrs) = val;
+ ASET (attrs, coding_attr_mnemonic, val);
coding_type = args[coding_arg_coding_type];
CHECK_SYMBOL (coding_type);
- CODING_ATTR_TYPE (attrs) = coding_type;
+ ASET (attrs, coding_attr_type, coding_type);
charset_list = args[coding_arg_charset_list];
if (SYMBOLP (charset_list))
max_charset_id = charset->id;
}
}
- CODING_ATTR_CHARSET_LIST (attrs) = charset_list;
+ ASET (attrs, coding_attr_charset_list, charset_list);
safe_charsets = make_uninit_string (max_charset_id + 1);
memset (SDATA (safe_charsets), 255, max_charset_id + 1);
for (tail = charset_list; CONSP (tail); tail = XCDR (tail))
SSET (safe_charsets, XFASTINT (XCAR (tail)), 0);
- CODING_ATTR_SAFE_CHARSETS (attrs) = safe_charsets;
+ ASET (attrs, coding_attr_safe_charsets, safe_charsets);
- CODING_ATTR_ASCII_COMPAT (attrs) = args[coding_arg_ascii_compatible_p];
+ ASET (attrs, coding_attr_ascii_compat, args[coding_arg_ascii_compatible_p]);
val = args[coding_arg_decode_translation_table];
if (! CHAR_TABLE_P (val) && ! CONSP (val))
CHECK_SYMBOL (val);
- CODING_ATTR_DECODE_TBL (attrs) = val;
+ ASET (attrs, coding_attr_decode_tbl, val);
val = args[coding_arg_encode_translation_table];
if (! CHAR_TABLE_P (val) && ! CONSP (val))
CHECK_SYMBOL (val);
- CODING_ATTR_ENCODE_TBL (attrs) = val;
+ ASET (attrs, coding_attr_encode_tbl, val);
val = args[coding_arg_post_read_conversion];
CHECK_SYMBOL (val);
- CODING_ATTR_POST_READ (attrs) = val;
+ ASET (attrs, coding_attr_post_read, val);
val = args[coding_arg_pre_write_conversion];
CHECK_SYMBOL (val);
- CODING_ATTR_PRE_WRITE (attrs) = val;
+ ASET (attrs, coding_attr_pre_write, val);
val = args[coding_arg_default_char];
if (NILP (val))
- CODING_ATTR_DEFAULT_CHAR (attrs) = make_number (' ');
+ ASET (attrs, coding_attr_default_char, make_number (' '));
else
{
CHECK_CHARACTER (val);
- CODING_ATTR_DEFAULT_CHAR (attrs) = val;
+ ASET (attrs, coding_attr_default_char, val);
}
val = args[coding_arg_for_unibyte];
- CODING_ATTR_FOR_UNIBYTE (attrs) = NILP (val) ? Qnil : Qt;
+ ASET (attrs, coding_attr_for_unibyte, NILP (val) ? Qnil : Qt);
val = args[coding_arg_plist];
CHECK_LIST (val);
- CODING_ATTR_PLIST (attrs) = val;
+ ASET (attrs, coding_attr_plist, val);
if (EQ (coding_type, Qcharset))
{
int idx = (dim - 1) * 4;
if (CHARSET_ASCII_COMPATIBLE_P (charset))
- CODING_ATTR_ASCII_COMPAT (attrs) = Qt;
+ ASET (attrs, coding_attr_ascii_compat, Qt);
for (i = charset->code_space[idx];
i <= charset->code_space[idx + 1]; i++)
{
Lisp_Object bom, endian;
- CODING_ATTR_ASCII_COMPAT (attrs) = Qnil;
+ ASET (attrs, coding_attr_ascii_compat, Qnil);
if (nargs < coding_arg_utf16_max)
goto short_args;
CHECK_CHARSET_GET_CHARSET (val, charset);
ASET (initial, i, make_number (CHARSET_ID (charset)));
if (i == 0 && CHARSET_ASCII_COMPATIBLE_P (charset))
- CODING_ATTR_ASCII_COMPAT (attrs) = Qt;
+ ASET (attrs, coding_attr_ascii_compat, Qt);
}
else
ASET (initial, i, make_number (-1));
}
if (category != coding_category_iso_8_1
&& category != coding_category_iso_8_2)
- CODING_ATTR_ASCII_COMPAT (attrs) = Qnil;
+ ASET (attrs, coding_attr_ascii_compat, Qnil);
}
else if (EQ (coding_type, Qemacs_mule))
{
if (EQ (args[coding_arg_charset_list], Qemacs_mule))
ASET (attrs, coding_attr_emacs_mule_full, Qt);
- CODING_ATTR_ASCII_COMPAT (attrs) = Qt;
+ ASET (attrs, coding_attr_ascii_compat, Qt);
category = coding_category_emacs_mule;
}
else if (EQ (coding_type, Qshift_jis))
error ("Dimension of charset %s is not one",
SDATA (SYMBOL_NAME (CHARSET_NAME (charset))));
if (CHARSET_ASCII_COMPATIBLE_P (charset))
- CODING_ATTR_ASCII_COMPAT (attrs) = Qt;
+ ASET (attrs, coding_attr_ascii_compat, Qt);
charset_list = XCDR (charset_list);
charset = CHARSET_FROM_ID (XINT (XCAR (charset_list)));
error ("Dimension of charset %s is not one",
SDATA (SYMBOL_NAME (CHARSET_NAME (charset))));
if (CHARSET_ASCII_COMPATIBLE_P (charset))
- CODING_ATTR_ASCII_COMPAT (attrs) = Qt;
+ ASET (attrs, coding_attr_ascii_compat, Qt);
charset_list = XCDR (charset_list);
charset = CHARSET_FROM_ID (XINT (XCAR (charset_list)));
else if (EQ (coding_type, Qraw_text))
{
category = coding_category_raw_text;
- CODING_ATTR_ASCII_COMPAT (attrs) = Qt;
+ ASET (attrs, coding_attr_ascii_compat, Qt);
}
else if (EQ (coding_type, Qutf_8))
{
}
ASET (attrs, coding_attr_utf_bom, bom);
if (NILP (bom))
- CODING_ATTR_ASCII_COMPAT (attrs) = Qt;
+ ASET (attrs, coding_attr_ascii_compat, Qt);
category = (CONSP (bom) ? coding_category_utf_8_auto
: NILP (bom) ? coding_category_utf_8_nosig
error ("Invalid coding system type: %s",
SDATA (SYMBOL_NAME (coding_type)));
- CODING_ATTR_CATEGORY (attrs) = make_number (category);
- CODING_ATTR_PLIST (attrs)
- = Fcons (QCcategory, Fcons (AREF (Vcoding_category_table, category),
- CODING_ATTR_PLIST (attrs)));
- CODING_ATTR_PLIST (attrs)
- = Fcons (QCascii_compatible_p,
- Fcons (CODING_ATTR_ASCII_COMPAT (attrs),
- CODING_ATTR_PLIST (attrs)));
+ ASET (attrs, coding_attr_category, make_number (category));
+ ASET (attrs, coding_attr_plist,
+ Fcons (QCcategory,
+ Fcons (AREF (Vcoding_category_table, category),
+ CODING_ATTR_PLIST (attrs))));
+ ASET (attrs, coding_attr_plist,
+ Fcons (QCascii_compatible_p,
+ Fcons (CODING_ATTR_ASCII_COMPAT (attrs),
+ CODING_ATTR_PLIST (attrs))));
eol_type = args[coding_arg_eol_type];
if (! NILP (eol_type)
{
if (! STRINGP (val))
CHECK_CHARACTER (val);
- CODING_ATTR_MNEMONIC (attrs) = val;
+ ASET (attrs, coding_attr_mnemonic, val);
}
else if (EQ (prop, QCdefault_char))
{
val = make_number (' ');
else
CHECK_CHARACTER (val);
- CODING_ATTR_DEFAULT_CHAR (attrs) = val;
+ ASET (attrs, coding_attr_default_char, val);
}
else if (EQ (prop, QCdecode_translation_table))
{
if (! CHAR_TABLE_P (val) && ! CONSP (val))
CHECK_SYMBOL (val);
- CODING_ATTR_DECODE_TBL (attrs) = val;
+ ASET (attrs, coding_attr_decode_tbl, val);
}
else if (EQ (prop, QCencode_translation_table))
{
if (! CHAR_TABLE_P (val) && ! CONSP (val))
CHECK_SYMBOL (val);
- CODING_ATTR_ENCODE_TBL (attrs) = val;
+ ASET (attrs, coding_attr_encode_tbl, val);
}
else if (EQ (prop, QCpost_read_conversion))
{
CHECK_SYMBOL (val);
- CODING_ATTR_POST_READ (attrs) = val;
+ ASET (attrs, coding_attr_post_read, val);
}
else if (EQ (prop, QCpre_write_conversion))
{
CHECK_SYMBOL (val);
- CODING_ATTR_PRE_WRITE (attrs) = val;
+ ASET (attrs, coding_attr_pre_write, val);
}
else if (EQ (prop, QCascii_compatible_p))
{
- CODING_ATTR_ASCII_COMPAT (attrs) = val;
+ ASET (attrs, coding_attr_ascii_compat, val);
}
- CODING_ATTR_PLIST (attrs)
- = Fplist_put (CODING_ATTR_PLIST (attrs), prop, val);
+ ASET (attrs, coding_attr_plist,
+ Fplist_put (CODING_ATTR_PLIST (attrs), prop, val));
return val;
}
}
metrics->width = metrics->lbearing = metrics->rbearing = 0;
}
- for (glyph = &LGSTRING_GLYPH (gstring, from); from < to; from++, glyph++)
+ for (glyph = lgstring_glyph_addr (gstring, from); from < to; from++, glyph++)
{
int x;
#define LGSTRING_GLYPH_LEN(lgs) (ASIZE ((lgs)) - 2)
#define LGSTRING_GLYPH(lgs, idx) AREF ((lgs), (idx) + 2)
#define LGSTRING_SET_GLYPH(lgs, idx, val) ASET ((lgs), (idx) + 2, (val))
+static inline Lisp_Object *
+lgstring_glyph_addr (Lisp_Object lgs, ptrdiff_t idx)
+{
+ return aref_addr (lgs, idx + 2);
+}
/* Vector size of Lispy glyph. */
enum lglyph_indices
string, make_number (0), res, Qnil);
}
else
- res = Fvector (to_char - from_char, &AREF (string, from_char));
+ res = Fvector (to_char - from_char, aref_addr (string, from_char));
return res;
}
string, make_number (0), res, Qnil);
}
else
- res = Fvector (to - from, &AREF (string, from));
+ res = Fvector (to - from, aref_addr (string, from));
return res;
}
/* Set up the free list. */
for (i = 0; i < sz - 1; ++i)
- HASH_NEXT (h, i) = make_number (i + 1);
+ set_hash_next (h, i, make_number (i + 1));
h->next_free = make_number (0);
XSET_HASH_TABLE (table, h);
the end of the free list. This makes some operations like
maphash faster. */
for (i = old_size; i < new_size - 1; ++i)
- HASH_NEXT (h, i) = make_number (i + 1);
+ set_hash_next (h, i, make_number (i + 1));
if (!NILP (h->next_free))
{
!NILP (next))
last = next;
- HASH_NEXT (h, XFASTINT (last)) = make_number (old_size);
+ set_hash_next (h, XFASTINT (last), make_number (old_size));
}
else
XSETFASTINT (h->next_free, old_size);
{
EMACS_UINT hash_code = XUINT (HASH_HASH (h, i));
ptrdiff_t start_of_bucket = hash_code % ASIZE (h->index);
- HASH_NEXT (h, i) = HASH_INDEX (h, start_of_bucket);
- HASH_INDEX (h, start_of_bucket) = make_number (i);
+ set_hash_next (h, i, HASH_INDEX (h, start_of_bucket));
+ set_hash_index (h, start_of_bucket, make_number (i));
}
}
}
/* Store key/value in the key_and_value vector. */
i = XFASTINT (h->next_free);
h->next_free = HASH_NEXT (h, i);
- HASH_KEY (h, i) = key;
- HASH_VALUE (h, i) = value;
+ set_hash_key (h, i, key);
+ set_hash_value (h, i, value);
/* Remember its hash code. */
- HASH_HASH (h, i) = make_number (hash);
+ set_hash_hash (h, i, make_number (hash));
/* Add new entry to its collision chain. */
start_of_bucket = hash % ASIZE (h->index);
- HASH_NEXT (h, i) = HASH_INDEX (h, start_of_bucket);
- HASH_INDEX (h, start_of_bucket) = make_number (i);
+ set_hash_next (h, i, HASH_INDEX (h, start_of_bucket));
+ set_hash_index (h, start_of_bucket, make_number (i));
return i;
}
{
/* Take entry out of collision chain. */
if (NILP (prev))
- HASH_INDEX (h, start_of_bucket) = HASH_NEXT (h, i);
+ set_hash_index (h, start_of_bucket, HASH_NEXT (h, i));
else
- HASH_NEXT (h, XFASTINT (prev)) = HASH_NEXT (h, i);
+ set_hash_next (h, XFASTINT (prev), HASH_NEXT (h, i));
/* Clear slots in key_and_value and add the slots to
the free list. */
- HASH_KEY (h, i) = HASH_VALUE (h, i) = HASH_HASH (h, i) = Qnil;
- HASH_NEXT (h, i) = h->next_free;
+ set_hash_key (h, i, Qnil);
+ set_hash_value (h, i, Qnil);
+ set_hash_hash (h, i, Qnil);
+ set_hash_next (h, i, h->next_free);
h->next_free = make_number (i);
h->count--;
eassert (h->count >= 0);
for (i = 0; i < size; ++i)
{
- HASH_NEXT (h, i) = i < size - 1 ? make_number (i + 1) : Qnil;
- HASH_KEY (h, i) = Qnil;
- HASH_VALUE (h, i) = Qnil;
- HASH_HASH (h, i) = Qnil;
+ set_hash_next (h, i, i < size - 1 ? make_number (i + 1) : Qnil);
+ set_hash_key (h, i, Qnil);
+ set_hash_value (h, i, Qnil);
+ set_hash_hash (h, i, Qnil);
}
for (i = 0; i < ASIZE (h->index); ++i)
{
/* Take out of collision chain. */
if (NILP (prev))
- HASH_INDEX (h, bucket) = next;
+ set_hash_index (h, bucket, next);
else
- HASH_NEXT (h, XFASTINT (prev)) = next;
+ set_hash_next (h, XFASTINT (prev), next);
/* Add to free list. */
- HASH_NEXT (h, i) = h->next_free;
+ set_hash_next (h, i, h->next_free);
h->next_free = idx;
/* Clear key, value, and hash. */
- HASH_KEY (h, i) = HASH_VALUE (h, i) = Qnil;
- HASH_HASH (h, i) = Qnil;
+ set_hash_key (h, i, Qnil);
+ set_hash_value (h, i, Qnil);
+ set_hash_hash (h, i, Qnil);
h->count--;
}
i = hash_lookup (h, key, &hash);
if (i >= 0)
- HASH_VALUE (h, i) = value;
+ set_hash_value (h, i, value);
else
hash_put (h, key, value, hash);
Lisp_Object elt = AREF (object, XFASTINT (from) + i);
CHECK_CHARACTER (elt);
}
- chars = &(AREF (object, XFASTINT (from)));
+ chars = aref_addr (object, XFASTINT (from));
}
vec = Fmake_vector (make_number (len), Qnil);
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;
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,
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);
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;
}
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
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;
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
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. */
{
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. */
}
/* 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. */
{
/* `: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))
{
}
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))
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)
|| (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);
}
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)))
/* 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;
#define ASET(ARRAY, IDX, VAL) \
(eassert ((IDX) == (IDX)), \
eassert ((IDX) >= 0 && (IDX) < ASIZE (ARRAY)), \
- AREF ((ARRAY), (IDX)) = (VAL))
+ XVECTOR (ARRAY)->contents[IDX] = (VAL))
/* Convenience macros for dealing with Lisp strings. */
struct window;
struct frame;
+/* Simple access functions. */
+
+static inline Lisp_Object *
+aref_addr (Lisp_Object array, ptrdiff_t idx)
+{
+ return & XVECTOR (array)->contents[idx];
+}
+
+static inline void
+set_hash_key (struct Lisp_Hash_Table *h, ptrdiff_t idx, Lisp_Object val)
+{
+ ASET (h->key_and_value, 2 * idx, val);
+}
+
+static inline void
+set_hash_value (struct Lisp_Hash_Table *h, ptrdiff_t idx, Lisp_Object val)
+{
+ ASET (h->key_and_value, 2 * idx + 1, val);
+}
+
+static inline void
+set_hash_next (struct Lisp_Hash_Table *h, ptrdiff_t idx, Lisp_Object val)
+{
+ ASET (h->next, idx, val);
+}
+
+static inline void
+set_hash_hash (struct Lisp_Hash_Table *h, ptrdiff_t idx, Lisp_Object val)
+{
+ ASET (h->hash, idx, val);
+}
+
+static inline void
+set_hash_index (struct Lisp_Hash_Table *h, ptrdiff_t idx, Lisp_Object val)
+{
+ ASET (h->index, idx, val);
+}
+
/* Defined in data.c. */
extern Lisp_Object Qnil, Qt, Qquote, Qlambda, Qunbound;
extern Lisp_Object Qerror_conditions, Qerror_message, Qtop_level;
SET_SYMBOL_VAL (XSYMBOL (sym), sym);
}
- ptr = &AREF (obarray, XINT(tem));
+ ptr = aref_addr (obarray, XINT(tem));
if (SYMBOLP (*ptr))
XSYMBOL (sym)->next = XSYMBOL (*ptr);
else
if (EQ (AREF (obarray, hash), tem))
{
if (XSYMBOL (tem)->next)
- XSETSYMBOL (AREF (obarray, hash), XSYMBOL (tem)->next);
+ {
+ Lisp_Object sym;
+ XSETSYMBOL (sym, XSYMBOL (tem)->next);
+ ASET (obarray, hash, sym);
+ }
else
- XSETINT (AREF (obarray, hash), 0);
+ ASET (obarray, hash, make_number (0));
}
else
{
{
entry
= AREF (menu_items, i + MENU_ITEMS_ITEM_VALUE);
- if (&AREF (menu_items, i) == client_data)
+ if (aref_addr (menu_items, i) == client_data)
{
if (keymaps != 0)
{
/* Save the frame's previous menu bar contents data */
if (previous_menu_items_used)
- memcpy (previous_items, &AREF (FVAR (f, menu_bar_vector), 0),
+ memcpy (previous_items, aref_addr (FVAR (f, menu_bar_vector), 0),
previous_menu_items_used * sizeof (Lisp_Object));
/* parse stage 1: extract from lisp */
/* If this item has a null value,
make the call_data null so that it won't display a box
when the mouse is on it. */
- wv->call_data
- = !NILP (def) ? (void *) &AREF (menu_items, i) : 0;
+ wv->call_data = !NILP (def) ? aref_addr (menu_items, i) : 0;
wv->enabled = !NILP (enable);
if (NILP (type))
unwind_data->pool = pool;
unwind_data->dialog = dialog;
-
+
record_unwind_protect (pop_down_menu, make_save_value (unwind_data, 0));
popup_activated_flag = 1;
tem = [dialog runDialogAt: p];
if (!NILP (descrip))
wv->key = SSDATA (descrip);
wv->value = SSDATA (item_name);
- wv->call_data = (void *) &AREF (menu_items, i);
+ wv->call_data = aref_addr (menu_items, i);
wv->enabled = !NILP (enable);
wv->help = Qnil;
prev_wv = wv;
{
Lisp_Object family = AREF (font_object, FONT_FAMILY_INDEX);
- LFACE_FAMILY (lface) = SYMBOL_NAME (family);
+ ASET (lface, LFACE_FAMILY_INDEX, SYMBOL_NAME (family));
}
if (force_p || UNSPECIFIEDP (LFACE_FOUNDRY (lface)))
{
Lisp_Object foundry = AREF (font_object, FONT_FOUNDRY_INDEX);
- LFACE_FOUNDRY (lface) = SYMBOL_NAME (foundry);
+ ASET (lface, LFACE_FOUNDRY_INDEX, SYMBOL_NAME (foundry));
}
if (force_p || UNSPECIFIEDP (LFACE_HEIGHT (lface)))
int pt = PIXEL_TO_POINT (font->pixel_size * 10, f->resy);
eassert (pt > 0);
- LFACE_HEIGHT (lface) = make_number (pt);
+ ASET (lface, LFACE_HEIGHT_INDEX, make_number (pt));
}
if (force_p || UNSPECIFIEDP (LFACE_WEIGHT (lface)))
{
val = FONT_WEIGHT_FOR_FACE (font_object);
- LFACE_WEIGHT (lface) = ! NILP (val) ? val :Qnormal;
+ ASET (lface, LFACE_WEIGHT_INDEX, ! NILP (val) ? val :Qnormal);
}
if (force_p || UNSPECIFIEDP (LFACE_SLANT (lface)))
{
val = FONT_SLANT_FOR_FACE (font_object);
- LFACE_SLANT (lface) = ! NILP (val) ? val : Qnormal;
+ ASET (lface, LFACE_SLANT_INDEX, ! NILP (val) ? val : Qnormal);
}
if (force_p || UNSPECIFIEDP (LFACE_SWIDTH (lface)))
{
val = FONT_WIDTH_FOR_FACE (font_object);
- LFACE_SWIDTH (lface) = ! NILP (val) ? val : Qnormal;
+ ASET (lface, LFACE_SWIDTH_INDEX, ! NILP (val) ? val : Qnormal);
}
- LFACE_FONT (lface) = font_object;
+ ASET (lface, LFACE_FONT_INDEX, font_object);
return 1;
}
signal_error ("Invalid face family", value);
}
old_value = LFACE_FAMILY (lface);
- LFACE_FAMILY (lface) = value;
+ ASET (lface, LFACE_FAMILY_INDEX, value);
prop_index = FONT_FAMILY_INDEX;
}
else if (EQ (attr, QCfoundry))
signal_error ("Invalid face foundry", value);
}
old_value = LFACE_FOUNDRY (lface);
- LFACE_FOUNDRY (lface) = value;
+ ASET (lface, LFACE_FOUNDRY_INDEX, value);
prop_index = FONT_FOUNDRY_INDEX;
}
else if (EQ (attr, QCheight))
}
old_value = LFACE_HEIGHT (lface);
- LFACE_HEIGHT (lface) = value;
+ ASET (lface, LFACE_HEIGHT_INDEX, value);
prop_index = FONT_SIZE_INDEX;
}
else if (EQ (attr, QCweight))
signal_error ("Invalid face weight", value);
}
old_value = LFACE_WEIGHT (lface);
- LFACE_WEIGHT (lface) = value;
+ ASET (lface, LFACE_WEIGHT_INDEX, value);
prop_index = FONT_WEIGHT_INDEX;
}
else if (EQ (attr, QCslant))
signal_error ("Invalid face slant", value);
}
old_value = LFACE_SLANT (lface);
- LFACE_SLANT (lface) = value;
+ ASET (lface, LFACE_SLANT_INDEX, value);
prop_index = FONT_SLANT_INDEX;
}
else if (EQ (attr, QCunderline))
signal_error ("Invalid face underline", value);
old_value = LFACE_UNDERLINE (lface);
- LFACE_UNDERLINE (lface) = value;
+ ASET (lface, LFACE_UNDERLINE_INDEX, value);
}
else if (EQ (attr, QCoverline))
{
signal_error ("Invalid face overline", value);
old_value = LFACE_OVERLINE (lface);
- LFACE_OVERLINE (lface) = value;
+ ASET (lface, LFACE_OVERLINE_INDEX, value);
}
else if (EQ (attr, QCstrike_through))
{
signal_error ("Invalid face strike-through", value);
old_value = LFACE_STRIKE_THROUGH (lface);
- LFACE_STRIKE_THROUGH (lface) = value;
+ ASET (lface, LFACE_STRIKE_THROUGH_INDEX, value);
}
else if (EQ (attr, QCbox))
{
signal_error ("Invalid face box", value);
old_value = LFACE_BOX (lface);
- LFACE_BOX (lface) = value;
+ ASET (lface, LFACE_BOX_INDEX, value);
}
else if (EQ (attr, QCinverse_video)
|| EQ (attr, QCreverse_video))
signal_error ("Invalid inverse-video face attribute value", value);
}
old_value = LFACE_INVERSE (lface);
- LFACE_INVERSE (lface) = value;
+ ASET (lface, LFACE_INVERSE_INDEX, value);
}
else if (EQ (attr, QCforeground))
{
signal_error ("Empty foreground color value", value);
}
old_value = LFACE_FOREGROUND (lface);
- LFACE_FOREGROUND (lface) = value;
+ ASET (lface, LFACE_FOREGROUND_INDEX, value);
}
else if (EQ (attr, QCbackground))
{
signal_error ("Empty background color value", value);
}
old_value = LFACE_BACKGROUND (lface);
- LFACE_BACKGROUND (lface) = value;
+ ASET (lface, LFACE_BACKGROUND_INDEX, value);
}
else if (EQ (attr, QCstipple))
{
&& NILP (Fbitmap_spec_p (value)))
signal_error ("Invalid stipple attribute", value);
old_value = LFACE_STIPPLE (lface);
- LFACE_STIPPLE (lface) = value;
+ ASET (lface, LFACE_STIPPLE_INDEX, value);
#endif /* HAVE_X_WINDOWS || HAVE_NS */
}
else if (EQ (attr, QCwidth))
signal_error ("Invalid face width", value);
}
old_value = LFACE_SWIDTH (lface);
- LFACE_SWIDTH (lface) = value;
+ ASET (lface, LFACE_SWIDTH_INDEX, value);
prop_index = FONT_WIDTH_INDEX;
}
else if (EQ (attr, QCfont))
set_lface_from_font (f, lface, value, 1);
}
else
- LFACE_FONT (lface) = value;
+ ASET (lface, LFACE_FONT_INDEX, value);
}
#endif /* HAVE_WINDOW_SYSTEM */
}
tmp = Fquery_fontset (value, Qnil);
if (NILP (tmp))
signal_error ("Invalid fontset name", value);
- LFACE_FONTSET (lface) = value = tmp;
+ ASET (lface, LFACE_FONTSET_INDEX, value = tmp);
}
#endif /* HAVE_WINDOW_SYSTEM */
}
if (!SYMBOLP (XCAR (tail)))
break;
if (NILP (tail))
- LFACE_INHERIT (lface) = value;
+ ASET (lface, LFACE_INHERIT_INDEX, value);
else
signal_error ("Invalid face inheritance", value);
}
else if (EQ (attr, QCbold))
{
old_value = LFACE_WEIGHT (lface);
- LFACE_WEIGHT (lface) = NILP (value) ? Qnormal : Qbold;
+ ASET (lface, LFACE_WEIGHT_INDEX, NILP (value) ? Qnormal : Qbold);
prop_index = FONT_WEIGHT_INDEX;
}
else if (EQ (attr, QCitalic))
{
attr = QCslant;
old_value = LFACE_SLANT (lface);
- LFACE_SLANT (lface) = NILP (value) ? Qnormal : Qitalic;
+ ASET (lface, LFACE_SLANT_INDEX, NILP (value) ? Qnormal : Qitalic);
prop_index = FONT_SLANT_INDEX;
}
else
{
face = Qdefault;
lface = lface_from_face_name (f, face, 1);
- LFACE_FOREGROUND (lface) = (STRINGP (new_value)
- ? new_value : Qunspecified);
+ ASET (lface, LFACE_FOREGROUND_INDEX,
+ (STRINGP (new_value) ? new_value : Qunspecified));
realize_basic_faces (f);
}
else if (EQ (param, Qbackground_color))
face = Qdefault;
lface = lface_from_face_name (f, face, 1);
- LFACE_BACKGROUND (lface) = (STRINGP (new_value)
- ? new_value : Qunspecified);
+ ASET (lface, LFACE_BACKGROUND_INDEX,
+ (STRINGP (new_value) ? new_value : Qunspecified));
realize_basic_faces (f);
}
#ifdef HAVE_WINDOW_SYSTEM
{
face = Qborder;
lface = lface_from_face_name (f, face, 1);
- LFACE_BACKGROUND (lface) = (STRINGP (new_value)
- ? new_value : Qunspecified);
+ ASET (lface, LFACE_BACKGROUND_INDEX,
+ (STRINGP (new_value) ? new_value : Qunspecified));
}
else if (EQ (param, Qcursor_color))
{
face = Qcursor;
lface = lface_from_face_name (f, face, 1);
- LFACE_BACKGROUND (lface) = (STRINGP (new_value)
- ? new_value : Qunspecified);
+ ASET (lface, LFACE_BACKGROUND_INDEX,
+ (STRINGP (new_value) ? new_value : Qunspecified));
}
else if (EQ (param, Qmouse_color))
{
face = Qmouse;
lface = lface_from_face_name (f, face, 1);
- LFACE_BACKGROUND (lface) = (STRINGP (new_value)
- ? new_value : Qunspecified);
+ ASET (lface, LFACE_BACKGROUND_INDEX,
+ (STRINGP (new_value) ? new_value : Qunspecified));
}
#endif
font = font_load_for_lface (f, XVECTOR (lface)->contents, font);
if (NILP (font))
return;
- LFACE_FONT (lface) = font;
+ ASET (lface, LFACE_FONT_INDEX, font);
}
f->default_face_done_p = 0;
Fmodify_frame_parameters (frame, Fcons (Fcons (Qfont, font), Qnil));
XSETFONT (font_object, FRAME_FONT (f));
set_lface_from_font (f, lface, font_object, f->default_face_done_p);
- LFACE_FONTSET (lface) = fontset_name (FRAME_FONTSET (f));
+ ASET (lface, LFACE_FONTSET_INDEX, fontset_name (FRAME_FONTSET (f)));
f->default_face_done_p = 1;
}
#endif /* HAVE_WINDOW_SYSTEM */
if (!FRAME_WINDOW_P (f))
{
- LFACE_FAMILY (lface) = build_string ("default");
- LFACE_FOUNDRY (lface) = LFACE_FAMILY (lface);
- LFACE_SWIDTH (lface) = Qnormal;
- LFACE_HEIGHT (lface) = make_number (1);
+ ASET (lface, LFACE_FAMILY_INDEX, build_string ("default"));
+ ASET (lface, LFACE_FOUNDRY_INDEX, LFACE_FAMILY (lface));
+ ASET (lface, LFACE_SWIDTH_INDEX, Qnormal);
+ ASET (lface, LFACE_HEIGHT_INDEX, make_number (1));
if (UNSPECIFIEDP (LFACE_WEIGHT (lface)))
- LFACE_WEIGHT (lface) = Qnormal;
+ ASET (lface, LFACE_WEIGHT_INDEX, Qnormal);
if (UNSPECIFIEDP (LFACE_SLANT (lface)))
- LFACE_SLANT (lface) = Qnormal;
+ ASET (lface, LFACE_SLANT_INDEX, Qnormal);
if (UNSPECIFIEDP (LFACE_FONTSET (lface)))
- LFACE_FONTSET (lface) = Qnil;
+ ASET (lface, LFACE_FONTSET_INDEX, Qnil);
}
if (UNSPECIFIEDP (LFACE_UNDERLINE (lface)))
- LFACE_UNDERLINE (lface) = Qnil;
+ ASET (lface, LFACE_UNDERLINE_INDEX, Qnil);
if (UNSPECIFIEDP (LFACE_OVERLINE (lface)))
- LFACE_OVERLINE (lface) = Qnil;
+ ASET (lface, LFACE_OVERLINE_INDEX, Qnil);
if (UNSPECIFIEDP (LFACE_STRIKE_THROUGH (lface)))
- LFACE_STRIKE_THROUGH (lface) = Qnil;
+ ASET (lface, LFACE_STRIKE_THROUGH_INDEX, Qnil);
if (UNSPECIFIEDP (LFACE_BOX (lface)))
- LFACE_BOX (lface) = Qnil;
+ ASET (lface, LFACE_BOX_INDEX, Qnil);
if (UNSPECIFIEDP (LFACE_INVERSE (lface)))
- LFACE_INVERSE (lface) = Qnil;
+ ASET (lface, LFACE_INVERSE_INDEX, Qnil);
if (UNSPECIFIEDP (LFACE_FOREGROUND (lface)))
{
Lisp_Object color = Fassq (Qforeground_color, FVAR (f, param_alist));
if (CONSP (color) && STRINGP (XCDR (color)))
- LFACE_FOREGROUND (lface) = XCDR (color);
+ ASET (lface, LFACE_FOREGROUND_INDEX, XCDR (color));
else if (FRAME_WINDOW_P (f))
return 0;
else if (FRAME_INITIAL_P (f) || FRAME_TERMCAP_P (f) || FRAME_MSDOS_P (f))
- LFACE_FOREGROUND (lface) = build_string (unspecified_fg);
+ ASET (lface, LFACE_FOREGROUND_INDEX, build_string (unspecified_fg));
else
abort ();
}
set in the frame parameter list. */
Lisp_Object color = Fassq (Qbackground_color, FVAR (f, param_alist));
if (CONSP (color) && STRINGP (XCDR (color)))
- LFACE_BACKGROUND (lface) = XCDR (color);
+ ASET (lface, LFACE_BACKGROUND_INDEX, XCDR (color));
else if (FRAME_WINDOW_P (f))
return 0;
else if (FRAME_INITIAL_P (f) || FRAME_TERMCAP_P (f) || FRAME_MSDOS_P (f))
- LFACE_BACKGROUND (lface) = build_string (unspecified_bg);
+ ASET (lface, LFACE_BACKGROUND_INDEX, build_string (unspecified_bg));
else
abort ();
}
if (UNSPECIFIEDP (LFACE_STIPPLE (lface)))
- LFACE_STIPPLE (lface) = Qnil;
+ ASET (lface, LFACE_STIPPLE_INDEX, Qnil);
/* Realize the face; it must be fully-specified now. */
eassert (lface_fully_specified_p (XVECTOR (lface)->contents));
list = Fcons (entity, list);
continue;
}
- if (memcmp (props, &(AREF (entity, FONT_FOUNDRY_INDEX)),
+ if (memcmp (props, aref_addr (entity, FONT_FOUNDRY_INDEX),
sizeof (Lisp_Object) * 7)
|| ! EQ (AREF (entity, FONT_SPACING_INDEX), props[7]))
{
- memcpy (props, &(AREF (entity, FONT_FOUNDRY_INDEX)),
+ memcpy (props, aref_addr (entity, FONT_FOUNDRY_INDEX),
sizeof (Lisp_Object) * 7);
props[7] = AREF (entity, FONT_SPACING_INDEX);
scripts = xfont_supported_scripts (display, indices[i],
/* If this item has a null value,
make the call_data null so that it won't display a box
when the mouse is on it. */
- wv->call_data
- = (!NILP (def) ? (void *) &AREF (menu_items, i) : 0);
+ wv->call_data = !NILP (def) ? aref_addr (menu_items, i) : 0;
wv->enabled = !NILP (enable);
if (NILP (type))
{
entry
= AREF (menu_items, i + MENU_ITEMS_ITEM_VALUE);
- if (menu_item_selection == &AREF (menu_items, i))
+ if (menu_item_selection == aref_addr (menu_items, i))
{
if (keymaps != 0)
{
if (!NILP (descrip))
wv->key = SSDATA (descrip);
wv->value = SSDATA (item_name);
- wv->call_data = (void *) &AREF (menu_items, i);
+ wv->call_data = aref_addr (menu_items, i);
wv->enabled = !NILP (enable);
wv->help = Qnil;
prev_wv = wv;
{
entry
= AREF (menu_items, i + MENU_ITEMS_ITEM_VALUE);
- if (menu_item_selection == &AREF (menu_items, i))
+ if (menu_item_selection == aref_addr (menu_items, i))
{
if (keymaps != 0)
{