Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
11b5ce3d1f5ea8fb4f083069d12d14a7c803b519
[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 // #define DEBUG 
6
7 static void  r_init()
8 {
9   
10   ruby_init();
11   ruby_init_loadpath();
12   rb_require("ApplicationHandler.rb");
13   
14
15
16 static void  application_handler_on_start_document(void)
17 {
18   
19    
20    r_init();
21    //current One
22    current = rb_funcall3(rb_const_get(rb_cObject, rb_intern("ApplicationHandler")),  rb_intern("new"), 0, 0);
23    rb_funcall(current,rb_intern("onStartDocument"),0);
24  #ifdef DEBUG
25    printf ("application_handler_on_start_document ...Done\n" );
26  #endif
27   
28 }
29
30 static void  application_handler_on_end_document(void)
31 {
32   
33   //r_init();
34   rb_funcall(current,rb_intern("onEndDocument"),0); 
35
36 }
37
38 static void application_handler_on_begin_process(void) 
39 {
40   //r_init();
41   VALUE hostName = rb_str_new2(A_surfxml_process_host);
42   VALUE function = rb_str_new2(A_surfxml_process_function);
43 #ifdef DEBUG
44    printf ("On_Begin_Process: %s : %s \n",RSTRING(hostName)->ptr,RSTRING(function)->ptr);
45 #endif 
46    rb_funcall(current,rb_intern("onBeginProcess"),2,hostName,function); 
47 }
48
49 static void  application_handler_on_process_arg(void)
50 {
51   //r_init();
52    VALUE arg = rb_str_new2(A_surfxml_argument_value);
53 #ifdef DEBUG
54    printf ("On_Process_Args >> Sufxml argument value : %s\n",RSTRING(arg)->ptr);
55 #endif
56    rb_funcall(current,rb_intern("onProcessArg"),1,arg); 
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 }