Module: RubyPythonBridge

Defined in:
ext/rubypython_bridge/rubypython_bridge.c

Defined Under Namespace

Classes: RubyPyClass, RubyPyFunction, RubyPyInstance, RubyPyModule, RubyPyObject

Class Method Summary collapse

Class Method Details

.func(modname, funcname, *args) ⇒ Object

Given a python module name modname and a function name funcname calls the given function with the supplied arguments.

Use builtins as the module for a built in function.



17
18
19
20
21
22
23
24
25
26
27
# File 'ext/rubypython_bridge/rubypython_bridge.c', line 17

static VALUE func_with_module(VALUE self, VALUE args)
{
  int started_here=safe_start();
  VALUE module,func,return_val;
  if(RARRAY(args)->len<2) return Qfalse;
  module=rb_ary_shift(args);
  func=rb_ary_shift(args);
  return_val=rp_call_func_with_module_name(module,func,args);
  safe_stop(started_here);
  return return_val;
}

.import(modname) ⇒ Object

Imports the python module modname using the interpreter and returns a ruby wrapper



34
35
36
37
# File 'ext/rubypython_bridge/rubypython_bridge.c', line 34

static VALUE rp_import(VALUE self,VALUE mname)
{
  return rb_class_new_instance(1,&mname,cRubyPyModule);
}

.startObject

Starts the python interpreter



44
45
46
47
48
49
50
51
52
53
54
# File 'ext/rubypython_bridge/rubypython_bridge.c', line 44

VALUE rp_start(VALUE self)
{
  

  if(Py_IsInitialized())
  {
    return Qfalse;
  }
  Py_Initialize();
  return Qtrue;
}

.stopObject

Stop the python interpreter



61
62
63
64
65
66
67
68
69
70
71
# File 'ext/rubypython_bridge/rubypython_bridge.c', line 61

VALUE rp_stop(VALUE self)
{
  
  if(Py_IsInitialized())
  {
    Py_Finalize();
    return Qtrue;
  }
  return Qfalse;
  
}