Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
LowLevelViews.cxx File Reference
#include "CPyCppyy.h"
#include "LowLevelViews.h"
#include "Converters.h"
#include <map>
#include <assert.h>
#include <limits.h>
Include dependency graph for LowLevelViews.cxx:

Namespaces

namespace  CPyCppyy
 Set of helper functions that are invoked from the pythonizors, on the Python side.
 

Macros

#define ADJUST_PTR(ptr, suboffsets, dim)    (HAVE_PTR(suboffsets, dim) ? *((char**)ptr) + suboffsets[dim] : ptr)
 
#define CPPYY_IMPL_VIEW_CREATOR(type)
 
#define HAVE_PTR(suboffsets, dim)   (suboffsets && suboffsets[dim] >= 0)
 
#define HAVE_SUBOFFSETS_IN_LAST_DIM(view)    (view->suboffsets && view->suboffsets[dest->ndim-1] >= 0)
 

Functions

static void copy_base (const Py_ssize_t *shape, Py_ssize_t itemsize, char *dptr, const Py_ssize_t *dstrides, const Py_ssize_t *dsuboffsets, char *sptr, const Py_ssize_t *sstrides, const Py_ssize_t *ssuboffsets, char *mem)
 
static int copy_single (Py_buffer *dest, Py_buffer *src)
 
 CPPYY_IMPL_VIEW_CREATOR (bool)
 
 CPPYY_IMPL_VIEW_CREATOR (double)
 
 CPPYY_IMPL_VIEW_CREATOR (float)
 
 CPPYY_IMPL_VIEW_CREATOR (int)
 
 CPPYY_IMPL_VIEW_CREATOR (long double)
 
 CPPYY_IMPL_VIEW_CREATOR (long long)
 
 CPPYY_IMPL_VIEW_CREATOR (long)
 
 CPPYY_IMPL_VIEW_CREATOR (short)
 
 CPPYY_IMPL_VIEW_CREATOR (signed char)
 
 CPPYY_IMPL_VIEW_CREATOR (std::complex< double >)
 
 CPPYY_IMPL_VIEW_CREATOR (std::complex< float >)
 
 CPPYY_IMPL_VIEW_CREATOR (std::complex< int >)
 
 CPPYY_IMPL_VIEW_CREATOR (std::complex< long >)
 
 CPPYY_IMPL_VIEW_CREATOR (unsigned char)
 
 CPPYY_IMPL_VIEW_CREATOR (unsigned int)
 
 CPPYY_IMPL_VIEW_CREATOR (unsigned long long)
 
 CPPYY_IMPL_VIEW_CREATOR (unsigned long)
 
 CPPYY_IMPL_VIEW_CREATOR (unsigned short)
 
template<typename T >
static PyObjectCreateLowLevelViewT (T **address, Py_ssize_t *shape)
 
template<typename T >
static PyObjectCreateLowLevelViewT (T *address, Py_ssize_t *shape)
 
static bool equiv_shape (const Py_buffer *dest, const Py_buffer *src)
 
static bool equiv_structure (const Py_buffer *dest, const Py_buffer *src)
 
static int init_slice (Py_buffer *base, PyObject *_key, int dim)
 
static Py_ssize_t is_multiindex (PyObject *key)
 
static bool is_multislice (PyObject *key)
 
static int last_dim_is_contiguous (const Py_buffer *dest, const Py_buffer *src)
 
static int ll_ass_sub (CPyCppyy::LowLevelView *self, PyObject *key, PyObject *value)
 
static void ll_dealloc (CPyCppyy::LowLevelView *pyobj)
 
static int ll_getbuf (CPyCppyy::LowLevelView *self, Py_buffer *view, int flags)
 
static Py_ssize_t ll_getsegcount (PyObject *, Py_ssize_t *lenp)
 
static PyObjectll_item (CPyCppyy::LowLevelView *self, Py_ssize_t index)
 
static PyObjectll_item_multi (CPyCppyy::LowLevelView *self, PyObject *tup)
 
static Py_ssize_t ll_length (CPyCppyy::LowLevelView *self)
 
static CPyCppyy::LowLevelViewll_new (PyTypeObject *subtype, PyObject *, PyObject *)
 
static Py_ssize_t ll_oldgetbuf (CPyCppyy::LowLevelView *self, Py_ssize_t seg, void **pptr)
 
