changeset 104:62a654ba5276

optimation of static ctors
author Frank Benoit <benoit@tionex.de>
date Fri, 18 Jan 2008 19:13:47 +0100
parents 0179b2e17eb2
children 34e9dc2642d5
files dsss.conf dwt/DWT.d dwt/accessibility/AccessibleFactory.d dwt/accessibility/AccessibleObject.d dwt/dwthelper/File.d dwt/graphics/Device.d dwt/graphics/ImageData.d dwt/internal/Library.d dwt/internal/Platform.d dwt/internal/gtk/OS.d dwt/internal/image/JPEGFileFormat.d dwt/internal/image/PngChunk.d dwt/widgets/Display.d dwtexamples/helloworld.d
diffstat 14 files changed, 145 insertions(+), 131 deletions(-) [+]
line wrap: on
line diff
--- a/dsss.conf	Fri Jan 18 17:00:39 2008 +0100
+++ b/dsss.conf	Fri Jan 18 19:13:47 2008 +0100
@@ -1,8 +1,7 @@
 [dwt]
 type=library
 
-[dwtexamples/helloworld.d]
-
+[*]
 buildflags+=-L-lgtk-x11-2.0
 buildflags+=-L-lgdk-x11-2.0
 buildflags+=-L-latk-1.0
@@ -31,4 +30,6 @@
 buildflags+=-I/home/frank/jive
 buildflags+=-g -gc
 
-
+[dwtexamples/helloworld.d]
+[dwtexamples/helloworld/HelloWorld1.d]
+[t.d]
--- a/dwt/DWT.d	Fri Jan 18 17:00:39 2008 +0100
+++ b/dwt/DWT.d	Fri Jan 18 19:13:47 2008 +0100
@@ -23,6 +23,8 @@
 
 import tango.core.Exception;
 
+//version=CARBON;
+
 /**
  * This class provides access to a small number of DWT system-wide
  * methods, and in addition defines the public constants provided
@@ -1748,7 +1750,7 @@
      *
      * @since 2.1
      */
-    public static /*const*/ int MODIFIER_MASK;
+    public static const int MODIFIER_MASK = ALT | SHIFT | CTRL | COMMAND;
 
     /**
      * Keyboard and/or mouse event mask indicating that mouse button one
@@ -1798,7 +1800,7 @@
      *
      * @since 2.1
      */
-    public static /*const*/ int BUTTON_MASK;
+    public static const int BUTTON_MASK = BUTTON1 | BUTTON2 | BUTTON3 | BUTTON4 | BUTTON5;
 
     /**
      * Keyboard and/or mouse event mask indicating that the MOD1 key
@@ -1808,7 +1810,12 @@
      *
      * @since 2.1
      */
-    public static /*const*/ int MOD1;
+    version(CARBON){
+        public static const int MOD1 = COMMAND;
+    }
+    else{
+        public static const int MOD1 = CONTROL;
+    }
 
     /**
      * Keyboard and/or mouse event mask indicating that the MOD2 key
@@ -1818,7 +1825,12 @@
      *
      * @since 2.1
      */
-    public static /*const*/ int MOD2;
+    version(CARBON){
+        public static const int MOD2 = SHIFT;
+    }
+    else{
+        public static const int MOD2 = SHIFT;
+    }
 
     /**
      * Keyboard and/or mouse event mask indicating that the MOD3 key
@@ -1826,7 +1838,12 @@
      *
      * @since 2.1
      */
-    public static /*const*/ int MOD3;
+    version(CARBON){
+        public static const int MOD3 = ALT;
+    }
+    else{
+        public static const int MOD3 = ALT;
+    }
 
     /**
      * Keyboard and/or mouse event mask indicating that the MOD4 key
@@ -1834,7 +1851,12 @@
      *
      * @since 2.1
      */
