Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
First version of ruby bindings by Medhi
[simgrid.git] / src / bindings / ruby / rb_application_handler.c
1 #include "rb_application_handler.h"
2 #include "surf/surfxml_parse.h"
3 #include <stdio.h>
4
5 static void  r_init()
6 {
7   
8   ruby_init();
9   ruby_init_loadpath();
10   rb_require("ApplicationHandler.rb");
11   
12
13
14 static void  application_handler_on_start_document(void)
15 {
16   
17    r_init();
18    //current One
19    current = rb_funcall3(rb_const_get(rb_cObject, rb_intern("ApplicationHandler")),  rb_intern("new"), 0, 0);
20    rb_funcall(current,rb_intern("onStartDocument"),0);
21   
22   
23 }
24
25 static void  application_handler_on_end_document(void)
26 {
27   
28   //r_init();
29   rb_funcall(current,rb_intern("onEndDocument"),0); 
30
31 }
32
33 static void application_handler_on_begin_process(void) 
34 {
35  
36   
37   //r_init();
38   
39   VALUE hostName = rb_str_new2(A_surfxml_process_host);
40   VALUE function = rb_str_new2(A_surfxml_process_function);
41   
42    rb_funcall(current,rb_intern("onBeginProcess"),2,hostName,function); 
43   
44   
45 }
46
47 static void  application_handler_on_process_arg(void)
48 {
49
50   //r_init();
51   
52    VALUE arg = rb_str_new2(A_surfxml_argument_value);
53   
54    rb_funcall(current,rb_intern("onProcessArg"),1,arg);
55   
56   
57 }
58
59 static void  application_handler_on_property(void)
60 {
61  
62   //r_init();
63   
64    VALUE id = rb_str_new2(A_surfxml_prop_id);
65    VALUE val =  rb_str_new2(A_surfxml_prop_value);
66   
67    rb_funcall(current,rb_intern("onProperty"),2,id,val);
68    
69    
70 }
71
72
73 static void application_handler_on_end_process(void)
74 {
75   
76  //r_init();
77  
78  rb_funcall(current,rb_intern("onEndProcess"),0);
79   
80   
81 }