static PyObjectll_reshape (CPyCppyy::LowLevelView *self, PyObject *shape)
 
static PyObjectll_subscript (CPyCppyy::LowLevelView *self, PyObject *key)
 
static PyObjectll_typecode (CPyCppyy::LowLevelView *self, void *)
 
static char * lookup_dimension (Py_buffer &view, char *ptr, int dim, Py_ssize_t index)
 
static voidptr_from_index (CPyCppyy::LowLevelView *llview, Py_ssize_t index)
 
static voidptr_from_tuple (CPyCppyy::LowLevelView *llview, PyObject *tup)
 

Variables

static PyBufferProcs ll_as_buffer
 
static PyMappingMethods ll_as_mapping
 
static PySequenceMethods ll_as_sequence
 
static PyGetSetDef ll_getset []
 
static PyMethodDef ll_methods []
 
PyTypeObject CPyCppyy::LowLevelView_Type
 

Macro Definition Documentation

◆ ADJUST_PTR

#define ADJUST_PTR (   ptr,
  suboffsets,
  dim 
)     (HAVE_PTR(suboffsets, dim) ? *((char**)ptr) + suboffsets[dim] : ptr)

Definition at line 106 of file LowLevelViews.cxx.

◆ CPPYY_IMPL_VIEW_CREATOR

#define CPPYY_IMPL_VIEW_CREATOR (   type)
Value:
return CreateLowLevelViewT<type>(address, shape); \
} \
return CreateLowLevelViewT<type>(address, shape); \
}
int Py_ssize_t
Definition CPyCppyy.h:236
_object PyObject
int type
Definition TGX11.cxx:121
PyObject * CreateLowLevelView(const char **, Py_ssize_t *shape=nullptr)

Definition at line 823 of file LowLevelViews.cxx.

◆ HAVE_PTR

#define HAVE_PTR (   suboffsets,
  dim 
)    (suboffsets && suboffsets[dim] >= 0)

Definition at line 104 of file LowLevelViews.cxx.

◆ HAVE_SUBOFFSETS_IN_LAST_DIM

#define HAVE_SUBOFFSETS_IN_LAST_DIM (   view)     (view->suboffsets && view->suboffsets[dest->ndim-1] >= 0)

Definition at line 111 of file LowLevelViews.cxx.

Function Documentation

◆ copy_base()

static void copy_base ( const Py_ssize_t shape,
Py_ssize_t  itemsize,
char *  dptr,
const Py_ssize_t dstrides,
const Py_ssize_t dsuboffsets,
char *  sptr,
const Py_ssize_t sstrides,
const Py_ssize_t ssuboffsets,
char *  mem 
)
static

Definition at line 159 of file LowLevelViews.cxx.

◆ copy_single()

static int copy_single ( Py_buffer *  dest,
Py_buffer *  src 
)
static

Definition at line 190 of file LowLevelViews.cxx.

◆ CPPYY_IMPL_VIEW_CREATOR() [1/18]

CPPYY_IMPL_VIEW_CREATOR ( bool  )

◆ CPPYY_IMPL_VIEW_CREATOR() [2/18]

CPPYY_IMPL_VIEW_CREATOR ( double  )

◆ CPPYY_IMPL_VIEW_CREATOR() [3/18]

CPPYY_IMPL_VIEW_CREATOR ( float  )

◆ CPPYY_IMPL_VIEW_CREATOR() [4/18]

CPPYY_IMPL_VIEW_CREATOR ( int  )

◆ CPPYY_IMPL_VIEW_CREATOR() [5/18]

CPPYY_IMPL_VIEW_CREATOR ( long double  )

◆ CPPYY_IMPL_VIEW_CREATOR() [6/18]

CPPYY_IMPL_VIEW_CREATOR ( long long  )

◆ CPPYY_IMPL_VIEW_CREATOR() [7/18]

CPPYY_IMPL_VIEW_CREATOR ( long  )

◆ CPPYY_IMPL_VIEW_CREATOR() [8/18]

CPPYY_IMPL_VIEW_CREATOR ( short  )

◆ CPPYY_IMPL_VIEW_CREATOR() [9/18]

CPPYY_IMPL_VIEW_CREATOR ( signed char  )

