# HG changeset patch # User Frank Benoit # Date 1219840359 -7200 # Node ID a9ab4c738ed8187a14f87d055b258a4d1e08b5b4 # Parent e831403a80a9a1980a9c52c0ed1e90997f3b8ccd Fix: instanceof diff -r e831403a80a9 -r a9ab4c738ed8 dwt/custom/SashForm.d --- a/dwt/custom/SashForm.d Wed Aug 27 14:30:35 2008 +0200 +++ b/dwt/custom/SashForm.d Wed Aug 27 14:32:39 2008 +0200 @@ -152,7 +152,7 @@ int[] ratios = new int[cArray.length]; for (int i = 0; i < cArray.length; i++) { Object data = cArray[i].getLayoutData(); - if (data !is null && data instanceof SashFormData) { + if (data !is null && null !is cast(SashFormData)data ) { ratios[i] = cast(int)((cast(SashFormData)data).weight * 1000 >> 16); } else { ratios[i] = 200; @@ -215,12 +215,12 @@ event.doit = false; } Object data1 = c1.getLayoutData(); - if (data1 is null || !(data1 instanceof SashFormData)) { + if (data1 is null || !( null !is cast(SashFormData)data1 )) { data1 = new SashFormData(); c1.setLayoutData(data1); } Object data2 = c2.getLayoutData(); - if (data2 is null || !(data2 instanceof SashFormData)) { + if (data2 is null || !( null !is cast(SashFormData)data2 )) { data2 = new SashFormData(); c2.setLayoutData(data2); } @@ -248,12 +248,12 @@ event.doit = false; } Object data1 = c1.getLayoutData(); - if (data1 is null || !(data1 instanceof SashFormData)) { + if (data1 is null || !( null !is cast(SashFormData)data1 )) { data1 = new SashFormData(); c1.setLayoutData(data1); } Object data2 = c2.getLayoutData(); - if (data2 is null || !(data2 instanceof SashFormData)) { + if (data2 is null || !( null !is cast(SashFormData)data2 )) { data2 = new SashFormData(); c2.setLayoutData(data2); } @@ -416,7 +416,7 @@ } for (int i = 0; i < cArray.length; i++) { Object data = cArray[i].getLayoutData(); - if (data is null || !(data instanceof SashFormData)) { + if (data is null || !( null !is cast(SashFormData)data )) { data = new SashFormData(); cArray[i].setLayoutData(data); } diff -r e831403a80a9 -r a9ab4c738ed8 dwt/custom/SashFormLayout.d --- a/dwt/custom/SashFormLayout.d Wed Aug 27 14:30:35 2008 +0200 +++ b/dwt/custom/SashFormLayout.d Wed Aug 27 14:32:39 2008 +0200 @@ -56,7 +56,7 @@ long total = 0; for (int i = 0; i < cArray.length; i++) { Object data = cArray[i].getLayoutData(); - if (data !is null && data instanceof SashFormData) { + if (data !is null && null !is cast(SashFormData)data ) { ratios[i] = (cast(SashFormData)data).weight; } else { data = new SashFormData(); @@ -141,7 +141,7 @@ long total = 0; for (int i = 0; i < controls.length; i++) { Object data = controls[i].getLayoutData(); - if (data !is null && data instanceof SashFormData) { + if (data !is null && null !is cast(SashFormData)data ) { ratios[i] = (cast(SashFormData)data).weight; } else { data = new SashFormData(); diff -r e831403a80a9 -r a9ab4c738ed8 dwt/custom/ScrolledComposite.d --- a/dwt/custom/ScrolledComposite.d Wed Aug 27 14:30:35 2008 +0200 +++ b/dwt/custom/ScrolledComposite.d Wed Aug 27 14:32:39 2008 +0200 @@ -170,7 +170,7 @@ filter = new Listener() { public void handleEvent(Event event) { - if (event.widget instanceof Control) { + if ( null !is cast(Control)event.widget ) { Control control = cast(Control) event.widget; if (contains(control)) showControl(control); } @@ -193,7 +193,7 @@ if (control is null || control.isDisposed()) return false; Composite parent = control.getParent(); - while (parent !is null && !(parent instanceof Shell)) { + while (parent !is null && !( null !is cast(Shell)parent )) { if (this is parent) return true; parent = parent.getParent(); } diff -r e831403a80a9 -r a9ab4c738ed8 dwt/custom/StyleRange.d --- a/dwt/custom/StyleRange.d Wed Aug 27 14:30:35 2008 +0200 +++ b/dwt/custom/StyleRange.d Wed Aug 27 14:32:39 2008 +0200 @@ -94,7 +94,7 @@ */ public bool opEquals(Object object) { if (object is this) return true; - if (object instanceof StyleRange) { + if ( null !is cast(StyleRange)object ) { StyleRange style = cast(StyleRange)object; if (start !is style.start) return false; if (length !is style.length) return false; diff -r e831403a80a9 -r a9ab4c738ed8 dwt/custom/ViewFormLayout.d --- a/dwt/custom/ViewFormLayout.d Wed Aug 27 14:30:35 2008 +0200 +++ b/dwt/custom/ViewFormLayout.d Wed Aug 27 14:32:39 2008 +0200 @@ -82,7 +82,7 @@ Point computeChildSize(Control control, int wHint, int hHint, bool flushCache) { Object data = control.getLayoutData(); - if (data is null || !(data instanceof CLayoutData)) { + if (data is null || !( null !is cast(CLayoutData)data )) { data = new CLayoutData(); control.setLayoutData(data); } @@ -90,7 +90,7 @@ } int computeTrim(Control c) { - if (c instanceof Scrollable) { + if ( null !is cast(Scrollable)c ) { Rectangle rect = (cast(Scrollable) c).computeTrim (0, 0, 0, 0); return rect.width; } @@ -99,7 +99,7 @@ protected bool flushCache(Control control) { Object data = control.getLayoutData(); - if (data !is null && data instanceof CLayoutData) (cast(CLayoutData)data).flushCache(); + if (data !is null && null !is cast(CLayoutData)data ) (cast(CLayoutData)data).flushCache(); return true; } diff -r e831403a80a9 -r a9ab4c738ed8 dwt/dnd/DragSource.d --- a/dwt/dnd/DragSource.d Wed Aug 27 14:30:35 2008 +0200 +++ b/dwt/dnd/DragSource.d Wed Aug 27 14:32:39 2008 +0200 @@ -174,11 +174,11 @@ }); Object effect = control.getData(DEFAULT_DRAG_SOURCE_EFFECT); - if (effect instanceof DragSourceEffect) { + if ( null !is cast(DragSourceEffect)effect ) { dragEffect = cast(DragSourceEffect) effect; - } else if (control instanceof Tree) { + } else if ( null !is cast(Tree)control ) { dragEffect = new TreeDragSourceEffect(cast(Tree) control); - } else if (control instanceof Table) { + } else if ( null !is cast(Table)control ) { dragEffect = new TableDragSourceEffect(cast(Table) control); } } @@ -277,7 +277,7 @@ Transfer transfer = transferAgents[i]; if (transfer !is null) { int[] types = transfer.getTypeIds(); - if (transfer instanceof FileTransfer) { + if ( null !is cast(FileTransfer)transfer ) { TransferData transferData = new TransferData(); transferData.type = types[0]; DNDEvent event2 = new DNDEvent(); @@ -424,7 +424,7 @@ int count = 0; for (int i = 0; i < length; i++) { Listener listener = listeners[i]; - if (listener instanceof DNDListener) { + if ( null !is cast(DNDListener)listener ) { dragListeners[count] = cast(DragSourceListener) (cast(DNDListener) listener).getEventListener(); count++; } diff -r e831403a80a9 -r a9ab4c738ed8 dwt/dnd/DropTarget.d --- a/dwt/dnd/DropTarget.d Wed Aug 27 14:30:35 2008 +0200 +++ b/dwt/dnd/DropTarget.d Wed Aug 27 14:32:39 2008 +0200 @@ -167,11 +167,11 @@ }); Object effect = control.getData(DEFAULT_DROP_TARGET_EFFECT); - if (effect instanceof DropTargetEffect) { + if ( null !is cast(DropTargetEffect)effect ) { dropEffect = cast(DropTargetEffect) effect; - } else if (control instanceof Table) { + } else if ( null !is cast(Table)control ) { dropEffect = new TableDropTargetEffect(cast(Table) control); - } else if (control instanceof Tree) { + } else if ( null !is cast(Tree)control ) { dropEffect = new TreeDropTargetEffect(cast(Tree) control); } @@ -543,7 +543,7 @@ int count = 0; for (int i = 0; i < length; i++) { Listener listener = listeners[i]; - if (listener instanceof DNDListener) { + if ( null !is cast(DNDListener)listener ) { dropListeners[count] = cast(DropTargetListener) (cast(DNDListener) listener).getEventListener(); count++; } diff -r e831403a80a9 -r a9ab4c738ed8 dwt/dnd/DropTargetEffect.d --- a/dwt/dnd/DropTargetEffect.d Wed Aug 27 14:30:35 2008 +0200 +++ b/dwt/dnd/DropTargetEffect.d Wed Aug 27 14:32:39 2008 +0200 @@ -85,10 +85,10 @@ * @return the item at the given x-y coordinate, or null if the coordinate is not in a selectable item */ public Widget getItem(int x, int y) { - if (control instanceof Table) { + if ( null !is cast(Table)control ) { return getItem(cast(Table) control, x, y); } - if (control instanceof Tree) { + if ( null !is cast(Tree)control ) { return getItem(cast(Tree) control, x, y); } return null; diff -r e831403a80a9 -r a9ab4c738ed8 dwt/dnd/ImageTransfer.d --- a/dwt/dnd/ImageTransfer.d Wed Aug 27 14:30:35 2008 +0200 +++ b/dwt/dnd/ImageTransfer.d Wed Aug 27 14:32:39 2008 +0200 @@ -200,7 +200,7 @@ } bool checkImage(Object object) { - if (object is null || !(object instanceof ImageData)) return false; + if (object is null || !( null !is cast(ImageData)object )) return false; return true; } diff -r e831403a80a9 -r a9ab4c738ed8 dwt/dnd/URLTransfer.d --- a/dwt/dnd/URLTransfer.d Wed Aug 27 14:30:35 2008 +0200 +++ b/dwt/dnd/URLTransfer.d Wed Aug 27 14:32:39 2008 +0200 @@ -1,1 +1,1 @@ -/******************************************************************************* * Copyright (c) 20007 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ module dwt.dnd; import dwt.internal.carbon.*; /** * The class URLTransfer provides a platform specific mechanism * for converting text in URL format represented as a java String * to a platform specific representation of the data and vice versa. See * Transfer for additional information. The String * must contain the fully specified url. * *

