Module: RubyPythonBridge

Defined in:
ext/rubypython_bridge/rubypython_bridge.c

Defined Under Namespace

Classes: RubyPyClass, RubyPyFunction, RubyPyModule, RubyPyObject

Class Method Summary collapse

Class Method Details

.func(args) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'ext/rubypython_bridge/rubypython_bridge.c', line 8

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 a python file_module 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);
}

.import_module(module) ⇒ Object



20
21
22
23
24
# File 'ext/rubypython_bridge/rubypython_bridge.c', line 20

static VALUE rp_import_module(VALUE self,VALUE module)
{
  VALUE instance=rb_class_instance_new(1,&module,cRubyPyModule);
  return instance;
}

.runObject



39
40
41
42
43
44
45
# File 'ext/rubypython_bridge/rubypython_bridge.c', line 39

static VALUE rp_python_block(VALUE self)
{
  rb_funcall(self,rb_intern("start"),0);
  rb_obj_instance_eval(0,NULL,self);
  rb_funcall(self,rb_intern("stop"),0);
  
}

.startObject

Starts the python interpreter RubyPythonBridge.start



55
56
57
58
59
60
61
62
63
64
65
# File 'ext/rubypython_bridge/rubypython_bridge.c', line 55

VALUE rp_start(VALUE self)
{
  

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

.stopObject



67
68
69
70
71
72
73
74
75
76
77
# File 'ext/rubypython_bridge/rubypython_bridge.c', line 67

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