NEURON
nrnpy_utils.h
Go to the documentation of this file.
1
#pragma once
2
3
#include "
nrnwrap_Python.h
"
4
#include "
nrn_export.hpp
"
5
#include "
neuron/unique_cstr.hpp
"
6
#include <cassert>
7
8
9
inline
bool
is_python_string
(
PyObject
* python_string) {
10
return
PyUnicode_Check(python_string) || PyBytes_Check(python_string);
11
}
12
13
class
NRN_EXPORT
Py2NRNString
{
14
public
:
15
[[nodiscard]]
static
neuron::unique_cstr
as_ascii(
PyObject
* python_string);
16
17
static
void
set_pyerr(
PyObject
*
type
,
const
char
* message);
18
[[nodiscard]]
static
neuron::unique_cstr
get_pyerr();
19
20
private
:
21
Py2NRNString
() =
delete
;
22
Py2NRNString
(
const
Py2NRNString
&) =
delete
;
23
Py2NRNString
&
operator=
(
const
Py2NRNString
&) =
delete
;
24
};
25
26
extern
void
nrnpy_sec_referr
();
27
#define CHECK_SEC_INVALID(sec) \
28
{ \
29
if (!sec->prop) { \
30
nrnpy_sec_referr(); \
31
return NULL; \
32
} \
33
}
34
35
extern
void
nrnpy_prop_referr
();
36
#define CHECK_PROP_INVALID(propid) \
37
{ \
38
if (!propid) { \
39
nrnpy_prop_referr(); \
40
return NULL; \
41
} \
42
}
Py2NRNString
Definition:
nrnpy_utils.h:13
Py2NRNString::Py2NRNString
Py2NRNString()=delete
Py2NRNString::Py2NRNString
Py2NRNString(const Py2NRNString &)=delete
Py2NRNString::operator=
Py2NRNString & operator=(const Py2NRNString &)=delete
neuron::unique_cstr
A RAII wrapper for C-style strings.
Definition:
unique_cstr.hpp:18
nrn_export.hpp
NRN_EXPORT
#define NRN_EXPORT
Definition:
nrn_export.hpp:6
type
short type
Definition:
cabvars.h:10
PyObject
_object PyObject
Definition:
nrnpy.h:12
nrnpy_sec_referr
void nrnpy_sec_referr()
Definition:
nrnpy_nrn.cpp:150
is_python_string
bool is_python_string(PyObject *python_string)
Definition:
nrnpy_utils.h:9
nrnpy_prop_referr
void nrnpy_prop_referr()
Definition:
nrnpy_nrn.cpp:154
nrnwrap_Python.h
unique_cstr.hpp
src
nrnpython
nrnpy_utils.h