◆ CPPYY_IMPL_VIEW_CREATOR() [10/18]

CPPYY_IMPL_VIEW_CREATOR ( std::complex< double )

◆ CPPYY_IMPL_VIEW_CREATOR() [11/18]

CPPYY_IMPL_VIEW_CREATOR ( std::complex< float >  )

◆ CPPYY_IMPL_VIEW_CREATOR() [12/18]

CPPYY_IMPL_VIEW_CREATOR ( std::complex< int )

◆ CPPYY_IMPL_VIEW_CREATOR() [13/18]

CPPYY_IMPL_VIEW_CREATOR ( std::complex< long )

◆ CPPYY_IMPL_VIEW_CREATOR() [14/18]

CPPYY_IMPL_VIEW_CREATOR ( unsigned char  )

◆ CPPYY_IMPL_VIEW_CREATOR() [15/18]

CPPYY_IMPL_VIEW_CREATOR ( unsigned int  )

◆ CPPYY_IMPL_VIEW_CREATOR() [16/18]

CPPYY_IMPL_VIEW_CREATOR ( unsigned long long  )

◆ CPPYY_IMPL_VIEW_CREATOR() [17/18]

CPPYY_IMPL_VIEW_CREATOR ( unsigned long  )

◆ CPPYY_IMPL_VIEW_CREATOR() [18/18]

CPPYY_IMPL_VIEW_CREATOR ( unsigned short  )

◆ CreateLowLevelViewT() [1/2]

template<typename T >
static PyObject * CreateLowLevelViewT ( T **  address,
Py_ssize_t shape 
)
inlinestatic

Definition at line 813 of file LowLevelViews.cxx.

◆ CreateLowLevelViewT() [2/2]

template<typename T >
static PyObject * CreateLowLevelViewT ( T *  address,
Py_ssize_t shape 
)
inlinestatic

Definition at line 765 of file LowLevelViews.cxx.

◆ equiv_shape()

static bool equiv_shape ( const Py_buffer *  dest,
const Py_buffer *  src 
)
inlinestatic

Definition at line 125 of file LowLevelViews.cxx.

◆ equiv_structure()

static bool equiv_structure ( const Py_buffer *  dest,
const Py_buffer *  src 
)
static

Definition at line 144 of file LowLevelViews.cxx.

◆ init_slice()

static int init_slice ( Py_buffer *  base,
PyObject _key,
int  dim 
)
inlinestatic

Definition at line 288 of file LowLevelViews.cxx.

◆ is_multiindex()

static Py_ssize_t is_multiindex ( PyObject key)
static

Definition at line 338 of file LowLevelViews.cxx.

◆ is_multislice()

static bool is_multislice ( PyObject key)
static

Definition at line 320 of file LowLevelViews.cxx.

◆ last_dim_is_contiguous()

static int last_dim_is_contiguous ( const Py_buffer *  dest,
const Py_buffer *  src 
)
inlinestatic

Definition at line 115 of file LowLevelViews.cxx.

◆ ll_ass_sub()

static int ll_ass_sub ( CPyCppyy::LowLevelView self,
PyObject key,
PyObject value 
)
static

Definition at line 452 of file LowLevelViews.cxx.

◆ ll_dealloc()

static void ll_dealloc ( CPyCppyy::LowLevelView pyobj)
static

Definition at line 33 of file LowLevelViews.cxx.

◆ ll_getbuf()

static int ll_getbuf ( CPyCppyy::LowLevelView self,
Py_buffer *  view,
int  flags 
)
static

Definition at line 566 of file LowLevelViews.cxx.

◆ ll_getsegcount()

static Py_ssize_t ll_getsegcount ( PyObject ,
Py_ssize_t lenp 
)
static

Definition at line 558 of file LowLevelViews.cxx.

◆ ll_item()

static PyObject * ll_item ( CPyCppyy::LowLevelView self,
Py_ssize_t  index 
)
static

Definition at line 357 of file LowLevelViews.cxx.

◆ ll_item_multi()

static PyObject * ll_item_multi ( CPyCppyy::LowLevelView self,
PyObject tup 
)
static

Definition at line 380 of file LowLevelViews.cxx.

◆ ll_length()

static Py_ssize_t ll_length ( CPyCppyy::LowLevelView self)
static

Definition at line 280 of file LowLevelViews.cxx.

