#include <stdlib.h>
#include <string.h>
-#include "native/jni.h"
-#include "native/llni.h"
-#include "native/native.h"
+#include "native/jni.hpp"
+#include "native/native.hpp"
#if defined(ENABLE_JNI_HEADERS)
# include "native/include/java_lang_String.h"
#endif
+#include "vm/javaobjects.hpp"
#include "vm/string.hpp"
-#include "vmcore/javaobjects.hpp"
-
// Native functions are exported as C functions.
extern "C" {
{
java_lang_String jls(_this);
- java_handle_chararray_t* value = jls.get_value();
+ CharArray value(jls.get_value());
+
int32_t offset = jls.get_offset();
int32_t count = jls.get_count();
int32_t hash = 0;
for (int32_t i = 0; i < count; i++) {
- hash = (31 * hash) + LLNI_array_direct(value, offset + i);
+ hash = (31 * hash) + value.get_element(offset + i);
}
return hash;
{
java_lang_String jls(_this);
- java_handle_chararray_t* value = jls.get_value();
+ CharArray value(jls.get_value());
+
int32_t offset = jls.get_offset();
int32_t count = jls.get_count();
for (int32_t i = 0; i < count; i++) {
- if (LLNI_array_direct(value, offset + i) == ch) {
+ if (value.get_element(offset + i) == ch) {
return i;
}
}
{
java_lang_String jls(_this);
- java_handle_chararray_t* value = jls.get_value();
+ CharArray value(jls.get_value());
+
int32_t offset = jls.get_offset();
int32_t count = jls.get_count();
}
for (int32_t i = fromIndex ; i < count ; i++) {
- if (LLNI_array_direct(value, offset + i) == ch) {
+ if (value.get_element(offset + i) == ch) {
return i;
}
}
{
java_lang_String jls(_this);
- java_handle_chararray_t* value = jls.get_value();
+ CharArray value(jls.get_value());
+
int32_t offset = jls.get_offset();
int32_t count = jls.get_count();
int32_t start = ((fromIndex >= count) ? count - 1 : fromIndex);
for (int32_t i = start; i >= 0; i--) {
- if (LLNI_array_direct(value, offset + i) == ch) {
+ if (value.get_element(offset + i) == ch) {
return i;
}
}
*******************************************************************************/
-// FIXME
-extern "C" {
void _Jv_java_lang_String_init(void)
{
- utf *u;
+ utf* u = utf_new_char("java/lang/String");
- u = utf_new_char("java/lang/String");
-
- native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
+ NativeMethods& nm = VM::get_current()->get_nativemethods();
+ nm.register_methods(u, methods, NATIVE_METHODS_COUNT);
}