-    public static /*const*/ int MOD4;
+    version(CARBON){
+        public static const int MOD4 = CONTROL;
+    }
+    else{
+        public static const int MOD4 = 0;
+    }
 
     /**
      * Constants to indicate line scrolling (value is 1).
@@ -3613,32 +3635,4 @@
     throw error;
 }
 
-public static void static_this() {
-    /*
-    * These values represent bit masks that may need to
-    * expand in the future.  Therefore they are not initialized
-    * in the declaration to stop the compiler from inlining.
-    */
-    BUTTON_MASK = BUTTON1 | BUTTON2 | BUTTON3 | BUTTON4 | BUTTON5;
-    MODIFIER_MASK = ALT | SHIFT | CTRL | COMMAND;
-
-    /*
-    * These values can be different on different platforms.
-    * Therefore they are not initialized in the declaration
-    * to stop the compiler from inlining.
-    */
-    char[] platform = getPlatform ();
-    if ("carbon" == platform ) { //$NON-NLS-1$
-        MOD1 = COMMAND;
-        MOD2 = SHIFT;
-        MOD3 = ALT;
-        MOD4 = CONTROL;
-    } else {
-        MOD1 = CONTROL;
-        MOD2 = SHIFT;
-        MOD3 = ALT;
-        MOD4 = 0;
-    }
 }
-
-}
--- a/dwt/accessibility/AccessibleFactory.d	Fri Jan 18 17:00:39 2008 +0100
+++ b/dwt/accessibility/AccessibleFactory.d	Fri Jan 18 19:13:47 2008 +0100
@@ -57,30 +57,41 @@
 
     /* AT callbacks*/
     /* interface definitions */
-    static GTypeInfo* ObjectIfaceDefinition;
-    static GInterfaceInfo* ActionIfaceDefinition;
-    static GInterfaceInfo* ComponentIfaceDefinition;
-    static GInterfaceInfo* HypertextIfaceDefinition;
-    static GInterfaceInfo* SelectionIfaceDefinition;
-    static GInterfaceInfo* TextIfaceDefinition;
+    private static GTypeInfo* ObjectIfaceDefinition;
+    private static GInterfaceInfo* ActionIfaceDefinition;
+    private static GInterfaceInfo* ComponentIfaceDefinition;
+    private static GInterfaceInfo* HypertextIfaceDefinition;
+    private static GInterfaceInfo* SelectionIfaceDefinition;
+    private static GInterfaceInfo* TextIfaceDefinition;
 
