Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Remove host data and had JAVA_HOST_LEVEL
[simgrid.git] / src / bindings / java / jmsg_host.c
index 9b8181b..81ed7f7 100644 (file)
@@ -18,7 +18,6 @@ static jmethodID jhost_method_Host_constructor;
 static jfieldID jhost_field_Host_bind;
 static jfieldID jhost_field_Host_name;
 
-
 jobject jhost_new_instance(JNIEnv * env) {
   jclass cls = jxbt_get_class(env, "org/simgrid/msg/Host");
   return (*env)->NewObject(env, cls, jhost_method_Host_constructor);
@@ -85,7 +84,7 @@ Java_org_simgrid_msg_Host_getByName(JNIEnv * env, jclass cls,
   }
   (*env)->ReleaseStringUTFChars(env, jname, name);
 
-  if (!MSG_host_get_data(host)) {       /* native host not associated yet with java host */
+  if (!xbt_lib_get_level(host, JAVA_HOST_LEVEL)) {       /* native host not associated yet with java host */
 
     /* Instantiate a new java host */
     jhost = jhost_new_instance(env);
@@ -110,11 +109,11 @@ Java_org_simgrid_msg_Host_getByName(JNIEnv * env, jclass cls,
     /* the native host data field is set with the global reference to the
      * java host returned by this function
      */
-    MSG_host_set_data(host, (void *) jhost);
+    xbt_lib_set(host_lib, host->key, JAVA_HOST_LEVEL, (void *) jhost);
   }
 
   /* return the global reference to the java host instance */
-  return (jobject) MSG_host_get_data(host);
+  return (jobject) xbt_lib_get_level(host, JAVA_HOST_LEVEL);
 }
 
 JNIEXPORT jobject JNICALL
@@ -123,7 +122,7 @@ Java_org_simgrid_msg_Host_currentHost(JNIEnv * env, jclass cls) {
 
   msg_host_t host = MSG_host_self();
 
-  if (!MSG_host_get_data(host)) {
+  if (!xbt_lib_get_level(host, JAVA_HOST_LEVEL)) {
     /* the native host not yet associated with the java host instance */
 
     /* instanciate a new java host instance */
@@ -147,9 +146,9 @@ Java_org_simgrid_msg_Host_currentHost(JNIEnv * env, jclass cls) {
     (*env)->SetObjectField(env, jhost, jhost_field_Host_name, jname);
     /* Bind & store it */
     jhost_bind(jhost, host, env);
-    MSG_host_set_data(host, (void *) jhost);
+    xbt_lib_set(host_lib, host->key, JAVA_HOST_LEVEL, (void *) jhost);
   } else {
-    jhost = (jobject) MSG_host_get_data(host);
+    jhost = (jobject) xbt_lib_get_level(host, JAVA_HOST_LEVEL);
   }
 
   return jhost;
@@ -291,7 +290,7 @@ Java_org_simgrid_msg_Host_all(JNIEnv * env, jclass cls_arg)
 
   for (index = 0; index < count; index++) {
     host = xbt_dynar_get_as(table,index,msg_host_t);
-    jhost = (jobject) (MSG_host_get_data(host));
+    jhost = (jobject) (xbt_lib_get_level(host, JAVA_HOST_LEVEL));
 
     if (!jhost) {
       jname = (*env)->NewStringUTF(env, MSG_host_get_name(host));