NEURON
nrnpy_p2h.cpp File Reference
#include <../../nrnconf.h>
#include <cstdio>
#include <optional>
#include <InterViews/resource.h>
#include <nrnoc2iv.h>
#include <classreg.h>
#include "neuron/unique_cstr.hpp"
#include "nrnpython.h"
#include "hoccontext.h"
#include "nrnpy.h"
#include "nrnpy_utils.h"
#include "oc_ansi.h"
#include "parse.hpp"
#include <nanobind/nanobind.h>
#include "nrnmpi.h"

Go to the source code of this file.

Classes

struct  Py2Nrn
 

Functions

static neuron::unique_cstr nrnpyerr_str ()
 Full python traceback error message returned as string. More...
 
static nb::object nrnpy_pyCallObject (nb::callable, nb::object)
 
static void call_python_with_section (Object *pyact, Section *sec)
 
static void * opaque_obj2pyobj (Object *ho)
 
int nrnpy_ho_eq_po (Object *ho, PyObject *po)
 
static int pysame (Object *o1, Object *o2)
 
PyObjectnrnpy_hoc2pyobject (Object *ho)
 
Objectnrnpy_pyobject_in_obj (PyObject *po)
 
static void py2n_component (Object *ob, Symbol *sym, int nindex, int isfunc)
 
static void hpoasgn (Object *o, int type)
 
static nb::object hoccommand_exec_help1 (nb::object po)
 
static nb::object hoccommand_exec_help (Object *ho)
 
static double praxis_efun (Object *ho, Object *v)
 
static int hoccommand_exec (Object *ho)
 
static int hoccommand_exec_strret (Object *ho, char *buf, int size)
 
static void grphcmdtool (Object *ho, int type, double x, double y, int key)
 
static Objectcallable_with_args (Object *ho, int narg)
 
static double func_call (Object *ho, int narg, int *err)
 
static double guigetval (Object *ho)
 
static void guisetval (Object *ho, double x)
 
static int guigetstr (Object *ho, char **cpp)
 
static void setpickle ()
 
static std::vector< char > pickle (PyObject *p)
 
static std::vector< char > po2pickle (Object *ho)
 
static nb::object unpickle (const char *s, std::size_t len)
 
static nb::object unpickle (const std::vector< char > &s)
 
static Objectpickle2po (const std::vector< char > &s)
 
std::vector< char > call_picklef (const std::vector< char > &fname, int narg)
 
static std::vector< int > mk_displ (int *cnts)
 
static nb::list char2pylist (const std::vector< char > &buf, const std::vector< int > &cnt, const std::vector< int > &displ)
 
static Objectpy_alltoall_type (int size, int type)
 
static PyThreadStatesave_thread ()
 
static void restore_thread (PyThreadState *g)
 
void nrnpython_reg_real_nrnpython_cpp (neuron::python::impl_ptrs *ptrs)
 
void nrnpython_reg_real_nrnpy_hoc_cpp (neuron::python::impl_ptrs *ptrs)
 
static void * p_cons (Object *)
 
static void p_destruct (void *v)
 
NRN_EXPORT void nrnpython_reg_real (neuron::python::impl_ptrs *ptrs)
 Populate NEURON state with information from a specific Python. More...
 

Variables

static PyObjectmain_module
 
static PyObjectmain_namespace
 
static nb::callable loads
 
static nb::callable dumps
 

Function Documentation

◆ call_picklef()

std::vector<char> call_picklef ( const std::vector< char > &  fname,
int  narg 
)

Definition at line 601 of file nrnpy_p2h.cpp.

◆ call_python_with_section()

static void call_python_with_section ( Object pyact,
Section sec 
)
static

Definition at line 36 of file nrnpy_p2h.cpp.

◆ callable_with_args()

static Object* callable_with_args ( Object ho,
int  narg 
)
static

Definition at line 397 of file nrnpy_p2h.cpp.

◆ char2pylist()

static nb::list char2pylist ( const std::vector< char > &  buf,
const std::vector< int > &  cnt,
const std::vector< int > &  displ 
)
static

Definition at line 641 of file nrnpy_p2h.cpp.

◆ func_call()

static double func_call ( Object ho,
int  narg,
int *  err 
)
static

Definition at line 423 of file nrnpy_p2h.cpp.

◆ grphcmdtool()

static void grphcmdtool ( Object ho,
int  type,
double  x,
double  y,
int  key 
)
static

Definition at line 379 of file nrnpy_p2h.cpp.

◆ guigetstr()

static int guigetstr ( Object ho,
char **  cpp 
)
static

Definition at line 488 of file nrnpy_p2h.cpp.

◆ guigetval()

static double guigetval ( Object ho)
static

Definition at line 468 of file nrnpy_p2h.cpp.

◆ guisetval()

static void guisetval ( Object ho,
double  x 
)
static

Definition at line 478 of file nrnpy_p2h.cpp.

◆ hoccommand_exec()

static int hoccommand_exec ( Object ho)
static

Definition at line 339 of file nrnpy_p2h.cpp.

◆ hoccommand_exec_help()

static nb::object hoccommand_exec_help ( Object ho)
static

Definition at line 312 of file nrnpy_p2h.cpp.

◆ hoccommand_exec_help1()

static nb::object hoccommand_exec_help1 ( nb::object  po)
static