-    static synchronized void static_this(){
+    private static synchronized void static_this(){
+        AccessibleObject.static_this();
+        /* Action interface */
+        if( ActionIfaceDefinition is null ){
             DefaultParentType = OS.g_type_from_name ("GtkAccessible"); //$NON-NLS-1$
-            /* Action interface */
             ActionIfaceDefinition = cast(GInterfaceInfo*)OS.g_malloc (GInterfaceInfo.sizeof);
             ActionIfaceDefinition.interface_init = &AccessibleFactory.initActionIfaceCB;
-            /* Component interface */
+        }
+        /* Component interface */
+        if( ComponentIfaceDefinition is null ){
             ComponentIfaceDefinition = cast(GInterfaceInfo*)OS.g_malloc (GInterfaceInfo.sizeof);
             ComponentIfaceDefinition.interface_init = &AccessibleFactory.initComponentIfaceCB;
-            /* Hypertext interface */
+        }
+        /* Hypertext interface */
+        if( HypertextIfaceDefinition is null ){
             HypertextIfaceDefinition = cast(GInterfaceInfo*)OS.g_malloc (GInterfaceInfo.sizeof);
             HypertextIfaceDefinition.interface_init = &AccessibleFactory.initHypertextIfaceCB;
-            /* Selection interface */
+        }
+        /* Selection interface */
+        if( SelectionIfaceDefinition is null ){
             SelectionIfaceDefinition = cast(GInterfaceInfo*)OS.g_malloc (GInterfaceInfo.sizeof);
             SelectionIfaceDefinition.interface_init = &AccessibleFactory.initSelectionIfaceCB;
-            /* Text interface */
+        }
+        /* Text interface */
+        if( TextIfaceDefinition is null ){
             TextIfaceDefinition =cast(GInterfaceInfo*) OS.g_malloc (GInterfaceInfo.sizeof);
             TextIfaceDefinition.interface_init = &AccessibleFactory.initTextIfaceCB;
+        }
     }
 
     private this (int /*long*/ widgetType) {
@@ -276,6 +287,7 @@
     }
 
     static void registerAccessible (Accessible accessible) {
+        static_this();
         /* If DefaultParentType is 0 then OS accessibility is not active */
         if (DefaultParentType is 0) return;
         auto controlHandle = accessible.getControlHandle ();
--- a/dwt/accessibility/AccessibleObject.d	Fri Jan 18 17:00:39 2008 +0100
+++ b/dwt/accessibility/AccessibleObject.d	Fri Jan 18 19:13:47 2008 +0100
@@ -54,14 +54,17 @@
     static /*const*/ uint ATK_SELECTION_TYPE;
     static /*const*/ uint ATK_TEXT_TYPE;
     static /*const*/ bool DEBUG;
+    static bool static_this_completed = false;
 
-    public static void static_this() {
+    package static void static_this() {
+        if( static_this_completed ) return;
         DEBUG = Display.DEBUG;
         ATK_ACTION_TYPE = ATK.g_type_from_name ("AtkAction");
         ATK_COMPONENT_TYPE = ATK.g_type_from_name ("AtkComponent");
         ATK_HYPERTEXT_TYPE = ATK.g_type_from_name ("AtkHypertext");
         ATK_SELECTION_TYPE = ATK.g_type_from_name ("AtkSelection");
         ATK_TEXT_TYPE = ATK.g_type_from_name ("AtkText");
+        static_this_completed = true;
     }
 
     this (int /*long*/ type, GtkWidget* widget, Accessible accessible, int /*long*/ parentType, bool isLightweight) {
--- a/dwt/dwthelper/File.d	Fri Jan 18 17:00:39 2008 +0100
+++ b/dwt/dwthelper/File.d	Fri Jan 18 19:13:47 2008 +0100
@@ -18,6 +18,13 @@
 
     private tango.io.FilePath.FilePath mFilePath;
 
+    static this(){
+        separator = tango.io.FileConst.FileConst.PathSeparatorString;
+        separatorChar = tango.io.FileConst.FileConst.PathSeparatorChar;
+        pathSeparator = tango.io.FileConst.FileConst.SystemPathString;
+        pathSeparatorChar = tango.io.FileConst.FileConst.SystemPathChar;
+    }
+
     public this ( char[] pathname ){
         mFilePath = new tango.io.FilePath.FilePath( pathname );
     }
@@ -189,13 +196,6 @@
         return null;
     }
 
-    public static void static_this(){
-        separator = tango.io.FileConst.FileConst.PathSeparatorString;
-        separatorChar = tango.io.FileConst.FileConst.PathSeparatorChar;
-        pathSeparator = tango.io.FileConst.FileConst.SystemPathString;
-        pathSeparatorChar = tango.io.FileConst.FileConst.SystemPathChar;
-    }
-
 
 }
 
--- a/dwt/graphics/Device.d	Fri Jan 18 17:00:39 2008 +0100
+++ b/dwt/graphics/Device.d	Fri Jan 18 19:13:47 2008 +0100
@@ -98,7 +98,7 @@
 
     static bool CAIRO_LOADED;
 
-    static Object CREATE_LOCK;
+//    static Object CREATE_LOCK;
 
     /*
     * TEMPORARY CODE. When a graphics object is
@@ -115,10 +115,10 @@
     protected static Device CurrentDevice;
     protected static Runnable DeviceFinder;
 
-synchronized static void static_this(){
-    CREATE_LOCK = new Object();
-    Devices = new Device[4];
-}
+//synchronized static void static_this(){
+//    CREATE_LOCK = new Object();
+//    Devices = new Device[4];
+//}
 /*
 * TEMPORARY CODE.
 */
@@ -156,12 +156,13 @@
  * @see #init
  * @see DeviceData
  */
+
 public this(DeviceData data) {
     handler_ids = new int [log_domains.length];
     debugging = DEBUG;
     tracking = DEBUG;
 
-    synchronized (CREATE_LOCK) {
+    synchronized ( this.classinfo ) {
         if (data !is null) {
             debugging = data.debugging;
             tracking = data.tracking;
@@ -558,7 +559,7 @@
     if (debugging) {
         if (xDisplay !is null) {
             /* Create the warning and error callbacks */
-            synchronized (CREATE_LOCK) {
+            synchronized (this.classinfo) {
                 int index = 0;
                 while (index < Devices.length) {
                     if (Devices [index] !is null) break;
--- a/dwt/graphics/ImageData.d	Fri Jan 18 17:00:39 2008 +0100
+++ b/dwt/graphics/ImageData.d	Fri Jan 18 19:13:47 2008 +0100
@@ -217,9 +217,14 @@
     /**
      * Arbitrary channel width data to 8-bit conversion table.
      */
-    static byte[][] ANY_TO_EIGHT;
+    private static byte[][] ANY_TO_EIGHT;
+    private static byte[] ONE_TO_ONE_MAPPING;
 
-    synchronized static void static_this() {
+    private static bool static_this_completed = false;
+    private static void static_this() {
+        if( static_this_completed ) return;
+        synchronized {
+            if( static_this_completed ) return;
             ANY_TO_EIGHT = new byte[][](9);
             for (int b = 0; b < 9; ++b) {
                 byte[] data = ANY_TO_EIGHT[b] = new byte[1 << b];
@@ -229,8 +234,9 @@
                 for (int v = 0, p = 0; v < 0x10000; v+= inc) data[p++] = cast(byte)(v >> 8);
             }
             ONE_TO_ONE_MAPPING = ANY_TO_EIGHT[8];
+            static_this_completed = true;
+        }
     }
-    static byte[] ONE_TO_ONE_MAPPING;
 
     /**
      * Scaled 8x8 Bayer dither matrix.
@@ -1772,6 +1778,9 @@
     int destX, int destY, int destWidth, int destHeight,
     int destRedMask, int destGreenMask, int destBlueMask,
     bool flipX, bool flipY) {
+
+    static_this();
+
     if ((destWidth <= 0) || (destHeight <= 0) || (alphaMode == ALPHA_TRANSPARENT)) return;
 
     // these should be supplied as params later
@@ -2202,6 +2211,9 @@
     int destX, int destY, int destWidth, int destHeight,
     byte[] destReds, byte[] destGreens, byte[] destBlues,
     bool flipX, bool flipY) {
+
+    static_this();
+
     if ((destWidth <= 0) || (destHeight <= 0) || (alphaMode == ALPHA_TRANSPARENT)) return;
 
     /*** Prepare scaling data ***/
@@ -2737,6 +2749,9 @@
     int destX, int destY, int destWidth, int destHeight,
     int destRedMask, int destGreenMask, int destBlueMask,
     bool flipX, bool flipY) {
+
+    static_this();
+
     if ((destWidth <= 0) || (destHeight <= 0) || (alphaMode == ALPHA_TRANSPARENT)) return;
 
     // these should be supplied as params later
@@ -3079,6 +3094,9 @@
     int destX, int destY, int destWidth, int destHeight,
     byte[] destReds, byte[] destGreens, byte[] destBlues,
     bool flipX, bool flipY) {
+
+    static_this();
+
     if ((destWidth <= 0) || (destHeight <= 0) || (alphaMode == ALPHA_TRANSPARENT)) return;
 
     // these should be supplied as params later
@@ -3427,6 +3445,7 @@
  * Extracts a field from packed RGB data given a mask for that field.
  */
 static byte getChannelField(int data, int mask) {
+    static_this();
     int shift = getChannelShift(mask);
     return ANY_TO_EIGHT[getChannelWidth(mask, shift)][(data & mask) >>> shift];
 }
--- a/dwt/internal/Library.d	Fri Jan 18 17:00:39 2008 +0100
+++ b/dwt/internal/Library.d	Fri Jan 18 19:13:47 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
  * Copyright (c) 2000, 2007 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
@@ -12,6 +12,13 @@
 
 import tango.util.Convert;
 
+// do it here, so it can be evaluated at compile time
+// this saves a static ctor.
+private int buildSWT_VERSION (int major, int minor) {
+    return major * 1000 + minor;
+}
+
+
 public class Library {
 
     /* DWT Version - Mmmm (M=major, mmm=minor) */
@@ -35,7 +42,7 @@
      * The JAVA and DWT versions
      */
     //public static const int JAVA_VERSION;
-    public static /*const*/ int SWT_VERSION;
+    public static const int SWT_VERSION = .buildSWT_VERSION(MAJOR_VERSION, MINOR_VERSION);
 
     version( linux ){
         static const char[] SEPARATOR = "\n";
@@ -45,12 +52,6 @@
     }
 
 
-public static void static_this() {
-    //SEPARATOR = System.getProperty("file.separator");
-    //JAVA_VERSION = parseVersion(System.getProperty("java.version"));
-    SWT_VERSION = buildSWT_VERSION(MAJOR_VERSION, MINOR_VERSION);
-}
-
 static int parseVersion(char[] aVersion) {
     if (aVersion == null) return 0;
     int major = 0, minor = 0, micro = 0;
@@ -95,7 +96,7 @@
  * @return the version
  */
 public static int buildSWT_VERSION (int major, int minor) {
-    return major * 1000 + minor;
+    return .buildSWT_VERSION(major, minor);
 }
 /+ PORTING_LEFT
 static bool extract (char[] fileName, char[] mappedName) {
--- a/dwt/internal/Platform.d	Fri Jan 18 17:00:39 2008 +0100
+++ b/dwt/internal/Platform.d	Fri Jan 18 19:13:47 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
  * Copyright (c) 2000, 2007 IBM Corporation and others. All rights reserved.
  * The contents of this file are made available under the terms
  * of the GNU Lesser General Public License (LGPL) Version 2.1 that
@@ -18,8 +18,8 @@
 
 public class Platform {
     public static const char[] PLATFORM = "gtk"; //$NON-NLS-1$
-    public static /*const*/ Lock lock;
-    public static void static_this() {
+    public static const Lock lock;
+    static this() {
         lock = new Lock();
     }
 }
--- a/dwt/internal/gtk/OS.d	Fri Jan 18 17:00:39 2008 +0100
+++ b/dwt/internal/gtk/OS.d	Fri Jan 18 19:13:47 2008 +0100
@@ -620,23 +620,21 @@
 +/
 //import dwt.internal.*;
 
+// for ctfe, save static ctor
+private int buildVERSION(int major, int minor, int micro) {
+    return (major << 16) + (minor << 8) + micro;
+}
+private int GTK_VERSION(){
+    return buildVERSION(gtk_major_version, gtk_minor_version, gtk_micro_version);
+}
+
 public class OS : Platform {
 
     /** OS Constants */
-    public static /*const*/ bool IsAIX, IsSunOS, IsLinux, IsHPUX;
-    public static void static_this() {
-        /* Initialize the OS flags and locale constants */
-        char[] osName = "Linux";//System.getProperty ("os.name");
-        bool isAIX = false, isSunOS = false, isLinux = false, isHPUX = false;
-        if (osName == "Linux") isLinux = true;
-        if (osName == "AIX") isAIX = true;
-        if (osName == "Solaris") isSunOS = true;
-        if (osName == "SunOS") isSunOS = true;
-        if (osName == "HP-UX") isHPUX = true;
-        IsAIX = isAIX;  IsSunOS = isSunOS;  IsLinux = isLinux;  IsHPUX = isHPUX;
-        //PORTING_LEFT
-        GTK_VERSION = buildVERSION(gtk_major_version(), gtk_minor_version(), gtk_micro_version());
-    }
+    public static const bool IsAIX   = false;
+    public static const bool IsSunOS = false;
+    public static const bool IsLinux = true;
+    public static const bool IsHPUX  = false;
 
     /** Constants */
     public static const int ATK_RELATION_LABELLED_BY = 4;
@@ -1082,11 +1080,14 @@
     public static const char[] ypad = "ypad";
     public static const char[] GTK_PRINT_SETTINGS_OUTPUT_URI = "output-uri";
 
-    public static /*const*/ int GTK_VERSION;// see static ctor = buildVERSION(gtk_major_version(), gtk_minor_version(), gtk_micro_version());
+    public static int GTK_VERSION(){
+        return .GTK_VERSION();
+    }
+//     = buildVERSION(gtk_major_version(), gtk_minor_version(), gtk_micro_version());
 
 
 public static int buildVERSION(int major, int minor, int micro) {
-    return (major << 16) + (minor << 8) + micro;
+    return .buildVERSION( major, minor, micro );
 }
 
 /++
--- a/dwt/internal/image/JPEGFileFormat.d	Fri Jan 18 17:00:39 2008 +0100
+++ b/dwt/internal/image/JPEGFileFormat.d	Fri Jan 18 19:13:47 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
  * Copyright (c) 2000, 2006 IBM Corporation and others.
  * All rights reserved.  This source file is made available under the terms contained in the README file
  * accompanying this program.  The README file should be located in the about_files directory of the
@@ -147,7 +147,8 @@
     public static int[] CrRTable, CbBTable, CrGTable, CbGTable;
     public static int[] RYTable, GYTable, BYTable,
         RCbTable, GCbTable, BCbTable, RCrTable, GCrTable, BCrTable, NBitsTable;
-    public static void static_this() {
+    //public static void static_this() {
+    static this() {
         initialize();
         RGB16 = [
             new RGB(0,0,0),
--- a/dwt/internal/image/PngChunk.d	Fri Jan 18 17:00:39 2008 +0100
+++ b/dwt/internal/image/PngChunk.d	Fri Jan 18 19:13:47 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
  * Copyright (c) 2000, 2006 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
@@ -49,8 +49,9 @@
     static const byte[] TYPE_IEND = cast(byte[])"IEND";//{(byte) 'I', (byte) 'E', (byte) 'N', (byte) 'D'};
     static const byte[] TYPE_tRNS = cast(byte[])"tRNS";//{(byte) 't', (byte) 'R', (byte) 'N', (byte) 'S'};
 
-    static /*const*/ int[] CRC_TABLE;
-    public static void static_this() {
+    static const int[] CRC_TABLE;
+    //public static void static_this() {
+    static this() {
         CRC_TABLE = new int[256];
         for (int i = 0; i < 256; i++) {
             CRC_TABLE[i] = i;
--- a/dwt/widgets/Display.d	Fri Jan 18 17:00:39 2008 +0100
+++ b/dwt/widgets/Display.d	Fri Jan 18 19:13:47 2008 +0100
@@ -395,7 +395,8 @@
     * it does not compile on some Java compilers when they are
     * targeted for CLDC.  Use Class.forName() instead.
     */
-    synchronized static void static_this() {
+    //synchronized static void static_this() {
+    static this() {
             Displays = new Display [4];
             initDeviceFinder();
             SWT_OBJECT_INDEX = OS.g_quark_from_string ("SWT_OBJECT_INDEX");
--- a/dwtexamples/helloworld.d	Fri Jan 18 17:00:39 2008 +0100
+++ b/dwtexamples/helloworld.d	Fri Jan 18 19:13:47 2008 +0100
@@ -1,6 +1,6 @@
 module helloworld;
 
-import dwt.SWT;
+import dwt.DWT;
 import dwt.widgets.Display;
 import dwt.widgets.Shell;
 import dwt.widgets.Composite;
@@ -12,22 +12,12 @@
 import tango.text.convert.Format;
 import tango.util.Convert;
 import tango.util.PathUtil;
-import dwt.graphics.Device;
-import dwt.graphics.ImageData;
 import dwt.events.SelectionListener;
 import dwt.events.SelectionEvent;
 
 
-import dwt.accessibility.AccessibleObject;
-import dwt.accessibility.AccessibleFactory;
-import dwt.SWT;
-import dwt.dwthelper.File;
+import dwt.DWT;
 import dwt.widgets.Display;
-import dwt.internal.Library;
-import dwt.internal.Platform;
-import dwt.internal.image.PngChunk;
-import dwt.internal.image.JPEGFileFormat;
-import dwt.internal.gtk.OS;
 
 import jive.stacktrace;
 
@@ -36,28 +26,19 @@
     TraceConfig.throwOnAll = true;
     try{
 
-        File.static_this();
-        Library.static_this();
-        Platform.static_this();
-        OS.static_this();
-        SWT.static_this();
-        AccessibleObject.static_this();
-        AccessibleFactory.static_this();
-        ImageData.static_this();
-        Device.static_this();
-        Display.static_this();
-        PngChunk.static_this();
-        JPEGFileFormat.static_this();
+        //Display.static_this();
+        //PngChunk.static_this();
+        //JPEGFileFormat.static_this();
 
         Display display = new Display();
         Shell shell = new Shell(display);
         shell.setSize(300, 200);
-        shell.setText("Simple SWT Sample");
-        auto btn = new Button( shell, SWT.PUSH );
+        shell.setText("Simple DWT Sample");
+        auto btn = new Button( shell, DWT.PUSH );
         btn.setBounds(40, 50, 100, 50);
         btn.setText( "hey" );
 
-        auto txt = new Text(shell, SWT.BORDER);
+        auto txt = new Text(shell, DWT.BORDER);
         txt.setBounds(170, 50, 100, 40);
 
         btn.addSelectionListener(new class () SelectionListener {
@@ -70,15 +51,13 @@
         });
 
         shell.open();
-        Stdout.formatln( "loop entered" );
         while (!shell.isDisposed()) {
             if (!display.readAndDispatch()) {
                 display.sleep();
             }
         }
     }
-    catch (Exception e)
-    {
+    catch (Exception e) {
         Stdout.formatln (e.toString);
     }
 }