2004/01/12 06:38:31
authormegacz <megacz@xwt.org>
Fri, 30 Jan 2004 07:44:12 +0000 (07:44 +0000)
committermegacz <megacz@xwt.org>
Fri, 30 Jan 2004 07:44:12 +0000 (07:44 +0000)
darcs-hash:20040130074412-2ba56-539fac2f39d245cd52a6d68562c0e06efecbe24a.gz

src/org/xwt/plat/GCJ.cc
src/org/xwt/plat/Win32.java
src/org/xwt/plat/X11.cc
src/org/xwt/plat/X11.java
src/org/xwt/util/BalancedTree.java
src/org/xwt/util/Log.java

index a70c952..b140c60 100644 (file)
@@ -118,7 +118,7 @@ void org::xwt::plat::GCJ::_decodeJPEG(java::io::InputStream* is, org::xwt::Pictu
         // FEATURE - we should handle errors better than this
         char msgbuf[JMSG_LENGTH_MAX];
         (jerr.pub.format_message)((j_common_ptr)&cinfo, msgbuf);
-        Log::log(&GCJ::class$,JvNewStringLatin1(msgbuf));
+        Log::info(&GCJ::class$,JvNewStringLatin1(msgbuf));
         jpeg_destroy_decompress(&cinfo);
         return;
     }
@@ -134,17 +134,17 @@ void org::xwt::plat::GCJ::_decodeJPEG(java::io::InputStream* is, org::xwt::Pictu
     
     p->width = cinfo.output_width;
     p->height = cinfo.output_height;
-    p->data = JvNewIntArray(width * height);
+    p->data = JvNewIntArray(p->width * p->height);
     
     while (cinfo.output_scanline < cinfo.output_height) {
-        JSAMPLE *dest = (JSAMPLE*) (elements(data) + cinfo.output_scanline * width);
+        JSAMPLE *dest = (JSAMPLE*) (elements(p->data) + cinfo.output_scanline * p->width);
         jpeg_read_scanlines(&cinfo,&dest,1);
     }
     jpeg_finish_decompress(&cinfo);
     jpeg_destroy_decompress(&cinfo);
     
-    for(int i=0;i<data->length;i++)
-        elements(data)[i] |= 0xff000000; // alpha channel
+    for(int i=0;i<p->data->length;i++)
+        elements(p->data)[i] |= 0xff000000; // alpha channel
 }
 
 // C++ new/delete operators (JvMalloc never fails)
index 938b6c2..0efdfa0 100644 (file)
@@ -268,7 +268,7 @@ public class Win32 extends GCJ {
             drawPicture(source, dx, dy, cx1, cy1, cx2, cy2, 0, false);
         }
         public void drawGlyph(org.xwt.Font.Glyph source, int dx, int dy, int cx1, int cy1, int cx2, int cy2, int rgb) {
-            Win32Picture p = ((Win32Picture)((DefaultGlyph)source).getPicture());
+            Win32Picture p = ((Win32Picture)((Platform.DefaultGlyph)source).getPicture());
             p.init();
             drawPicture(p, dx, dy, cx1, cy1, cx2, cy2, rgb, true);
         }
