Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@7117 48e7efb5...
[simgrid.git] / src / bindings / ruby / rb_msg_host.c
index 27eefce..68b888a 100644 (file)
@@ -1,3 +1,13 @@
+/*
+ * $Id$
+ *
+ * Copyright 2010 Martin Quinson, Mehdi Fekari           
+ * All right reserved. 
+ *
+ * This program is free software; you can redistribute 
+ * it and/or modify it under the terms of the license 
+ *(GNU LGPL) which comes with this package. 
+ */
 #include "rb_msg_host.h"
 
 // Free Method
@@ -5,28 +15,24 @@ static void host_free(m_host_t ht) {
   //Nothing to do !!?
 }
 
-
 // New Method : return a Host
 static VALUE host_get_by_name(VALUE class, VALUE name)
 {
   
-  m_host_t host = MSG_get_host_by_name(RSTRING(name)->ptr);
+  const char * h_name = RSTRING(name)->ptr;
+  m_host_t host = MSG_get_host_by_name(h_name);
   if(!host)
-    
     rb_raise(rb_eRuntimeError,"MSG_get_host_by_name() failled");
   
-  return Data_Wrap_Struct(class, 0, host_free, host);
+  return Data_Wrap_Struct(class,0,host_free,host);
 
 }
 
-
 //Get Name
-
 static VALUE host_name(VALUE class,VALUE host)
 {
   
   // Wrap Ruby Value to m_host_t struct
-  
   m_host_t ht;
   Data_Get_Struct(host, m_host_t, ht);
   return rb_str_new2(MSG_host_get_name(ht));
@@ -36,8 +42,8 @@ static VALUE host_name(VALUE class,VALUE host)
 // Get Number
 static VALUE host_number(VALUE class)
 {
-  return MSG_get_host_number();
+  
+  return INT2NUM(MSG_get_host_number());
   
 }
 
@@ -50,7 +56,6 @@ static VALUE host_speed(VALUE class,VALUE host)
   
 }
 
-
 // Host Set Data
 static void host_set_data(VALUE class,VALUE host,VALUE data)
 {
@@ -64,9 +69,6 @@ static VALUE host_get_data(VALUE class,VALUE host)
   return Qnil;
 }
 
-
-
-
 // Host is Avail
 static VALUE host_is_avail(VALUE class,VALUE host)
 {