Mercurial > emacs
comparison src/buffer.c @ 86285:59344cb482f3
* 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.
| author | Stefan Monnier <monnier@iro.umontreal.ca> |
|---|---|
| date | Wed, 21 Nov 2007 20:59:47 +0000 |
| parents | 79043dac5524 |
| children | 13041217da4b |
comparison
equal
deleted
inserted
replaced
| 86284:d0c1a4ea2562 | 86285:59344cb482f3 |
|---|---|
| 96 | 96 |
| 97 DECL_ALIGN (struct buffer, buffer_local_symbols); | 97 DECL_ALIGN (struct buffer, buffer_local_symbols); |
| 98 | 98 |
| 99 /* A Lisp_Object pointer to the above, used for staticpro */ | 99 /* A Lisp_Object pointer to the above, used for staticpro */ |
| 100 static Lisp_Object Vbuffer_local_symbols; | 100 static Lisp_Object Vbuffer_local_symbols; |
| 101 | |
| 102 /* This structure holds the required types for the values in the | |
| 103 buffer-local slots. If a slot contains Qnil, then the | |
| 104 corresponding buffer slot may contain a value of any type. If a | |
| 105 slot contains an integer, then prospective values' tags must be | |
| 106 equal to that integer (except nil is always allowed). | |
| 107 When a tag does not match, the function | |
| 108 buffer_slot_type_mismatch will signal an error. | |
| 109 | |
| 110 If a slot here contains -1, the corresponding variable is read-only. */ | |
| 111 struct buffer buffer_local_types; | |
| 112 | 101 |
| 113 /* Flags indicating which built-in buffer-local variables | 102 /* Flags indicating which built-in buffer-local variables |
| 114 are permanent locals. */ | 103 are permanent locals. */ |
| 115 static char buffer_permanent_local_flags[MAX_PER_BUFFER_VARS]; | 104 static char buffer_permanent_local_flags[MAX_PER_BUFFER_VARS]; |
| 116 | 105 |
| 4400 | 4389 |
| 4401 /* Somebody has tried to store a value with an unacceptable type | 4390 /* Somebody has tried to store a value with an unacceptable type |
| 4402 in the slot with offset OFFSET. */ | 4391 in the slot with offset OFFSET. */ |
| 4403 | 4392 |
| 4404 void | 4393 void |
| 4405 buffer_slot_type_mismatch (offset) | 4394 buffer_slot_type_mismatch (sym, type) |
| 4406 int offset; | 4395 Lisp_Object sym; |
| 4407 { | 4396 int type; |
| 4408 Lisp_Object sym; | 4397 { |
| 4409 char *type_name; | 4398 char *type_name; |
| 4410 | 4399 |
| 4411 switch (XINT (PER_BUFFER_TYPE (offset))) | 4400 switch (type) |
| 4412 { | 4401 { |
| 4413 case Lisp_Int: | 4402 case Lisp_Int: |
| 4414 type_name = "integers"; | 4403 type_name = "integers"; |
| 4415 break; | 4404 break; |
| 4416 | 4405 |
| 4424 | 4413 |
| 4425 default: | 4414 default: |
| 4426 abort (); | 4415 abort (); |
| 4427 } | 4416 } |
| 4428 | 4417 |
| 4429 sym = PER_BUFFER_SYMBOL (offset); | |
| 4430 error ("Only %s should be stored in the buffer-local variable %s", | 4418 error ("Only %s should be stored in the buffer-local variable %s", |
| 4431 type_name, SDATA (SYMBOL_NAME (sym))); | 4419 type_name, SDATA (SYMBOL_NAME (sym))); |
| 4432 } | 4420 } |
| 4433 | 4421 |
| 4434 | 4422 |
| 5272 val = allocate_misc (); | 5260 val = allocate_misc (); |
| 5273 offset = (char *)address - (char *)current_buffer; | 5261 offset = (char *)address - (char *)current_buffer; |
| 5274 | 5262 |
| 5275 XMISCTYPE (val) = Lisp_Misc_Buffer_Objfwd; | 5263 XMISCTYPE (val) = Lisp_Misc_Buffer_Objfwd; |
| 5276 XBUFFER_OBJFWD (val)->offset = offset; | 5264 XBUFFER_OBJFWD (val)->offset = offset; |
| 5265 XBUFFER_OBJFWD (val)->slottype = type; | |
| 5277 SET_SYMBOL_VALUE (sym, val); | 5266 SET_SYMBOL_VALUE (sym, val); |
| 5278 PER_BUFFER_SYMBOL (offset) = sym; | 5267 PER_BUFFER_SYMBOL (offset) = sym; |
| 5279 PER_BUFFER_TYPE (offset) = type; | |
| 5280 | 5268 |
| 5281 if (PER_BUFFER_IDX (offset) == 0) | 5269 if (PER_BUFFER_IDX (offset) == 0) |
| 5282 /* Did a DEFVAR_PER_BUFFER without initializing the corresponding | 5270 /* Did a DEFVAR_PER_BUFFER without initializing the corresponding |
| 5283 slot of buffer_local_flags */ | 5271 slot of buffer_local_flags */ |
| 5284 abort (); | 5272 abort (); |