An example of a java String[] containing a URL is shown * below:

* *
 *     String url = "http://www.eclipse.org";
 * 
*/ public class URLTransfer : ByteArrayTransfer { static URLTransfer _instance = new URLTransfer(); static final String URL = "url "; //$NON-NLS-1$ static final int URL_ID = registerType(URL); static final String URLN = "urln"; //$NON-NLS-1$ static final int URLN_ID = registerType(URLN); private URLTransfer() {} /** * Returns the singleton instance of the URLTransfer class. * * @return the singleton instance of the URLTransfer class */ public static URLTransfer getInstance () { return _instance; } /** * This implementation of javaToNative converts a URL * represented by a java String to a platform specific representation. * For additional information see Transfer#javaToNative. * * @param object a java String[] containing a URL * @param transferData an empty TransferData object; this * object will be filled in on return with the platform specific format of the data */ public void javaToNative (Object object, TransferData transferData){ if (!checkURL(object) || !isSupportedType(transferData)) { DND.error(DND.ERROR_INVALID_DATA); } transferData.result = -1; String url = cast(String)object; int count = url.length(); char[] chars = new char[count]; url.getChars(0, count, chars, 0); int cfString = OS.CFStringCreateWithCharacters(OS.kCFAllocatorDefault, chars, count); if (cfString is 0) return; try { CFRange range = new CFRange(); range.length = chars.length; int encoding = OS.CFStringGetSystemEncoding(); int[] size = new int[1]; int numChars = OS.CFStringGetBytes(cfString, range, encoding, cast(byte)'?', true, null, 0, size); if (numChars is 0 || size[0] is 0) return; byte[] buffer = new byte[size[0]]; numChars = OS.CFStringGetBytes(cfString, range, encoding, cast(byte)'?', true, buffer, size [0], size); if (numChars is 0) return; transferData.data = new byte[][] {buffer}; transferData.result = 0; } finally { OS.CFRelease(cfString); } } /** * This implementation of nativeToJava converts a platform specific * representation of a URL to a java String. * For additional information see Transfer#nativeToJava. * * @param transferData the platform specific representation of the data to be * converted * @return a java String[] containing a URL if the * conversion was successful; otherwise null */ public Object nativeToJava(TransferData transferData){ if (!isSupportedType(transferData) || transferData.data is null) return null; if (transferData.data.length is 0) return null; byte[] buffer = transferData.data[0]; int encoding = OS.CFStringGetSystemEncoding(); int cfString = OS.CFStringCreateWithBytes(OS.kCFAllocatorDefault, buffer, buffer.length, encoding, true); if (cfString is 0) return null; try { int length = OS.CFStringGetLength(cfString); if (length is 0) return null; char[] chars = new char[length]; CFRange range = new CFRange(); range.length = length; OS.CFStringGetCharacters(cfString, range, chars); return new String(chars); } finally { OS.CFRelease(cfString); } } protected int[] getTypeIds(){ return new int[] {URL_ID, URLN_ID}; } protected String[] getTypeNames(){ return new String[] {URL, URLN}; } bool checkURL(Object object) { return object !is null && (object instanceof String) && (cast(String)object).length() > 0; } protected bool validate(Object object) { return checkURL(object); } } +/******************************************************************************* * Copyright (c) 20007 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ module dwt.dnd; import dwt.internal.carbon.*; /** * The class URLTransfer provides a platform specific mechanism * for converting text in URL format represented as a java String * to a platform specific representation of the data and vice versa. See * Transfer for additional information. The String * must contain the fully specified url. * *

An example of a java String[] containing a URL is shown * below:

* *
 *     String url = "http://www.eclipse.org";
 * 
*/ public class URLTransfer : ByteArrayTransfer { static URLTransfer _instance = new URLTransfer(); static final String URL = "url "; //$NON-NLS-1$ static final int URL_ID = registerType(URL); static final String URLN = "urln"; //$NON-NLS-1$ static final int URLN_ID = registerType(URLN); private URLTransfer() {} /** * Returns the singleton instance of the URLTransfer class. * * @return the singleton instance of the URLTransfer class */ public static URLTransfer getInstance () { return _instance; } /** * This implementation of javaToNative converts a URL * represented by a java String to a platform specific representation. * For additional information see Transfer#javaToNative. * * @param object a java String[] containing a URL * @param transferData an empty TransferData object; this * object will be filled in on return with the platform specific format of the data */ public void javaToNative (Object object, TransferData transferData){ if (!checkURL(object) || !isSupportedType(transferData)) { DND.error(DND.ERROR_INVALID_DATA); } transferData.result = -1; String url = cast(String)object; int count = url.length(); char[] chars = new char[count]; url.getChars(0, count, chars, 0); int cfString = OS.CFStringCreateWithCharacters(OS.kCFAllocatorDefault, chars, count); if (cfString is 0) return; try { CFRange range = new CFRange(); range.length = chars.length; int encoding = OS.CFStringGetSystemEncoding(); int[] size = new int[1]; int numChars = OS.CFStringGetBytes(cfString, range, encoding, cast(byte)'?', true, null, 0, size); if (numChars is 0 || size[0] is 0) return; byte[] buffer = new byte[size[0]]; numChars = OS.CFStringGetBytes(cfString, range, encoding, cast(byte)'?', true, buffer, size [0], size); if (numChars is 0) return; transferData.data = new byte[][] {buffer}; transferData.result = 0; } finally { OS.CFRelease(cfString); } } /** * This implementation of nativeToJava converts a platform specific * representation of a URL to a java String. * For additional information see Transfer#nativeToJava. * * @param transferData the platform specific representation of the data to be * converted * @return a java String[] containing a URL if the * conversion was successful; otherwise null */ public Object nativeToJava(TransferData transferData){ if (!isSupportedType(transferData) || transferData.data is null) return null; if (transferData.data.length is 0) return null; byte[] buffer = transferData.data[0]; int encoding = OS.CFStringGetSystemEncoding(); int cfString = OS.CFStringCreateWithBytes(OS.kCFAllocatorDefault, buffer, buffer.length, encoding, true); if (cfString is 0) return null; try { int length = OS.CFStringGetLength(cfString); if (length is 0) return null; char[] chars = new char[length]; CFRange range = new CFRange(); range.length = length; OS.CFStringGetCharacters(cfString, range, chars); return new String(chars); } finally { OS.CFRelease(cfString); } } protected int[] getTypeIds(){ return new int[] {URL_ID, URLN_ID}; } protected String[] getTypeNames(){ return new String[] {URL, URLN}; } bool checkURL(Object object) { return object !is null && ( null !is cast(String)object ) && (cast(String)object).length() > 0; } protected bool validate(Object object) { return checkURL(object); } } diff -r e831403a80a9 -r a9ab4c738ed8 dwt/graphics/Color.d --- a/dwt/graphics/Color.d Wed Aug 27 14:30:35 2008 +0200 +++ b/dwt/graphics/Color.d Wed Aug 27 14:32:39 2008 +0200 @@ -122,7 +122,7 @@ */ public bool equals(Object object) { if (object is this) return true; - if (!(object instanceof Color)) return false; + if (!( null !is cast(Color)object )) return false; Color color = cast(Color)object; float[] rgbColor = color.handle; if (handle is rgbColor) return true; diff -r e831403a80a9 -r a9ab4c738ed8 dwt/graphics/Cursor.d --- a/dwt/graphics/Cursor.d Wed Aug 27 14:30:35 2008 +0200 +++ b/dwt/graphics/Cursor.d Wed Aug 27 14:32:39 2008 +0200 @@ -347,7 +347,7 @@ */ public bool equals (Object object) { if (object is this) return true; - if (!(object instanceof Cursor)) return false; + if (!( null !is cast(Cursor)object )) return false; Cursor cursor = cast(Cursor) object; return device is cursor.device && handle is cursor.handle; } diff -r e831403a80a9 -r a9ab4c738ed8 dwt/graphics/Font.d --- a/dwt/graphics/Font.d Wed Aug 27 14:30:35 2008 +0200 +++ b/dwt/graphics/Font.d Wed Aug 27 14:32:39 2008 +0200 @@ -161,7 +161,7 @@ */ public bool equals(Object object) { if (object is this) return true; - if (!(object instanceof Font)) return false; + if (!( null !is cast(Font)object )) return false; Font font = cast(Font)object; return handle is font.handle; } diff -r e831403a80a9 -r a9ab4c738ed8 dwt/graphics/FontData.d --- a/dwt/graphics/FontData.d Wed Aug 27 14:30:35 2008 +0200 +++ b/dwt/graphics/FontData.d Wed Aug 27 14:32:39 2008 +0200 @@ -214,7 +214,7 @@ */ public bool equals (Object object) { if (object is this) return true; - if (!(object instanceof FontData)) return false; + if (!( null !is cast(FontData)object )) return false; FontData data = cast(FontData)object; return name.equals(data.name) && height is data.height && style is data.style; } diff -r e831403a80a9 -r a9ab4c738ed8 dwt/graphics/FontMetrics.d --- a/dwt/graphics/FontMetrics.d Wed Aug 27 14:30:35 2008 +0200 +++ b/dwt/graphics/FontMetrics.d Wed Aug 27 14:32:39 2008 +0200 @@ -50,7 +50,7 @@ */ public bool equals (Object object) { if (object is this) return true; - if (!(object instanceof FontMetrics)) return false; + if (!( null !is cast(FontMetrics)object )) return false; FontMetrics metrics = cast(FontMetrics)object; return ascent is metrics.ascent && descent is metrics.descent && averageCharWidth is metrics.averageCharWidth && leading is metrics.leading && diff -r e831403a80a9 -r a9ab4c738ed8 dwt/graphics/GC.d --- a/dwt/graphics/GC.d Wed Aug 27 14:30:35 2008 +0200 +++ b/dwt/graphics/GC.d Wed Aug 27 14:32:39 2008 +0200 @@ -1400,7 +1400,7 @@ */ public bool equals(Object object) { if (object is this) return true; - if (!(object instanceof GC)) return false; + if (!( null !is cast(GC)object )) return false; return handle is (cast(GC)object).handle; } diff -r e831403a80a9 -r a9ab4c738ed8 dwt/graphics/GlyphMetrics.d --- a/dwt/graphics/GlyphMetrics.d Wed Aug 27 14:30:35 2008 +0200 +++ b/dwt/graphics/GlyphMetrics.d Wed Aug 27 14:32:39 2008 +0200 @@ -79,7 +79,7 @@ */ public bool equals (Object object) { if (object is this) return true; - if (!(object instanceof GlyphMetrics)) return false; + if (!( null !is cast(GlyphMetrics)object )) return false; GlyphMetrics metrics = cast(GlyphMetrics)object; return metrics.ascent is ascent && metrics.descent is descent && metrics.width is width; } diff -r e831403a80a9 -r a9ab4c738ed8 dwt/graphics/Image.d --- a/dwt/graphics/Image.d Wed Aug 27 14:30:35 2008 +0200 +++ b/dwt/graphics/Image.d Wed Aug 27 14:32:39 2008 +0200 @@ -547,7 +547,7 @@ */ public bool equals (Object object) { if (object is this) return true; - if (!(object instanceof Image)) return false; + if (!( null !is cast(Image)object )) return false; Image image = cast(Image)object; return device is image.device && handle is image.handle && transparentPixel is image.transparentPixel; diff -r e831403a80a9 -r a9ab4c738ed8 dwt/graphics/Point.d --- a/dwt/graphics/Point.d Wed Aug 27 14:30:35 2008 +0200 +++ b/dwt/graphics/Point.d Wed Aug 27 14:32:39 2008 +0200 @@ -75,7 +75,7 @@ */ public bool equals (Object object) { if (object is this) return true; - if (!(object instanceof Point)) return false; + if (!( null !is cast(Point)object )) return false; Point p = cast(Point)object; return (p.x is this.x) && (p.y is this.y); } diff -r e831403a80a9 -r a9ab4c738ed8 dwt/graphics/RGB.d --- a/dwt/graphics/RGB.d Wed Aug 27 14:30:35 2008 +0200 +++ b/dwt/graphics/RGB.d Wed Aug 27 14:32:39 2008 +0200 @@ -194,7 +194,7 @@ */ public bool equals(Object object) { if (object is this) return true; - if (!(object instanceof RGB)) return false; + if (!( null !is cast(RGB)object )) return false; RGB rgb = cast(RGB)object; return (rgb.red is this.red) && (rgb.green is this.green) && (rgb.blue is this.blue); } diff -r e831403a80a9 -r a9ab4c738ed8 dwt/graphics/Rectangle.d --- a/dwt/graphics/Rectangle.d Wed Aug 27 14:30:35 2008 +0200 +++ b/dwt/graphics/Rectangle.d Wed Aug 27 14:32:39 2008 +0200 @@ -152,7 +152,7 @@ */ public bool equals (Object object) { if (object is this) return true; - if (!(object instanceof Rectangle)) return false; + if (!( null !is cast(Rectangle)object )) return false; Rectangle r = cast(Rectangle)object; return (r.x is this.x) && (r.y is this.y) && (r.width is this.width) && (r.height is this.height); } diff -r e831403a80a9 -r a9ab4c738ed8 dwt/graphics/Region.d --- a/dwt/graphics/Region.d Wed Aug 27 14:30:35 2008 +0200 +++ b/dwt/graphics/Region.d Wed Aug 27 14:32:39 2008 +0200 @@ -298,7 +298,7 @@ */ public bool equals(Object object) { if (this is object) return true; - if (!(object instanceof Region)) return false; + if (!( null !is cast(Region)object )) return false; Region region = cast(Region)object; return handle is region.handle; } diff -r e831403a80a9 -r a9ab4c738ed8 dwt/graphics/TextStyle.d --- a/dwt/graphics/TextStyle.d Wed Aug 27 14:30:35 2008 +0200 +++ b/dwt/graphics/TextStyle.d Wed Aug 27 14:32:39 2008 +0200 @@ -200,7 +200,7 @@ public bool equals(Object object) { if (object is this) return true; if (object is null) return false; - if (!(object instanceof TextStyle)) return false; + if (!( null !is cast(TextStyle)object )) return false; TextStyle style = cast(TextStyle)object; if (foreground !is null) { if (!foreground.equals(style.foreground)) return false; diff -r e831403a80a9 -r a9ab4c738ed8 dwt/internal/image/FileFormat.d --- a/dwt/internal/image/FileFormat.d Wed Aug 27 14:30:35 2008 +0200 +++ b/dwt/internal/image/FileFormat.d Wed Aug 27 14:32:39 2008 +0200 @@ -51,7 +51,7 @@ inputStream = stream; return loadFromByteStream(); } catch (Exception e) { - if (e instanceof IOException) { + if ( null !is cast(IOException)e ) { DWT.error(DWT.ERROR_IO, e); } else { DWT.error(DWT.ERROR_INVALID_IMAGE, e); diff -r e831403a80a9 -r a9ab4c738ed8 dwt/layout/FillLayout.d --- a/dwt/layout/FillLayout.d Wed Aug 27 14:30:35 2008 +0200 +++ b/dwt/layout/FillLayout.d Wed Aug 27 14:32:39 2008 +0200 @@ -155,7 +155,7 @@ } else { // TEMPORARY CODE int trimX, trimY; - if (control instanceof Scrollable) { + if ( null !is cast(Scrollable)control ) { Rectangle rect = (cast(Scrollable) control).computeTrim (0, 0, 0, 0); trimX = rect.width; trimY = rect.height; diff -r e831403a80a9 -r a9ab4c738ed8 dwt/layout/FormLayout.d --- a/dwt/layout/FormLayout.d Wed Aug 27 14:30:35 2008 +0200 +++ b/dwt/layout/FormLayout.d Wed Aug 27 14:32:39 2008 +0200 @@ -313,7 +313,7 @@ if (data.height is DWT.DEFAULT && !data.needed) { int trim = 0; //TEMPORARY CODE - if (child instanceof Scrollable) { + if ( null !is cast(Scrollable)child ) { Rectangle rect = (cast(Scrollable) child).computeTrim (0, 0, 0, 0); trim = rect.width; } else { diff -r e831403a80a9 -r a9ab4c738ed8 dwt/layout/GridLayout.d --- a/dwt/layout/GridLayout.d Wed Aug 27 14:30:35 2008 +0200 +++ b/dwt/layout/GridLayout.d Wed Aug 27 14:32:39 2008 +0200 @@ -222,7 +222,7 @@ if (data.cacheWidth < data.minimumWidth) { int trim = 0; //TEMPORARY CODE - if (child instanceof Scrollable) { + if ( null !is cast(Scrollable)child ) { Rectangle rect = (cast(Scrollable) child).computeTrim (0, 0, 0, 0); trim = rect.width; } else { @@ -471,7 +471,7 @@ currentWidth += (hSpan - 1) * horizontalSpacing - data.horizontalIndent; if ((currentWidth !is data.cacheWidth && data.horizontalAlignment is DWT.FILL) || (data.cacheWidth > currentWidth)) { int trim = 0; - if (child instanceof Scrollable) { + if ( null !is cast(Scrollable)child ) { Rectangle rect = (cast(Scrollable) child).computeTrim (0, 0, 0, 0); trim = rect.width; } else { diff -r e831403a80a9 -r a9ab4c738ed8 dwt/program/Program.d --- a/dwt/program/Program.d Wed Aug 27 14:30:35 2008 +0200 +++ b/dwt/program/Program.d Wed Aug 27 14:32:39 2008 +0200 @@ -517,7 +517,7 @@ */ public bool equals(Object other) { if (this is other) return true; - if (other instanceof Program) { + if ( null !is cast(Program)other ) { final Program program = cast(Program) other; return name.equals(program.name); } diff -r e831403a80a9 -r a9ab4c738ed8 dwt/widgets/Composite.d --- a/dwt/widgets/Composite.d Wed Aug 27 14:30:35 2008 +0200 +++ b/dwt/widgets/Composite.d Wed Aug 27 14:32:39 2008 +0200 @@ -108,7 +108,7 @@ if (tag !is 0 && tag !is -1) { Object widget = OS.JNIGetObject(tag); if (widget !is null && widget !is this) { - if (widget instanceof Control) { + if ( null !is cast(Control)widget ) { children [j++] = cast(Control) widget; } } diff -r e831403a80a9 -r a9ab4c738ed8 dwt/widgets/Control.d --- a/dwt/widgets/Control.d Wed Aug 27 14:30:35 2008 +0200 +++ b/dwt/widgets/Control.d Wed Aug 27 14:32:39 2008 +0200 @@ -655,7 +655,7 @@ Font defaultFont () { //TODO - Controls only, does this leak? - if (view instanceof NSControl) { + if ( null !is cast(NSControl)view ) { NSFont nsFont = (cast(NSControl)view).font (); if (nsFont !is null) { return Font.cocoa_new (display, nsFont); @@ -806,7 +806,7 @@ void enableWidget (bool enabled) { //TODO - other views - if (view instanceof NSControl) { + if ( null !is cast(NSControl)view ) { (cast(NSControl)view).setEnabled(enabled); } } @@ -1360,7 +1360,7 @@ } bool isFocusAncestor (Control control) { - while (control !is null && control !is this && !(control instanceof Shell)) { + while (control !is null && control !is this && !( null !is cast(Shell)control )) { control = control.parent; } return control is this; @@ -2566,7 +2566,7 @@ void setFont (NSFont font) { //TODO - bad cast - if (view instanceof NSControl) { + if ( null !is cast(NSControl)view ) { (cast(NSControl)view).setFont(font); } } diff -r e831403a80a9 -r a9ab4c738ed8 dwt/widgets/Display.d --- a/dwt/widgets/Display.d Wed Aug 27 14:30:35 2008 +0200 +++ b/dwt/widgets/Display.d Wed Aug 27 14:32:39 2008 +0200 @@ -769,7 +769,7 @@ int tag = OS.objc_msgSend(handle, OS.sel_tag); if (tag !is -1) { Object object = OS.JNIGetObject(tag); - if (object instanceof Widget) { + if ( null !is cast(Widget)object ) { return cast(Widget)object; } } @@ -869,7 +869,7 @@ int tag = OS.objc_msgSend(view.id, OS.sel_tag); if (tag !is -1) { Object object = OS.JNIGetObject(tag); - if (object instanceof Shell) { + if ( null !is cast(Shell)object ) { return cast(Shell)object; } } @@ -1119,7 +1119,7 @@ int tag = OS.objc_msgSend(view.id, OS.sel_tag); if (tag !is -1) { Object object = OS.JNIGetObject(tag); - if (object instanceof Control) { + if ( null !is cast(Control)object ) { //TODO go up hierarchy return cast(Control)object; } @@ -1138,7 +1138,7 @@ tag = OS.objc_msgSend(delegate.id, OS.sel_tag); if (tag !is 0 && tag !is -1) { Object object = OS.JNIGetObject(tag); - if (object instanceof Control) { + if ( null !is cast(Control)object ) { return cast(Control)object; } } @@ -1332,7 +1332,7 @@ int jniRef = OS.objc_msgSend(view.id, OS.sel_tag); if (jniRef !is 0 && jniRef !is -1) { Object object = OS.JNIGetObject(jniRef); - if (object instanceof Shell) { + if ( null !is cast(Shell)object ) { result[index++] = cast(Shell)object; } } @@ -3114,9 +3114,9 @@ dialog.changeFont(arg0); } else if (sel is OS.sel_windowWillClose_1) { Object object = OS.JNIGetObject(jniRef); - if (object instanceof FontDialog) { + if ( null !is cast(FontDialog)object ) { (cast(FontDialog)object).windowWillClose(arg0); - } else if (object instanceof ColorDialog) { + } else if ( null !is cast(ColorDialog)object ) { (cast(ColorDialog)object).windowWillClose(arg0); } } diff -r e831403a80a9 -r a9ab4c738ed8 dwt/widgets/Menu.d --- a/dwt/widgets/Menu.d Wed Aug 27 14:30:35 2008 +0200 +++ b/dwt/widgets/Menu.d Wed Aug 27 14:32:39 2008 +0200 @@ -640,7 +640,7 @@ int jniRef = OS.objc_msgSend(itemID, OS.sel_tag); if (jniRef !is -1 && jniRef !is 0) { Object object = OS.JNIGetObject(jniRef); - if (object instanceof MenuItem) { + if ( null !is cast(MenuItem)object ) { MenuItem item = cast(MenuItem)object; item.sendEvent (DWT.Arm); } diff -r e831403a80a9 -r a9ab4c738ed8 dwt/widgets/Monitor.d --- a/dwt/widgets/Monitor.d Wed Aug 27 14:30:35 2008 +0200 +++ b/dwt/widgets/Monitor.d Wed Aug 27 14:32:39 2008 +0200 @@ -44,7 +44,7 @@ */ public bool equals (Object object) { if (object is this) return true; - if (!(object instanceof Monitor)) return false; + if (!( null !is cast(Monitor)object )) return false; Monitor monitor = cast(Monitor) object; return handle is monitor.handle; } diff -r e831403a80a9 -r a9ab4c738ed8 dwt/widgets/TypedListener.d --- a/dwt/widgets/TypedListener.d Wed Aug 27 14:30:35 2008 +0200 +++ b/dwt/widgets/TypedListener.d Wed Aug 27 14:32:39 2008 +0200 @@ -133,7 +133,7 @@ break; } case DWT.Collapse: { - if (eventListener instanceof TreeListener) { + if ( null !is cast(TreeListener)eventListener ) { (cast(TreeListener) eventListener).treeCollapsed(new TreeEvent(e)); } else { (cast(ExpandListener) eventListener).itemCollapsed(new ExpandEvent(e)); @@ -161,7 +161,7 @@ break; } case DWT.Expand: { - if (eventListener instanceof TreeListener) { + if ( null !is cast(TreeListener)eventListener ) { (cast(TreeListener) eventListener).treeExpanded(new TreeEvent(e)); } else { (cast(ExpandListener) eventListener).itemExpanded(new ExpandEvent(e));