Mercurial > projects > dwt2
changeset 47:65761bc28ab2
swt linux again compilable for d1.
line wrap: on
line diff
--- a/base/src/java/nonstandard/SharedLib.d Fri Mar 27 11:10:45 2009 +0100 +++ b/base/src/java/nonstandard/SharedLib.d Fri Mar 27 11:43:53 2009 +0100 @@ -1,6 +1,10 @@ module java.nonstandard.SharedLib; import java.lang.all; +version(Tango){ + static import tango.sys.SharedLib; + static import tango.stdc.stringz; +} struct Symbol { String name; @@ -21,7 +25,7 @@ foreach( inout s; symbols ){ if( s.major < major ) continue; if( s.major == major && s.minor > minor ) continue; - *s.symbol = lib.getSymbol( s.name.ptr ); + *s.symbol = lib.getSymbol( tango.stdc.stringz.toStringz(s.name ) ); if( s.symbol is null ){ getDwtLogger.error( __FILE__, __LINE__, "{}: Symbol '{}' not found", libname, s.name ); } @@ -37,7 +41,7 @@ version(Tango){ if (auto lib = tango.sys.SharedLib.SharedLib.load(libname)) { foreach( inout s; symbols ){ - *s.symbol = lib.getSymbol( s.name.ptr ); + *s.symbol = lib.getSymbol( tango.stdc.stringz.toStringz(s.name ) ); if( s.symbol is null ){ getDwtLogger.error( __FILE__, __LINE__, "{}: Symbol '{}' not found", libname, s.name ); } @@ -53,7 +57,7 @@ bool result = false; version(Tango){ if (auto lib = tango.sys.SharedLib.SharedLib.load( libname ) ) { - void* ptr = lib.getSymbol(symbolname); + void* ptr = lib.getSymbol( tango.stdc.stringz.toStringz(symbolname)); if (ptr !is null){ dg(ptr); result = true;
--- a/org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/accessibility/Accessible.d Fri Mar 27 11:10:45 2009 +0100 +++ b/org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/accessibility/Accessible.d Fri Mar 27 11:43:53 2009 +0100 @@ -20,7 +20,7 @@ import org.eclipse.swt.accessibility.AccessibleControlListener; import org.eclipse.swt.accessibility.AccessibleFactory; import org.eclipse.swt.accessibility.AccessibleObject; -import tango.core.Thread; +import java.lang.Thread; import org.eclipse.swt.SWT; //import org.eclipse.swt.events.*; import org.eclipse.swt.internal.gtk.OS; @@ -206,7 +206,7 @@ /* isValidThread was copied from Widget, and rewritten to work in this package */ bool isValidThread () { - return control.getDisplay ().getThread () is Thread.getThis (); + return control.getDisplay ().getThread () is Thread.currentThread (); } void release () {
--- a/org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/browser/Browser.d Fri Mar 27 11:10:45 2009 +0100 +++ b/org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/browser/Browser.d Fri Mar 27 11:43:53 2009 +0100 @@ -14,7 +14,7 @@ import java.lang.all; -import tango.core.Thread; +import java.lang.Thread; import org.eclipse.swt.SWT; import org.eclipse.swt.SWTError; @@ -129,7 +129,7 @@ if (parent !is null && !parent.isDisposed ()) { Display display = parent.getDisplay (); if (display !is null) { - if (display.getThread () is Thread.getThis ()) { + if (display.getThread () is Thread.currentThread ()) { display.setData (NO_INPUT_METHOD, stringcast("true")); //$NON-NLS-1$ } }
--- a/org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/dnd/Clipboard.d Fri Mar 27 11:10:45 2009 +0100 +++ b/org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/dnd/Clipboard.d Fri Mar 27 11:43:53 2009 +0100 @@ -27,7 +27,7 @@ import java.lang.all; -import tango.core.Thread; +import java.lang.Thread; static import tango.stdc.string; /** @@ -82,7 +82,7 @@ display = Display.getDefault(); } } - if (display.getThread() !is Thread.getThis()) { + if (display.getThread() !is Thread.currentThread()) { DND.error(SWT.ERROR_THREAD_INVALID_ACCESS); } this.display = display; @@ -147,7 +147,7 @@ protected void checkWidget () { Display display = this.display; if (display is null) DND.error (SWT.ERROR_WIDGET_DISPOSED); - if (display.getThread() !is Thread.getThis ()) DND.error (SWT.ERROR_THREAD_INVALID_ACCESS); + if (display.getThread() !is Thread.currentThread ()) DND.error (SWT.ERROR_THREAD_INVALID_ACCESS); if (display.isDisposed()) DND.error(SWT.ERROR_WIDGET_DISPOSED); } @@ -215,7 +215,7 @@ */ public void dispose () { if (isDisposed()) return; - if (display.getThread() !is Thread.getThis()) DND.error(SWT.ERROR_THREAD_INVALID_ACCESS); + if (display.getThread() !is Thread.currentThread()) DND.error(SWT.ERROR_THREAD_INVALID_ACCESS); display = null; }
--- a/org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/dnd/DragSource.d Fri Mar 27 11:10:45 2009 +0100 +++ b/org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/dnd/DragSource.d Fri Mar 27 11:43:53 2009 +0100 @@ -38,7 +38,7 @@ import org.eclipse.swt.dnd.TransferData; import java.lang.all; -import tango.core.Thread; +import java.lang.Thread; /** * @@ -266,7 +266,7 @@ } static DragSource FindDragSource(GtkWidget* handle) { - Display display = Display.findDisplay(Thread.getThis()); + Display display = Display.findDisplay(Thread.currentThread()); if (display is null || display.isDisposed()) return null; Widget widget = display.findWidget(handle); if (widget is null) return null;
--- a/org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/dnd/DropTarget.d Fri Mar 27 11:10:45 2009 +0100 +++ b/org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/dnd/DropTarget.d Fri Mar 27 11:43:53 2009 +0100 @@ -38,7 +38,7 @@ import org.eclipse.swt.dnd.TreeDropTargetEffect; import java.lang.all; -import tango.core.Thread; +import java.lang.Thread; static import tango.stdc.string; /** @@ -320,7 +320,7 @@ } static DropTarget FindDropTarget(GtkWidget* handle) { - Display display = Display.findDisplay(Thread.getThis()); + Display display = Display.findDisplay(Thread.currentThread()); if (display is null || display.isDisposed()) return null; Widget widget = display.findWidget(handle); if (widget is null) return null;
--- a/org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/graphics/TextLayout.d Fri Mar 27 11:10:45 2009 +0100 +++ b/org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/graphics/TextLayout.d Fri Mar 27 11:43:53 2009 +0100 @@ -210,7 +210,7 @@ i += incr; } } - int slen = strlen(ptr); + int slen = OS.strlen(ptr); Font defaultFont = font !is null ? font : device.systemFont; for (int i = 0; i < styles.length - 1; i++) { StyleItem styleItem = styles[i]; @@ -523,7 +523,7 @@ auto ptr = OS.pango_layout_get_text(layout); int byteSelStart = selectionStart;//(OS.g_utf8_offset_to_pointer(ptr, selectionStart) - ptr); int byteSelEnd = selectionEnd + 1;//(OS.g_utf8_offset_to_pointer(ptr, selectionEnd + 1) - ptr); - int slen = strlen(ptr); + int slen = OS.strlen(ptr); byteSelStart = Math.min(byteSelStart, slen); byteSelEnd = Math.min(byteSelEnd, slen); if (cairo !is null && OS.GTK_VERSION >= OS.buildVERSION(2, 8, 0)) { @@ -957,7 +957,7 @@ } int byteStart = start;//(OS.g_utf8_offset_to_pointer (ptr, start) - ptr); int byteEnd = end + incr;//(OS.g_utf8_offset_to_pointer (ptr, end + 1) - ptr); - int slen = strlen(ptr); + int slen = OS.strlen(ptr); byteStart = Math.min(byteStart, slen); byteEnd = Math.min(byteEnd, slen); int[] ranges = [byteStart, byteEnd]; @@ -1095,7 +1095,7 @@ PangoLayoutRun* run = new PangoLayoutRun(); auto ptr = OS.pango_layout_get_text(layout); auto byteOffset = offset;//OS.g_utf8_offset_to_pointer(ptr, offset) - ptr; - int slen = strlen(ptr); + int slen = OS.strlen(ptr); byteOffset = Math.min(byteOffset, slen); do { auto runPtr = OS.pango_layout_iter_get_run(iter); @@ -1188,7 +1188,7 @@ int line = 0; auto ptr = OS.pango_layout_get_text(layout); auto byteOffset = offset;//OS.g_utf8_offset_to_pointer(ptr,offset) - ptr; - int slen = strlen(ptr); + int slen = OS.strlen(ptr); byteOffset = Math.min(byteOffset, slen); auto iter = OS.pango_layout_get_iter(layout); if (iter is null) SWT.error(SWT.ERROR_NO_HANDLES);
--- a/org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/internal/Lock.d Fri Mar 27 11:10:45 2009 +0100 +++ b/org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/internal/Lock.d Fri Mar 27 11:43:53 2009 +0100 @@ -74,7 +74,7 @@ public void unlock() { version(Tango){ synchronized (mutex) { - Thread current = Thread.getThis(); + Thread current = Thread.currentThread(); if (owner is current) { if (--count is 0) { owner = null;
--- a/org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/widgets/Control.d Fri Mar 27 11:10:45 2009 +0100 +++ b/org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/widgets/Control.d Fri Mar 27 11:43:53 2009 +0100 @@ -56,7 +56,7 @@ import org.eclipse.swt.widgets.Widget; import org.eclipse.swt.accessibility.Accessible; -import tango.core.Thread; +import java.lang.Thread; /** @@ -2037,7 +2037,7 @@ if (eventPtr !is null) { break; } else { - try {Thread.sleep(0.050);} catch (Exception ex) {} + try {Thread.sleep(50);} catch (Exception ex) {} } } switch (cast(int)OS.GDK_EVENT_TYPE (eventPtr)) {
--- a/org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/widgets/Display.d Fri Mar 27 11:10:45 2009 +0100 +++ b/org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/widgets/Display.d Fri Mar 27 11:43:53 2009 +0100 @@ -46,7 +46,7 @@ import tango.stdc.string; import java.lang.all; -import tango.core.Thread; +import java.lang.Thread; /** * Instances of this class are responsible for managing the @@ -763,7 +763,7 @@ protected override void checkDevice () { if (thread is null) error (SWT.ERROR_WIDGET_DISPOSED); - if (thread !is Thread.getThis ()) error (SWT.ERROR_THREAD_INVALID_ACCESS); + if (thread !is Thread.currentThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS); if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED); } @@ -907,7 +907,7 @@ */ protected override void create (DeviceData data) { checkSubclass (); - checkDisplay(thread = Thread.getThis (), false); + checkDisplay(thread = Thread.currentThread (), false); createDisplay (data); register (this); if (Default is null) Default = this; @@ -1422,7 +1422,7 @@ * @return the current display */ public static Display getCurrent () { - return findDisplay (Thread.getThis ()); + return findDisplay (Thread.currentThread ()); } int getCaretBlinkTime () { @@ -2616,7 +2616,7 @@ } bool isValidThread () { - return thread is Thread.getThis (); + return thread is Thread.currentThread (); } /** @@ -4153,7 +4153,7 @@ public void wake () { synchronized (Device.classinfo) { if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED); - if (thread is Thread.getThis ()) return; + if (thread is Thread.currentThread ()) return; wakeThread (); } }
--- a/org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/widgets/RunnableLock.d Fri Mar 27 11:10:45 2009 +0100 +++ b/org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/widgets/RunnableLock.d Fri Mar 27 11:43:53 2009 +0100 @@ -14,7 +14,7 @@ import java.lang.all; -import tango.core.Thread; +import java.lang.Thread; import tango.core.Exception; import tango.core.sync.Condition; import tango.core.sync.Mutex;
--- a/org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/widgets/Synchronizer.d Fri Mar 27 11:10:45 2009 +0100 +++ b/org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/widgets/Synchronizer.d Fri Mar 27 11:43:53 2009 +0100 @@ -18,7 +18,7 @@ import java.lang.all; import org.eclipse.swt.SWT; -import tango.core.Thread; +import java.lang.Thread; import org.eclipse.swt.graphics.Device; import tango.core.Exception; @@ -172,7 +172,7 @@ /* * Only remember the syncThread for syncExec. */ - lock.thread = Thread.getThis(); + lock.thread = Thread.currentThread(); addLast (lock); } }
--- a/org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/widgets/Tracker.d Fri Mar 27 11:10:45 2009 +0100 +++ b/org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/widgets/Tracker.d Fri Mar 27 11:43:53 2009 +0100 @@ -31,7 +31,7 @@ import org.eclipse.swt.widgets.Event; import tango.core.Exception; -import tango.core.Thread; +import java.lang.Thread; /** * Instances of this class implement rubber banding rectangles that are @@ -730,7 +730,7 @@ if (eventPtr !is null) { break; } else { - try { Thread.sleep(0.050); } catch (Exception ex) {} + try { Thread.sleep(50); } catch (Exception ex) {} } } gdkEvent = eventPtr;
--- a/org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/widgets/Widget.d Fri Mar 27 11:10:45 2009 +0100 +++ b/org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/widgets/Widget.d Fri Mar 27 11:43:53 2009 +0100 @@ -26,7 +26,7 @@ import org.eclipse.swt.widgets.TypedListener; import tango.stdc.string; -import tango.core.Thread; +import java.lang.Thread; /** @@ -468,7 +468,7 @@ public void checkWidget () { Display display = this.display; if (display is null) error (SWT.ERROR_WIDGET_DISPOSED); - if (display.thread !is Thread.getThis ()) error (SWT.ERROR_THREAD_INVALID_ACCESS); + if (display.thread !is Thread.currentThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS); if ((state & DISPOSED) !is 0) error (SWT.ERROR_WIDGET_DISPOSED); }
--- a/rakefile Fri Mar 27 11:10:45 2009 +0100 +++ b/rakefile Fri Mar 27 11:43:53 2009 +0100 @@ -24,12 +24,11 @@ ########################################################################## # Constants # -DMD = "dmd" -OBJDIR = File.expand_path("obj") -DIMPDIR = File.expand_path("imp") -LIBDIR = File.expand_path("lib") +DIR_OBJ = File.expand_path("obj") +DIR_IMP = File.expand_path("imp") +DIR_LIB = File.expand_path("lib") BINDIR = File.expand_path("bin") -RSPNAME = File.expand_path("rsp") +FILE_RSP = File.expand_path("rsp") ALL_RESDIRS = [ "base/res", "res" ] LOG_STDOUT = File.expand_path("olog.txt") @@ -38,16 +37,19 @@ if isWindows BASEDIR_SWT = "org.eclipse.swt.win32.win32.x86" - LIBEXT = ".lib" - OBJEXT = ".obj" - EXEEXT = ".exe" - MAPEXT = ".map" + LIBEXT = ".lib" + OBJEXT = ".obj" + EXEEXT = ".exe" + MAPEXT = ".map" + PROG_LIB = "lib.exe" else BASEDIR_SWT = "org.eclipse.swt.gtk.linux.x86" - LIBEXT = ".a" - OBJEXT = ".o" - EXEEXT = "" + LIBEXT = ".a" + OBJEXT = ".o" + EXEEXT = "" + PROG_LIB = "ar" end +PROG_DMD = "dmd#{EXEEXT}" ALL_RESDIRS << File.join(BASEDIR_SWT, "res" ) @@ -99,14 +101,14 @@ resdir_abs = File.expand_path( File.join( basedir, resdir )) srcdir_abs = File.expand_path( File.join( basedir, srcdir )) - FileUtils.mkdir_p DIMPDIR - FileUtils.mkdir_p OBJDIR + FileUtils.mkdir_p DIR_IMP + FileUtils.mkdir_p DIR_OBJ - rsp = File.new( RSPNAME, "w+" ) + rsp = File.new( FILE_RSP, "w+" ) rsp.puts "-H" - #rsp.puts "-Hd#{DIMPDIR.to_path}" + #rsp.puts "-Hd#{DIR_IMP.to_path}" rsp.puts "-I#{srcdir_abs.to_path}" - rsp.puts "-I#{DIMPDIR.to_path}" + rsp.puts "-I#{DIR_IMP.to_path}" rsp.puts "-J#{resdir_abs.to_path}" if dcargs != nil rsp.puts dcargs @@ -125,9 +127,9 @@ Dir.chdir(srcdir_abs) do if isWindows - cmd = "#{DMD} @#{RSPNAME.to_path}" + cmd = "#{PROG_DMD} @#{FILE_RSP.to_path}" else - cmd = "cat #{RSPNAME.to_path} | xargs #{DMD}" + cmd = "cat #{FILE_RSP.to_path} | xargs #{PROG_DMD}" end sh cmd, :verbose => false do |ok, res| if !ok then @@ -144,7 +146,7 @@ Find.find( srcdir_abs ) do |path| if FileTest.file?(path) && path =~ /\.di$/ then - trgfile = File.join( DIMPDIR, path[ srcdir_abs.length+1 .. -1 ]) + trgfile = File.join( DIR_IMP, path[ srcdir_abs.length+1 .. -1 ]) FileUtils.mkdir_p File.dirname(trgfile) FileUtils.mv path, trgfile end @@ -155,8 +157,8 @@ Find.find( srcdir_abs ) do |path| if FileTest.file?(path) && path =~ /\.o(bj)?$/ then trgfile = split_all( path )[ srcdirparts .. -1 ].join( "-" ) - FileUtils.mv path, File.join( OBJDIR, trgfile ) - libobjs << File.join( OBJDIR, trgfile ) + FileUtils.mv path, File.join( DIR_OBJ, trgfile ) + libobjs << File.join( DIR_OBJ, trgfile ) end end @@ -164,14 +166,24 @@ end def createLib( libobjs, name ) - FileUtils.mkdir_p LIBDIR.to_path - rsp = File.new( RSPNAME, "w+" ) - rsp.puts "-p512 -n -c #{LIBDIR}/#{name}#{LIBEXT}" - libobjs.each do |obj| - rsp.puts obj.to_path + FileUtils.mkdir_p DIR_LIB.to_path + rsp = File.new( FILE_RSP, "w+" ) + if isWindows + rsp.puts "-p512" + rsp.puts "-n" + rsp.puts "-c #{DIR_LIB}/#{name}#{LIBEXT}" + libobjs.each do |obj| + rsp.puts obj.to_path + end + else + rsp.puts "-r" + rsp.puts "-c #{DIR_LIB}/#{name}#{LIBEXT}" + libobjs.each do |obj| + rsp.puts obj.to_path + end end rsp.close - cmd = "lib @#{RSPNAME} > #{LOG_STDOUT}" + cmd = "#{PROG_LIB} @#{FILE_RSP} > #{LOG_STDOUT}" sh cmd, :verbose => false do |ok, res| if !ok then raise "librarian error" @@ -189,9 +201,9 @@ srcdir_abs = File.expand_path( File.join( basedir, srcdir)) resdir_abs = File.expand_path( File.join( basedir, resdir)) - rsp = File.new( RSPNAME, "w+" ) + rsp = File.new( FILE_RSP, "w+" ) rsp.puts "-I#{srcdir_abs.to_path}" - rsp.puts "-I#{DIMPDIR.to_path}" + rsp.puts "-I#{DIR_IMP.to_path}" rsp.puts "-J#{resdir_abs.to_path}" if dflags.size > 0 then rsp.puts dflags @@ -206,10 +218,10 @@ end rsp.puts "-L+dwt-base.lib" rsp.puts "-L+#{BASEDIR_SWT}.lib" - rsp.puts "-L+#{LIBDIR.to_path}\\" + rsp.puts "-L+#{DIR_LIB.to_path}\\" rsp.puts "-op" - rsp.puts "-od#{OBJDIR.to_path}" + rsp.puts "-od#{DIR_OBJ.to_path}" applfile = File.join(BINDIR,appname+EXEEXT) rsp.puts "-of#{applfile.to_path}" filelist.each do |path| @@ -219,9 +231,9 @@ Dir.chdir(srcdir_abs) do if isWindows - cmd = "#{DMD} @#{RSPNAME.to_path}" + cmd = "#{PROG_DMD} @#{FILE_RSP.to_path}" else - cmd = "cat #{RSPNAME.to_path} | xargs #{DMD}" + cmd = "cat #{FILE_RSP.to_path} | xargs #{PROG_DMD}" end sh cmd, :verbose => false do |ok, res| if !ok then @@ -240,10 +252,10 @@ desc "Clean" task :clean do puts "Cleaning" - FileUtils.rm_rf DIMPDIR - FileUtils.rm_rf OBJDIR - FileUtils.rm_rf LIBDIR - FileUtils.rm RSPNAME, :force => true + FileUtils.rm_rf DIR_IMP + FileUtils.rm_rf DIR_OBJ + FileUtils.rm_rf DIR_LIB + FileUtils.rm FILE_RSP, :force => true FileUtils.rm LOG_STDOUT, :force => true FileUtils.rm LOG_STDERR, :force => true end