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)
 
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 void * ptr_from_index (CPyCppyy::LowLevelView *llview, Py_ssize_t index)
 
static void * ptr_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 109 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
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
PyObject * CreateLowLevelView(bool *, Py_ssize_t *shape=nullptr)

Definition at line 826 of file LowLevelViews.cxx.

◆ HAVE_PTR

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

Definition at line 107 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 114 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 162 of file LowLevelViews.cxx.

◆ copy_single()

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

Definition at line 193 of file LowLevelViews.cxx.

◆ CreateLowLevelViewT() [1/2]

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

Definition at line 816 of file LowLevelViews.cxx.

◆ CreateLowLevelViewT() [2/2]

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

Definition at line 768 of file LowLevelViews.cxx.

◆ equiv_shape()

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

Definition at line 128 of file LowLevelViews.cxx.

◆ equiv_structure()

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

Definition at line 147 of file LowLevelViews.cxx.

◆ init_slice()

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

Definition at line 291 of file LowLevelViews.cxx.

◆ is_multiindex()

static Py_ssize_t is_multiindex ( PyObject key)
static

Definition at line 341 of file LowLevelViews.cxx.

◆ is_multislice()

static bool is_multislice ( PyObject key)
static

Definition at line 323 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 118 of file LowLevelViews.cxx.

◆ ll_ass_sub()

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

Definition at line 455 of file LowLevelViews.cxx.

◆ ll_dealloc()

static void ll_dealloc ( CPyCppyy::LowLevelView pyobj)
static

Definition at line 36 of file LowLevelViews.cxx.

◆ ll_getbuf()

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

Definition at line 569 of file LowLevelViews.cxx.

◆ ll_getsegcount()

static Py_ssize_t ll_getsegcount ( PyObject ,
Py_ssize_t lenp 
)
static

Definition at line 561 of file LowLevelViews.cxx.

◆ ll_item()

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

Definition at line 360 of file LowLevelViews.cxx.

◆ ll_item_multi()

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

Definition at line 383 of file LowLevelViews.cxx.

◆ ll_length()

static Py_ssize_t ll_length ( CPyCppyy::LowLevelView self)
static

Definition at line 283 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 549 of file LowLevelViews.cxx.

◆ ll_reshape()

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

Definition at line 61 of file LowLevelViews.cxx.

◆ ll_subscript()

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

Definition at line 409 of file LowLevelViews.cxx.

◆ ll_typecode()

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

Definition at line 47 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 224 of file LowLevelViews.cxx.

◆ ptr_from_index()

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

Definition at line 249 of file LowLevelViews.cxx.

◆ ptr_from_tuple()

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

Definition at line 257 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 636 of file LowLevelViews.cxx.

◆ ll_as_mapping

PyMappingMethods ll_as_mapping
static
Initial value:
= {
( inquiry ) ll_length,
(binaryfunc) ll_subscript,
(objobjargproc)ll_ass_sub,
}
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 615 of file LowLevelViews.cxx.

◆ ll_as_sequence

PySequenceMethods ll_as_sequence
static
Initial value:
= {
( inquiry )ll_length,
0,
0,
( intargfunc )ll_item,
0,
0,
0,
0,
0,
0,
}
static PyObject * ll_item(CPyCppyy::LowLevelView *self, Py_ssize_t index)

Definition at line 622 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 53 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 94 of file LowLevelViews.cxx.