Commits

Michele Bini committed 97bbcef

Renamed 'contents' in lisp_vector to 'lisp_vector_contents'; AREF is not an lvalue anymore; using ASET and AREF as much as possible.

Comments (0)

Files changed (40)

 /* Handy constants for vectorlike objects.  */
 enum
   {
-    header_size = offsetof (struct Lisp_Vector, contents),
+    header_size = offsetof (struct Lisp_Vector, lisp_vector_contents),
     word_size = sizeof (Lisp_Object)
   };
 
 
   /* Only the first lisplen slots will be traced normally by the GC.  */
   for (i = 0; i < lisplen; ++i)
-    v->contents[i] = Qnil;
+    v->lisp_vector_contents[i] = Qnil;
 
   v->header.size_and_gcgroup = ARRAY_GC_UNMARK(0);
   XSETPVECTYPESIZE (v, tag, lisplen);
 
   p = allocate_vector (sizei);
   for (i = 0; i < sizei; i++)
-    p->contents[i] = init;
+    p->lisp_vector_contents[i] = init;
 
   XSETVECTOR (vector, p);
   return vector;
   val = Fmake_vector (len, Qnil);
   p = XVECTOR (val);
   for (i = 0; i < nargs; i++)
-    p->contents[i] = args[i];
+    p->lisp_vector_contents[i] = args[i];
   return val;
 }
 
     {
       if (!NILP (Vpurify_flag))
 	args[i] = Fpurecopy (args[i]);
-      p->contents[i] = args[i];
+      p->lisp_vector_contents[i] = args[i];
     }
   XSETPVECTYPE (p, PVEC_COMPILED);
   XSETCOMPILED (val, p);
 {
   Lisp_Object new;
   struct Lisp_Vector *p;
-  size_t size = (offsetof (struct Lisp_Vector, contents)
+  size_t size = (offsetof (struct Lisp_Vector, lisp_vector_contents)
 		 + len * sizeof (Lisp_Object));
 
   p = (struct Lisp_Vector *) pure_alloc (size, Lisp_Vectorlike);
       size_proper = SIZE_NOGC(size_field);
       vec = XVECTOR (make_pure_vector (size_proper));
       for (i = 0; i < size_proper; i++)
-	vec->contents[i] = Fpurecopy (XVECTOR (obj)->contents[i]);
+	vec->lisp_vector_contents[i] = Fpurecopy (XVECTOR (obj)->lisp_vector_contents[i]);
       if (COMPILEDP (obj))
 	{
 	  XSETPVECTYPE (vec, PVEC_COMPILED);
      non-Lisp_Object fields at the end of the structure.  */
   size = SIZE_NOGC(size_and_gcgroup);
   for (i = 0; i < size; i++) /* and then mark its elements */
-    mark_object (ptr->contents[i]);
+    mark_object (ptr->lisp_vector_contents[i]);
 }
 
 /* Like mark_vectorlike but optimized for char-tables (and
   VECTOR_MARK (ptr);
   for (i = 0; i < size; i++)
     {
-      Lisp_Object val = ptr->contents[i];
+      Lisp_Object val = ptr->lisp_vector_contents[i];
 
       if (INTEGERP (val) || (SYMBOLP (val) && (XSYMBOL (val)->gcgroupbit == marked_gcgroup)))
 	continue;
 	  for (i = 0; i < size; i++) /* and then mark its elements */
 	    {
 	      if (i != COMPILED_CONSTANTS)
-		mark_object (ptr->contents[i]);
+		mark_object (ptr->lisp_vector_contents[i]);
 	    }
-	  obj = ptr->contents[COMPILED_CONSTANTS];
+	  obj = ptr->lisp_vector_contents[COMPILED_CONSTANTS];
 	  goto loop;
 	}
       else if (FRAMEP (obj))
     Lisp_Object *copy = (Lisp_Object *) alloca (size * sizeof (Lisp_Object));
     int i;
 
-    memcpy (copy, XVECTOR (last_overlay_modification_hooks)->contents,
+    memcpy (copy, XVECTOR (last_overlay_modification_hooks)->lisp_vector_contents,
 	    size * sizeof (Lisp_Object));
     gcpro1.var = copy;
     gcpro1.nvars = size;
 #ifdef BYTE_CODE_SAFE
   bytestr_length = SBYTES (bytestr);
 #endif
-  vectorp = XVECTOR (vector)->contents;
+  vectorp = XVECTOR (vector)->lisp_vector_contents;
 
   stack.byte_string = bytestr;
   stack.pc = stack.byte_string_start = SDATA (bytestr);
     error ("Category `%c' is already defined", (int) XFASTINT (category));
   if (!NILP (Vpurify_flag))
     docstring = Fpurecopy (docstring);
-  CATEGORY_DOCSTRING (table, XFASTINT (category)) = docstring;
+  SET_CATEGORY_DOCSTRING (table, XFASTINT (category), docstring);
 
   return Qnil;
 }
 
 /* Return the doc string of CATEGORY in category table TABLE.  */
 #define CATEGORY_DOCSTRING(table, category) \
-  XVECTOR (Fchar_table_extra_slot (table, make_number (0)))->contents[(category) - ' ']
+  AREF(Fchar_table_extra_slot (table, make_number (0)), (category) - ' ')
+#define SET_CATEGORY_DOCSTRING(table, category, v)			\
+  ASET(Fchar_table_extra_slot (table, make_number (0)), (category) - ' ', v)
 
 /* Return the version number of category table TABLE.  Not used for
    the moment.  */
 
 /* Return a hash table of id number ID.  */
 #define GET_HASH_TABLE(id) \
-  (XHASH_TABLE (XCDR (XVECTOR (Vtranslation_hash_table_vector)->contents[(id)])))
+  (XHASH_TABLE (XCDR (AREF(Vtranslation_hash_table_vector, (id)))))
 
 /* CCL (Code Conversion Language) is a simple language which has
    operations on one input buffer, one output buffer, and 7 registers.
 	    ccl_prog_stack_struct[stack_idx].ic = ic;
 	    ccl_prog_stack_struct[stack_idx].eof_ic = eof_ic;
 	    stack_idx++;
-	    ccl_prog = XVECTOR (AREF (slot, 1))->contents;
+	    ccl_prog = XVECTOR (AREF (slot, 1))->lisp_vector_contents;
 	    ic = CCL_HEADER_MAIN;
 	    eof_ic = XFASTINT (ccl_prog[CCL_HEADER_EOF]);
 	  }
 	return -1;
       vp = XVECTOR (ccl_prog);
       ccl->size = HEADERSIZE(vp);
-      ccl->prog = vp->contents;
-      ccl->eof_ic = XINT (vp->contents[CCL_HEADER_EOF]);
-      ccl->buf_magnification = XINT (vp->contents[CCL_HEADER_BUF_MAG]);
+      ccl->prog = vp->lisp_vector_contents;
+      ccl->eof_ic = XINT (vp->lisp_vector_contents[CCL_HEADER_EOF]);
+      ccl->buf_magnification = XINT (vp->lisp_vector_contents[CCL_HEADER_BUF_MAG]);
       if (ccl->idx >= 0)
 	{
 	  Lisp_Object slot;
 
 /* Return a translation table of id number ID.  */
 #define GET_TRANSLATION_TABLE(id) \
-  (XCDR(XVECTOR(Vtranslation_table_vector)->contents[(id)]))
+  (XCDR(AREF(Vtranslation_table_vector, (id))))
 
 #endif /* EMACS_CHARACTER_H */
 		{
 		  int n = CODE_POINT_TO_INDEX (charset, max_code) + 1;
 
-		  vec = CHARSET_DECODER (charset)
-		    = Fmake_vector (make_number (n), make_number (-1));
+		  vec =
+		    ASET(CHARSET_ATTRIBUTES (charset),
+			 charset_decoder,
+			 Fmake_vector (make_number (n), make_number (-1)));
 		}
 	      else
 		{
 	    {
 	      table = Fmake_char_table (Qnil, Qnil);
 	      if (charset->method == CHARSET_METHOD_MAP)
-		CHARSET_ENCODER (charset) = table;
+		ASET(CHARSET_ATTRIBUTES (charset),
+		     charset_encoder,
+		     table);
 	      else
-		CHARSET_DEUNIFIER (charset) = table;
+		ASET(CHARSET_ATTRIBUTES (charset),
+		     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;
+      HASH_SET_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;
+	  ASET(CHARSET_ATTRIBUTES(cs), charset_unify_map, unify_map);
 	}
       if (NILP (Vchar_unify_table))
 	Vchar_unify_table = Fmake_char_table (Qnil, Qnil);
 static Lisp_Object
 uniprop_encode_value_run_length (Lisp_Object table, Lisp_Object value)
 {
-  Lisp_Object *value_table = XVECTOR (XCHAR_TABLE (table)->extras[4])->contents;
+  Lisp_Object *value_table = XVECTOR (XCHAR_TABLE (table)->extras[4])->lisp_vector_contents;
   int i, size = ASIZE_NOGC (XCHAR_TABLE (table)->extras[4]);
 
   for (i = 0; i < size; i++)
 static Lisp_Object
 uniprop_encode_value_numeric (Lisp_Object table, Lisp_Object value)
 {
-  Lisp_Object *value_table = XVECTOR (XCHAR_TABLE (table)->extras[4])->contents;
+  Lisp_Object *value_table = XVECTOR (XCHAR_TABLE (table)->extras[4])->lisp_vector_contents;
   int i, size = ASIZE_NOGC (XCHAR_TABLE (table)->extras[4]);
 
   CHECK_NUMBER (value);
   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;
+      SET_CODING_ATTR_CHARSET_LIST (attrs, charset_list = Vemacs_mule_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;
+      SET_CODING_ATTR_CHARSET_LIST (attrs, charset_list = Viso_2022_charset_list);
       ASET (attrs, coding_attr_safe_charsets, Qnil);
     }
 
 	    break;
 	check_extra_latin:
 	  if (! VECTORP (Vlatin_extra_code_table)
-	      || NILP (XVECTOR (Vlatin_extra_code_table)->contents[c]))
+	      || NILP (AREF(Vlatin_extra_code_table, c)))
 	    {
 	      rejected = CATEGORY_MASK_ISO;
 	      break;
 	  if (c < 0xA0
 	      && check_latin_extra
 	      && (!VECTORP (Vlatin_extra_code_table)
-		  || NILP (XVECTOR (Vlatin_extra_code_table)->contents[c])))
+		  || NILP (AREF(Vlatin_extra_code_table, c))))
 	    break;
 	  found = CATEGORY_MASK_CHARSET;
 	}
 
   name = args[coding_arg_name];
   CHECK_SYMBOL (name);
-  CODING_ATTR_BASE_NAME (attrs) = name;
+  SET_CODING_ATTR_BASE_NAME (attrs, name);
 
   val = args[coding_arg_mnemonic];
   if (! STRINGP (val))
     CHECK_CHARACTER (val);
-  CODING_ATTR_MNEMONIC (attrs) = val;
+  SET_CODING_ATTR_MNEMONIC (attrs, val);
 
   coding_type = args[coding_arg_coding_type];
   CHECK_SYMBOL (coding_type);
-  CODING_ATTR_TYPE (attrs) = coding_type;
+  SET_CODING_ATTR_TYPE (attrs, 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;
+  SET_CODING_ATTR_CHARSET_LIST (attrs, 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;
+  SET_CODING_ATTR_SAFE_CHARSETS (attrs, safe_charsets);
 
-  CODING_ATTR_ASCII_COMPAT (attrs) = args[coding_arg_ascii_compatible_p];
+  SET_CODING_ATTR_ASCII_COMPAT (attrs, 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;
+  SET_CODING_ATTR_DECODE_TBL (attrs, val);
 
   val = args[coding_arg_encode_translation_table];
   if (! CHAR_TABLE_P (val) && ! CONSP (val))
     CHECK_SYMBOL (val);
-  CODING_ATTR_ENCODE_TBL (attrs) = val;
+  SET_CODING_ATTR_ENCODE_TBL (attrs, val);
 
   val = args[coding_arg_post_read_conversion];
   CHECK_SYMBOL (val);
-  CODING_ATTR_POST_READ (attrs) = val;
+  SET_CODING_ATTR_POST_READ (attrs, val);
 
   val = args[coding_arg_pre_write_conversion];
   CHECK_SYMBOL (val);
-  CODING_ATTR_PRE_WRITE (attrs) = val;
+  SET_CODING_ATTR_PRE_WRITE (attrs, val);
 
   val = args[coding_arg_default_char];
   if (NILP (val))
-    CODING_ATTR_DEFAULT_CHAR (attrs) = make_number (' ');
+    SET_CODING_ATTR_DEFAULT_CHAR (attrs, make_number (' '));
   else
     {
       CHECK_CHARACTER (val);
-      CODING_ATTR_DEFAULT_CHAR (attrs) = val;
+      SET_CODING_ATTR_DEFAULT_CHAR (attrs, val);
     }
 
   val = args[coding_arg_for_unibyte];
-  CODING_ATTR_FOR_UNIBYTE (attrs) = NILP (val) ? Qnil : Qt;
+  SET_CODING_ATTR_FOR_UNIBYTE (attrs, NILP (val) ? Qnil : Qt);
 
   val = args[coding_arg_plist];
   CHECK_LIST (val);
-  CODING_ATTR_PLIST (attrs) = val;
+  SET_CODING_ATTR_PLIST (attrs, val);
 
   if (EQ (coding_type, Qcharset))
     {
 	  int idx = (dim - 1) * 4;
 
 	  if (CHARSET_ASCII_COMPATIBLE_P (charset))
-	    CODING_ATTR_ASCII_COMPAT (attrs) = Qt;
+	    SET_CODING_ATTR_ASCII_COMPAT (attrs, Qt);
 
 	  for (i = charset->code_space[idx];
 	       i <= charset->code_space[idx + 1]; i++)
     {
       Lisp_Object bom, endian;
 
-      CODING_ATTR_ASCII_COMPAT (attrs) = Qnil;
+      SET_CODING_ATTR_ASCII_COMPAT (attrs, 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;
+		SET_CODING_ATTR_ASCII_COMPAT (attrs, 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;
+	SET_CODING_ATTR_ASCII_COMPAT (attrs, 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;
+      SET_CODING_ATTR_ASCII_COMPAT (attrs, 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;
+	SET_CODING_ATTR_ASCII_COMPAT (attrs, 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;
+	SET_CODING_ATTR_ASCII_COMPAT (attrs, 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;
+      SET_CODING_ATTR_ASCII_COMPAT (attrs, Qt);
     }
   else if (EQ (coding_type, Qutf_8))
     {
 	}
       ASET (attrs, coding_attr_utf_bom, bom);
       if (NILP (bom))
-	CODING_ATTR_ASCII_COMPAT (attrs) = Qt;
+	SET_CODING_ATTR_ASCII_COMPAT (attrs, 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)));
+  SET_CODING_ATTR_CATEGORY (attrs, make_number (category));
+  SET_CODING_ATTR_PLIST
+    (attrs,
+     Fcons (QCcategory,
+	    Fcons (AREF (Vcoding_category_table, category),
+		   CODING_ATTR_PLIST (attrs))));
+  SET_CODING_ATTR_PLIST
+    (attrs,
+     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;
+      SET_CODING_ATTR_MNEMONIC (attrs, val);
     }
   else if (EQ (prop, QCdefault_char))
     {
 	val = make_number (' ');
       else
 	CHECK_CHARACTER (val);
-      CODING_ATTR_DEFAULT_CHAR (attrs) = val;
+      SET_CODING_ATTR_DEFAULT_CHAR (attrs, val);
     }
   else if (EQ (prop, QCdecode_translation_table))
     {
       if (! CHAR_TABLE_P (val) && ! CONSP (val))
 	CHECK_SYMBOL (val);
-      CODING_ATTR_DECODE_TBL (attrs) = val;
+      SET_CODING_ATTR_DECODE_TBL (attrs, val);
     }
   else if (EQ (prop, QCencode_translation_table))
     {
       if (! CHAR_TABLE_P (val) && ! CONSP (val))
 	CHECK_SYMBOL (val);
-      CODING_ATTR_ENCODE_TBL (attrs) = val;
+      SET_CODING_ATTR_ENCODE_TBL (attrs, val);
     }
   else if (EQ (prop, QCpost_read_conversion))
     {
       CHECK_SYMBOL (val);
-      CODING_ATTR_POST_READ (attrs) = val;
+      SET_CODING_ATTR_POST_READ (attrs, val);
     }
   else if (EQ (prop, QCpre_write_conversion))
     {
       CHECK_SYMBOL (val);
-      CODING_ATTR_PRE_WRITE (attrs) = val;
+      SET_CODING_ATTR_PRE_WRITE (attrs, val);
     }
   else if (EQ (prop, QCascii_compatible_p))
     {
-      CODING_ATTR_ASCII_COMPAT (attrs) = val;
+      SET_CODING_ATTR_ASCII_COMPAT (attrs, val);
     }
 
-  CODING_ATTR_PLIST (attrs)
-    = Fplist_put (CODING_ATTR_PLIST (attrs), prop, val);
+  SET_CODING_ATTR_PLIST
+    (attrs,
+     Fplist_put (CODING_ATTR_PLIST (attrs), prop, val));
   return val;
 }
 
     Vcoding_category_list = Qnil;
     for (i = coding_category_max - 1; i >= 0; i--)
       Vcoding_category_list
-	= Fcons (XVECTOR (Vcoding_category_table)->contents[i],
+	= Fcons (AREF(Vcoding_category_table, i),
 		 Vcoding_category_list);
   }
 
 #define CODING_ATTR_CATEGORY(attrs)	AREF (attrs, coding_attr_category)
 #define CODING_ATTR_SAFE_CHARSETS(attrs)AREF (attrs, coding_attr_safe_charsets)
 
+#define SET_CODING_ATTR_BASE_NAME(attrs, x)	ASET (attrs, coding_attr_base_name,      x)
+#define SET_CODING_ATTR_TYPE(attrs, x)		ASET (attrs, coding_attr_type, 		 x)
+#define SET_CODING_ATTR_CHARSET_LIST(attrs, x)	ASET (attrs, coding_attr_charset_list,   x)
+#define SET_CODING_ATTR_MNEMONIC(attrs, x)	ASET (attrs, coding_attr_mnemonic,       x)
+#define SET_CODING_ATTR_DOCSTRING(attrs, x)	ASET (attrs, coding_attr_docstring,      x)
+#define SET_CODING_ATTR_ASCII_COMPAT(attrs, x)	ASET (attrs, coding_attr_ascii_compat,   x)
+#define SET_CODING_ATTR_DECODE_TBL(attrs, x)	ASET (attrs, coding_attr_decode_tbl,     x)
+#define SET_CODING_ATTR_ENCODE_TBL(attrs, x)	ASET (attrs, coding_attr_encode_tbl,     x)
+#define SET_CODING_ATTR_TRANS_TBL(attrs, x)	ASET (attrs, coding_attr_trans_tbl,      x)
+#define SET_CODING_ATTR_POST_READ(attrs, x)	ASET (attrs, coding_attr_post_read,      x)
+#define SET_CODING_ATTR_PRE_WRITE(attrs, x)	ASET (attrs, coding_attr_pre_write,      x)
+#define SET_CODING_ATTR_DEFAULT_CHAR(attrs, x)	ASET (attrs, coding_attr_default_char,   x)
+#define SET_CODING_ATTR_FOR_UNIBYTE(attrs, x)	ASET (attrs, coding_attr_for_unibyte,    x)
+#define SET_CODING_ATTR_FLUSHING(attrs, x)	ASET (attrs, coding_attr_flushing,       x)
+#define SET_CODING_ATTR_PLIST(attrs, x)	        ASET (attrs, coding_attr_plist, 	 x)
+#define SET_CODING_ATTR_CATEGORY(attrs, x)	ASET (attrs, coding_attr_category,       x)
+#define SET_CODING_ATTR_SAFE_CHARSETS(attrs, x) ASET (attrs, coding_attr_safe_charsets,  x)
+
 
 /* Return the name of a coding system specified by ID.  */
 #define CODING_ID_NAME(id) \
 	for (i = 0; i < nchars; i++)
 	  {
 	    FETCH_STRING_CHAR_ADVANCE (ch, string, charpos, bytepos);
-	    XVECTOR (key)->contents[i] = make_number (ch);
+	    ASET(key, i, make_number (ch));
 	  }
       else
 	for (i = 0; i < nchars; i++)
 	  {
 	    FETCH_CHAR_ADVANCE (ch, charpos, bytepos);
-	    XVECTOR (key)->contents[i] = make_number (ch);
+	    ASET(key, i, make_number (ch));
 	  }
     }
   else
     composition_table = xpalloc (composition_table, &composition_table_size,
 				 1, -1, sizeof *composition_table);
 
-  key_contents = XVECTOR (key)->contents;
+  key_contents = XVECTOR (key)->lisp_vector_contents;
 
   /* Check if the contents of COMPONENTS are valid if COMPONENTS is a
      vector or a list.  It should be a sequence of:
 composition_gstring_width (Lisp_Object gstring, EMACS_INT from, EMACS_INT to,
 			   struct font_metrics *metrics)
 {
-  Lisp_Object *glyph;
+  Lisp_Object glyph;
   int width = 0;
 
   if (metrics)
 	}
       metrics->width = metrics->lbearing = metrics->rbearing = 0;
     }
-  for (glyph = &LGSTRING_GLYPH (gstring, from); from < to; from++, glyph++)
+  for (; from < to; from++)
     {
       int x;
-
-      if (NILP (LGLYPH_ADJUSTMENT (*glyph)))
-	width += LGLYPH_WIDTH (*glyph);
+      glyph = LGSTRING_GLYPH (gstring, from);
+	
+      if (NILP (LGLYPH_ADJUSTMENT (glyph)))
+	width += LGLYPH_WIDTH (glyph);
       else
-	width += LGLYPH_WADJUST (*glyph);
+	width += LGLYPH_WADJUST (glyph);
       if (metrics)
 	{
-	  x = metrics->width + LGLYPH_LBEARING (*glyph) + LGLYPH_XOFF (*glyph);
+	  x = metrics->width + LGLYPH_LBEARING (glyph) + LGLYPH_XOFF (glyph);
 	  if (metrics->lbearing > x)
 	    metrics->lbearing = x;
-	  x = metrics->width + LGLYPH_RBEARING (*glyph) + LGLYPH_XOFF (*glyph);
+	  x = metrics->width + LGLYPH_RBEARING (glyph) + LGLYPH_XOFF (glyph);
 	  if (metrics->rbearing < x)
 	    metrics->rbearing = x;
 	  metrics->width = width;
-	  x = LGLYPH_ASCENT (*glyph) - LGLYPH_YOFF (*glyph);
+	  x = LGLYPH_ASCENT (glyph) - LGLYPH_YOFF (glyph);
 	  if (metrics->ascent < x)
 	    metrics->ascent = x;
-	  x = LGLYPH_DESCENT (*glyph) + LGLYPH_YOFF (*glyph);
+	  x = LGLYPH_DESCENT (glyph) + LGLYPH_YOFF (glyph);
 	  if (metrics->descent < x)
 	    metrics->descent = x;
 	}
 #define COMPOSITION_GLYPH(cmp, n)					\
   XINT (XVECTOR (XVECTOR (XHASH_TABLE (composition_hash_table)		\
 			  ->key_and_value)				\
-		 ->contents[cmp->hash_index * 2])			\
-	->contents[cmp->method == COMPOSITION_WITH_RULE_ALTCHARS	\
+		 ->lisp_vector_contents[cmp->hash_index * 2])			\
+	->lisp_vector_contents[cmp->method == COMPOSITION_WITH_RULE_ALTCHARS	\
 		  ? (n) * 2 : (n)])
 
 /* Return the encoded composition rule to compose the Nth glyph of
 #define COMPOSITION_RULE(cmp, n)				\
   XINT (XVECTOR (XVECTOR (XHASH_TABLE (composition_hash_table)	\
 			  ->key_and_value)			\
-		 ->contents[cmp->hash_index * 2])		\
-	->contents[(n) * 2 - 1])
+		 ->lisp_vector_contents[cmp->hash_index * 2])		\
+	->lisp_vector_contents[(n) * 2 - 1])
 
 /* Decode encoded composition rule RULE_CODE into GREF (global
    reference point code), NREF (new ref. point code).  Don't check RULE_CODE;
     {
       if (idxval < 0 || idxval >= ASIZE_NOGC (array))
 	args_out_of_range (array, idx);
-      XVECTOR (array)->contents[idxval] = newelt;
+      ASET(array, idxval, newelt);
     }
   else if (BOOL_VECTOR_P (array))
     {
   else
     state = frame_and_buffer_state;
 
-  vecp = XVECTOR (state)->contents;
+  vecp = XVECTOR (state)->lisp_vector_contents;
   end = vecp + ASIZE_NOGC (state);
 
   FOR_EACH_FRAME (tail, frame)
     }
 
   /* Record the new data in the (possibly reallocated) vector.  */
-  vecp = XVECTOR (state)->contents;
+  vecp = XVECTOR (state)->lisp_vector_contents;
   FOR_EACH_FRAME (tail, frame)
     {
       *vecp++ = frame;
     }
   /* Fill up the vector with lambdas (always at least one).  */
   *vecp++ = Qlambda;
-  while (vecp - XVECTOR (state)->contents
+  while (vecp - XVECTOR (state)->lisp_vector_contents
 	 < ASIZE_NOGC (state))
     *vecp++ = Qlambda;
   /* Make sure we didn't overflow the vector.  */
-  if (vecp - XVECTOR (state)->contents
+  if (vecp - XVECTOR (state)->lisp_vector_contents
       > ASIZE_NOGC (state))
     abort ();
   return Qt;
     if (f->output_method == output_termcap)
       create_tty_output (f);
 #endif
-    t->display_info.tty->top_frame = selected_frame;
+    {
+      Lisp_Object l;
+      XSETTTYDISPLAYINFO(l, t->display_info.tty);
+      XSETTDITOPFRAME(l, selected_frame);
+    }
     change_frame_size (XFRAME (selected_frame),
                        FrameRows (t->display_info.tty),
                        FrameCols (t->display_info.tty), 0, 0, 1);
 /* Return the current base (for indexing) of the GLYPH table,
    or 0 if the table isn't currently valid.  */
 #define GLYPH_TABLE_BASE  \
-  ((VECTORP (Vglyph_table)) ? XVECTOR (Vglyph_table)->contents : 0)
+  ((VECTORP (Vglyph_table)) ? XVECTOR (Vglyph_table)->lisp_vector_contents : 0)
 
 /* Given BASE and LEN returned by the two previous macros,
    return nonzero if the GLYPH code G should be output as a single
 			    string, make_number (0), res, Qnil);
     }
   else
-    res = Fvector (to_char - from_char, &AREF (string, from_char));
+    res = Fvector (to_char - from_char, &AREF__LVALUE (string, from_char));
 
   return res;
 }
 			    string, make_number (0), res, Qnil);
     }
   else
-    res = Fvector (to - from, &AREF (string, from));
+    res = Fvector (to - from, &AREF__LVALUE (string, from));
 
   return res;
 }
 
 	  for (i = n = 0; i < ASIZE_NOGC (seq); ++i)
 	    if (NILP (Fequal (AREF (seq, i), elt)))
-	      p->contents[n++] = AREF (seq, i);
+	      p->lisp_vector_contents[n++] = AREF (seq, i);
 
 	  XSETVECTOR (seq, p);
 	}
 
   if (VECTORP (array))
     {
-      register Lisp_Object *p = XVECTOR (array)->contents;
+      register Lisp_Object *p = XVECTOR (array)->lisp_vector_contents;
       size = ASIZE_NOGC (array);
       for (idx = 0; idx < size; idx++)
 	p[idx] = item;
   xassert (new_size >= old_size);
 
   v = allocate_vector (new_size);
-  memcpy (v->contents, XVECTOR (vec)->contents, old_size * sizeof *v->contents);
+  memcpy (v->lisp_vector_contents, XVECTOR (vec)->lisp_vector_contents, old_size * sizeof *v->lisp_vector_contents);
   for (i = old_size; i < new_size; ++i)
-    v->contents[i] = init;
+    v->lisp_vector_contents[i] = init;
   XSETVECTOR (vec, v);
   return vec;
 }
 
   /* Set up the free list.  */
   for (i = 0; i < sz - 1; ++i)
-    HASH_NEXT (h, i) = make_number (i + 1);
+    HASH_SET_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);
+	HASH_SET_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);
+	  HASH_SET_NEXT (h, XFASTINT (last), make_number (old_size));
 	}
       else
 	XSETFASTINT (h->next_free, old_size);
 	  {
 	    EMACS_UINT hash_code = XUINT (HASH_HASH (h, i));
 	    EMACS_INT start_of_bucket = hash_code % ASIZE_NOGC (h->index);
-	    HASH_NEXT (h, i) = HASH_INDEX (h, start_of_bucket);
-	    HASH_INDEX (h, start_of_bucket) = make_number (i);
+	    HASH_SET_NEXT (h, i, HASH_INDEX (h, start_of_bucket));
+	    HASH_SET_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;
+  HASH_SET_KEY    (h, i, key);
+  HASH_SET_VALUE  (h, i, value);
 
   /* Remember its hash code.  */
-  HASH_HASH (h, i) = make_number (hash);
+  HASH_SET_HASH (h, i, make_number (hash));
 
   /* Add new entry to its collision chain.  */
   start_of_bucket = hash % ASIZE_NOGC (h->index);
-  HASH_NEXT (h, i) = HASH_INDEX (h, start_of_bucket);
-  HASH_INDEX (h, start_of_bucket) = make_number (i);
+  HASH_SET_NEXT (h, i, HASH_INDEX (h, start_of_bucket));
+  HASH_SET_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);
+	    HASH_SET_INDEX (h, start_of_bucket, HASH_NEXT (h, i));
 	  else
-	    HASH_NEXT (h, XFASTINT (prev)) = HASH_NEXT (h, i);
+	    HASH_SET_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;
+	  HASH_SET_KEY (h, i, HASH_SET_VALUE (h, i, HASH_SET_HASH (h, i, Qnil)));
+	  HASH_SET_NEXT (h, i, h->next_free);
 	  h->next_free = make_number (i);
 	  h->count--;
 	  xassert (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;
+	  HASH_SET_NEXT (h, i, i < size - 1 ? make_number (i + 1) : Qnil);
+	  HASH_SET_KEY (h, i, Qnil);
+	  HASH_SET_VALUE (h, i, Qnil);
+	  HASH_SET_HASH (h, i, Qnil);
 	}
 
       for (i = 0; i < ASIZE_NOGC (h->index); ++i)
 		{
 		  /* Take out of collision chain.  */
 		  if (NILP (prev))
-		    HASH_INDEX (h, bucket) = next;
+		    HASH_SET_INDEX (h, bucket, next);
 		  else
-		    HASH_NEXT (h, XFASTINT (prev)) = next;
+		    HASH_SET_NEXT (h, XFASTINT (prev), next);
 
 		  /* Add to free list.  */
-		  HASH_NEXT (h, i) = h->next_free;
+		  HASH_SET_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;
+		  HASH_SET_KEY (h, i, HASH_SET_VALUE (h, i, Qnil));
+		  HASH_SET_HASH (h, i, Qnil);
 
 		  h->count--;
 		}
 
   i = hash_lookup (h, key, &hash);
   if (i >= 0)
-    HASH_VALUE (h, i) = value;
+    HASH_SET_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__LVALUE (object, XFASTINT (from)));
     }
 
   vec = Fmake_vector (make_number (len), Qnil);
   font = XFONT_OBJECT (font_object);
 
   info = Fmake_vector (make_number (7), Qnil);
-  XVECTOR (info)->contents[0] = AREF (font_object, FONT_NAME_INDEX);
-  XVECTOR (info)->contents[1] = AREF (font_object, FONT_FULLNAME_INDEX);
-  XVECTOR (info)->contents[2] = make_number (font->pixel_size);
-  XVECTOR (info)->contents[3] = make_number (font->height);
-  XVECTOR (info)->contents[4] = make_number (font->baseline_offset);
-  XVECTOR (info)->contents[5] = make_number (font->relative_compose);
-  XVECTOR (info)->contents[6] = make_number (font->default_ascent);
+  ASET(info, 0, AREF (font_object, FONT_NAME_INDEX));
+  ASET(info, 1, AREF (font_object, FONT_FULLNAME_INDEX));
+  ASET(info, 2, make_number (font->pixel_size));
+  ASET(info, 3, make_number (font->height));
+  ASET(info, 4, make_number (font->baseline_offset));
+  ASET(info, 5, make_number (font->relative_compose));
+  ASET(info, 6, make_number (font->default_ascent));
 
 #if 0
   /* As font_object is still in FONT_OBJLIST of the entity, we can't
     }
 
   if (score_changed)
-    qsort (XVECTOR (vec)->contents, size, sizeof (Lisp_Object),
+    qsort (XVECTOR (vec)->lisp_vector_contents, size, sizeof (Lisp_Object),
 	   fontset_compare_rfontdef);
   XSETCAR (font_group, make_number (charset_ordered_list_tick));
 }
   FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_none;
   FRAME_MENU_BAR_LINES(f) = NILP (Vmenu_bar_mode) ? 0 : 1;
 
-  /* Set the top frame to the newly created frame. */
-  if (FRAMEP (FRAME_TTY (f)->top_frame)
-      && FRAME_LIVE_P (XFRAME (FRAME_TTY (f)->top_frame)))
-    XFRAME (FRAME_TTY (f)->top_frame)->async_visible = 2; /* obscured */
-
-  FRAME_TTY (f)->top_frame = frame;
+  {
+    Lisp_Object tty;
+    XSETTTYDISPLAYINFO(tty, FRAME_TTY (f));
+    
+    /* Set the top frame to the newly created frame. */
+    {
+      Lisp_Object top_frame = XTDITOPFRAME(tty);
+      if (FRAMEP (top_frame)
+	  &&
+	  FRAME_LIVE_P (XFRAME(top_frame))) {
+	XFRAME (top_frame)->async_visible = 2; /* obscured */
+      }
+    }
+    
+    XSETTDITOPFRAME(tty, frame);
+  }
 
   if (!noninteractive)
     init_frame_faces (f);
 
   if (FRAME_TERMCAP_P (XFRAME (frame)) || FRAME_MSDOS_P (XFRAME (frame)))
     {
-      if (FRAMEP (FRAME_TTY (XFRAME (frame))->top_frame))
+      Lisp_Object tty;
+      Lisp_Object top_frame;
+      XSETTTYDISPLAYINFO(tty, FRAME_TTY (XFRAME (frame)));
+      top_frame = XTDITOPFRAME(tty);
+      if (FRAMEP (top_frame))
 	/* Mark previously displayed frame as now obscured.  */
-	XFRAME (FRAME_TTY (XFRAME (frame))->top_frame)->async_visible = 2;
+	XFRAME (top_frame)->async_visible = 2;
       XFRAME (frame)->async_visible = 1;
-      FRAME_TTY (XFRAME (frame))->top_frame = frame;
+      XSETTDITOPFRAME(tty, frame);
     }
 
   selected_frame = frame;
 #define XMENUCBDATA(a) ((xg_menu_cb_data *)XPNTR_OR_NULL(a))
 #define XSETMENUCBDATA(a, b) XSETPSEUDOVECTOR(a, b, PVEC_OTHER)
 
-  Lisp_Object   next, prev;
-#define XMENUCBNEXT(cbdata) AREF(cbdata, 0)
-#define XSETMENUCBNEXT(cbdata, x) ASET(cbdata, 0, x)
-#define XMENUCBPREV(cbdata) AREF(cbdata, 1)
-#define XSETMENUCBPREV(cbdata, x) ASET(cbdata, 1, x)
+  Lisp_Object   ___next, ___prev;
+#define XMENUCBNEXT(cbdata)           AREF(cbdata, PSEUDOVECSIZE(xg_menu_cb_data, ___next))
+#define XSETMENUCBNEXT(cbdata, x)     ASET(cbdata, PSEUDOVECSIZE(xg_menu_cb_data, ___next), x)
+#define XMENUCBPREV(cbdata)           AREF(cbdata, PSEUDOVECSIZE(xg_menu_cb_data, ___prev))
+#define XSETMENUCBPREV(cbdata, x)     ASET(cbdata, PSEUDOVECSIZE(xg_menu_cb_data, ___prev), x)
+
   Lisp_Object   ___menu_bar_vector;
-#define XMENUBARVECTOR(cbdata) AREF(cbdata, 2)
-#define XSETMENUBARVECTOR(cbdata, x) ASET(cbdata, 2, x)
+#define XMENUBARVECTOR(cbdata)        AREF(cbdata, PSEUDOVECSIZE(xg_menu_cb_data, ___menu_bar_vector))
+#define XSETMENUBARVECTOR(cbdata, x)  ASET(cbdata, PSEUDOVECSIZE(xg_menu_cb_data, ___menu_bar_vector), x)
 
 #define ALLOCATE_MENUCBDATA()				\
   ALLOCATE_PSEUDOVECTOR(xg_menu_cb_data,		\
 
   Lisp_Object   next, prev;
   Lisp_Object   ___help;
-#define XMENUITEMHELP(cbdata) AREF(cbdata, 2)
-#define XSETMENUITEMHELP(cbdata, x) ASET(cbdata, 2, x)
+#define XMENUITEMHELP(cbdata)        AREF(cbdata, PSEUDOVECSIZE(xg_menu_item_cb_data, ___help))
+#define XSETMENUITEMHELP(cbdata, x)  ASET(cbdata, PSEUDOVECSIZE(xg_menu_item_cb_data, ___help), x)
   Lisp_Object   ___menu;
-#define XMENUITEMMENU(cbdata) AREF(cbdata, 3)
-#define XSETMENUITEMMENU(cbdata, x) ASET(cbdata, 3, x)
+#define XMENUITEMMENU(cbdata)        AREF(cbdata, PSEUDOVECSIZE(xg_menu_item_cb_data, ___menu))
+#define XSETMENUITEMMENU(cbdata, x)  ASET(cbdata, PSEUDOVECSIZE(xg_menu_item_cb_data, ___menu), x)
 
 #define ALLOCATE_MENUITEMCBDATA()			\
   ALLOCATE_PSEUDOVECTOR(xg_menu_item_cb_data,		\
 	     for one line of the image.  */
 	  for (i = 0; i < height; ++i)
 	    {
-	      Lisp_Object elt = XVECTOR (data)->contents[i];
+	      Lisp_Object elt = AREF(data, i);
 
 	      if (STRINGP (elt))
 		{
 	      p = bits = (char *) alloca (nbytes * img->height);
 	      for (i = 0; i < img->height; ++i, p += nbytes)
 		{
-		  Lisp_Object line = XVECTOR (data)->contents[i];
+		  Lisp_Object line = AREF(data, i);
 		  if (STRINGP (line))
 		    memcpy (p, SDATA (line), nbytes);
 		  else
       if (ASIZE_NOGC (tem) != 4)
 	return 0;
       for (i = 0; i < 4; ++i)
-	if (!INTEGERP (XVECTOR (tem)->contents[i]))
+	if (!INTEGERP (AREF(tem, i)))
 	  return 0;
     }
   else
    invalidate the buffer's width_run_cache.  */
 
 int
-disptab_matches_widthtab (struct Lisp_Char_Table *disptab, struct Lisp_Vector *widthtab)
+disptab_matches_widthtab (struct Lisp_Char_Table *disptab, Lisp_Object widthtab)
 {
   int i;
 
-  if (HEADERSIZE(widthtab) != 256)
+  if (ASIZE_NOGC(widthtab) != 256)
     abort ();
 
   for (i = 0; i < 256; i++)
     if (character_width (i, disptab)
-        != XFASTINT (widthtab->contents[i]))
+        != XFASTINT (AREF(widthtab, i)))
       return 0;
 
   return 1;
 recompute_width_table (struct buffer *buf, struct Lisp_Char_Table *disptab)
 {
   int i;
-  struct Lisp_Vector *widthtab;
+  Lisp_Object widthtab;
 
   if (!VECTORP (BVAR (buf, width_table)))
     BVAR (buf, width_table) = Fmake_vector (make_number (256), make_number (0));
-  widthtab = XVECTOR (BVAR (buf, width_table));
-  if (HEADERSIZE(widthtab) != 256)
+  widthtab = BVAR (buf, width_table);
+  if (ASIZE_NOGC(widthtab) != 256)
     abort ();
 
-  for (i = 0; i < 256; i++)
-    XSETFASTINT (widthtab->contents[i], character_width (i, disptab));
+  for (i = 0; i < 256; i++) {
+    Lisp_Object v;
+    XSETFASTINT (v, character_width (i, disptab));
+    ASET(widthtab, i, v);
+  }
 }
 
 /* Allocate or free the width run cache, as requested by the current
   EMACS_INT width_run_start = from;
   EMACS_INT width_run_end   = from;
   EMACS_INT width_run_width = 0;
-  Lisp_Object *width_table;
+  Lisp_Object width_table;
   Lisp_Object buffer;
 
   /* The next buffer pos where we should consult the width run cache. */
   width_run_cache_on_off ();
   if (dp == buffer_display_table ())
     width_table = (VECTORP (BVAR (current_buffer, width_table))
-                   ? XVECTOR (BVAR (current_buffer, width_table))->contents
-                   : 0);
+                   ? BVAR (current_buffer, width_table)
+                   : Qnil);
   else
     /* If the window has its own display table, we can't use the width
        run cache, because that's based on the buffer's display table.  */
-    width_table = 0;
+    width_table = Qnil;
 
   /* Negative width means use all available text columns.  */
   if (width < 0)
 	      /* Is this character part of the current run?  If so, extend
 		 the run.  */
 	      if (pos - 1 == width_run_end
-		  && XFASTINT (width_table[c]) == width_run_width)
+		  && XFASTINT (AREF(width_table, c)) == width_run_width)
 		width_run_end = pos;
 
 	      /* The previous run is over, since this is a character at a
 				       width_run_start, width_run_end);
 
 		  /* Start recording a new width run.  */
-		  width_run_width = XFASTINT (width_table[c]);
+		  width_run_width = XFASTINT (AREF(width_table, c));
 		  width_run_start = pos - 1;
 		  width_run_end = pos;
 		}
    for characters as WIDTHTAB.  We use this to decide when to
    invalidate the buffer's column_cache.  */
 int disptab_matches_widthtab (struct Lisp_Char_Table *disptab,
-                              struct Lisp_Vector *widthtab);
+                              Lisp_Object widthtab);
 
 /* Recompute BUF's width table, using the display table DISPTAB.  */
 void recompute_width_table (struct buffer *buf,
 	  if (i == this_single_command_key_start)
 	    before_command_echo_length = echo_length ();
 
-	  c = XVECTOR (this_command_keys)->contents[i];
+	  c = AREF(this_command_keys, i);
 	  if (! (EVENT_HAS_PARAMETERS (c)
 		 && EQ (EVENT_HEAD_KIND (EVENT_HEAD (c)), Qmouse_movement)))
 	    echo_char (c);
 
       if (!VECTORP (timer) || ASIZE_NOGC (timer) != 8)
 	continue;
-      XVECTOR (timer)->contents[0] = Qnil;
+      ASET(timer, 0, Qnil);
     }
 }
 
 	      timers = XCDR (timers);
 	      continue;
 	    }
-	  vector = XVECTOR (timer)->contents;
+	  vector = XVECTOR (timer)->lisp_vector_contents;
 
 	  if (!INTEGERP (vector[1]) || !INTEGERP (vector[2])
 	      || !INTEGERP (vector[3])
 	      idle_timers = XCDR (idle_timers);
 	      continue;
 	    }
-	  vector = XVECTOR (timer)->contents;
+	  vector = XVECTOR (timer)->lisp_vector_contents;
 
 	  if (!INTEGERP (vector[1]) || !INTEGERP (vector[2])
 	      || !INTEGERP (vector[3])
       if (CONSP (timers))
 	{
 	  timer = XCAR (timers);
-	  vector = XVECTOR (timer)->contents;
+	  vector = XVECTOR (timer)->lisp_vector_contents;
 	  EMACS_SET_SECS (timer_time,
 			  (XINT (vector[1]) << 16) | (XINT (vector[2])));
 	  EMACS_SET_USECS (timer_time, XINT (vector[3]));
       if (CONSP (idle_timers))
 	{
 	  idle_timer = XCAR (idle_timers);
-	  vector = XVECTOR (idle_timer)->contents;
+	  vector = XVECTOR (idle_timer)->lisp_vector_contents;
 	  EMACS_SET_SECS (idle_timer_time,
 			  (XINT (vector[1]) << 16) | (XINT (vector[2])));
 	  EMACS_SET_USECS (idle_timer_time, XINT (vector[3]));
 	  idle_timers = XCDR (idle_timers);
 	  difference = idle_timer_difference;
 	}
-      vector = XVECTOR (chosen_timer)->contents;
+      vector = XVECTOR (chosen_timer)->lisp_vector_contents;
 
       /* If timer is ripe, run it if it hasn't been run.  */
       if (EMACS_TIME_NEG_P (difference)
 	int button = event->code;
 	int is_double;
 	Lisp_Object position;
-	Lisp_Object *start_pos_ptr;
 	Lisp_Object start_pos;
 
 	position = Qnil;
 	    mouse_syms = larger_vector (mouse_syms, button + 1, Qnil);
 	  }
 
-	start_pos_ptr = &AREF (button_down_location, button);
-	start_pos = *start_pos_ptr;
-	*start_pos_ptr = Qnil;
+	start_pos = AREF (button_down_location, button);
+	ASET (button_down_location, button, Qnil);
 
 	{
 	  /* On window-system frames, use the value of
 	    else
 	      double_click_count = 1;
 	    button_down_time = event->timestamp;
-	    *start_pos_ptr = Fcopy_alist (position);
+	    ASET (button_down_location, button, Fcopy_alist (position));
 	    ignore_mouse_drag_p = 0;
 	  }
 
   modifier_list = Qnil;
   for (i = 0; (1<<i) <= modifiers && i < NUM_MOD_NAMES; i++)
     if (modifiers & (1<<i))
-      modifier_list = Fcons (XVECTOR (modifier_symbols)->contents[i],
+      modifier_list = Fcons (AREF(modifier_symbols, i),
 			     modifier_list);
 
   return modifier_list;
 	  *symbol_table = Fmake_vector (size, Qnil);
 	}
 
-      value = XVECTOR (*symbol_table)->contents[symbol_num];
+      value = AREF(*symbol_table, symbol_num);
     }
 
   /* Have we already used this symbol before?  */
       if (CONSP (*symbol_table))
         *symbol_table = Fcons (Fcons (symbol_int, value), *symbol_table);
       else
-	XVECTOR (*symbol_table)->contents[symbol_num] = value;
+	ASET(*symbol_table, symbol_num, value);
 
       /* Fill in the cache entries for this symbol; this also
 	 builds the Qevent_symbol_elements property, which the user
 	(ASCII_CHAR_P (event_buf.code)
 	 ? ASCII_KEYSTROKE_EVENT : MULTIBYTE_CHAR_KEYSTROKE_EVENT);
       /* See the comment in tty_read_avail_input.  */
-      event_buf.frame_or_window = tty->top_frame;
+      {
+	Lisp_Object tty_l;
+	XSETTTYDISPLAYINFO(tty_l, tty);
+	event_buf.frame_or_window = XTDITOPFRAME(tty_l);
+      }
       event_buf.arg = Qnil;
       kbd_buffer_store_event (&event_buf);
     }
 	    buf.modifiers = meta_modifier;
 	    buf.code = cbuf[i] & ~0x80;
 	    /* See the comment below.  */
-	    buf.frame_or_window = tty->top_frame;
+	    {
+	      Lisp_Object tty_l;
+	      XSETTTYDISPLAYINFO(tty_l, tty);
+	      buf.frame_or_window = XTDITOPFRAME(tty_l);
+	    }
 	    buf.arg = Qnil;
 	    kbd_buffer_store_event (&buf);
 	    from = i + 1;
       /* Set the frame corresponding to the active tty.  Note that the
          value of selected_frame is not reliable here, redisplay tends
          to temporarily change it.  */
-      buf.frame_or_window = tty->top_frame;
+      {
+	Lisp_Object tty_l;
+	XSETTTYDISPLAYINFO(tty_l, tty);
+	buf.frame_or_window = XTDITOPFRAME(tty_l);
+      }
       buf.arg = Qnil;
 
       kbd_buffer_store_event (&buf);
       int end = menu_bar_items_index;
 
       for (i = 0; i < end; i += 4)
-	if (EQ (XCAR (tail), XVECTOR (menu_bar_items_vector)->contents[i]))
+	if (EQ (XCAR (tail), AREF(menu_bar_items_vector, i)))
 	  {
 	    Lisp_Object tem0, tem1, tem2, tem3;
 	    /* Move the item at index I to the end,
 	       shifting all the others forward.  */
-	    tem0 = XVECTOR (menu_bar_items_vector)->contents[i + 0];
-	    tem1 = XVECTOR (menu_bar_items_vector)->contents[i + 1];
-	    tem2 = XVECTOR (menu_bar_items_vector)->contents[i + 2];
-	    tem3 = XVECTOR (menu_bar_items_vector)->contents[i + 3];
+	    tem0 = AREF(menu_bar_items_vector, i + 0);
+	    tem1 = AREF(menu_bar_items_vector, i + 1);
+	    tem2 = AREF(menu_bar_items_vector, i + 2);
+	    tem3 = AREF(menu_bar_items_vector, i + 3);
 	    if (end > i + 4)
-	      memmove (&XVECTOR (menu_bar_items_vector)->contents[i],
-		       &XVECTOR (menu_bar_items_vector)->contents[i + 4],
+	      memmove (&AREF__LVALUE(menu_bar_items_vector, i),
+		       &AREF__LVALUE(menu_bar_items_vector, i + 4),
 		       (end - i - 4) * sizeof (Lisp_Object));
-	    XVECTOR (menu_bar_items_vector)->contents[end - 4] = tem0;
-	    XVECTOR (menu_bar_items_vector)->contents[end - 3] = tem1;
-	    XVECTOR (menu_bar_items_vector)->contents[end - 2] = tem2;
-	    XVECTOR (menu_bar_items_vector)->contents[end - 1] = tem3;
+	    ASET(menu_bar_items_vector, end - 4, tem0);
+	    ASET(menu_bar_items_vector, end - 3, tem1);
+	    ASET(menu_bar_items_vector, end - 2, tem2);
+	    ASET(menu_bar_items_vector, end - 1, tem3);
 	    break;
 	  }
     }
       menu_bar_items_vector =
 	larger_vector (menu_bar_items_vector, 2 * i, Qnil);
     /* Add this item.  */
-    XVECTOR (menu_bar_items_vector)->contents[i++] = Qnil;
-    XVECTOR (menu_bar_items_vector)->contents[i++] = Qnil;
-    XVECTOR (menu_bar_items_vector)->contents[i++] = Qnil;
-    XVECTOR (menu_bar_items_vector)->contents[i++] = Qnil;
+    ASET(menu_bar_items_vector, i++, Qnil);
+    ASET(menu_bar_items_vector, i++, Qnil);
+    ASET(menu_bar_items_vector, i++, Qnil);
+    ASET(menu_bar_items_vector, i++, Qnil);
     menu_bar_items_index = i;
   }
 
 	 discard any previously made menu bar item.  */
 
       for (i = 0; i < menu_bar_items_index; i += 4)
-	if (EQ (key, XVECTOR (menu_bar_items_vector)->contents[i]))
+	if (EQ (key, AREF(menu_bar_items_vector, i)))
 	  {
 	    if (menu_bar_items_index > i + 4)
-	      memmove (&XVECTOR (menu_bar_items_vector)->contents[i],
-		       &XVECTOR (menu_bar_items_vector)->contents[i + 4],
+	      memmove (&AREF__LVALUE(menu_bar_items_vector, i),
+		       &AREF__LVALUE(menu_bar_items_vector, i + 4),
 		       (menu_bar_items_index - i - 4) * sizeof (Lisp_Object));
 	    menu_bar_items_index -= 4;
 	  }
   if (!i)
     return;
 
-  item = XVECTOR (item_properties)->contents[ITEM_PROPERTY_DEF];
+  item = AREF(item_properties, ITEM_PROPERTY_DEF);
 
   /* Find any existing item for this KEY.  */
   for (i = 0; i < menu_bar_items_index; i += 4)
-    if (EQ (key, XVECTOR (menu_bar_items_vector)->contents[i]))
+    if (EQ (key, AREF(menu_bar_items_vector, i)))
       break;
 
   /* If we did not find this KEY, add it at the end.  */
       if (i + 4 > ASIZE_NOGC (menu_bar_items_vector))
 	menu_bar_items_vector = larger_vector (menu_bar_items_vector, 2 * i, Qnil);
       /* Add this item.  */
-      XVECTOR (menu_bar_items_vector)->contents[i++] = key;
-      XVECTOR (menu_bar_items_vector)->contents[i++]
-	= XVECTOR (item_properties)->contents[ITEM_PROPERTY_NAME];
-      XVECTOR (menu_bar_items_vector)->contents[i++] = Fcons (item, Qnil);
-      XVECTOR (menu_bar_items_vector)->contents[i++] = make_number (0);
+      ASET(menu_bar_items_vector, i++, key);
+      ASET(menu_bar_items_vector, i++,
+	   AREF(item_properties, ITEM_PROPERTY_NAME));
+      ASET(menu_bar_items_vector, i++, Fcons (item, Qnil));
+      ASET(menu_bar_items_vector, i++, make_number (0));
       menu_bar_items_index = i;
     }
   /* We did find an item for this KEY.  Add ITEM to its list of maps.  */
   else
     {
       Lisp_Object old;
-      old = XVECTOR (menu_bar_items_vector)->contents[i + 2];
+      old = AREF(menu_bar_items_vector, i + 2);
       /* If the new and the old items are not both keymaps,
 	 the lookup will only find `item'.  */
       item = Fcons (item, KEYMAPP (item) && KEYMAPP (XCAR (old)) ? old : Qnil);
-      XVECTOR (menu_bar_items_vector)->contents[i + 2] = item;
+      ASET(menu_bar_items_vector, i + 2, item);
     }
 }
 
   }
 
   /* Include this when menu help is implemented.
-  tem = XVECTOR (item_properties)->contents[ITEM_PROPERTY_HELP];
+  tem = AREF(item_properties, ITEM_PROPERTY_HELP);
   if (!(NILP (tem) || STRINGP (tem)))
     {
       tem = menu_item_eval_property (tem);
       if (!STRINGP (tem))
 	tem = Qnil;
-      XVECTOR (item_properties)->contents[ITEM_PROPERTY_HELP] = tem;
+      ASET(item_properties, ITEM_PROPERTY_HELP, tem);
     }
   */
 
 	 discard any previously made item.  */
       for (i = 0; i < ntool_bar_items; i += TOOL_BAR_ITEM_NSLOTS)
 	{
-	  Lisp_Object *v = XVECTOR (tool_bar_items_vector)->contents + i;
+	  Lisp_Object *v = XVECTOR (tool_bar_items_vector)->lisp_vector_contents + i;
 
 	  if (EQ (key, v[TOOL_BAR_ITEM_KEY]))
 	    {
 parse_tool_bar_item (Lisp_Object key, Lisp_Object item)
 {
   /* Access slot with index IDX of vector tool_bar_item_properties.  */
-#define PROP(IDX) XVECTOR (tool_bar_item_properties)->contents[IDX]
+#define PROP(IDX) AREF(tool_bar_item_properties, IDX)
+#define SET_PROP(IDX, V) ASET(tool_bar_item_properties, IDX, V)
 
   Lisp_Object filter = Qnil;
   Lisp_Object caption;
   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.  */
-	  PROP (TOOL_BAR_ITEM_IMAGES)
-	    = menu_item_eval_property (Vtool_bar_separator_image_expression);
-	  PROP (TOOL_BAR_ITEM_ENABLED_P) = Qnil;
-	  PROP (TOOL_BAR_ITEM_SELECTED_P) = Qnil;
-	  PROP (TOOL_BAR_ITEM_CAPTION) = Qnil;
+	  SET_PROP (TOOL_BAR_ITEM_IMAGES, menu_item_eval_property (Vtool_bar_separator_image_expression));
+	  SET_PROP (TOOL_BAR_ITEM_ENABLED_P, Qnil);
+	  SET_PROP (TOOL_BAR_ITEM_SELECTED_P,  Qnil);
+	  SET_PROP (TOOL_BAR_ITEM_CAPTION, Qnil);
 #endif
 	  return 1;
 	}
     }
 
   /* 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_NOGC (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) = make_string ("", 0);
+        SET_PROP (TOOL_BAR_ITEM_LABEL, make_string ("", 0));
       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;
 
 
   /* Append entries from tool_bar_item_properties to the end of
      tool_bar_items_vector.  */
-  to = XVECTOR (tool_bar_items_vector)->contents + ntool_bar_items;
-  from = XVECTOR (tool_bar_item_properties)->contents;
+  to = XVECTOR (tool_bar_items_vector)->lisp_vector_contents + ntool_bar_items;
+  from = XVECTOR (tool_bar_item_properties)->lisp_vector_contents;
   memcpy (to, from, TOOL_BAR_ITEM_NSLOTS * sizeof *to);
   ntool_bar_items += TOOL_BAR_ITEM_NSLOTS;
 }
 
 	  /* Look at the next element of the map.  */
 	  if (idx >= 0)
-	    elt = XVECTOR (vector)->contents[idx];
+	    elt = AREF(vector, idx);
 	  else
 	    elt = Fcar_safe (rest);
 
 		  Lisp_Object upcased_event, downcased_event;
 		  Lisp_Object desc = Qnil;
 		  Lisp_Object s
-		    = XVECTOR (item_properties)->contents[ITEM_PROPERTY_NAME];
+		    = AREF(item_properties, ITEM_PROPERTY_NAME);
 
 		  upcased_event = Fupcase (event);
 		  downcased_event = Fdowncase (event);
 #if 0  /* It is redundant to list the equivalent key bindings because
 	  the prefix is what the user has already typed.  */
 		  tem
-		    = XVECTOR (item_properties)->contents[ITEM_PROPERTY_KEYEQ];
+		    = AREF(item_properties, ITEM_PROPERTY_KEYEQ);
 		  if (!NILP (tem))
 		    /* Insert equivalent keybinding.  */
 		    s = concat2 (s, tem);
 #endif
 		  tem
-		    = XVECTOR (item_properties)->contents[ITEM_PROPERTY_TYPE];
+		    = AREF(item_properties, ITEM_PROPERTY_TYPE);
 		  if (EQ (tem, QCradio) || EQ (tem, QCtoggle))
 		    {
 		      /* Insert button prefix.  */
 		      Lisp_Object selected
-			= XVECTOR (item_properties)->contents[ITEM_PROPERTY_SELECTED];
+			= AREF(item_properties, ITEM_PROPERTY_SELECTED);
 		      if (EQ (tem, QCradio))
 			tem = build_string (NILP (selected) ? "(*) " : "( ) ");
 		      else
 	      && current_buffer != starting_buffer)
 	    {
 	      GROW_RAW_KEYBUF;
-	      XVECTOR (raw_keybuf)->contents[raw_keybuf_count++] = key;
+	      ASET(raw_keybuf, raw_keybuf_count++, key);
 	      keybuf[t++] = key;
 	      mock_input = t;
 	      Vquit_flag = Qnil;
 		      && BUFFERP (XWINDOW (window)->buffer)
 		      && XBUFFER (XWINDOW (window)->buffer) != current_buffer)
 		    {
-		      XVECTOR (raw_keybuf)->contents[raw_keybuf_count++] = key;
+		      ASET(raw_keybuf, raw_keybuf_count++, key);
 		      keybuf[t] = key;
 		      mock_input = t + 1;
 
 #endif
 
   saved_keys = Fvector (this_command_key_count,
-			XVECTOR (this_command_keys)->contents);
+			XVECTOR (this_command_keys)->lisp_vector_contents);
   saved_last_point_position_buffer = last_point_position_buffer;
   saved_last_point_position = last_point_position;
   GCPRO3 (saved_keys, prefixarg, saved_last_point_position_buffer);
     this_command_key_count_reset = 0;
     this_single_command_key_start = 0;
 
-    keys = XVECTOR (saved_keys)->contents;
+    keys = XVECTOR (saved_keys)->lisp_vector_contents;
     for (i = 0; i < ASIZE_NOGC (saved_keys); i++)
       add_command_key (keys[i]);
 
        doc: /* Return vector of last 300 events, not counting those from keyboard macros.  */)
   (void)
 {
-  Lisp_Object *keys = XVECTOR (recent_keys)->contents;
+  Lisp_Object *keys = XVECTOR (recent_keys)->lisp_vector_contents;
   Lisp_Object val;
 
   if (total_keys < NUM_RECENT_KEYS)
   else
     {
       val = Fvector (NUM_RECENT_KEYS, keys);
-      memcpy (XVECTOR (val)->contents, keys + recent_keys_index,
+      memcpy (XVECTOR (val)->lisp_vector_contents,
+	      keys + recent_keys_index,
 	      (NUM_RECENT_KEYS - recent_keys_index) * sizeof (Lisp_Object));
-      memcpy (XVECTOR (val)->contents + NUM_RECENT_KEYS - recent_keys_index,
+      memcpy (XVECTOR (val)->lisp_vector_contents + NUM_RECENT_KEYS - recent_keys_index,
 	      keys, recent_keys_index * sizeof (Lisp_Object));
       return val;
     }
   (void)
 {
   return make_event_array (this_command_key_count,
-			   XVECTOR (this_command_keys)->contents);
+			   XVECTOR (this_command_keys)->lisp_vector_contents);
 }
 
 DEFUN ("this-command-keys-vector", Fthis_command_keys_vector, Sthis_command_keys_vector, 0, 0, 0,
   (void)
 {
   return Fvector (this_command_key_count,
-		  XVECTOR (this_command_keys)->contents);
+		  XVECTOR (this_command_keys)->lisp_vector_contents);
 }
 
 DEFUN ("this-single-command-keys", Fthis_single_command_keys,
 {
   return Fvector (this_command_key_count
 		  - this_single_command_key_start,
-		  (XVECTOR (this_command_keys)->contents
+		  (XVECTOR (this_command_keys)->lisp_vector_contents
 		   + this_single_command_key_start));
 }
 
   (void)
 {
   return Fvector (raw_keybuf_count,
-		  (XVECTOR (raw_keybuf)->contents));
+		  (XVECTOR (raw_keybuf)->lisp_vector_contents));
 }
 
 DEFUN ("reset-this-command-lengths", Freset_this_command_lengths,
   if (NILP (keep_record))
     {
       for (i = 0; i < ASIZE_NOGC (recent_keys); ++i)
-	XVECTOR (recent_keys)->contents[i] = Qnil;
+	ASET(recent_keys, i, Qnil);
       total_keys = 0;
       recent_keys_index = 0;
     }
          controlling tty, if we have a frame there.  We disable the
          interrupt key on secondary ttys, so the SIGINT must have come
          from the controlling tty.  */
-      internal_last_event_frame = terminal->display_info.tty->top_frame;
+      {
+	Lisp_Object tty_l;
+	XSETTTYDISPLAYINFO(tty_l, terminal->display_info.tty);
+	internal_last_event_frame = XTDITOPFRAME(tty_l);
+      }
 
       handle_interrupt ();
     }
     modifier_symbols = Fmake_vector (make_number (len), Qnil);
     for (i = 0; i < len; i++)
       if (modifier_names[i])
-	XVECTOR (modifier_symbols)->contents[i] = intern_c_string (modifier_names[i]);
+	ASET(modifier_symbols, i, intern_c_string (modifier_names[i]));
     staticpro (&modifier_symbols);
   }
 
 
 /* Convenience macros for dealing with Lisp arrays.  */
 
-#define AREF(ARRAY, IDX)	XVECTOR ((ARRAY))->contents[IDX]
-#define ASIZE_FIELD(ARRAY)		XVECTOR ((ARRAY))->header.size_and_gcgroup
-#define ASIZE_NOGC(ARRAY) 			HEADERSIZE(XVECTOR ((ARRAY)))
+#define AREF__LVALUE(ARRAY, IDX) (XVECTOR ((ARRAY))->lisp_vector_contents[IDX])
+#define AREF(ARRAY, IDX)    LISP_MAKE_RVALUE(AREF__LVALUE(ARRAY, IDX))
+#define ASIZE_FIELD(ARRAY)  LISP_MAKE_RVALUE(XVECTOR ((ARRAY))->header.size_and_gcgroup)
+#define ASIZE_NOGC(ARRAY)   HEADERSIZE(XVECTOR ((ARRAY)))
 /* The IDX==IDX tries to detect when the macro argument is side-effecting.  */
 #define ASET(ARRAY, IDX, VAL)	\
   (eassert ((IDX) == (IDX)),				\
    eassert ((IDX) >= 0 && (IDX) < ASIZE_NOGC(ARRAY)),	\
-   AREF ((ARRAY), (IDX)) = (VAL))
+   AREF__LVALUE ((ARRAY), (IDX)) = (VAL))
 
 /* Convenience macros for dealing with Lisp strings.  */
 
 struct Lisp_Vector
   {
     struct vectorlike_header header;
-    Lisp_Object contents[1];
+    Lisp_Object lisp_vector_contents[1];
   };
 
 /* If a struct is made to look like a vector, this macro returns the length
    of the shortest vector that would hold that struct.  */
 #define VECSIZE(type) ((sizeof (type)					  \
-			- offsetof (struct Lisp_Vector, contents[0])      \
+			- offsetof (struct Lisp_Vector, lisp_vector_contents[0])      \
                         + sizeof (Lisp_Object) - 1) /* round up */	  \
 		       / sizeof (Lisp_Object))
 
    at the end and we need to compute the number of Lisp_Object fields (the
    ones that the GC needs to trace).  */
 #define PSEUDOVECSIZE(type, nonlispfield) \
