Mercurial > emacs
changeset 73575:c39e3aff703e
(mac_create_bitmap_from_bitmap_data): Make variable
`swap_nibbles' static const.
(atsu_get_text_layout_with_text_ptr): Make variables `lengths',
`tags', `sizes', `values' static const.
(mac_draw_string_common): Make variables `context' static. Make
variables `tags', `sizes', and `values' static const.
(pcm_get_status, x_detect_focus_change, x_scroll_bar_handle_click)
(xlfdpat_create, xlfdpat_block_match_1, xlfdpat_match)
(mac_to_x_fontname, parse_x_font_name, add_mac_font_name)
(mac_do_list_fonts, is_fully_specified_xlfd, do_grow_window)
(mac_store_event_ref_as_apple_event, mac_make_rdb): Add const
qualifier to arguments.
(xlfd_scalable_fields, keycode_to_xkeysym_table)
(fn_keycode_to_keycode_table): Make static const.
(mac_load_query_font): Make variables `tags', `sizes', `values',
`types', and `selectors' static const.
(mac_handle_command_event, mac_handle_window_event): Make
variables `names' and `types' static const.
(init_command_handler, install_window_handler): Make variables
`specs*' static const.
(mac_handle_font_event, mac_handle_text_input_event)
(mac_store_service_event): Make variables `names' and `types'
const. Make variables `names_*' and `types_*' static const.
author | YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> |
---|---|
date | Tue, 31 Oct 2006 08:32:56 +0000 |
parents | 848513456fe7 |
children | dcac157aa8ae |
files | src/macterm.c |
diffstat | 1 files changed, 109 insertions(+), 94 deletions(-) [+] |
line wrap: on
line diff
--- a/src/macterm.c Tue Oct 31 08:32:25 2006 +0000 +++ b/src/macterm.c Tue Oct 31 08:32:56 2006 +0000 @@ -244,7 +244,8 @@ static void mac_focus_changed P_ ((int, struct mac_display_info *, struct frame *, struct input_event *)); static void x_detect_focus_change P_ ((struct mac_display_info *, - EventRecord *, struct input_event *)); + const EventRecord *, + struct input_event *)); static void XTframe_rehighlight P_ ((struct frame *)); static void x_frame_rehighlight P_ ((struct x_display_info *)); static void x_draw_hollow_cursor P_ ((struct window *, struct glyph_row *)); @@ -640,7 +641,7 @@ char *bits; int w, h; { - static unsigned char swap_nibble[16] + static const unsigned char swap_nibble[16] = { 0x0, 0x8, 0x4, 0xc, /* 0000 1000 0100 1100 */ 0x2, 0xa, 0x6, 0xe, /* 0010 1010 0110 1110 */ 0x1, 0x9, 0x5, 0xd, /* 0001 1001 0101 1101 */ @@ -826,9 +827,9 @@ if (saved_text_layout == NULL) { - UniCharCount lengths[] = {kATSUToTextEnd}; - ATSUAttributeTag tags[] = {kATSULineLayoutOptionsTag}; - ByteCount sizes[] = {sizeof (ATSLineLayoutOptions)}; + static const UniCharCount lengths[] = {kATSUToTextEnd}; + static const ATSUAttributeTag tags[] = {kATSULineLayoutOptionsTag}; + static const ByteCount sizes[] = {sizeof (ATSLineLayoutOptions)}; static ATSLineLayoutOptions line_layout = #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020 kATSLineDisableAllLayoutOperations | kATSLineUseDeviceMetrics @@ -837,7 +838,7 @@ kATSLineIsDisplayOnly | kATSLineFractDisable #endif ; - ATSUAttributeValuePtr values[] = {&line_layout}; + static const ATSUAttributeValuePtr values[] = {&line_layout}; err = ATSUCreateTextLayoutWithTextPtr (text, kATSUFromTextBeginning, @@ -960,11 +961,11 @@ else { CGrafPtr port; - CGContextRef context; + static CGContextRef context; float port_height = FRAME_PIXEL_HEIGHT (f); - ATSUAttributeTag tags[] = {kATSUCGContextTag}; - ByteCount sizes[] = {sizeof (CGContextRef)}; - ATSUAttributeValuePtr values[] = {&context}; + static const ATSUAttributeTag tags[] = {kATSUCGContextTag}; + static const ByteCount sizes[] = {sizeof (CGContextRef)}; + static const ATSUAttributeValuePtr values[] = {&context}; #if USE_CG_DRAWING context = mac_begin_cg_clip (f, gc); @@ -2196,7 +2197,7 @@ static enum pcm_status pcm_get_status (pcm) - XCharStruct *pcm; + const XCharStruct *pcm; { int height = pcm->ascent + pcm->descent; @@ -4219,7 +4220,7 @@ static void x_detect_focus_change (dpyinfo, event, bufp) struct mac_display_info *dpyinfo; - EventRecord *event; + const EventRecord *event; struct input_event *bufp; { struct frame *frame; @@ -5232,7 +5233,7 @@ x_scroll_bar_handle_click (bar, part_code, er, bufp) struct scroll_bar *bar; ControlPartCode part_code; - EventRecord *er; + const EventRecord *er; struct input_event *bufp; { int win_y, top_range; @@ -6695,11 +6696,12 @@ static struct xlfdpat * xlfdpat_create (pattern) - char *pattern; + const char *pattern; { struct xlfdpat *pat; int nblocks, i, skip; unsigned char last_char, *p, *q, *anychar_head; + const unsigned char *ptr; struct xlfdpat_block *blk; pat = xmalloc (sizeof (struct xlfdpat)); @@ -6710,9 +6712,9 @@ anychar_head = NULL; q = pat->buf; last_char = '\0'; - for (p = pattern; *p; p++) - { - unsigned char c = *p; + for (ptr = pattern; *ptr; ptr++) + { + unsigned char c = *ptr; if (c == '*') if (last_char == '*') @@ -6816,14 +6818,15 @@ that the pattern in *BLK matches with its prefix. Return NULL there is no such strings. STRING must be lowered in advance. */ -static char * +static const char * xlfdpat_block_match_1 (blk, string, start_max) struct xlfdpat_block *blk; - unsigned char *string; + const unsigned char *string; int start_max; { int start, infinity; - unsigned char *p, *s; + unsigned char *p; + const unsigned char *s; xassert (blk->len > 0); xassert (start_max + blk->len <= strlen (string)); @@ -6880,17 +6883,17 @@ ((b)->len == 1 ? memchr ((s), (b)->last_char, (m) + 1) \ : xlfdpat_block_match_1 (b, s, m)) -/* Check if XLFD pattern PAT, which is generated by `xfldpat_create', +/* Check if XLFD pattern PAT, which is generated by `xlfdpat_create', matches with STRING. STRING must be lowered in advance. */ static int xlfdpat_match (pat, string) struct xlfdpat *pat; - unsigned char *string; + const unsigned char *string; { int str_len, nblocks, i, start_max; struct xlfdpat_block *blk; - unsigned char *s; + const unsigned char *s; xassert (pat->nblocks > 0); @@ -7061,7 +7064,7 @@ static char * mac_to_x_fontname (name, size, style, charset) - char *name; + const char *name; int size; Style style; char *charset; @@ -7108,7 +7111,8 @@ static int parse_x_font_name (xf, family, size, style, charset) - char *xf, *family; + const char *xf; + char *family; int *size; Style *style; char *charset; @@ -7191,10 +7195,10 @@ static void add_mac_font_name (name, size, style, charset) - char *name; + const char *name; int size; Style style; - char *charset; + const char *charset; { if (size > 0) add_font_name_table_entry (mac_to_x_fontname (name, size, style, charset)); @@ -7496,7 +7500,7 @@ XLFD_SCL_LAST }; -static int xlfd_scalable_fields[] = +static const int xlfd_scalable_fields[] = { 6, /* PIXEL_SIZE */ 7, /* POINT_SIZE */ @@ -7506,14 +7510,16 @@ static Lisp_Object mac_do_list_fonts (pattern, maxnames) - char *pattern; + const char *pattern; int maxnames; { int i, n_fonts = 0; Lisp_Object font_list = Qnil; struct xlfdpat *pat; - char *scaled, *ptr; - int scl_val[XLFD_SCL_LAST], *field, *val; + char *scaled; + const char *ptr; + int scl_val[XLFD_SCL_LAST], *val; + const int *field; int exact; if (font_name_table == NULL) /* Initialize when first used. */ @@ -7763,7 +7769,8 @@ fields are present, none is '*'. */ static int -is_fully_specified_xlfd (char *p) +is_fully_specified_xlfd (p) + const char *p; { int i; char *q; @@ -7840,18 +7847,21 @@ if (strcmp (charset, "iso10646-1") == 0) /* XXX */ { OSStatus err; - ATSUAttributeTag tags[] = {kATSUFontTag, kATSUSizeTag, - kATSUQDBoldfaceTag, kATSUQDItalicTag}; - ByteCount sizes[] = {sizeof (ATSUFontID), sizeof (Fixed), - sizeof (Boolean), sizeof (Boolean)}; + static const ATSUAttributeTag tags[] = + {kATSUFontTag, kATSUSizeTag, + kATSUQDBoldfaceTag, kATSUQDItalicTag}; + static const ByteCount sizes[] = + {sizeof (ATSUFontID), sizeof (Fixed), + sizeof (Boolean), sizeof (Boolean)}; static Fixed size_fixed; static Boolean bold_p, italic_p; - ATSUAttributeValuePtr values[] = {&font_id, &size_fixed, - &bold_p, &italic_p}; - ATSUFontFeatureType types[] = {kAllTypographicFeaturesType, - kDiacriticsType}; - ATSUFontFeatureSelector selectors[] = {kAllTypeFeaturesOffSelector, - kDecomposeDiacriticsSelector}; + static const ATSUAttributeValuePtr values[] = + {&font_id, &size_fixed, + &bold_p, &italic_p}; + static const ATSUFontFeatureType types[] = + {kAllTypographicFeaturesType, kDiacriticsType}; + static const ATSUFontFeatureSelector selectors[] = + {kAllTypeFeaturesOffSelector, kDecomposeDiacriticsSelector}; Lisp_Object font_id_cons; FMFontStyle style; @@ -8642,7 +8652,7 @@ except `clear' (-> <clear>) on the KeyPad, `enter' (-> <kp-enter>) on the right of the Cmd key on laptops, and fn + `enter' (-> <linefeed>). */ -static unsigned char keycode_to_xkeysym_table[] = { +static const unsigned char keycode_to_xkeysym_table[] = { /*0x00*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*0x10*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*0x20*/ 0, 0, 0, 0, 0x0d /*return*/, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -8679,7 +8689,7 @@ keyboard, and they may not be the same on other types of keyboards. If the destination is identical to the source (f1 ... f12), it doesn't map `fn' key to a modifier. */ -static unsigned char fn_keycode_to_keycode_table[] = { +static const unsigned char fn_keycode_to_keycode_table[] = { /*0x00*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*0x10*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*0x20*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -9137,7 +9147,9 @@ Mesander and IM - Window Manager A. */ static void -do_grow_window (WindowPtr w, EventRecord *e) +do_grow_window (w, e) + WindowPtr w; + const EventRecord *e; { Rect limit_rect; int rows, columns, width, height; @@ -9321,8 +9333,8 @@ Lisp_Object class_key, id_key; EventRef event; UInt32 num_params; - EventParamName *names; - EventParamType *types; + const EventParamName *names; + const EventParamType *types; { OSStatus err = eventNotHandledErr; Lisp_Object binding; @@ -9383,10 +9395,10 @@ { OSStatus result, err; HICommand command; - static EventParamName names[] = {kEventParamDirectObject, - kEventParamKeyModifiers}; - static EventParamType types[] = {typeHICommand, - typeUInt32}; + static const EventParamName names[] = + {kEventParamDirectObject, kEventParamKeyModifiers}; + static const EventParamType types[] = + {typeHICommand, typeUInt32}; int num_params = sizeof (names) / sizeof (names[0]); result = CallNextEventHandler (next_handler, event); @@ -9410,7 +9422,8 @@ static OSStatus init_command_handler () { - EventTypeSpec specs[] = {{kEventClassCommand, kEventCommandProcess}}; + static const EventTypeSpec specs[] = + {{kEventClassCommand, kEventCommandProcess}}; static EventHandlerUPP handle_command_eventUPP = NULL; if (handle_command_eventUPP == NULL) @@ -9570,18 +9583,18 @@ case kEventWindowToolbarSwitchMode: result = CallNextEventHandler (next_handler, event); { - static EventParamName names[] = {kEventParamDirectObject, - kEventParamWindowMouseLocation, - kEventParamKeyModifiers, - kEventParamMouseButton, - kEventParamClickCount, - kEventParamMouseChord}; - static EventParamType types[] = {typeWindowRef, - typeQDPoint, - typeUInt32, - typeMouseButton, - typeUInt32, - typeUInt32}; + static const EventParamName names[] = {kEventParamDirectObject, + kEventParamWindowMouseLocation, + kEventParamKeyModifiers, + kEventParamMouseButton, + kEventParamClickCount, + kEventParamMouseChord}; + static const EventParamType types[] = {typeWindowRef, + typeQDPoint, + typeUInt32, + typeMouseButton, + typeUInt32, + typeUInt32}; int num_params = sizeof (names) / sizeof (names[0]); err = mac_store_event_ref_as_apple_event (0, 0, @@ -9688,18 +9701,18 @@ OSStatus result, err; Lisp_Object id_key; int num_params; - EventParamName *names; - EventParamType *types; - static EventParamName names_sel[] = {kEventParamATSUFontID, - kEventParamATSUFontSize, - kEventParamFMFontFamily, - kEventParamFMFontSize, - kEventParamFontColor}; - static EventParamType types_sel[] = {typeATSUFontID, - typeATSUSize, - typeFMFontFamily, - typeFMFontSize, - typeFontColor}; + const EventParamName *names; + const EventParamType *types; + static const EventParamName names_sel[] = {kEventParamATSUFontID, + kEventParamATSUFontSize, + kEventParamFMFontFamily, + kEventParamFMFontSize, + kEventParamFontColor}; + static const EventParamType types_sel[] = {typeATSUFontID, + typeATSUSize, + typeFMFontFamily, + typeFMFontSize, + typeFontColor}; result = CallNextEventHandler (next_handler, event); if (result != eventNotHandledErr) @@ -9740,10 +9753,10 @@ OSStatus result, err = noErr; Lisp_Object id_key = Qnil; int num_params; - EventParamName *names; - EventParamType *types; + const EventParamName *names; + const EventParamType *types; static UInt32 seqno_uaia = 0; - static EventParamName names_uaia[] = + static const EventParamName names_uaia[] = {kEventParamTextInputSendComponentInstance, kEventParamTextInputSendRefCon, kEventParamTextInputSendSLRec, @@ -9756,7 +9769,7 @@ kEventParamTextInputSendTextServiceEncoding, kEventParamTextInputSendTextServiceMacEncoding, EVENT_PARAM_TEXT_INPUT_SEQUENCE_NUMBER}; - static EventParamType types_uaia[] = + static const EventParamType types_uaia[] = {typeComponentInstance, typeLongInteger, typeIntlWritingCode, @@ -9773,12 +9786,12 @@ typeUInt32, typeUInt32, typeUInt32}; - static EventParamName names_ufke[] = + static const EventParamName names_ufke[] = {kEventParamTextInputSendComponentInstance, kEventParamTextInputSendRefCon, kEventParamTextInputSendSLRec, kEventParamTextInputSendText}; - static EventParamType types_ufke[] = + static const EventParamType types_ufke[] = {typeComponentInstance, typeLongInteger, typeIntlWritingCode, @@ -9931,12 +9944,12 @@ OSStatus err; Lisp_Object id_key; int num_params; - EventParamName *names; - EventParamType *types; - static EventParamName names_pfm[] = {kEventParamServiceMessageName, - kEventParamServiceUserData}; - static EventParamType types_pfm[] = {typeCFStringRef, - typeCFStringRef}; + const EventParamName *names; + const EventParamType *types; + static const EventParamName names_pfm[] = + {kEventParamServiceMessageName, kEventParamServiceUserData}; + static const EventParamType types_pfm[] = + {typeCFStringRef, typeCFStringRef}; switch (GetEventKind (event)) { @@ -9974,7 +9987,7 @@ { OSStatus err = noErr; #if USE_CARBON_EVENTS - EventTypeSpec specs_window[] = + static const EventTypeSpec specs_window[] = {{kEventClassWindow, kEventWindowUpdate}, {kEventClassWindow, kEventWindowGetIdealSize}, {kEventClassWindow, kEventWindowBoundsChanging}, @@ -9992,16 +10005,18 @@ {kEventClassWindow, kEventWindowFocusRelinquish}, #endif }; - EventTypeSpec specs_mouse[] = {{kEventClassMouse, kEventMouseWheelMoved}}; + static const EventTypeSpec specs_mouse[] = + {{kEventClassMouse, kEventMouseWheelMoved}}; static EventHandlerUPP handle_window_eventUPP = NULL; static EventHandlerUPP handle_mouse_eventUPP = NULL; #if USE_MAC_FONT_PANEL - EventTypeSpec specs_font[] = {{kEventClassFont, kEventFontPanelClosed}, - {kEventClassFont, kEventFontSelection}}; + static const EventTypeSpec specs_font[] = + {{kEventClassFont, kEventFontPanelClosed}, + {kEventClassFont, kEventFontSelection}}; static EventHandlerUPP handle_font_eventUPP = NULL; #endif #if USE_MAC_TSM - EventTypeSpec specs_text_input[] = + static const EventTypeSpec specs_text_input[] = {{kEventClassTextInput, kEventTextInputUpdateActiveInputArea}, {kEventClassTextInput, kEventTextInputUnicodeForKeyEvent}, {kEventClassTextInput, kEventTextInputOffsetToPos}}; @@ -11218,7 +11233,7 @@ static XrmDatabase mac_make_rdb (xrm_option) - char *xrm_option; + const char *xrm_option; { XrmDatabase database;