Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use my axe to get ruby bindings compiling. Need to get them working now
authormquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Mon, 1 Mar 2010 15:49:06 +0000 (15:49 +0000)
committermquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Mon, 1 Mar 2010 15:49:06 +0000 (15:49 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@7152 48e7efb5-ca39-0410-a469-dd3cf9ba447f

src/Makefile.am
src/bindings/ruby/rb_msg_host.c
src/bindings/ruby/rb_msg_process.c
src/bindings/ruby/rb_msg_task.c
src/bindings/ruby/rb_msg_task.h [deleted file]
src/bindings/ruby_bindings.h
src/simix/smx_context_lua.c

index 303d760..dca45a9 100644 (file)
@@ -384,7 +384,10 @@ else
   EXTRA_DIST += $(LUA_SRC)
 endif
 
   EXTRA_DIST += $(LUA_SRC)
 endif
 
-RUBY_SRC= simix/smx_context_ruby.c bindings/ruby/rb_msg_process.c
+RUBY_SRC= simix/smx_context_ruby.c \
+   bindings/ruby/rb_msg_process.c  \
+   bindings/ruby/rb_msg_host.c     \
+   bindings/ruby/rb_msg_task.c
 if HAVE_RUBY
   simgrid_sources += $(RUBY_SRC)
 else
 if HAVE_RUBY
   simgrid_sources += $(RUBY_SRC)
 else
index cae895f..f4ecd65 100644 (file)
@@ -20,7 +20,7 @@ VALUE rb_host_get_by_name(VALUE class, VALUE name) {
   if(!host)
     rb_raise(rb_eRuntimeError,"MSG_get_host_by_name() failled");
   
   if(!host)
     rb_raise(rb_eRuntimeError,"MSG_get_host_by_name() failled");
   
-  return Data_Wrap_Struct(class,0,host_free,host);
+  return Data_Wrap_Struct(class,0,rb_host_free,host);
 
 }
 
 
 }
 
