diff options
| author | Paul Eggert | 2015-01-05 09:07:45 -0800 |
|---|---|---|
| committer | Paul Eggert | 2015-01-05 10:14:58 -0800 |
| commit | 58f2d6ef32b28a787fcc4e0d98b3f331ceb2a68c (patch) | |
| tree | d6d79ad7b7cceafc78c5a9c54f5be1ac441a8ed7 /src/fileio.c | |
| parent | d2cf05d1bac19d8564d0806f515b9f40fe57f4df (diff) | |
| download | emacs-58f2d6ef32b28a787fcc4e0d98b3f331ceb2a68c.tar.gz emacs-58f2d6ef32b28a787fcc4e0d98b3f331ceb2a68c.zip | |
Compute C decls for DEFSYMs automatically
Fixes Bug#15880.
This patch also makes Q constants (e.g., Qnil) constant addresses
from the C point of view.
* make-docfile.c: Revamp to generate table of symbols, too.
Include <stdbool.h>.
(xstrdup): New function.
(main): Don't process the same file twice.
(SYMBOL): New constant in enum global_type.
(struct symbol): Turn 'value' member into a union, either v.value
for int or v.svalue for string. All uses changed.
(add_global): New arg svalue, which overrides value, so that globals
can have a string value.
(close_emacs_global): New arg num_symbols; all uses changed.
Output lispsym decl.
(write_globals): Output symbol globals too. Output more
ATTRIBUTE_CONST, now that Qnil etc. are C constants.
Output defsym_name table.
(scan_c_file): Move most of guts into ...
(scan_c_stream): ... new function. Scan for DEFSYMs and
record symbols found. Don't read past EOF if file doesn't
end in newline.
* alloc.c, bidi.c, buffer.c, bytecode.c, callint.c, casefiddle:
* casetab.c, category.c, ccl.c, charset.c, chartab.c, cmds.c, coding.c:
* composite.c, data.c, dbusbind.c, decompress.c, dired.c, dispnew.c:
* doc.c, editfns.c, emacs.c, eval.c, fileio.c, fns.c, font.c, fontset.c:
* frame.c, fringe.c, ftfont.c, ftxfont.c, gfilenotify.c, gnutls.c:
* image.c, inotify.c, insdel.c, keyboard.c, keymap.c, lread.c:
* macfont.m, macros.c, minibuf.c, nsfns.m, nsfont.m, nsimage.m:
* nsmenu.m, nsselect.m, nsterm.m, print.c, process.c, profiler.c:
* search.c, sound.c, syntax.c, term.c, terminal.c, textprop.c, undo.c:
* window.c, xdisp.c, xfaces.c, xfns.c, xftfont.c, xmenu.c, xml.c:
* xselect.c, xsettings.c, xterm.c:
Remove Q vars that represent symbols (e.g., Qnil, Qt, Qemacs).
These names are now defined automatically by make-docfile.
* alloc.c (init_symbol): New function.
(Fmake_symbol): Use it.
(c_symbol_p): New function.
(valid_lisp_object_p, purecopy): Use it.
* alloc.c (marked_pinned_symbols):
Use make_lisp_symbol instead of make_lisp_ptr.
(garbage_collect_1): Mark lispsym symbols.
(CHECK_ALLOCATED_AND_LIVE_SYMBOL): New macro.
(mark_object): Use it.
(sweep_symbols): Sweep lispsym symbols.
(symbol_uses_obj): New function.
(which_symbols): Use it. Work for lispsym symbols, too.
(init_alloc_once): Initialize Vpurify_flag here; no need to wait,
since Qt's address is already known now.
(syms_of_alloc): Add lispsym count to symbols_consed.
* buffer.c (init_buffer_once): Compare to Qnil, not to make_number (0),
when testing whether storage is all bits zero.
* dispextern (struct image_type):
* font.c (font_property_table):
* frame.c (struct frame_parm_table, frame_parms):
* keyboard.c (scroll_bar_parts, struct event_head):
* xdisp.c (struct props):
Use XSYMBOL_INIT (Qfoo) and struct Lisp_Symbol * rather than &Qfoo and
Lisp_Object *, since Qfoo is no longer an object whose address can be
taken. All uses changed.
* eval.c (run_hook): New function. Most uses of Frun_hooks changed to
use it, so that they no longer need to take the address of a Lisp sym.
(syms_of_eval): Don't use DEFSYM on Vrun_hooks, as it's a variable.
* frame.c (syms_of_frame): Add defsyms for the frame_parms table.
* keyboard.c (syms_of_keyboard): Don't DEFSYM Qmenu_bar here.
DEFSYM Qdeactivate_mark before the corresponding var.
* keymap.c (syms_of_keymap): Use DEFSYM for Qmenu_bar and Qmode_line
instead of interning their symbols; this avoids duplicates.
(LISP_INITIALLY, TAG_PTR)
(DEFINE_LISP_SYMBOL_BEGIN, DEFINE_LISP_SYMBOL_END, XSYMBOL_INIT):
New macros.
(LISP_INITIALLY_ZERO): Use it.
(enum symbol_interned, enum symbol_redirect, struct Lisp_Symbol)
(EXFUN, DEFUN_ARGS_MANY, DEFUN_ARGS_UNEVALLED, DEFUN_ARGS_*):
Move decls up, to avoid forward uses. Include globals.h earlier, too.
(make_lisp_symbol): New function.
(XSETSYMBOL): Use it.
(DEFSYM): Now just a placeholder for make-docfile.
* lread.c (DEFINE_SYMBOLS): Define, for globals.h.
(intern_sym): New function, with body taken from old intern_driver.
(intern_driver): Use it. Last arg is now Lisp integer, not ptrdiff_t.
All uses changed.
(define_symbol): New function.
(init_obarray): Define the C symbols taken from lispsym.
Use plain DEFSYM for Qt and Qnil.
* syntax.c (init_syntax_once): No need to worry about
Qchar_table_extra_slots.
Diffstat (limited to 'src/fileio.c')
| -rw-r--r-- | src/fileio.c | 99 |
1 files changed, 21 insertions, 78 deletions
diff --git a/src/fileio.c b/src/fileio.c index 0f0fd1a5c8d..15c6f9123a2 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -113,50 +113,10 @@ static bool auto_save_error_occurred; | |||
| 113 | static bool valid_timestamp_file_system; | 113 | static bool valid_timestamp_file_system; |
| 114 | static dev_t timestamp_file_system; | 114 | static dev_t timestamp_file_system; |
| 115 | 115 | ||
| 116 | /* The symbol bound to coding-system-for-read when | ||
| 117 | insert-file-contents is called for recovering a file. This is not | ||
| 118 | an actual coding system name, but just an indicator to tell | ||
| 119 | insert-file-contents to use `emacs-mule' with a special flag for | ||
| 120 | auto saving and recovering a file. */ | ||
| 121 | static Lisp_Object Qauto_save_coding; | ||
| 122 | |||
| 123 | /* Property name of a file name handler, | ||
| 124 | which gives a list of operations it handles.. */ | ||
| 125 | static Lisp_Object Qoperations; | ||
| 126 | |||
| 127 | /* Lisp functions for translating file formats. */ | ||
| 128 | static Lisp_Object Qformat_decode, Qformat_annotate_function; | ||
| 129 | |||
| 130 | /* Lisp function for setting buffer-file-coding-system and the | ||
| 131 | multibyteness of the current buffer after inserting a file. */ | ||
| 132 | static Lisp_Object Qafter_insert_file_set_coding; | ||
| 133 | |||
| 134 | static Lisp_Object Qwrite_region_annotate_functions; | ||
| 135 | /* Each time an annotation function changes the buffer, the new buffer | 116 | /* Each time an annotation function changes the buffer, the new buffer |
| 136 | is added here. */ | 117 | is added here. */ |
| 137 | static Lisp_Object Vwrite_region_annotation_buffers; | 118 | static Lisp_Object Vwrite_region_annotation_buffers; |
| 138 | 119 | ||
| 139 | static Lisp_Object Qdelete_by_moving_to_trash; | ||
| 140 | |||
| 141 | /* Lisp function for moving files to trash. */ | ||
| 142 | static Lisp_Object Qmove_file_to_trash; | ||
| 143 | |||
| 144 | /* Lisp function for recursively copying directories. */ | ||
| 145 | static Lisp_Object Qcopy_directory; | ||
| 146 | |||
| 147 | /* Lisp function for recursively deleting directories. */ | ||
| 148 | static Lisp_Object Qdelete_directory; | ||
| 149 | |||
| 150 | static Lisp_Object Qsubstitute_env_in_file_name; | ||
| 151 | static Lisp_Object Qget_buffer_window_list; | ||
| 152 | |||
| 153 | Lisp_Object Qfile_error, Qfile_notify_error; | ||
| 154 | static Lisp_Object Qfile_already_exists, Qfile_date_error; | ||
| 155 | static Lisp_Object Qexcl; | ||
| 156 | Lisp_Object Qfile_name_history; | ||
| 157 | |||
| 158 | static Lisp_Object Qcar_less_than_car; | ||
| 159 | |||
| 160 | static bool a_write (int, Lisp_Object, ptrdiff_t, ptrdiff_t, | 120 | static bool a_write (int, Lisp_Object, ptrdiff_t, ptrdiff_t, |
| 161 | Lisp_Object *, struct coding_system *); | 121 | Lisp_Object *, struct coding_system *); |
| 162 | static bool e_write (int, Lisp_Object, ptrdiff_t, ptrdiff_t, | 122 | static bool e_write (int, Lisp_Object, ptrdiff_t, ptrdiff_t, |
| @@ -291,43 +251,6 @@ restore_point_unwind (Lisp_Object location) | |||
| 291 | } | 251 | } |
| 292 | 252 | ||
| 293 | 253 | ||
| 294 | static Lisp_Object Qexpand_file_name; | ||
| 295 | static Lisp_Object Qsubstitute_in_file_name; | ||
| 296 | static Lisp_Object Qdirectory_file_name; | ||
| 297 | static Lisp_Object Qfile_name_directory; | ||
| 298 | static Lisp_Object Qfile_name_nondirectory; | ||
| 299 | static Lisp_Object Qunhandled_file_name_directory; | ||
| 300 | static Lisp_Object Qfile_name_as_directory; | ||
| 301 | static Lisp_Object Qcopy_file; | ||
| 302 | static Lisp_Object Qmake_directory_internal; | ||
| 303 | static Lisp_Object Qmake_directory; | ||
| 304 | static Lisp_Object Qdelete_directory_internal; | ||
| 305 | Lisp_Object Qdelete_file; | ||
| 306 | static Lisp_Object Qrename_file; | ||
| 307 | static Lisp_Object Qadd_name_to_file; | ||
| 308 | static Lisp_Object Qmake_symbolic_link; | ||
| 309 | Lisp_Object Qfile_exists_p; | ||
| 310 | static Lisp_Object Qfile_executable_p; | ||
| 311 | static Lisp_Object Qfile_readable_p; | ||
| 312 | static Lisp_Object Qfile_writable_p; | ||
| 313 | static Lisp_Object Qfile_symlink_p; | ||
| 314 | static Lisp_Object Qaccess_file; | ||
| 315 | Lisp_Object Qfile_directory_p; | ||
| 316 | static Lisp_Object Qfile_regular_p; | ||
| 317 | static Lisp_Object Qfile_accessible_directory_p; | ||
| 318 | static Lisp_Object Qfile_modes; | ||
| 319 | static Lisp_Object Qset_file_modes; | ||
| 320 | static Lisp_Object Qset_file_times; | ||
| 321 | static Lisp_Object Qfile_selinux_context; | ||
| 322 | static Lisp_Object Qset_file_selinux_context; | ||
| 323 | static Lisp_Object Qfile_acl; | ||
| 324 | static Lisp_Object Qset_file_acl; | ||
| 325 | static Lisp_Object Qfile_newer_than_file_p; | ||
| 326 | Lisp_Object Qinsert_file_contents; | ||
| 327 | Lisp_Object Qwrite_region; | ||
| 328 | static Lisp_Object Qverify_visited_file_modtime; | ||
| 329 | static Lisp_Object Qset_visited_file_modtime; | ||
| 330 | |||
| 331 | DEFUN ("find-file-name-handler", Ffind_file_name_handler, | 254 | DEFUN ("find-file-name-handler", Ffind_file_name_handler, |
| 332 | Sfind_file_name_handler, 2, 2, 0, | 255 | Sfind_file_name_handler, 2, 2, 0, |
| 333 | doc: /* Return FILENAME's handler function for OPERATION, if it has one. | 256 | doc: /* Return FILENAME's handler function for OPERATION, if it has one. |
| @@ -5866,7 +5789,10 @@ init_fileio (void) | |||
| 5866 | void | 5789 | void |
| 5867 | syms_of_fileio (void) | 5790 | syms_of_fileio (void) |
| 5868 | { | 5791 | { |
| 5792 | /* Property name of a file name handler, | ||
| 5793 | which gives a list of operations it handles. */ | ||
| 5869 | DEFSYM (Qoperations, "operations"); | 5794 | DEFSYM (Qoperations, "operations"); |
| 5795 | |||
| 5870 | DEFSYM (Qexpand_file_name, "expand-file-name"); | 5796 | DEFSYM (Qexpand_file_name, "expand-file-name"); |
| 5871 | DEFSYM (Qsubstitute_in_file_name, "substitute-in-file-name"); | 5797 | DEFSYM (Qsubstitute_in_file_name, "substitute-in-file-name"); |
| 5872 | DEFSYM (Qdirectory_file_name, "directory-file-name"); | 5798 | DEFSYM (Qdirectory_file_name, "directory-file-name"); |
| @@ -5903,6 +5829,12 @@ syms_of_fileio (void) | |||
| 5903 | DEFSYM (Qwrite_region, "write-region"); | 5829 | DEFSYM (Qwrite_region, "write-region"); |
| 5904 | DEFSYM (Qverify_visited_file_modtime, "verify-visited-file-modtime"); | 5830 | DEFSYM (Qverify_visited_file_modtime, "verify-visited-file-modtime"); |
| 5905 | DEFSYM (Qset_visited_file_modtime, "set-visited-file-modtime"); | 5831 | DEFSYM (Qset_visited_file_modtime, "set-visited-file-modtime"); |
| 5832 | |||
| 5833 | /* The symbol bound to coding-system-for-read when | ||
| 5834 | insert-file-contents is called for recovering a file. This is not | ||
| 5835 | an actual coding system name, but just an indicator to tell | ||
| 5836 | insert-file-contents to use `emacs-mule' with a special flag for | ||
| 5837 | auto saving and recovering a file. */ | ||
| 5906 | DEFSYM (Qauto_save_coding, "auto-save-coding"); | 5838 | DEFSYM (Qauto_save_coding, "auto-save-coding"); |
| 5907 | 5839 | ||
| 5908 | DEFSYM (Qfile_name_history, "file-name-history"); | 5840 | DEFSYM (Qfile_name_history, "file-name-history"); |
| @@ -5938,9 +5870,14 @@ On MS-Windows, the value of this variable is largely ignored if | |||
| 5938 | behaves as if file names were encoded in `utf-8'. */); | 5870 | behaves as if file names were encoded in `utf-8'. */); |
| 5939 | Vdefault_file_name_coding_system = Qnil; | 5871 | Vdefault_file_name_coding_system = Qnil; |
| 5940 | 5872 | ||
| 5873 | /* Lisp functions for translating file formats. */ | ||
| 5941 | DEFSYM (Qformat_decode, "format-decode"); | 5874 | DEFSYM (Qformat_decode, "format-decode"); |
| 5942 | DEFSYM (Qformat_annotate_function, "format-annotate-function"); | 5875 | DEFSYM (Qformat_annotate_function, "format-annotate-function"); |
| 5876 | |||
| 5877 | /* Lisp function for setting buffer-file-coding-system and the | ||
| 5878 | multibyteness of the current buffer after inserting a file. */ | ||
| 5943 | DEFSYM (Qafter_insert_file_set_coding, "after-insert-file-set-coding"); | 5879 | DEFSYM (Qafter_insert_file_set_coding, "after-insert-file-set-coding"); |
| 5880 | |||
| 5944 | DEFSYM (Qcar_less_than_car, "car-less-than-car"); | 5881 | DEFSYM (Qcar_less_than_car, "car-less-than-car"); |
| 5945 | 5882 | ||
| 5946 | Fput (Qfile_error, Qerror_conditions, | 5883 | Fput (Qfile_error, Qerror_conditions, |
| @@ -6094,11 +6031,17 @@ When non-nil, certain file deletion commands use the function | |||
| 6094 | This includes interactive calls to `delete-file' and | 6031 | This includes interactive calls to `delete-file' and |
| 6095 | `delete-directory' and the Dired deletion commands. */); | 6032 | `delete-directory' and the Dired deletion commands. */); |
| 6096 | delete_by_moving_to_trash = 0; | 6033 | delete_by_moving_to_trash = 0; |
| 6097 | Qdelete_by_moving_to_trash = intern_c_string ("delete-by-moving-to-trash"); | 6034 | DEFSYM (Qdelete_by_moving_to_trash, "delete-by-moving-to-trash"); |
| 6098 | 6035 | ||
| 6036 | /* Lisp function for moving files to trash. */ | ||
| 6099 | DEFSYM (Qmove_file_to_trash, "move-file-to-trash"); | 6037 | DEFSYM (Qmove_file_to_trash, "move-file-to-trash"); |
| 6038 | |||
| 6039 | /* Lisp function for recursively copying directories. */ | ||
| 6100 | DEFSYM (Qcopy_directory, "copy-directory"); | 6040 | DEFSYM (Qcopy_directory, "copy-directory"); |
| 6041 | |||
| 6042 | /* Lisp function for recursively deleting directories. */ | ||
| 6101 | DEFSYM (Qdelete_directory, "delete-directory"); | 6043 | DEFSYM (Qdelete_directory, "delete-directory"); |
| 6044 | |||
| 6102 | DEFSYM (Qsubstitute_env_in_file_name, "substitute-env-in-file-name"); | 6045 | DEFSYM (Qsubstitute_env_in_file_name, "substitute-env-in-file-name"); |
| 6103 | DEFSYM (Qget_buffer_window_list, "get-buffer-window-list"); | 6046 | DEFSYM (Qget_buffer_window_list, "get-buffer-window-list"); |
| 6104 | 6047 | ||