aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDmitry Antipov2012-08-20 11:42:06 +0400
committerDmitry Antipov2012-08-20 11:42:06 +0400
commit4ce60d2ec56748e74fb56487b7761a2bdba1d644 (patch)
tree6dc415220c4199b029e638bca3dcb10c493f4b67 /src
parent36e8d1eb27b39ea35e9a57575858cb86a8784f2a (diff)
downloademacs-4ce60d2ec56748e74fb56487b7761a2bdba1d644.tar.gz
emacs-4ce60d2ec56748e74fb56487b7761a2bdba1d644.zip
Inline getter and setter functions for per-buffer values.
* buffer.h (per_buffer_default, set_per_buffer_default) (per_buffer_value, set_per_buffer_value): New functions. (PER_BUFFER_VALUE, PER_BUFFER_DEFAULT): Remove. * buffer.c, data.c: Adjust users.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog8
-rw-r--r--src/buffer.c10
-rw-r--r--src/buffer.h36
-rw-r--r--src/data.c16
4 files changed, 48 insertions, 22 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 8cffccdad37..c5ab370d311 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,11 @@
12012-08-20 Dmitry Antipov <dmantipov@yandex.ru>
2
3 Inline getter and setter functions for per-buffer values.
4 * buffer.h (per_buffer_default, set_per_buffer_default)
5 (per_buffer_value, set_per_buffer_value): New functions.
6 (PER_BUFFER_VALUE, PER_BUFFER_DEFAULT): Remove.
7 * buffer.c, data.c: Adjust users.
8
12012-08-20 Juanma Barranquero <lekktu@gmail.com> 92012-08-20 Juanma Barranquero <lekktu@gmail.com>
2 10
3 * makefile.w32-in ($(BLD)/vm-limit.$(O)): Update dependencies. 11 * makefile.w32-in ($(BLD)/vm-limit.$(O)): Update dependencies.
diff --git a/src/buffer.c b/src/buffer.c
index 9373e3cd363..c900ef8c5a8 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -695,7 +695,7 @@ clone_per_buffer_values (struct buffer *from, struct buffer *to)
695 if (offset == PER_BUFFER_VAR_OFFSET (name)) 695 if (offset == PER_BUFFER_VAR_OFFSET (name))
696 continue; 696 continue;
697 697
698 obj = PER_BUFFER_VALUE (from, offset); 698 obj = per_buffer_value (from, offset);
699 if (MARKERP (obj) && XMARKER (obj)->buffer == from) 699 if (MARKERP (obj) && XMARKER (obj)->buffer == from)
700 { 700 {
701 struct Lisp_Marker *m = XMARKER (obj); 701 struct Lisp_Marker *m = XMARKER (obj);
@@ -704,7 +704,7 @@ clone_per_buffer_values (struct buffer *from, struct buffer *to)
704 XMARKER (obj)->insertion_type = m->insertion_type; 704 XMARKER (obj)->insertion_type = m->insertion_type;
705 } 705 }
706 706
707 PER_BUFFER_VALUE (to, offset) = obj; 707 set_per_buffer_value (to, offset, obj);
708 } 708 }
709 709
710 memcpy (to->local_flags, from->local_flags, sizeof to->local_flags); 710 memcpy (to->local_flags, from->local_flags, sizeof to->local_flags);
@@ -1063,7 +1063,7 @@ reset_buffer_local_variables (register struct buffer *b, int permanent_too)
1063 if ((idx > 0 1063 if ((idx > 0
1064 && (permanent_too 1064 && (permanent_too
1065 || buffer_permanent_local_flags[idx] == 0))) 1065 || buffer_permanent_local_flags[idx] == 0)))
1066 PER_BUFFER_VALUE (b, offset) = PER_BUFFER_DEFAULT (offset); 1066 set_per_buffer_value (b, offset, per_buffer_default (offset));
1067 } 1067 }
1068} 1068}
1069 1069
@@ -1239,7 +1239,7 @@ buffer_local_value_1 (Lisp_Object variable, Lisp_Object buffer)
1239 { 1239 {
1240 union Lisp_Fwd *fwd = SYMBOL_FWD (sym); 1240 union Lisp_Fwd *fwd = SYMBOL_FWD (sym);
1241 if (BUFFER_OBJFWDP (fwd)) 1241 if (BUFFER_OBJFWDP (fwd))
1242 result = PER_BUFFER_VALUE (buf, XBUFFER_OBJFWD (fwd)->offset); 1242 result = per_buffer_value (buf, XBUFFER_OBJFWD (fwd)->offset);
1243 else 1243 else
1244 result = Fdefault_value (variable); 1244 result = Fdefault_value (variable);
1245 break; 1245 break;
@@ -1319,7 +1319,7 @@ No argument or nil as argument means use current buffer as BUFFER. */)
1319 && SYMBOLP (PER_BUFFER_SYMBOL (offset))) 1319 && SYMBOLP (PER_BUFFER_SYMBOL (offset)))
1320 { 1320 {
1321 Lisp_Object sym = PER_BUFFER_SYMBOL (offset); 1321 Lisp_Object sym = PER_BUFFER_SYMBOL (offset);
1322 Lisp_Object val = PER_BUFFER_VALUE (buf, offset); 1322 Lisp_Object val = per_buffer_value (buf, offset);
1323 result = Fcons (EQ (val, Qunbound) ? sym : Fcons (sym, val), 1323 result = Fcons (EQ (val, Qunbound) ? sym : Fcons (sym, val),
1324 result); 1324 result);
1325 } 1325 }
diff --git a/src/buffer.h b/src/buffer.h
index 510a8e55682..6c63c52dc47 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -1203,18 +1203,36 @@ extern int last_per_buffer_idx;
1203#define PER_BUFFER_IDX(OFFSET) \ 1203#define PER_BUFFER_IDX(OFFSET) \
1204 XINT (*(Lisp_Object *)((OFFSET) + (char *) &buffer_local_flags)) 1204 XINT (*(Lisp_Object *)((OFFSET) + (char *) &buffer_local_flags))
1205 1205
1206/* Return the default value of the per-buffer variable at offset 1206/* Functions to get and set default value of the per-buffer
1207 OFFSET in the buffer structure. */ 1207 variable at offset OFFSET in the buffer structure. */
1208 1208
1209#define PER_BUFFER_DEFAULT(OFFSET) \ 1209BUFFER_INLINE Lisp_Object
1210 (*(Lisp_Object *)((OFFSET) + (char *) &buffer_defaults)) 1210per_buffer_default (int offset)
1211{
1212 return *(Lisp_Object *)(offset + (char *) &buffer_defaults);
1213}
1211 1214
1212/* Return the buffer-local value of the per-buffer variable at offset 1215BUFFER_INLINE void
1213 OFFSET in the buffer structure. */ 1216set_per_buffer_default (int offset, Lisp_Object value)
1217{
1218 *(Lisp_Object *)(offset + (char *) &buffer_defaults) = value;
1219}
1220
1221/* Functions to get and set buffer-local value of the per-buffer
1222 variable at offset OFFSET in the buffer structure. */
1223
1224BUFFER_INLINE Lisp_Object
1225per_buffer_value (struct buffer *b, int offset)
1226{
1227 return *(Lisp_Object *)(offset + (char *) b);
1228}
1229
1230BUFFER_INLINE void
1231set_per_buffer_value (struct buffer *b, int offset, Lisp_Object value)
1232{
1233 *(Lisp_Object *)(offset + (char *) b) = value;
1234}
1214 1235
1215#define PER_BUFFER_VALUE(BUFFER, OFFSET) \
1216 (*(Lisp_Object *)((OFFSET) + (char *) (BUFFER)))
1217
1218/* Downcase a character C, or make no change if that cannot be done. */ 1236/* Downcase a character C, or make no change if that cannot be done. */
1219BUFFER_INLINE int 1237BUFFER_INLINE int
1220downcase (int c) 1238downcase (int c)
diff --git a/src/data.c b/src/data.c
index 6dd852dd710..f812c280b40 100644
--- a/src/data.c
+++ b/src/data.c
@@ -847,7 +847,7 @@ do_symval_forwarding (register union Lisp_Fwd *valcontents)
847 return *XOBJFWD (valcontents)->objvar; 847 return *XOBJFWD (valcontents)->objvar;
848 848
849 case Lisp_Fwd_Buffer_Obj: 849 case Lisp_Fwd_Buffer_Obj:
850 return PER_BUFFER_VALUE (current_buffer, 850 return per_buffer_value (current_buffer,
851 XBUFFER_OBJFWD (valcontents)->offset); 851 XBUFFER_OBJFWD (valcontents)->offset);
852 852
853 case Lisp_Fwd_Kboard_Obj: 853 case Lisp_Fwd_Kboard_Obj:
@@ -919,7 +919,7 @@ store_symval_forwarding (union Lisp_Fwd *valcontents, register Lisp_Object newva
919 b = XBUFFER (lbuf); 919 b = XBUFFER (lbuf);
920 920
921 if (! PER_BUFFER_VALUE_P (b, idx)) 921 if (! PER_BUFFER_VALUE_P (b, idx))
922 PER_BUFFER_VALUE (b, offset) = newval; 922 set_per_buffer_value (b, offset, newval);
923 } 923 }
924 } 924 }
925 break; 925 break;
@@ -937,7 +937,7 @@ store_symval_forwarding (union Lisp_Fwd *valcontents, register Lisp_Object newva
937 937
938 if (buf == NULL) 938 if (buf == NULL)
939 buf = current_buffer; 939 buf = current_buffer;
940 PER_BUFFER_VALUE (buf, offset) = newval; 940 set_per_buffer_value (buf, offset, newval);
941 } 941 }
942 break; 942 break;
943 943
@@ -1309,7 +1309,7 @@ default_value (Lisp_Object symbol)
1309 { 1309 {
1310 int offset = XBUFFER_OBJFWD (valcontents)->offset; 1310 int offset = XBUFFER_OBJFWD (valcontents)->offset;
1311 if (PER_BUFFER_IDX (offset) != 0) 1311 if (PER_BUFFER_IDX (offset) != 0)
1312 return PER_BUFFER_DEFAULT (offset); 1312 return per_buffer_default (offset);
1313 } 1313 }
1314 1314
1315 /* For other variables, get the current value. */ 1315 /* For other variables, get the current value. */
@@ -1396,7 +1396,7 @@ for this variable. */)
1396 int offset = XBUFFER_OBJFWD (valcontents)->offset; 1396 int offset = XBUFFER_OBJFWD (valcontents)->offset;
1397 int idx = PER_BUFFER_IDX (offset); 1397 int idx = PER_BUFFER_IDX (offset);
1398 1398
1399 PER_BUFFER_DEFAULT (offset) = value; 1399 set_per_buffer_default (offset, value);
1400 1400
1401 /* If this variable is not always local in all buffers, 1401 /* If this variable is not always local in all buffers,
1402 set it in the buffers that don't nominally have a local value. */ 1402 set it in the buffers that don't nominally have a local value. */
@@ -1406,7 +1406,7 @@ for this variable. */)
1406 1406
1407 FOR_EACH_BUFFER (b) 1407 FOR_EACH_BUFFER (b)
1408 if (!PER_BUFFER_VALUE_P (b, idx)) 1408 if (!PER_BUFFER_VALUE_P (b, idx))
1409 PER_BUFFER_VALUE (b, offset) = value; 1409 set_per_buffer_value (b, offset, value);
1410 } 1410 }
1411 return value; 1411 return value;
1412 } 1412 }
@@ -1705,8 +1705,8 @@ From now on the default value will apply in this buffer. Return VARIABLE. */)
1705 if (idx > 0) 1705 if (idx > 0)
1706 { 1706 {
1707 SET_PER_BUFFER_VALUE_P (current_buffer, idx, 0); 1707 SET_PER_BUFFER_VALUE_P (current_buffer, idx, 0);
1708 PER_BUFFER_VALUE (current_buffer, offset) 1708 set_per_buffer_value (current_buffer, offset,
1709 = PER_BUFFER_DEFAULT (offset); 1709 per_buffer_default (offset));
1710 } 1710 }
1711 } 1711 }
1712 return variable; 1712 return variable;