1 /* SimGrid -- Ruby bindings */
3 /* Copyright (c) 2010, the SimGrid team. All right reserved */
5 /* This program is free software; you can redistribute it and/or modify it
6 * under the terms of the license (GNU LGPL) which comes with this package. */
10 #define RB_SG_BINDINGS
12 * There is 4 sections in this file:
13 * - Header loading (ruby makes it quite difficult, damn it)
14 * - definitions of ruby contextes for use in simix
15 * - Functions to Manage The Ruby Process (named Up Calls)
16 * - Functions to Manage The Native Process Simulation Bound (named Down Calls)
20 #include "msg/datatypes.h"
22 //#include "msg/private.h"
23 //#include "msg/mailbox.h"
24 #include "surf/surfxml_parse.h"
25 #include "simix/simix.h"
26 #include "simix/private.h"
27 #include "xbt/sysdep.h"
29 #include "xbt/asserts.h"
30 //#include "rb_msg_host.h"
32 /* Damn Ruby. They load their full config.h, which breaks since we also load ours.
33 * So, we undef the offending defines
35 #undef PACKAGE_VERSION
37 #undef PACKAGE_TARNAME
39 #undef PACKAGE_BUGREPORT
45 /* ********************* *
46 * Context related stuff *
47 * ********************* */
48 typedef struct s_smx_ctx_ruby {
50 VALUE process; // The Ruby Process Instance
52 }s_smx_ctx_ruby_t,*smx_ctx_ruby_t;
53 void SIMIX_ctx_ruby_factory_init(smx_context_factory_t *factory);
56 void initRuby(void); // Mandatory to call Ruby methods from C
58 /* *********************************************** *
59 * Functions for Ruby Process Management (Up Call) *
61 * Independent Methods *
62 * *********************************************** */
64 VALUE rb_process_getName( VALUE ruby_process );
65 VALUE rb_process_getID(VALUE ruby_process);
66 VALUE rb_process_getBind(VALUE ruby_class);
67 void rb_process_setBind(VALUE ruby_class,long bind);
68 VALUE rb_process_isAlive(VALUE ruby_process);
69 void rb_process_kill(VALUE ruby_process);
70 void rb_process_join( VALUE ruby_process );
71 void rb_process_unschedule( VALUE ruby_process );
72 void rb_process_schedule( VALUE ruby_process );
75 /* ********************************************** *
76 * Function for Native Process (Bound) Management *
78 * Methods Belonging to The MSG Module *
79 * ********************************************** */
81 // ProcessBind Method ; Process Ruby >> Process C
83 //friend Method // Not belong to the Class but Called within !!
84 m_process_t rb_process_to_native(VALUE ruby_process);
86 // Binding Process >> Friend Method
87 void rb_processBind(VALUE ruby_class,m_process_t process);
89 // CreateProcess Method
90 void rb_processCreate(VALUE Class,VALUE rb_process,VALUE host);
93 void rb_processSuspend(VALUE Class,VALUE ruby_process);
96 void rb_processResume(VALUE Class,VALUE ruby_process);
98 //ProcessIsSuspend return Boolean ( Qtrue / Qfalse )
99 VALUE rb_processIsSuspend(VALUE Class,VALUE ruby_process);
102 void rb_processKill(VALUE Class,VALUE ruby_process);
105 VALUE rb_processGetHost(VALUE Class,VALUE ruby_process);
108 void rb_processExit(VALUE Class,VALUE ruby_process);
110 #endif /* RB_SG_BINDINGS */