24#ifndef _das_generator_h_
25#define _das_generator_h_
55#define VARIDX_MAX ARYIDX_MAX
58#define VARIDX_BORROW (VARIDX_RAGGED - 1)
59#define VARIDX_UNUSED (VARIDX_BORROW - 1)
62#define VARIDX_MAXFLG VARIDX_RAGGED
64#define VARIDX_INIT_UNUSED {-3,-3,-3,-3,-3,-3,-3,-3}
65#define VARIDX_INIT_BEGIN { 0, 0, 0, 0, 0, 0, 0, 0}
100 const char* sShape,
int nMaxRank,
bool bAllowFlags, ptrdiff_t* pShape,
101 int* pnRank,
const char* sWhere
108 const ptrdiff_t* pShape,
int nRank,
char* sBuf,
int nLen
128typedef enum das_gen_type_e {
137typedef struct das_generator DasGen;
139typedef struct DasGen_VTbl {
146 const DasGen* pThis,
const ptrdiff_t* pExtLoc, ubyte* pRun,
size_t uRunMax
153 int (*extShape)(
const DasGen* pThis, ptrdiff_t* pShape);
157 ptrdiff_t (*lengthIn)(
const DasGen* pThis,
int nIdx, ptrdiff_t* pLoc);
166 const DasGen* pThis,
const ptrdiff_t* pExtLoc,
size_t* pCount
181 const DasGen* pThis,
int nExtRank,
const ptrdiff_t* pMin,
182 const ptrdiff_t* pMax
197 const DasGen* pThis,
int nExtRank,
const ptrdiff_t* pMin,
198 const ptrdiff_t* pMax, ubyte* pBuf,
size_t uBufLen
201 void (*destroy)(DasGen* pThis);
206struct das_generator {
210 const DasGen_VTbl* pVTbl;
235#define DasGen_type(P) ((P)->kind)
239#define DasGen_elemType(P) ((P)->elem)
246int DasGen_incRef(DasGen* pThis);
263int DasGen_decRef(DasGen* pThis);
279 const DasGen* pThis,
const ptrdiff_t* pExtLoc, ubyte* pRun,
size_t uRunMax
295int DasGen_extShape(
const DasGen* pThis, ptrdiff_t* pShape);
306ptrdiff_t DasGen_lengthIn(
const DasGen* pThis,
int nIdx, ptrdiff_t* pLoc);
321const ubyte* DasGen_at(
322 const DasGen* pThis,
const ptrdiff_t* pExtLoc,
size_t* pCount
337 const DasGen* pThis,
int nExtRank,
const ptrdiff_t* pMin,
const ptrdiff_t* pMax
354int DasGen_subsetInto(
355 const DasGen* pThis,
int nExtRank,
const ptrdiff_t* pMin,
356 const ptrdiff_t* pMax, ubyte* pBuf,
size_t uBufLen
369const ubyte* DasGen_getFill(
const DasGen* pThis);
379size_t DasGen_itemElems(
const DasGen* pThis);
402int DasGen_elemShape(
const DasGen* pThis, ptrdiff_t* pShape);
413DasGen* DasGen_copy(
const DasGen* pThis);
427char* DasGen_expression(
const DasGen* pThis,
char* sBuf,
int nLen);
436DasAry* DasGen_getArray(
const DasGen* pThis);
449bool DasGen_setArray(DasGen* pThis,
DasAry* pNew);
454typedef struct das_gen_array {
472#define DASGEN_SEQ_SLOT sizeof(das_time)
474typedef struct das_gen_seq {
491#define DasGenSeq_intercept(P,c) ((P)->pIntercept + (size_t)(c)*DASGEN_SEQ_SLOT)
494#define DasGenSeq_interval(P,c,i) \
495 ((P)->pInterval + ((size_t)(c)*VARIDX_MAX + (size_t)(i))*DASGEN_SEQ_SLOT)
497typedef struct das_gen_const {
499 ubyte aValue[
sizeof(double)];
509typedef bool (*das_gen_applyfn)(
510 das_elem_type etL, das_elem_type etR,
511 const ubyte* pL,
const ubyte* pR, ubyte* pOut
514typedef struct das_gen_op {
516 das_gen_applyfn apply;
547DasGen* new_DasGenAry(
DasAry* pAry,
int nExtRank,
const int8_t* pIdxMap);
561DasGen* new_DasGenSeq(
562 das_elem_type et,
const ubyte* pIntercept,
int nExtRank,
563 const ubyte* pIntervals,
const ptrdiff_t* pExtShape
576DasGen* new_DasGenSeqN(
577 das_elem_type et,
int nComps,
const ubyte* pIntercepts,
int nExtRank,
578 const ubyte* pIntervals,
const ptrdiff_t* pExtShape
592DasGen* new_DasGenConst(
593 das_elem_type et,
const ubyte* pVal,
int nExtRank,
const ptrdiff_t* pExtShape
610DasGen* new_DasGenBinop(
611 das_gen_applyfn apply, das_elem_type etOut, DasGen* pLeft, DasGen* pRight,
A dynamic buffer with multi-dimensional array style access.
DAS_API void das_varindex_merge(int nRank, ptrdiff_t *pDest, ptrdiff_t *pSrc)
Merge two shapes in the model's index space, taking the lattice.
DAS_API DasErrCode das_shape_fromStr(const char *sShape, int nMaxRank, bool bAllowFlags, ptrdiff_t *pShape, int *pnRank, const char *sWhere)
Parse a shape string in the model's index vocabulary.
DAS_API ptrdiff_t das_varlength_merge(ptrdiff_t nLeft, ptrdiff_t nRight)
Merge the length of one index position, same lattice as above.
#define VARIDX_MAX
Max index count for the model.
Definition generator.h:55
DAS_API int das_shape_toStr(const ptrdiff_t *pShape, int nRank, char *sBuf, int nLen)
Emit a shape string, the exact inverse of das_shape_fromStr().
int DasErrCode
return code type 0 indicates success, negative integer indicates failure
Definition defs.h:184
Dynamic recursive ragged arrays.
Definition array.h:271
A generic value type for use in arrays, datums and variables.