diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 23 | ||||
| -rw-r--r-- | src/alloc.c | 20 | ||||
| -rw-r--r-- | src/buffer.c | 7 | ||||
| -rw-r--r-- | src/buffer.h | 61 | ||||
| -rw-r--r-- | src/dired.c | 4 | ||||
| -rw-r--r-- | src/editfns.c | 4 | ||||
| -rw-r--r-- | src/fileio.c | 4 | ||||
| -rw-r--r-- | src/font.c | 2 | ||||
| -rw-r--r-- | src/ftfont.c | 2 | ||||
| -rw-r--r-- | src/gtkutil.c | 2 | ||||
| -rw-r--r-- | src/keymap.c | 2 | ||||
| -rw-r--r-- | src/lisp.h | 63 | ||||
| -rw-r--r-- | src/lread.c | 2 | ||||
| -rw-r--r-- | src/nsmenu.m | 2 | ||||
| -rw-r--r-- | src/nsterm.m | 2 | ||||
| -rw-r--r-- | src/xfns.c | 2 | ||||
| -rw-r--r-- | src/xmenu.c | 10 | ||||
| -rw-r--r-- | src/xselect.c | 2 |
18 files changed, 135 insertions, 79 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 115b8d42915..c85e0a789ea 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,26 @@ | |||
| 1 | 2013-01-17 Dmitry Antipov <dmantipov@yandex.ru> | ||
| 2 | |||
| 3 | * lisp.h (toplevel): Add comment about using Lisp_Save_Value | ||
| 4 | objects, related functions and macros. | ||
| 5 | (make_save_value): Adjust prototype. | ||
| 6 | (make_save_pointer): New prototype. | ||
| 7 | (SAFE_NALLOCA): Fix indentation. Use make_save_pointer. | ||
| 8 | (SAFE_ALLOCA_LISP): Adjust make_save_value usage. | ||
| 9 | * alloc.c (format_save_value): Rename to make_save_value. | ||
| 10 | (make_save_pointer): New function. | ||
| 11 | (record_xmalloc): Use make_save_pointer. | ||
| 12 | * dired.c, editfns.c, fileio.c, font.c, gtkutil.c, lread.c: | ||
| 13 | * nsmenu.m, nsterm.m, xfns.c, xmenu.c, xselect.c, keymap.c: | ||
| 14 | Change users of make_save_value to make_save_pointer. | ||
| 15 | Likewise for format_save_value and make_save_value. | ||
| 16 | |||
| 17 | 2013-01-17 Dmitry Antipov <dmantipov@yandex.ru> | ||
| 18 | |||
| 19 | * buffer.h (NARROWED, BUF_NARROWED): Drop unused macros. | ||
| 20 | (DECODE_POSITION, BUFFER_CHECK_INDIRECTION): Fix indentation. | ||
| 21 | * buffer.c (toplevel, syms_of_buffer): Drop old commented-out | ||
| 22 | debugging stubs. | ||
| 23 | |||
| 1 | 2013-01-15 Paul Eggert <eggert@cs.ucla.edu> | 24 | 2013-01-15 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 25 | ||
| 3 | * alloc.c (free_save_value): Now static. | 26 | * alloc.c (free_save_value): Now static. |
diff --git a/src/alloc.c b/src/alloc.c index 7275a01bb73..a2e7282bb60 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -845,7 +845,7 @@ void * | |||
| 845 | record_xmalloc (size_t size) | 845 | record_xmalloc (size_t size) |
| 846 | { | 846 | { |
| 847 | void *p = xmalloc (size); | 847 | void *p = xmalloc (size); |
| 848 | record_unwind_protect (safe_alloca_unwind, make_save_value (p, 0)); | 848 | record_unwind_protect (safe_alloca_unwind, make_save_pointer (p)); |
| 849 | return p; | 849 | return p; |
| 850 | } | 850 | } |
| 851 | 851 | ||
| @@ -3356,7 +3356,7 @@ free_misc (Lisp_Object misc) | |||
| 3356 | and `o' for Lisp_Object. Up to 4 objects can be specified. */ | 3356 | and `o' for Lisp_Object. Up to 4 objects can be specified. */ |
| 3357 | 3357 | ||
| 3358 | Lisp_Object | 3358 | Lisp_Object |
| 3359 | format_save_value (const char *fmt, ...) | 3359 | make_save_value (const char *fmt, ...) |
| 3360 | { | 3360 | { |
| 3361 | va_list ap; | 3361 | va_list ap; |
| 3362 | int len = strlen (fmt); | 3362 | int len = strlen (fmt); |
| @@ -3404,15 +3404,19 @@ format_save_value (const char *fmt, ...) | |||
| 3404 | return val; | 3404 | return val; |
| 3405 | } | 3405 | } |
| 3406 | 3406 | ||
| 3407 | /* Return a Lisp_Save_Value object containing POINTER and INTEGER. | 3407 | /* The most common task it to save just one C pointer. */ |
| 3408 | Most code should use this to package C integers and pointers | ||
| 3409 | to call record_unwind_protect. The unwind function can get the | ||
| 3410 | C values back using XSAVE_POINTER and XSAVE_INTEGER. */ | ||
| 3411 | 3408 | ||
| 3412 | Lisp_Object | 3409 | Lisp_Object |
| 3413 | make_save_value (void *pointer, ptrdiff_t integer) | 3410 | make_save_pointer (void *pointer) |
| 3414 | { | 3411 | { |
| 3415 | return format_save_value ("pi", pointer, integer); | 3412 | Lisp_Object val = allocate_misc (Lisp_Misc_Save_Value); |
| 3413 | struct Lisp_Save_Value *p = XSAVE_VALUE (val); | ||
| 3414 | |||
| 3415 | p->area = 0; | ||
| 3416 | p->type0 = SAVE_POINTER; | ||
| 3417 | p->data[0].pointer = pointer; | ||
| 3418 | p->type1 = p->type2 = p->type3 = SAVE_UNUSED; | ||
| 3419 | return val; | ||
| 3416 | } | 3420 | } |
| 3417 | 3421 | ||
| 3418 | /* Free a Lisp_Save_Value object. Do not use this function | 3422 | /* Free a Lisp_Save_Value object. Do not use this function |
diff --git a/src/buffer.c b/src/buffer.c index 218ae1a7d11..66581cb7828 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -372,9 +372,6 @@ bset_zv_marker (struct buffer *b, Lisp_Object val) | |||
| 372 | b->INTERNAL_FIELD (zv_marker) = val; | 372 | b->INTERNAL_FIELD (zv_marker) = val; |
| 373 | } | 373 | } |
| 374 | 374 | ||
| 375 | /* For debugging; temporary. See set_buffer_internal. */ | ||
| 376 | /* Lisp_Object Qlisp_mode, Vcheck_symbol; */ | ||
| 377 | |||
| 378 | void | 375 | void |
| 379 | nsberror (Lisp_Object spec) | 376 | nsberror (Lisp_Object spec) |
| 380 | { | 377 | { |
| @@ -6003,10 +6000,6 @@ simple case that you moved off with C-b means scrolling just one line. | |||
| 6003 | window scrolls by a full window height. Meaningful values are | 6000 | window scrolls by a full window height. Meaningful values are |
| 6004 | between 0.0 and 1.0, inclusive. */); | 6001 | between 0.0 and 1.0, inclusive. */); |
| 6005 | 6002 | ||
| 6006 | /*DEFVAR_LISP ("debug-check-symbol", &Vcheck_symbol, | ||
| 6007 | "Don't ask."); | ||
| 6008 | */ | ||
| 6009 | |||
| 6010 | DEFVAR_LISP ("before-change-functions", Vbefore_change_functions, | 6003 | DEFVAR_LISP ("before-change-functions", Vbefore_change_functions, |
| 6011 | doc: /* List of functions to call before each text change. | 6004 | doc: /* List of functions to call before each text change. |
| 6012 | Two arguments are passed to each function: the positions of | 6005 | Two arguments are passed to each function: the positions of |
diff --git a/src/buffer.h b/src/buffer.h index b4cc21d675d..276cca32e48 100644 --- a/src/buffer.h +++ b/src/buffer.h | |||
| @@ -82,9 +82,6 @@ INLINE_HEADER_BEGIN | |||
| 82 | /* Size of gap. */ | 82 | /* Size of gap. */ |
| 83 | #define GAP_SIZE (current_buffer->text->gap_size) | 83 | #define GAP_SIZE (current_buffer->text->gap_size) |
| 84 | 84 | ||
| 85 | /* Is the current buffer narrowed? */ | ||
| 86 | #define NARROWED ((BEGV != BEG) || (ZV != Z)) | ||
| 87 | |||
| 88 | /* Modification count. */ | 85 | /* Modification count. */ |
| 89 | #define MODIFF (current_buffer->text->modiff) | 86 | #define MODIFF (current_buffer->text->modiff) |
| 90 | 87 | ||
| @@ -173,10 +170,6 @@ INLINE_HEADER_BEGIN | |||
| 173 | /* Size of gap. */ | 170 | /* Size of gap. */ |
| 174 | #define BUF_GAP_SIZE(buf) ((buf)->text->gap_size) | 171 | #define BUF_GAP_SIZE(buf) ((buf)->text->gap_size) |
| 175 | 172 | ||
| 176 | /* Is this buffer narrowed? */ | ||
| 177 | #define BUF_NARROWED(buf) ((BUF_BEGV (buf) != BUF_BEG (buf)) \ | ||
| 178 | || (BUF_ZV (buf) != BUF_Z (buf))) | ||
| 179 | |||
| 180 | /* Modification count. */ | 173 | /* Modification count. */ |
| 181 | #define BUF_MODIFF(buf) ((buf)->text->modiff) | 174 | #define BUF_MODIFF(buf) ((buf)->text->modiff) |
| 182 | 175 | ||
| @@ -294,24 +287,24 @@ extern void enlarge_buffer_text (struct buffer *, ptrdiff_t); | |||
| 294 | /* Access a Lisp position value in POS, | 287 | /* Access a Lisp position value in POS, |
| 295 | and store the charpos in CHARPOS and the bytepos in BYTEPOS. */ | 288 | and store the charpos in CHARPOS and the bytepos in BYTEPOS. */ |
| 296 | 289 | ||
| 297 | #define DECODE_POSITION(charpos, bytepos, pos) \ | 290 | #define DECODE_POSITION(charpos, bytepos, pos) \ |
| 298 | do \ | 291 | do \ |
| 299 | { \ | 292 | { \ |
| 300 | Lisp_Object __pos = (pos); \ | 293 | Lisp_Object __pos = (pos); \ |
| 301 | if (NUMBERP (__pos)) \ | 294 | if (NUMBERP (__pos)) \ |
| 302 | { \ | 295 | { \ |
| 303 | charpos = __pos; \ | 296 | charpos = __pos; \ |
| 304 | bytepos = buf_charpos_to_bytepos (current_buffer, __pos); \ | 297 | bytepos = buf_charpos_to_bytepos (current_buffer, __pos); \ |
| 305 | } \ | 298 | } \ |
| 306 | else if (MARKERP (__pos)) \ | 299 | else if (MARKERP (__pos)) \ |
| 307 | { \ | 300 | { \ |
| 308 | charpos = marker_position (__pos); \ | 301 | charpos = marker_position (__pos); \ |
| 309 | bytepos = marker_byte_position (__pos); \ | 302 | bytepos = marker_byte_position (__pos); \ |
| 310 | } \ | 303 | } \ |
| 311 | else \ | 304 | else \ |
| 312 | wrong_type_argument (Qinteger_or_marker_p, __pos); \ | 305 | wrong_type_argument (Qinteger_or_marker_p, __pos); \ |
| 313 | } \ | 306 | } \ |
| 314 | while (0) | 307 | while (0) |
| 315 | 308 | ||
| 316 | /* Maximum number of bytes in a buffer. | 309 | /* Maximum number of bytes in a buffer. |
| 317 | A buffer cannot contain more bytes than a 1-origin fixnum can represent, | 310 | A buffer cannot contain more bytes than a 1-origin fixnum can represent, |
| @@ -1009,15 +1002,15 @@ bset_width_table (struct buffer *b, Lisp_Object val) | |||
| 1009 | #define BUFFER_CHECK_INDIRECTION(b) \ | 1002 | #define BUFFER_CHECK_INDIRECTION(b) \ |
| 1010 | do { \ | 1003 | do { \ |
| 1011 | if (BUFFER_LIVE_P (b)) \ | 1004 | if (BUFFER_LIVE_P (b)) \ |
| 1012 | { \ | 1005 | { \ |
| 1013 | if (b->base_buffer) \ | 1006 | if (b->base_buffer) \ |
| 1014 | { \ | 1007 | { \ |
| 1015 | eassert (b->indirections == -1); \ | 1008 | eassert (b->indirections == -1); \ |
| 1016 | eassert (b->base_buffer->indirections > 0); \ | 1009 | eassert (b->base_buffer->indirections > 0); \ |
| 1017 | } \ | 1010 | } \ |
| 1018 | else \ | 1011 | else \ |
| 1019 | eassert (b->indirections >= 0); \ | 1012 | eassert (b->indirections >= 0); \ |
| 1020 | } \ | 1013 | } \ |
| 1021 | } while (0) | 1014 | } while (0) |
| 1022 | 1015 | ||
| 1023 | /* Chain of all buffers, including killed ones. */ | 1016 | /* Chain of all buffers, including killed ones. */ |
diff --git a/src/dired.c b/src/dired.c index 3dca9d24f67..a4c8621e9c0 100644 --- a/src/dired.c +++ b/src/dired.c | |||
| @@ -152,7 +152,7 @@ directory_files_internal (Lisp_Object directory, Lisp_Object full, | |||
| 152 | file-attributes on filenames, both of which can throw, so we must | 152 | file-attributes on filenames, both of which can throw, so we must |
| 153 | do a proper unwind-protect. */ | 153 | do a proper unwind-protect. */ |
| 154 | record_unwind_protect (directory_files_internal_unwind, | 154 | record_unwind_protect (directory_files_internal_unwind, |
| 155 | make_save_value (d, 0)); | 155 | make_save_pointer (d)); |
| 156 | 156 | ||
| 157 | #ifdef WINDOWSNT | 157 | #ifdef WINDOWSNT |
| 158 | if (attrs) | 158 | if (attrs) |
| @@ -465,7 +465,7 @@ file_name_completion (Lisp_Object file, Lisp_Object dirname, bool all_flag, | |||
| 465 | report_file_error ("Opening directory", Fcons (dirname, Qnil)); | 465 | report_file_error ("Opening directory", Fcons (dirname, Qnil)); |
| 466 | 466 | ||
| 467 | record_unwind_protect (directory_files_internal_unwind, | 467 | record_unwind_protect (directory_files_internal_unwind, |
| 468 | make_save_value (d, 0)); | 468 | make_save_pointer (d)); |
| 469 | 469 | ||
| 470 | /* Loop reading blocks */ | 470 | /* Loop reading blocks */ |
| 471 | /* (att3b compiler bug requires do a null comparison this way) */ | 471 | /* (att3b compiler bug requires do a null comparison this way) */ |
diff --git a/src/editfns.c b/src/editfns.c index 8910b66e4d3..197950517b7 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -833,7 +833,7 @@ This function does not move point. */) | |||
| 833 | Lisp_Object | 833 | Lisp_Object |
| 834 | save_excursion_save (void) | 834 | save_excursion_save (void) |
| 835 | { | 835 | { |
| 836 | return format_save_value | 836 | return make_save_value |
| 837 | ("oooo", | 837 | ("oooo", |
| 838 | Fpoint_marker (), | 838 | Fpoint_marker (), |
| 839 | /* Do not copy the mark if it points to nowhere. */ | 839 | /* Do not copy the mark if it points to nowhere. */ |
| @@ -4249,7 +4249,7 @@ usage: (format STRING &rest OBJECTS) */) | |||
| 4249 | { | 4249 | { |
| 4250 | buf = xmalloc (bufsize); | 4250 | buf = xmalloc (bufsize); |
| 4251 | sa_must_free = 1; | 4251 | sa_must_free = 1; |
| 4252 | buf_save_value = make_save_value (buf, 0); | 4252 | buf_save_value = make_save_pointer (buf); |
| 4253 | record_unwind_protect (safe_alloca_unwind, buf_save_value); | 4253 | record_unwind_protect (safe_alloca_unwind, buf_save_value); |
| 4254 | memcpy (buf, initial_buffer, used); | 4254 | memcpy (buf, initial_buffer, used); |
| 4255 | } | 4255 | } |
diff --git a/src/fileio.c b/src/fileio.c index 87d945c1e5e..8d711e8e6bf 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -4249,7 +4249,7 @@ by calling `format-decode', which see. */) | |||
| 4249 | to be signaled after decoding the text we read. */ | 4249 | to be signaled after decoding the text we read. */ |
| 4250 | nbytes = internal_condition_case_1 | 4250 | nbytes = internal_condition_case_1 |
| 4251 | (read_non_regular, | 4251 | (read_non_regular, |
| 4252 | format_save_value ("iii", (ptrdiff_t) fd, inserted, trytry), | 4252 | make_save_value ("iii", (ptrdiff_t) fd, inserted, trytry), |
| 4253 | Qerror, read_non_regular_quit); | 4253 | Qerror, read_non_regular_quit); |
| 4254 | 4254 | ||
| 4255 | if (NILP (nbytes)) | 4255 | if (NILP (nbytes)) |
| @@ -5608,7 +5608,7 @@ A non-nil CURRENT-ONLY argument means save only current buffer. */) | |||
| 5608 | } | 5608 | } |
| 5609 | 5609 | ||
| 5610 | record_unwind_protect (do_auto_save_unwind, | 5610 | record_unwind_protect (do_auto_save_unwind, |
| 5611 | make_save_value (stream, 0)); | 5611 | make_save_pointer (stream)); |
| 5612 | record_unwind_protect (do_auto_save_unwind_1, | 5612 | record_unwind_protect (do_auto_save_unwind_1, |
| 5613 | make_number (minibuffer_auto_raise)); | 5613 | make_number (minibuffer_auto_raise)); |
| 5614 | minibuffer_auto_raise = 0; | 5614 | minibuffer_auto_raise = 0; |
diff --git a/src/font.c b/src/font.c index 89931f6ec76..18caf751643 100644 --- a/src/font.c +++ b/src/font.c | |||
| @@ -1861,7 +1861,7 @@ otf_open (Lisp_Object file) | |||
| 1861 | else | 1861 | else |
| 1862 | { | 1862 | { |
| 1863 | otf = STRINGP (file) ? OTF_open (SSDATA (file)) : NULL; | 1863 | otf = STRINGP (file) ? OTF_open (SSDATA (file)) : NULL; |
| 1864 | val = make_save_value (otf, 0); | 1864 | val = make_save_pointer (otf); |
| 1865 | otf_list = Fcons (Fcons (file, val), otf_list); | 1865 | otf_list = Fcons (Fcons (file, val), otf_list); |
| 1866 | } | 1866 | } |
| 1867 | return otf; | 1867 | return otf; |
diff --git a/src/ftfont.c b/src/ftfont.c index 5bf91832c7c..03e40bf2e46 100644 --- a/src/ftfont.c +++ b/src/ftfont.c | |||
| @@ -393,7 +393,7 @@ ftfont_lookup_cache (Lisp_Object key, enum ftfont_cache_for cache_for) | |||
| 393 | cache_data = xmalloc (sizeof *cache_data); | 393 | cache_data = xmalloc (sizeof *cache_data); |
| 394 | cache_data->ft_face = NULL; | 394 | cache_data->ft_face = NULL; |
| 395 | cache_data->fc_charset = NULL; | 395 | cache_data->fc_charset = NULL; |
| 396 | val = make_save_value (cache_data, 0); | 396 | val = make_save_value ("pi", cache_data, 0); |
| 397 | cache = Fcons (Qnil, val); | 397 | cache = Fcons (Qnil, val); |
| 398 | Fputhash (key, cache, ft_face_cache); | 398 | Fputhash (key, cache, ft_face_cache); |
| 399 | } | 399 | } |
diff --git a/src/gtkutil.c b/src/gtkutil.c index f045deacd33..d5bc159c063 100644 --- a/src/gtkutil.c +++ b/src/gtkutil.c | |||
| @@ -1716,7 +1716,7 @@ xg_dialog_run (FRAME_PTR f, GtkWidget *w) | |||
| 1716 | g_signal_connect (G_OBJECT (w), "delete-event", G_CALLBACK (gtk_true), NULL); | 1716 | g_signal_connect (G_OBJECT (w), "delete-event", G_CALLBACK (gtk_true), NULL); |
| 1717 | gtk_widget_show (w); | 1717 | gtk_widget_show (w); |
| 1718 | 1718 | ||
| 1719 | record_unwind_protect (pop_down_dialog, make_save_value (&dd, 0)); | 1719 | record_unwind_protect (pop_down_dialog, make_save_pointer (&dd)); |
| 1720 | 1720 | ||
| 1721 | (void) xg_maybe_add_timer (&dd); | 1721 | (void) xg_maybe_add_timer (&dd); |
| 1722 | g_main_loop_run (dd.loop); | 1722 | g_main_loop_run (dd.loop); |
diff --git a/src/keymap.c b/src/keymap.c index a9266120e86..1e201e06dc3 100644 --- a/src/keymap.c +++ b/src/keymap.c | |||
| @@ -610,7 +610,7 @@ map_keymap_internal (Lisp_Object map, | |||
| 610 | } | 610 | } |
| 611 | else if (CHAR_TABLE_P (binding)) | 611 | else if (CHAR_TABLE_P (binding)) |
| 612 | map_char_table (map_keymap_char_table_item, Qnil, binding, | 612 | map_char_table (map_keymap_char_table_item, Qnil, binding, |
| 613 | format_save_value ("ppo", fun, data, args)); | 613 | make_save_value ("ppo", fun, data, args)); |
| 614 | } | 614 | } |
| 615 | UNGCPRO; | 615 | UNGCPRO; |
| 616 | return tail; | 616 | return tail; |
diff --git a/src/lisp.h b/src/lisp.h index 31028e14679..cf4dd22e364 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -1393,7 +1393,50 @@ enum | |||
| 1393 | SAVE_OBJECT | 1393 | SAVE_OBJECT |
| 1394 | }; | 1394 | }; |
| 1395 | 1395 | ||
| 1396 | /* Special object used to hold a different values for later use. */ | 1396 | /* Special object used to hold a different values for later use. |
| 1397 | |||
| 1398 | This is mostly used to package C integers and pointers to call | ||
| 1399 | record_unwind_protect. Typical task is to pass just one C pointer | ||
| 1400 | to unwind function. You should pack pointer with make_save_pointer | ||
| 1401 | and then get it back with XSAVE_POINTER, e.g.: | ||
| 1402 | |||
| 1403 | ... | ||
| 1404 | struct my_data *md = get_my_data (); | ||
| 1405 | record_unwind_protect (my_unwind, make_save_pointer (md)); | ||
| 1406 | ... | ||
| 1407 | |||
| 1408 | Lisp_Object my_unwind (Lisp_Object arg) | ||
| 1409 | { | ||
| 1410 | struct my_data *md = XSAVE_POINTER (arg, 0); | ||
| 1411 | ... | ||
| 1412 | } | ||
| 1413 | |||
| 1414 | If yon need to pass more than just one C pointer, you should | ||
| 1415 | use make_save_value. This function allows you to pack up to | ||
| 1416 | 4 integers, pointers or Lisp_Objects and conveniently get them | ||
| 1417 | back with XSAVE_POINTER, XSAVE_INTEGER and XSAVE_OBJECT macros: | ||
| 1418 | |||
| 1419 | ... | ||
| 1420 | struct my_data *md = get_my_data (); | ||
| 1421 | ptrdiff_t my_offset = get_my_offset (); | ||
| 1422 | Lisp_Object my_object = get_my_object (); | ||
| 1423 | record_unwind_protect | ||
| 1424 | (my_unwind, make_save_value ("pio", md, my_offset, my_object)); | ||
| 1425 | ... | ||
| 1426 | |||
| 1427 | Lisp_Object my_unwind (Lisp_Object arg) | ||
| 1428 | { | ||
| 1429 | struct my_data *md = XSAVE_POINTER (arg, 0); | ||
| 1430 | ptrdiff_t my_offset = XSAVE_INTEGER (arg, 1); | ||
| 1431 | Lisp_Object my_object = XSAVE_OBJECT (arg, 2); | ||
| 1432 | ... | ||
| 1433 | } | ||
| 1434 | |||
| 1435 | If ENABLE_CHECKING is in effect, XSAVE_xxx macros do type checking of the | ||
| 1436 | saved objects and raise eassert if type of the saved object doesn't match | ||
| 1437 | the type which is extracted. In the example above, XSAVE_INTEGER (arg, 2) | ||
| 1438 | or XSAVE_OBJECT (arg, 1) are wrong because integer was saved in slot 1 and | ||
| 1439 | Lisp_Object was saved in slot 2 of ARG. */ | ||
| 1397 | 1440 | ||
| 1398 | struct Lisp_Save_Value | 1441 | struct Lisp_Save_Value |
| 1399 | { | 1442 | { |
| @@ -3023,8 +3066,8 @@ extern bool abort_on_gc; | |||
| 3023 | extern Lisp_Object make_float (double); | 3066 | extern Lisp_Object make_float (double); |
| 3024 | extern void display_malloc_warning (void); | 3067 | extern void display_malloc_warning (void); |
| 3025 | extern ptrdiff_t inhibit_garbage_collection (void); | 3068 | extern ptrdiff_t inhibit_garbage_collection (void); |
| 3026 | extern Lisp_Object format_save_value (const char *, ...); | 3069 | extern Lisp_Object make_save_value (const char *, ...); |
| 3027 | extern Lisp_Object make_save_value (void *, ptrdiff_t); | 3070 | extern Lisp_Object make_save_pointer (void *); |
| 3028 | extern Lisp_Object build_overlay (Lisp_Object, Lisp_Object, Lisp_Object); | 3071 | extern Lisp_Object build_overlay (Lisp_Object, Lisp_Object, Lisp_Object); |
| 3029 | extern void free_marker (Lisp_Object); | 3072 | extern void free_marker (Lisp_Object); |
| 3030 | extern void free_cons (struct Lisp_Cons *); | 3073 | extern void free_cons (struct Lisp_Cons *); |
| @@ -3706,16 +3749,16 @@ extern void *record_xmalloc (size_t); | |||
| 3706 | NITEMS items, each of the same type as *BUF. MULTIPLIER must | 3749 | NITEMS items, each of the same type as *BUF. MULTIPLIER must |
| 3707 | positive. The code is tuned for MULTIPLIER being a constant. */ | 3750 | positive. The code is tuned for MULTIPLIER being a constant. */ |
| 3708 | 3751 | ||
| 3709 | #define SAFE_NALLOCA(buf, multiplier, nitems) \ | 3752 | #define SAFE_NALLOCA(buf, multiplier, nitems) \ |
| 3710 | do { \ | 3753 | do { \ |
| 3711 | if ((nitems) <= MAX_ALLOCA / sizeof *(buf) / (multiplier)) \ | 3754 | if ((nitems) <= MAX_ALLOCA / sizeof *(buf) / (multiplier)) \ |
| 3712 | (buf) = alloca (sizeof *(buf) * (multiplier) * (nitems)); \ | 3755 | (buf) = alloca (sizeof *(buf) * (multiplier) * (nitems)); \ |
| 3713 | else \ | 3756 | else \ |
| 3714 | { \ | 3757 | { \ |
| 3715 | (buf) = xnmalloc (nitems, sizeof *(buf) * (multiplier)); \ | 3758 | (buf) = xnmalloc (nitems, sizeof *(buf) * (multiplier)); \ |
| 3716 | sa_must_free = 1; \ | 3759 | sa_must_free = 1; \ |
| 3717 | record_unwind_protect (safe_alloca_unwind, \ | 3760 | record_unwind_protect (safe_alloca_unwind, \ |
| 3718 | make_save_value (buf, 0)); \ | 3761 | make_save_pointer (buf)); \ |
| 3719 | } \ | 3762 | } \ |
| 3720 | } while (0) | 3763 | } while (0) |
| 3721 | 3764 | ||
| @@ -3740,7 +3783,7 @@ extern void *record_xmalloc (size_t); | |||
| 3740 | { \ | 3783 | { \ |
| 3741 | Lisp_Object arg_; \ | 3784 | Lisp_Object arg_; \ |
| 3742 | buf = xmalloc ((nelt) * word_size); \ | 3785 | buf = xmalloc ((nelt) * word_size); \ |
| 3743 | arg_ = make_save_value (buf, nelt); \ | 3786 | arg_ = make_save_value ("pi", buf, nelt); \ |
| 3744 | XSAVE_VALUE (arg_)->area = 1; \ | 3787 | XSAVE_VALUE (arg_)->area = 1; \ |
| 3745 | sa_must_free = 1; \ | 3788 | sa_must_free = 1; \ |
| 3746 | record_unwind_protect (safe_alloca_unwind, arg_); \ | 3789 | record_unwind_protect (safe_alloca_unwind, arg_); \ |
diff --git a/src/lread.c b/src/lread.c index a01cf099b49..09eccb0fb30 100644 --- a/src/lread.c +++ b/src/lread.c | |||
| @@ -1298,7 +1298,7 @@ Return t if the file exists and loads successfully. */) | |||
| 1298 | message_with_string ("Loading %s...", file, 1); | 1298 | message_with_string ("Loading %s...", file, 1); |
| 1299 | } | 1299 | } |
| 1300 | 1300 | ||
| 1301 | record_unwind_protect (load_unwind, make_save_value (stream, 0)); | 1301 | record_unwind_protect (load_unwind, make_save_pointer (stream)); |
| 1302 | record_unwind_protect (load_descriptor_unwind, load_descriptor_list); | 1302 | record_unwind_protect (load_descriptor_unwind, load_descriptor_list); |
| 1303 | specbind (Qload_file_name, found); | 1303 | specbind (Qload_file_name, found); |
| 1304 | specbind (Qinhibit_file_name_operation, Qnil); | 1304 | specbind (Qinhibit_file_name_operation, Qnil); |
diff --git a/src/nsmenu.m b/src/nsmenu.m index b0369e76a27..6899e3575f5 100644 --- a/src/nsmenu.m +++ b/src/nsmenu.m | |||
| @@ -1440,7 +1440,7 @@ ns_popup_dialog (Lisp_Object position, Lisp_Object contents, Lisp_Object header) | |||
| 1440 | unwind_data->pool = pool; | 1440 | unwind_data->pool = pool; |
| 1441 | unwind_data->dialog = dialog; | 1441 | unwind_data->dialog = dialog; |
| 1442 | 1442 | ||
| 1443 | record_unwind_protect (pop_down_menu, make_save_value (unwind_data, 0)); | 1443 | record_unwind_protect (pop_down_menu, make_save_pointer (unwind_data)); |
| 1444 | popup_activated_flag = 1; | 1444 | popup_activated_flag = 1; |
| 1445 | tem = [dialog runDialogAt: p]; | 1445 | tem = [dialog runDialogAt: p]; |
| 1446 | unbind_to (specpdl_count, Qnil); /* calls pop_down_menu */ | 1446 | unbind_to (specpdl_count, Qnil); /* calls pop_down_menu */ |
diff --git a/src/nsterm.m b/src/nsterm.m index 48efac3f70b..d346f05624b 100644 --- a/src/nsterm.m +++ b/src/nsterm.m | |||
| @@ -3677,7 +3677,7 @@ ns_set_vertical_scroll_bar (struct window *window, | |||
| 3677 | } | 3677 | } |
| 3678 | 3678 | ||
| 3679 | bar = [[EmacsScroller alloc] initFrame: r window: win]; | 3679 | bar = [[EmacsScroller alloc] initFrame: r window: win]; |
| 3680 | wset_vertical_scroll_bar (window, make_save_value (bar, 0)); | 3680 | wset_vertical_scroll_bar (window, make_save_pointer (bar)); |
| 3681 | } | 3681 | } |
| 3682 | else | 3682 | else |
| 3683 | { | 3683 | { |
diff --git a/src/xfns.c b/src/xfns.c index 65148d1c9e1..f01983fea4d 100644 --- a/src/xfns.c +++ b/src/xfns.c | |||
| @@ -5416,7 +5416,7 @@ Otherwise, if ONLY-DIR-P is non-nil, the user can only select directories. */) | |||
| 5416 | XmStringFree (default_xmstring); | 5416 | XmStringFree (default_xmstring); |
| 5417 | } | 5417 | } |
| 5418 | 5418 | ||
| 5419 | record_unwind_protect (clean_up_file_dialog, make_save_value (dialog, 0)); | 5419 | record_unwind_protect (clean_up_file_dialog, make_save_pointer (dialog)); |
| 5420 | 5420 | ||
| 5421 | /* Process events until the user presses Cancel or OK. */ | 5421 | /* Process events until the user presses Cancel or OK. */ |
| 5422 | x_menu_set_in_use (1); | 5422 | x_menu_set_in_use (1); |
diff --git a/src/xmenu.c b/src/xmenu.c index 7f6914d26ac..958cd220393 100644 --- a/src/xmenu.c +++ b/src/xmenu.c | |||
| @@ -1477,7 +1477,7 @@ create_and_show_popup_menu (FRAME_PTR f, widget_value *first_wv, int x, int y, | |||
| 1477 | gtk_menu_popup (GTK_MENU (menu), 0, 0, pos_func, &popup_x_y, i, | 1477 | gtk_menu_popup (GTK_MENU (menu), 0, 0, pos_func, &popup_x_y, i, |
| 1478 | timestamp ? timestamp : gtk_get_current_event_time ()); | 1478 | timestamp ? timestamp : gtk_get_current_event_time ()); |
| 1479 | 1479 | ||
| 1480 | record_unwind_protect (pop_down_menu, make_save_value (menu, 0)); | 1480 | record_unwind_protect (pop_down_menu, make_save_pointer (menu)); |
| 1481 | 1481 | ||
| 1482 | if (gtk_widget_get_mapped (menu)) | 1482 | if (gtk_widget_get_mapped (menu)) |
| 1483 | { | 1483 | { |
| @@ -1826,7 +1826,7 @@ xmenu_show (FRAME_PTR f, int x, int y, bool for_click, bool keymaps, | |||
| 1826 | /* Make sure to free the widget_value objects we used to specify the | 1826 | /* Make sure to free the widget_value objects we used to specify the |
| 1827 | contents even with longjmp. */ | 1827 | contents even with longjmp. */ |
| 1828 | record_unwind_protect (cleanup_widget_value_tree, | 1828 | record_unwind_protect (cleanup_widget_value_tree, |
| 1829 | make_save_value (first_wv, 0)); | 1829 | make_save_pointer (first_wv)); |
| 1830 | 1830 | ||
| 1831 | /* Actually create and show the menu until popped down. */ | 1831 | /* Actually create and show the menu until popped down. */ |
| 1832 | create_and_show_popup_menu (f, first_wv, x, y, for_click, timestamp); | 1832 | create_and_show_popup_menu (f, first_wv, x, y, for_click, timestamp); |
| @@ -1925,7 +1925,7 @@ create_and_show_dialog (FRAME_PTR f, widget_value *first_wv) | |||
| 1925 | if (menu) | 1925 | if (menu) |
| 1926 | { | 1926 | { |
| 1927 | ptrdiff_t specpdl_count = SPECPDL_INDEX (); | 1927 | ptrdiff_t specpdl_count = SPECPDL_INDEX (); |
| 1928 | record_unwind_protect (pop_down_menu, make_save_value (menu, 0)); | 1928 | record_unwind_protect (pop_down_menu, make_save_pointer (menu)); |
| 1929 | 1929 | ||
| 1930 | /* Display the menu. */ | 1930 | /* Display the menu. */ |
| 1931 | gtk_widget_show_all (menu); | 1931 | gtk_widget_show_all (menu); |
| @@ -2136,7 +2136,7 @@ xdialog_show (FRAME_PTR f, | |||
| 2136 | /* Make sure to free the widget_value objects we used to specify the | 2136 | /* Make sure to free the widget_value objects we used to specify the |
| 2137 | contents even with longjmp. */ | 2137 | contents even with longjmp. */ |
| 2138 | record_unwind_protect (cleanup_widget_value_tree, | 2138 | record_unwind_protect (cleanup_widget_value_tree, |
| 2139 | make_save_value (first_wv, 0)); | 2139 | make_save_pointer (first_wv)); |
| 2140 | 2140 | ||
| 2141 | /* Actually create and show the dialog. */ | 2141 | /* Actually create and show the dialog. */ |
| 2142 | create_and_show_dialog (f, first_wv); | 2142 | create_and_show_dialog (f, first_wv); |
| @@ -2479,7 +2479,7 @@ xmenu_show (FRAME_PTR f, int x, int y, bool for_click, bool keymaps, | |||
| 2479 | #endif | 2479 | #endif |
| 2480 | 2480 | ||
| 2481 | record_unwind_protect (pop_down_menu, | 2481 | record_unwind_protect (pop_down_menu, |
| 2482 | format_save_value ("pp", f, menu)); | 2482 | make_save_value ("pp", f, menu)); |
| 2483 | 2483 | ||
| 2484 | /* Help display under X won't work because XMenuActivate contains | 2484 | /* Help display under X won't work because XMenuActivate contains |
| 2485 | a loop that doesn't give Emacs a chance to process it. */ | 2485 | a loop that doesn't give Emacs a chance to process it. */ |
diff --git a/src/xselect.c b/src/xselect.c index b7cdf70ff77..37d2c753c5e 100644 --- a/src/xselect.c +++ b/src/xselect.c | |||
| @@ -1141,7 +1141,7 @@ wait_for_property_change (struct prop_location *location) | |||
| 1141 | 1141 | ||
| 1142 | /* Make sure to do unexpect_property_change if we quit or err. */ | 1142 | /* Make sure to do unexpect_property_change if we quit or err. */ |
| 1143 | record_unwind_protect (wait_for_property_change_unwind, | 1143 | record_unwind_protect (wait_for_property_change_unwind, |
| 1144 | make_save_value (location, 0)); | 1144 | make_save_pointer (location)); |
| 1145 | 1145 | ||
| 1146 | XSETCAR (property_change_reply, Qnil); | 1146 | XSETCAR (property_change_reply, Qnil); |
| 1147 | property_change_reply_object = location; | 1147 | property_change_reply_object = location; |