Major refactoring

This commit is contained in:
Siu Kwan Lam 2013-01-25 12:29:31 -06:00
commit eba88b32ba
22 changed files with 999 additions and 924 deletions

View 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_

View file

@ -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){