* lisp.h (struct Lisp_Buffer_Objfwd): Add a `slottype' field.
authorStefan Monnier <monnier@iro.umontreal.ca>
Wed, 21 Nov 2007 20:59:47 +0000 (20:59 +0000)
committerStefan Monnier <monnier@iro.umontreal.ca>
Wed, 21 Nov 2007 20:59:47 +0000 (20:59 +0000)
* data.c (store_symval_forwarding): Get type from buffer_objfwd.
Update call to buffer_slot_type_mismatch.
* buffer.h (buffer_local_types, PER_BUFFER_TYPE): Remove.
(buffer_slot_type_mismatch): Update.
* buffer.c (buffer_local_types): Remove.
(buffer_slot_type_mismatch): Get the symbol and type as arguments.
(defvar_per_buffer): Set the type in the buffer_objfwd.

src/ChangeLog
src/buffer.c
src/buffer.h
src/data.c
src/lisp.h

index 9f99493..8349b4d 100644 (file)
@@ -1,7 +1,18 @@
+2007-11-21  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * lisp.h (struct Lisp_Buffer_Objfwd): Add a `slottype' field.
+       * data.c (store_symval_forwarding): Get type from buffer_objfwd.
+       Update call to buffer_slot_type_mismatch.
+       * buffer.h (buffer_local_types, PER_BUFFER_TYPE): Remove.
+       (buffer_slot_type_mismatch): Update.
+       * buffer.c (buffer_local_types): Remove.
+       (buffer_slot_type_mismatch): Get the symbol and type as arguments.
+       (defvar_per_buffer): Set the type in the buffer_objfwd.
+
 2007-11-21  Jason Rumney  <jasonr@gnu.org>
 
-       * w32bdf.c (w32_init_bdf_font, w32_BDF_to_x_font): CreateFileMapping
-       returns NULL on failure.
+       * w32bdf.c (w32_init_bdf_font, w32_BDF_to_x_font):
+       CreateFileMapping returns NULL on failure.
 
 2007-11-21  Stefan Monnier  <monnier@iro.umontreal.ca>
 
index 045a22c..675992d 100644 (file)
@@ -99,17 +99,6 @@ DECL_ALIGN (struct buffer, buffer_local_symbols);
 /* A Lisp_Object pointer to the above, used for staticpro */
 static Lisp_Object Vbuffer_local_symbols;
 
-/* This structure holds the required types for the values in the
-   buffer-local slots.  If a slot contains Qnil, then the
-   corresponding buffer slot may contain a value of any type.  If a
-   slot contains an integer, then prospective values' tags must be
-   equal to that integer (except nil is always allowed).
-   When a tag does not match, the function
-   buffer_slot_type_mismatch will signal an error.
-
-   If a slot here contains -1, the corresponding variable is read-only.  */
-struct buffer buffer_local_types;
-
 /* Flags indicating which built-in buffer-local variables
    are permanent locals.  */
 static char buffer_permanent_local_flags[MAX_PER_BUFFER_VARS];
@@ -4402,13 +4391,13 @@ evaporate_overlays (pos)
    in the slot with offset OFFSET.  */
 
 void
-buffer_slot_type_mismatch (offset)
-     int offset;
+buffer_slot_type_mismatch (sym, type)
+     Lisp_Object sym;
+     int type;
 {
-  Lisp_Object sym;
   char *type_name;
 
-  switch (XINT (PER_BUFFER_TYPE (offset)))
+  switch (type)
     {
     case Lisp_Int:
       type_name = "integers";
@@ -4426,7 +4415,6 @@ buffer_slot_type_mismatch (offset)
       abort ();
     }
 
-  sym = PER_BUFFER_SYMBOL (offset);
   error ("Only %s should be stored in the buffer-local variable %s",
         type_name, SDATA (SYMBOL_NAME (sym)));
 }
@@ -5274,9 +5262,9 @@ defvar_per_buffer (namestring, address, type, doc)
 
   XMISCTYPE (val) = Lisp_Misc_Buffer_Objfwd;
   XBUFFER_OBJFWD (val)->offset = offset;
