Fixed a lazySlot bug where lazy slots in different objects end up pointing to the...
[io/quag.git] / libs / iovm / source / IoSeq.h
blob18f0931f0a8f46c2deaf3eb4c724487036eeb6c6
1 /*#io
2 Sequence ioDoc(
3 docCopyright("Steve Dekorte", 2002)
4 docLicense("BSD revised")
5 */
7 #ifndef IOSEQ_DEFINED
8 #define IOSEQ_DEFINED 1
10 #include "IoVMApi.h"
12 #include "Common.h"
13 #include "UArray.h"
14 #include "IoObject_struct.h"
15 #include "IoMessage.h"
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
21 IOVM_API int ISMUTABLESEQ(IoObject *self);
22 #define ISSEQ(self) IOOBJECT_ISTYPE(self, Seq)
23 #define ISSYMBOL(self) IoObject_isSymbol(self)
24 #define ISBUFFER(self) ISMUTABLESEQ(self)
26 #define IOSEQ(data, size) IoSeq_newWithData_length_((IoState*)IOSTATE, data, size)
27 #define IOSEQ_LENGTH(self) UArray_size((UArray *)(IoObject_dataPointer(self)))
28 #define IOSEQ_BYTES(self) UArray_bytes((UArray *)(IoObject_dataPointer(self)))
30 #define WHITESPACE " \t\n\r"
32 // Symbol defines
34 #define IOSYMBOL(s) IoState_symbolWithCString_((IoState*)IOSTATE, (char *)(s))
35 #define IOSYMBOLID(s) (IoObject_dataPointer(self))
36 #define CSTRING(uString) IoSeq_asCString(uString)
38 #if !defined(IoSymbol_DEFINED)
39 #define IoSymbol_DEFINED
40 typedef IoObject IoSymbol;
41 typedef IoObject IoSeq;
42 #endif
44 #define IOSYMBOL_LENGTH(self) UArray_size(((UArray *)(IoObject_dataPointer(self))))
45 #define IOSYMBOL_BYTES(self) UArray_bytes(((UArray *)(IoObject_dataPointer(self))))
47 typedef IoObject *(IoSplitFunction)(void *, UArray *, int);
49 typedef IoObject IoSeq;
51 IOVM_API int ioSeqCompareFunc(void *s1, void *s2);
52 IOVM_API int ioSymbolFindFunc(void *s, void *ioSymbol);
54 IOVM_API int IoObject_isStringOrBuffer(IoObject *self);
55 IOVM_API int IoObject_isNotStringOrBuffer(IoObject *self);
57 IOVM_API IoSeq *IoSeq_proto(void *state);
58 IOVM_API IoSeq *IoSeq_protoFinish(IoSeq *self);
60 IOVM_API IoSeq *IoSeq_rawClone(IoSeq *self);
61 IOVM_API IoSeq *IoSeq_new(void *state);
62 IOVM_API IoSeq *IoSeq_newWithUArray_copy_(void *state, UArray *ba, int copy);
63 IOVM_API IoSeq *IoSeq_newWithData_length_(void *state, const unsigned char *s, size_t length);
64 IOVM_API IoSeq *IoSeq_newWithCString_length_(void *state, const char *s, size_t length);
65 IOVM_API IoSeq *IoSeq_newWithCString_(void *state, const char *s);
66 IOVM_API IoSeq *IoSeq_newFromFilePath_(void *state, const char *path);
67 IOVM_API IoSeq *IoSeq_rawMutableCopy(IoSeq *self);
69 // these Symbol creation methods should only be called by IoState
71 IOVM_API IoSymbol *IoSeq_newSymbolWithCString_(void *state, const char *s);
72 IOVM_API IoSymbol *IoSeq_newSymbolWithData_length_(void *state, const char *s, size_t length);
73 IOVM_API IoSymbol *IoSeq_newSymbolWithUArray_copy_(void *state, UArray *ba, int copy);
75 // these Symbol creation methods can be called by anyone
77 IOVM_API IoSymbol *IoSeq_newSymbolWithFormat_(void *state, const char *format, ...);
81 IOVM_API void IoSeq_free(IoSeq *self);
82 IOVM_API int IoSeq_compare(IoSeq *self, IoSeq *v);
84 IOVM_API char *IoSeq_asCString(IoSeq *self);
85 IOVM_API unsigned char *IoSeq_rawBytes(IoSeq *self);
86 IOVM_API UArray *IoSeq_rawUArray(IoSeq *self);
88 IOVM_API size_t IoSeq_rawSize(IoSeq *self);
89 IOVM_API size_t IoSeq_rawSizeInBytes(IoSeq *self);
90 IOVM_API void IoSeq_rawSetSize_(IoSeq *self, size_t size);
92 // conversion
94 IOVM_API double IoSeq_asDouble(IoSeq *self);
95 IOVM_API IoSymbol *IoSeq_rawAsSymbol(IoSeq *self);
97 IOVM_API IoSymbol *IoSeq_rawAsUnquotedSymbol(IoSeq *self);
98 IOVM_API IoSymbol *IoSeq_rawAsUnescapedSymbol(IoSeq *self);
100 IOVM_API int IoSeq_rawEqualsCString_(IoSeq *self, const char *s);
101 IOVM_API double IoSeq_rawAsDoubleFromHex(IoSeq *self);
102 IOVM_API double IoSeq_rawAsDoubleFromOctal(IoSeq *self);
104 // hashing
106 int IoSeq_rawEqualTo(IoSeq *self, IoObject *other);
107 uintptr_t IoSeq_rawHash(IoSeq *self);
110 #include "IoSeq_immutable.h"
111 #include "IoSeq_mutable.h"
112 #include "IoSeq_vector.h"
113 #include "IoSeq_inline.h"
115 #ifdef __cplusplus
117 #endif
118 #endif