Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Stuks When a process ( Slave ) Tries to Recieve a Task...
[simgrid.git] / src / bindings / ruby / rb_application_handler.c
1 /*
2  * $Id$
3  *
4  * Copyright 2010 Martin Quinson, Mehdi Fekari           
5  * All right reserved. 
6  *
7  * This program is free software; you can redistribute 
8  * it and/or modify it under the terms of the license 
9  *(GNU LGPL) which comes with this package. 
10  */
11 #include "rb_application_handler.h"
12 #include "surf/surfxml_parse.h"
13 #include <stdio.h>
14
15 // #define MY_DEBUG 
16
17 static void  r_init()
18 {
19   
20   ruby_init();
21   ruby_init_loadpath();
22   rb_require("ApplicationHandler.rb");
23   
24
25
26 static void  application_handler_on_start_document(void)
27 {
28   
29    r_init();
30    //current One
31    current = rb_funcall3(rb_const_get(rb_cObject, rb_intern("ApplicationHandler")),  rb_intern("new"), 0, 0);
32    rb_funcall(current,rb_intern("onStartDocument"),0);
33  #ifdef MY_DEBUG
34    printf ("application_handler_on_start_document ...Done\n" );
35  #endif
36   
37 }
38
39 static void  application_handler_on_end_document(void)
40 {
41   //r_init();
42   rb_funcall(current,rb_intern("onEndDocument"),0); 
43
44 }
45
46 static void application_handler_on_begin_process(void) 
47 {
48   //r_init();
49   VALUE hostName = rb_str_new2(A_surfxml_process_host);
50   VALUE function = rb_str_new2(A_surfxml_process_function);
51 #ifdef MY_DEBUG
52    printf ("On_Begin_Process: %s : %s \n",RSTRING(hostName)->ptr,RSTRING(function)->ptr);
53 #endif 
54    rb_funcall(current,rb_intern("onBeginProcess"),2,hostName,function); 
55 }
56
57 static void  application_handler_on_process_arg(void)
58 {
59   //r_init();
60    VALUE arg = rb_str_new2(A_surfxml_argument_value);
61 #ifdef MY_DEBUG
62    printf ("On_Process_Args >> Sufxml argument value : %s\n",RSTRING(arg)->ptr);
63 #endif
64    rb_funcall(current,rb_intern("onProcessArg"),1,arg); 
65 }
66
67 static void  application_handler_on_property(void)
68 {
69  
70   //r_init()
71    VALUE id = rb_str_new2(A_surfxml_prop_id);
72    VALUE val =  rb_str_new2(A_surfxml_prop_value);
73    rb_funcall(current,rb_intern("onProperty"),2,id,val);
74    
75 }
76
77
78 static void application_handler_on_end_process(void)
79 {
80   
81  //r_init()
82  rb_funcall(current,rb_intern("onEndProcess"),0);
83     
84 }