+  XBUFFER_OBJFWD (val)->slottype = type;
   SET_SYMBOL_VALUE (sym, val);
   PER_BUFFER_SYMBOL (offset) = sym;
-  PER_BUFFER_TYPE (offset) = type;
 
   if (PER_BUFFER_IDX (offset) == 0)
     /* Did a DEFVAR_PER_BUFFER without initializing the corresponding
index 37f499f..a308d20 100644 (file)
@@ -818,18 +818,6 @@ extern struct buffer buffer_local_flags;
    that don't have such names.  */
 
 extern struct buffer buffer_local_symbols;
-
-/* This structure holds the required types for the values in the
-   buffer-local slots.  If a slot contains Qnil, then the
-   corresponding buffer slot may contain a value of any type.  If a
-   slot contains an integer, then prospective values' tags must be
-   equal to that integer (except nil is always allowed).
-   When a tag does not match, the function
-   buffer_slot_type_mismatch will signal an error.
-
-   If a slot here contains -1, the corresponding variable is read-only.  */
-
-extern struct buffer buffer_local_types;
 \f
 extern void delete_all_overlays P_ ((struct buffer *));
 extern void reset_buffer P_ ((struct buffer *));
@@ -843,7 +831,7 @@ extern void set_buffer_internal P_ ((struct buffer *));
 extern void set_buffer_internal_1 P_ ((struct buffer *));
 extern void set_buffer_temp P_ ((struct buffer *));
 extern void record_buffer P_ ((Lisp_Object));
-extern void buffer_slot_type_mismatch P_ ((int)) NO_RETURN;
+extern void buffer_slot_type_mismatch P_ ((Lisp_Object, int)) NO_RETURN;
 extern void fix_overlays_before P_ ((struct buffer *, EMACS_INT, EMACS_INT));
 extern void mmap_set_vars P_ ((int));
 
@@ -995,11 +983,5 @@ extern int last_per_buffer_idx;
 #define PER_BUFFER_SYMBOL(OFFSET) \
       (*(Lisp_Object *)((OFFSET) + (char *) &buffer_local_symbols))
 
-/* Return the type of the per-buffer variable at offset OFFSET in the
-   buffer structure.  */
-
-#define PER_BUFFER_TYPE(OFFSET) \
-      (*(Lisp_Object *)((OFFSET) + (char *) &buffer_local_types))
-
 /* arch-tag: 679305dd-d41c-4a50-b170-3caf5c97b2d1
    (do not change this comment) */
index 2ee84f0..4a63eb7 100644 (file)
@@ -930,7 +930,7 @@ store_symval_forwarding (symbol, valcontents, newval, buf)
          break;
 
        case Lisp_Misc_Boolfwd:
-         *XBOOLFWD (valcontents)->boolvar = NILP (newval) ? 0 : 1;
+         *XBOOLFWD (valcontents)->boolvar = !NILP (newval);
          break;
 
        case Lisp_Misc_Objfwd:
@@ -970,12 +970,11 @@ store_symval_forwarding (symbol, valcontents, newval, buf)
        case Lisp_Misc_Buffer_Objfwd:
          {
            int offset = XBUFFER_OBJFWD (valcontents)->offset;
-           Lisp_Object type;
+           Lisp_Object type = XBUFFER_OBJFWD (valcontents)->slottype;
 
-           type = PER_BUFFER_TYPE (offset);
            if (! NILP (type) && ! NILP (newval)
                && XTYPE (newval) != XINT (type))
-             buffer_slot_type_mismatch (offset);
+             buffer_slot_type_mismatch (symbol, XINT (type));
 
            if (buf == NULL)
              buf = current_buffer;
index aa160f4..49013ad 100644 (file)
@@ -1226,6 +1226,7 @@ struct Lisp_Buffer_Objfwd
     int type : 16;     /* = Lisp_Misc_Buffer_Objfwd */
     unsigned gcmarkbit : 1;
     int spacer : 15;
+    Lisp_Object slottype; /* Qnil, Lisp_Int, Lisp_Symbol, or Lisp_String.  */
     int offset;
   };