Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
FacadeHelpers.cxx
Go to the documentation of this file.
1// Author: Enric Tejedor CERN 04/2020
2
3/*************************************************************************
4 * Copyright (C) 1995-2020, Rene Brun and Fons Rademakers. *
5 * All rights reserved. *
6 * *
7 * For the licensing terms see $ROOTSYS/LICENSE. *
8 * For the list of contributors see $ROOTSYS/README/CREDITS. *
9 *************************************************************************/
10
11// Bindings
12#include "FacadeHelpers.hxx"
13
14// Cppyy
15#include "LowLevelViews.h"
16
17// ROOT
18#include "RtypesCore.h"
19#include "ROOT/RConfig.hxx"
20
21//////////////////////////////////////////////////////////////////////////
22/// \brief Get a buffer starting at a given address
23/// \param[in] self Always null, since this is a module function.
24/// \param[in] addr Address to create buffer from
25///
26/// \return A cppyy LowLevelView object on the received address, i.e. an
27/// indexable buffer starting at that address.
29{
30 if (!addr) {
31 PyErr_SetString(PyExc_RuntimeError, "Unable to create buffer from invalid address");
32 return NULL;
33 }
34
35 Long64_t cAddr = PyLong_AsLongLong(addr);
36 if (cAddr == -1 && PyErr_Occurred()) {
37 PyErr_SetString(PyExc_RuntimeError, "Unable to create buffer: address is not a valid integer");
38 return NULL;
39 }
40
41#ifdef R__B64
43#else
44 return CPyCppyy::CreateLowLevelView((Int_t*)cAddr);
45#endif
46}
_object PyObject
long long Long64_t
Definition RtypesCore.h:80
PyObject * CreateLowLevelView(const char **, Py_ssize_t *shape=nullptr)
PyObject * CreateBufferFromAddress(PyObject *self, PyObject *addr)
Get a buffer starting at a given address.