index ca45618..8012340 100644 (file)
@@ -725,12 +725,12 @@ void org::xwt::plat::X11::natInit() {
     visual = DefaultVisual(display, screen_num);
     char buf[255];
     sprintf(buf, "X11 DISPLAY: %s", XDisplayString(display));
-    org::xwt::util::Log::log(this->getClass(), JvNewStringLatin1(buf));
+    org::xwt::util::Log::info(this->getClass(), JvNewStringLatin1(buf));
     sprintf(buf, "X11 SHM:     %s", shm_supported ? "enabled" : "disabled");
-    org::xwt::util::Log::log(this->getClass(), JvNewStringLatin1(buf));
+    org::xwt::util::Log::info(this->getClass(), JvNewStringLatin1(buf));
     sprintf(buf, "X11 Visual:  %x %x %x bits: %i visualid: %i depth: %i",
             visual->red_mask, visual->green_mask, visual->blue_mask, visual->bits_per_rgb, visual->visualid, colorDepth);
-    org::xwt::util::Log::log(this->getClass(), JvNewStringLatin1(buf));
+    org::xwt::util::Log::info(this->getClass(), JvNewStringLatin1(buf));
 
     // FIXME: don't know why (True, False) is the best solution...
     if(XmuLookupStandardColormap(display, screen_num, visual->visualid, colorDepth, XA_RGB_BEST_MAP, True, False) == 0)
@@ -748,13 +748,13 @@ void org::xwt::plat::X11::natInit() {
     colormap_info = best_map_info;
 
     sprintf(buf, "            red_max / red_mult: %x %x", colormap_info->red_max, colormap_info->red_mult);
-    org::xwt::util::Log::log(this->getClass(), JvNewStringLatin1(buf));
+    org::xwt::util::Log::info(this->getClass(), JvNewStringLatin1(buf));
     sprintf(buf, "            green_max / green_mult: %x %x", colormap_info->green_max, colormap_info->green_mult);
-    org::xwt::util::Log::log(this->getClass(), JvNewStringLatin1(buf));
+    org::xwt::util::Log::info(this->getClass(), JvNewStringLatin1(buf));
     sprintf(buf, "            blue_max / blue_mult: %x %x", colormap_info->blue_max, colormap_info->blue_mult);
-    org::xwt::util::Log::log(this->getClass(), JvNewStringLatin1(buf));
+    org::xwt::util::Log::info(this->getClass(), JvNewStringLatin1(buf));
     sprintf(buf, "            base_pixel: %x", colormap_info->base_pixel);
-    org::xwt::util::Log::log(this->getClass(), JvNewStringLatin1(buf));
+    org::xwt::util::Log::info(this->getClass(), JvNewStringLatin1(buf));
 }
 
 
index 113512b..b51b1a6 100644 (file)
@@ -174,7 +174,7 @@ public class X11 extends POSIX {
            cx2 = Math.min(dx + source.width, cx2); 
            cy2 = Math.min(dy + source.height, cy2); 
            if (cx1 >= cx2 || cy1 >= cy2) return;
-            slowDrawPicture(((DefaultGlyph)source).getPicture(), dx, dy, cx1, cy1, cx2, cy2, rgb, true);
+            slowDrawPicture(((Platform.DefaultGlyph)source).getPicture(), dx, dy, cx1, cy1, cx2, cy2, rgb, true);
         }
         public void drawPicture(Picture source, int dx, int dy, int cx1, int cy1, int cx2, int cy2) {
            cx1 = Math.max(dx, cx1);
index 0775ebe..5e15b3e 100644 (file)
@@ -66,7 +66,7 @@ public class BalancedTree {
         int index = 0;
         while(true) {
             // everything to the left is before us so add that to the index
-            index += size(left[slot]);
+            index += sizeof(left[slot]);
             // we are before anything on the right
             while(left[parent[slot]] == slot) slot = parent[slot];
             // we end of the first node who isn't on the left, go to the node that has as its child
@@ -202,7 +202,7 @@ public class BalancedTree {
     private final int rightmost(int slot) { return right[slot] <= 0 ? slot : rightmost(right[slot]); }
     private final int next(int slot) { return right[slot] <= 0 ? -1 * right[slot] : leftmost(right[slot]); }
     private final int prev(int slot) { return left[slot] <= 0 ? -1 * left[slot] : rightmost(left[slot]); }
-    private final int size(int slot) { return slot <= 0 ? 0 : size[slot]; }
+    private final int sizeof(int slot) { return slot <= 0 ? 0 : size[slot]; }
     private final int root(int slot) { return parent[slot] == 0 ? slot : root(parent[slot]); }
 
 
@@ -234,15 +234,15 @@ public class BalancedTree {
         else if (left[p] == b)   left[p] = d;
         else if (right[p] == b)  right[p] = d;
         else throw new Error("rotate called with invalid parent");
-        size[b] = 1 + size(left[b]) + size(right[b]);
-        size[d] = 1 + size(left[d]) + size(right[d]);
+        size[b] = 1 + sizeof(left[b]) + sizeof(right[b]);
+        size[d] = 1 + sizeof(left[d]) + sizeof(right[d]);
     }
 
     private void balance(int slot, int p) {
         if (slot <= 0) return;
-        size[slot] = 1 + size(left[slot]) + size(right[slot]);
-        if (size(left[slot]) - 1 > 2 * size(right[slot])) rotate(false, slot, p);
-        else if (size(left[slot]) * 2 < size(right[slot]) - 1) rotate(true, slot, p);
+        size[slot] = 1 + sizeof(left[slot]) + sizeof(right[slot]);
+        if (sizeof(left[slot]) - 1 > 2 * sizeof(right[slot])) rotate(false, slot, p);
+        else if (sizeof(left[slot]) * 2 < sizeof(right[slot]) - 1) rotate(true, slot, p);
     }
 
 
@@ -250,10 +250,10 @@ public class BalancedTree {
     // Insert /////////////////////////////////////////////////////////////////////////
 
     private void insert(int index, int arg, int slot, int p, boolean replace, boolean wentLeft) {
-        int diff = slot <= 0 ? 0 : index - size(left[slot]);
+        int diff = slot <= 0 ? 0 : index - sizeof(left[slot]);
         if (slot > 0 && diff != 0) {
             if (diff < 0) insert(index, arg, left[slot], slot, replace, true);
-            else insert(index - size(left[slot]) - 1, arg, right[slot], slot, replace, false);
+            else insert(index - sizeof(left[slot]) - 1, arg, right[slot], slot, replace, false);
             balance(slot, p);
             return;
         }
@@ -310,7 +310,7 @@ public class BalancedTree {
     // Retrieval //////////////////////////////////////////////////////////////////////
 
     private int get(int index, int slot) {
-        int diff = index - size(left[slot]);
+        int diff = index - sizeof(left[slot]);
         if (diff > 0) return get(diff - 1, right[slot]);
         else if (diff < 0) return get(index, left[slot]);
         else return slot;
@@ -320,7 +320,7 @@ public class BalancedTree {
     // Deletion //////////////////////////////////////////////////////////////////////
 
     private int delete(int index, int slot, int p) {
-        int diff = index - size(left[slot]);
+        int diff = index - sizeof(left[slot]);
         if (diff < 0) {
             int ret = delete(index, left[slot], slot);
             balance(slot, p);
@@ -360,7 +360,7 @@ public class BalancedTree {
 
             // node to be deleted has two children, so we replace it with its left child's rightmost descendant
             } else {
-                int left_childs_rightmost = delete(size(left[slot]) - 1, left[slot], slot);
+                int left_childs_rightmost = delete(sizeof(left[slot]) - 1, left[slot], slot);
                 left[left_childs_rightmost] = left[slot];
                 right[left_childs_rightmost] = right[slot];
                 if(left[slot] > 0) parent[left[slot]] = left_childs_rightmost;
index 329382f..03c5a52 100644 (file)
@@ -49,7 +49,7 @@ public class Log {
     private static final int BROWN = 33;
     private static final int GRAY = 37;
     
-    private static String color(int color, boolean bright, String s) {
+    private static String colorize(int color, boolean bright, String s) {
         if (!Log.color) return s;
         return
             "\033[40;" + (bright?"1;":"") + color + "m" +
@@ -61,14 +61,14 @@ public class Log {
     private static synchronized void log(Object o, Object message, int level) {
         if (firstMessage && !logDates) {
             firstMessage = false;
-            System.err.println(color(GREEN, false, "==========================================================================="));
+            System.err.println(colorize(GREEN, false, "==========================================================================="));
             diag(Log.class, "Logging enabled at " + new java.util.Date());
             if (color) diag(Log.class, "logging messages in " +
-                color(BLUE, true, "c") +
-                color(RED, true, "o") +
-                color(CYAN, true, "l") +
-                color(GREEN, true, "o") +
-                color(PURPLE, true, "r"));
+                colorize(BLUE, true, "c") +
+                colorize(RED, true, "o") +
+                colorize(CYAN, true, "l") +
+                colorize(GREEN, true, "o") +
+                colorize(PURPLE, true, "r"));
         }
 
         String classname;
@@ -83,7 +83,7 @@ public class Log {
         if (classname.length() > (logDates ? 14 : 20)) classname = classname.substring(0, (logDates ? 14 : 20));
         while (classname.length() < (logDates ? 14 : 20)) classname = " " + classname;
         classname = classname + (classname.trim().length() == 0 ? "  " : ": ");
-        classname = color(GRAY, true, classname);
+        classname = colorize(GRAY, true, classname);
         classname = classname.replace('$', '.');
 
         if (logDates) {
@@ -91,7 +91,7 @@ public class Log {
             if (lastDate == null || d.getYear() != lastDate.getYear() || d.getMonth() != lastDate.getMonth() || d.getDay() != lastDate.getDay()) {
                 String now = new java.text.SimpleDateFormat("EEE dd MMM yyyy").format(d);
                 System.err.println();
-                System.err.println(color(GRAY, false, "=== " + now + " =========================================================="));
+                System.err.println(colorize(GRAY, false, "=== " + now + " =========================================================="));
             }
             java.text.DateFormat df = new java.text.SimpleDateFormat("[EEE HH:mm:ss] ");
             classname = df.format(d) + classname;
@@ -111,7 +111,7 @@ public class Log {
                 while((s = br.readLine()) != null) m += s + "\n";
                 log(o, m.substring(0, m.length() - 1), level);
             } catch (IOException e) {
-                System.err.println(color(RED, true, "Logger: exception thrown by ByteArrayInputStream -- this should not happen"));
+                System.err.println(colorize(RED, true, "Logger: exception thrown by ByteArrayInputStream -- this should not happen"));
             }
             return;
         }
@@ -120,7 +120,7 @@ public class Log {
         while(str.indexOf('\t') != -1)
             str = str.substring(0, str.indexOf('\t')) + "    " + str.substring(str.indexOf('\t') + 1);
 
-        classname = color(GRAY, false, classname);
+        classname = colorize(GRAY, false, classname);
         int levelcolor = GRAY;
         boolean bright = true;
         switch (level) {
@@ -133,12 +133,12 @@ public class Log {
         }
 
         while(str.indexOf('\n') != -1) {
-            System.err.println(classname + color(levelcolor, bright, str.substring(0, str.indexOf('\n'))));
+            System.err.println(classname + colorize(levelcolor, bright, str.substring(0, str.indexOf('\n'))));
             classname = logDates ? "                " : "                      ";
-            classname = color(GRAY,false,classname);
+            classname = colorize(GRAY,false,classname);
             str = str.substring(str.indexOf('\n') + 1);
         }
-        System.err.println(classname + color(levelcolor, bright, str));
+        System.err.println(classname + colorize(levelcolor, bright, str));
     }
 
     public static void recursiveLog(String indent, String name, Object o) throws JSExn {