Commit a098c930 authored by Dmitry Antipov's avatar Dmitry Antipov

Simple interface to set Lisp_Object fields of chararcter tables.

* lisp.h (CSET): New macro.
(char_table_set_extras, char_table_set_contents)
(sub_char_table_set_contents): New function.
* casetab.c, category.c, chartab.c, fns.c, fontset.c, search.c:
* syntax.c: Adjust users.
parent 8be3a09c
2012-08-16 Dmitry Antipov <dmantipov@yandex.ru>
Simple interface to set Lisp_Object fields of chararcter tables.
* lisp.h (CSET): New macro.
(char_table_set_extras, char_table_set_contents)
(sub_char_table_set_contents): New function.
* casetab.c, category.c, chartab.c, fns.c, fontset.c, search.c:
* syntax.c: Adjust users.
2012-08-16 Stefan Monnier <monnier@iro.umontreal.ca> 2012-08-16 Stefan Monnier <monnier@iro.umontreal.ca>
* eval.c (eval_sub): Bind lexical-binding. * eval.c (eval_sub): Bind lexical-binding.
......
...@@ -128,13 +128,13 @@ set_case_table (Lisp_Object table, int standard) ...@@ -128,13 +128,13 @@ set_case_table (Lisp_Object table, int standard)
up = Fmake_char_table (Qcase_table, Qnil); up = Fmake_char_table (Qcase_table, Qnil);
map_char_table (set_identity, Qnil, table, up); map_char_table (set_identity, Qnil, table, up);
map_char_table (shuffle, Qnil, table, up); map_char_table (shuffle, Qnil, table, up);
XCHAR_TABLE (table)->extras[0] = up; char_table_set_extras (table, 0, up);
} }
if (NILP (canon)) if (NILP (canon))
{ {
canon = Fmake_char_table (Qcase_table, Qnil); canon = Fmake_char_table (Qcase_table, Qnil);
XCHAR_TABLE (table)->extras[1] = canon; char_table_set_extras (table, 1, canon);
map_char_table (set_canon, Qnil, table, table); map_char_table (set_canon, Qnil, table, table);
} }
...@@ -143,11 +143,11 @@ set_case_table (Lisp_Object table, int standard) ...@@ -143,11 +143,11 @@ set_case_table (Lisp_Object table, int standard)
eqv = Fmake_char_table (Qcase_table, Qnil); eqv = Fmake_char_table (Qcase_table, Qnil);
map_char_table (set_identity, Qnil, canon, eqv); map_char_table (set_identity, Qnil, canon, eqv);
map_char_table (shuffle, Qnil, canon, eqv); map_char_table (shuffle, Qnil, canon, eqv);
XCHAR_TABLE (table)->extras[2] = eqv; char_table_set_extras (table, 2, eqv);
} }
/* This is so set_image_of_range_1 in regex.c can find the EQV table. */ /* This is so set_image_of_range_1 in regex.c can find the EQV table. */
XCHAR_TABLE (canon)->extras[2] = eqv; char_table_set_extras (canon, 2, eqv);
if (standard) if (standard)
{ {
...@@ -260,7 +260,7 @@ init_casetab_once (void) ...@@ -260,7 +260,7 @@ init_casetab_once (void)
down = Fmake_char_table (Qcase_table, Qnil); down = Fmake_char_table (Qcase_table, Qnil);
Vascii_downcase_table = down; Vascii_downcase_table = down;
XCHAR_TABLE (down)->purpose = Qcase_table; CSET (XCHAR_TABLE (down), purpose, Qcase_table);
for (i = 0; i < 128; i++) for (i = 0; i < 128; i++)
{ {
...@@ -268,10 +268,10 @@ init_casetab_once (void) ...@@ -268,10 +268,10 @@ init_casetab_once (void)
CHAR_TABLE_SET (down, i, make_number (c)); CHAR_TABLE_SET (down, i, make_number (c));
} }
XCHAR_TABLE (down)->extras[1] = Fcopy_sequence (down); char_table_set_extras (down, 1, Fcopy_sequence (down));
up = Fmake_char_table (Qcase_table, Qnil); up = Fmake_char_table (Qcase_table, Qnil);
XCHAR_TABLE (down)->extras[0] = up; char_table_set_extras (down, 0, up);
for (i = 0; i < 128; i++) for (i = 0; i < 128; i++)
{ {
...@@ -281,7 +281,7 @@ init_casetab_once (void) ...@@ -281,7 +281,7 @@ init_casetab_once (void)
CHAR_TABLE_SET (up, i, make_number (c)); CHAR_TABLE_SET (up, i, make_number (c));
} }
XCHAR_TABLE (down)->extras[2] = Fcopy_sequence (up); char_table_set_extras (down, 2, Fcopy_sequence (up));
/* Fill in what isn't filled in. */ /* Fill in what isn't filled in. */
set_case_table (down, 1); set_case_table (down, 1);
......
...@@ -71,11 +71,12 @@ hash_get_category_set (Lisp_Object table, Lisp_Object category_set) ...@@ -71,11 +71,12 @@ hash_get_category_set (Lisp_Object table, Lisp_Object category_set)
EMACS_UINT hash; EMACS_UINT hash;
if (NILP (XCHAR_TABLE (table)->extras[1])) if (NILP (XCHAR_TABLE (table)->extras[1]))
XCHAR_TABLE (table)->extras[1] char_table_set_extras
= make_hash_table (Qequal, make_number (DEFAULT_HASH_SIZE), (table, 1,
make_float (DEFAULT_REHASH_SIZE), make_hash_table (Qequal, make_number (DEFAULT_HASH_SIZE),
make_float (DEFAULT_REHASH_THRESHOLD), make_float (DEFAULT_REHASH_SIZE),
Qnil, Qnil, Qnil); make_float (DEFAULT_REHASH_THRESHOLD),
Qnil, Qnil, Qnil));
h = XHASH_TABLE (XCHAR_TABLE (table)->extras[1]); h = XHASH_TABLE (XCHAR_TABLE (table)->extras[1]);
i = hash_lookup (h, category_set, &hash); i = hash_lookup (h, category_set, &hash);
if (i >= 0) if (i >= 0)
...@@ -238,10 +239,10 @@ copy_category_table (Lisp_Object table) ...@@ -238,10 +239,10 @@ copy_category_table (Lisp_Object table)
table = copy_char_table (table); table = copy_char_table (table);
if (! NILP (XCHAR_TABLE (table)->defalt)) if (! NILP (XCHAR_TABLE (table)->defalt))
XCHAR_TABLE (table)->defalt CSET (XCHAR_TABLE (table), defalt,
= Fcopy_sequence (XCHAR_TABLE (table)->defalt); Fcopy_sequence (XCHAR_TABLE (table)->defalt));
XCHAR_TABLE (table)->extras[0] char_table_set_extras
= Fcopy_sequence (XCHAR_TABLE (table)->extras[0]); (table, 0, Fcopy_sequence (XCHAR_TABLE (table)->extras[0]));
map_char_table (copy_category_entry, Qnil, table, table); map_char_table (copy_category_entry, Qnil, table, table);
return table; return table;
...@@ -270,9 +271,9 @@ DEFUN ("make-category-table", Fmake_category_table, Smake_category_table, ...@@ -270,9 +271,9 @@ DEFUN ("make-category-table", Fmake_category_table, Smake_category_table,
int i; int i;
val = Fmake_char_table (Qcategory_table, Qnil); val = Fmake_char_table (Qcategory_table, Qnil);
XCHAR_TABLE (val)->defalt = MAKE_CATEGORY_SET; CSET (XCHAR_TABLE (val), defalt, MAKE_CATEGORY_SET);
for (i = 0; i < (1 << CHARTAB_SIZE_BITS_0); i++) for (i = 0; i < (1 << CHARTAB_SIZE_BITS_0); i++)
XCHAR_TABLE (val)->contents[i] = MAKE_CATEGORY_SET; char_table_set_contents (val, i, MAKE_CATEGORY_SET);
Fset_char_table_extra_slot (val, make_number (0), Fset_char_table_extra_slot (val, make_number (0),
Fmake_vector (make_number (95), Qnil)); Fmake_vector (make_number (95), Qnil));
return val; return val;
...@@ -466,7 +467,7 @@ init_category_once (void) ...@@ -466,7 +467,7 @@ init_category_once (void)
Vstandard_category_table = Fmake_char_table (Qcategory_table, Qnil); Vstandard_category_table = Fmake_char_table (Qcategory_table, Qnil);
/* Set a category set which contains nothing to the default. */ /* Set a category set which contains nothing to the default. */
XCHAR_TABLE (Vstandard_category_table)->defalt = MAKE_CATEGORY_SET; CSET (XCHAR_TABLE (Vstandard_category_table), defalt, MAKE_CATEGORY_SET);
Fset_char_table_extra_slot (Vstandard_category_table, make_number (0), Fset_char_table_extra_slot (Vstandard_category_table, make_number (0),
Fmake_vector (make_number (95), Qnil)); Fmake_vector (make_number (95), Qnil));
} }
......
...@@ -115,8 +115,8 @@ the char-table has no extra slot. */) ...@@ -115,8 +115,8 @@ the char-table has no extra slot. */)
size = VECSIZE (struct Lisp_Char_Table) - 1 + n_extras; size = VECSIZE (struct Lisp_Char_Table) - 1 + n_extras;
vector = Fmake_vector (make_number (size), init); vector = Fmake_vector (make_number (size), init);
XSETPVECTYPE (XVECTOR (vector), PVEC_CHAR_TABLE); XSETPVECTYPE (XVECTOR (vector), PVEC_CHAR_TABLE);
XCHAR_TABLE (vector)->parent = Qnil; CSET (XCHAR_TABLE (vector), parent, Qnil);
XCHAR_TABLE (vector)->purpose = purpose; CSET (XCHAR_TABLE (vector), purpose, purpose);
XSETCHAR_TABLE (vector, XCHAR_TABLE (vector)); XSETCHAR_TABLE (vector, XCHAR_TABLE (vector));
return vector; return vector;
} }
...@@ -167,9 +167,9 @@ copy_sub_char_table (Lisp_Object table) ...@@ -167,9 +167,9 @@ copy_sub_char_table (Lisp_Object table)
{ {
val = XSUB_CHAR_TABLE (table)->contents[i]; val = XSUB_CHAR_TABLE (table)->contents[i];
if (SUB_CHAR_TABLE_P (val)) if (SUB_CHAR_TABLE_P (val))
XSUB_CHAR_TABLE (copy)->contents[i] = copy_sub_char_table (val); sub_char_table_set_contents (copy, i, copy_sub_char_table (val));
else else
XSUB_CHAR_TABLE (copy)->contents[i] = val; sub_char_table_set_contents (copy, i, val);
} }
return copy; return copy;
...@@ -185,18 +185,19 @@ copy_char_table (Lisp_Object table) ...@@ -185,18 +185,19 @@ copy_char_table (Lisp_Object table)
copy = Fmake_vector (make_number (size), Qnil); copy = Fmake_vector (make_number (size), Qnil);
XSETPVECTYPE (XVECTOR (copy), PVEC_CHAR_TABLE); XSETPVECTYPE (XVECTOR (copy), PVEC_CHAR_TABLE);
XCHAR_TABLE (copy)->defalt = XCHAR_TABLE (table)->defalt; CSET (XCHAR_TABLE (copy), defalt, XCHAR_TABLE (table)->defalt);
XCHAR_TABLE (copy)->parent = XCHAR_TABLE (table)->parent; CSET (XCHAR_TABLE (copy), parent, XCHAR_TABLE (table)->parent);
XCHAR_TABLE (copy)->purpose = XCHAR_TABLE (table)->purpose; CSET (XCHAR_TABLE (copy), purpose, XCHAR_TABLE (table)->purpose);
for (i = 0; i < chartab_size[0]; i++) for (i = 0; i < chartab_size[0]; i++)
XCHAR_TABLE (copy)->contents[i] char_table_set_contents
= (SUB_CHAR_TABLE_P (XCHAR_TABLE (table)->contents[i]) (copy, i,
? copy_sub_char_table (XCHAR_TABLE (table)->contents[i]) (SUB_CHAR_TABLE_P (XCHAR_TABLE (table)->contents[i])
: XCHAR_TABLE (table)->contents[i]); ? copy_sub_char_table (XCHAR_TABLE (table)->contents[i])
XCHAR_TABLE (copy)->ascii = char_table_ascii (copy); : XCHAR_TABLE (table)->contents[i]));
CSET (XCHAR_TABLE (copy), ascii, char_table_ascii (copy));
size -= VECSIZE (struct Lisp_Char_Table) - 1; size -= VECSIZE (struct Lisp_Char_Table) - 1;
for (i = 0; i < size; i++) for (i = 0; i < size; i++)
XCHAR_TABLE (copy)->extras[i] = XCHAR_TABLE (table)->extras[i]; char_table_set_extras (copy, i, XCHAR_TABLE (table)->extras[i]);
XSETCHAR_TABLE (copy, XCHAR_TABLE (copy)); XSETCHAR_TABLE (copy, XCHAR_TABLE (copy));
return copy; return copy;
...@@ -394,7 +395,7 @@ sub_char_table_set (Lisp_Object table, int c, Lisp_Object val, int is_uniprop) ...@@ -394,7 +395,7 @@ sub_char_table_set (Lisp_Object table, int c, Lisp_Object val, int is_uniprop)
Lisp_Object sub; Lisp_Object sub;
if (depth == 3) if (depth == 3)
tbl->contents[i] = val; sub_char_table_set_contents (table, i, val);
else else
{ {
sub = tbl->contents[i]; sub = tbl->contents[i];
...@@ -407,7 +408,7 @@ sub_char_table_set (Lisp_Object table, int c, Lisp_Object val, int is_uniprop) ...@@ -407,7 +408,7 @@ sub_char_table_set (Lisp_Object table, int c, Lisp_Object val, int is_uniprop)
sub = make_sub_char_table (depth + 1, sub = make_sub_char_table (depth + 1,
min_char + i * chartab_chars[depth], min_char + i * chartab_chars[depth],
sub); sub);
tbl->contents[i] = sub; sub_char_table_set_contents (table, i, sub);
} }
} }
sub_char_table_set (sub, c, val, is_uniprop); sub_char_table_set (sub, c, val, is_uniprop);
...@@ -421,9 +422,7 @@ char_table_set (Lisp_Object table, int c, Lisp_Object val) ...@@ -421,9 +422,7 @@ char_table_set (Lisp_Object table, int c, Lisp_Object val)
if (ASCII_CHAR_P (c) if (ASCII_CHAR_P (c)
&& SUB_CHAR_TABLE_P (tbl->ascii)) && SUB_CHAR_TABLE_P (tbl->ascii))
{ sub_char_table_set_contents (tbl->ascii, c, val);
XSUB_CHAR_TABLE (tbl->ascii)->contents[c] = val;
}
else else
{ {
int i = CHARTAB_IDX (c, 0, 0); int i = CHARTAB_IDX (c, 0, 0);
...@@ -433,11 +432,11 @@ char_table_set (Lisp_Object table, int c, Lisp_Object val) ...@@ -433,11 +432,11 @@ char_table_set (Lisp_Object table, int c, Lisp_Object val)
if (! SUB_CHAR_TABLE_P (sub)) if (! SUB_CHAR_TABLE_P (sub))
{ {
sub = make_sub_char_table (1, i * chartab_chars[0], sub); sub = make_sub_char_table (1, i * chartab_chars[0], sub);
tbl->contents[i] = sub; char_table_set_contents (table, i, sub);
} }
sub_char_table_set (sub, c, val, UNIPROP_TABLE_P (table)); sub_char_table_set (sub, c, val, UNIPROP_TABLE_P (table));
if (ASCII_CHAR_P (c)) if (ASCII_CHAR_P (c))
tbl->ascii = char_table_ascii (table); CSET (tbl, ascii, char_table_ascii (table));
} }
return val; return val;
} }
...@@ -461,7 +460,7 @@ sub_char_table_set_range (Lisp_Object table, int from, int to, Lisp_Object val, ...@@ -461,7 +460,7 @@ sub_char_table_set_range (Lisp_Object table, int from, int to, Lisp_Object val,
if (c > to) if (c > to)
break; break;
if (from <= c && c + chars_in_block - 1 <= to) if (from <= c && c + chars_in_block - 1 <= to)
tbl->contents[i] = val; sub_char_table_set_contents (table, i, val);
else else
{ {
Lisp_Object sub = tbl->contents[i]; Lisp_Object sub = tbl->contents[i];
...@@ -472,7 +471,7 @@ sub_char_table_set_range (Lisp_Object table, int from, int to, Lisp_Object val, ...@@ -472,7 +471,7 @@ sub_char_table_set_range (Lisp_Object table, int from, int to, Lisp_Object val,
else else
{ {
sub = make_sub_char_table (depth + 1, c, sub); sub = make_sub_char_table (depth + 1, c, sub);
tbl->contents[i] = sub; sub_char_table_set_contents (table, i, sub);
} }
} }
sub_char_table_set_range (sub, from, to, val, is_uniprop); sub_char_table_set_range (sub, from, to, val, is_uniprop);
...@@ -500,20 +499,20 @@ char_table_set_range (Lisp_Object table, int from, int to, Lisp_Object val) ...@@ -500,20 +499,20 @@ char_table_set_range (Lisp_Object table, int from, int to, Lisp_Object val)
if (c > to) if (c > to)
break; break;
if (from <= c && c + chartab_chars[0] - 1 <= to) if (from <= c && c + chartab_chars[0] - 1 <= to)
tbl->contents[i] = val; char_table_set_contents (table, i, val);
else else
{ {
Lisp_Object sub = tbl->contents[i]; Lisp_Object sub = tbl->contents[i];
if (! SUB_CHAR_TABLE_P (sub)) if (! SUB_CHAR_TABLE_P (sub))
{ {
sub = make_sub_char_table (1, i * chartab_chars[0], sub); sub = make_sub_char_table (1, i * chartab_chars[0], sub);
tbl->contents[i] = sub; char_table_set_contents (table, i, sub);
} }
sub_char_table_set_range (sub, from, to, val, is_uniprop); sub_char_table_set_range (sub, from, to, val, is_uniprop);
} }
} }
if (ASCII_CHAR_P (from)) if (ASCII_CHAR_P (from))
tbl->ascii = char_table_ascii (table); CSET (tbl, ascii, char_table_ascii (table));
} }
return val; return val;
} }
...@@ -563,7 +562,7 @@ Return PARENT. PARENT must be either nil or another char-table. */) ...@@ -563,7 +562,7 @@ Return PARENT. PARENT must be either nil or another char-table. */)
error ("Attempt to make a chartable be its own parent"); error ("Attempt to make a chartable be its own parent");
} }
XCHAR_TABLE (char_table)->parent = parent; CSET (XCHAR_TABLE (char_table), parent, parent);
return parent; return parent;
} }
...@@ -594,7 +593,8 @@ DEFUN ("set-char-table-extra-slot", Fset_char_table_extra_slot, ...@@ -594,7 +593,8 @@ DEFUN ("set-char-table-extra-slot", Fset_char_table_extra_slot,
|| XINT (n) >= CHAR_TABLE_EXTRA_SLOTS (XCHAR_TABLE (char_table))) || XINT (n) >= CHAR_TABLE_EXTRA_SLOTS (XCHAR_TABLE (char_table)))
args_out_of_range (char_table, n); args_out_of_range (char_table, n);
return XCHAR_TABLE (char_table)->extras[XINT (n)] = value; char_table_set_extras (char_table, XINT (n), value);
return value;
} }
DEFUN ("char-table-range", Fchar_table_range, Schar_table_range, DEFUN ("char-table-range", Fchar_table_range, Schar_table_range,
...@@ -640,12 +640,12 @@ or a character code. Return VALUE. */) ...@@ -640,12 +640,12 @@ or a character code. Return VALUE. */)
{ {
int i; int i;
XCHAR_TABLE (char_table)->ascii = value; CSET (XCHAR_TABLE (char_table), ascii, value);
for (i = 0; i < chartab_size[0]; i++) for (i = 0; i < chartab_size[0]; i++)
XCHAR_TABLE (char_table)->contents[i] = value; char_table_set_contents (char_table, i, value);
} }
else if (EQ (range, Qnil)) else if (EQ (range, Qnil))
XCHAR_TABLE (char_table)->defalt = value; CSET (XCHAR_TABLE (char_table), defalt, value);
else if (CHARACTERP (range)) else if (CHARACTERP (range))
char_table_set (char_table, XINT (range), value); char_table_set (char_table, XINT (range), value);
else if (CONSP (range)) else if (CONSP (range))
...@@ -728,11 +728,11 @@ equivalent and can be merged. It defaults to `equal'. */) ...@@ -728,11 +728,11 @@ equivalent and can be merged. It defaults to `equal'. */)
{ {
elt = XCHAR_TABLE (char_table)->contents[i]; elt = XCHAR_TABLE (char_table)->contents[i];
if (SUB_CHAR_TABLE_P (elt)) if (SUB_CHAR_TABLE_P (elt))
XCHAR_TABLE (char_table)->contents[i] char_table_set_contents
= optimize_sub_char_table (elt, test); (char_table, i, optimize_sub_char_table (elt, test));
} }
/* Reset the `ascii' cache, in case it got optimized away. */ /* Reset the `ascii' cache, in case it got optimized away. */
XCHAR_TABLE (char_table)->ascii = char_table_ascii (char_table); CSET (XCHAR_TABLE (char_table), ascii, char_table_ascii (char_table));
return Qnil; return Qnil;
} }
...@@ -824,9 +824,9 @@ map_sub_char_table (void (*c_function) (Lisp_Object, Lisp_Object, Lisp_Object), ...@@ -824,9 +824,9 @@ map_sub_char_table (void (*c_function) (Lisp_Object, Lisp_Object, Lisp_Object),
/* This is to get a value of FROM in PARENT /* This is to get a value of FROM in PARENT
without checking the parent of PARENT. */ without checking the parent of PARENT. */
XCHAR_TABLE (parent)->parent = Qnil; CSET (XCHAR_TABLE (parent), parent, Qnil);
val = CHAR_TABLE_REF (parent, from); val = CHAR_TABLE_REF (parent, from);
XCHAR_TABLE (parent)->parent = temp; CSET (XCHAR_TABLE (parent), parent, temp);
XSETCDR (range, make_number (c - 1)); XSETCDR (range, make_number (c - 1));
val = map_sub_char_table (c_function, function, val = map_sub_char_table (c_function, function,
parent, arg, val, range, parent, arg, val, range,
...@@ -906,9 +906,9 @@ map_char_table (void (*c_function) (Lisp_Object, Lisp_Object, Lisp_Object), ...@@ -906,9 +906,9 @@ map_char_table (void (*c_function) (Lisp_Object, Lisp_Object, Lisp_Object),
temp = XCHAR_TABLE (parent)->parent; temp = XCHAR_TABLE (parent)->parent;
/* This is to get a value of FROM in PARENT without checking the /* This is to get a value of FROM in PARENT without checking the
parent of PARENT. */ parent of PARENT. */
XCHAR_TABLE (parent)->parent = Qnil; CSET (XCHAR_TABLE (parent), parent, Qnil);
val = CHAR_TABLE_REF (parent, from); val = CHAR_TABLE_REF (parent, from);
XCHAR_TABLE (parent)->parent = temp; CSET (XCHAR_TABLE (parent), parent, temp);
val = map_sub_char_table (c_function, function, parent, arg, val, range, val = map_sub_char_table (c_function, function, parent, arg, val, range,
parent); parent);
table = parent; table = parent;
...@@ -1143,10 +1143,9 @@ uniprop_table_uncompress (Lisp_Object table, int idx) ...@@ -1143,10 +1143,9 @@ uniprop_table_uncompress (Lisp_Object table, int idx)
int min_char = (XINT (XSUB_CHAR_TABLE (table)->min_char) int min_char = (XINT (XSUB_CHAR_TABLE (table)->min_char)
+ chartab_chars[2] * idx); + chartab_chars[2] * idx);
Lisp_Object sub = make_sub_char_table (3, min_char, Qnil); Lisp_Object sub = make_sub_char_table (3, min_char, Qnil);
struct Lisp_Sub_Char_Table *subtbl = XSUB_CHAR_TABLE (sub);
const unsigned char *p, *pend; const unsigned char *p, *pend;
XSUB_CHAR_TABLE (table)->contents[idx] = sub; sub_char_table_set_contents (table, idx, sub);
p = SDATA (val), pend = p + SBYTES (val); p = SDATA (val), pend = p + SBYTES (val);
if (*p == 1) if (*p == 1)
{ {
...@@ -1156,7 +1155,8 @@ uniprop_table_uncompress (Lisp_Object table, int idx) ...@@ -1156,7 +1155,8 @@ uniprop_table_uncompress (Lisp_Object table, int idx)
while (p < pend && idx < chartab_chars[2]) while (p < pend && idx < chartab_chars[2])
{ {
int v = STRING_CHAR_ADVANCE (p); int v = STRING_CHAR_ADVANCE (p);
subtbl->contents[idx++] = v > 0 ? make_number (v) : Qnil; sub_char_table_set_contents
(sub, idx++, v > 0 ? make_number (v) : Qnil);
} }
} }
else if (*p == 2) else if (*p == 2)
...@@ -1181,7 +1181,7 @@ uniprop_table_uncompress (Lisp_Object table, int idx) ...@@ -1181,7 +1181,7 @@ uniprop_table_uncompress (Lisp_Object table, int idx)
} }
} }
while (count-- > 0) while (count-- > 0)
subtbl->contents[idx++] = make_number (v); sub_char_table_set_contents (sub, idx++, make_number (v));
} }
} }
/* It seems that we don't need this function because C code won't need /* It seems that we don't need this function because C code won't need
...@@ -1284,7 +1284,7 @@ uniprop_encode_value_numeric (Lisp_Object table, Lisp_Object value) ...@@ -1284,7 +1284,7 @@ uniprop_encode_value_numeric (Lisp_Object table, Lisp_Object value)
args[0] = XCHAR_TABLE (table)->extras[4]; args[0] = XCHAR_TABLE (table)->extras[4];
args[1] = Fmake_vector (make_number (1), value); args[1] = Fmake_vector (make_number (1), value);
XCHAR_TABLE (table)->extras[4] = Fvconcat (2, args); char_table_set_extras (table, 4, Fvconcat (2, args));
} }
return make_number (i); return make_number (i);
} }
...@@ -1346,7 +1346,7 @@ uniprop_table (Lisp_Object prop) ...@@ -1346,7 +1346,7 @@ uniprop_table (Lisp_Object prop)
: ! NILP (val)) : ! NILP (val))
return Qnil; return Qnil;
/* Prepare ASCII values in advance for CHAR_TABLE_REF. */ /* Prepare ASCII values in advance for CHAR_TABLE_REF. */
XCHAR_TABLE (table)->ascii = char_table_ascii (table); CSET (XCHAR_TABLE (table), ascii, char_table_ascii (table));
return table; return table;
} }
......
...@@ -2150,8 +2150,8 @@ ARRAY is a vector, string, char-table, or bool-vector. */) ...@@ -2150,8 +2150,8 @@ ARRAY is a vector, string, char-table, or bool-vector. */)
int i; int i;
for (i = 0; i < (1 << CHARTAB_SIZE_BITS_0); i++) for (i = 0; i < (1 << CHARTAB_SIZE_BITS_0); i++)
XCHAR_TABLE (array)->contents[i] = item; char_table_set_contents (array, i, item);
XCHAR_TABLE (array)->defalt = item; CSET (XCHAR_TABLE (array), defalt, item);
} }
else if (STRINGP (array)) else if (STRINGP (array))
{ {
......
...@@ -1916,7 +1916,7 @@ format is the same as above. */) ...@@ -1916,7 +1916,7 @@ format is the same as above. */)
if (!EQ (fontset, Vdefault_fontset)) if (!EQ (fontset, Vdefault_fontset))
{ {
tables[1] = Fmake_char_table (Qnil, Qnil); tables[1] = Fmake_char_table (Qnil, Qnil);
XCHAR_TABLE (tables[0])->extras[0] = tables[1]; char_table_set_extras (tables[0], 0, tables[1]);
fontsets[1] = Vdefault_fontset; fontsets[1] = Vdefault_fontset;
} }
...@@ -1979,7 +1979,7 @@ format is the same as above. */) ...@@ -1979,7 +1979,7 @@ format is the same as above. */)
if (c <= MAX_5_BYTE_CHAR) if (c <= MAX_5_BYTE_CHAR)
char_table_set_range (tables[k], c, to, alist); char_table_set_range (tables[k], c, to, alist);
else else
XCHAR_TABLE (tables[k])->defalt = alist; CSET (XCHAR_TABLE (tables[k]), defalt, alist);
/* At last, change each elements to font names. */ /* At last, change each elements to font names. */
for (; CONSP (alist); alist = XCDR (alist)) for (; CONSP (alist); alist = XCDR (alist))
......
...@@ -936,7 +936,11 @@ enum CHARTAB_SIZE_BITS ...@@ -936,7 +936,11 @@ enum CHARTAB_SIZE_BITS
extern const int chartab_size[4]; extern const int chartab_size[4];
struct Lisp_Sub_Char_Table; /* Most code should use this macro to set non-array Lisp fields in struct
Lisp_Char_Table. For CONTENTS and EXTRAS, use char_table_set_contents
and char_table_set_extras, respectively. */
#define CSET(c, field, value) ((c)->field = (value))
struct Lisp_Char_Table struct Lisp_Char_Table
{ {
...@@ -986,6 +990,7 @@ struct Lisp_Sub_Char_Table ...@@ -986,6 +990,7 @@ struct Lisp_Sub_Char_Table
/* Minimum character covered by the sub char-table. */ /* Minimum character covered by the sub char-table. */
Lisp_Object min_char; Lisp_Object min_char;
/* Use sub_char_table_set_contents to set this. */
Lisp_Object contents[1]; Lisp_Object contents[1];
}; };