public
Created

Generic Ruby Embedding API

  • Download Gist
embed.h
C
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
/**
* VM supplies rb_ctx and rb_obj definitions here
*/
#include "vm_specific.h"
 
extern "C" {
 
/**
* Create a embedded ruby context
*/
rb_ctx rb_create_ctx();
 
/**
* Requires a ruby file (like require 'file' in ruby)
*
* Returns true if it executed without exception, false if there was an error.
* Finding out what went wrong will be defined later.
*/
int rb_require_file(rb_ctx ctx, const char * file);
 
/**
* Evaulate a ruby file
*
* Returns true if it executed without exception, false if there was an error.
* Finding out what went wrong will be defined later.
*/
int rb_eval_file(rb_ctx ctx, const char * file);
 
/**
* Evaluate a ruby string
*
* Returns true if it executed without exception, false if there was an error.
* Finding out what went wrong will be defined later.
*/
int rb_eval(rb_ctx ctx, const char * code);
 
/**
* Send a message to an object
*
* Send +msg+ to object +recv+ with arguments specified by +argc+ and the
* variadic parameters that follow. All arguments *must* be of type rb_obj.
*/
rb_obj rb_send(rb_ctx ctx, rb_obj recv, const char* msg, int argc, ...);
 
/**
* Clean up a context
*/
void rb_close_ctx(rb_ctx ctx);
 
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.