Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Dont declare variables at the middle of nowhere.
[simgrid.git] / src / bindings / rubyDag / rb_SD_workstation.c
1 /* Copyright (c) 2010. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5   * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #include "rb_SD_workstation.h"
8
9 static void SD_workstation_free(SD_workstation_t wrk)
10 {
11   //NOTHING TO DO
12 }
13 // Workstation list
14 static VALUE rb_SD_workstation_list(VALUE class)
15 {
16  
17   int i,nb;
18   nb = SD_workstation_get_number();
19   VALUE workstation_list = rb_ary_new2(nb);
20   for (i=0;i<nb;i++)
21   {
22    VALUE wrk = Qnil;
23    wrk = Data_Wrap_Struct(class, 0, SD_workstation_free, SD_workstation_get_list()[i]);
24    rb_ary_push(workstation_list,wrk);
25     
26   }
27   return workstation_list;
28 }
29
30 // Workstation number
31 static VALUE rb_SD_workstation_number(VALUE class)
32 {
33   int nb = SD_workstation_get_number();
34   return INT2NUM(nb);
35 }
36
37 // Workstation name
38 static VALUE rb_SD_workstation_name(VALUE class,VALUE workstation)
39 {
40  SD_workstation_t wk;
41  Data_Get_Struct(workstation, SD_workstation_t, wk);
42  return rb_str_new2(SD_workstation_get_name(wk));
43  
44 }