ROOT
master
Reference Guide
Loading...
Searching...
No Matches
PythonInterface.cxx
Go to the documentation of this file.
1
#include "
./PythonInterface.h
"
2
3
#include <
TSystem.h
>
4
5
namespace
xPython
{
6
7
// https://docs.python.org/3.11/c-api/init.html#c.Py_IsInitialized
8
bool
isPythonInitialized
() {
9
using
fn_t
=
int
(*)();
10
static
auto
f
=
reinterpret_cast<
fn_t
>
(
gSystem
->
DynFindSymbol
(
"*"
,
"Py_IsInitialized"
));
11
return
f
&&
f
();
12
}
13
14
// https://docs.python.org/3/c-api/sys.html#c.PySys_WriteStdout
15
void
writeStdoutLine
(
const
char
*
msg
) {
16
using
fn_t
= void (*)(
const
char
*, ...);
17
static
auto
f
=
reinterpret_cast<
fn_t
>
(
gSystem
->
DynFindSymbol
(
"*"
,
"PySys_WriteStdout"
));
18
if
(
f
)
19
f
(
"%s\n"
,
msg
);
20
}
21
22
// https://docs.python.org/3/c-api/sys.html#c.PySys_WriteStderr
23
void
writeStderrLine
(
const
char
*
msg
) {
24
using
fn_t
= void (*)(
const
char
*, ...);
25
static
auto
f
=
reinterpret_cast<
fn_t
>
(
gSystem
->
DynFindSymbol
(
"*"
,
"PySys_WriteStderr"
));
26
if
(
f
)
27
f
(
"%s\n"
,
msg
);
28
}
29
30
}
// namespace xPython
PythonInterface.h
f
#define f(i)
Definition
RSha256.hxx:104
TSystem.h
gSystem
R__EXTERN TSystem * gSystem
Definition
TSystem.h:582
ROOT::Detail::TRangeCast
Definition
TCollection.h:313
TSystem::DynFindSymbol
virtual Func_t DynFindSymbol(const char *module, const char *entry)
Find specific entry point in specified library.
Definition
TSystem.cxx:2059
int
xPython
Definition
PythonInterface.cxx:5
xPython::writeStdoutLine
void writeStdoutLine(const char *msg)
Definition
PythonInterface.cxx:15
xPython::isPythonInitialized
bool isPythonInitialized()
Definition
PythonInterface.cxx:8
xPython::writeStderrLine
void writeStderrLine(const char *msg)
Definition
PythonInterface.cxx:23
roofit
xroofit
src
PythonInterface.cxx
ROOTmaster - Reference Guide Generated on Sun Jun 21 2026 04:48:09 (GVA Time) using Doxygen 1.10.0