Mercurial > hg > xemacs-beta
diff src/redisplay.c @ 4967:0d4c9d0f6a8d
rewrite dynarr code
-------------------- ChangeLog entries follow: --------------------
src/ChangeLog addition:
2010-02-03 Ben Wing <ben@xemacs.org>
* device-x.c (x_get_resource_prefix):
* device-x.c (Fx_get_resource):
* device-x.c (Fx_get_resource_prefix):
* device-x.c (Fx_put_resource):
* dialog-msw.c:
* dialog-msw.c (handle_question_dialog_box):
* dired-msw.c (mswindows_sort_files):
* dired-msw.c (mswindows_get_files):
* extents.c (extent_fragment_sort_by_priority):
* extents.c (Fset_extent_parent):
* file-coding.c (coding_reader):
* file-coding.c (coding_writer):
* file-coding.c (gzip_convert):
* frame.c (generate_title_string):
* gutter.c (calculate_gutter_size_from_display_lines):
* indent.c (vmotion_1):
* lread.c (read_bit_vector):
* mule-coding.c (iso2022_decode):
* rangetab.c:
* rangetab.c (Fcopy_range_table):
* rangetab.c (Fget_range_table):
* rangetab.c (unified_range_table_copy_data):
* redisplay-msw.c (mswindows_output_string):
* redisplay-output.c (output_display_line):
* redisplay-output.c (redisplay_move_cursor):
* redisplay-output.c (redisplay_clear_bottom_of_window):
* redisplay-tty.c (tty_output_ichar_dynarr):
* redisplay-tty.c (set_foreground_to):
* redisplay-tty.c (set_background_to):
* redisplay-xlike-inc.c (XLIKE_output_string):
* redisplay.c (redisplay_window_text_width_string):
* redisplay.c (redisplay_text_width_string):
* redisplay.c (create_text_block):
* redisplay.c (SET_CURRENT_MODE_CHARS_PIXSIZE):
* redisplay.c (generate_fstring_runes):
* redisplay.c (regenerate_modeline):
* redisplay.c (ensure_modeline_generated):
* redisplay.c (real_current_modeline_height):
* redisplay.c (create_string_text_block):
* redisplay.c (regenerate_window):
* redisplay.c (REGEN_INC_FIND_START_END):
* redisplay.c (point_visible):
* redisplay.c (redisplay_window):
* redisplay.c (mark_glyph_block_dynarr):
* redisplay.c (line_start_cache_start):
* redisplay.c (start_with_line_at_pixpos):
* redisplay.c (update_line_start_cache):
* redisplay.c (glyph_to_pixel_translation):
* redisplay.c (pixel_to_glyph_translation):
* sysdep.c (qxe_readdir):
* text.c (dfc_convert_to_external_format):
* text.c (dfc_convert_to_internal_format):
* toolbar-common.c (common_output_toolbar_button):
* window.c (window_modeline_height):
* window.c (Fwindow_last_line_visible_height):
* window.c (window_displayed_height):
* window.c (window_scroll):
* window.c (get_current_pixel_pos):
Use Dynarr_begin() in place of Dynarr_atp (foo, 0).
* dynarr.c (Dynarr_realloc):
* dynarr.c (Dynarr_lisp_realloc):
* dynarr.c (Dynarr_resize):
* dynarr.c (Dynarr_insert_many):
* dynarr.c (Dynarr_delete_many):
* dynarr.c (Dynarr_memory_usage):
* dynarr.c (stack_like_malloc):
* dynarr.c (stack_like_free):
* lisp.h:
* lisp.h (DECLARE_DYNARR_LISP_IMP):
* lisp.h (XD_DYNARR_DESC):
* lisp.h (Dynarr_pop):
* gutter.c (output_gutter):
* redisplay-output.c (sync_rune_structs):
* redisplay-output.c (redisplay_output_window):
Redo the dynarr code, add greater checks.
Rename the `len', `largest' and `max' members to `len_',
`largest_' and `max_' to try and catch existing places that might
directly modify these values. Make new accessors Dynarr_largest()
and Dynarr_max() and make them and existing Dynarr_length() be
non-lvalues by adding '+ 0' to them; fix a couple of places in the
redisplay code that tried to modify the length directly by setting
Dynarr_length(). Use the accessors whenever possible even in the
dynarr code itself. The accessors also verify that 0 <= len <=
largest <= max. Rename settor function Dynarr_set_size() to
Dynarr_set_length() and use it more consistently; also create
lower-level Dynarr_set_length_1(). This latter function should be
the only function that directly modifies the `len_' member of a
Dynarr, and in the process makes sure that the `largest' value is
kept correct.
Consistently use ERROR_CHECK_STRUCTURES instead of
ERROR_CHECK_TYPES for error-checking code. Reintroduce the
temporarily disabled verification code on the positions of
Dynarr_at(), Dynarr_atp() and Dynarr_atp_past_end().
Also create Dynarr_resize_if() in place of a repeated
code fragment. Clean up all the functions that modify Dynarrs to
use the new macros and functions and verify the correctness of the
Dynarr both before and after the change.
Note that there are two kinds of verification -- one for accessing
and one for modifying. The difference is that the modify
verification additionally checks to make sure that the Dynarr
isn't locked. (This is used in redisplay to check for problems
with reentrancy.)
* lrecord.h: Move XD_DYNARR_DESC to lisp.h, grouping with the dynarr code.
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Wed, 03 Feb 2010 20:51:18 -0600 |
parents | 19a72041c5ed |
children | 4d35e52790f8 |
line wrap: on
line diff
--- a/src/redisplay.c Mon Feb 01 14:11:36 2010 -0600 +++ b/src/redisplay.c Wed Feb 03 20:51:18 2010 -0600 @@ -661,7 +661,7 @@ nonreloc = XSTRING_DATA (reloc); convert_ibyte_string_into_ichar_dynarr (nonreloc, len, rtw_ichar_dynarr); return redisplay_window_text_width_ichar_string - (w, findex, Dynarr_atp (rtw_ichar_dynarr, 0), + (w, findex, Dynarr_begin (rtw_ichar_dynarr), Dynarr_length (rtw_ichar_dynarr)); } @@ -697,7 +697,7 @@ argument. */ text_width, (XWINDOW (window), &cachel, - Dynarr_atp (rtw_ichar_dynarr, 0), + Dynarr_begin (rtw_ichar_dynarr), Dynarr_length (rtw_ichar_dynarr))); } @@ -2312,9 +2312,9 @@ works because we always recalculate the extent-fragments for propagated data, we never actually propagate the fragments that still need to be displayed. */ - if (*prop && Dynarr_atp (*prop, 0)->type == PROP_GLYPH) - { - last_glyph = Dynarr_atp (*prop, 0)->data.p_glyph.glyph; + if (*prop && Dynarr_begin (*prop)->type == PROP_GLYPH) + { + last_glyph = Dynarr_begin (*prop)->data.p_glyph.glyph; Dynarr_free (*prop); *prop = 0; } @@ -4082,7 +4082,7 @@ true of max_pixsize. */ #define SET_CURRENT_MODE_CHARS_PIXSIZE \ if (Dynarr_length (data->db->runes)) \ - cur_pixsize = data->pixpos - Dynarr_atp (data->db->runes, 0)->xpos; \ + cur_pixsize = data->pixpos - Dynarr_begin (data->db->runes)->xpos; \ else \ cur_pixsize = 0; @@ -4208,7 +4208,7 @@ decode_mode_spec (w, ch, type); - str = Dynarr_atp (mode_spec_ibyte_string, 0); + str = Dynarr_begin (mode_spec_ibyte_string); size = bytecount_to_charcount /* Skip the null character added by `decode_mode_spec' */ (str, Dynarr_length (mode_spec_ibyte_string)) - 1; @@ -4489,11 +4489,11 @@ { display_line_dynarr *dla = window_display_lines (w, DESIRED_DISP); - if (!Dynarr_length (dla) || !Dynarr_atp (dla, 0)->modeline) + if (!Dynarr_length (dla) || !Dynarr_begin (dla)->modeline) return; else { - generate_modeline (w, Dynarr_atp (dla, 0), DESIRED_DISP); + generate_modeline (w, Dynarr_begin (dla), DESIRED_DISP); redisplay_update_line (w, 0, 0, 0); } } @@ -4545,7 +4545,7 @@ /* If we're adding a new place marker go ahead and generate the modeline so that it is available for use by window_modeline_height. */ - generate_modeline (w, Dynarr_atp (dla, 0), type); + generate_modeline (w, Dynarr_begin (dla), type); } return need_modeline; @@ -4564,9 +4564,9 @@ if (Dynarr_length (dla)) { - if (Dynarr_atp (dla, 0)->modeline) - return (Dynarr_atp (dla, 0)->ascent + - Dynarr_atp (dla, 0)->descent); + if (Dynarr_begin (dla)->modeline) + return (Dynarr_begin (dla)->ascent + + Dynarr_begin (dla)->descent); } } return 0; @@ -4781,9 +4781,9 @@ { Lisp_Object last_glyph = Qnil; /* Deal with clipped glyphs that we have already displayed. */ - if (*prop && Dynarr_atp (*prop, 0)->type == PROP_GLYPH) - { - last_glyph = Dynarr_atp (*prop, 0)->data.p_glyph.glyph; + if (*prop && Dynarr_begin (*prop)->type == PROP_GLYPH) + { + last_glyph = Dynarr_begin (*prop)->data.p_glyph.glyph; Dynarr_free (*prop); *prop = 0; } @@ -5649,7 +5649,7 @@ { /* We know that this is the right thing to use because we put it there when we first started working in this function. */ - generate_modeline (w, Dynarr_atp (dla, 0), type); + generate_modeline (w, Dynarr_begin (dla), type); } if (depth >= 0) @@ -5663,12 +5663,12 @@ return 0; \ else \ { \ - if (Dynarr_atp (cdla, 0)->modeline && Dynarr_atp (ddla, 0)->modeline) \ + if (Dynarr_begin (cdla)->modeline && Dynarr_begin (ddla)->modeline) \ { \ dla_start = 1; \ } \ - else if (!Dynarr_atp (cdla, 0)->modeline \ - && !Dynarr_atp (ddla, 0)->modeline) \ + else if (!Dynarr_begin (cdla)->modeline \ + && !Dynarr_begin (ddla)->modeline) \ { \ dla_start = 0; \ } \ @@ -6102,7 +6102,7 @@ display_line_dynarr *dla = window_display_lines (w, type); int first_line; - if (Dynarr_length (dla) && Dynarr_atp (dla, 0)->modeline) + if (Dynarr_length (dla) && Dynarr_begin (dla)->modeline) first_line = 1; else first_line = 0; @@ -7597,7 +7597,7 @@ { if (gba) { - glyph_block *gb = Dynarr_atp (gba, 0); + glyph_block *gb = Dynarr_begin (gba); glyph_block *gb_last = Dynarr_past_lastp (gba); for (; gb < gb_last; gb++) @@ -7732,7 +7732,7 @@ if (!Dynarr_length (cache)) return -1; else - return Dynarr_atp (cache, 0)->start; + return Dynarr_begin (cache)->start; } /* Return the very last buffer position contained in the given @@ -8227,7 +8227,7 @@ on that assert. So we have no option but to continue the search if we found point at the top of the line_start_cache again. */ - cur_pos = Dynarr_atp (w->line_start_cache,0)->start; + cur_pos = Dynarr_begin (w->line_start_cache)->start; } prev_pos = cur_pos; } @@ -8404,7 +8404,7 @@ if (!Dynarr_length (cache)) { - Dynarr_add_many (cache, Dynarr_atp (internal_cache, 0), + Dynarr_add_many (cache, Dynarr_begin (internal_cache), Dynarr_length (internal_cache)); w->line_cache_validation_override--; return; @@ -8434,13 +8434,13 @@ if (!(ic_elt >= 0)) { Dynarr_reset (cache); - Dynarr_add_many (cache, Dynarr_atp (internal_cache, 0), + Dynarr_add_many (cache, Dynarr_begin (internal_cache), Dynarr_length (internal_cache)); w->line_cache_validation_override--; return; } - Dynarr_insert_many_at_start (cache, Dynarr_atp (internal_cache, 0), + Dynarr_insert_many_at_start (cache, Dynarr_begin (internal_cache), ic_elt + 1); } @@ -8459,7 +8459,7 @@ if (!(ic_elt < Dynarr_length (internal_cache))) { Dynarr_reset (cache); - Dynarr_add_many (cache, Dynarr_atp (internal_cache, 0), + Dynarr_add_many (cache, Dynarr_begin (internal_cache), Dynarr_length (internal_cache)); w->line_cache_validation_override--; return; @@ -8491,7 +8491,7 @@ to layout a single line. This is not possible since we force at least a single line to be layout for CMOTION_DISP */ assert (Dynarr_length (internal_cache)); - assert (startp == Dynarr_atp (internal_cache, 0)->start); + assert (startp == Dynarr_begin (internal_cache)->start); ic_elt = Dynarr_length (internal_cache) - 1; if (low_bound != -1) @@ -8526,7 +8526,7 @@ if (ic_elt >= 0) /* we still have lines to add.. */ { - Dynarr_insert_many (cache, Dynarr_atp (internal_cache, 0), + Dynarr_insert_many (cache, Dynarr_begin (internal_cache), ic_elt + 1, marker); marker += (ic_elt + 1); } @@ -8561,7 +8561,7 @@ /* See comment above about regenerate_window failing. */ assert (Dynarr_length (internal_cache)); - Dynarr_add_many (cache, Dynarr_atp (internal_cache, 0), + Dynarr_add_many (cache, Dynarr_begin (internal_cache), Dynarr_length (internal_cache)); high_bound = Dynarr_lastp (cache)->end; startp = high_bound + 1; @@ -8606,7 +8606,7 @@ modeline = 0; if (num_disp_lines) { - if (Dynarr_atp (dla, 0)->modeline) + if (Dynarr_begin (dla)->modeline) { num_disp_lines--; modeline = 1; @@ -9063,9 +9063,9 @@ if (x_check <= left_bound) { if (dl->modeline) - *modeline_closest = Dynarr_atp (db->runes, 0)->charpos; + *modeline_closest = Dynarr_begin (db->runes)->charpos; else - *closest = Dynarr_atp (db->runes, 0)->charpos; + *closest = Dynarr_begin (db->runes)->charpos; } else {