Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Cleanup log mess in ruby bindings, various cosmetics, restaure a FIXME which slept...
authormquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 3 Mar 2010 18:01:01 +0000 (18:01 +0000)
committermquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 3 Mar 2010 18:01:01 +0000 (18:01 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@7181 48e7efb5-ca39-0410-a469-dd3cf9ba447f

src/bindings/ruby/rb_application_handler.c
src/bindings/ruby/simgrid.rb

index 42fa57d..97f6b8e 100644 (file)
@@ -6,19 +6,17 @@
  */
 #include "bindings/ruby_bindings.h"
 #include "surf/surfxml_parse.h"
  */
 #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
 
 // Used to instanciate the Process
-
 static  VALUE args;
 static  VALUE prop;
 static  VALUE function_name;
 static  VALUE host_name; 
 
 
 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();
 static VALUE rb_process_instance(VALUE fct_name,VALUE arguments,VALUE properties) {
   ruby_init();
   ruby_init_loadpath();
@@ -26,6 +24,7 @@ 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);
 }
 
   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);
 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);
@@ -57,17 +56,11 @@ static void rb_process_create_with_args(VALUE fct_name,VALUE arguments,VALUE pro
   }
   process->simdata->PID = msg_global->PID++; //  msg_global ??
 
   }
   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);
   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);
 
   /* 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 +73,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);
 
           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);
 
   if (SIMIX_process_self()) { // SomeOne Created Me !!
     process->simdata->PPID = MSG_process_get_PID(SIMIX_process_self()->data);
@@ -103,6 +95,7 @@ void rb_application_handler_on_start_document(void) {
 }
 
 void rb_application_handler_on_end_document(void) {
 }
 
 void rb_application_handler_on_end_document(void) {
+  // FIXME: probably leaking
   //application_handler_class = Qnil;
   args = Qnil;
   prop = Qnil;
   //application_handler_class = Qnil;
   args = Qnil;
   prop = Qnil;
@@ -113,7 +106,7 @@ void rb_application_handler_on_end_document(void) {
 
 void rb_application_handler_on_begin_process(void) {
   
 
 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);
   
 }
   function_name = rb_str_new2(A_surfxml_process_function);
   
 }
@@ -125,6 +118,7 @@ void rb_application_handler_on_process_arg(void) {
 }
 
 void rb_application_handler_on_property(void) {
 }
 
 void rb_application_handler_on_property(void) {
+  // FIXME: properties are never added to the ruby process
   VALUE id = rb_str_new2(A_surfxml_prop_id);
   VALUE val =  rb_str_new2(A_surfxml_prop_value);
   int i_id = NUM2INT (id);
   VALUE id = rb_str_new2(A_surfxml_prop_id);
   VALUE val =  rb_str_new2(A_surfxml_prop_value);
   int i_id = NUM2INT (id);
index 5c96cdb..daa12ea 100644 (file)
@@ -1,3 +1,5 @@
+# FIXME: add license like in C files
+
 require 'simgrid_ruby'
 require 'thread'
 
 require 'simgrid_ruby'
 require 'thread'
 
@@ -52,8 +54,8 @@ class MSG::Process < Thread
   @@nextProcessId = 0
 
 # Attributes
   @@nextProcessId = 0
 
 # Attributes
-  attr_reader :bind, :id ,:name           # Read only
-  attr_accessor :properties, :pargs  # R/W
+  attr_reader :bind, :id, :name, :pargs # Read only
+  attr_accessor :properties             # R/W 
   
 
     def initialize(*args)
   
 
     def initialize(*args)
@@ -63,9 +65,8 @@ class MSG::Process < Thread
      
     @schedBegin = Semaphore.new(0)
     @schedEnd = Semaphore.new(0)    
      
     @schedBegin = Semaphore.new(0)
     @schedEnd = Semaphore.new(0)    
-    #@properties = Hash.new()
-    @id = @@nextProcessId
-    @@nextProcessId += 1
+    #@properties = Hash.new() FIXME: get this from the C (yep that makes 4 args to this function)
+    @id = @@nextProcessId++
     @name = args[0]
     @pargs = args[1]
     @properties = args[2]
     @name = args[0]
     @pargs = args[1]
     @properties = args[2]
@@ -95,12 +96,12 @@ class MSG::Process < Thread
     
 
   
     
 
   
-  #Get Bind ( Used > Native to Ruby)
+  # Get Bind
   def getBind()
     return @bind
   end
   
   def getBind()
     return @bind
   end
   
-  #Get Binds (Used > Ruby to Native)
+  # Set Binds
   def setBind(bind)
     @bind = bind
   end
   def setBind(bind)
     @bind = bind
   end
@@ -115,30 +116,23 @@ class MSG::Process < Thread
     @schedEnd.acquire
   end
   
     @schedEnd.acquire
   end
   
-   #C Simualator Process Equivalent  Management
-  # After Binding Ruby Process to C Process
-  
-#   pause
   def pause()
     processSuspend(self)
   end
   
   def pause()
     processSuspend(self)
   end
   
-#   restart
   def restart()
     processResume(self)
   end
   
   def restart()
     processResume(self)
   end
   
-#   isSuspended
   def isSuspended()
     processIsSuspended(self)
   end
   
   def isSuspended()
     processIsSuspended(self)
   end
   
-#   getHost
   def getHost()
     processGetHost(self)
   end
   
   def getHost()
     processGetHost(self)
   end
   
-# The Rest of Methods !!! To be Continued ...
+# The Rest of Methods !!! To be Continued ... FIXME: what's missing?
 end
 
 #########################
 end
 
 #########################