-  ((offsetof (type, nonlispfield) - offsetof (struct Lisp_Vector, contents[0])) \
+  ((offsetof (type, nonlispfield) - offsetof (struct Lisp_Vector, lisp_vector_contents[0])) \
    / sizeof (Lisp_Object))
 
 /* A char-table is a kind of vectorlike, with contents are like a
 /* Value is the key part of entry IDX in hash table H.  */
 
 #define HASH_KEY(H, IDX)   AREF ((H)->key_and_value, 2 * (IDX))
+#define HASH_SET_KEY(H, IDX, V)   ASET ((H)->key_and_value, 2 * (IDX), (V))
 
 /* Value is the value part of entry IDX in hash table H.  */
 
 #define HASH_VALUE(H, IDX) AREF ((H)->key_and_value, 2 * (IDX) + 1)
+#define HASH_SET_VALUE(H, IDX, V) ASET ((H)->key_and_value, 2 * (IDX) + 1, (V))
 
 /* Value is the index of the next entry following the one at IDX
    in hash table H.  */
 
 #define HASH_NEXT(H, IDX)  AREF ((H)->next, (IDX))
+#define HASH_SET_NEXT(H, IDX, V)  ASET ((H)->next, (IDX), (V))
 
 /* Value is the hash code computed for entry IDX in hash table H.  */
 
 #define HASH_HASH(H, IDX)  AREF ((H)->hash, (IDX))
+#define HASH_SET_HASH(H, IDX, V)  ASET ((H)->hash, (IDX), (V))
 
 /* Value is the index of the element in hash table H that is the
    start of the collision list at index IDX in the index vector of H.  */
 
 #define HASH_INDEX(H, IDX)  AREF ((H)->index, (IDX))
+#define HASH_SET_INDEX(H, IDX, V)  ASET ((H)->index, (IDX), (V))
 
 /* Value is the size of hash table H.  */
 
 	  Lisp_Object tmp;
 	  tmp = read_vector (readcharfun, 1);
 	  return Fmake_byte_code (ASIZE_NOGC (tmp),
-				  XVECTOR (tmp)->contents);
+				  XVECTOR (tmp)->lisp_vector_contents);
 	}
       if (c == '(')
 	{
   vector = (read_pure ? make_pure_vector (XINT (len)) : Fmake_vector (len, Qnil));
 
   size = ASIZE_NOGC (vector);
-  ptr = XVECTOR (vector)->contents;
+  ptr = XVECTOR (vector)->lisp_vector_contents;
   for (i = 0; i < size; i++)
     {
       item = Fcar (tem);
       SET_SYMBOL_VAL (XSYMBOL (sym), sym);
     }
 
-  ptr = &XVECTOR (obarray)->contents[XINT (tem)];
+  ptr = &AREF__LVALUE(obarray, XINT (tem));
   if (SYMBOLP (*ptr))
     XSYMBOL (sym)->next = XSYMBOL (*ptr);
   else
 
   hash = oblookup_last_bucket_number;
 
-  if (EQ (XVECTOR (obarray)->contents[hash], tem))
+  if (EQ (AREF(obarray, hash), tem))
     {
       if (XSYMBOL (tem)->next)
-	XSETSYMBOL (XVECTOR (obarray)->contents[hash], XSYMBOL (tem)->next);
+	XSETSYMBOL (XVECTOR (obarray)->lisp_vector_contents[hash], XSYMBOL (tem)->next);
       else
-	XSETINT (XVECTOR (obarray)->contents[hash], 0);
+	XSETINT (XVECTOR (obarray)->lisp_vector_contents[hash], 0);
     }
   else
     {
       Lisp_Object tail, following;
 
-      for (tail = XVECTOR (obarray)->contents[hash];
+      for (tail = XVECTOR (obarray)->lisp_vector_contents[hash];
 	   XSYMBOL (tail)->next;
 	   tail = following)
 	{
       obsize = ASIZE_NOGC (obarray);
     }
   hash = hash_string (ptr, size_byte) % obsize;
-  bucket = XVECTOR (obarray)->contents[hash];
+  bucket = AREF(obarray, hash);
   oblookup_last_bucket_number = hash;
   if (EQ (bucket, make_number (0)))
     ;
   CHECK_VECTOR (obarray);
   for (i = ASIZE_NOGC (obarray) - 1; i >= 0; i--)
     {
-      tail = XVECTOR (obarray)->contents[i];
+      tail = AREF(obarray, i);
       if (SYMBOLP (tail))
 	while (1)
 	  {
   if (menu_items_used + 1 > menu_items_allocated)
     grow_menu_items ();
 
-  XVECTOR (menu_items)->contents[menu_items_used++] = Qnil;
+  ASET(menu_items, menu_items_used++, Qnil);
   menu_items_submenu_depth++;
 }
 
   if (menu_items_used + 1 > menu_items_allocated)
     grow_menu_items ();
 
-  XVECTOR (menu_items)->contents[menu_items_used++] = Qlambda;
+  ASET(menu_items, menu_items_used++, Qlambda);
   menu_items_submenu_depth--;
 }
 
   if (menu_items_used + 1 > menu_items_allocated)
     grow_menu_items ();
 
-  XVECTOR (menu_items)->contents[menu_items_used++] = Qquote;
+  ASET(menu_items, menu_items_used++, Qquote);
 }
 
 /* Start a new menu pane in menu_items.
 
   if (menu_items_submenu_depth == 0)
     menu_items_n_panes++;
-  XVECTOR (menu_items)->contents[menu_items_used++] = Qt;
-  XVECTOR (menu_items)->contents[menu_items_used++] = name;
-  XVECTOR (menu_items)->contents[menu_items_used++] = prefix_vec;
+  ASET (menu_items, menu_items_used++, Qt);
+  ASET (menu_items, menu_items_used++, name);
+  ASET (menu_items, menu_items_used++, prefix_vec);
 }
 
 /* Push one menu item into the current pane.  NAME is the string to
   if (!res)
     return;			/* Not a menu item.  */
 
-  map = XVECTOR (item_properties)->contents[ITEM_PROPERTY_MAP];
+  map = AREF(item_properties, ITEM_PROPERTY_MAP);
 
-  enabled = XVECTOR (item_properties)->contents[ITEM_PROPERTY_ENABLE];
-  item_string = XVECTOR (item_properties)->contents[ITEM_PROPERTY_NAME];
+  enabled = AREF(item_properties, ITEM_PROPERTY_ENABLE);
+  item_string = AREF(item_properties, ITEM_PROPERTY_NAME);
 
   if (!NILP (map) && SREF (item_string, 0) == '@')
     {
 #endif /* HAVE_X_WINDOWS || MSDOS */
 
   push_menu_item (item_string, enabled, key,
-		  XVECTOR (item_properties)->contents[ITEM_PROPERTY_DEF],
-		  XVECTOR (item_properties)->contents[ITEM_PROPERTY_KEYEQ],
-		  XVECTOR (item_properties)->contents[ITEM_PROPERTY_TYPE],
-		  XVECTOR (item_properties)->contents[ITEM_PROPERTY_SELECTED],
-		  XVECTOR (item_properties)->contents[ITEM_PROPERTY_HELP]);
+		  AREF(item_properties, ITEM_PROPERTY_DEF),
+		  AREF(item_properties, ITEM_PROPERTY_KEYEQ),
+		  AREF(item_properties, ITEM_PROPERTY_TYPE),
+		  AREF(item_properties, ITEM_PROPERTY_SELECTED),
+		  AREF(item_properties, ITEM_PROPERTY_HELP));
 
 #if defined (USE_X_TOOLKIT) || defined (USE_GTK) || defined (HAVE_NS) || defined (HAVE_NTGUI)
   /* Display a submenu using the toolkit.  */
   i = start;
   while (i < end)
     {
-      if (EQ (XVECTOR (menu_items)->contents[i], Qnil))
+      if (EQ (AREF(menu_items, i), Qnil))
 	{
 	  submenu_stack[submenu_depth++] = save_wv;
 	  save_wv = prev_wv;
 	  prev_wv = 0;
 	  i++;
 	}
-      else if (EQ (XVECTOR (menu_items)->contents[i], Qlambda))
+      else if (EQ (AREF(menu_items, i), Qlambda))
 	{
 	  prev_wv = save_wv;
 	  save_wv = submenu_stack[--submenu_depth];
 	  i++;
 	}
-      else if (EQ (XVECTOR (menu_items)->contents[i], Qt)
+      else if (EQ (AREF(menu_items, i), Qt)
 	       && submenu_depth != 0)
 	i += MENU_ITEMS_PANE_LENGTH;
       /* Ignore a nil in the item list.
 	 It's meaningful only for dialog boxes.  */
-      else if (EQ (XVECTOR (menu_items)->contents[i], Qquote))
+      else if (EQ (AREF(menu_items, i), Qquote))
 	i += 1;
-      else if (EQ (XVECTOR (menu_items)->contents[i], Qt))
+      else if (EQ (AREF(menu_items, i), Qt))
 	{
 	  /* Create a new pane.  */
 	  Lisp_Object pane_name;
 
 	  panes_seen++;
 
-	  pane_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_NAME];
+	  pane_name = AREF(menu_items, i + MENU_ITEMS_PANE_NAME);
 
 #ifdef HAVE_NTGUI
 	  if (STRINGP (pane_name))
 
   while (i < menu_bar_items_used)
     {
-      if (EQ (XVECTOR (vector)->contents[i], Qnil))
+      if (EQ (AREF(vector, i), Qnil))
 	{
 	  subprefix_stack[submenu_depth++] = prefix;
 	  prefix = entry;
 	  i++;
 	}
-      else if (EQ (XVECTOR (vector)->contents[i], Qlambda))
+      else if (EQ (AREF(vector, i), Qlambda))
 	{
 	  prefix = subprefix_stack[--submenu_depth];
 	  i++;
 	}
-      else if (EQ (XVECTOR (vector)->contents[i], Qt))
+      else if (EQ (AREF(vector, i), Qt))
 	{
-	  prefix = XVECTOR (vector)->contents[i + MENU_ITEMS_PANE_PREFIX];
+	  prefix = AREF(vector, i + MENU_ITEMS_PANE_PREFIX);
 	  i += MENU_ITEMS_PANE_LENGTH;
 	}
       else
 	{
-	  entry = XVECTOR (vector)->contents[i + MENU_ITEMS_ITEM_VALUE];
+	  entry = AREF(vector, i + MENU_ITEMS_ITEM_VALUE);
 	  /* Treat the pointer as an integer.  There's no problem
 	     as long as pointers have enough bits to hold small integers.  */
 	  if ((intptr_t) client_data == i)
     {
       collection = check_obarray (collection);
       obsize = ASIZE_NOGC (collection);
-      bucket = XVECTOR (collection)->contents[idx];
+      bucket = AREF(collection, idx);
     }
 
   while (1)
 	    break;
 	  else
 	    {
-	      bucket = XVECTOR (collection)->contents[idx];
+	      bucket = AREF(collection, idx);
 	      continue;
 	    }
 	}
     {
       collection = check_obarray (collection);
       obsize = ASIZE_NOGC (collection);
-      bucket = XVECTOR (collection)->contents[idx];
+      bucket = AREF(collection, idx);
     }