lib/pycall/libpython.rb in pycall-0.1.0.alpha.20170224 vs lib/pycall/libpython.rb in pycall-0.1.0.alpha.20170226
- old
+ new
@@ -126,66 +126,61 @@
attach_variable :PyList_Type, PyTypeObject
attach_variable :PyTuple_Type, PyTypeObject
attach_variable :PyDict_Type, PyTypeObject
attach_variable :PySet_Type, PyTypeObject
+ attach_variable :PyFunction_Type, PyTypeObject
+ attach_variable :PyMethod_Type, PyTypeObject
+
# --- functions ---
attach_function :Py_GetVersion, [], :string
-
- # Py_InitializeEx :: (int) -> void
attach_function :Py_InitializeEx, [:int], :void
-
- # Py_IsInitialized :: () -> int
attach_function :Py_IsInitialized, [], :int
- # Comparing two objects
- attach_function :PyObject_RichCompare, [PyObject.by_ref, PyObject.by_ref, :int], PyObject.by_ref
+ # Object
- # Accessing Object's attributes
+ attach_function :PyObject_RichCompare, [PyObject.by_ref, PyObject.by_ref, :int], PyObject.by_ref
attach_function :PyObject_GetAttrString, [PyObject.by_ref, :string], PyObject.by_ref
attach_function :PyObject_SetAttrString, [PyObject.by_ref, :string, PyObject.by_ref], :int
attach_function :PyObject_HasAttrString, [PyObject.by_ref, :string], :int
-
- # Accessing Object's items
attach_function :PyObject_GetItem, [PyObject.by_ref, PyObject.by_ref], PyObject.by_ref
attach_function :PyObject_SetItem, [PyObject.by_ref, PyObject.by_ref, PyObject.by_ref], :int
attach_function :PyObject_DelItem, [PyObject.by_ref, PyObject.by_ref], :int
-
- # Calling a object as a function
attach_function :PyObject_Call, [PyObject.by_ref, PyObject.by_ref, PyObject.by_ref], PyObject.by_ref
+ attach_function :PyObject_IsInstance, [PyObject.by_ref, PyObject.by_ref], :int
+ attach_function :PyObject_Dir, [PyObject.by_ref], PyObject.by_ref
+ attach_function :PyObject_Repr, [PyObject.by_ref], PyObject.by_ref
+ attach_function :PyObject_Str, [PyObject.by_ref], PyObject.by_ref
+ attach_function :PyObject_Type, [PyObject.by_ref], PyTypeObject.by_ref
- # PyObject_IsInstane :: (PyPtr, PyPtr) -> int
- attach_function :PyObject_IsInstance, [PyObject.by_ref, PyTypeObject.by_ref], :int
+ # Bool
- # PyBool_FromLong :: (long) -> PyPtr
attach_function :PyBool_FromLong, [:long], PyObject.by_ref
- # PyInt_AsSsize_t :: (PyPtr) -> ssize_t
+ # Integer
+
if has_PyInt_Type
attach_function :PyInt_AsSsize_t, [PyObject.by_ref], :ssize_t
else
attach_function :PyInt_AsSsize_t, :PyLong_AsSsize_t, [PyObject.by_ref], :ssize_t
end
- # PyInt_FromSsize_t :: (ssize_t) -> PyPtr
if has_PyInt_Type
attach_function :PyInt_FromSsize_t, [:ssize_t], PyObject.by_ref
else
attach_function :PyInt_FromSsize_t, :PyLong_FromSsize_t, [:ssize_t], PyObject.by_ref
end
- # PyFloat_FromDouble :: (double) -> PyPtr
- attach_function :PyFloat_FromDouble, [:double], PyObject.by_ref
+ # Float
- # PyFloat_AsDouble :: (PyPtr) -> double
+ attach_function :PyFloat_FromDouble, [:double], PyObject.by_ref
attach_function :PyFloat_AsDouble, [PyObject.by_ref], :double
- # PyComplex_RealAsDouble :: (PyPtr) -> double
- attach_function :PyComplex_RealAsDouble, [PyObject.by_ref], :double
+ # Complex
- # PyComplex_ImagAsDouble :: (PyPtr) -> double
+ attach_function :PyComplex_RealAsDouble, [PyObject.by_ref], :double
attach_function :PyComplex_ImagAsDouble, [PyObject.by_ref], :double
# String
if string_as_bytes
@@ -211,11 +206,11 @@
attach_function :PyUnicodeUCS4_DecodeUTF8, [:string, :ssize_t, :string], PyObject.by_ref
when libpython.find_symbol('PyUnicodeUCS2_DecodeUTF8')
attach_function :PyUnicodeUCS2_DecodeUTF8, [:string, :ssize_t, :string], PyObject.by_ref
end
- # PyUnicode_AsUTF8String :: (PyPtr) -> PyPtr
+ # PyUnicode_AsUTF8String
case
when libpython.find_symbol('PyUnicode_AsUTF8String')
attach_function :PyUnicode_AsUTF8String, [PyObject.by_ref], PyObject.by_ref
when libpython.find_symbol('PyUnicodeUCS4_AsUTF8String')
attach_function :PyUnicode_AsUTF8String, :PyUnicodeUCS4_AsUTF8String, [PyObject.by_ref], PyObject.by_ref
@@ -240,85 +235,60 @@
attach_function :PyList_Size, [PyObject.by_ref], :ssize_t
attach_function :PyList_GetItem, [PyObject.by_ref, :ssize_t], PyObject.by_ref
attach_function :PyList_SetItem, [PyObject.by_ref, :ssize_t, PyObject.by_ref], :int
attach_function :PyList_Append, [PyObject.by_ref, PyObject.by_ref], :int
- # PySequence_Size :: (PyPtr) -> ssize_t
- attach_function :PySequence_Size, [PyObject.by_ref], :ssize_t
+ # Sequence
- # PySequence_GetItem :: (PyPtr, ssize_t) -> PyPtr
+ attach_function :PySequence_Size, [PyObject.by_ref], :ssize_t
attach_function :PySequence_GetItem, [PyObject.by_ref, :ssize_t], PyObject.by_ref
+ attach_function :PySequence_Contains, [PyObject.by_ref, PyObject.by_ref], :int
# Dict
attach_function :PyDict_New, [], PyObject.by_ref
-
- # PyDict_GetItem :: (PyPtr, PyPtr) -> PyPtr
attach_function :PyDict_GetItem, [PyObject.by_ref, PyObject.by_ref], PyObject.by_ref
-
- # PyDict_GetItemString :: (PyPtr, char const*) -> PyPtr
attach_function :PyDict_GetItemString, [PyObject.by_ref, :string], PyObject.by_ref
-
- # PyDict_SetItem :: (PyPtr, PyPtr, PyPtr) -> int
attach_function :PyDict_SetItem, [PyObject.by_ref, PyObject.by_ref, PyObject.by_ref], :int
-
- # PyDict_SetItemString :: (PyPtr, char const*, PyPtr) -> int
attach_function :PyDict_SetItemString, [PyObject.by_ref, :string, PyObject.by_ref], :int
-
- # PyDict_DelItem :: (PyPtr, PyPtr) -> int
attach_function :PyDict_DelItem, [PyObject.by_ref, PyObject.by_ref], :int
-
- # PyDict_DelItemString :: (PyPtr, char const*) -> int
attach_function :PyDict_DelItem, [PyObject.by_ref, :string], :int
-
- # PyDict_Size :: (PyPtr) -> ssize_t
attach_function :PyDict_Size, [PyObject.by_ref], :ssize_t
-
- # PyDict_Keys :: (PyPtr) -> PyPtr
attach_function :PyDict_Keys, [PyObject.by_ref], PyObject.by_ref
-
- # PyDict_Values :: (PyPtr) -> PyPtr
attach_function :PyDict_Values, [PyObject.by_ref], PyObject.by_ref
-
- # PyDict_Items :: (PyPtr) -> PyPtr
attach_function :PyDict_Items, [PyObject.by_ref], PyObject.by_ref
-
- # PyDict_Contains :: (PyPtr, PyPtr) -> int
attach_function :PyDict_Contains, [PyObject.by_ref, PyObject.by_ref], :int
- # PySet_Size :: (PyPtr) -> ssize_t
- attach_function :PySet_Size, [PyObject.by_ref], :ssize_t
+ # Set
- # PySet_Contains :: (PyPtr, PyPtr) -> int
+ attach_function :PySet_Size, [PyObject.by_ref], :ssize_t
attach_function :PySet_Contains, [PyObject.by_ref, PyObject.by_ref], :int
-
- # PySet_Add :: (PyPtr, PyPtr) -> int
attach_function :PySet_Add, [PyObject.by_ref, PyObject.by_ref], :int
-
- # PySet_Discard :: (PyPtr, PyPtr) -> int
attach_function :PySet_Discard, [PyObject.by_ref, PyObject.by_ref], :int
- # PyModule_GetDict :: (PyPtr) -> PyPtr
+ # Module
+
attach_function :PyModule_GetDict, [PyObject.by_ref], PyObject.by_ref
- # PyImport_ImportModule :: (char const*) -> PyPtr
+ # Import
+
attach_function :PyImport_ImportModule, [:string], PyObject.by_ref
# Operators
attach_function :PyNumber_Add, [PyObject.by_ref, PyObject.by_ref], PyObject.by_ref
attach_function :PyNumber_Subtract, [PyObject.by_ref, PyObject.by_ref], PyObject.by_ref
attach_function :PyNumber_Multiply, [PyObject.by_ref, PyObject.by_ref], PyObject.by_ref
attach_function :PyNumber_TrueDivide, [PyObject.by_ref, PyObject.by_ref], PyObject.by_ref
- # Py_CompileString :: (char const*, char const*, int) -> PyPtr
- attach_function :Py_CompileString, [:string, :string, :int], PyObject.by_ref
+ # Compiler
- # PyEval_EvalCode :: (PyPtr, PyPtr, PyPtr) -> PyPtr
+ attach_function :Py_CompileString, [:string, :string, :int], PyObject.by_ref
attach_function :PyEval_EvalCode, [PyObject.by_ref, PyObject.by_ref, PyObject.by_ref], PyObject.by_ref
# Error
+ attach_function :PyErr_Clear, [], :void
attach_function :PyErr_Print, [], :void
attach_function :PyErr_Occurred, [], PyObject.by_ref
attach_function :PyErr_Fetch, [:pointer, :pointer, :pointer], :void
attach_function :PyErr_NormalizeException, [:pointer, :pointer, :pointer], :void