Page Menu
Home
HEPForge
Search
Configure Global Search
Log In
Files
F19251297
pyWrapUtils.hh
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
pyWrapUtils.hh
View Options
#ifndef NPSTAT_PYWRAPUTILS_HH_
#define NPSTAT_PYWRAPUTILS_HH_
#include
<stdexcept>
#include
"Python.h"
namespace
npstat
{
inline
double
getDoubleFromPyObj
(
PyObject
*
d
)
{
if
(
PyErr_Occurred
())
throw
std
::
runtime_error
(
"In npstat::getDoubleFromPyObj: unhandled error at the time of call"
);
const
double
tmp
=
PyFloat_AsDouble
(
d
);
if
(
PyErr_Occurred
())
throw
std
::
runtime_error
(
"In npstat::getDoubleFromPyObj: argument can not be converted to a double"
);
return
tmp
;
}
class
DecrefHandle
{
public
:
inline
explicit
DecrefHandle
(
PyObject
*
ptr
)
:
ptr_
(
ptr
)
{}
inline
~
DecrefHandle
()
{
Py_XDECREF
(
ptr_
);}
inline
PyObject
*
release
()
{
PyObject
*
p
=
ptr_
;
ptr_
=
0
;
return
p
;}
private
:
PyObject
*
ptr_
;
};
inline
void
validatePyCallable
(
PyObject
*
pFunc
)
{
if
(
!
pFunc
)
throw
std
::
invalid_argument
(
"In npstat::validatePyCallable: null object encountered"
);
if
(
!
PyCallable_Check
(
pFunc
))
throw
std
::
invalid_argument
(
"In npstat::validatePyCallable: argument is not callable"
);
}
}
#endif
// NPSTAT_PYWRAPUTILS_HH_
File Metadata
Details
Attached
Mime Type
text/x-c
Expires
Tue, Sep 30, 5:49 AM (1 d, 8 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
6560499
Default Alt Text
pyWrapUtils.hh (1 KB)
Attached To
Mode
rNPSTATSVN npstatsvn
Attached
Detach File
Event Timeline
Log In to Comment