* Re: Fixes for 64-bit Emacs on Snow Leopard @ 2009-09-08 5:18 Eddie Hillenbrand 0 siblings, 0 replies; 8+ messages in thread From: Eddie Hillenbrand @ 2009-09-08 5:18 UTC (permalink / raw) To: emacs-devel [-- Attachment #1: Type: text/plain, Size: 270 bytes --] Hi, Thanks to Erik Charlebois I was able to create a patch that would get Emacs.app to build on Snow Leopard. I did not use all of his changes and there are still many warnings, but Emacs.app at least builds. The patch is attached. All credit goes to Erik! Yay! [-- Attachment #2: emacs-app-snow-leopard.patch --] [-- Type: application/octet-stream, Size: 5589 bytes --] diff --git a/src/dbusbind.c b/src/dbusbind.c --- a/src/dbusbind.c +++ b/src/dbusbind.c @@ -1247,7 +1247,7 @@ CHECK_STRING (service); GCPRO3 (bus, serial, service); - XD_DEBUG_MESSAGE ("%d %s ", XUINT (serial), SDATA (service)); + XD_DEBUG_MESSAGE ("%ld %s ", XUINT (serial), SDATA (service)); /* Open a connection to the bus. */ connection = xd_initialize (bus); @@ -1341,7 +1341,7 @@ CHECK_STRING (service); GCPRO3 (bus, serial, service); - XD_DEBUG_MESSAGE ("%d %s ", XUINT (serial), SDATA (service)); + XD_DEBUG_MESSAGE ("%ld %s ", XUINT (serial), SDATA (service)); /* Open a connection to the bus. */ connection = xd_initialize (bus); diff --git a/src/font.c b/src/font.c --- a/src/font.c +++ b/src/font.c @@ -1357,7 +1357,7 @@ { f[XLFD_AVGWIDTH_INDEX] = alloca (11); len += sprintf (f[XLFD_AVGWIDTH_INDEX], - "%d", XINT (AREF (font, FONT_AVGWIDTH_INDEX))) + 1; + "%ld", XINT (AREF (font, FONT_AVGWIDTH_INDEX))) + 1; } else f[XLFD_AVGWIDTH_INDEX] = "*", len += 2; @@ -1673,7 +1673,7 @@ } if (INTEGERP (AREF (font, FONT_DPI_INDEX))) - len += sprintf (work, ":dpi=%d", XINT (AREF (font, FONT_DPI_INDEX))); + len += sprintf (work, ":dpi=%ld", XINT (AREF (font, FONT_DPI_INDEX))); if (INTEGERP (AREF (font, FONT_SPACING_INDEX))) len += strlen (":spacing=100"); if (INTEGERP (AREF (font, FONT_AVGWIDTH_INDEX))) @@ -1686,7 +1686,7 @@ if (STRINGP (val)) len += SBYTES (val); else if (INTEGERP (val)) - len += sprintf (work, "%d", XINT (val)); + len += sprintf (work, "%ld", XINT (val)); else if (SYMBOLP (val)) len += (NILP (val) ? 5 : 4); /* for "false" or "true" */ } @@ -1713,9 +1713,9 @@ p += sprintf (p, ":%s=%s", style_names[i], SDATA (SYMBOL_NAME (styles[i]))); if (INTEGERP (AREF (font, FONT_DPI_INDEX))) - p += sprintf (p, ":dpi=%d", XINT (AREF (font, FONT_DPI_INDEX))); + p += sprintf (p, ":dpi=%ld", XINT (AREF (font, FONT_DPI_INDEX))); if (INTEGERP (AREF (font, FONT_SPACING_INDEX))) - p += sprintf (p, ":spacing=%d", XINT (AREF (font, FONT_SPACING_INDEX))); + p += sprintf (p, ":spacing=%ld", XINT (AREF (font, FONT_SPACING_INDEX))); if (INTEGERP (AREF (font, FONT_AVGWIDTH_INDEX))) { if (XINT (AREF (font, FONT_AVGWIDTH_INDEX)) == 0) diff --git a/src/nsfns.m b/src/nsfns.m --- a/src/nsfns.m +++ b/src/nsfns.m @@ -1772,7 +1772,7 @@ { check_ns (); #ifdef NS_IMPL_COCOA - PSFlush (); + /*PSFlush ();*/ #endif /*ns_delete_terminal (dpyinfo->terminal); */ [NSApp terminate: NSApp]; diff --git a/src/nsfont.m b/src/nsfont.m --- a/src/nsfont.m +++ b/src/nsfont.m @@ -245,7 +245,10 @@ return w; } #endif - w = [sfont widthOfString: cstr]; + NSDictionary *attrsDictionary = + [NSDictionary dictionaryWithObject:sfont + forKey:NSFontAttributeName]; + w = [cstr sizeWithAttributes:attrsDictionary].width; return max (w, 2.0); } diff --git a/src/nsgui.h b/src/nsgui.h --- a/src/nsgui.h +++ b/src/nsgui.h @@ -129,12 +129,13 @@ } XRectangle; #ifndef __OBJC__ -typedef struct _NSPoint { float x, y; } NSPoint; -typedef struct _NSSize { float width, height; } NSSize; +typedef double CGFloat; +typedef struct _NSPoint { CGFloat x, y; } NSPoint; +typedef struct _NSSize { CGFloat width, height; } NSSize; typedef struct _NSRect { NSPoint origin; NSSize size; } NSRect; #endif -#define NativeRectangle struct _NSRect +#define NativeRectangle NSRect #define CONVERT_TO_XRECT(xr, nr) \ ((xr).x = (nr).origin.x, \ diff --git a/src/nsterm.m b/src/nsterm.m --- a/src/nsterm.m +++ b/src/nsterm.m @@ -1481,7 +1481,7 @@ Convert a color to a lisp string with the RGB equivalent -------------------------------------------------------------------------- */ { - float red, green, blue, alpha, gray; + CGFloat red, green, blue, alpha, gray; char buf[1024]; const char *str; NSTRACE (ns_color_to_lisp); @@ -1523,7 +1523,7 @@ and set color_def pixel to the resulting index. -------------------------------------------------------------------------- */ { - float r, g, b, a; + CGFloat r, g, b, a; [((NSColor *)col) getRed: &r green: &g blue: &b alpha: &a]; color_def->red = r * 65535; @@ -5833,15 +5833,18 @@ em_portion = portion; em_whole = whole; - if (portion >= whole) - [self setFloatValue: 0.0 knobProportion: 1.0]; + if (portion >= whole) { + [self setDoubleValue: 0.0]; + [self setKnobProportion: 1.0]; + } else { float pos, por; portion = max ((float)whole*min_portion/pixel_height, portion); pos = (float)position / (whole - portion); por = (float)portion/whole; - [self setFloatValue: pos knobProportion: por]; + [self setDoubleValue: pos]; + [self setKnobProportion: por]; } #ifdef NS_IMPL_GNUSTEP [self display]; @@ -5946,7 +5949,7 @@ case NSScrollerKnobSlot: /* GNUstep-only */ last_hit_part = scroll_bar_move_ratio; break; default: /* NSScrollerNoPart? */ - fprintf (stderr, "EmacsScoller-mouseDown: unexpected part %d\n", part); + fprintf (stderr, "EmacsScoller-mouseDown: unexpected part %ld\n", part); return; } diff --git a/src/process.c b/src/process.c --- a/src/process.c +++ b/src/process.c @@ -1522,7 +1522,7 @@ insert_string ("?"); if (INTEGERP (speed)) { - sprintf (tembuf, " at %d b/s", XINT (speed)); + sprintf (tembuf, " at %ld b/s", XINT (speed)); insert_string (tembuf); } insert_string (")\n"); [-- Attachment #3: Type: text/plain, Size: 1 bytes --] ^ permalink raw reply [flat|nested] 8+ messages in thread
* Fixes for 64-bit Emacs on Snow Leopard @ 2009-09-07 21:08 Erik Charlebois 2009-09-07 22:03 ` Chong Yidong 2009-09-07 23:26 ` David Reitter 0 siblings, 2 replies; 8+ messages in thread From: Erik Charlebois @ 2009-09-07 21:08 UTC (permalink / raw) To: emacs-devel [-- Attachment #1: Type: text/plain, Size: 690 bytes --] I've posted the steps/fixes to get a 64-bit NS/Cocoa Emacs 23.1 working for Snow Leopard on my blog at http://blog.fac9.com/index.php/2009/08/30/building-a-64-bit-emacs-on-snow-leopard/ . I've been using it for a week without problems. Feel free to roll those changes in, I haven't contributed to any GNU projects before so I'm not really sure where to begin making a patch / dealing with copyright assignment. Which brings me to: is there a page somewhere with the steps on how to get involved /w emacs dev, what the contribution protocols are, who owns what area and such? I'm interested in improving Mac and Win32 support. Erik Charlebois erikcharlebois@gmail.com [-- Attachment #2: Type: text/html, Size: 2101 bytes --] ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Fixes for 64-bit Emacs on Snow Leopard 2009-09-07 21:08 Erik Charlebois @ 2009-09-07 22:03 ` Chong Yidong 2009-09-09 12:56 ` Adrian Robert 2009-09-07 23:26 ` David Reitter 1 sibling, 1 reply; 8+ messages in thread From: Chong Yidong @ 2009-09-07 22:03 UTC (permalink / raw) To: Erik Charlebois; +Cc: David Reitter, Adrian Robert, emacs-devel Erik Charlebois <erikcharlebois@gmail.com> writes: > I've posted the steps/fixes to get a 64-bit NS/Cocoa Emacs 23.1 working for > Snow Leopard on my blog: > >> Steps to fix the 64-bit Emacs on Snow Leopard (configure –with-ns, make, >> make install): > >> Undef HAVE_POSIX_MEMALIGN in the #ifdef temacs part of >> src/s/darwin.h. posix_memalign does not call wind up calling the hooked >> unexec_malloc, so you wind up with incorrect free calls. > > Feel free to roll those changes in, I haven't contributed to any GNU > projects before so I'm not really sure where to begin making a patch / > dealing with copyright assignment. Could someone review this and check it in if it's the right thing to do? (David or Adrian?) > Which brings me to: is there a page somewhere with the steps on how to get > involved /w emacs dev, what the contribution protocols are, who owns what area > and such? I'm interested in improving Mac and Win32 support. Please post patches to this mailing list. If you're interested in posting significant changes, you'll need a copyright assignment; email me privately, and I'll guide you through the process. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Fixes for 64-bit Emacs on Snow Leopard 2009-09-07 22:03 ` Chong Yidong @ 2009-09-09 12:56 ` Adrian Robert 0 siblings, 0 replies; 8+ messages in thread From: Adrian Robert @ 2009-09-09 12:56 UTC (permalink / raw) To: Chong Yidong; +Cc: David Reitter, Erik Charlebois, emacs-devel > On Sep 7, 2009, at 6:03 PM, Chong Yidong wrote: >> Erik Charlebois <erikcharlebois@gmail.com> writes: >> >>> I've posted the steps/fixes to get a 64-bit NS/Cocoa Emacs 23.1 >>> working for >>> Snow Leopard on my blog: >>> ... >>> >>> Feel free to roll those changes in, I haven't contributed to any GNU >>> projects before so I'm not really sure where to begin making a >>> patch / >>> dealing with copyright assignment. >> >> Could someone review this and check it in if it's the right thing >> to do? >> (David or Adrian?) Excellent. I should be able to take a look at this next week. (URL is http://blog.fac9.com/index.php/2009/08/30/building-a-64-bit- emacs-on-snow-leopard/ ) Adrian ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Fixes for 64-bit Emacs on Snow Leopard 2009-09-07 21:08 Erik Charlebois 2009-09-07 22:03 ` Chong Yidong @ 2009-09-07 23:26 ` David Reitter 2009-09-08 8:14 ` Erik Charlebois 1 sibling, 1 reply; 8+ messages in thread From: David Reitter @ 2009-09-07 23:26 UTC (permalink / raw) To: Erik Charlebois; +Cc: emacs-devel Hi Erik, On Sep 7, 2009, at 5:08 PM, Erik Charlebois wrote: > I've posted the steps/fixes to get a 64-bit NS/Cocoa Emacs 23.1 > working for Snow Leopard on my blog at http://blog.fac9.com/index.php/2009/08/30/building-a-64-bit-emacs-on-snow-leopard/ > . I've been using it for a week without problems. Thanks, that's great news. Regarding your point 5: I did not redefine CGFloat when I tried to address these things; I'm not sure if it is necessary. You might be right. See this file http://github.com/davidswelt/aquamacs-emacs/blob/874784331f6e1bcfe319823616067bcf2432c29a/src/nsgui.h Would you be willing to post a patch with all of your changes? Thanks again - David ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Fixes for 64-bit Emacs on Snow Leopard 2009-09-07 23:26 ` David Reitter @ 2009-09-08 8:14 ` Erik Charlebois 2009-09-08 17:38 ` CHENG Gao 2009-09-09 7:32 ` Erik Charlebois 0 siblings, 2 replies; 8+ messages in thread From: Erik Charlebois @ 2009-09-08 8:14 UTC (permalink / raw) To: David Reitter; +Cc: emacs-devel [-- Attachment #1: 0001-Fixes-to-get-a-working-64-bit-Emacs-on-OS-X-10.6.patch --] [-- Type: application/octet-stream, Size: 21123 bytes --] From 1f11770e68581826091fbf24a60fd3f7d0259c52 Mon Sep 17 00:00:00 2001 From: Erik Charlebois <erikc@ermac.local> Date: Tue, 8 Sep 2009 00:44:33 -0700 Subject: [PATCH 1/2] Fixes to get a working 64-bit Emacs on OS X 10.6. --- lib-src/movemail.c | 2 +- src/ChangeLog | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/emacs.c | 2 +- src/font.c | 11 ++++++----- src/menu.c | 2 +- src/nsfns.m | 4 ++-- src/nsfont.m | 44 ++++++++++++++++++++++++++++++++------------ src/nsgui.h | 18 +++++++++++++++--- src/nsimage.m | 4 ++-- src/nsmenu.m | 6 +++--- src/nsterm.h | 15 +++++++++++---- src/nsterm.m | 31 ++++++++++++++++++++++--------- src/process.c | 2 +- src/unexmacosx.c | 4 ++-- 14 files changed, 151 insertions(+), 46 deletions(-) diff --git a/lib-src/movemail.c b/lib-src/movemail.c index 732f8dd..2feaae8 100644 --- a/lib-src/movemail.c +++ b/lib-src/movemail.c @@ -622,7 +622,7 @@ error (s1, s2, s3) else if (s2) fprintf (stderr, s1, s2); else - fprintf (stderr, s1); + fputs (s1, stderr); fprintf (stderr, "\n"); } diff --git a/src/ChangeLog b/src/ChangeLog index fdbe825..fa355da 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,55 @@ +2009-09-08 Erik Charlebois <erikcharlebois@gmail.com> + + * movemail.c (error): Change fprintf to fputs to fix warning. + + * emacs.c (main): Remove extra format specifier to fix warning. + + * font.c (font_unparse_xlfd): Print EMACS_INT with %ld. + (font_unparse_fcname): Print EMACS_INT with %ld. + + * menu.c (find_and_return_menu_selection): Fix truncation warning. + + * nsfns.m (x-close-connection): PSFlush does not exist on 64-bit Cocoa. + (xw-color-values): Use CGFloat instead of float. + + * nsfont.m (ns_char_width): Use sizeWithAttributes: instead of + widthOfString:, which does no exist in 64-bit Cocoa. + (ns_findfonts): Print EMACS_INT with %ld. + (nsfont_list_family): Print EMACS_INT with %ld. + (nsfont_open): Use Core Text for OS X 10.5 and later. + (nsfont_close): Release Core Text resource. + (ns_uni_to_glyphs): Use NSUInteger when calling Cocoa APIs. + (layoutOptions): Use NSUInteger in method signature. + (insertGlyphs): Use NSUIntger in method signature. + (setIntAttribute): Use NSInteger and NSUInteger in method signature. + + * nsgui.h: Add typedefs for NSUInteger, NSInteger and CGFloat for + pre-10.5 OS X and GNUstep. + + * nsimage.m (setXBMColor): Use CGFloat for calls to Cocoa. + (getPixelAtX): Use CGFloat for calls to Cocoa. + + * nsmenu.m (addItemWithWidgetValue): Use NSInteger for call to Cocoa. + (fillWithWidgetValue): sizeToFit is deprecated (does nothing). Remove + call for OS X 10.5 and later. + (initWithContentRect): Use NSUInteger in method signature. + + * nsterm.h: Add Delegate protocols to interfaces to fix warnings. + Use Core Text on OS X 10.5 and later. + + * nsterm.m (mouseDown): Remove redundant leading 0s in format specifier. + (ns_query_color): Use CGFloat for calls to Cocoa. + (characterIndexForPoint): Use NUSInteger in method signature. + (draggingEntered): Use NSDragOperation in method signature. + (scrollerWidth): Use CGFloat in method signature. + (setPosition): Use setDoubleValue: and setKnobProportion: on 10.5 and + later since setFloatVAlue:knobProportion: is deprecated. + (mouseDown): Use %ld to print NSScrollerPart. + + * process.c (list_processes_1): Use %ld to print EMACS_INT. + + * unexmacosx.c (read_load_commands): Use %ld to print vm_address_t. + 2009-09-04 Jan Djärv <jan.h.d@swipnet.se> * xterm.c (x_focus_changed): If we get a focusout and pointer diff --git a/src/emacs.c b/src/emacs.c index 2c14be5..44ed9ce 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -1181,7 +1181,7 @@ main (int argc, char **argv) argv[skip_args] = fdStr; execv (argv[0], argv); - fprintf (stderr, "emacs daemon: exec failed: %d\t%d\n", errno); + fprintf (stderr, "emacs daemon: exec failed: %d\n", errno); exit (1); } diff --git a/src/font.c b/src/font.c index cfc4852..7571a00 100644 --- a/src/font.c +++ b/src/font.c @@ -1357,7 +1357,7 @@ font_unparse_xlfd (font, pixel_size, name, nbytes) { f[XLFD_AVGWIDTH_INDEX] = alloca (11); len += sprintf (f[XLFD_AVGWIDTH_INDEX], - "%d", XINT (AREF (font, FONT_AVGWIDTH_INDEX))) + 1; + "%ld", (long) XINT (AREF (font, FONT_AVGWIDTH_INDEX))) + 1; } else f[XLFD_AVGWIDTH_INDEX] = "*", len += 2; @@ -1673,7 +1673,7 @@ font_unparse_fcname (font, pixel_size, name, nbytes) } if (INTEGERP (AREF (font, FONT_DPI_INDEX))) - len += sprintf (work, ":dpi=%d", XINT (AREF (font, FONT_DPI_INDEX))); + len += sprintf (work, ":dpi=%ld", (long) XINT (AREF (font, FONT_DPI_INDEX))); if (INTEGERP (AREF (font, FONT_SPACING_INDEX))) len += strlen (":spacing=100"); if (INTEGERP (AREF (font, FONT_AVGWIDTH_INDEX))) @@ -1686,7 +1686,7 @@ font_unparse_fcname (font, pixel_size, name, nbytes) if (STRINGP (val)) len += SBYTES (val); else if (INTEGERP (val)) - len += sprintf (work, "%d", XINT (val)); + len += sprintf (work, "%ld", (long) XINT (val)); else if (SYMBOLP (val)) len += (NILP (val) ? 5 : 4); /* for "false" or "true" */ } @@ -1713,9 +1713,10 @@ font_unparse_fcname (font, pixel_size, name, nbytes) p += sprintf (p, ":%s=%s", style_names[i], SDATA (SYMBOL_NAME (styles[i]))); if (INTEGERP (AREF (font, FONT_DPI_INDEX))) - p += sprintf (p, ":dpi=%d", XINT (AREF (font, FONT_DPI_INDEX))); + p += sprintf (p, ":dpi=%ld", (long) XINT (AREF (font, FONT_DPI_INDEX))); if (INTEGERP (AREF (font, FONT_SPACING_INDEX))) - p += sprintf (p, ":spacing=%d", XINT (AREF (font, FONT_SPACING_INDEX))); + p += sprintf (p, ":spacing=%ld", + (long) XINT (AREF (font, FONT_SPACING_INDEX))); if (INTEGERP (AREF (font, FONT_AVGWIDTH_INDEX))) { if (XINT (AREF (font, FONT_AVGWIDTH_INDEX)) == 0) diff --git a/src/menu.c b/src/menu.c index 940986f..23a7013 100644 --- a/src/menu.c +++ b/src/menu.c @@ -1005,7 +1005,7 @@ find_and_return_menu_selection (FRAME_PTR f, int keymaps, void *client_data) { entry = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_VALUE]; - if ((int) (EMACS_INT)client_data == (int)(&XVECTOR (menu_items)->contents[i])) + if ((EMACS_INT)client_data == (EMACS_INT)(&XVECTOR (menu_items)->contents[i])) { if (keymaps != 0) { diff --git a/src/nsfns.m b/src/nsfns.m index 136ae03..f941a16 100644 --- a/src/nsfns.m +++ b/src/nsfns.m @@ -1771,7 +1771,7 @@ The argument DISPLAY is currently ignored. */) Lisp_Object display; { check_ns (); -#ifdef NS_IMPL_COCOA +#if defined(NS_IMPL_COCOA) && !defined(_LP64) PSFlush (); #endif /*ns_delete_terminal (dpyinfo->terminal); */ @@ -2237,7 +2237,7 @@ DEFUN ("xw-color-values", Fxw_color_values, Sxw_color_values, 1, 2, 0, Lisp_Object color, frame; { NSColor * col; - float red, green, blue, alpha; + CGFloat red, green, blue, alpha; check_ns (); CHECK_STRING (color); diff --git a/src/nsfont.m b/src/nsfont.m index 46c50aa..c141fa4 100644 --- a/src/nsfont.m +++ b/src/nsfont.m @@ -245,7 +245,10 @@ ns_char_width (NSFont *sfont, int c) return w; } #endif - w = [sfont widthOfString: cstr]; + NSDictionary *attrsDictionary = + [NSDictionary dictionaryWithObject: sfont + forKey: NSFontAttributeName]; + w = [cstr sizeWithAttributes: attrsDictionary].width; return max (w, 2.0); } @@ -517,7 +520,8 @@ ns_findfonts (Lisp_Object font_spec, BOOL isMatch) return ns_fallback_entity (); if (NSFONT_TRACE) - fprintf (stderr, " Returning %d entities.\n", XINT (Flength (list))); + fprintf (stderr, " Returning %ld entities.\n", + (long) XINT (Flength (list))); return list; } @@ -623,8 +627,8 @@ nsfont_list_family (Lisp_Object frame) /* FIXME: escape the name? */ if (NSFONT_TRACE) - fprintf (stderr, "nsfont: list families returning %d entries\n", - XINT (Flength (list))); + fprintf (stderr, "nsfont: list families returning %ld entries\n", + (long) XINT (Flength (list))); return list; } @@ -843,14 +847,27 @@ nsfont_open (FRAME_PTR f, Lisp_Object font_entity, int pixel_size) ((CFStringRef)@"Monaco", kATSOptionFlagsDefault); } } + +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 + font_info->ctfont = + CTFontCreateWithPlatformFont (atsFont, 0.0f, NULL, NULL); + font_info->cgfont = CTFontCopyGraphicsFont (font_info->ctfont, NULL); +#else font_info->cgfont = CGFontCreateWithPlatformFont ((void*)&atsFont); +#endif } #endif /* set up metrics portion of font struct */ font->ascent = [sfont ascender]; font->descent = -[sfont descender]; - font->min_width = [sfont widthOfString: @"|"]; /* FIXME */ + + /* FIXME */ + NSDictionary *attrsDictionary = + [NSDictionary dictionaryWithObject: sfont + forKey: NSFontAttributeName]; + font->min_width = [@"|" sizeWithAttributes: attrsDictionary].width; + font->space_width = lrint (ns_char_width (sfont, ' ')); font->average_width = lrint (font_info->width); font->max_width = lrint (font_info->max_bounds.width); @@ -888,6 +905,9 @@ nsfont_close (FRAME_PTR f, struct font *font) [font_info->nsfont release]; #ifdef NS_IMPL_COCOA CGFontRelease (font_info->cgfont); +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 + CFRelease (font_info->ctfont); +#endif #endif xfree (font_info->name); xfree (font_info); @@ -1308,7 +1328,7 @@ ns_uni_to_glyphs (struct nsfont_info *font_info, unsigned char block) NSGlyphGenerator *glyphGenerator = [NSGlyphGenerator sharedGlyphGenerator]; /*NSCharacterSet *coveredChars = [nsfont coveredCharacterSet]; */ unsigned int numGlyphs = [font_info->nsfont numberOfGlyphs]; - unsigned int gInd =0, cInd =0; + NSUInteger gInd =0, cInd =0; [glyphStorage setString: allChars font: font_info->nsfont]; [glyphGenerator generateGlyphsForGlyphStorage: glyphStorage @@ -1439,7 +1459,7 @@ ns_glyph_metrics (struct nsfont_info *font_info, unsigned char block) } /* NSGlyphStorage protocol */ -- (unsigned int)layoutOptions +- (NSUInteger)layoutOptions { return 0; } @@ -1449,9 +1469,9 @@ ns_glyph_metrics (struct nsfont_info *font_info, unsigned char block) return attrStr; } -- (void)insertGlyphs: (const NSGlyph *)glyphs length: (unsigned int)length - forStartingGlyphAtIndex: (unsigned int)glyphIndex - characterIndex: (unsigned int)charIndex +- (void)insertGlyphs: (const NSGlyph *)glyphs length: (NSUInteger)length + forStartingGlyphAtIndex: (NSUInteger)glyphIndex + characterIndex: (NSUInteger)charIndex { len = glyphIndex+length; for (i =glyphIndex; i<len; i++) @@ -1460,8 +1480,8 @@ ns_glyph_metrics (struct nsfont_info *font_info, unsigned char block) maxGlyph = len; } -- (void)setIntAttribute: (int)attributeTag value: (int)val - forGlyphAtIndex: (unsigned)glyphIndex +- (void)setIntAttribute: (NSInteger)attributeTag value: (NSInteger)val + forGlyphAtIndex: (NSUInteger)glyphIndex { return; } diff --git a/src/nsgui.h b/src/nsgui.h index 9bf6be6..5594b7b 100644 --- a/src/nsgui.h +++ b/src/nsgui.h @@ -128,13 +128,25 @@ typedef struct { unsigned width, height; } XRectangle; +#if !defined(__OBJC__) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5 +#ifdef _LP64 +typedef unsigned long NSUInteger; +typedef long NSInteger; +typedef double CGFloat; +#else +typedef unsigned int NSUInteger; +typedef int NSInteger; +typedef float CGFloat; +#endif +#endif + #ifndef __OBJC__ -typedef struct _NSPoint { float x, y; } NSPoint; -typedef struct _NSSize { float width, height; } NSSize; +typedef struct _NSPoint { CGFloat x, y; } NSPoint; +typedef struct _NSSize { CGFloat width, height; } NSSize; typedef struct _NSRect { NSPoint origin; NSSize size; } NSRect; #endif -#define NativeRectangle struct _NSRect +#define NativeRectangle NSRect #define CONVERT_TO_XRECT(xr, nr) \ ((xr).x = (nr).origin.x, \ diff --git a/src/nsimage.m b/src/nsimage.m index 9ef7ad3..87499b0 100644 --- a/src/nsimage.m +++ b/src/nsimage.m @@ -329,7 +329,7 @@ static EmacsImage *ImageList = nil; NSSize s = [self size]; int len = (int) s.width * s.height; unsigned char *planes[5]; - float r, g, b, a; + CGFloat r, g, b, a; NSColor *rgbColor; if (bmRep == nil || color == nil) @@ -431,7 +431,7 @@ static EmacsImage *ImageList = nil; else if (onTiger) { NSColor *color = [bmRep colorAtX: x y: y]; - float r, g, b, a; + CGFloat r, g, b, a; [color getRed: &r green: &g blue: &b alpha: &a]; return ((int)(a * 255.0) << 24) | ((int)(r * 255.0) << 16) | ((int)(g * 255.0) << 8) diff --git a/src/nsmenu.m b/src/nsmenu.m index 0518466..e8549b4 100644 --- a/src/nsmenu.m +++ b/src/nsmenu.m @@ -656,7 +656,7 @@ name_is_separator (name) else [item setState: NSOffState]; - [item setTag: (int)wv->call_data]; + [item setTag: (NSInteger)wv->call_data]; } return item; @@ -708,7 +708,7 @@ name_is_separator (name) #ifdef NS_IMPL_GNUSTEP if ([[self window] isVisible]) [self sizeToFit]; -#else +#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5 if ([self supermenu] == nil) [self sizeToFit]; #endif @@ -1611,7 +1611,7 @@ ns_popup_dialog (Lisp_Object position, Lisp_Object contents, Lisp_Object header) #define TEXTHEIGHT 20.0 #define MINCELLWIDTH 90.0 -- initWithContentRect: (NSRect)contentRect styleMask: (unsigned int)aStyle +- initWithContentRect: (NSRect)contentRect styleMask: (NSUInteger)aStyle backing: (NSBackingStoreType)backingType defer: (BOOL)flag { NSSize spacing = {SPACER, SPACER}; diff --git a/src/nsterm.h b/src/nsterm.h index 7375e3c..46335d9 100644 --- a/src/nsterm.h +++ b/src/nsterm.h @@ -54,7 +54,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ @class EmacsToolbar; -@interface EmacsView : NSView <NSTextInput> +@interface EmacsView : NSView <NSTextInput, NSWindowDelegate> { char *old_title; BOOL windowClosing; @@ -104,7 +104,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ ========================================================================== */ -@interface EmacsMenu : NSMenu +@interface EmacsMenu : NSMenu <NSMenuDelegate> { struct frame *frame; unsigned long keyEquivModMask; @@ -131,7 +131,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ @class EmacsImage; -@interface EmacsToolbar : NSToolbar +@interface EmacsToolbar : NSToolbar <NSToolbarDelegate> { EmacsView *emacsView; NSMutableDictionary *identifierToItem; @@ -174,7 +174,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ - (Lisp_Object)runDialogAt: (NSPoint)p; @end -@interface EmacsTooltip : NSObject +@interface EmacsTooltip : NSObject <NSWindowDelegate> { NSWindow *win; NSTextField *textField; @@ -420,9 +420,16 @@ struct nsfont_info #else /* GNUstep or OS X < 10.3 */ void *cgfont; #endif + /* ctFont is used only on OS X 10.5+ */ +#if defined (NS_IMPL_COCOA) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5) + CTFontRef ctfont; +#else /* GNUstep or OS X < 10.5 */ + void *ctfont; +#endif #else /* ! OBJC */ void *nsfont; void *cgfont; + void *ctfont; #endif char bold, ital; /* convenience flags */ char synthItal; diff --git a/src/nsterm.m b/src/nsterm.m index 5a58f1d..233f699 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -1481,7 +1481,7 @@ ns_color_to_lisp (NSColor *col) Convert a color to a lisp string with the RGB equivalent -------------------------------------------------------------------------- */ { - float red, green, blue, alpha, gray; + CGFloat red, green, blue, alpha, gray; char buf[1024]; const char *str; NSTRACE (ns_color_to_lisp); @@ -1501,13 +1501,13 @@ ns_color_to_lisp (NSColor *col) { [[col colorUsingColorSpaceName: NSCalibratedWhiteColorSpace] getWhite: &gray alpha: &alpha]; - snprintf (buf, sizeof (buf), "#%02.2lx%02.2lx%02.2lx", + snprintf (buf, sizeof (buf), "#%2.2lx%2.2lx%2.2lx", lrint (gray * 0xff), lrint (gray * 0xff), lrint (gray * 0xff)); UNBLOCK_INPUT; return build_string (buf); } - snprintf (buf, sizeof (buf), "#%02.2lx%02.2lx%02.2lx", + snprintf (buf, sizeof (buf), "#%2.2lx%2.2lx%2.2lx", lrint (red*0xff), lrint (green*0xff), lrint (blue*0xff)); UNBLOCK_INPUT; @@ -1523,7 +1523,7 @@ ns_query_color(void *col, XColor *color_def, int setPixel) and set color_def pixel to the resulting index. -------------------------------------------------------------------------- */ { - float r, g, b, a; + CGFloat r, g, b, a; [((NSColor *)col) getRed: &r green: &g blue: &b alpha: &a]; color_def->red = r * 65535; @@ -4741,7 +4741,7 @@ extern void update_window_cursor (struct window *w, int on); return NSMakeRange (NSNotFound, 0); } -- (unsigned int)characterIndexForPoint: (NSPoint)thePoint +- (NSUInteger)characterIndexForPoint: (NSPoint)thePoint { if (NS_KEYLOG) NSLog (@"characterIndexForPoint request"); @@ -5418,7 +5418,7 @@ extern void update_window_cursor (struct window *w, int on); /* NSDraggingDestination protocol methods. Actually this is not really a protocol, but a category of Object. O well... */ --(unsigned int) draggingEntered: (id <NSDraggingInfo>) sender +-(NSDragOperation) draggingEntered: (id <NSDraggingInfo>) sender { NSTRACE (draggingEntered); return NSDragOperationGeneric; @@ -5703,7 +5703,7 @@ extern void update_window_cursor (struct window *w, int on); #define SCROLL_BAR_FIRST_DELAY 0.5 #define SCROLL_BAR_CONTINUOUS_DELAY (1.0 / 15) -+ (float) scrollerWidth ++ (CGFloat) scrollerWidth { /* TODO: if we want to allow variable widths, this is the place to do it, however neither GNUstep nor Cocoa support it very well */ @@ -5834,14 +5834,26 @@ extern void update_window_cursor (struct window *w, int on); em_whole = whole; if (portion >= whole) - [self setFloatValue: 0.0 knobProportion: 1.0]; + { +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 + [self setDoubleValue: 0.0]; + [self setKnobProportion: 1.0]; +#else + [self setFloatValue: 0.0 knobProportion: 1.0]; +#endif + } else { float pos, por; portion = max ((float)whole*min_portion/pixel_height, portion); pos = (float)position / (whole - portion); por = (float)portion/whole; +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 + [self setDoubleValue: pos]; + [self setKnobProportion: por]; +#else [self setFloatValue: pos knobProportion: por]; +#endif } #ifdef NS_IMPL_GNUSTEP [self display]; @@ -5946,7 +5958,8 @@ extern void update_window_cursor (struct window *w, int on); case NSScrollerKnobSlot: /* GNUstep-only */ last_hit_part = scroll_bar_move_ratio; break; default: /* NSScrollerNoPart? */ - fprintf (stderr, "EmacsScoller-mouseDown: unexpected part %d\n", part); + fprintf (stderr, "EmacsScoller-mouseDown: unexpected part %ld\n", + (long) part); return; } diff --git a/src/process.c b/src/process.c index e65d495..99f57d3 100644 --- a/src/process.c +++ b/src/process.c @@ -1522,7 +1522,7 @@ list_processes_1 (query_only) insert_string ("?"); if (INTEGERP (speed)) { - sprintf (tembuf, " at %d b/s", XINT (speed)); + sprintf (tembuf, " at %ld b/s", (long) XINT (speed)); insert_string (tembuf); } insert_string (")\n"); diff --git a/src/unexmacosx.c b/src/unexmacosx.c index bb71d8f..489489d 100644 --- a/src/unexmacosx.c +++ b/src/unexmacosx.c @@ -684,8 +684,8 @@ read_load_commands () } } - printf ("Highest address of load commands in input file: %#8x\n", - infile_lc_highest_addr); + printf ("Highest address of load commands in input file: %#8lx\n", + (long) infile_lc_highest_addr); printf ("Lowest offset of all sections in __TEXT segment: %#8lx\n", text_seg_lowest_offset); -- 1.6.4.1 [-- Attachment #2: 0002-Fix-Changelogs.patch --] [-- Type: application/octet-stream, Size: 1074 bytes --] From b86cef4736cc0ce5afe531a59c1b470256f12f65 Mon Sep 17 00:00:00 2001 From: Erik Charlebois <erikc@ermac.local> Date: Tue, 8 Sep 2009 00:50:20 -0700 Subject: [PATCH 2/2] Fix Changelogs. --- lib-src/ChangeLog | 4 ++++ src/ChangeLog | 2 -- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog index 04bc7a7..f183872 100644 --- a/lib-src/ChangeLog +++ b/lib-src/ChangeLog @@ -1,3 +1,7 @@ +2009-09-08 Erik Charlebois <erikcharlebois@gmail.com> + + * movemail.c (error): Change fprintf to fputs to fix warning. + 2009-08-19 Glenn Morris <rgm@gnu.org> * cvtmail.c: Remove file. diff --git a/src/ChangeLog b/src/ChangeLog index fa355da..02fab25 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,7 +1,5 @@ 2009-09-08 Erik Charlebois <erikcharlebois@gmail.com> - * movemail.c (error): Change fprintf to fputs to fix warning. - * emacs.c (main): Remove extra format specifier to fix warning. * font.c (font_unparse_xlfd): Print EMACS_INT with %ld. -- 1.6.4.1 [-- Attachment #3: Type: text/plain, Size: 1300 bytes --] I've attached two patches (sorry about that, first time I used git and I got the ChangeLogs wrong after committing :). I've tried to make sure nothing's been introduced that would break pre-10.5 OS X or GNUstep, but I don't have either of those systems to test with. The bulk of the changes deal with deprecated Cocoa methods, LP64 issues (printf specifiers, NSInteger/NSUInteger) and CGFloat being double on 64-bit Cocoa. I've built/tested on 32- and 64-bit OS X 10.6. Erik Charlebois erikcharlebois@gmail.com On 2009-09-07, at 4:26 PM, David Reitter wrote: > Hi Erik, > > On Sep 7, 2009, at 5:08 PM, Erik Charlebois wrote: > >> I've posted the steps/fixes to get a 64-bit NS/Cocoa Emacs 23.1 >> working for Snow Leopard on my blog at http://blog.fac9.com/index.php/2009/08/30/building-a-64-bit-emacs-on-snow-leopard/ >> . I've been using it for a week without problems. > > Thanks, that's great news. > > Regarding your point 5: I did not redefine CGFloat when I tried to > address these things; I'm not sure if it is necessary. You might be > right. > See this file > > http://github.com/davidswelt/aquamacs-emacs/blob/874784331f6e1bcfe319823616067bcf2432c29a/src/nsgui.h > > Would you be willing to post a patch with all of your changes? > > Thanks again > - David > ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: Fixes for 64-bit Emacs on Snow Leopard 2009-09-08 8:14 ` Erik Charlebois @ 2009-09-08 17:38 ` CHENG Gao 2009-09-09 7:32 ` Erik Charlebois 1 sibling, 0 replies; 8+ messages in thread From: CHENG Gao @ 2009-09-08 17:38 UTC (permalink / raw) To: emacs-devel I search whole all DocSets including legacy library, and can not find PSflush(). Gooling shows it's in OpenStep library. Since it's included in NS_IMPL_COCOA, I trust it's safe to remove it. -- The truth which makes men free is for the most part the truth which men prefer not to hear. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Fixes for 64-bit Emacs on Snow Leopard 2009-09-08 8:14 ` Erik Charlebois 2009-09-08 17:38 ` CHENG Gao @ 2009-09-09 7:32 ` Erik Charlebois 1 sibling, 0 replies; 8+ messages in thread From: Erik Charlebois @ 2009-09-09 7:32 UTC (permalink / raw) To: emacs-devel [-- Attachment #1: 0001-Fix-Emacs-64-bit-on-Snow-Leopard.patch --] [-- Type: application/octet-stream, Size: 20260 bytes --] From caec5991567ba9546ca21b904b1a4824776a835c Mon Sep 17 00:00:00 2001 From: Erik Charlebois <erikc@ermac.local> Date: Wed, 9 Sep 2009 00:24:37 -0700 Subject: [PATCH] Fix Emacs 64-bit on Snow Leopard. --- lib-src/ChangeLog | 4 ++++ lib-src/movemail.c | 2 +- src/ChangeLog | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/emacs.c | 2 +- src/font.c | 11 ++++++----- src/menu.c | 2 +- src/nsfns.m | 6 ++---- src/nsfont.m | 44 ++++++++++++++++++++++++++++++++------------ src/nsgui.h | 18 +++++++++++++++--- src/nsimage.m | 4 ++-- src/nsmenu.m | 6 +++--- src/nsterm.h | 7 +++++++ src/nsterm.m | 31 ++++++++++++++++++++++--------- src/process.c | 2 +- src/unexmacosx.c | 4 ++-- 15 files changed, 149 insertions(+), 44 deletions(-) diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog index 7970ee5..f2f9144 100644 --- a/lib-src/ChangeLog +++ b/lib-src/ChangeLog @@ -1,3 +1,7 @@ +2009-09-09 Erik Charlebois <erikcharlebois@gmail.com> + + * movemail.c (error): Change fprintf to fputs to fix warning. + 2009-09-09 Glenn Morris <rgm@gnu.org> * Makefile.in ($(DESTDIR)${archlibdir}): Set umask to world-readable diff --git a/lib-src/movemail.c b/lib-src/movemail.c index 732f8dd..2feaae8 100644 --- a/lib-src/movemail.c +++ b/lib-src/movemail.c @@ -622,7 +622,7 @@ error (s1, s2, s3) else if (s2) fprintf (stderr, s1, s2); else - fprintf (stderr, s1); + fputs (s1, stderr); fprintf (stderr, "\n"); } diff --git a/src/ChangeLog b/src/ChangeLog index 52ee600..80c487a 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,53 @@ +2009-09-09 Erik Charlebois <erikcharlebois@gmail.com> + + * emacs.c (main): Remove extra format specifier to fix warning. + + * font.c (font_unparse_xlfd): Print EMACS_INT with %ld. + (font_unparse_fcname): Print EMACS_INT with %ld. + + * menu.c (find_and_return_menu_selection): Fix truncation warning. + + * nsfns.m (x-close-connection): Remove PSFlush call. Does not do anything + on Cocoa. Does not exist in 64-bit Cocoa. + (xw-color-values): Use CGFloat instead of float. + + * nsfont.m (ns_char_width): Use sizeWithAttributes: instead of + widthOfString:, which does no exist in 64-bit Cocoa. + (ns_findfonts): Print EMACS_INT with %ld. + (nsfont_list_family): Print EMACS_INT with %ld. + (nsfont_open): Use Core Text for OS X 10.5 and later. + (nsfont_close): Release Core Text resource. + (ns_uni_to_glyphs): Use NSUInteger when calling Cocoa APIs. + (layoutOptions): Use NSUInteger in method signature. + (insertGlyphs): Use NSUIntger in method signature. + (setIntAttribute): Use NSInteger and NSUInteger in method signature. + + * nsgui.h: Add typedefs for NSUInteger, NSInteger and CGFloat for + pre-10.5 OS X and GNUstep. + + * nsimage.m (setXBMColor): Use CGFloat for calls to Cocoa. + (getPixelAtX): Use CGFloat for calls to Cocoa. + + * nsmenu.m (addItemWithWidgetValue): Use NSInteger for call to Cocoa. + (fillWithWidgetValue): sizeToFit is deprecated (does nothing). Remove + call for OS X 10.5 and later. + (initWithContentRect): Use NSUInteger in method signature. + + * nsterm.h: Use Core Text on OS X 10.5 and later. + + * nsterm.m (mouseDown): Remove redundant leading 0s in format specifier. + (ns_query_color): Use CGFloat for calls to Cocoa. + (characterIndexForPoint): Use NUSInteger in method signature. + (draggingEntered): Use NSDragOperation in method signature. + (scrollerWidth): Use CGFloat in method signature. + (setPosition): Use setDoubleValue: and setKnobProportion: on 10.5 and + later since setFloatVAlue:knobProportion: is deprecated. + (mouseDown): Use %ld to print NSScrollerPart. + + * process.c (list_processes_1): Use %ld to print EMACS_INT. + + * unexmacosx.c (read_load_commands): Use %ld to print vm_address_t. + 2009-09-09 Stefan Monnier <monnier@iro.umontreal.ca> * keymap.c (where_is_internal): Filter out shadowed remappings. diff --git a/src/emacs.c b/src/emacs.c index 2c14be5..44ed9ce 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -1181,7 +1181,7 @@ main (int argc, char **argv) argv[skip_args] = fdStr; execv (argv[0], argv); - fprintf (stderr, "emacs daemon: exec failed: %d\t%d\n", errno); + fprintf (stderr, "emacs daemon: exec failed: %d\n", errno); exit (1); } diff --git a/src/font.c b/src/font.c index cfc4852..7571a00 100644 --- a/src/font.c +++ b/src/font.c @@ -1357,7 +1357,7 @@ font_unparse_xlfd (font, pixel_size, name, nbytes) { f[XLFD_AVGWIDTH_INDEX] = alloca (11); len += sprintf (f[XLFD_AVGWIDTH_INDEX], - "%d", XINT (AREF (font, FONT_AVGWIDTH_INDEX))) + 1; + "%ld", (long) XINT (AREF (font, FONT_AVGWIDTH_INDEX))) + 1; } else f[XLFD_AVGWIDTH_INDEX] = "*", len += 2; @@ -1673,7 +1673,7 @@ font_unparse_fcname (font, pixel_size, name, nbytes) } if (INTEGERP (AREF (font, FONT_DPI_INDEX))) - len += sprintf (work, ":dpi=%d", XINT (AREF (font, FONT_DPI_INDEX))); + len += sprintf (work, ":dpi=%ld", (long) XINT (AREF (font, FONT_DPI_INDEX))); if (INTEGERP (AREF (font, FONT_SPACING_INDEX))) len += strlen (":spacing=100"); if (INTEGERP (AREF (font, FONT_AVGWIDTH_INDEX))) @@ -1686,7 +1686,7 @@ font_unparse_fcname (font, pixel_size, name, nbytes) if (STRINGP (val)) len += SBYTES (val); else if (INTEGERP (val)) - len += sprintf (work, "%d", XINT (val)); + len += sprintf (work, "%ld", (long) XINT (val)); else if (SYMBOLP (val)) len += (NILP (val) ? 5 : 4); /* for "false" or "true" */ } @@ -1713,9 +1713,10 @@ font_unparse_fcname (font, pixel_size, name, nbytes) p += sprintf (p, ":%s=%s", style_names[i], SDATA (SYMBOL_NAME (styles[i]))); if (INTEGERP (AREF (font, FONT_DPI_INDEX))) - p += sprintf (p, ":dpi=%d", XINT (AREF (font, FONT_DPI_INDEX))); + p += sprintf (p, ":dpi=%ld", (long) XINT (AREF (font, FONT_DPI_INDEX))); if (INTEGERP (AREF (font, FONT_SPACING_INDEX))) - p += sprintf (p, ":spacing=%d", XINT (AREF (font, FONT_SPACING_INDEX))); + p += sprintf (p, ":spacing=%ld", + (long) XINT (AREF (font, FONT_SPACING_INDEX))); if (INTEGERP (AREF (font, FONT_AVGWIDTH_INDEX))) { if (XINT (AREF (font, FONT_AVGWIDTH_INDEX)) == 0) diff --git a/src/menu.c b/src/menu.c index 940986f..23a7013 100644 --- a/src/menu.c +++ b/src/menu.c @@ -1005,7 +1005,7 @@ find_and_return_menu_selection (FRAME_PTR f, int keymaps, void *client_data) { entry = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_VALUE]; - if ((int) (EMACS_INT)client_data == (int)(&XVECTOR (menu_items)->contents[i])) + if ((EMACS_INT)client_data == (EMACS_INT)(&XVECTOR (menu_items)->contents[i])) { if (keymaps != 0) { diff --git a/src/nsfns.m b/src/nsfns.m index 136ae03..8375109 100644 --- a/src/nsfns.m +++ b/src/nsfns.m @@ -1771,9 +1771,7 @@ The argument DISPLAY is currently ignored. */) Lisp_Object display; { check_ns (); -#ifdef NS_IMPL_COCOA - PSFlush (); -#endif + /*ns_delete_terminal (dpyinfo->terminal); */ [NSApp terminate: NSApp]; return Qnil; @@ -2237,7 +2235,7 @@ DEFUN ("xw-color-values", Fxw_color_values, Sxw_color_values, 1, 2, 0, Lisp_Object color, frame; { NSColor * col; - float red, green, blue, alpha; + CGFloat red, green, blue, alpha; check_ns (); CHECK_STRING (color); diff --git a/src/nsfont.m b/src/nsfont.m index 46c50aa..c141fa4 100644 --- a/src/nsfont.m +++ b/src/nsfont.m @@ -245,7 +245,10 @@ ns_char_width (NSFont *sfont, int c) return w; } #endif - w = [sfont widthOfString: cstr]; + NSDictionary *attrsDictionary = + [NSDictionary dictionaryWithObject: sfont + forKey: NSFontAttributeName]; + w = [cstr sizeWithAttributes: attrsDictionary].width; return max (w, 2.0); } @@ -517,7 +520,8 @@ ns_findfonts (Lisp_Object font_spec, BOOL isMatch) return ns_fallback_entity (); if (NSFONT_TRACE) - fprintf (stderr, " Returning %d entities.\n", XINT (Flength (list))); + fprintf (stderr, " Returning %ld entities.\n", + (long) XINT (Flength (list))); return list; } @@ -623,8 +627,8 @@ nsfont_list_family (Lisp_Object frame) /* FIXME: escape the name? */ if (NSFONT_TRACE) - fprintf (stderr, "nsfont: list families returning %d entries\n", - XINT (Flength (list))); + fprintf (stderr, "nsfont: list families returning %ld entries\n", + (long) XINT (Flength (list))); return list; } @@ -843,14 +847,27 @@ nsfont_open (FRAME_PTR f, Lisp_Object font_entity, int pixel_size) ((CFStringRef)@"Monaco", kATSOptionFlagsDefault); } } + +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 + font_info->ctfont = + CTFontCreateWithPlatformFont (atsFont, 0.0f, NULL, NULL); + font_info->cgfont = CTFontCopyGraphicsFont (font_info->ctfont, NULL); +#else font_info->cgfont = CGFontCreateWithPlatformFont ((void*)&atsFont); +#endif } #endif /* set up metrics portion of font struct */ font->ascent = [sfont ascender]; font->descent = -[sfont descender]; - font->min_width = [sfont widthOfString: @"|"]; /* FIXME */ + + /* FIXME */ + NSDictionary *attrsDictionary = + [NSDictionary dictionaryWithObject: sfont + forKey: NSFontAttributeName]; + font->min_width = [@"|" sizeWithAttributes: attrsDictionary].width; + font->space_width = lrint (ns_char_width (sfont, ' ')); font->average_width = lrint (font_info->width); font->max_width = lrint (font_info->max_bounds.width); @@ -888,6 +905,9 @@ nsfont_close (FRAME_PTR f, struct font *font) [font_info->nsfont release]; #ifdef NS_IMPL_COCOA CGFontRelease (font_info->cgfont); +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 + CFRelease (font_info->ctfont); +#endif #endif xfree (font_info->name); xfree (font_info); @@ -1308,7 +1328,7 @@ ns_uni_to_glyphs (struct nsfont_info *font_info, unsigned char block) NSGlyphGenerator *glyphGenerator = [NSGlyphGenerator sharedGlyphGenerator]; /*NSCharacterSet *coveredChars = [nsfont coveredCharacterSet]; */ unsigned int numGlyphs = [font_info->nsfont numberOfGlyphs]; - unsigned int gInd =0, cInd =0; + NSUInteger gInd =0, cInd =0; [glyphStorage setString: allChars font: font_info->nsfont]; [glyphGenerator generateGlyphsForGlyphStorage: glyphStorage @@ -1439,7 +1459,7 @@ ns_glyph_metrics (struct nsfont_info *font_info, unsigned char block) } /* NSGlyphStorage protocol */ -- (unsigned int)layoutOptions +- (NSUInteger)layoutOptions { return 0; } @@ -1449,9 +1469,9 @@ ns_glyph_metrics (struct nsfont_info *font_info, unsigned char block) return attrStr; } -- (void)insertGlyphs: (const NSGlyph *)glyphs length: (unsigned int)length - forStartingGlyphAtIndex: (unsigned int)glyphIndex - characterIndex: (unsigned int)charIndex +- (void)insertGlyphs: (const NSGlyph *)glyphs length: (NSUInteger)length + forStartingGlyphAtIndex: (NSUInteger)glyphIndex + characterIndex: (NSUInteger)charIndex { len = glyphIndex+length; for (i =glyphIndex; i<len; i++) @@ -1460,8 +1480,8 @@ ns_glyph_metrics (struct nsfont_info *font_info, unsigned char block) maxGlyph = len; } -- (void)setIntAttribute: (int)attributeTag value: (int)val - forGlyphAtIndex: (unsigned)glyphIndex +- (void)setIntAttribute: (NSInteger)attributeTag value: (NSInteger)val + forGlyphAtIndex: (NSUInteger)glyphIndex { return; } diff --git a/src/nsgui.h b/src/nsgui.h index 9bf6be6..5594b7b 100644 --- a/src/nsgui.h +++ b/src/nsgui.h @@ -128,13 +128,25 @@ typedef struct { unsigned width, height; } XRectangle; +#if !defined(__OBJC__) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5 +#ifdef _LP64 +typedef unsigned long NSUInteger; +typedef long NSInteger; +typedef double CGFloat; +#else +typedef unsigned int NSUInteger; +typedef int NSInteger; +typedef float CGFloat; +#endif +#endif + #ifndef __OBJC__ -typedef struct _NSPoint { float x, y; } NSPoint; -typedef struct _NSSize { float width, height; } NSSize; +typedef struct _NSPoint { CGFloat x, y; } NSPoint; +typedef struct _NSSize { CGFloat width, height; } NSSize; typedef struct _NSRect { NSPoint origin; NSSize size; } NSRect; #endif -#define NativeRectangle struct _NSRect +#define NativeRectangle NSRect #define CONVERT_TO_XRECT(xr, nr) \ ((xr).x = (nr).origin.x, \ diff --git a/src/nsimage.m b/src/nsimage.m index 9ef7ad3..87499b0 100644 --- a/src/nsimage.m +++ b/src/nsimage.m @@ -329,7 +329,7 @@ static EmacsImage *ImageList = nil; NSSize s = [self size]; int len = (int) s.width * s.height; unsigned char *planes[5]; - float r, g, b, a; + CGFloat r, g, b, a; NSColor *rgbColor; if (bmRep == nil || color == nil) @@ -431,7 +431,7 @@ static EmacsImage *ImageList = nil; else if (onTiger) { NSColor *color = [bmRep colorAtX: x y: y]; - float r, g, b, a; + CGFloat r, g, b, a; [color getRed: &r green: &g blue: &b alpha: &a]; return ((int)(a * 255.0) << 24) | ((int)(r * 255.0) << 16) | ((int)(g * 255.0) << 8) diff --git a/src/nsmenu.m b/src/nsmenu.m index 0518466..e8549b4 100644 --- a/src/nsmenu.m +++ b/src/nsmenu.m @@ -656,7 +656,7 @@ name_is_separator (name) else [item setState: NSOffState]; - [item setTag: (int)wv->call_data]; + [item setTag: (NSInteger)wv->call_data]; } return item; @@ -708,7 +708,7 @@ name_is_separator (name) #ifdef NS_IMPL_GNUSTEP if ([[self window] isVisible]) [self sizeToFit]; -#else +#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5 if ([self supermenu] == nil) [self sizeToFit]; #endif @@ -1611,7 +1611,7 @@ ns_popup_dialog (Lisp_Object position, Lisp_Object contents, Lisp_Object header) #define TEXTHEIGHT 20.0 #define MINCELLWIDTH 90.0 -- initWithContentRect: (NSRect)contentRect styleMask: (unsigned int)aStyle +- initWithContentRect: (NSRect)contentRect styleMask: (NSUInteger)aStyle backing: (NSBackingStoreType)backingType defer: (BOOL)flag { NSSize spacing = {SPACER, SPACER}; diff --git a/src/nsterm.h b/src/nsterm.h index 7375e3c..033f757 100644 --- a/src/nsterm.h +++ b/src/nsterm.h @@ -420,9 +420,16 @@ struct nsfont_info #else /* GNUstep or OS X < 10.3 */ void *cgfont; #endif + /* ctFont is used only on OS X 10.5+ */ +#if defined (NS_IMPL_COCOA) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5) + CTFontRef ctfont; +#else /* GNUstep or OS X < 10.5 */ + void *ctfont; +#endif #else /* ! OBJC */ void *nsfont; void *cgfont; + void *ctfont; #endif char bold, ital; /* convenience flags */ char synthItal; diff --git a/src/nsterm.m b/src/nsterm.m index 5a58f1d..233f699 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -1481,7 +1481,7 @@ ns_color_to_lisp (NSColor *col) Convert a color to a lisp string with the RGB equivalent -------------------------------------------------------------------------- */ { - float red, green, blue, alpha, gray; + CGFloat red, green, blue, alpha, gray; char buf[1024]; const char *str; NSTRACE (ns_color_to_lisp); @@ -1501,13 +1501,13 @@ ns_color_to_lisp (NSColor *col) { [[col colorUsingColorSpaceName: NSCalibratedWhiteColorSpace] getWhite: &gray alpha: &alpha]; - snprintf (buf, sizeof (buf), "#%02.2lx%02.2lx%02.2lx", + snprintf (buf, sizeof (buf), "#%2.2lx%2.2lx%2.2lx", lrint (gray * 0xff), lrint (gray * 0xff), lrint (gray * 0xff)); UNBLOCK_INPUT; return build_string (buf); } - snprintf (buf, sizeof (buf), "#%02.2lx%02.2lx%02.2lx", + snprintf (buf, sizeof (buf), "#%2.2lx%2.2lx%2.2lx", lrint (red*0xff), lrint (green*0xff), lrint (blue*0xff)); UNBLOCK_INPUT; @@ -1523,7 +1523,7 @@ ns_query_color(void *col, XColor *color_def, int setPixel) and set color_def pixel to the resulting index. -------------------------------------------------------------------------- */ { - float r, g, b, a; + CGFloat r, g, b, a; [((NSColor *)col) getRed: &r green: &g blue: &b alpha: &a]; color_def->red = r * 65535; @@ -4741,7 +4741,7 @@ extern void update_window_cursor (struct window *w, int on); return NSMakeRange (NSNotFound, 0); } -- (unsigned int)characterIndexForPoint: (NSPoint)thePoint +- (NSUInteger)characterIndexForPoint: (NSPoint)thePoint { if (NS_KEYLOG) NSLog (@"characterIndexForPoint request"); @@ -5418,7 +5418,7 @@ extern void update_window_cursor (struct window *w, int on); /* NSDraggingDestination protocol methods. Actually this is not really a protocol, but a category of Object. O well... */ --(unsigned int) draggingEntered: (id <NSDraggingInfo>) sender +-(NSDragOperation) draggingEntered: (id <NSDraggingInfo>) sender { NSTRACE (draggingEntered); return NSDragOperationGeneric; @@ -5703,7 +5703,7 @@ extern void update_window_cursor (struct window *w, int on); #define SCROLL_BAR_FIRST_DELAY 0.5 #define SCROLL_BAR_CONTINUOUS_DELAY (1.0 / 15) -+ (float) scrollerWidth ++ (CGFloat) scrollerWidth { /* TODO: if we want to allow variable widths, this is the place to do it, however neither GNUstep nor Cocoa support it very well */ @@ -5834,14 +5834,26 @@ extern void update_window_cursor (struct window *w, int on); em_whole = whole; if (portion >= whole) - [self setFloatValue: 0.0 knobProportion: 1.0]; + { +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 + [self setDoubleValue: 0.0]; + [self setKnobProportion: 1.0]; +#else + [self setFloatValue: 0.0 knobProportion: 1.0]; +#endif + } else { float pos, por; portion = max ((float)whole*min_portion/pixel_height, portion); pos = (float)position / (whole - portion); por = (float)portion/whole; +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 + [self setDoubleValue: pos]; + [self setKnobProportion: por]; +#else [self setFloatValue: pos knobProportion: por]; +#endif } #ifdef NS_IMPL_GNUSTEP [self display]; @@ -5946,7 +5958,8 @@ extern void update_window_cursor (struct window *w, int on); case NSScrollerKnobSlot: /* GNUstep-only */ last_hit_part = scroll_bar_move_ratio; break; default: /* NSScrollerNoPart? */ - fprintf (stderr, "EmacsScoller-mouseDown: unexpected part %d\n", part); + fprintf (stderr, "EmacsScoller-mouseDown: unexpected part %ld\n", + (long) part); return; } diff --git a/src/process.c b/src/process.c index e65d495..99f57d3 100644 --- a/src/process.c +++ b/src/process.c @@ -1522,7 +1522,7 @@ list_processes_1 (query_only) insert_string ("?"); if (INTEGERP (speed)) { - sprintf (tembuf, " at %d b/s", XINT (speed)); + sprintf (tembuf, " at %ld b/s", (long) XINT (speed)); insert_string (tembuf); } insert_string (")\n"); diff --git a/src/unexmacosx.c b/src/unexmacosx.c index bb71d8f..489489d 100644 --- a/src/unexmacosx.c +++ b/src/unexmacosx.c @@ -684,8 +684,8 @@ read_load_commands () } } - printf ("Highest address of load commands in input file: %#8x\n", - infile_lc_highest_addr); + printf ("Highest address of load commands in input file: %#8lx\n", + (long) infile_lc_highest_addr); printf ("Lowest offset of all sections in __TEXT segment: %#8lx\n", text_seg_lowest_offset); -- 1.6.4.1 [-- Attachment #2: Type: text/plain, Size: 1708 bytes --] Revised patch that fixes 10.5 building (removed the protocol specifications as noted by Eddie Hillenbrand) and removed the PSFlush () call as noted by Cheng Gao. Erik Charlebois erikcharlebois@gmail.com On 2009-09-08, at 1:14 AM, Erik Charlebois wrote: > <0001-Fixes-to-get-a-working-64-bit-Emacs-on-OS-X-10.6.patch><0002- > Fix-Changelogs.patch> > I've attached two patches (sorry about that, first time I used git > and I got the ChangeLogs wrong after committing :). I've tried to > make sure nothing's been introduced that would break pre-10.5 OS X > or GNUstep, but I don't have either of those systems to test with. > The bulk of the changes deal with deprecated Cocoa methods, LP64 > issues (printf specifiers, NSInteger/NSUInteger) and CGFloat being > double on 64-bit Cocoa. I've built/tested on 32- and 64-bit OS X 10.6. > > Erik Charlebois > erikcharlebois@gmail.com > > > > > On 2009-09-07, at 4:26 PM, David Reitter wrote: > >> Hi Erik, >> >> On Sep 7, 2009, at 5:08 PM, Erik Charlebois wrote: >> >>> I've posted the steps/fixes to get a 64-bit NS/Cocoa Emacs 23.1 >>> working for Snow Leopard on my blog at http://blog.fac9.com/index.php/2009/08/30/building-a-64-bit-emacs-on-snow-leopard/ >>> . I've been using it for a week without problems. >> >> Thanks, that's great news. >> >> Regarding your point 5: I did not redefine CGFloat when I tried to >> address these things; I'm not sure if it is necessary. You might >> be right. >> See this file >> >> http://github.com/davidswelt/aquamacs-emacs/blob/874784331f6e1bcfe319823616067bcf2432c29a/src/nsgui.h >> >> Would you be willing to post a patch with all of your changes? >> >> Thanks again >> - David >> > ^ permalink raw reply related [flat|nested] 8+ messages in thread
end of thread, other threads:[~2009-09-09 12:56 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2009-09-08 5:18 Fixes for 64-bit Emacs on Snow Leopard Eddie Hillenbrand -- strict thread matches above, loose matches on Subject: below -- 2009-09-07 21:08 Erik Charlebois 2009-09-07 22:03 ` Chong Yidong 2009-09-09 12:56 ` Adrian Robert 2009-09-07 23:26 ` David Reitter 2009-09-08 8:14 ` Erik Charlebois 2009-09-08 17:38 ` CHENG Gao 2009-09-09 7:32 ` Erik Charlebois
Code repositories for project(s) associated with this public inbox https://git.savannah.gnu.org/cgit/emacs.git This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).