* src/vm/primitive.c: Removed.
[cacao.git] / src / vm / string.c
index 2d215c15c1cb18099ee6759ffb1a823303413b3a..74400828214dddca58a96e3403a2af24e4842b42 100644 (file)
@@ -27,6 +27,8 @@
 
 #include <assert.h>
 
+#include "vmcore/system.h"
+
 #include "vm/types.h"
 
 #include "vm/global.h"
@@ -43,7 +45,7 @@
 #include "vm/array.h"
 #include "vm/builtin.h"
 #include "vm/exceptions.h"
-#include "vm/primitive.h"
+#include "vm/primitive.hpp"
 #include "vm/stringlocal.h"
 #include "vm/vm.h"
 
@@ -139,7 +141,7 @@ void stringtable_update(void)
                                if (!a->header.objheader.vftbl) 
                                        /* vftbl of character-array is NULL */ 
                                        a->header.objheader.vftbl =
-                                               primitive_arrayclass_get_by_type(ARRAYTYPE_CHAR)->vftbl;
+                                               Primitive_get_arrayclass_by_type(ARRAYTYPE_CHAR)->vftbl;
 
                                /* follow link in external hash chain */
                                s = s->hashlink;
@@ -228,7 +230,8 @@ java_handle_t *javastring_safe_new_from_utf8(const char *text)
        s4 nbytes;
        s4 len;
 
-       assert(text);
+       if (text == NULL)
+               return NULL;
 
        /* Get number of bytes. We need this to completely emulate the messy */
        /* behaviour of the RI. :(                                           */
@@ -586,7 +589,7 @@ static java_object_t *literalstring_u2(java_chararray_t *a, u4 length,
     /* location in hashtable found, complete arrayheader */
 
     ca->header.objheader.vftbl =
-               primitive_arrayclass_get_by_type(ARRAYTYPE_CHAR)->vftbl;
+               Primitive_get_arrayclass_by_type(ARRAYTYPE_CHAR)->vftbl;
     ca->header.size            = length;
 
        assert(class_java_lang_String);
@@ -759,13 +762,13 @@ java_handle_t *javastring_intern(java_handle_t *s)
 }
 
 
-/* javastring_print ************************************************************
+/* javastring_fprint ***********************************************************
 
-   Print the given Java string.
+   Print the given Java string to the given stream.
 
 *******************************************************************************/
 
-void javastring_print(java_handle_t *s)
+void javastring_fprint(java_handle_t *s, FILE *stream)
 {
        java_lang_String        *so;
        java_handle_chararray_t *value;
@@ -782,7 +785,7 @@ void javastring_print(java_handle_t *s)
 
        for (i = offset; i < offset + count; i++) {
                c = LLNI_array_direct(value, i);
-               putchar(c);
+               fputc(c, stream);
        }
 }