if(enable_ruby)
include(FindRuby)
if(RUBY_LIBRARY)
- if(RUBY_VERSION_MAJOR MATCHES "1" AND RUBY_VERSION_MINOR MATCHES "8")
+ if(RUBY_VERSION_MAJOR MATCHES "1" AND RUBY_VERSION_MINOR MATCHES "9")
set(LIB_RUBY_VERSION "${RUBY_VERSION_MAJOR}.${RUBY_VERSION_MINOR}.${RUBY_VERSION_PATCH}")
string(REGEX MATCH "ruby.*[0-9]" RUBY_LIBRARY_NAME ${RUBY_LIBRARY})
if(NOT RUBY_LIBRARY_NAME)
endif(NOT operation)
ADD_DEFINITIONS("-I${CMAKE_HOME_DIRECTORY}/src/bindings/ruby -I${CMAKE_HOME_DIRECTORY}/src/simix")
SET(HAVE_RUBY 1)
- else(RUBY_VERSION_MAJOR MATCHES "1" AND RUBY_VERSION_MINOR MATCHES "8")
- message("Ruby binding need version 1.8.x actually version ${RUBY_VERSION_MAJOR}.${RUBY_VERSION_MINOR}.x")
+ else(RUBY_VERSION_MAJOR MATCHES "1" AND RUBY_VERSION_MINOR MATCHES "9")
+ message("Ruby binding need version 1.9.x actually version ${RUBY_VERSION_MAJOR}.${RUBY_VERSION_MINOR}.x")
SET(HAVE_RUBY 0)
- endif(RUBY_VERSION_MAJOR MATCHES "1" AND RUBY_VERSION_MINOR MATCHES "8")
+ endif(RUBY_VERSION_MAJOR MATCHES "1" AND RUBY_VERSION_MINOR MATCHES "9")
else(RUBY_LIBRARY)
SET(HAVE_RUBY 0)
endif(RUBY_LIBRARY)
{
ruby_init();
ruby_init_loadpath();
- char *p_className = RSTRING(fct_name)->ptr; // name of process is the one of the class
+ char *p_className = RSTRING_PTR(fct_name); // name of process is the one of the class
return rb_funcall(rb_const_get(rb_cObject, rb_intern(p_className)),
rb_intern("new"), 3, fct_name, arguments, properties);
}
if (!fct_name)
rb_raise(rb_eRuntimeError,
"Internal error: Process name cannot be NULL");
- name = RSTRING(fct_name)->ptr;
+ name = RSTRING_PTR(fct_name);
DEBUG1("Create native process %s", name);
char **argv = xbt_new(char *, 2);
- argv[0] = bprintf("%s@%s", name, RSTRING(ht_name)->ptr);
+ argv[0] = bprintf("%s@%s", name, RSTRING_PTR(ht_name));
argv[1] = NULL;
// Allocate the data for the simulation
process = MSG_process_create_with_arguments(name,
(xbt_main_func_t) ruby_process,
process,
- MSG_get_host_by_name(RSTRING(ht_name)->ptr),
+ MSG_get_host_by_name(RSTRING_PTR(ht_name)),
1, argv);
// Bind The Ruby Process instance to The Native Process
VALUE rb_host_get_by_name(VALUE class, VALUE name)
{
- const char *h_name = RSTRING(name)->ptr;
+ const char *h_name = RSTRING_PTR(name);
m_host_t host = MSG_get_host_by_name(h_name);
- if (!host)
- rb_raise(rb_eRuntimeError,
- bprintf("No host called '%s' found", h_name));
+ if (!host){
+ char *message = bprintf("No host called '%s' found", h_name);
+ VALUE errorobj = rb_exc_new2(rb_eRuntimeError, message);
+ xbt_free(message);
+ rb_exc_raise(errorobj);
+ }
return Data_Wrap_Struct(class, 0, rb_host_free, host);
}
VALUE rb_task_new(VALUE class, VALUE name, VALUE comp_size,
VALUE comm_size)
{
- m_task_t task = MSG_task_create(RSTRING(name)->ptr, NUM2INT(comp_size),
+ m_task_t task = MSG_task_create(RSTRING_PTR(name), NUM2INT(comp_size),
NUM2INT(comm_size), NULL);
rb_data_t data = malloc(sizeof(s_ruby_data_t));
data->ruby_task = NULL;
data->ruby_task = (void *) task;
MSG_task_set_data(tk, (void *) data);
DEBUG1("Sending task %p", tk);
- rv = MSG_task_send(tk, RSTRING(mailbox)->ptr);
+ rv = MSG_task_send(tk, RSTRING_PTR(mailbox));
if (rv != MSG_OK) {
if (rv == MSG_TRANSFER_FAILURE)
rb_raise(rb_eRuntimeError, "Transfer failure while Sending");
*ptask = NULL;
rb_data_t data = NULL;
DEBUG2("Receiving a task on mailbox '%s', store it into %p",
- RSTRING(mailbox)->ptr, &task);
- MSG_task_receive(ptask, RSTRING(mailbox)->ptr);
+ RSTRING_PTR(mailbox), &task);
+ MSG_task_receive(ptask, RSTRING_PTR(mailbox));
task = *ptask;
free(ptask);
data = MSG_task_get_data(task);
int rv;
Data_Get_Struct(task, s_m_task_t, tk);
- p_alias = RSTRING(alias)->ptr;
+ p_alias = RSTRING_PTR(alias);
rv = MSG_task_listen(p_alias);
Data_Get_Struct(task, s_m_task_t, tk);
Data_Get_Struct(host, s_m_host_t, ht);
- p_alias = RSTRING(alias)->ptr;
+ p_alias = RSTRING_PTR(alias);
rv = MSG_task_listen_from_host(p_alias, ht);
if (rv)
return Qtrue;
"Bad arguments to msg_init (expecting an array)");
return;
}
- ptr = RARRAY(args)->ptr;
- argc = RARRAY(args)->len;
+ ptr = RARRAY_PTR(args);
+ argc = RARRAY_LEN(args);
// Create C array to hold data_get_struct
argc++;
argv = xbt_new0(char *, argc);
VALUE value = ptr[i];
type = TYPE(value);
// if (type == T_STRING)
- tmp = RSTRING(value)->ptr;
+ tmp = RSTRING_PTR(value);
argv[i + 1] = strdup(tmp);
}
// Calling C Msg_Init Method
int type = TYPE(plateformFile);
if (type != T_STRING)
rb_raise(rb_eRuntimeError, "Bad Argument's Type");
- const char *platform = RSTRING(plateformFile)->ptr;
+ const char *platform = RSTRING_PTR(plateformFile);
MSG_create_environment(platform);
DEBUG1("Create Environment (%s)...Done", platform);
}
if (type != T_STRING)
rb_raise(rb_eRuntimeError,
"Bad Argument's Type for deployApplication ");
- const char *dep_file = RSTRING(deploymentFile)->ptr;
+ const char *dep_file = RSTRING_PTR(deploymentFile);
surf_parse_reset_parser();
surfxml_add_callback(STag_surfxml_process_cb_list,
rb_application_handler_on_begin_process);
// INFO
static void msg_info(VALUE class, VALUE msg)
{
- const char *s = RSTRING(msg)->ptr;
+ const char *s = RSTRING_PTR(msg);
INFO1("%s", s);
}
static void msg_debug(VALUE class, VALUE msg)
{
- const char *s = RSTRING(msg)->ptr;
+ const char *s = RSTRING_PTR(msg);
DEBUG1("%s", s);
}