Module: PyBind
- Extended by:
- Utils
- Defined in:
- lib/pybind.rb,
lib/pybind/init.rb,
lib/pybind/error.rb,
lib/pybind/types.rb,
lib/pybind/utils.rb,
lib/pybind/import.rb,
lib/pybind/struct.rb,
lib/pybind/version.rb,
lib/pybind/wrapper.rb,
lib/pybind/autocall.rb,
lib/pybind/typecast.rb,
lib/pybind/libpython.rb,
lib/pybind/types/set.rb,
lib/pybind/types/dict.rb,
lib/pybind/types/list.rb,
lib/pybind/types/basic.rb,
lib/pybind/types/slice.rb,
lib/pybind/types/tuple.rb,
lib/pybind/types/object.rb,
lib/pybind/types/function.rb,
lib/pybind/types/sequence.rb,
lib/pybind/wrapper/operator.rb,
lib/pybind/wrapper/attr_accessor.rb,
lib/pybind/wrapper/rich_comparer.rb
Defined Under Namespace
Modules: AttrAccessor, Import, LibPython, Operator, PyCallable, PyClassWrapper, PyObjectClassMethods, PyObjectWrapper, PySequence, RichComparer, TypeCast, Types, Utils Classes: PyBool, PyBuiltinFunction, PyComplex, PyDict, PyError, PyFloat, PyFunction, PyInt, PyList, PyMethod, PyObject, PyObjectStruct, PySet, PySlice, PyString, PyTuple, PyType, PyUnicode
Constant Summary collapse
- VERSION =
'0.1.0'.freeze
- PYTHON_DESCRIPTION =
LibPython.Py_GetVersion().freeze
- PYTHON_VERSION =
PYTHON_DESCRIPTION.split(' ', 2)[0].freeze
Constants included from Utils
Utils::BUILTIN_FUNCS, Utils::MODULE_SHORTCUTS
Class Attribute Summary collapse
-
.builtin ⇒ Object
readonly
Returns the value of attribute builtin.
Class Method Summary collapse
Methods included from Utils
False, None, True, callable?, decref, eval, execfile, incref
Class Attribute Details
.builtin ⇒ Object (readonly)
Returns the value of attribute builtin.
5 6 7 |
# File 'lib/pybind/init.rb', line 5 def builtin @builtin end |
Class Method Details
.__initialize_pybind__ ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/pybind/init.rb', line 8 def self.__initialize_pybind__ initialized = (0 != LibPython.Py_IsInitialized()) return if initialized LibPython.Py_InitializeEx(0) FFI::MemoryPointer.new(:pointer, 1) do |argv| argv.write_pointer(FFI::MemoryPointer.from_string('')) LibPython.PySys_SetArgvEx(0, argv, 0) end @builtin = LibPython.PyImport_ImportModule(PYTHON_VERSION < '3.0.0' ? '__builtin__' : 'builtins').to_ruby end |
.import(name) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/pybind/import.rb', line 38 def self.import(name) name = name.to_s if name.is_a? Symbol raise TypeError, 'name must be a String' unless name.is_a? String value = LibPython.PyImport_ImportModule(name) raise PyError.fetch if value.null? value = value.to_ruby return value unless block_given? begin yield value ensure PyBind.decref(value) end end |
.parse_traceback(traceback) ⇒ Object
34 35 36 37 |
# File 'lib/pybind/error.rb', line 34 def self.parse_traceback(traceback) format_tb_func = PyBind.traceback.get_attribute('format_tb') format_tb_func.call(traceback).to_a end |