Commit 46e82ddb authored by André Anjos's avatar André Anjos 💬
Browse files

Use cleanup from xbob.blitz

parent 2ac64d33
/**
* @author Andre Anjos <andre.anjos@idiap.ch>
* @date Wed 11 Dec 08:42:53 2013
*
* @brief Some C++ tricks to make our life dealing with Python references a bit
* easier
*/
#include <Python.h>
#include <memory>
/**
* Calls Py_DECREF(x) on the input object x. Usage pattern:
*
* PyObject* x = ... // builds x with a new python reference
* auto protected_x = make_safe(x);
*
* After this point, no need to worry about DECREF'ing x anymore.
* You can still use `x' inside your code, or protected_x.get().
*/
template <typename T> std::shared_ptr<T> make_safe(T* o) {
return std::shared_ptr<T>(o, [&](T* p){Py_DECREF(p);});
}
/**
* Calls Py_XDECREF(x) on the input object x. Usage pattern:
*
* PyObject* x = ... // builds x with a new python reference, x may be NULL
* auto protected_x = make_xsafe(x);
*
* After this point, no need to worry about XDECREF'ing x anymore.
* You can still use `x' inside your code, or protected_x.get(). Note
* `x' may be NULL with this method.
*/
template <typename T> std::shared_ptr<T> make_xsafe(T* o) {
return std::shared_ptr<T>(o, [&](T* p){Py_XDECREF(p);});
}
......@@ -8,9 +8,9 @@
* Copyright (C) 2011-2013 Idiap Research Institute, Martigny, Switzerland
*/
#include "cleanup.h"
#include "histogram.h"
#include <xbob.blitz/cppapi.h>
#include <xbob.blitz/cleanup.h>
#include "bob/math/histogram.h"
static PyObject* py_histogram_intersection_1
......
......@@ -8,9 +8,9 @@
* Copyright (C) 2011-2013 Idiap Research Institute, Martigny, Switzerland
*/
#include "cleanup.h"
#include "histogram.h"
#include <xbob.blitz/cppapi.h>
#include <xbob.blitz/cleanup.h>
#include "bob/math/linsolve.h"
static PyObject* py_linsolve_1(PyObject*, PyObject* args, PyObject* kwds) {
......
......@@ -9,9 +9,9 @@
* Copyright (C) 2011-2013 Idiap Research Institute, Martigny, Switzerland
*/
#include "cleanup.h"
#include "lp_interior_point.h"
#include <xbob.blitz/cppapi.h>
#include <xbob.blitz/cleanup.h>
#include <bob/math/LPInteriorPoint.h>
#include <structmember.h>
......
......@@ -6,9 +6,9 @@
* @brief Binds the Pool-Adjacent-Violators Algorithm
*/
#include "cleanup.h"
#include "pavx.h"
#include <xbob.blitz/cppapi.h>
#include <xbob.blitz/cleanup.h>
#include "bob/math/pavx.h"
#include "bob/core/cast.h"
......
......@@ -7,9 +7,9 @@
* Copyright (C) 2011-2013 Idiap Research Institute, Martigny, Switzerland
*/
#include "cleanup.h"
#include "scatter.h"
#include <xbob.blitz/cppapi.h>
#include <xbob.blitz/cleanup.h>
#include <bob/math/stats.h>
PyObject* py_scatter (PyObject*, PyObject* args, PyObject* kwds) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment