2 * Copyright 2010. The SimGrid Team. All right reserved.
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.
7 #include "bindings/ruby_bindings.h"
8 #include "surf/surfxml_parse.h"
10 static VALUE application_handler_class; // The Current Instance of ApplicationHandler Class ,is it the same as Current Thread ??!!
15 static void r_init() {
18 rb_require("ApplicationHandler.rb");
22 void rb_application_handler_on_start_document(void) {
25 application_handler_class = rb_funcall3(rb_const_get(rb_cObject, rb_intern("ApplicationHandler")), rb_intern("new"), 0, 0);
26 rb_funcall(application_handler_class,rb_intern("onStartDocument"),0);
28 printf ("application_handler_on_start_document ...Done\n" );
33 void rb_application_handler_on_end_document(void) {
34 rb_funcall(application_handler_class,rb_intern("onEndDocument"),0);
37 void rb_application_handler_on_begin_process(void) {
38 VALUE hostName = rb_str_new2(A_surfxml_process_host);
39 VALUE function = rb_str_new2(A_surfxml_process_function);
41 printf ("On_Begin_Process: %s : %s \n",RSTRING(hostName)->ptr,RSTRING(function)->ptr);
43 rb_funcall(application_handler_class,rb_intern("onBeginProcess"),2,hostName,function);
46 void rb_application_handler_on_process_arg(void) {
47 VALUE arg = rb_str_new2(A_surfxml_argument_value);
49 printf ("On_Process_Args >> Sufxml argument value : %s\n",RSTRING(arg)->ptr);
51 rb_funcall(application_handler_class,rb_intern("onProcessArg"),1,arg);
54 void rb_application_handler_on_property(void) {
55 VALUE id = rb_str_new2(A_surfxml_prop_id);
56 VALUE val = rb_str_new2(A_surfxml_prop_value);
57 rb_funcall(application_handler_class,rb_intern("onProperty"),2,id,val);
61 void rb_application_handler_on_end_process(void) {
62 rb_funcall(application_handler_class,rb_intern("onEndProcess"),0);