# HG changeset patch # User Jacob Carlborg # Date 1244845505 -7200 # Node ID 535243e6d16ae0110216016aab207135edab26e2 # Parent 8433dabeb15ed2007036cae35c4b1c60b1911b9a Fixes to make dwt compile with ldc diff -r 8433dabeb15e -r 535243e6d16a dsss.conf --- a/dsss.conf Thu Jun 11 01:36:32 2009 +0200 +++ b/dsss.conf Sat Jun 13 00:25:05 2009 +0200 @@ -1,6 +1,4 @@ [dwt] -dylib -buildflags+=-dc=gdc-posix-tango version (GNU){ buildflags += -Jres -framework Cocoa -framework Carbon @@ -8,6 +6,7 @@ version (LDC){ buildflags += -Jres -L-framework=Cocoa -L-framework=Carbon + exclude=dwt/browser } version (DMD){ diff -r 8433dabeb15e -r 535243e6d16a dwt/browser/AppFileLocProvider.d --- a/dwt/browser/AppFileLocProvider.d Thu Jun 11 01:36:32 2009 +0200 +++ b/dwt/browser/AppFileLocProvider.d Sat Jun 13 00:25:05 2009 +0200 @@ -68,7 +68,7 @@ nsresult QueryInterface (nsID* riid, void** ppvObject) { if (riid is null || ppvObject is null) return XPCOM.NS_ERROR_NO_INTERFACE; - if (*riid == nsISupports.IID) { + if (*riid == nsISupports.IID) { *ppvObject = cast(void*)cast(nsISupports)this; AddRef (); return XPCOM.NS_OK; @@ -155,8 +155,8 @@ /* value appears to be a valid pathname */ if (rc !is XPCOM.NS_OK) Mozilla.error (rc); if (localFile is null) Mozilla.error (XPCOM.NS_ERROR_NULL_POINTER); - - rc = localFile.QueryInterface (&nsIFile.IID, cast(void**)&file); + //rc = localFile.QueryInterface (&nsIFile.IID, cast(void**)&file); TODO + rc = localFile.QueryInterface (&NS_IFILE_IID, cast(void**)&file); if (rc !is XPCOM.NS_OK) Mozilla.error (rc); if (file is null) Mozilla.error (XPCOM.NS_ERROR_NO_INTERFACE); localFile.Release (); @@ -241,6 +241,7 @@ if (localFile is null) Mozilla.error (XPCOM.NS_ERROR_NULL_POINTER); nsIFile file; + rc = localFile.QueryInterface (&nsIFile.IID, cast(void**)&file); if (rc !is XPCOM.NS_OK) Mozilla.error (rc); if (file is null) Mozilla.error (XPCOM.NS_ERROR_NO_INTERFACE); diff -r 8433dabeb15e -r 535243e6d16a dwt/custom/StyleRange.d --- a/dwt/custom/StyleRange.d Thu Jun 11 01:36:32 2009 +0200 +++ b/dwt/custom/StyleRange.d Sat Jun 13 00:25:05 2009 +0200 @@ -201,30 +201,30 @@ */ public override String toString() { StringBuffer buffer = new StringBuffer(); - buffer.append("StyleRange {"); - buffer.append(start); - buffer.append(", "); - buffer.append(length); - buffer.append(", fontStyle="); + buffer.format("{}", "StyleRange {"); + buffer.format("{}", start); + buffer.format("{}", ", "); + buffer.format("{}", length); + buffer.format("{}", ", fontStyle="); switch (fontStyle) { case DWT.BOLD: - buffer.append("bold"); + buffer.format("{}", "bold"); break; case DWT.ITALIC: - buffer.append("italic"); + buffer.format("{}", "italic"); break; case DWT.BOLD | DWT.ITALIC: - buffer.append("bold-italic"); + buffer.format("{}", "bold-italic"); break; default: - buffer.append("normal"); + buffer.format("{}", "normal"); } String str = super.toString(); int index = tango.text.Util.locate( str, '{'); if( index is str.length ) index = -1; str = str[ index + 1 .. $ ]; - if (str.length > 1) buffer.append(", "); - buffer.append(str); + if (str.length > 1) buffer.format("{}", ", "); + buffer.format("{}", str); return buffer.toString(); } } diff -r 8433dabeb15e -r 535243e6d16a dwt/custom/StyledText.d --- a/dwt/custom/StyledText.d Thu Jun 11 01:36:32 2009 +0200 +++ b/dwt/custom/StyledText.d Sat Jun 13 00:25:05 2009 +0200 @@ -544,7 +544,7 @@ } } else { StringBuffer buffer = new StringBuffer("0"); - while ((count /= 10) > 0) buffer.append("0"); + while ((count /= 10) > 0) buffer.format("{}", "0"); printLayout.setText(buffer.toString()); numberingWidth = printLayout.getBounds().width; } @@ -652,8 +652,8 @@ if (pageIndex !is -1 ) { int pageTagLength = StyledTextPrintOptions.PAGE_TAG.length; StringBuffer buffer = new StringBuffer(segment.substring (0, pageIndex)); - buffer.append (page); - buffer.append (segment.substring(pageIndex + pageTagLength)); + buffer.format ("{}", page); + buffer.format ("{}", segment.substring(pageIndex + pageTagLength)); segment = buffer.toString().dup; } if (segment.length > 0) { @@ -906,7 +906,7 @@ void writeHeader() { StringBuffer header = new StringBuffer(); FontData fontData = getFont().getFontData()[0]; - header.append("{\\rtf1\\ansi"); + header.format("{}", "{\\rtf1\\ansi"); // specify code page, necessary for copy to work in bidi // systems that don't support Unicode RTF. // PORTING_TODO: String cpg = System.getProperty("file.encoding").toLowerCase(); @@ -914,38 +914,38 @@ /+ if (cpg.startsWith("cp") || cpg.startsWith("ms")) { cpg = cpg.substring(2, cpg.length()); - header.append("\\ansicpg"); - header.append(cpg); + header.format("{}", "\\ansicpg"); + header.format("{}", cpg); } +/ - header.append("\\uc0\\deff0{\\fonttbl{\\f0\\fnil "); - header.append(fontData.getName()); - header.append(";"); + header.format("{}", "\\uc0\\deff0{\\fonttbl{\\f0\\fnil "); + header.format("{}", fontData.getName()); + header.format("{}", ";"); for (int i = 1; i < fontTable.length; i++) { - header.append("\\f"); - header.append(i); - header.append(" "); + header.format("{}", "\\f"); + header.format("{}", i); + header.format("{}", " "); FontData fd = (cast(Font)fontTable[i]).getFontData()[0]; - header.append(fd.getName()); - header.append(";"); - } - header.append("}}\n{\\colortbl"); + header.format("{}", fd.getName()); + header.format("{}", ";"); + } + header.format("{}", "}}\n{\\colortbl"); for (int i = 0; i < colorTable.length; i++) { Color color = cast(Color) colorTable[i]; - header.append("\\red"); - header.append(color.getRed()); - header.append("\\green"); - header.append(color.getGreen()); - header.append("\\blue"); - header.append(color.getBlue()); - header.append(";"); + header.format("{}", "\\red"); + header.format("{}", color.getRed()); + header.format("{}", "\\green"); + header.format("{}", color.getGreen()); + header.format("{}", "\\blue"); + header.format("{}", color.getBlue()); + header.format("{}", ";"); } // some RTF readers ignore the deff0 font tag. Explicitly // set the font for the whole document to work around this. - header.append("}\n{\\f0\\fs"); + header.format("{}", "}\n{\\f0\\fs"); // font size is specified in half points - header.append(fontData.getHeight() * 2); - header.append(" "); + header.format("{}", fontData.getHeight() * 2); + header.format("{}", " "); write(header.toString(), 0); } /** @@ -1209,7 +1209,7 @@ * Appends the given string to the data. */ void write(String string) { - buffer.append(string); + buffer.format("{}", string); } /** * Inserts the given string to the data at the specified offset. @@ -1231,13 +1231,13 @@ * Appends the given int to the data. */ void write(int i) { - buffer.append(i); + buffer.format("{}", i); } /** * Appends the given character to the data. */ void write(char i) { - buffer.append(i); + buffer.format("{}", i); } /** * Appends the specified line text to the data. @@ -1940,25 +1940,25 @@ if (lfIndex is -1 && crIndex is -1) { // no more line breaks? break; } else if ((crIndex < lfIndex && crIndex !is -1) || lfIndex is -1) { - convertedText.append(text.substring(i, crIndex)); + convertedText.format("{}", text.substring(i, crIndex)); if (lfIndex is crIndex + 1) { // CR/LF combination? i = lfIndex + 1; } else { i = crIndex + 1; } } else { // LF occurs before CR! - convertedText.append(text.substring(i, lfIndex)); + convertedText.format("{}", text.substring(i, lfIndex)); i = lfIndex + 1; } if (isSingleLine()) { break; } - convertedText.append(delimiter); + convertedText.format("{}", delimiter); } // copy remaining text if any and if not in single line mode or no // text copied thus far (because there only is one line) if (i < length && (!isSingleLine() || convertedText.length() is 0)) { - convertedText.append(text.substring(i)); + convertedText.format("{}", text.substring(i)); } return convertedText.toString(); } diff -r 8433dabeb15e -r 535243e6d16a dwt/dnd/DropTargetEvent.d --- a/dwt/dnd/DropTargetEvent.d Thu Jun 11 01:36:32 2009 +0200 +++ b/dwt/dnd/DropTargetEvent.d Sat Jun 13 00:25:05 2009 +0200 @@ -132,22 +132,22 @@ public String toString() { String string = super.toString (); StringBuffer sb = new StringBuffer(); - sb.append(string.substring (0, string.length() - 1)); // remove trailing '}' - sb.append(" x="); sb.append(x); - sb.append(" y="); sb.append(y); - sb.append(" item="); sb.append(item.toString); - sb.append(" operations="); sb.append(operations); - sb.append(" operation="); sb.append(detail); - sb.append(" feedback="); sb.append(feedback); - sb.append(" dataTypes={ "); + sb.format("{}", string.substring (0, string.length() - 1)); // remove trailing '}' + sb.format("{}", " x="); sb.format("{}", x); + sb.format("{}", " y="); sb.format("{}", y); + sb.format("{}", " item="); sb.format("{}", item.toString); + sb.format("{}", " operations="); sb.format("{}", operations); + sb.format("{}", " operation="); sb.format("{}", detail); + sb.format("{}", " feedback="); sb.format("{}", feedback); + sb.format("{}", " dataTypes={ "); if (dataTypes !is null) { for (int i = 0; i < dataTypes.length; i++) { - sb.append(dataTypes[i].type); sb.append(' '); + sb.format("{}", dataTypes[i].type); sb.format("{}", ' '); } } - sb.append('}'); - sb.append(" currentDataType="); sb.append(currentDataType !is null ? currentDataType.type : '0'); - sb.append('}'); + sb.format("{}", '}'); + sb.format("{}", " currentDataType="); sb.format("{}", currentDataType !is null ? currentDataType.type : '0'); + sb.format("{}", '}'); return sb.toString(); } } diff -r 8433dabeb15e -r 535243e6d16a dwt/graphics/FontData.d --- a/dwt/graphics/FontData.d Thu Jun 11 01:36:32 2009 +0200 +++ b/dwt/graphics/FontData.d Sat Jun 13 00:25:05 2009 +0200 @@ -441,15 +441,15 @@ */ public String toString() { StringBuffer buffer = new StringBuffer(); - buffer.append("1|"); - buffer.append(getName()); - buffer.append("|"); - buffer.append(getHeightF()); - buffer.append("|"); - buffer.append(getStyle()); - buffer.append("|"); - buffer.append("COCOA|1|"); - if (nsName !is null) buffer.append(nsName); + buffer.format("{}", "1|"); + buffer.format("{}", getName()); + buffer.format("{}", "|"); + buffer.format("{}", getHeightF()); + buffer.format("{}", "|"); + buffer.format("{}", getStyle()); + buffer.format("{}", "|"); + buffer.format("{}", "COCOA|1|"); + if (nsName !is null) buffer.format("{}", nsName); return buffer.toString(); } diff -r 8433dabeb15e -r 535243e6d16a dwt/graphics/TextLayout.d --- a/dwt/graphics/TextLayout.d Thu Jun 11 01:36:32 2009 +0200 +++ b/dwt/graphics/TextLayout.d Sat Jun 13 00:25:05 2009 +0200 @@ -411,14 +411,15 @@ pt.x = x; pt.y = y; bool hasSelection = selectionStart <= selectionEnd && selectionStart !is -1 && selectionEnd !is -1; - NSRange* selectionRange = null; + NSRange* selectionRange = null; NSColor selectionColor = null; if (hasSelection || (flags & DWT.LAST_LINE_SELECTION) !is 0) { if (selectionBackground is null) selectionBackground = device.getSystemColor(DWT.COLOR_LIST_SELECTION); selectionColor = NSColor.colorWithDeviceRed(selectionBackground.handle[0], selectionBackground.handle[1], selectionBackground.handle[2], selectionBackground.handle[3]); } if (hasSelection) { - selectionRange = &NSRange(); + NSRange range; + selectionRange = ⦥ selectionRange.location = selectionStart; selectionRange.length = selectionEnd - selectionStart + 1; layoutManager.addTemporaryAttribute(OS.NSBackgroundColorAttributeName, selectionColor, *selectionRange); diff -r 8433dabeb15e -r 535243e6d16a dwt/graphics/TextStyle.d --- a/dwt/graphics/TextStyle.d Thu Jun 11 01:36:32 2009 +0200 +++ b/dwt/graphics/TextStyle.d Sat Jun 13 00:25:05 2009 +0200 @@ -324,39 +324,39 @@ StringBuffer buffer = new StringBuffer("TextStyle {"); int startLength = buffer.length(); if (font !is null) { - if (buffer.length() > startLength) buffer.append(", "); - buffer.append("font="); - buffer.append(font.toString); + if (buffer.length() > startLength) buffer.format("{}", ", "); + buffer.format("{}", "font="); + buffer.format("{}", font.toString); } if (foreground !is null) { - if (buffer.length() > startLength) buffer.append(", "); - buffer.append("foreground="); - buffer.append(foreground.toString); + if (buffer.length() > startLength) buffer.format("{}", ", "); + buffer.format("{}", "foreground="); + buffer.format("{}", foreground.toString); } if (background !is null) { - if (buffer.length() > startLength) buffer.append(", "); - buffer.append("background="); - buffer.append(background.toString); + if (buffer.length() > startLength) buffer.format("{}", ", "); + buffer.format("{}", "background="); + buffer.format("{}", background.toString); } if (underline) { - if (buffer.length() > startLength) buffer.append(", "); - buffer.append("underlined"); + if (buffer.length() > startLength) buffer.format("{}", ", "); + buffer.format("{}", "underlined"); } if (strikeout) { - if (buffer.length() > startLength) buffer.append(", "); - buffer.append("striked out"); + if (buffer.length() > startLength) buffer.format("{}", ", "); + buffer.format("{}", "striked out"); } if (rise !is 0) { - if (buffer.length() > startLength) buffer.append(", "); - buffer.append("rise="); - buffer.append(rise); + if (buffer.length() > startLength) buffer.format("{}", ", "); + buffer.format("{}", "rise="); + buffer.format("{}", rise); } if (metrics !is null) { - if (buffer.length() > startLength) buffer.append(", "); - buffer.append("metrics="); - buffer.append(metrics.toString); + if (buffer.length() > startLength) buffer.format("{}", ", "); + buffer.format("{}", "metrics="); + buffer.format("{}", metrics.toString); } - buffer.append("}"); + buffer.format("{}", "}"); return buffer.toString(); } diff -r 8433dabeb15e -r 535243e6d16a dwt/internal/mozilla/nsIFile.d --- a/dwt/internal/mozilla/nsIFile.d Thu Jun 11 01:36:32 2009 +0200 +++ b/dwt/internal/mozilla/nsIFile.d Sat Jun 13 00:25:05 2009 +0200 @@ -14,7 +14,7 @@ interface nsIFile : nsISupports { static const char[] IID_STR = NS_IFILE_IID_STR; - static const nsIID IID = NS_IFILE_IID; + static /*const*/ nsIID IID = NS_IFILE_IID; // const causes bug in ldc TODO enum { NORMAL_FILE_TYPE = 0U }; enum { DIRECTORY_TYPE = 1U }; diff -r 8433dabeb15e -r 535243e6d16a dwt/internal/mozilla/nsISupports.d --- a/dwt/internal/mozilla/nsISupports.d Thu Jun 11 01:36:32 2009 +0200 +++ b/dwt/internal/mozilla/nsISupports.d Sat Jun 13 00:25:05 2009 +0200 @@ -12,11 +12,10 @@ interface IUnknown { static const char[] IID_STR = NS_ISUPPORTS_IID_STR; - static const nsIID IID = NS_ISUPPORTS_IID; + static /*const*/ nsIID IID = NS_ISUPPORTS_IID; // const causes bug in ldc TODO -extern(System): +extern(System): //causes assert in ldc TODO nsresult QueryInterface( nsIID* uuid, void **result); - nsrefcnt AddRef(); nsrefcnt Release(); } diff -r 8433dabeb15e -r 535243e6d16a dwt/widgets/Display.d --- a/dwt/widgets/Display.d Thu Jun 11 01:36:32 2009 +0200 +++ b/dwt/widgets/Display.d Sat Jun 13 00:25:05 2009 +0200 @@ -559,7 +559,8 @@ NSPoint* cascade = screenCascade[index]; if (cascade is null) { NSRect frame = screen.frame(); - cascade = &NSPoint(); + NSPoint nsPoint; + cascade = &nsPoint; cascade.x = frame.x; cascade.y = frame.y + frame.height; }