-#include <stdlib.h>
-#include <stdio.h>
+// Copyright 2002 Adam Megacz, see the COPYING file for licensing [LGPL]
+
+// Inclusions /////////////////////////////////////////////////////////
+
#include <gcj/cni.h>
#include <gcj/array.h>
-#include "jpeglib.h"
-#include <setjmp.h>
+extern "C" {
-#include <java/lang/RuntimeException.h>
+// hack for broken Solaris headers
+#define _WCHAR_T
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <setjmp.h>
+#include "jpeglib.h"
+}
+#include <org/xwt/plat/GCJ.h>
#include <java/io/InputStream.h>
+#include <java/io/ByteArrayInputStream.h>
+#include <java/lang/RuntimeException.h>
#include <org/xwt/plat/GCJ.h>
#include <org/xwt/plat/GCJ$JPEG.h>
+
+
+// builtin.xwar /////////////////////////////////////////////////////////
+
+extern unsigned char builtin_bytes[];
+extern int builtin_length;
+
+java::io::InputStream* org::xwt::plat::GCJ::_getBuiltinInputStream() {
+ jbyteArray ret = JvNewByteArray(builtin_length);
+ memcpy(elements(ret), builtin_bytes, builtin_length);
+ return new java::io::ByteArrayInputStream(ret);
+}
+
+
+
+// JPEG ////////////////////////////////////////////////////////////////
+
#define INPUT_BUF_SIZE (1024 * 16)
typedef struct {
jpeg_destroy_decompress(&cinfo);
}
-
+// C++ new/delete operators (JvMalloc never fails)
+void* operator new(size_t size) { return JvMalloc(size); }
+void* operator new[](size_t size) { return JvMalloc(size);}
+void operator delete(void *p) { JvFree(p); }
+void operator delete[](void *p) { JvFree(p); }