X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/762740361e42dd14f5d24d239a29a1e08895ef64..ea131c282aef654396f98d3e5d0d6cffdbf6ebab:/src/bindings/ruby/rb_msg_host.c diff --git a/src/bindings/ruby/rb_msg_host.c b/src/bindings/ruby/rb_msg_host.c index f4ecd65962..4ac3a82957 100644 --- a/src/bindings/ruby/rb_msg_host.c +++ b/src/bindings/ruby/rb_msg_host.c @@ -1,10 +1,10 @@ -/* - * Copyright 2010. The SimGrid Team. 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. - */ +/* Host-related bindings to ruby */ + +/* Copyright 2010. The SimGrid Team. 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 "bindings/ruby_bindings.h" // Free Method @@ -14,24 +14,23 @@ void rb_host_free(m_host_t ht) { // New Method : return a Host VALUE rb_host_get_by_name(VALUE class, VALUE name) { - + 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,rb_host_free,host); + rb_raise(rb_eRuntimeError,bprintf("No host called '%s' found",h_name)); + return Data_Wrap_Struct(class,0,rb_host_free,host); } //Get Name VALUE rb_host_name(VALUE class,VALUE host) { - + // Wrap Ruby Value to m_host_t struct m_host_t ht; Data_Get_Struct(host, s_m_host_t, ht); return rb_str_new2(MSG_host_get_name(ht)); - + } // Get Number @@ -65,9 +64,9 @@ VALUE rb_host_is_avail(VALUE class,VALUE host) { rb_raise(rb_eRuntimeError,"Host not Bound"); return Qnil; } - + if(MSG_host_is_avail(ht)) return Qtrue; - + return Qfalse; }