Sha256: 54505e42a6d28ef3d89a7a145bffd5a74e299939d98b4082d5a9fe69c8a6c7e8
Contents?: true
Size: 921 Bytes
Versions: 2
Compression:
Stored size: 921 Bytes
Contents
module PyCall module Eval Py_eval_input = 258 def self.eval(str, filename: "pycall") globals_ptr = maindict_ptr locals_ptr = maindict_ptr defer_sigint do py_code_ptr = LibPython.Py_CompileString(str, filename, Py_eval_input) LibPython.PyEval_EvalCode(py_code_ptr, globals_ptr, locals_ptr) end end class << self private def maindict_ptr LibPython.PyModule_GetDict(PyCall.import_module("__main__")) end def defer_sigint # TODO: should be implemented yield end end end def self.import_module(name) name = name.to_s if name.kind_of? Symbol raise TypeError, "name must be a String" unless name.kind_of? String value = LibPython.PyImport_ImportModule(name) return value.to_ruby unless value.null? raise PyError.fetch end def self.eval(str) Eval.eval(str).to_ruby end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pycall-0.1.0.alpha.20170224b | lib/pycall/eval.rb |
pycall-0.1.0.alpha.20170224 | lib/pycall/eval.rb |