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
116 const ptrdiff_t* pShape,
int nRank,
char* sBuf,
size_t uLen
139 const ptrdiff_t* pShape,
int nExtRank,
int nShapeLen,
char* sBuf,
size_t uLen
168typedef enum das_gen_type_e {
177typedef struct das_generator DasGen;
179typedef struct DasGen_VTbl {
186 const DasGen* pThis,
const ptrdiff_t* pExtLoc, ubyte* pRun,
size_t uRunMax
193 int (*extShape)(
const DasGen* pThis, ptrdiff_t* pShape);
197 ptrdiff_t (*lengthIn)(
const DasGen* pThis,
int nIdx, ptrdiff_t* pLoc);
206 const DasGen* pThis,
const ptrdiff_t* pExtLoc,
size_t* pCount
221 const DasGen* pThis,
int nExtRank,
const ptrdiff_t* pMin,
222 const ptrdiff_t* pMax
237 const DasGen* pThis,
int nExtRank,
const ptrdiff_t* pMin,
238 const ptrdiff_t* pMax, ubyte* pBuf,
size_t uBufLen
241 void (*destroy)(DasGen* pThis);
246struct das_generator {
250 const DasGen_VTbl* pVTbl;
275#define DasGen_type(P) ((P)->kind)
279#define DasGen_elemType(P) ((P)->elem)
286DAS_API
int DasGen_incRef(DasGen* pThis);
303DAS_API
int DasGen_decRef(DasGen* pThis);
319 const DasGen* pThis,
const ptrdiff_t* pExtLoc, ubyte* pRun,
size_t uRunMax
335int DasGen_extShape(
const DasGen* pThis, ptrdiff_t* pShape);
346ptrdiff_t DasGen_lengthIn(
const DasGen* pThis,
int nIdx, ptrdiff_t* pLoc);
361const ubyte* DasGen_at(
362 const DasGen* pThis,
const ptrdiff_t* pExtLoc,
size_t* pCount
377 const DasGen* pThis,
int nExtRank,
const ptrdiff_t* pMin,
const ptrdiff_t* pMax
394int DasGen_subsetInto(
395 const DasGen* pThis,
int nExtRank,
const ptrdiff_t* pMin,
396 const ptrdiff_t* pMax, ubyte* pBuf,
size_t uBufLen
409DAS_API
const ubyte* DasGen_getFill(
const DasGen* pThis);
419size_t DasGen_itemElems(
const DasGen* pThis);
430DasGen* DasGen_copy(
const DasGen* pThis);
444char* DasGen_expression(
const DasGen* pThis,
char* sBuf,
size_t uLen);
453DasAry* DasGen_getArray(
const DasGen* pThis);
466bool DasGen_setArray(DasGen* pThis,
DasAry* pNew);
471typedef struct das_gen_array {
489#define DASGEN_SEQ_SLOT sizeof(das_time)
491typedef struct das_gen_seq {
508#define DasGenSeq_intercept(P,c) ((P)->pIntercept + (size_t)(c)*DASGEN_SEQ_SLOT)
511#define DasGenSeq_interval(P,c,i) \
512 ((P)->pInterval + ((size_t)(c)*VARIDX_MAX + (size_t)(i))*DASGEN_SEQ_SLOT)
514typedef struct das_gen_const {
516 ubyte aValue[
sizeof(double)];
526typedef bool (*das_gen_applyfn)(
527 das_elem_type etL, das_elem_type etR,
528 const ubyte* pL,
const ubyte* pR, ubyte* pOut
531typedef struct das_gen_op {
533 das_gen_applyfn apply;
564DAS_API DasGen* new_DasGenAry(
DasAry* pAry,
int nExtRank,
const int8_t* pIdxMap);
578DAS_API DasGen* new_DasGenSeq(
579 das_elem_type et,
const ubyte* pIntercept,
int nExtRank,
580 const ubyte* pIntervals,
const ptrdiff_t* pExtShape
593DAS_API DasGen* new_DasGenSeqN(
594 das_elem_type et,
int nComps,
const ubyte* pIntercepts,
int nExtRank,
595 const ubyte* pIntervals,
const ptrdiff_t* pExtShape
609DAS_API DasGen* new_DasGenConst(
610 das_elem_type et,
const ubyte* pVal,
int nExtRank,
const ptrdiff_t* pExtShape
627DAS_API DasGen* new_DasGenBinop(
628 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.
DAS_API char * das_shape_toStr(const ptrdiff_t *pShape, int nRank, char *sBuf, size_t uLen)
Emit a shape string, the exact inverse of das_shape_fromStr().
#define VARIDX_MAX
Max index count for the model.
Definition generator.h:55
DAS_API int das_shape_info(const ptrdiff_t *pShape, int nExtRank, int nShapeLen, char *sBuf, size_t uLen)
Print shape information using symbols i,j,k etc for index positions.
DAS_API void das_varindex_prndir(bool bFastLast)
Set index printing direction for das_shape_info().
int DasErrCode
return code type 0 indicates success, negative integer indicates failure
Definition defs.h:189
Dynamic recursive ragged arrays.
Definition array.h:243
A generic value type for use in arrays, datums and variables.