]> AND Public Git Repository - simgrid.git/blobdiff - src/bindings/ruby/rb_application_handler.c
Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
We must put the location where we copy the task
[simgrid.git] / src / bindings / ruby / rb_application_handler.c
index 42fa57d0d088f1c4319f6ce0c4111e110473d8c1..02802e10349a1b2090a84076fb6a3748f76a6e06 100644 (file)
@@ -6,19 +6,16 @@
  */
 #include "bindings/ruby_bindings.h"
 #include "surf/surfxml_parse.h"
-#include "msg/private.h" /* s_simdata_process_t */
+#include "msg/private.h" /* s_simdata_process_t FIXME: don't mess with MSG internals that way */
 
-// XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ruby,bindings,"Ruby Bindings");
+XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(ruby);
 
 // Used to instanciate the Process
-
 static  VALUE args;
 static  VALUE prop;
 static  VALUE function_name;
 static  VALUE host_name; 
 
-
-
 static VALUE rb_process_instance(VALUE fct_name,VALUE arguments,VALUE properties) {
   ruby_init();
   ruby_init_loadpath();
@@ -26,29 +23,29 @@ static VALUE rb_process_instance(VALUE fct_name,VALUE arguments,VALUE properties
   return rb_funcall(rb_const_get(rb_cObject, rb_intern(p_className)),rb_intern("new"),3,fct_name,arguments,properties);
 }
 
+// FIXME: don't mess with MSG internals here, use MSG_process_create_with_arguments()
 static void rb_process_create_with_args(VALUE fct_name,VALUE arguments,VALUE properties,VALUE ht_name) {
   
   VALUE ruby_process = rb_process_instance(fct_name,arguments,properties);
   m_process_t process; // Native Process to Create
   const char * name ; // Name of C Native Processs
 
+
   if(!fct_name)
     rb_raise(rb_eRuntimeError,"Internal error: Process name cannot be NULL");
+  name = RSTRING(fct_name)->ptr;
+  DEBUG1("Create native process %s",name);
 
   // Allocate the data for the simulation
   process = xbt_new0(s_m_process_t,1);
   process->simdata = xbt_new0(s_simdata_process_t,1);
-  // Do we Really Need to Create Ruby Process Instance , >> process is already a Ruby Process !! So..Keep on ;)
   // Bind The Ruby Process instance to The Native Process
   rb_process_bind(ruby_process,process);
-  name = RSTRING(fct_name)->ptr;
   process->name = xbt_strdup(name);
   // Host
   m_host_t host = MSG_get_host_by_name(RSTRING(ht_name)->ptr);
   process->simdata->m_host = host;
   
-  //Data_Get_Struct(host,s_m_host_t,process->simdata->m_host);
-
   if(!(process->simdata->m_host)) { // Not Binded
     free(process->simdata);
     free(process->data);
@@ -57,17 +54,10 @@ static void rb_process_create_with_args(VALUE fct_name,VALUE arguments,VALUE pro
   }
   process->simdata->PID = msg_global->PID++; //  msg_global ??
 
-/*
   DEBUG7("fill in process %s/%s (pid=%d) %p (sd=%p , host=%p, host->sd=%p)",
       process->name , process->simdata->m_host->name,process->simdata->PID,
       process,process->simdata, process->simdata->m_host,
       process->simdata->m_host->simdata);
-*/
-
-printf("fill in process %s/%s (pid=%d) %p (sd=%p , host=%p, host->sd=%p)\n",
-      process->name , process->simdata->m_host->name,process->simdata->PID,
-      process,process->simdata, process->simdata->m_host,
-      process->simdata->m_host->simdata);
 
   /* FIXME: that's mainly for debugging. We could only allocate this if XBT_LOG_ISENABLED(ruby,debug) is true since I guess this leaks */
   char **argv=xbt_new(char*,2);
@@ -80,8 +70,7 @@ printf("fill in process %s/%s (pid=%d) %p (sd=%p , host=%p, host->sd=%p)\n",
           process->simdata->m_host->simdata->smx_host->name,
           1,argv,NULL);
 
- // DEBUG1("context created (s_process=%p)",process->simdata->s_process);
- printf("context created (s_process=%p)\n",process->simdata->s_process);
+  DEBUG1("context created (s_process=%p)",process->simdata->s_process);
 
   if (SIMIX_process_self()) { // SomeOne Created Me !!
     process->simdata->PPID = MSG_process_get_PID(SIMIX_process_self()->data);
@@ -94,28 +83,24 @@ printf("fill in process %s/%s (pid=%d) %p (sd=%p , host=%p, host->sd=%p)\n",
 }
 
 
-
-
 void rb_application_handler_on_start_document(void) {
   
-   args = rb_ary_new();  // Max lenght = 16 ?!
-   prop = rb_ary_new();
 }
 
 void rb_application_handler_on_end_document(void) {
-  //application_handler_class = Qnil;
-  args = Qnil;
-  prop = Qnil;
-  function_name = Qnil;
-  host_name = Qnil;
+
+  //application_handler_class = Qnil; FIXME: probably leaking
   
 }
 
 void rb_application_handler_on_begin_process(void) {
   
-  host_name = rb_str_new2(A_surfxml_process_host);;
+  host_name = rb_str_new2(A_surfxml_process_host);
   function_name = rb_str_new2(A_surfxml_process_function);
-  
+
+  args = rb_ary_new();  // Max lenght = 16 ?!
+  prop = rb_ary_new();
+
 }
 
 void rb_application_handler_on_process_arg(void) {