From: Jan Djärv Date: Fri, 13 Jul 2012 18:03:10 +0000 (+0200) Subject: Remove compiler warnings in objective-C files. X-Git-Tag: emacs-24.2.90~1199^2~9 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=0dc8cf5002ba3f79bf840de5b83c0f4f2e4e6279;p=emacs.git Remove compiler warnings in objective-C files. * nsfns.m (x_set_icon_name, ns_set_name_internal) (ns_set_name_as_filename, ns_implicitly_set_icon_type) (x_set_icon_type, ns_lisp_to_cursor_type, Fns_read_file_name) (Fns_get_resource, Fns_set_resource, Fx_open_connection) (Fns_font_name, Fns_perform_service) (Fns_convert_utf8_nfd_to_nfc, ns_do_applescript) (Fns_do_applescript, Fx_show_tip): Use SSDATA where appropriate. (ns_set_name): Remove unused variable view. (x_set_menu_bar_lines): Remove unused variable olines. (x_set_tool_bar_lines): Remove unused variable root_window. (Fns_list_colors): Put () around assignment in while statement. (Fns_perform_service): Remove unused variable len. (Fns_display_usable_bounds): Remove unused variable top. (syms_of_nsfns): Remove unused variable i. * nsfont.m (ns_get_family, ns_lang_to_script, ns_otf_to_script) (ns_registry_to_script, ns_get_req_script, nsfont_open): Use SSDATA where appropriate. (ns_get_covering_families, ns_findfonts, nsfont_list_family): Put () around assignment in loop statement. (nsfont_open): Remove unused variable i. (nsfont_open): Remove unused variable len. (nsfont_draw): Remove unused variable cs. * nsimage.m (ns_load_image, allocInitFromFile): Use SSDATA where appropriate. (setXBMColor): Remove unused variable len. (setPixmapData): Put () around assignment in loop statement. * nsmenu.m (ns_update_menubar, ns_menu_show, process_dialog) (initFromContents): Use SSDATA where appropriate. (ns_update_menubar): Add braces to ambigous if-else. (initWithTitle): Put () around assignment in if statement. (ns_menu_show): Remove unused variables window and keymap. (update_frame_tool_bar): Remove unused variable selected_p. (initWithContentRect): Remove unused variable this_cmd_name. * nsterm.h (menuDown): Add id as type to argument sender. (ns_display_info_for_name): Add Lisp_Object argument. (ns_term_init): Add Lisp_Object argument. (ns_map_event_to_object): Add void argument. (ns_string_from_pasteboard, ns_string_to_pasteboard): Add correct prototype with arguments and only declare if __OBJC__. (nxatoms_of_nsselect): Add void argument. (ns_lisp_to_cursor_type): Add Lisp_Object argument. (ns_alloc_autorelease_pool): Add void argument. (ns_release_autorelease_pool): Add void* argument. (ns_get_defaults_value): Add const char* argument. * nsterm.m (uRect): Only define if NS_IMPL_GNUSTEP. (x_free_frame_resources): Pass x_free_frame_resources to NSTRACE. (ns_lisp_to_color, ns_string_to_lispmod, ns_term_init) (ns_term_shutdown, requestService, initFrameFromEmacs): Use SSDATA where appropriate. (ns_exec_path, ns_load_path, changeFont): Put () around assignment used as boolean expression. (x_set_window_size): Remove unused variable toolbar. (ns_get_color_default, ns_mod_to_lisp): Remove. (ns_mouse_position): Remove unused variables xchar and ychar. (ns_compute_glyph_string_overhangs): Remove unused variable face. (ns_set_vertical_scroll_bar): Remove unused variable count. (ns_delete_terminal): Remove unused variable i. (ns_term_init): Remove unused variables r, g and b. (mouseDown): Remove unused variable window. (windowDidResize): Move definition of theWindow inside NS_IMPL_GNUSTEP. (initFrameFromEmacs): Remove unused variable vbextra. (mouseEntered): Remove unused variables p and dpyinfo. (mouseExited): Remove unused variables p and r. (ns_define_frame_cursor, ns_clear_frame_area) (ns_draw_window_cursor, ns_initialize_display_info): Make static. (menuDown): Assign [sender tag] to variable and cast the variable. --- diff --git a/src/ChangeLog b/src/ChangeLog index e9d2d7f7d37..4a7c481b8b1 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,77 @@ 2012-07-13 Jan Djärv + * nsterm.m (uRect): Only define if NS_IMPL_GNUSTEP. + (x_free_frame_resources): Pass x_free_frame_resources to NSTRACE. + (ns_lisp_to_color, ns_string_to_lispmod, ns_term_init) + (ns_term_shutdown, requestService, initFrameFromEmacs): Use SSDATA + where appropriate. + (ns_exec_path, ns_load_path, changeFont): Put () around assignment used + as boolean expression. + (x_set_window_size): Remove unused variable toolbar. + (ns_get_color_default, ns_mod_to_lisp): Remove. + (ns_mouse_position): Remove unused variables xchar and ychar. + (ns_compute_glyph_string_overhangs): Remove unused variable face. + (ns_set_vertical_scroll_bar): Remove unused variable count. + (ns_delete_terminal): Remove unused variable i. + (ns_term_init): Remove unused variables r, g and b. + (mouseDown): Remove unused variable window. + (windowDidResize): Move definition of theWindow inside NS_IMPL_GNUSTEP. + (initFrameFromEmacs): Remove unused variable vbextra. + (mouseEntered): Remove unused variables p and dpyinfo. + (mouseExited): Remove unused variables p and r. + (ns_define_frame_cursor, ns_clear_frame_area) + (ns_draw_window_cursor, ns_initialize_display_info): Make static. + (menuDown): Assign [sender tag] to variable and cast the variable. + + * nsterm.h (menuDown): Add id as type to argument sender. + (ns_display_info_for_name): Add Lisp_Object argument. + (ns_term_init): Add Lisp_Object argument. + (ns_map_event_to_object): Add void argument. + (ns_string_from_pasteboard, ns_string_to_pasteboard): Add correct + prototype with arguments and only declare if __OBJC__. + (nxatoms_of_nsselect): Add void argument. + (ns_lisp_to_cursor_type): Add Lisp_Object argument. + (ns_alloc_autorelease_pool): Add void argument. + (ns_release_autorelease_pool): Add void* argument. + (ns_get_defaults_value): Add const char* argument. + + * nsmenu.m (ns_update_menubar, ns_menu_show, process_dialog) + (initFromContents): Use SSDATA where appropriate. + (ns_update_menubar): Add braces to ambigous if-else. + (initWithTitle): Put () around assignment in if statement. + (ns_menu_show): Remove unused variables window and keymap. + (update_frame_tool_bar): Remove unused variable selected_p. + (initWithContentRect): Remove unused variable this_cmd_name. + + * nsimage.m (ns_load_image, allocInitFromFile): Use SSDATA where + appropriate. + (setXBMColor): Remove unused variable len. + (setPixmapData): Put () around assignment in loop statement. + + * nsfont.m (ns_get_family, ns_lang_to_script, ns_otf_to_script) + (ns_registry_to_script, ns_get_req_script, nsfont_open): Use SSDATA + where appropriate. + (ns_get_covering_families, ns_findfonts, nsfont_list_family): Put () + around assignment in loop statement. + (nsfont_open): Remove unused variable i. + (nsfont_open): Remove unused variable len. + (nsfont_draw): Remove unused variable cs. + + * nsfns.m (x_set_icon_name, ns_set_name_internal) + (ns_set_name_as_filename, ns_implicitly_set_icon_type) + (x_set_icon_type, ns_lisp_to_cursor_type, Fns_read_file_name) + (Fns_get_resource, Fns_set_resource, Fx_open_connection) + (Fns_font_name, Fns_perform_service) + (Fns_convert_utf8_nfd_to_nfc, ns_do_applescript) + (Fns_do_applescript, Fx_show_tip): Use SSDATA where appropriate. + (ns_set_name): Remove unused variable view. + (x_set_menu_bar_lines): Remove unused variable olines. + (x_set_tool_bar_lines): Remove unused variable root_window. + (Fns_list_colors): Put () around assignment in while statement. + (Fns_perform_service): Remove unused variable len. + (Fns_display_usable_bounds): Remove unused variable top. + (syms_of_nsfns): Remove unused variable i. + * nsmenu.m (ns_update_menubar): Exchange place of argument 2 and 3 to memcpy (Bug#11907). diff --git a/src/nsfns.m b/src/nsfns.m index 47943e5d98a..7c8f673d9ae 100644 --- a/src/nsfns.m +++ b/src/nsfns.m @@ -471,11 +471,11 @@ x_set_icon_name (struct frame *f, Lisp_Object arg, Lisp_Object oldval) if ([[view window] miniwindowTitle] && ([[[view window] miniwindowTitle] isEqualToString: [NSString stringWithUTF8String: - SDATA (arg)]])) + SSDATA (arg)]])) return; [[view window] setMiniwindowTitle: - [NSString stringWithUTF8String: SDATA (arg)]]; + [NSString stringWithUTF8String: SSDATA (arg)]]; } static void @@ -490,7 +490,7 @@ ns_set_name_internal (FRAME_PTR f, Lisp_Object name) encoded_name = ENCODE_UTF_8 (name); UNGCPRO; - str = [NSString stringWithUTF8String: SDATA (encoded_name)]; + str = [NSString stringWithUTF8String: SSDATA (encoded_name)]; /* Don't change the name if it's already NAME. */ if (! [[[view window] title] isEqualToString: str]) @@ -501,7 +501,7 @@ ns_set_name_internal (FRAME_PTR f, Lisp_Object name) else encoded_icon_name = ENCODE_UTF_8 (f->icon_name); - str = [NSString stringWithUTF8String: SDATA (encoded_icon_name)]; + str = [NSString stringWithUTF8String: SSDATA (encoded_icon_name)]; if ([[view window] miniwindowTitle] && ! [[[view window] miniwindowTitle] isEqualToString: str]) @@ -512,7 +512,6 @@ ns_set_name_internal (FRAME_PTR f, Lisp_Object name) static void ns_set_name (struct frame *f, Lisp_Object name, int explicit) { - NSView *view; NSTRACE (ns_set_name); if (ns_in_resize) @@ -641,14 +640,14 @@ ns_set_name_as_filename (struct frame *f) title = FRAME_ICONIFIED_P (f) ? [[[view window] miniwindowTitle] UTF8String] : [[[view window] title] UTF8String]; - if (title && (! strcmp (title, SDATA (encoded_name)))) + if (title && (! strcmp (title, SSDATA (encoded_name)))) { [pool release]; UNBLOCK_INPUT; return; } - str = [NSString stringWithUTF8String: SDATA (encoded_name)]; + str = [NSString stringWithUTF8String: SSDATA (encoded_name)]; if (str == nil) str = @"Bad coding"; if (FRAME_ICONIFIED_P (f)) @@ -663,7 +662,7 @@ ns_set_name_as_filename (struct frame *f) encoded_filename = ENCODE_UTF_8 (filename); UNGCPRO; - fstr = [NSString stringWithUTF8String: SDATA (encoded_filename)]; + fstr = [NSString stringWithUTF8String: SSDATA (encoded_filename)]; if (fstr == nil) fstr = @""; #ifdef NS_IMPL_COCOA /* work around a bug observed on 10.3 and later where @@ -706,7 +705,6 @@ void x_set_menu_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval) { int nlines; - int olines = FRAME_MENU_BAR_LINES (f); if (FRAME_MINIBUF_ONLY_P (f)) return; @@ -737,7 +735,6 @@ void x_set_tool_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval) { int nlines; - Lisp_Object root_window; if (FRAME_MINIBUF_ONLY_P (f)) return; @@ -780,7 +777,7 @@ ns_implicitly_set_icon_type (struct frame *f) BLOCK_INPUT; pool = [[NSAutoreleasePool alloc] init]; if (f->output_data.ns->miniimage - && [[NSString stringWithUTF8String: SDATA (f->name)] + && [[NSString stringWithUTF8String: SSDATA (f->name)] isEqualToString: [(NSImage *)f->output_data.ns->miniimage name]]) { [pool release]; @@ -802,10 +799,10 @@ ns_implicitly_set_icon_type (struct frame *f) { elt = XCAR (chain); /* special case: 't' means go by file type */ - if (SYMBOLP (elt) && EQ (elt, Qt) && SDATA (f->name)[0] == '/') + if (SYMBOLP (elt) && EQ (elt, Qt) && SSDATA (f->name)[0] == '/') { NSString *str - = [NSString stringWithUTF8String: SDATA (f->name)]; + = [NSString stringWithUTF8String: SSDATA (f->name)]; if ([[NSFileManager defaultManager] fileExistsAtPath: str]) image = [[[NSWorkspace sharedWorkspace] iconForFile: str] retain]; } @@ -818,7 +815,7 @@ ns_implicitly_set_icon_type (struct frame *f) if (image == nil) image = [[NSImage imageNamed: [NSString stringWithUTF8String: - SDATA (XCDR (elt))]] retain]; + SSDATA (XCDR (elt))]] retain]; } } @@ -847,7 +844,7 @@ x_set_icon_type (struct frame *f, Lisp_Object arg, Lisp_Object oldval) if (!NILP (arg) && SYMBOLP (arg)) { - arg =build_string (SDATA (SYMBOL_NAME (arg))); + arg =build_string (SSDATA (SYMBOL_NAME (arg))); store_frame_param (f, Qicon_type, arg); } @@ -863,7 +860,7 @@ x_set_icon_type (struct frame *f, Lisp_Object arg, Lisp_Object oldval) image = [EmacsImage allocInitFromFile: arg]; if (image == nil) image =[NSImage imageNamed: [NSString stringWithUTF8String: - SDATA (arg)]]; + SSDATA (arg)]]; if (image == nil) { @@ -892,9 +889,9 @@ ns_lisp_to_cursor_type (Lisp_Object arg) { char *str; if (XTYPE (arg) == Lisp_String) - str = SDATA (arg); + str = SSDATA (arg); else if (XTYPE (arg) == Lisp_Symbol) - str = SDATA (SYMBOL_NAME (arg)); + str = SSDATA (SYMBOL_NAME (arg)); else return -1; if (!strcmp (str, "box")) return FILLED_BOX_CURSOR; if (!strcmp (str, "hollow")) return HOLLOW_BOX_CURSOR; @@ -1493,12 +1490,12 @@ Optional arg INIT, if non-nil, provides a default file name to use. */) Lisp_Object fname; NSString *promptS = NILP (prompt) || !STRINGP (prompt) ? nil : - [NSString stringWithUTF8String: SDATA (prompt)]; + [NSString stringWithUTF8String: SSDATA (prompt)]; NSString *dirS = NILP (dir) || !STRINGP (dir) ? - [NSString stringWithUTF8String: SDATA (BVAR (current_buffer, directory))] : - [NSString stringWithUTF8String: SDATA (dir)]; + [NSString stringWithUTF8String: SSDATA (BVAR (current_buffer, directory))] : + [NSString stringWithUTF8String: SSDATA (dir)]; NSString *initS = NILP (init) || !STRINGP (init) ? nil : - [NSString stringWithUTF8String: SDATA (init)]; + [NSString stringWithUTF8String: SSDATA (init)]; check_ns (); @@ -1568,9 +1565,9 @@ If OWNER is nil, Emacs is assumed. */) if (NILP (owner)) owner = build_string([ns_app_name UTF8String]); CHECK_STRING (name); -/*fprintf (stderr, "ns-get-resource checking resource '%s'\n", SDATA (name)); */ +/*fprintf (stderr, "ns-get-resource checking resource '%s'\n", SSDATA (name)); */ - value = ns_get_defaults_value (SDATA (name)); + value = ns_get_defaults_value (SSDATA (name)); if (value) return build_string (value); @@ -1591,15 +1588,15 @@ If VALUE is nil, the default is removed. */) if (NILP (value)) { [[NSUserDefaults standardUserDefaults] removeObjectForKey: - [NSString stringWithUTF8String: SDATA (name)]]; + [NSString stringWithUTF8String: SSDATA (name)]]; } else { CHECK_STRING (value); [[NSUserDefaults standardUserDefaults] setObject: - [NSString stringWithUTF8String: SDATA (value)] + [NSString stringWithUTF8String: SSDATA (value)] forKey: [NSString stringWithUTF8String: - SDATA (name)]]; + SSDATA (name)]]; } return Qnil; @@ -1795,10 +1792,10 @@ terminate Emacs if we can't open the connection. { if (!NILP (must_succeed)) fatal ("OpenStep on %s not responding.\n", - SDATA (display)); + SSDATA (display)); else error ("OpenStep on %s not responding.\n", - SDATA (display)); + SSDATA (display)); } /* Register our external input/output types, used for determining @@ -1897,14 +1894,14 @@ font descriptor. If string contains `fontset' and not { char *nm; CHECK_STRING (name); - nm = SDATA (name); + nm = SSDATA (name); if (nm[0] != '-') return name; if (strstr (nm, "fontset") && !strstr (nm, "fontset-startup")) return name; - return build_string (ns_xlfd_to_fontname (SDATA (name))); + return build_string (ns_xlfd_to_fontname (SSDATA (name))); } @@ -1927,14 +1924,14 @@ The optional argument FRAME is currently ignored. */) BLOCK_INPUT; colorlists = [[NSColorList availableColorLists] objectEnumerator]; - while (clist = [colorlists nextObject]) + while ((clist = [colorlists nextObject])) { if ([[clist name] length] < 7 || [[clist name] rangeOfString: @"PANTONE"].location == 0) { NSEnumerator *cnames = [[clist allKeys] reverseObjectEnumerator]; NSString *cname; - while (cname = [cnames nextObject]) + while ((cname = [cnames nextObject])) list = Fcons (build_string ([cname UTF8String]), list); /* for (i = [[clist allKeys] count] - 1; i >= 0; i--) list = Fcons (build_string ([[[clist allKeys] objectAtIndex: i] @@ -2014,12 +2011,11 @@ there was no result. */) id pb; NSString *svcName; char *utfStr; - int len; CHECK_STRING (service); check_ns (); - utfStr = SDATA (service); + utfStr = SSDATA (service); svcName = [NSString stringWithUTF8String: utfStr]; pb =[NSPasteboard pasteboardWithUniqueName]; @@ -2044,7 +2040,7 @@ DEFUN ("ns-convert-utf8-nfd-to-nfc", Fns_convert_utf8_nfd_to_nfc, NSString *utfStr; CHECK_STRING (str); - utfStr = [NSString stringWithUTF8String: SDATA (str)]; + utfStr = [NSString stringWithUTF8String: SSDATA (str)]; if (![utfStr respondsToSelector: @selector (precomposedStringWithCanonicalMapping)]) { @@ -2074,7 +2070,7 @@ ns_do_applescript (Lisp_Object script, Lisp_Object *result) NSAppleScript* scriptObject = [[NSAppleScript alloc] initWithSource: - [NSString stringWithUTF8String: SDATA (script)]]; + [NSString stringWithUTF8String: SSDATA (script)]]; returnDescriptor = [scriptObject executeAndReturnError: &errorDict]; [scriptObject release]; @@ -2173,7 +2169,7 @@ In case the execution fails, an error is signaled. */) else if (!STRINGP (result)) error ("AppleScript error %d", status); else - error ("%s", SDATA (result)); + error ("%s", SSDATA (result)); } #endif @@ -2400,7 +2396,6 @@ frame, a display name (a string), or terminal ID. If omitted or nil, that stands for the selected frame's display. */) (Lisp_Object display) { - int top; NSScreen *screen; NSRect vScreen; @@ -2558,7 +2553,7 @@ Text larger than the specified size is clipped. */) GCPRO4 (string, parms, frame, timeout); CHECK_STRING (string); - str = SDATA (string); + str = SSDATA (string); f = check_x_frame (frame); if (NILP (timeout)) timeout = make_number (5); @@ -2692,8 +2687,6 @@ Value is t if tooltip was open, nil otherwise. */) void syms_of_nsfns (void) { - int i; - Qfontsize = intern_c_string ("fontsize"); staticpro (&Qfontsize); diff --git a/src/nsfont.m b/src/nsfont.m index 7a44182a93e..6f9294e082a 100644 --- a/src/nsfont.m +++ b/src/nsfont.m @@ -100,7 +100,7 @@ ns_get_family (Lisp_Object font_spec) return nil; else { - char *tmp = xstrdup (SDATA (SYMBOL_NAME (tem))); + char *tmp = xstrdup (SSDATA (SYMBOL_NAME (tem))); NSString *family; ns_unescape_name (tmp); family = [NSString stringWithUTF8String: tmp]; @@ -293,13 +293,13 @@ ns_charset_covers(NSCharacterSet *set1, NSCharacterSet *set2, float pct) static NSString *ns_lang_to_script (Lisp_Object lang) { - if (!strcmp (SDATA (SYMBOL_NAME (lang)), "ja")) + if (!strcmp (SSDATA (SYMBOL_NAME (lang)), "ja")) return @"han"; /* NOTE: ja given for any hanzi that's also a kanji, but Chinese fonts have more characters. */ - else if (!strcmp (SDATA (SYMBOL_NAME (lang)), "zh")) + else if (!strcmp (SSDATA (SYMBOL_NAME (lang)), "zh")) return @"han"; - else if (!strcmp (SDATA (SYMBOL_NAME (lang)), "ko")) + else if (!strcmp (SSDATA (SYMBOL_NAME (lang)), "ko")) return @"hangul"; else return @""; @@ -313,7 +313,7 @@ static NSString { Lisp_Object script = assq_no_quit (XCAR (otf), Votf_script_alist); return CONSP (script) - ? [NSString stringWithUTF8String: SDATA (SYMBOL_NAME (XCDR ((script))))] + ? [NSString stringWithUTF8String: SSDATA (SYMBOL_NAME (XCDR ((script))))] : @""; } @@ -326,10 +326,10 @@ static NSString while CONSP (rts) { r = XCAR (XCAR (rts)); - if (!strncmp(SDATA(r), reg, strlen(SDATA(r)))) + if (!strncmp(SSDATA(r), reg, strlen(SSDATA(r)))) { script = XCDR (XCAR (rts)); - return [NSString stringWithUTF8String: SDATA (SYMBOL_NAME (script))]; + return [NSString stringWithUTF8String: SSDATA (SYMBOL_NAME (script))]; } rts = XCDR (rts); } @@ -355,7 +355,7 @@ static NSString Lisp_Object key = XCAR (tmp), val = XCDR (tmp); if (EQ (key, QCscript) && SYMBOLP (val)) return [NSString stringWithUTF8String: - SDATA (SYMBOL_NAME (val))]; + SSDATA (SYMBOL_NAME (val))]; if (EQ (key, QClang) && SYMBOLP (val)) return ns_lang_to_script (val); if (EQ (key, QCotf) && CONSP (val) && SYMBOLP (XCAR (val))) @@ -373,7 +373,7 @@ static NSString if (EQ (reg, Qiso10646_1)) reg = Qiso8859_1; #endif - return ns_registry_to_script (SDATA (SYMBOL_NAME (reg))); + return ns_registry_to_script (SSDATA (SYMBOL_NAME (reg))); } return @""; @@ -464,7 +464,7 @@ static NSSet while (1) { NSEnumerator *allFamiliesEnum = [allFamilies objectEnumerator]; - while (family = [allFamiliesEnum nextObject]) + while ((family = [allFamiliesEnum nextObject])) { NSCharacterSet *fset = [[fontMgr fontWithFamily: family traits: 0 weight: 5 size: 12.0] coveredCharacterSet]; @@ -528,7 +528,7 @@ ns_findfonts (Lisp_Object font_spec, BOOL isMatch) NSLog(@"Got desc %@ and found %d matching fonts from it: ", fdesc, [matchingDescs count]); - for (dEnum = [matchingDescs objectEnumerator]; desc = [dEnum nextObject]; ) + for (dEnum = [matchingDescs objectEnumerator]; (desc = [dEnum nextObject]);) { if (![cFamilies containsObject: [desc objectForKey: NSFontFamilyAttribute]]) @@ -664,7 +664,7 @@ nsfont_list_family (Lisp_Object frame) [[[NSFontManager sharedFontManager] availableFontFamilies] objectEnumerator]; NSString *family; - while (family = [families nextObject]) + while ((family = [families nextObject])) list = Fcons (intern ([family UTF8String]), list); /* FIXME: escape the name? */ @@ -692,7 +692,6 @@ nsfont_open (FRAME_PTR f, Lisp_Object font_entity, int pixel_size) Lisp_Object tem; NSRect brect; Lisp_Object font_object; - int i; int fixLeopardBug; static NSMutableDictionary *fontCache = nil; NSNumber *cached; @@ -719,7 +718,7 @@ nsfont_open (FRAME_PTR f, Lisp_Object font_entity, int pixel_size) } tem = AREF (font_entity, FONT_ADSTYLE_INDEX); - synthItal = !NILP (tem) && !strncmp ("synthItal", SDATA (SYMBOL_NAME (tem)), + synthItal = !NILP (tem) && !strncmp ("synthItal", SSDATA (SYMBOL_NAME (tem)), 9); family = ns_get_family (font_entity); if (family == nil) @@ -812,7 +811,6 @@ nsfont_open (FRAME_PTR f, Lisp_Object font_entity, int pixel_size) { const char *fontName = [[nsfont fontName] UTF8String]; - int len = strlen (fontName); /* The values specified by fonts are not always exact. For * example, a 6x8 font could specify that the descender is @@ -1060,7 +1058,6 @@ nsfont_draw (struct glyph_string *s, int from, int to, int x, int y, NS to render the string, it will come out differently from the individual character widths added up because of layout processing. */ { - XCharStruct *cs; int cwidth, twidth = 0; int hi, lo; /* FIXME: composition: no vertical displacement is considered. */ diff --git a/src/nsimage.m b/src/nsimage.m index 82a176975ff..1479294948b 100644 --- a/src/nsimage.m +++ b/src/nsimage.m @@ -96,7 +96,7 @@ ns_load_image (struct frame *f, struct image *img, { NSData *data; - data = [NSData dataWithBytes: SDATA (spec_data) + data = [NSData dataWithBytes: SSDATA (spec_data) length: SBYTES (spec_data)]; eImg = [[EmacsImage alloc] initWithData: data]; [eImg setPixmapData]; @@ -171,7 +171,7 @@ static EmacsImage *ImageList = nil; /* look for an existing image of the same name */ while (image != nil && - [[image name] compare: [NSString stringWithUTF8String: SDATA (file)]] + [[image name] compare: [NSString stringWithUTF8String: SSDATA (file)]] != NSOrderedSame) image = [image imageListNext]; @@ -187,7 +187,7 @@ static EmacsImage *ImageList = nil; return nil; image = [[EmacsImage alloc] initByReferencingFile: - [NSString stringWithUTF8String: SDATA (found)]]; + [NSString stringWithUTF8String: SSDATA (found)]]; #if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 imgRep = [NSBitmapImageRep imageRepWithData:[image TIFFRepresentation]]; @@ -205,7 +205,7 @@ static EmacsImage *ImageList = nil; [image setScalesWhenResized: YES]; [image setSize: NSMakeSize([imgRep pixelsWide], [imgRep pixelsHigh])]; - [image setName: [NSString stringWithUTF8String: SDATA (file)]]; + [image setName: [NSString stringWithUTF8String: SSDATA (file)]]; [image reference]; ImageList = [image imageListSetNext: ImageList]; @@ -334,7 +334,6 @@ static EmacsImage *ImageList = nil; - setXBMColor: (NSColor *)color { NSSize s = [self size]; - int len = (int) s.width * s.height; unsigned char *planes[5]; CGFloat r, g, b, a; NSColor *rgbColor; @@ -400,7 +399,7 @@ static EmacsImage *ImageList = nil; NSImageRep *rep; reps = [[self representations] objectEnumerator]; - while (rep = (NSImageRep *) [reps nextObject]) + while ((rep = (NSImageRep *) [reps nextObject])) { if ([rep respondsToSelector: @selector (getBitmapDataPlanes:)]) { diff --git a/src/nsmenu.m b/src/nsmenu.m index f3bd9dd3ecb..c919f350c6c 100644 --- a/src/nsmenu.m +++ b/src/nsmenu.m @@ -249,7 +249,7 @@ ns_update_menubar (struct frame *f, int deep_p, EmacsMenu *submenu) /* FIXME: we'd like to only parse the needed submenu, but this was causing crashes in the _common parsing code.. need to make sure proper initialization done.. */ -/* if (submenu && strcmp (submenuTitle, SDATA (string))) +/* if (submenu && strcmp (submenuTitle, SSDATA (string))) continue; */ submenu_start[i] = menu_items_used; @@ -318,8 +318,8 @@ ns_update_menubar (struct frame *f, int deep_p, EmacsMenu *submenu) if (!EQ (previous_items[i], AREF (menu_items, i))) if (!(STRINGP (previous_items[i]) && STRINGP (AREF (menu_items, i)) - && !strcmp (SDATA (previous_items[i]), - SDATA (AREF (menu_items, i))))) + && !strcmp (SSDATA (previous_items[i]), + SSDATA (AREF (menu_items, i))))) break; if (i == previous_menu_items_used) { @@ -356,7 +356,7 @@ ns_update_menubar (struct frame *f, int deep_p, EmacsMenu *submenu) string = AREF (items, i + 1); if (NILP (string)) break; -/* if (submenu && strcmp (submenuTitle, SDATA (string))) +/* if (submenu && strcmp (submenuTitle, SSDATA (string))) continue; */ wv->name = SSDATA (string); @@ -422,11 +422,13 @@ ns_update_menubar (struct frame *f, int deep_p, EmacsMenu *submenu) if (EQ (string, make_number (0))) // FIXME: Why??? --Stef continue; if (NILP (string)) - if (previous_strings[i][0]) - break; - else - continue; - if (memcmp (previous_strings[i], SDATA (string), + { + if (previous_strings[i][0]) + break; + else + continue; + } + else if (memcmp (previous_strings[i], SDATA (string), min (10, SBYTES (string) + 1))) break; } @@ -528,7 +530,7 @@ set_frame_menubar (struct frame *f, int first_time, int deep_p) /* override designated initializer */ - initWithTitle: (NSString *)title { - if (self = [super initWithTitle: title]) + if ((self = [super initWithTitle: title])) [self setAutoenablesItems: NO]; return self; } @@ -793,7 +795,7 @@ ns_menu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps, { EmacsMenu *pmenu; NSPoint p; - Lisp_Object window, tem, keymap; + Lisp_Object tem; ptrdiff_t specpdl_count = SPECPDL_INDEX (); widget_value *wv, *first_wv = 0; @@ -990,7 +992,7 @@ ns_menu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps, } pmenu = [[EmacsMenu alloc] initWithTitle: - [NSString stringWithUTF8String: SDATA (title)]]; + [NSString stringWithUTF8String: SSDATA (title)]]; [pmenu fillWithWidgetValue: first_wv->contents]; free_menubar_widget_value_tree (first_wv); unbind_to (specpdl_count, Qnil); @@ -1043,7 +1045,6 @@ update_frame_tool_bar (FRAME_PTR f) i * TOOL_BAR_ITEM_NSLOTS + (IDX)) BOOL enabled_p = !NILP (TOOLPROP (TOOL_BAR_ITEM_ENABLED_P)); - BOOL selected_p = !NILP (TOOLPROP (TOOL_BAR_ITEM_SELECTED_P)); int idx; ptrdiff_t img_id; struct image *img; @@ -1473,7 +1474,6 @@ ns_popup_dialog (Lisp_Object position, Lisp_Object contents, Lisp_Object header) { NSSize spacing = {SPACER, SPACER}; NSRect area; - char this_cmd_name[80]; id cell; static NSImageView *imgView; static FlippedView *contentView; @@ -1581,11 +1581,11 @@ void process_dialog (id window, Lisp_Object list) item = XCAR (list); if (XTYPE (item) == Lisp_String) { - [window addString: SDATA (item) row: row++]; + [window addString: SSDATA (item) row: row++]; } else if (XTYPE (item) == Lisp_Cons) { - [window addButton: SDATA (XCAR (item)) + [window addButton: SSDATA (XCAR (item)) value: XCDR (item) row: row++]; } else if (NILP (item)) @@ -1675,7 +1675,7 @@ void process_dialog (id window, Lisp_Object list) if (XTYPE (head) == Lisp_String) [title setStringValue: - [NSString stringWithUTF8String: SDATA (head)]]; + [NSString stringWithUTF8String: SSDATA (head)]]; else if (isQ == YES) [title setStringValue: @"Question"]; else diff --git a/src/nsterm.h b/src/nsterm.h index abfdfd4803a..b20621a53d7 100644 --- a/src/nsterm.h +++ b/src/nsterm.h @@ -89,7 +89,7 @@ along with GNU Emacs. If not, see . */ } /* AppKit-side interface */ -- menuDown: sender; +- menuDown: (id)sender; - toolbarClicked: (id)item; - toggleToolbar: (id)sender; - (void)keyDown: (NSEvent *)theEvent; @@ -535,7 +535,7 @@ struct ns_display_info extern struct ns_display_info *x_display_list; extern Lisp_Object ns_display_name_list; -extern struct ns_display_info *ns_display_info_for_name (); +extern struct ns_display_info *ns_display_info_for_name (Lisp_Object name); struct ns_display_info *check_x_display_info (Lisp_Object frame); FRAME_PTR check_x_frame (Lisp_Object frame); @@ -697,7 +697,7 @@ struct x_output (! (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f)) ? 0 \ : FRAME_SCROLL_BAR_COLS (f)) -extern struct ns_display_info *ns_term_init (); +extern struct ns_display_info *ns_term_init (Lisp_Object display_name); extern void ns_term_shutdown (int sig); /* constants for text rendering */ @@ -725,13 +725,15 @@ extern void ns_clear_frame (struct frame *f); extern const char *ns_xlfd_to_fontname (const char *xlfd); extern void check_ns (void); -extern Lisp_Object ns_map_event_to_object (); -extern Lisp_Object ns_string_from_pasteboard (); -extern void ns_string_to_pasteboard (); +extern Lisp_Object ns_map_event_to_object (void); +#ifdef __OBJC__ +extern Lisp_Object ns_string_from_pasteboard (id pb); +extern void ns_string_to_pasteboard (id pb, Lisp_Object str); +#endif extern Lisp_Object ns_get_local_selection (Lisp_Object selection_name, Lisp_Object target_type); -extern void nxatoms_of_nsselect (); -extern int ns_lisp_to_cursor_type (); +extern void nxatoms_of_nsselect (void); +extern int ns_lisp_to_cursor_type (Lisp_Object arg); extern Lisp_Object ns_cursor_type_to_lisp (int arg); extern Lisp_Object Qnone; extern void ns_set_name_as_filename (struct frame *f); @@ -756,9 +758,9 @@ extern void ns_free_indexed_color (unsigned long idx, struct frame *f); /* C access to ObjC functionality */ extern void ns_release_object (void *obj); extern void ns_retain_object (void *obj); -extern void *ns_alloc_autorelease_pool (); -extern void ns_release_autorelease_pool (); -extern const char *ns_get_defaults_value (); +extern void *ns_alloc_autorelease_pool (void); +extern void ns_release_autorelease_pool (void *); +extern const char *ns_get_defaults_value (const char *key); /* in nsmenu */ extern void update_frame_tool_bar (FRAME_PTR f); @@ -794,6 +796,7 @@ extern void x_set_tool_bar_lines (struct frame *f, extern void x_activate_menubar (struct frame *); extern void free_frame_menubar (struct frame *); extern void x_free_frame_resources (struct frame *); +extern void x_destroy_window (struct frame *); #define NSAPP_DATA2_RUNASSCRIPT 10 extern void ns_run_ascript (void); diff --git a/src/nsterm.m b/src/nsterm.m index 0fceb873ae2..ff978d89d0e 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -169,7 +169,9 @@ static EmacsScroller *last_mouse_scroll_bar = nil; static struct frame *ns_updating_frame; static NSView *focus_view = NULL; static int ns_window_num = 0; +#ifdef NS_IMPL_GNUSTEP static NSRect uRect; +#endif static BOOL gsaved = NO; BOOL ns_in_resize = NO; static BOOL ns_fake_keydown = NO; @@ -347,7 +349,7 @@ ns_exec_path (void) pathEnum = [paths objectEnumerator]; resourcePaths = @""; - while (resourcePath = [pathEnum nextObject]) + while ((resourcePath = [pathEnum nextObject])) { if ([fileManager fileExistsAtPath: resourcePath isDirectory: &isDir]) if (isDir) @@ -387,7 +389,7 @@ ns_load_path (void) /* Hack to skip site-lisp. */ if (no_site_lisp) resourcePath = [pathEnum nextObject]; - while (resourcePath = [pathEnum nextObject]) + while ((resourcePath = [pathEnum nextObject])) { if ([fileManager fileExistsAtPath: resourcePath isDirectory: &isDir]) if (isDir) @@ -1111,7 +1113,7 @@ x_free_frame_resources (struct frame *f) NSView *view = FRAME_NS_VIEW (f); struct ns_display_info *dpyinfo = FRAME_NS_DISPLAY_INFO (f); Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f); - NSTRACE (x_destroy_window); + NSTRACE (x_free_frame_resources); check_ns (); [(EmacsView *)view setWindowClosing: YES]; /* may not have been informed */ @@ -1218,7 +1220,6 @@ x_set_window_size (struct frame *f, int change_grav, int cols, int rows) -------------------------------------------------------------------------- */ { EmacsView *view = FRAME_NS_VIEW (f); - EmacsToolbar *toolbar = [view toolbar]; NSWindow *window = [view window]; NSRect wr = [window frame]; int tb = FRAME_EXTERNAL_TOOL_BAR (f); @@ -1503,21 +1504,6 @@ ns_get_color (const char *name, NSColor **col) } -static NSColor * -ns_get_color_default (const char *name, NSColor *dflt) -/* -------------------------------------------------------------------------- - Parse a color or use a default value - -------------------------------------------------------------------------- */ -{ - NSColor * col; - - if (ns_get_color (name, &col)) - return dflt; - else - return col; -} - - int ns_lisp_to_color (Lisp_Object color, NSColor **col) /* -------------------------------------------------------------------------- @@ -1526,9 +1512,9 @@ ns_lisp_to_color (Lisp_Object color, NSColor **col) { NSTRACE (ns_lisp_to_color); if (STRINGP (color)) - return ns_get_color (SDATA (color), col); + return ns_get_color (SSDATA (color), col); else if (SYMBOLP (color)) - return ns_get_color (SDATA (SYMBOL_NAME (color)), col); + return ns_get_color (SSDATA (SYMBOL_NAME (color)), col); return 1; } @@ -1773,7 +1759,6 @@ ns_mouse_position (struct frame **fp, int insist, Lisp_Object *bar_window, { id view; NSPoint position; - int xchar, ychar; Lisp_Object frame, tail; struct frame *f; struct ns_display_info *dpyinfo; @@ -1867,7 +1852,7 @@ ns_frame_up_to_date (struct frame *f) } -void +static void ns_define_frame_cursor (struct frame *f, Cursor cursor) /* -------------------------------------------------------------------------- External (RIF): set frame mouse pointer type. @@ -1992,7 +1977,7 @@ ns_clear_frame (struct frame *f) } -void +static void ns_clear_frame_area (struct frame *f, int x, int y, int width, int height) /* -------------------------------------------------------------------------- External (RIF): Clear section of frame @@ -2195,8 +2180,7 @@ ns_compute_glyph_string_overhangs (struct glyph_string *s) External (RIF); compute left/right overhang of whole string and set in s -------------------------------------------------------------------------- */ { - struct face *face = FACE_FROM_ID (s->f, s->first_glyph->face_id); - struct font *font = s->font; /*face->font; */ + struct font *font = s->font; if (s->char2b) { @@ -2313,7 +2297,7 @@ ns_draw_fringe_bitmap (struct window *w, struct glyph_row *row, } -void +static void ns_draw_window_cursor (struct window *w, struct glyph_row *glyph_row, int x, int y, int cursor_type, int cursor_width, int on_p, int active_p) @@ -3627,7 +3611,6 @@ ns_set_vertical_scroll_bar (struct window *window, BOOL barOnVeryLeft, barOnVeryRight; int top, left, height, width, sb_width, sb_left; EmacsScroller *bar; -static int count = 0; /* optimization; display engine sends WAY too many of these.. */ if (!NILP (window->vertical_scroll_bar)) @@ -3809,43 +3792,23 @@ static Lisp_Object ns_string_to_lispmod (const char *s) Convert modifier name to lisp symbol -------------------------------------------------------------------------- */ { - if (!strncmp (SDATA (SYMBOL_NAME (Qmeta)), s, 10)) + if (!strncmp (SSDATA (SYMBOL_NAME (Qmeta)), s, 10)) return Qmeta; - else if (!strncmp (SDATA (SYMBOL_NAME (Qsuper)), s, 10)) + else if (!strncmp (SSDATA (SYMBOL_NAME (Qsuper)), s, 10)) return Qsuper; - else if (!strncmp (SDATA (SYMBOL_NAME (Qcontrol)), s, 10)) + else if (!strncmp (SSDATA (SYMBOL_NAME (Qcontrol)), s, 10)) return Qcontrol; - else if (!strncmp (SDATA (SYMBOL_NAME (Qalt)), s, 10)) + else if (!strncmp (SSDATA (SYMBOL_NAME (Qalt)), s, 10)) return Qalt; - else if (!strncmp (SDATA (SYMBOL_NAME (Qhyper)), s, 10)) + else if (!strncmp (SSDATA (SYMBOL_NAME (Qhyper)), s, 10)) return Qhyper; - else if (!strncmp (SDATA (SYMBOL_NAME (Qnone)), s, 10)) + else if (!strncmp (SSDATA (SYMBOL_NAME (Qnone)), s, 10)) return Qnone; else return Qnil; } -static Lisp_Object ns_mod_to_lisp (int m) -/* -------------------------------------------------------------------------- - Convert modifier code (see lisp.h) to lisp symbol - -------------------------------------------------------------------------- */ -{ - if (m == CHAR_META) - return Qmeta; - else if (m == CHAR_SUPER) - return Qsuper; - else if (m == CHAR_CTL) - return Qcontrol; - else if (m == CHAR_ALT) - return Qalt; - else if (m == CHAR_HYPER) - return Qhyper; - else /* if (m == 0) */ - return Qnone; -} - - static void ns_default (const char *parameter, Lisp_Object *result, Lisp_Object yesval, Lisp_Object noval, @@ -3874,7 +3837,7 @@ ns_default (const char *parameter, Lisp_Object *result, } -void +static void ns_initialize_display_info (struct ns_display_info *dpyinfo) /* -------------------------------------------------------------------------- Initialize global info and storage for display. @@ -3963,7 +3926,6 @@ static void ns_delete_terminal (struct terminal *terminal) { struct ns_display_info *dpyinfo = terminal->display_info.ns; - int i; /* Protect against recursive calls. delete_frame in delete_terminal calls us back when it deletes our last frame. */ @@ -4124,7 +4086,6 @@ ns_term_init (Lisp_Object display_name) if ( cl == nil ) { Lisp_Object color_file, color_map, color; - int r,g,b; unsigned long c; char *name; @@ -4141,7 +4102,7 @@ ns_term_init (Lisp_Object display_name) for ( ; CONSP (color_map); color_map = XCDR (color_map)) { color = XCAR (color_map); - name = SDATA (XCAR (color)); + name = SSDATA (XCAR (color)); c = XINT (XCDR (color)); [cl setColor: [NSColor colorWithCalibratedRed: RED_FROM_ULONG (c) / 255.0 @@ -4253,7 +4214,7 @@ ns_term_shutdown (int sig) /* code not reached in emacs.c after this is called by shut_down_emacs: */ if (STRINGP (Vauto_save_list_file_name)) - unlink (SDATA (Vauto_save_list_file_name)); + unlink (SSDATA (Vauto_save_list_file_name)); if (sig == 0 || sig == SIGTERM) { @@ -4600,7 +4561,7 @@ ns_term_shutdown (int sig) { [ns_pending_service_names addObject: userData]; [ns_pending_service_args addObject: [NSString stringWithUTF8String: - SDATA (ns_string_from_pasteboard (pboard))]]; + SSDATA (ns_string_from_pasteboard (pboard))]]; } @@ -4664,8 +4625,8 @@ ns_term_shutdown (int sig) if (!emacs_event) return; - if (newFont = [sender convertFont: - ((struct nsfont_info *)face->font)->nsfont]) + if ((newFont = [sender convertFont: + ((struct nsfont_info *)face->font)->nsfont])) { SET_FRAME_GARBAGED (emacsframe); /* now needed as of 2008/10 */ @@ -5141,7 +5102,6 @@ ns_term_shutdown (int sig) - (void)mouseDown: (NSEvent *)theEvent { NSPoint p = [self convertPoint: [theEvent locationInWindow] fromView: nil]; - Lisp_Object window; NSTRACE (mouseDown); @@ -5371,9 +5331,9 @@ ns_term_shutdown (int sig) - (void)windowDidResize: (NSNotification *)notification { +#ifdef NS_IMPL_GNUSTEP NSWindow *theWindow = [notification object]; -#ifdef NS_IMPL_GNUSTEP /* in GNUstep, at least currently, it's possible to get a didResize without getting a willResize.. therefore we need to act as if we got the willResize now */ @@ -5493,7 +5453,6 @@ ns_term_shutdown (int sig) Lisp_Object tem; NSWindow *win; NSButton *toggleButton; - int vbextra = NS_SCROLL_BAR_WIDTH (f); NSSize sz; NSColor *col; NSString *name; @@ -5546,7 +5505,7 @@ ns_term_shutdown (int sig) tem = f->name; name = [NSString stringWithUTF8String: - NILP (tem) ? (unsigned char *)"Emacs" : SDATA (tem)]; + NILP (tem) ? "Emacs" : SSDATA (tem)]; [win setTitle: name]; /* toolbar support */ @@ -5565,7 +5524,7 @@ ns_term_shutdown (int sig) tem = f->icon_name; if (!NILP (tem)) [win setMiniwindowTitle: - [NSString stringWithUTF8String: SDATA (tem)]]; + [NSString stringWithUTF8String: SSDATA (tem)]]; { NSScreen *screen = [win screen]; @@ -5710,18 +5669,13 @@ ns_term_shutdown (int sig) - (void)mouseEntered: (NSEvent *)theEvent { - NSPoint p = [self convertPoint: [theEvent locationInWindow] fromView: nil]; - struct ns_display_info *dpyinfo = FRAME_NS_DISPLAY_INFO (emacsframe); NSTRACE (mouseEntered); - last_mouse_movement_time = EV_TIMESTAMP (theEvent); } - (void)mouseExited: (NSEvent *)theEvent { - NSPoint p = [self convertPoint: [theEvent locationInWindow] fromView: nil]; - NSRect r; Mouse_HLInfo *hlinfo = emacsframe ? MOUSE_HL_INFO (emacsframe) : NULL; NSTRACE (mouseExited); @@ -5744,10 +5698,14 @@ ns_term_shutdown (int sig) NSTRACE (menuDown); if (context_menu_value == -1) context_menu_value = [sender tag]; - else - find_and_call_menu_selection (emacsframe, emacsframe->menu_bar_items_used, - emacsframe->menu_bar_vector, - (void *)[sender tag]); + else + { + NSInteger tag = [sender tag]; + find_and_call_menu_selection (emacsframe, emacsframe->menu_bar_items_used, + emacsframe->menu_bar_vector, + (void *)tag); + } + ns_send_appdefined (-1); return self; }