◆ ll_new()

static CPyCppyy::LowLevelView * ll_new ( PyTypeObject *  subtype,
PyObject ,
PyObject  
)
static

Definition at line 20 of file LowLevelViews.cxx.

◆ ll_oldgetbuf()

static Py_ssize_t ll_oldgetbuf ( CPyCppyy::LowLevelView self,
Py_ssize_t  seg,
void **  pptr 
)
static

Definition at line 546 of file LowLevelViews.cxx.

◆ ll_reshape()

static PyObject * ll_reshape ( CPyCppyy::LowLevelView self,
PyObject shape 
)
static

Definition at line 58 of file LowLevelViews.cxx.

◆ ll_subscript()

static PyObject * ll_subscript ( CPyCppyy::LowLevelView self,
PyObject key 
)
static

Definition at line 406 of file LowLevelViews.cxx.

◆ ll_typecode()

static PyObject * ll_typecode ( CPyCppyy::LowLevelView self,
void  
)
static

Definition at line 44 of file LowLevelViews.cxx.

◆ lookup_dimension()

static char * lookup_dimension ( Py_buffer &  view,
char *  ptr,
int  dim,
Py_ssize_t  index 
)
static

Definition at line 221 of file LowLevelViews.cxx.

◆ ptr_from_index()

static void * ptr_from_index ( CPyCppyy::LowLevelView llview,
Py_ssize_t  index 
)
inlinestatic

Definition at line 246 of file LowLevelViews.cxx.

◆ ptr_from_tuple()

static void * ptr_from_tuple ( CPyCppyy::LowLevelView llview,
PyObject tup 
)
static

Definition at line 254 of file LowLevelViews.cxx.

Variable Documentation

◆ ll_as_buffer

PyBufferProcs ll_as_buffer
static
Initial value:
= {
(readbufferproc)ll_oldgetbuf,
(writebufferproc)ll_oldgetbuf,
(segcountproc)ll_getsegcount,
0,
(getbufferproc)ll_getbuf,
0,
}
static Py_ssize_t ll_oldgetbuf(CPyCppyy::LowLevelView *self, Py_ssize_t seg, void **pptr)
static Py_ssize_t ll_getsegcount(PyObject *, Py_ssize_t *lenp)
static int ll_getbuf(CPyCppyy::LowLevelView *self, Py_buffer *view, int flags)

Definition at line 633 of file LowLevelViews.cxx.

◆ ll_as_mapping

PyMappingMethods ll_as_mapping
static
Initial value:
= {
(binaryfunc) ll_subscript,
(objobjargproc)ll_ass_sub,
}
#define lenfunc
Definition CPyCppyy.h:245
static int ll_ass_sub(CPyCppyy::LowLevelView *self, PyObject *key, PyObject *value)
static Py_ssize_t ll_length(CPyCppyy::LowLevelView *self)
static PyObject * ll_subscript(CPyCppyy::LowLevelView *self, PyObject *key)

Definition at line 612 of file LowLevelViews.cxx.

◆ ll_as_sequence

PySequenceMethods ll_as_sequence
static
Initial value:
= {
0,
0,
0,
0,
0,
0,
0,
0,
}
#define ssizeargfunc
Definition CPyCppyy.h:246
static PyObject * ll_item(CPyCppyy::LowLevelView *self, Py_ssize_t index)

Definition at line 619 of file LowLevelViews.cxx.

◆ ll_getset

PyGetSetDef ll_getset[]
static
Initial value:
= {
{(char*)"format", (getter)ll_typecode, nullptr, nullptr, nullptr},
{(char*)"typecode", (getter)ll_typecode, nullptr, nullptr, nullptr},
{(char*)nullptr, nullptr, nullptr, nullptr, nullptr }
}
static PyObject * ll_typecode(CPyCppyy::LowLevelView *self, void *)

Definition at line 50 of file LowLevelViews.cxx.

◆ ll_methods

PyMethodDef ll_methods[]
static
Initial value:
= {
{(char*)"reshape", (PyCFunction)ll_reshape, METH_O, nullptr},
{(char*)nullptr, nullptr, 0, nullptr}
}
static PyObject * ll_reshape(CPyCppyy::LowLevelView *self, PyObject *shape)

Definition at line 91 of file LowLevelViews.cxx.