Major refactoring
This commit is contained in:
parent
a3da74c416
commit
eba88b32ba
22 changed files with 999 additions and 924 deletions
38
newbinding/include/llvm_binding/auto_pyobject.h
Normal file
38
newbinding/include/llvm_binding/auto_pyobject.h
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
#ifndef AUTO_PYOBJECT_H_
|
||||
#define AUTO_PYOBJECT_H_
|
||||
|
||||
#include <Python.h>
|
||||
|
||||
class auto_pyobject{
|
||||
mutable PyObject* PO;
|
||||
public:
|
||||
auto_pyobject(): PO(NULL) { }
|
||||
|
||||
auto_pyobject(PyObject* po) : PO(po) { }
|
||||
|
||||
auto_pyobject(const auto_pyobject& other) : PO(*other){
|
||||
other.PO = NULL;
|
||||
}
|
||||
|
||||
~auto_pyobject() {
|
||||
Py_XDECREF(PO);
|
||||
}
|
||||
|
||||
bool operator ! () const {
|
||||
return !PO;
|
||||
}
|
||||
|
||||
PyObject* operator * () const {
|
||||
return PO;
|
||||
}
|
||||
|
||||
PyObject* get() const {
|
||||
return PO;
|
||||
}
|
||||
private:
|
||||
// disable assign
|
||||
void operator = (const auto_pyobject&);
|
||||
};
|
||||
|
||||
#endif AUTO_PYOBJECT_H_
|
||||
|
||||
|
|
@ -62,6 +62,11 @@ static
|
|||
PyObject* py_str_from(const std::string &str){
|
||||
return PyString_FromStringAndSize(str.c_str(), str.size());
|
||||
}
|
||||
//
|
||||
//static
|
||||
//PyObject* py_str_from(const llvm::StringRef *str){
|
||||
// return py_str_from(str->str());
|
||||
//}
|
||||
|
||||
static
|
||||
PyObject* py_bool_from(bool val){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue