Mercurial > projects > dwt2
changeset 22:4642ab680468
some work on dwt-win for tango/phobos
line wrap: on
line diff
--- a/org.eclipse.swt.win32.win32.x86/src/org/eclipse/swt/custom/CTabFolder2Listener.d Thu Mar 19 20:38:55 2009 +0100 +++ b/org.eclipse.swt.win32.win32.x86/src/org/eclipse/swt/custom/CTabFolder2Listener.d Fri Mar 20 12:52:28 2009 +0100 @@ -15,8 +15,13 @@ import org.eclipse.swt.internal.SWTEventListener; import org.eclipse.swt.custom.CTabFolderEvent; -import tango.core.Traits; -import tango.core.Tuple; +version(Tango){ + import tango.core.Traits; + import tango.core.Tuple; +} else { // Phobos + import std.traits; + import std.typetuple; +} /** * Classes which implement this interface provide methods @@ -129,9 +134,15 @@ /// Helper class for the dgListener template function private class _DgCTabFolder2ListenerT(Dg,T...) : CTabFolder2Listener { - alias ParameterTupleOf!(Dg) DgArgs; - static assert( is(DgArgs == Tuple!(CTabFolderEvent,T)), + version(Tango){ + alias ParameterTupleOf!(Dg) DgArgs; + static assert( is(DgArgs == Tuple!(CTabFolderEvent,T)), "Delegate args not correct: "~DgArgs.stringof~" vs. (Event,"~T.stringof~")" ); + } else { // Phobos + alias ParameterTypeTuple!(Dg) DgArgs; + static assert( is(DgArgs == TypeTuple!(CTabFolderEvent,T)), + "Delegate args not correct: "~DgArgs.stringof~" vs. (Event,"~T.stringof~")" ); + } Dg dg; T t;
--- a/org.eclipse.swt.win32.win32.x86/src/org/eclipse/swt/custom/CTabFolderListener.d Thu Mar 19 20:38:55 2009 +0100 +++ b/org.eclipse.swt.win32.win32.x86/src/org/eclipse/swt/custom/CTabFolderListener.d Fri Mar 20 12:52:28 2009 +0100 @@ -15,8 +15,13 @@ import org.eclipse.swt.internal.SWTEventListener; import org.eclipse.swt.custom.CTabFolderEvent; -import tango.core.Traits; -import tango.core.Tuple; +version(Tango){ + import tango.core.Traits; + import tango.core.Tuple; +} else { // Phobos + import std.traits; + import std.typetuple; +} /** * Classes which implement this interface provide a method @@ -51,9 +56,15 @@ /// Helper class for the dgListener template function private class _DgCTabFolderListenerT(Dg,T...) : CTabFolderListener { - alias ParameterTupleOf!(Dg) DgArgs; - static assert( is(DgArgs == Tuple!(CTabFolderEvent,T)), + version(Tango){ + alias ParameterTupleOf!(Dg) DgArgs; + static assert( is(DgArgs == Tuple!(CTabFolderEvent,T)), "Delegate args not correct" ); + } else { // Phobos + alias ParameterTypeTuple!(Dg) DgArgs; + static assert( is(DgArgs == TypeTuple!(CTabFolderEvent,T)), + "Delegate args not correct" ); + } Dg dg; T t;
--- a/org.eclipse.swt.win32.win32.x86/src/org/eclipse/swt/dnd/Transfer.d Thu Mar 19 20:38:55 2009 +0100 +++ b/org.eclipse.swt.win32.win32.x86/src/org/eclipse/swt/dnd/Transfer.d Fri Mar 20 12:52:28 2009 +0100 @@ -48,13 +48,13 @@ */ int getData(IDataObject dataObject, FORMATETC* pFormatetc, STGMEDIUM* pmedium) { if (dataObject.GetData(pFormatetc, pmedium) is COM.S_OK) return COM.S_OK; - try {tango.core.Thread.Thread.sleep(50);} catch (Exception t) {} + try {Thread.sleep(50);} catch (Exception t) {} int result = dataObject.GetData(pFormatetc, pmedium); int retryCount = 0; while (result !is COM.S_OK && retryCount++ < RETRY_LIMIT) { MSG msg; OS.PeekMessage(&msg, null, 0, 0, OS.PM_NOREMOVE | OS.PM_NOYIELD); - try {tango.core.Thread.Thread.sleep(50);} catch (Exception t) {} + try {Thread.sleep(50);} catch (Exception t) {} result = dataObject.GetData(pFormatetc, pmedium); } return result;
--- a/org.eclipse.swt.win32.win32.x86/src/org/eclipse/swt/graphics/ImageLoader.d Thu Mar 19 20:38:55 2009 +0100 +++ b/org.eclipse.swt.win32.win32.x86/src/org/eclipse/swt/graphics/ImageLoader.d Fri Mar 20 12:52:28 2009 +0100 @@ -21,7 +21,7 @@ import org.eclipse.swt.internal.Compatibility; import org.eclipse.swt.internal.image.FileFormat; -import tango.core.Array; +//import tango.core.Array; import java.util.Vector; import java.lang.all;
--- a/org.eclipse.swt.win32.win32.x86/src/org/eclipse/swt/internal/C.d Thu Mar 19 20:38:55 2009 +0100 +++ b/org.eclipse.swt.win32.win32.x86/src/org/eclipse/swt/internal/C.d Fri Mar 20 12:52:28 2009 +0100 @@ -12,10 +12,18 @@ import org.eclipse.swt.internal.Platform; -static import tango.stdc.string; +version(Tango){ + static import tango.stdc.string; +} else { // Phobos + static import std.c.string; +} public class C : Platform { - alias tango.stdc.string.memmove MoveMemory; + version(Tango){ + alias tango.stdc.string.memmove MoveMemory; + } else { // Phobos + alias std.c.string.memmove MoveMemory; + } //public static final native void free (int /*long*/ ptr); //public static final native int /*long*/ getenv (byte[] wcsToMbcs); //public static final native int /*long*/ malloc (int /*long*/ size);
--- a/org.eclipse.swt.win32.win32.x86/src/org/eclipse/swt/internal/Compatibility.d Thu Mar 19 20:38:55 2009 +0100 +++ b/org.eclipse.swt.win32.win32.x86/src/org/eclipse/swt/internal/Compatibility.d Fri Mar 20 12:52:28 2009 +0100 @@ -25,11 +25,15 @@ public import java.io.FileOutputStream; import java.io.InputStream; -import Unicode = tango.text.Unicode; -import tango.sys.Process; import java.lang.all; import java.util.ResourceBundle; -import tango.io.Path; + +version(Tango){ +static import tango.text.Unicode; +static import tango.sys.Process; +static import tango.io.Path; +} else { // Phobos +} /** * This class is a placeholder for utility methods commonly @@ -117,7 +121,10 @@ * @return true if the file exists */ public static bool fileExists(String parent, String child) { - return FS.exists( FS.join(parent, child)); + return tango.io.Path.exists( + tango.io.Path.join( + tango.io.Path.standard(parent), + tango.io.Path.standard(child))); } /** @@ -273,7 +280,7 @@ * if the program cannot be executed */ public static void exec(String prog) { - auto proc = new Process( prog ); + auto proc = new tango.sys.Process.Process( prog ); proc.execute; } @@ -290,7 +297,7 @@ * if the program cannot be executed */ public static void exec(String[] progArray) { - auto proc = new Process( progArray ); + auto proc = new tango.sys.Process.Process( progArray ); proc.execute; } @@ -412,8 +419,8 @@ delete s1b; delete s2b; } - String s1c = Unicode.toFold( s1, s1b ); - String s2c = Unicode.toFold( s2, s2b ); + String s1c = tango.text.Unicode.toFold( s1, s1b ); + String s2c = tango.text.Unicode.toFold( s2, s2b ); return s1c == s2c; }
--- a/org.eclipse.swt.win32.win32.x86/src/org/eclipse/swt/internal/Lock.d Thu Mar 19 20:38:55 2009 +0100 +++ b/org.eclipse.swt.win32.win32.x86/src/org/eclipse/swt/internal/Lock.d Fri Mar 20 12:52:28 2009 +0100 @@ -13,8 +13,11 @@ module org.eclipse.swt.internal.Lock; import java.lang.Thread; -import tango.core.sync.Mutex; -import tango.core.sync.Condition; +version(Tango){ + import tango.core.sync.Mutex; + import tango.core.sync.Condition; +} else { // Phobos +} /** * Instance of this represent a recursive monitor. @@ -22,52 +25,68 @@ public class Lock { int count, waitCount; Thread owner; - Mutex mutex; - Condition cond; + version(Tango){ + Mutex mutex; + Condition cond; + } else { // Phobos + } + public this() { - mutex = new Mutex; - cond = new Condition(mutex); + version(Tango){ + mutex = new Mutex; + cond = new Condition(mutex); + } else { // Phobos + } } -/** - * Locks the monitor and returns the lock count. If - * the lock is owned by another thread, wait until - * the lock is released. - * - * @return the lock count - */ -public int lock() { - synchronized (mutex) { - Thread current = Thread.currentThread(); - if (owner !is current) { - waitCount++; - while (count > 0) { - try { - cond.wait(); - } catch (SyncException e) { - /* Wait forever, just like synchronized blocks */ + /** + * Locks the monitor and returns the lock count. If + * the lock is owned by another thread, wait until + * the lock is released. + * + * @return the lock count + */ + public int lock() { + version(Tango){ + synchronized (mutex) { + Thread current = Thread.currentThread(); + if (owner !is current) { + waitCount++; + while (count > 0) { + try { + cond.wait(); + } catch (SyncException e) { + /* Wait forever, just like synchronized blocks */ + } + } + --waitCount; + owner = current; + } + return ++count; + } + } else { // Phobos + implMissing( __FILE__, __LINE__ ); + return 0; + } + } + + /** + * Unlocks the monitor. If the current thread is not + * the monitor owner, do nothing. + */ + public void unlock() { + version(Tango){ + synchronized (mutex) { + Thread current = Thread.currentThread(); + if (owner is current) { + if (--count is 0) { + owner = null; + if (waitCount > 0) cond.notifyAll(); + } } } - --waitCount; - owner = current; - } - return ++count; - } -} - -/** - * Unlocks the monitor. If the current thread is not - * the monitor owner, do nothing. - */ -public void unlock() { - synchronized (mutex) { - Thread current = Thread.currentThread(); - if (owner is current) { - if (--count is 0) { - owner = null; - if (waitCount > 0) cond.notifyAll(); - } + } else { // Phobos + implMissing( __FILE__, __LINE__ ); } } } -}
--- a/org.eclipse.swt.win32.win32.x86/src/org/eclipse/swt/internal/gdip/Gdip.d Thu Mar 19 20:38:55 2009 +0100 +++ b/org.eclipse.swt.win32.win32.x86/src/org/eclipse/swt/internal/gdip/Gdip.d Fri Mar 20 12:52:28 2009 +0100 @@ -21,7 +21,11 @@ import org.eclipse.swt.internal.win32.WINTYPES; import org.eclipse.swt.internal.win32.WINAPI; import org.eclipse.swt.internal.win32.OS; -import tango.sys.win32.UserGdi; + +version(Tango){ + import tango.sys.win32.UserGdi; +} else { // Phobos +} alias org.eclipse.swt.internal.gdip.native.GdiplusStartupInput GdiplusStartupInput; alias org.eclipse.swt.internal.gdip.native.GdiplusStartupOutput GdiplusStartupOutput;
--- a/org.eclipse.swt.win32.win32.x86/src/org/eclipse/swt/internal/gdip/native.d Thu Mar 19 20:38:55 2009 +0100 +++ b/org.eclipse.swt.win32.win32.x86/src/org/eclipse/swt/internal/gdip/native.d Fri Mar 20 12:52:28 2009 +0100 @@ -13,9 +13,13 @@ module org.eclipse.swt.internal.gdip.native; import org.eclipse.swt.internal.win32.WINTYPES; -import tango.sys.SharedLib : SharedLib; import java.lang.all; +version(Tango){ + static import tango.sys.SharedLib; +} else { // Phobos +} + extern(Windows): /****************************************************************************** @@ -1677,7 +1681,7 @@ void loadLib_Gdip(){ - if (auto lib = SharedLib.load(`gdiplus.dll`)) { + if (auto lib = tango.sys.SharedLib.SharedLib.load(`gdiplus.dll`)) { foreach( inout s; symbols ){ *s.symbol = lib.getSymbol( s.name.ptr ); if( s.symbol is null ){
--- a/org.eclipse.swt.win32.win32.x86/src/org/eclipse/swt/internal/image/FileFormat.d Thu Mar 19 20:38:55 2009 +0100 +++ b/org.eclipse.swt.win32.win32.x86/src/org/eclipse/swt/internal/image/FileFormat.d Fri Mar 20 12:52:28 2009 +0100 @@ -32,7 +32,11 @@ import org.eclipse.swt.internal.image.JPEGFileFormat; import org.eclipse.swt.internal.image.PNGFileFormat; -import tango.core.Tuple; +version(Tango){ + import tango.core.Tuple; +} else { // Phobos + import std.typetuple; +} /** * Abstract factory class for loading/unloading images from files or streams @@ -43,7 +47,12 @@ static const String FORMAT_PACKAGE = "org.eclipse.swt.internal.image"; //$NON-NLS-1$ static const String FORMAT_SUFFIX = "FileFormat"; //$NON-NLS-1$ static const String[] FORMATS = [ "WinBMP"[], "WinBMP", "GIF", "WinICO", "JPEG", "PNG", "TIFF", "OS2BMP" ]; //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$//$NON-NLS-5$ //$NON-NLS-6$//$NON-NLS-7$//$NON-NLS-8$ - alias Tuple!( WinBMPFileFormat, WinBMPFileFormat, GIFFileFormat, WinICOFileFormat, JPEGFileFormat, PNGFileFormat, TIFFFileFormat, OS2BMPFileFormat ) TFormats; + version(Tango){ + alias Tuple!( WinBMPFileFormat, WinBMPFileFormat, GIFFileFormat, WinICOFileFormat, JPEGFileFormat, PNGFileFormat, TIFFFileFormat, OS2BMPFileFormat ) TFormats; + } else { // Phobos + alias TypeTuple!( WinBMPFileFormat, WinBMPFileFormat, GIFFileFormat, WinICOFileFormat, JPEGFileFormat, PNGFileFormat, TIFFFileFormat, OS2BMPFileFormat ) TFormats; + } + LEDataInputStream inputStream; LEDataOutputStream outputStream; ImageLoader loader;
--- a/org.eclipse.swt.win32.win32.x86/src/org/eclipse/swt/internal/mozilla/nsILocalFile.d Thu Mar 19 20:38:55 2009 +0100 +++ b/org.eclipse.swt.win32.win32.x86/src/org/eclipse/swt/internal/mozilla/nsILocalFile.d Fri Mar 20 12:52:28 2009 +0100 @@ -8,7 +8,11 @@ import org.eclipse.swt.internal.mozilla.nsIFile; import org.eclipse.swt.internal.mozilla.nsStringAPI; -import tango.stdc.stdio : FILE; +version(Tango){ + import tango.stdc.stdio : FILE; +} else { // Phobos + import std.c.stdio : FILE; +} const char[] NS_ILOCALFILE_IID_STR = "aa610f20-a889-11d3-8c81-000064657374";
--- a/org.eclipse.swt.win32.win32.x86/src/org/eclipse/swt/internal/ole/win32/extras.d Thu Mar 19 20:38:55 2009 +0100 +++ b/org.eclipse.swt.win32.win32.x86/src/org/eclipse/swt/internal/ole/win32/extras.d Fri Mar 20 12:52:28 2009 +0100 @@ -36,17 +36,7 @@ E_UNEXPECTED = cast(int)0x8000FFFF, } -// in tango types.di -// struct GUID { // size is 16 -// align(1): -// DWORD Data1; -// WORD Data2; -// WORD Data3; -// BYTE Data4[8]; -// } - -enum -{ +enum { CLSCTX_INPROC_SERVER = 0x1, CLSCTX_INPROC_HANDLER = 0x2, CLSCTX_LOCAL_SERVER = 0x4,
--- a/org.eclipse.swt.win32.win32.x86/src/org/eclipse/swt/internal/win32/OS.d Thu Mar 19 20:38:55 2009 +0100 +++ b/org.eclipse.swt.win32.win32.x86/src/org/eclipse/swt/internal/win32/OS.d Fri Mar 20 12:52:28 2009 +0100 @@ -19,6 +19,7 @@ import org.eclipse.swt.internal.Library; import java.lang.all; +version(Tango){ static import tango.sys.win32.UserGdi; static import tango.sys.SharedLib; static import tango.sys.Common; @@ -27,6 +28,9 @@ static import tango.stdc.string; alias tango.sys.win32.UserGdi WINAPI; +} else { // Phobos +} + alias org.eclipse.swt.internal.win32.WINAPI DWTWINAPI; void trace(int line ){ @@ -266,7 +270,11 @@ _PCHAR!("SWT Unicode version applications can't run in a non-Unicode platform !"), _PCHAR!("Error"), MB_OK|MB_ICONERROR); - tango.stdc.stdlib.exit(-1); + version(Tango){ + tango.stdc.stdlib.exit(-1); + } else { // Phobos + std.c.stdlib.exit(-1); + } } //OSVERSIONINFO info = new OSVERSIONINFOW (); //info.dwOSVersionInfoSize = OSVERSIONINFOW.sizeof;