comparison src/symbols.c @ 446:1ccc32a20af4 r21-2-38

Import from CVS: tag r21-2-38
author cvs
date Mon, 13 Aug 2007 11:37:21 +0200
parents 576fb035e263
children 3d3049ae1304
comparison
equal deleted inserted replaced
445:34f3776fcf0e 446:1ccc32a20af4
993 static const struct lrecord_description symbol_value_forward_description[] = { 993 static const struct lrecord_description symbol_value_forward_description[] = {
994 { XD_END } 994 { XD_END }
995 }; 995 };
996 996
997 static const struct lrecord_description symbol_value_buffer_local_description[] = { 997 static const struct lrecord_description symbol_value_buffer_local_description[] = {
998 { XD_LISP_OBJECT, offsetof (struct symbol_value_buffer_local, default_value) }, 998 { XD_LISP_OBJECT, offsetof (struct symbol_value_buffer_local, default_value) },
999 { XD_LO_RESET_NIL, offsetof (struct symbol_value_buffer_local, current_value), 3 }, 999 { XD_LISP_OBJECT, offsetof (struct symbol_value_buffer_local, current_value) },
1000 { XD_LISP_OBJECT, offsetof (struct symbol_value_buffer_local, current_buffer) },
1001 { XD_LISP_OBJECT, offsetof (struct symbol_value_buffer_local, current_alist_element) },
1000 { XD_END } 1002 { XD_END }
1001 }; 1003 };
1002 1004
1003 static const struct lrecord_description symbol_value_lisp_magic_description[] = { 1005 static const struct lrecord_description symbol_value_lisp_magic_description[] = {
1004 { XD_LISP_OBJECT_ARRAY, offsetof (struct symbol_value_lisp_magic, handler), 2*MAGIC_HANDLER_MAX+1 }, 1006 { XD_LISP_OBJECT_ARRAY, offsetof (struct symbol_value_lisp_magic, handler), 2*MAGIC_HANDLER_MAX+1 },
1391 1393
1392 We might also want to call a magic function. 1394 We might also want to call a magic function.
1393 1395
1394 So instead, we call this function. */ 1396 So instead, we call this function. */
1395 store_symval_forwarding (sym, bfwd->current_value, new_val); 1397 store_symval_forwarding (sym, bfwd->current_value, new_val);
1398 }
1399
1400
1401 /* SYM is a buffer-local variable, and BFWD is its buffer-local structure.
1402 Flush the cache. BFWD->CURRENT_BUFFER will be nil after this operation.
1403 */
1404
1405 static void
1406 flush_buffer_local_cache (Lisp_Object sym,
1407 struct symbol_value_buffer_local *bfwd)
1408 {
1409 if (NILP (bfwd->current_buffer))
1410 /* Cache is already flushed. */
1411 return;
1412
1413 /* Flush out the old cache. */
1414 write_out_buffer_local_cache (sym, bfwd);
1415
1416 bfwd->current_alist_element = Qnil;
1417 bfwd->current_buffer = Qnil;
1418
1419 /* Now store default the value into the current-value slot.
1420 We don't simply write it there, because the current-value
1421 slot might be a forwarding pointer, in which case we need
1422 to instead write the value into the C variable.
1423
1424 We might also want to call a magic function.
1425
1426 So instead, we call this function. */
1427 store_symval_forwarding (sym, bfwd->current_value, bfwd->default_value);
1428 }
1429
1430 /* Flush all the buffer-local variable caches. Whoever has a
1431 non-interned buffer-local variable will be spanked. Whoever has a
1432 magic variable that interns or uninterns symbols... I don't even
1433 want to think about it.
1434 */
1435
1436 void
1437 flush_all_buffer_local_cache (void)
1438 {
1439 Lisp_Object *syms = XVECTOR_DATA (Vobarray);
1440 long count = XVECTOR_LENGTH (Vobarray);
1441 long i;
1442
1443 for (i=0; i<count; i++)
1444 {
1445 Lisp_Object sym = syms[i];
1446 Lisp_Object value;
1447
1448 if (!ZEROP (sym))
1449 for(;;)
1450 {
1451 Lisp_Symbol *next;
1452 assert (SYMBOLP (sym));
1453 value = fetch_value_maybe_past_magic (sym, Qt);
1454 if (SYMBOL_VALUE_BUFFER_LOCAL_P (value))
1455 flush_buffer_local_cache (sym, XSYMBOL_VALUE_BUFFER_LOCAL (value));
1456
1457 next = symbol_next (XSYMBOL (sym));
1458 if (!next)
1459 break;
1460 XSETSYMBOL (sym, next);
1461 }
1462 }
1396 } 1463 }
1397 1464
1398 1465
1399 void 1466 void
1400 kill_buffer_local_variables (struct buffer *buf) 1467 kill_buffer_local_variables (struct buffer *buf)