Merged with michi branch at rev 1684fe51cf3d.
[cacao.git] / src / native / vm / cldc1.1 / java_lang_Float.cpp
index bea50c0c5fac47cea35e91545de5b2946904dc22..d4c200150097047afe2cc3974d753f1695bdeae9 100644 (file)
 
 #include <stdint.h>
 
-#include "native/jni.h"
-#include "native/native.h"
+#include "native/jni.hpp"
+#include "native/native.hpp"
 
 #if defined(ENABLE_JNI_HEADERS)
 # include "native/include/java_lang_Float.h"
 #endif
 
-#include "vm/builtin.h"
+#include "vm/vm.hpp"
+
+#include "vm/jit/builtin.hpp"
 
 
 // Native functions are exported as C functions.
@@ -61,6 +63,18 @@ JNIEXPORT jint JNICALL Java_java_lang_Float_floatToIntBits(JNIEnv *env, jclass c
        return val.i;
 }
 
+/*
+ * Class:     java/lang/Float
+ * Method:    intBitsToFloat
+ * Signature: (I)F
+ */
+JNIEXPORT jfloat JNICALL Java_java_lang_Float_intBitsToFloat(JNIEnv *env, jclass clazz, jint value)
+{
+        imm_union val;
+        val.i = value;
+        return val.f;
+}
+
 } // extern "C"
 
 
@@ -68,6 +82,7 @@ JNIEXPORT jint JNICALL Java_java_lang_Float_floatToIntBits(JNIEnv *env, jclass c
  
 static JNINativeMethod methods[] = {
        { (char*) "floatToIntBits", (char*) "(F)I", (void*) (uintptr_t) &Java_java_lang_Float_floatToIntBits },
+       { (char*) "intBitsToFloat", (char*) "(I)F", (void*) (uintptr_t) &Java_java_lang_Float_intBitsToFloat }
 };
  
  
@@ -77,16 +92,12 @@ static JNINativeMethod methods[] = {
  
 *******************************************************************************/
 
-// FIXME
-extern "C" { 
 void _Jv_java_lang_Float_init(void)
 {
-       utf *u;
+       utf* u = utf_new_char("java/lang/Float");
  
-       u = utf_new_char("java/lang/Float");
-       native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
+       NativeMethods& nm = VM::get_current()->get_nativemethods();
+       nm.register_methods(u, methods, NATIVE_METHODS_COUNT);
 }