@@ -29,41 +29,38 @@ VALUE rb_host_name(VALUE class,VALUE host) {
   
   // Wrap Ruby Value to m_host_t struct
   m_host_t ht;
   
   // Wrap Ruby Value to m_host_t struct
   m_host_t ht;
-  Data_Get_Struct(host, m_host_t, ht);
+  Data_Get_Struct(host, s_m_host_t, ht);
   return rb_str_new2(MSG_host_get_name(ht));
    
 }
 
 // Get Number
 VALUE rb_host_number(VALUE class) {
   return rb_str_new2(MSG_host_get_name(ht));
    
 }
 
 // Get Number
 VALUE rb_host_number(VALUE class) {
-  
   return INT2NUM(MSG_get_host_number());
   return INT2NUM(MSG_get_host_number());
-  
 }
 
 // Host Speed ( Double )
 VALUE rb_host_speed(VALUE class,VALUE host) {
   m_host_t ht ;
 }
 
 // Host Speed ( Double )
 VALUE rb_host_speed(VALUE class,VALUE host) {
   m_host_t ht ;
-  Data_Get_Struct(host,m_host_t,ht);
+  Data_Get_Struct(host,s_m_host_t,ht);
   return MSG_get_host_speed(ht);
   return MSG_get_host_speed(ht);
-  
 }
 
 // Host Set Data
 void rb_host_set_data(VALUE class,VALUE host,VALUE data) {
 }
 
 // Host Set Data
 void rb_host_set_data(VALUE class,VALUE host,VALUE data) {
-  //...
+  THROW_UNIMPLEMENTED;
 }
 
 // Host Get Data
 VALUE rb_host_get_data(VALUE class,VALUE host) {
 }
 
 // Host Get Data
 VALUE rb_host_get_data(VALUE class,VALUE host) {
-  //...
+  THROW_UNIMPLEMENTED;
   return Qnil;
 }
 
 // Host is Avail
 VALUE rb_host_is_avail(VALUE class,VALUE host) {
   m_host_t ht;
   return Qnil;
 }
 
 // Host is Avail
 VALUE rb_host_is_avail(VALUE class,VALUE host) {
   m_host_t ht;
-  Data_Get_Struct(host,m_host_t,ht);
+  Data_Get_Struct(host,s_m_host_t,ht);
   if (!ht) {
     rb_raise(rb_eRuntimeError,"Host not Bound");
     return Qnil;
   if (!ht) {
     rb_raise(rb_eRuntimeError,"Host not Bound");
     return Qnil;
index 202becc..b19e39e 100644 (file)
@@ -130,7 +130,7 @@ void rb_process_create(VALUE class,VALUE ruby_process,VALUE host) {
   rb_process_bind(ruby_process,process);
   name = RSTRING(rbName)->ptr;
   process->name = xbt_strdup(name);
   rb_process_bind(ruby_process,process);
   name = RSTRING(rbName)->ptr;
   process->name = xbt_strdup(name);
-  Data_Get_Struct(host,m_host_t,process->simdata->m_host);
+  Data_Get_Struct(host,s_m_host_t,process->simdata->m_host);
 
   if(!(process->simdata->m_host)) // Not Binded
   {
 
   if(!(process->simdata->m_host)) // Not Binded
   {
index 9334a12..0de3ffa 100644 (file)
 /*
 /*
- * $Id$
- *
- * Copyright 2010 Martin Quinson, Mehdi Fekari           
- * All right reserved. 
+ * Copyright 2010. The SimGrid Team. All right reserved.
  *
  * This program is free software; you can redistribute 
  * it and/or modify it under the terms of the license 
  *(GNU LGPL) which comes with this package. 
  */
  *
  * This program is free software; you can redistribute 
  * it and/or modify it under the terms of the license 
  *(GNU LGPL) which comes with this package. 
  */
-#include "rb_msg_task.h"
+#include "bindings/ruby_bindings.h"
 
 // Free Method
 
 // Free Method
-static void task_free(m_task_t tk) {
+void rb_task_free(m_task_t tk) {
   MSG_task_destroy(tk);
 }
 
 // New Method
   MSG_task_destroy(tk);
 }
 
 // New Method
-static VALUE task_new(VALUE class, VALUE name,VALUE comp_size,VALUE comm_size)
-{
-  
+VALUE rb_task_new(VALUE class, VALUE name,VALUE comp_size,VALUE comm_size) {
   //char * t_name = RSTRING(name)->ptr;
   m_task_t task = MSG_task_create(RSTRING(name)->ptr,NUM2INT(comp_size),NUM2INT(comm_size),NULL);
   // Wrap m_task_t to a Ruby Value
   //char * t_name = RSTRING(name)->ptr;
   m_task_t task = MSG_task_create(RSTRING(name)->ptr,NUM2INT(comp_size),NUM2INT(comm_size),NULL);
   // Wrap m_task_t to a Ruby Value
-  return Data_Wrap_Struct(class, 0, task_free, task);
+  return Data_Wrap_Struct(class, 0, rb_task_free, task);
 
 }
 
 //Get Computation Size
 
 }
 
 //Get Computation Size
-static VALUE task_comp(VALUE class,VALUE task)
-{
+VALUE rb_task_comp(VALUE class,VALUE task) {
   double size;
   m_task_t tk;
   // Wrap Ruby Value to m_task_t struct
   double size;
   m_task_t tk;
   // Wrap Ruby Value to m_task_t struct
-  Data_Get_Struct(task, m_task_t, tk);
+  Data_Get_Struct(task, s_m_task_t, tk);
   size = MSG_task_get_compute_duration(tk);
   return rb_float_new(size);
 }
 
 //Get Name
   size = MSG_task_get_compute_duration(tk);
   return rb_float_new(size);
 }
 
 //Get Name
-static VALUE task_name(VALUE class,VALUE task)
-{
+VALUE rb_task_name(VALUE class,VALUE task) {
   
   // Wrap Ruby Value to m_task_t struct
   m_task_t tk;
   
   // Wrap Ruby Value to m_task_t struct
   m_task_t tk;
-  Data_Get_Struct(task, m_task_t, tk);
+  Data_Get_Struct(task, s_m_task_t, tk);
   return rb_str_new2(MSG_task_get_name(tk));
   return rb_str_new2(MSG_task_get_name(tk));
-   
 }
 
 // Execute Task
 }
 
 // Execute Task
-static VALUE task_execute(VALUE class,VALUE task)
-{
+VALUE rb_task_execute(VALUE class,VALUE task) {
   
   // Wrap Ruby Value to m_task_t struct
   m_task_t tk;
   
   // Wrap Ruby Value to m_task_t struct
   m_task_t tk;
-  Data_Get_Struct(task, m_task_t, tk);
+  Data_Get_Struct(task, s_m_task_t, tk);
   return INT2NUM(MSG_task_execute(tk));
   return INT2NUM(MSG_task_execute(tk));
-  
 }
 
 // Sending Task
 }
 
 // Sending Task
-static void task_send(VALUE class,VALUE task,VALUE mailbox)
-{
+void rb_task_send(VALUE class,VALUE task,VALUE mailbox) {
   
   // Wrap Ruby Value to m_task_t struct
   m_task_t tk;
   
   // Wrap Ruby Value to m_task_t struct
   m_task_t tk;
-  Data_Get_Struct(task, m_task_t, tk);
+  Data_Get_Struct(task, s_m_task_t, tk);
   int res = MSG_task_send(tk,RSTRING(mailbox)->ptr);
   if(res != MSG_OK)
    rb_raise(rb_eRuntimeError,"MSG_task_send failed");
   int res = MSG_task_send(tk,RSTRING(mailbox)->ptr);
   if(res != MSG_OK)
    rb_raise(rb_eRuntimeError,"MSG_task_send failed");
-  
-  return;
 }
 
 }
 
-// Recieving Task 
-
-/**
-*It Return a Task 
-*/
-
-static VALUE task_receive(VALUE class,VALUE mailbox)
-{
+// Receiving Task (returns a Task)
+VALUE rb_task_receive(VALUE class,VALUE mailbox) {
   // Task
   m_task_t task = NULL;
   MSG_task_receive(&task,RSTRING(mailbox)->ptr);
   // Task
   m_task_t task = NULL;
   MSG_task_receive(&task,RSTRING(mailbox)->ptr);
-  return Data_Wrap_Struct(class, 0, task_free, task);
+  return Data_Wrap_Struct(class, 0, rb_task_free, task);
 }
 
 // Recieve Task 2
 // Not Appreciated 
 }
 
 // Recieve Task 2
 // Not Appreciated 
-static void task_receive2(VALUE class,VALUE task,VALUE mailbox)
-{
+void rb_task_receive2(VALUE class,VALUE task,VALUE mailbox) {
   m_task_t tk;
   m_task_t tk;
-  Data_Get_Struct(task, m_task_t, tk);
+  Data_Get_Struct(task, s_m_task_t, tk);
   MSG_task_receive(&tk,RSTRING(mailbox)->ptr);
   MSG_task_receive(&tk,RSTRING(mailbox)->ptr);
-  
 }
 
 // It Return a Native Process ( m_process_t )
 }
 
 // It Return a Native Process ( m_process_t )
-static VALUE task_sender(VALUE class,VALUE task)
-{
+VALUE rb_task_sender(VALUE class,VALUE task) {
   m_task_t tk;
   m_task_t tk;
-  Data_Get_Struct(task,m_task_t,tk);
-  return MSG_task_get_sender(tk);
-  
+  Data_Get_Struct(task,s_m_task_t,tk);
+  THROW_UNIMPLEMENTED;
+  return 0;//MSG_task_get_sender(tk);
 }
 
 // it return a Host 
 }
 
 // it return a Host 
-static VALUE task_source(VALUE class,VALUE task)
-{
+VALUE rb_task_source(VALUE class,VALUE task) {
   m_task_t tk;
   m_task_t tk;
-  Data_Get_Struct(task,m_task_t,tk);
+  Data_Get_Struct(task,s_m_task_t,tk);
   
   m_host_t host = MSG_task_get_source(tk);
   
   m_host_t host = MSG_task_get_source(tk);
-  if(!host->data)
-  {
+  if(!host->data) {
     rb_raise(rb_eRuntimeError,"MSG_task_get_source() failed");
     return Qnil;
   }
     rb_raise(rb_eRuntimeError,"MSG_task_get_source() failed");
     return Qnil;
   }
-  return host;
-  
+  THROW_UNIMPLEMENTED;
+  return 0;//host;
 }
 
 // Return Boolean
 }
 
 // Return Boolean
-static VALUE task_listen(VALUE class,VALUE task,VALUE alias)
-{
+VALUE rb_task_listen(VALUE class,VALUE task,VALUE alias) {
  m_task_t tk;
  const char *p_alias;
  int rv;
  
  m_task_t tk;
  const char *p_alias;
  int rv;
  
- Data_Get_Struct(task,m_task_t,tk);
+ Data_Get_Struct(task,s_m_task_t,tk);
  p_alias = RSTRING(alias)->ptr;
  
  rv = MSG_task_listen(p_alias);
  p_alias = RSTRING(alias)->ptr;
  
  rv = MSG_task_listen(p_alias);
@@ -137,51 +112,25 @@ static VALUE task_listen(VALUE class,VALUE task,VALUE alias)
  if(rv) return Qtrue;
  
  return Qfalse;
  if(rv) return Qtrue;
  
  return Qfalse;
-
 }
 
 // return Boolean
 }
 
 // return Boolean
-static VALUE task_listen_host(VALUE class,VALUE task,VALUE alias,VALUE host)
-{
+VALUE rb_task_listen_host(VALUE class,VALUE task,VALUE alias,VALUE host) {
   
  m_task_t tk;
  m_host_t ht;
  const char *p_alias;
  int rv;
  
   
  m_task_t tk;
  m_host_t ht;
  const char *p_alias;
  int rv;
  
- Data_Get_Struct(task,m_task_t,tk);
- Data_Get_Struct(host,m_host_t,ht);
+ Data_Get_Struct(task,s_m_task_t,tk);
+ Data_Get_Struct(host,s_m_host_t,ht);
  p_alias = RSTRING(alias)->ptr;
  
  rv = MSG_task_listen_from_host(p_alias,ht);
  
  p_alias = RSTRING(alias)->ptr;
  
  rv = MSG_task_listen_from_host(p_alias,ht);
  
- if (rv) return Qtrue;
+ if (rv)
+   return Qtrue;
  return Qfalse;
  return Qfalse;
 }
 
 
 }
 
 
-// Put
-static void task_put(VALUE class,VALUE task,VALUE host)
-{
-  
- m_task_t tk;
- m_host_t ht;
- Data_Get_Struct(task,m_task_t,tk);
- Data_Get_Struct(host,m_host_t,ht);
- MSG_task_put(tk,ht,PORT_22);  //Channel set to 0
-}
-
-//get 
-static VALUE task_get(VALUE class)
-{
-  
- m_task_t task = NULL;
- int res = MSG_task_get(&task,PORT_22); // Channel set to 0
- xbt_assert0(res == MSG_OK, "MSG_task_get failed");
- return Data_Wrap_Struct(class, 0, task_free, task);
-}
diff --git a/src/bindings/ruby/rb_msg_task.h b/src/bindings/ruby/rb_msg_task.h
deleted file mode 100644 (file)
index 131196d..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-#ifndef RB_MSG_TASK_H
-#define RB_MSG_TASK_H
-
-#include <ruby.h>
-#include <stdio.h>
-#include "msg/msg.h"
-#include "msg/datatypes.h"
-#include "xbt/sysdep.h"        
-#include "xbt/log.h"
-#include "xbt/asserts.h"
-
-typedef enum {
-  PORT_22 = 0,
-  MAX_CHANNEL
-} channel_t;
-
-// Free Method
-static void task_free(m_task_t tk);
-
-// New Method  >>> Data NULL
-static VALUE task_new(VALUE Class, VALUE name,VALUE comp_size,VALUE comm_size);
-
-//Get Computation Size
-static VALUE task_comp(VALUE Class,VALUE task);
-
-//Get Name
-static VALUE task_name(VALUE Class,VALUE task);
-
-// Execute Task
-static VALUE task_execute(VALUE Class,VALUE task);
-
-// Sending Task 
-static void task_send(VALUE Class,VALUE task,VALUE mailbox);
-
-// Recieve : return a task
-static VALUE task_receive(VALUE Class,VALUE mailbox);
-
-// Recieve Task 2 <<  Not Appreciated 
-static void task_receive2(VALUE Class,VALUE task,VALUE mailbox);
-
-// Get Sender
-static VALUE task_sender(VALUE Class,VALUE task);
-
-// Get Source
-static VALUE task_source(VALUE Class,VALUE task);
-
-//Listen From Alias
-static VALUE task_listen(VALUE Class,VALUE task,VALUE alias);
-
-//Listen from Host
-static VALUE task_listen_host(VALUE Class,VALUE task,VALUE alias,VALUE host);
-
-// put
-static void task_put(VALUE Class,VALUE task,VALUE host);
-
-//get
-static VALUE task_get(VALUE Class);
-#endif
\ No newline at end of file
index 82a8e30..fca1ace 100644 (file)
@@ -102,5 +102,19 @@ void  rb_host_set_data(VALUE Class,VALUE host,VALUE data);
 VALUE rb_host_get_data(VALUE Class,VALUE host);
 VALUE rb_host_is_avail(VALUE Class,VALUE host);
 
 VALUE rb_host_get_data(VALUE Class,VALUE host);
 VALUE rb_host_is_avail(VALUE Class,VALUE host);
 
+/* Functions related to tasks */
+void rb_task_free(m_task_t tk);
+// New Method  >>> Data NULL
+VALUE rb_task_new(VALUE Class, VALUE name,VALUE comp_size,VALUE comm_size);
+VALUE rb_task_comp(VALUE Class,VALUE task); // Get Computation Size
+VALUE rb_task_name(VALUE Class,VALUE task);
+VALUE rb_task_execute(VALUE Class,VALUE task);
+void  rb_task_send(VALUE Class,VALUE task,VALUE mailbox);
+VALUE rb_task_receive(VALUE Class,VALUE mailbox);// Receive : return a task
+void  rb_task_receive2(VALUE Class,VALUE task,VALUE mailbox);// Receive Task 2 <<  Not Appreciated
+VALUE rb_task_sender(VALUE Class,VALUE task);
+VALUE rb_task_source(VALUE Class,VALUE task);
+VALUE rb_task_listen(VALUE Class,VALUE task,VALUE alias); //Listen From Alias (=mailbox)
+VALUE rb_task_listen_host(VALUE Class,VALUE task,VALUE alias,VALUE host); //Listen from Host
 
 #endif /* RB_SG_BINDINGS */
 
 #endif /* RB_SG_BINDINGS */
index 499a8ad..d47c1b1 100644 (file)
@@ -25,7 +25,7 @@
 // FIXME: better location for that
 extern void MSG_register(lua_State *L);
 
 // FIXME: better location for that
 extern void MSG_register(lua_State *L);
 
-XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(smx_lua);
+XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(lua);
 
 typedef struct s_smx_ctx_sysv {
   SMX_CTX_BASE_T;
 
 typedef struct s_smx_ctx_sysv {
   SMX_CTX_BASE_T;