diff options
author | griffin <briang42@easystreet.net> | 2022-08-08 19:38:19 (GMT) |
---|---|---|
committer | griffin <briang42@easystreet.net> | 2022-08-08 19:38:19 (GMT) |
commit | 7030b2b274ec5a3c7f7a29b5549a28a9f9002a16 (patch) | |
tree | 03f33c2c1cfc5be63560164c9b13096e80a0d9f8 /generic/tclAbstractList.h | |
parent | c35f73ae26971655393e97ecf7ef928604810afa (diff) | |
download | tcl-7030b2b274ec5a3c7f7a29b5549a28a9f9002a16.zip tcl-7030b2b274ec5a3c7f7a29b5549a28a9f9002a16.tar.gz tcl-7030b2b274ec5a3c7f7a29b5549a28a9f9002a16.tar.bz2 |
Abstract Lists (TIP-225) initial implementation.
Diffstat (limited to 'generic/tclAbstractList.h')
-rw-r--r-- | generic/tclAbstractList.h | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/generic/tclAbstractList.h b/generic/tclAbstractList.h new file mode 100644 index 0000000..dc45709 --- /dev/null +++ b/generic/tclAbstractList.h @@ -0,0 +1,56 @@ +/* + * tclAbstractList.h -- + * + * The AbstractList Obj Type -- a psuedo List + * + * Copyright © 2022 by Brian Griffin. All rights reserved. + * + * See the file "license.terms" for information on usage and redistribution of + * this file, and for a DISCLAIMER OF ALL WARRANTIES. + */ + +#ifndef _TCLABSTRACTLIST +#define _TCLABSTRACTLIST + +#include "tclInt.h" + +static inline AbstractList* AbstractListGetInternalRep( + Tcl_Obj *objPtr) /* Object of type AbstractList */ +{ + const Tcl_ObjInternalRep *irPtr; + irPtr = TclFetchInternalRep((objPtr), &tclAbstractListType); + return irPtr ? (AbstractList *)(irPtr->twoPtrValue.ptr1) : NULL; +} + + +static inline const char* +Tcl_AbstractListTypeName( + Tcl_Obj *objPtr) /* Should be of type AbstractList */ +{ + AbstractList *abstractListRepPtr = + AbstractListGetInternalRep(objPtr); + return (abstractListRepPtr->typeName + ? abstractListRepPtr->typeName + : (objPtr->typePtr + ? objPtr->typePtr->name + : "pure string")); +} + + +Tcl_Obj* Tcl_NewAbstractListObj(Tcl_Interp *interp, const char* typeName, size_t requiredSize); +int Tcl_AbstractListCheckedSetProc(Tcl_Obj *objPtr, Tcl_AbstractListProcType ptype, void** procPtr); +Tcl_WideInt Tcl_AbstractListObjLength(Tcl_Obj *abstractListPtr); +Tcl_Obj* Tcl_AbstractListObjIndex(Tcl_Obj *abstractListPtr, Tcl_WideInt index); +Tcl_Obj* Tcl_AbstractListObjRange(Tcl_Obj *abstractListPtr, Tcl_WideInt fromIdx, Tcl_WideInt toIdx); +Tcl_Obj* Tcl_AbstractListObjReverse(Tcl_Obj *abstractListPtr); +int Tcl_AbstractListObjGetElements(Tcl_Interp *interp, Tcl_Obj *objPtr, int *objcPtr, Tcl_Obj ***objvPtr); + +#endif + +/* + * Local Variables: + * mode: c + * c-basic-offset: 4 + * fill-column: 78 + * End: + */ |