The .hh files created with the header file generator are all
included here as are the C functions implementing these methods.
- $Id: native.c 1331 2004-07-21 15:46:54Z twisti $
+ $Id: native.c 1464 2004-11-06 22:55:46Z motse $
*/
#include "nativetable.inc"
-/* searchpath for classfiles */
-char *classpath;
-
/* for java-string to char conversion */
#define MAXSTRINGSIZE 1000
/*************************** include native methods ***************************/
#ifdef USE_GTK
-#include "nat/GdkGraphics.c"
#include "nat/GtkComponentPeer.c"
-#include "nat/GdkPixbufDecoder.c"
#include "nat/GtkScrollPanePeer.c"
#include "nat/GtkFileDialogPeer.c"
#endif
#undef JOWENN_DEBUG
#undef JOWENN_DEBUG1
+#ifdef STATIC_CLASSPATH
#define NATIVETABLESIZE (sizeof(nativetable)/sizeof(struct nativeref))
/* table for fast string comparison */
/* string comparsion table initialized */
static bool nativecompdone = false;
-
+#endif
/******************************************************************************/
}
-/********************* function: native_setclasspath **************************/
-
-void native_setclasspath(char *path)
-{
- /* set searchpath for classfiles */
- classpath = path;
-}
-
-
/*********************** Function: native_findfunction *************************
Looks up a method (must have the same class name, method name, descriptor
functionptr native_findfunction(utf *cname, utf *mname,
utf *desc, bool isstatic)
{
+#ifdef STATIC_CLASSPATH
int i;
/* entry of table for fast string comparison */
struct nativecompref *n;
/* keep compiler happy */
return NULL;
+#else
+/* dynamic classpath */
+ return 0;
+#endif
}
java_lang_String *javastring_new(utf *u)
{
- char *utf_ptr = u->text; /* current utf character in utf string */
- int utflength = utf_strlen(u); /* length of utf-string if uncompressed */
+ char *utf_ptr; /* current utf character in utf string */
+ u4 utflength; /* length of utf-string if uncompressed */
java_lang_String *s; /* result-string */
java_chararray *a;
s4 i;
-
+
+ if (!u) {
+ *exceptionptr = new_nullpointerexception();
+ return NULL;
+ }
+
+ utf_ptr = u->text;
+ utflength = utf_strlen(u);
+
s = (java_lang_String *) builtin_new(class_java_lang_String);
a = builtin_newarray_char(utflength);
java_lang_String *javastring_new_char(char *text)
{
s4 i;
- s4 len = strlen(text); /* length of the string */
+ s4 len; /* length of the string */
java_lang_String *s; /* result-string */
java_chararray *a;
-
+
+ if (!text) {
+ *exceptionptr = new_nullpointerexception();
+ return NULL;
+ }
+
+ len = strlen(text);
+
s = (java_lang_String *) builtin_new(class_java_lang_String);
a = builtin_newarray_char(len);
/* string already in hashtable, free memory */
if (!copymode)
- lit_mem_free(a, sizeof(java_chararray) + sizeof(u2) * (length - 1) + 10);
+ mem_free(a, sizeof(java_chararray) + sizeof(u2) * (length - 1) + 10);
#ifdef DEBUG_LITERALSTRING_U2
printf("literalstring_u2: foundentry at %p\n", js);
if (copymode) {
/* create copy of u2-array for new javastring */
u4 arraysize = sizeof(java_chararray) + sizeof(u2) * (length - 1) + 10;
- stringdata = lit_mem_alloc(arraysize);
+ stringdata = mem_alloc(arraysize);
/* memcpy(stringdata, a, arraysize); */
memcpy(&(stringdata->header), &(a->header), sizeof(java_arrayheader));
memcpy(&(stringdata->data), &(a->data) + offset, sizeof(u2) * (length - 1) + 10);
}
/* create new javastring */
- js = LNEW(java_lang_String);
+ js = NEW(java_lang_String);
+#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+ initObjectLock(&js->header);
+#endif
js->header.vftbl = class_java_lang_String->vftbl;
js->value = stringdata;
js->offset = 0;
u4 i;
/* allocate memory */
- a = lit_mem_alloc(sizeof(java_chararray) + sizeof(u2) * (utflength - 1) + 10);
+ a = mem_alloc(sizeof(java_chararray) + sizeof(u2) * (utflength - 1) + 10);
/* convert utf-string to u2-array */
for (i = 0; i < utflength; i++)
java_chararray *a = s->value;
/* dispose memory of java.lang.String object */
- LFREE(s, java_lang_String);
+ FREE(s, java_lang_String);
/* dispose memory of java-characterarray */
- LFREE(a, sizeof(java_chararray) + sizeof(u2) * (a->header.size - 1)); /* +10 ?? */
+ FREE(a, sizeof(java_chararray) + sizeof(u2) * (a->header.size - 1)); /* +10 ?? */
}