Definition at line 300 of file nrnpy_p2h.cpp.

◆ hoccommand_exec_strret()

static int hoccommand_exec_strret ( Object ho,
char *  buf,
int  size 
)
static

Definition at line 357 of file nrnpy_p2h.cpp.

◆ hpoasgn()

static void hpoasgn ( Object o,
int  type 
)
static

Definition at line 248 of file nrnpy_p2h.cpp.

◆ mk_displ()

static std::vector<int> mk_displ ( int *  cnts)
static

Definition at line 632 of file nrnpy_p2h.cpp.

◆ nrnpy_ho_eq_po()

int nrnpy_ho_eq_po ( Object ho,
PyObject po 
)

Definition at line 61 of file nrnpy_p2h.cpp.

◆ nrnpy_hoc2pyobject()

PyObject* nrnpy_hoc2pyobject ( Object ho)

Definition at line 77 of file nrnpy_p2h.cpp.

◆ nrnpy_pyCallObject()

static nb::object nrnpy_pyCallObject ( nb::callable  callable,
nb::object  args 
)
static

if (!p) { auto mes = nrnpyerr_str(); if (mes.is_valid()) { Fprintf(stderr, "%s\n", mes.c_str()); free(mes); hoc_execerror("Call of Python Callable failed", NULL); } if (PyErr_Occurred()) { PyErr_Print(); // Python process will exit with the error code specified by the SystemExit instance. } }

Definition at line 101 of file nrnpy_p2h.cpp.

◆ nrnpy_pyobject_in_obj()

Object* nrnpy_pyobject_in_obj ( PyObject po)

Definition at line 91 of file nrnpy_p2h.cpp.

◆ nrnpyerr_str()

static neuron::unique_cstr nrnpyerr_str ( )
static

Full python traceback error message returned as string.

Caller should free the return value if not NULL

Definition at line 561 of file nrnpy_p2h.cpp.

◆ nrnpython_reg_real()

NRN_EXPORT void nrnpython_reg_real ( neuron::python::impl_ptrs ptrs)

Populate NEURON state with information from a specific Python.

Parameters
ptrsLogically a return value; avoidi

Definition at line 914 of file nrnpy_p2h.cpp.

◆ nrnpython_reg_real_nrnpy_hoc_cpp()

void nrnpython_reg_real_nrnpy_hoc_cpp ( neuron::python::impl_ptrs ptrs)

Definition at line 3491 of file nrnpy_hoc.cpp.

◆ nrnpython_reg_real_nrnpython_cpp()

void nrnpython_reg_real_nrnpython_cpp ( neuron::python::impl_ptrs ptrs)

Definition at line 415 of file nrnpython.cpp.

◆ opaque_obj2pyobj()

static void* opaque_obj2pyobj ( Object ho)
static

Definition at line 54 of file nrnpy_p2h.cpp.

◆ p_cons()

static void* p_cons ( Object )
static

Definition at line 902 of file nrnpy_p2h.cpp.

◆ p_destruct()

static void p_destruct ( void *  v)
static

Definition at line 906 of file nrnpy_p2h.cpp.

◆ pickle()

static std::vector<char> pickle ( PyObject p)
static

Definition at line 525 of file nrnpy_p2h.cpp.

◆ pickle2po()

static Object* pickle2po ( const std::vector< char > &  s)
static

Definition at line 551 of file nrnpy_p2h.cpp.

◆ po2pickle()

static std::vector<char> po2pickle ( Object ho)
static

Definition at line 534 of file nrnpy_p2h.cpp.

◆ praxis_efun()

static double praxis_efun ( Object ho,
Object v 
)
static

Definition at line 318 of file nrnpy_p2h.cpp.

◆ py2n_component()

static void py2n_component ( Object ob,
Symbol sym,
int  nindex,
int  isfunc 
)
static

Definition at line 137 of file nrnpy_p2h.cpp.

◆ py_alltoall_type()

static Object* py_alltoall_type ( int  size,
int  type 
)
static

Definition at line 725 of file nrnpy_p2h.cpp.

◆ pysame()

static int pysame ( Object o1,
Object o2 
)
static

Definition at line 69 of file nrnpy_p2h.cpp.

◆ restore_thread()

static void restore_thread ( PyThreadState g)
static

Definition at line 895 of file nrnpy_p2h.cpp.

◆ save_thread()

static PyThreadState* save_thread ( )
static

Definition at line 892 of file nrnpy_p2h.cpp.

◆ setpickle()

static void setpickle ( )
static

Definition at line 506 of file nrnpy_p2h.cpp.

◆ unpickle() [1/2]

static nb::object unpickle ( const char *  s,
std::size_t  len 
)
static

Definition at line 543 of file nrnpy_p2h.cpp.

◆ unpickle() [2/2]

static nb::object unpickle ( const std::vector< char > &  s)
static

Definition at line 547 of file nrnpy_p2h.cpp.

Variable Documentation

◆ dumps

nb::callable dumps
static

Definition at line 504 of file nrnpy_p2h.cpp.

◆ loads

nb::callable loads
static

Definition at line 503 of file nrnpy_p2h.cpp.

◆ main_module

PyObject* main_module
static

Definition at line 24 of file nrnpy_p2h.cpp.

◆ main_namespace

PyObject* main_namespace
static

Definition at line 25 of file nrnpy_p2h.cpp.