diff options
| author | Paul Eggert | 2019-03-04 00:00:39 -0800 |
|---|---|---|
| committer | Paul Eggert | 2019-03-04 00:05:04 -0800 |
| commit | 5c2563a5472cd5580e7af570aa320ac581ad1985 (patch) | |
| tree | fbf88ede49dc0ba527d3925dfc274c230b8cf95f /src/emacs-module.c | |
| parent | d6b3e5bbc5e14c32f3faad9f1481ec16807ac2fe (diff) | |
| download | emacs-5c2563a5472cd5580e7af570aa320ac581ad1985.tar.gz emacs-5c2563a5472cd5580e7af570aa320ac581ad1985.zip | |
Simplify list creation in C code
The main new thing here is that C code can now say
‘list (a, b, c, d, e, f)’ instead of
‘listn (CONSTYPE_HEAP, 6, a, b, c, d, e, f)’,
thus relieving callers of the responsibility of counting
arguments (plus, the code feels more like Lisp). The old
list1 ... list5 functions remain, as they’re probably a bit
faster for small lists.
* src/alloc.c (cons_listn, pure_listn): New functions.
(listn): Omit enum argument.
All callers changed to use either new ‘list’ or ‘pure_list’ macros.
* src/charset.c (Fdefine_charset_internal):
* src/coding.c (detect_coding_system)
(Fset_terminal_coding_system_internal):
* src/frame.c (frame_size_history_add, adjust_frame_size):
* src/gtkutil.c (xg_frame_set_char_size):
* src/keyboard.c (command_loop_1):
* src/nsfns.m (frame_geometry):
* src/widget.c (set_frame_size):
* src/xfaces.c (Fcolor_distance):
* src/xfns.c (frame_geometry):
* src/xterm.c (x_set_window_size_1):
* src/xwidget.c (Fxwidget_size_request):
Prefer list1i, list2i, etc. to open-coding them.
* src/charset.c (Fset_charset_priority):
* src/nsterm.m (append2):
* src/window.c (window_list):
* src/xfaces.c (Fx_list_fonts):
Use nconc2 instead of open-coding it.
* src/eval.c (eval_sub, backtrace_frame_apply):
* src/kqueue.c (kqueue_generate_event):
* src/nsterm.m (performDragOperation:):
* src/pdumper.c (Fpdumper_stats):
* src/w32.c (init_environment):
Prefer list1, list2, etc. to open-coding them.
* src/font.c (font_list_entities):
Parenthesize to avoid expanding new ‘list’ macro.
* src/gtkutil.c (GETSETUP): Rename from MAKE_FLOAT_PAGE_SETUP
to get lines to fit. Move outside the ‘list’ call, since it’s
now a macro.
* src/keymap.c (Fmake_keymap): Simplify.
* src/lisp.h (list, pure_list): New macros.
(list1i): New function.
Diffstat (limited to 'src/emacs-module.c')
| -rw-r--r-- | src/emacs-module.c | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/src/emacs-module.c b/src/emacs-module.c index b70d6cea812..4e2411cb295 100644 --- a/src/emacs-module.c +++ b/src/emacs-module.c | |||
| @@ -1234,42 +1234,38 @@ syms_of_module (void) | |||
| 1234 | 1234 | ||
| 1235 | DEFSYM (Qmodule_load_failed, "module-load-failed"); | 1235 | DEFSYM (Qmodule_load_failed, "module-load-failed"); |
| 1236 | Fput (Qmodule_load_failed, Qerror_conditions, | 1236 | Fput (Qmodule_load_failed, Qerror_conditions, |
| 1237 | listn (CONSTYPE_PURE, 2, Qmodule_load_failed, Qerror)); | 1237 | pure_list (Qmodule_load_failed, Qerror)); |
| 1238 | Fput (Qmodule_load_failed, Qerror_message, | 1238 | Fput (Qmodule_load_failed, Qerror_message, |
| 1239 | build_pure_c_string ("Module load failed")); | 1239 | build_pure_c_string ("Module load failed")); |
| 1240 | 1240 | ||
| 1241 | DEFSYM (Qmodule_open_failed, "module-open-failed"); | 1241 | DEFSYM (Qmodule_open_failed, "module-open-failed"); |
| 1242 | Fput (Qmodule_open_failed, Qerror_conditions, | 1242 | Fput (Qmodule_open_failed, Qerror_conditions, |
| 1243 | listn (CONSTYPE_PURE, 3, | 1243 | pure_list (Qmodule_open_failed, Qmodule_load_failed, Qerror)); |
| 1244 | Qmodule_open_failed, Qmodule_load_failed, Qerror)); | ||
| 1245 | Fput (Qmodule_open_failed, Qerror_message, | 1244 | Fput (Qmodule_open_failed, Qerror_message, |
| 1246 | build_pure_c_string ("Module could not be opened")); | 1245 | build_pure_c_string ("Module could not be opened")); |
| 1247 | 1246 | ||
| 1248 | DEFSYM (Qmodule_not_gpl_compatible, "module-not-gpl-compatible"); | 1247 | DEFSYM (Qmodule_not_gpl_compatible, "module-not-gpl-compatible"); |
| 1249 | Fput (Qmodule_not_gpl_compatible, Qerror_conditions, | 1248 | Fput (Qmodule_not_gpl_compatible, Qerror_conditions, |
| 1250 | listn (CONSTYPE_PURE, 3, | 1249 | pure_list (Qmodule_not_gpl_compatible, Qmodule_load_failed, Qerror)); |
| 1251 | Qmodule_not_gpl_compatible, Qmodule_load_failed, Qerror)); | ||
| 1252 | Fput (Qmodule_not_gpl_compatible, Qerror_message, | 1250 | Fput (Qmodule_not_gpl_compatible, Qerror_message, |
| 1253 | build_pure_c_string ("Module is not GPL compatible")); | 1251 | build_pure_c_string ("Module is not GPL compatible")); |
| 1254 | 1252 | ||
| 1255 | DEFSYM (Qmissing_module_init_function, "missing-module-init-function"); | 1253 | DEFSYM (Qmissing_module_init_function, "missing-module-init-function"); |
| 1256 | Fput (Qmissing_module_init_function, Qerror_conditions, | 1254 | Fput (Qmissing_module_init_function, Qerror_conditions, |
| 1257 | listn (CONSTYPE_PURE, 3, | 1255 | pure_list (Qmissing_module_init_function, Qmodule_load_failed, |
| 1258 | Qmissing_module_init_function, Qmodule_load_failed, Qerror)); | 1256 | Qerror)); |
| 1259 | Fput (Qmissing_module_init_function, Qerror_message, | 1257 | Fput (Qmissing_module_init_function, Qerror_message, |
| 1260 | build_pure_c_string ("Module does not export an " | 1258 | build_pure_c_string ("Module does not export an " |
| 1261 | "initialization function")); | 1259 | "initialization function")); |
| 1262 | 1260 | ||
| 1263 | DEFSYM (Qmodule_init_failed, "module-init-failed"); | 1261 | DEFSYM (Qmodule_init_failed, "module-init-failed"); |
| 1264 | Fput (Qmodule_init_failed, Qerror_conditions, | 1262 | Fput (Qmodule_init_failed, Qerror_conditions, |
| 1265 | listn (CONSTYPE_PURE, 3, | 1263 | pure_list (Qmodule_init_failed, Qmodule_load_failed, Qerror)); |
| 1266 | Qmodule_init_failed, Qmodule_load_failed, Qerror)); | ||
| 1267 | Fput (Qmodule_init_failed, Qerror_message, | 1264 | Fput (Qmodule_init_failed, Qerror_message, |
| 1268 | build_pure_c_string ("Module initialization failed")); | 1265 | build_pure_c_string ("Module initialization failed")); |
| 1269 | 1266 | ||
| 1270 | DEFSYM (Qinvalid_arity, "invalid-arity"); | 1267 | DEFSYM (Qinvalid_arity, "invalid-arity"); |
| 1271 | Fput (Qinvalid_arity, Qerror_conditions, | 1268 | Fput (Qinvalid_arity, Qerror_conditions, pure_list (Qinvalid_arity, Qerror)); |
| 1272 | listn (CONSTYPE_PURE, 2, Qinvalid_arity, Qerror)); | ||
| 1273 | Fput (Qinvalid_arity, Qerror_message, | 1269 | Fput (Qinvalid_arity, Qerror_message, |
| 1274 | build_pure_c_string ("Invalid function arity")); | 1270 | build_pure_c_string ("Invalid function arity")); |
| 1275 | 1271 | ||