Michael Heilmann's Arcadia Ring 2
This is the documentation for Michael Heilmann's Arcadia Ring 2. Arcadia Ring 2 facilitates the creation of C programs - in particular interpreters - that are portable, maintainable, as well as safe.
Files
You can find the sources of Arcadia Ring 2 in my GitHub repository https://github.com/michaelheilmann/michaelheilmann.com. The subdirectory of Arcadia Ring 2 in the repository is here https://github.com/michaelheilmann/michaelheilmann.com/tree/main/Runtime/Ring2.
- The (sources of the) library resides in the directory https://github.com/michaelheilmann/michaelheilmann.com/tree/main/Runtime/Ring2/Library
- The (sources of) tests reside in the directory https://github.com/michaelheilmann/michaelheilmann.com/tree/main/Runtime/Ring2/Tests
- The (sources of this very documentation you are reading) documentation reside in the directory https://github.com/michaelheilmann/michaelheilmann.com/tree/main/Runtime/Ring2/Documentation
Arcadia Ring 2 supports various platforms (including but not restricted to Windows, Linux, and many more), however, we currently only officially support Windows. For instructions on how to build, test, and use Arcadia Ring 1, refer to README.md in the root folder of the repository.
Further References
Arcadia Ring 2 relies on Arcadia Ring 1 and Arcadia ARMS.
Documentation
Objects
Arcadia_Object
Arcadia_Object
is the ancestor type from which so called object types derive from.
Arcadia_Object
types are allocated on the heap and can are referenced by Arcadia_Object*
pointers.
Arcadia_Object_getHash
Arcadia_SizeValue
Arcadia_Object_getHash
(
Arcadia_Thread* thread,
Arcadia_Object* self
)
Arcadia_Object
or derived type value.
Parameters
Arcadia_Thread
object.Return value
The hash of this code>Arcadia_Object or derived type value.
Arcadia_Object_isEqualTo
Arcadia_BooleanValue
Arcadia_Object_isEqualTo_pn
(
Arcadia_Thread* thread,
Arcadia_Object* self,
Arcadia_Value other
)
Arcadia_Object
or derived type value is equal to the specified value other
.
Parameters
Arcadia_Thread
object.Return value
Arcadia_BooleanValue_True
if this code>Arcadia_Object or derived type value is equal to the other value.
Arcadia_BooleanValue_False
otherwise.
Arcadia_Object_isNotEqualTo
Arcadia_BooleanValue
Arcadia_Object_isEqualTo_pn
(
Arcadia_Thread* thread,
Arcadia_Object* self,
Arcadia_Value other
)
Arcadia_Object
or derived type value is not equal to the specified value other
.
Parameters
Arcadia_Thread
object.Return value
Arcadia_BooleanValue_True
if this code>Arcadia_Object or derived type value is not equal to the other value.
Arcadia_BooleanValue_False
otherwise.
Arcadia_ByteBuffer
Arcadia_ByteBuffer
extends Arcadia_Object
.
Arcadia_ByteBuffer
represents a mutable sequence of Bytes.
Arcadia_ByteBuffer_create
Arcadia_ByteBuffer*
Arcadia_ByteBuffer_create
(
Arcadia_Thread* thread
)
Parameters
Arcadia_Thread
object.Errors
Return value
A pointer to the Arcadia_ByteBuffer
object.
Arcadia_ByteBuffer_clear
void
Arcadia_ByteBuffer_clear
(
Arcadia_Thread* thread,
Arcadia_ByteBuffer* self
)
Parameters
Arcadia_Thread
object.Arcadia_ByteBuffer_endsWith_pn
Arcadia_BooleanValue
Arcadia_ByteBuffer_endsWith_pn
(
Arcadia_Thread* thread,
Arcadia_ByteBuffer const* self,
void const* bytes,
Arcadia_SizeValue numberOfBytes
)
Parameters
Arcadia_Thread
object.n
Bytes.p
.Return value
Arcadia_BooleanValue_True
if the sequence of Bytes is a suffix of this byte buffer's sequence of Bytes.
Arcadia_BooleanValue_False
otherwise.
Arcadia_ByteBuffer_startsWith_pn
Arcadia_BooleanValue
Arcadia_ByteBuffer_startsWith_pn
(
Arcadia_Thread* thread,
Arcadia_ByteBuffer* self,
void const* bytes,
Arcadia_SizeValue numberOfBytes
)
Parameters
Arcadia_Thread
object.n
Bytes.p
.Return value
Arcadia_BooleanValue_True
if the sequence of Bytes is a prefix of this byte buffer's sequence of Bytes.
Arcadia_BooleanValue_False
otherwise.
Arcadia_isEqualTo_pn
Arcadia_BooleanValue
Arcadia_ByteBuffer_isEqualTo_pn
(
Arcadia_Thread* thread,
Arcadia_ByteBuffer* self,
void const* bytes,
Arcadia_SizeValue numberOfBytes
)
Parameters
Arcadia_Thread
object.n
Bytes.p
.Return value
Arcadia_BooleanValue_True
if the sequence of Bytes is this byte buffer's sequence of Bytes.
Arcadia_BooleanValue_False
otherwise.
Arcadia_ByteBuffer_append_pn
void
Arcadia_ByteBuffer_append_pn
(
Arcadia_Thread* thread,
Arcadia_ByteBuffer* self,
void const* bytes,
Arcadia_SizeValue numberOfBytes
)
Parameters
Arcadia_Thread
object.n
Bytes.p
.Errors
self
is a null pointer.bytes
is a null pointer.Arcadia_ByteBuffer_prepend_pn
void
Arcadia_ByteBuffer_prepend_pn
(
Arcadia_Thread* thread,
Arcadia_ByteBuffer* self,
void const* p,
Arcadia_SizeValue n
)
Parameters
Arcadia_Thread
object.n
Bytes.p
.Errors
self
is a null pointer.bytes
is a null pointer.Arcadia_ByteBuffer_insert_pn
void
Arcadia_ByteBuffer_insert_pn
(
Arcadia_Thread* thread,
Arcadia_ByteBuffer* self,
Arcadia_SizeValue index,
void const* p,
Arcadia_SizeValue n
)
Parameters
Arcadia_Thread
object.[0,n)
where n
is the size of this Byte buffer.n
Bytes.p
.Errors
self
is a null pointer.bytes
is a null pointer.Arcadia_ByteBuffer_isEqualTo
Arcadia_BooleanValue
Arcadia_ByteBuffer_isEqualTo
(
Arcadia_Thread* thread,
Arcadia_ByteBuffer const* self,
Arcadia_ByteBuffer const* other
)
Parameters
Arcadia_Thread
object.Return value
Arcadia_BooleanValue_True
if this Byte buffer is equal to the other Byte buffer.
Arcadia_BooleanValue_False
otherwise.
Arcadia_ByteBuffer_getSize
Arcadia_SizeValue
Arcadia_ByteBuffer_getSize
(
Arcadia_Thread* thread,
Arcadia_ByteBuffer const* self
)
Parameters
Arcadia_Thread
object.Return value
The size of this Byte buffer.
Arcadia_ByteBuffer_getAt
Arcadia_Natural8Value
Arcadia_ByteBuffer_getAt
(
Arcadia_Thread* thread,
Arcadia_ByteBuffer const* self,
Arcadia_SizeValue index
)
Parameters
Arcadia_Thread
object.[0,n)
where n
is the size of this Byte buffer.Return value
The Byte value.
Arcadia_ByteBuffer_isEmpty
Arcadia_BooleanValue
Arcadia_ByteBuffer_isEmpty
(
Arcadia_Thread* thread,
Arcadia_ByteBuffer* self
)
Parameters
Arcadia_Thread
object.Return value
Arcadia_BooleanValue_True
if this Byte buffer is empty. Arcadia_BooleanValue_False
otherwise.
Errors
self
is a null pointer.Arcadia_ByteBuffer_swap
void
Arcadia_ByteBuffer_swap
(
Arcadia_Thread* thread,
Arcadia_ByteBuffer* self,
Arcadia_ByteBuffer* other
)
Parameters
Arcadia_Thread
object.Errors
self
is a null pointer.other
is a null pointer.Arcadia_ExistingFilePolicy
typedef enum Arcadia_ExistingFilePolicy Arcadia_ExistingFilePolicy;
Elements
Arcadia_ExistingFilePolicy_Retain
Arcadia_ExistingFilePolicy_Truncate
Arcadia_FileAccessMode
typedef enum Arcadia_FileAccessMode Arcadia_FileAccessMode;
Elements
Arcadia_FileAccessMode_Read
Arcadia_FileAccessMode_Write
.
Arcadia_FileAccessMode_Write
Arcadia_FileAccessMode_Read
.
Arcadia_FileAccessMode_ReadWrite
Arcadia_FileAccessMode_Read|Arcadia_FileAccessMode_Write
and for Arcadia_FileAccessMode_WriteRead
.
Arcadia_FileAccessMode_WriteRead
Arcadia_FileAccessMode_Write|Arcadia_FileAccessMode_Read
and for Arcadia_FileAccessMode_ReadWrite
.
Arcadia_FileHandle
Arcadia_FileHandle
extends Arcadia_Object
.
Arcadia_FileHandle
represents a operating system file handle.
Arcadia_FileHandle_create
Arcadia_FileHandle*
Arcadia_FileHandle_create
(
Arcadia_Thread* thread,
Arcadia_FileSystem* fileSystem
)
Parameters
Arcadia_Thread
object.Arcadia_FileSystem
object.Return value
A pointer to the file handle.
Arcadia_FileHandle_close
void
Arcadia_FileHandle_close
(
Arcadia_Thread* thread,
Arcadia_FileHandle* self
)
Parameters
Arcadia_Thread
object.Arcadia_FileHandle_openForReading
void
Arcadia_FileHandle_openForReading
(
Arcadia_Thread* thread,
Arcadia_FileHandle* self,
Arcadia_FilePath* path
)
Parameters
Arcadia_Thread
object.Errors
self
is a null pointer.path
is a null pointer.Arcadia_FileHandle_openForWriting
void
Arcadia_FileHandle_openForWriting
(
Arcadia_FileHandle* self,
Arcadia_FilePath* path
)
Parameters
Errors
self
is a null pointer.path
is a null pointer.Arcadia_FileHandle_isClosed
Arcadia_BooleanValue
Arcadia_FileHandle_isClosed
(
Arcadia_FileHandle const* self
)
Parameters
Return value
Arcadia_BooleanValue_True
if this file handle is closed.
Arcadia_BooleanValue_False
otherwise.
Arcadia_FileHandle_isOpened
Arcadia_BooleanValue
Arcadia_FileHandle_isOpened
(
Arcadia_FileHandle const* self
)
Parameters
Return value
Arcadia_BooleanValue_True
if this file handle is opened.
Arcadia_BooleanValue_False
otherwise.
Arcadia_FileHandle_isOpenedForReading
Arcadia_BooleanValue
Arcadia_FileHandle_isOpenedForReading
(
Arcadia_FileHandle const* self
)
Parameters
Return value
Arcadia_BooleanValue_True
if this file handle is opened for reading.
Arcadia_BooleanValue_False
otherwise.
Arcadia_FileHandle_isOpenedForWriting
Arcadia_BooleanValue
Arcadia_FileHandle_isOpenedForWriting
(
Arcadia_FileHandle const* self
)
Parameters
Return value
Arcadia_BooleanValue_True
if this file handle is opened for writing.
Arcadia_BooleanValue_False
otherwise.
Arcadia_FileHandle_write
void
Arcadia_FileHandle_write
(
Arcadia_FileHandle* self,
void const* p,
Arcadia_SizeValue bytesToWrite
)
Parameters
bytesToWrite
Bytes.bytes
.Arcadia_SizeValue
variable.Success
*bytesWritten
is assigned the actual number of Bytes written.
Errors
self
is a null pointer. bytes
is a null pointer.Arcadia_FileHandle_read
void
Arcadia_FileHandle_read
(
Arcadia_FileHandle* self,
void const* bytes,
Arcadia_SizeValue bytesToRead,
Arcadia_SizeValue* bytesRead
)
Parameters
bytesToWrite
Bytes.bytes
.Arcadia_SizeValue
variable.Success
*bytesRead
is assigned the actual number of Bytes read.
The number of Bytes read is 0 if the end of the file was reached.
Errors
self
is a null pointer.bytes
is a null pointer.bytesRead
is a null pointer.Arcadia_FilePath
Arcadia_FilePath
extends Arcadia_Object
.
Arcadia_FilePath
represents a file path.
create
Arcadia_FilePath*
Arcadia_FilePath_create
(
Arcadia_Thread* thread
)
Parameters
Arcadia_Thread
object.Return value
A pointer to the file path.
Arcadia_FilePath_parseWindows
Arcadia_FilePath*
Arcadia_FilePath_parseWindows
(
Arcadia_Thread* thread,
void const* bytes,
Arcadia_SizeValue numberOfBytes
)
Parameters
Arcadia_Thread
object.numberOfBytes
Bytes.bytes
Bytes.Return value
A pointer to the file path.
Arcadi_FilePath_parseUnix
Arcadia_FilePath*
Arcadia_FilePath_parseUnix
(
Arcadia_Thread* thread,
void const* bytes,
Arcadia_SizeValue numberOfBytes
)
Parameters
Arcadia_Thread
object.numberOfBytes
Bytes.bytes
Bytes.Return value
A pointer to the file path.
Arcadia_FilePath_parseNative
Arcadia_FilePath*
Arcadia_FilePath_parseNative
(
Arcadia_Thread* thread,
void const* bytes,
Arcadia_SizeValue numberOfBytes
)
Parameters
Arcadia_Thread
object.numberOfBytes
Bytes.bytes
Bytes.Return value
A pointer to the file path.
Arcadia_FilePath_toNative
Arcadia_String*
Arcadia_FilePath_toNative
(
Arcadia_Thread* thread,
Arcadia_FilePath* self
)
Parameters
Arcadia_Thread
object.Return value
A pointer to the string.
Arcadia_FileSystem
Arcadia_FileSystem
extends Arcadia_Object
.
Arcadia_FileSystem
provides access to the file system.
Arcadia_FileSystem_create
Arcadia_FileSystem*
Arcadia_FileSystem_create
(
Arcadia_Thread* thread
)
Parameters
Arcadia_Thread
object.Errors
Return value
A pointer to a Arcadia_FileSystem
object.
Remarks
Do not call this function.
Call Arcadia_FileSystem_getOrCreate
instead.
Arcadia_FileSystem_getOrCreate
Arcadia_FileSystem*
Arcadia_FileSystem_getOrCreate
(
Arcadia_Thread* thread
)
Parameters
Arcadia_Thread
object.Errors
Return value
A pointer to a Arcadia_FileSystem
object.
Arcadia_FileSystem_getFileContents
Arcadia_ByteBuffer*
Arcadia_FileSystem_getFileContents
(
Arcadia_Thread* thread,
Arcadia_FileSystem* self,
Arcadia_FilePath* path
)
Parameters
Arcadia_Thread
object.Arcadia_FileSystem
object.Return value
A pointer to a Arcadia_ByteBuffer
object with the file contents.
Errors
self
is a null pointer.path
is a null pointer.Arcadia_FileSystem_setFileContents
void
Arcadia_FileSystem_setFileContents
(
Arcadia_Thread* thread,
Arcadia_FileSystem* self,
Arcadia_FilePath* path,
Arcadia_ByteBuffer* contents
)
Parameters
Arcadia_Thread
object.Arcadia_FileSystem
object.Errors
sekf
is a null pointer.path
is a null pointer.contents
is a null pointer.Arcadia_FileSystem_regularFileExists
Arcadia_BooleanValue
Arcadia_FileSystem_regularFileExists
(
Arcadia_Thread* thread,
Arcadia_FileSystem* self,
Arcadia_FilePath* path
)
Parameters
Arcadia_Thread
object.Arcadia_FileSystem
object.Return value
Arcadia_BooleanValue_True
if the file exists and is a regular file.
Arcadia_BooleanValue_False
otherwise.
Errors
self
is a null pointer.path
is a null pointer.Arcadia_FileSystem_directoryFileExists
Arcadia_BooleanValue
Arcadia_FileSystem_directoryFileExists
(
Arcadia_Thread* thread,
Arcadia_FileSystem* self,
Arcadia_FilePath* path
)
Parameters
Arcadia_Thread
object.Arcadia_FileSystem
object.Return value
Arcadia_BooleanValue_True
if the file exists and is a directory file.
Arcadia_BooleanValue_False
otherwise.
Errors
self
is a null pointer.path
is a null pointer.Arcadia_FileType
typedef enum Arcadia_FileType Arcadia_FileType;
Elements
Arcadia_FileType_Unknown
Arcadia_FileType_Regular
Arcadia_FileType_Directory
Arcadia_NonExistingFilePolicy
typedef enum Arcadia_NonExistingFilePolicy Arcadia_NonExistingFilePolicy;
Elements
Arcadia_NonExistingFilePolicy_Fail
Arcadia_NonExistingFilePolicy_Create
Collection
Arcadia_Collection
extends Arcadia_Object
.
Arcadia_Collection
represents a collection of Arcadia_Value
objects.
Arcadia_Collection_clear
void
Arcadia_Collection_clear
(
Arcadia_Thread* thread,
Arcadia_Collection* self
)
Parameters
Arcadia_Thread
object.Arcadia_Collection_getSize
Arcadia_SizeValue
Arcadia_Collection_getSize
(
Arcadia_Thread* thread,
Arcadia_Collection* self
)
Parameters
Arcadia_Thread
object.Return value
The size of this collection.
Errors
self
is a null pointer.Arcadia_Collection_isEmpty
Arcadia_BooleanValue
Arcadia_Collection_isEmpty
(
Arcadia_Thread* thread,
Arcadia_Collection* self
)
Parameters
Arcadia_Thread
object.Return value
Arcadia_BooleanValue_True
if this collection is empty. Arcadia_BooleanValue_False
otherwise.
Errors
self
is a null pointer.Arcadia_List
Arcadia_List
extends Arcadia_Collection
.
Arcadia_List
represents a list of Arcadia_Value
objects.
Arcadia_List_getAt
Arcadia_Value
Arcadia_List_getAt
(
Arcadia_Thread* thread,
Arcadia_List* self,
Arcadia_SizeValue index
)
Parameters
Arcadia_Thread
object.[0,n)
where n
is the size of this list.Errors
index
is out of bounds.Return value
The value.
Arcadia_List_insertAt
void
Arcadia_List_insertAt
(
Arcadia_Thread* thread,
Arcadia_List* self,
Arcadia_SizeValue index,
Arcadia_Value value
)
Parameters
Arcadia_Thread
object.[0,n]
where n
is the size of thie list.Errors
index
is out of bounds.value
is a Void value.Arcadia_List_insertBack
void
Arcadia_List_insertBack
(
Arcadia_Thread* thread,
Arcadia_List* self,
Arcadia_Value value
)
Parameters
Arcadia_Thread
object.Errors
value
is a Void value.Arcadia_List_insertFront
void
Arcadia_List_insertFront
(
Arcadia_Thread* thread,
Arcadia_List* self,
Arcadia_Value value
)
Parameters
Arcadia_Thread
object.Errors
value
is a Void value.Arcadia_List_removeAt
void
Arcadia_List_removeAt
(
Arcadia_Thread* thread,
Arcadia_List* self,
Arcadia_SizeValue start,
Arcadia_SizeValue length
)
length
values starting with element at index start
.
Parameters
Arcadia_Thread
object.Errors
self
is a null pointer.index + length > n
where n
is the length of the list.Map
Arcadia_Map
extends Arcadia_Collection
.
Arcadia_Map
represents a map from Arcadia_Value
objects, the keys, to Arcadia_Value
objects, the values.
Arcadia_Map_get
Arcadia_Value
Arcadia_Map_get
(
Arcadia_Thread* thread,
Arcadia_Map* self,
Arcadia_Value key
)
Get the value of an entry for a given key in this map.
More formally: Let \(x\) be the specified key.
- If there exist an entry \(x' \mapsto y'\) in the map such that \(x\) is equivalent to \(x'\), then y' is returned.
- Otherwise (if there exists no such entry in the map), then a Void value is returned.
Parameters
Arcadia_Thread
object.Arcadia_Map
object.Return value
The value for the given key if it was found. A Void value otherwise.
Errors
key
is a Void value.Arcadia_Map_remove
Arcadia_Value
Arcadia_Map_set
(
Arcadia_Thread* thread,
Arcadia_Stack* self,
Arcadia_Value key
)
Remove an entry for a given key from this map.
More formally: Let \(x\) be the specified key and \(y\) be the specified value.
- If \(y\) is an Void value then there are two cases:
- If there exist an entry \((x' \mapsto y')\) in the map such that \(x\) is equivalent to \(x'\), then this entry is removed and y' is returned.
- Otherwise (if there exists no such entry in the map), then a Void value is returned.
- Otherwise (\(y\) is not an Void value) then there are two cases:
- If there exist one \((x' \mapsto y')\) in the map such that \(x\) is equivalent to \(x'\), then this entry is replaced by the entry \((x' \mapsto y)\) and y' is returned.
- Otherwise the entry \((x \mapsto y)\) is added and an Void value is returned.
Parameters
Arcadia_Thread
object.Return value
The value of the removed entry \((x \mapsto y)\) such an entry was found. A Void value otherwise.
Errors
key
is a Void value.Arcadia_Map_set
void
Arcadia_Map_set
(
Arcadia_Thread* thread,
Arcadia_Stack* self,
Arcadia_Value key,
Arcadia_Value value
Arcadia_Value* oldKey,
Arcadia_Value* oldValue,
)
Set the value for the given key in this map.
More formally: Let \(x\) be the specified key and \(y\) be the specified value.
- If \(x\) is an Void value, then an Argument Type Invalid error is raised.
- If \(y\) is an Void value then there are two cases:
-
If there exist an entry \((x' \mapsto y')\) in the map such that \(x\) is equivalent to \(x'\), then this entry is removed.
\(x'\) is returned in
*oldKey
if oldKey is not null. \(y'\) is returned in*oldValue
if oldValue is not null. -
Otherwise (if there exists no such entry in the map):
Void value is returned in
*oldKey
if oldKey is not null. Void value is returned in*oldValue
if oldValue is not null.
-
If there exist an entry \((x' \mapsto y')\) in the map such that \(x\) is equivalent to \(x'\), then this entry is removed.
\(x'\) is returned in
- Otherwise (\(y\) is not an Void value) then there are two cases:
-
If there exist one \(x' \mapsto y'\) in the map such that \(x\) is equivalent to \(x'\), then this entry is replaced by the entry \(x \mapsto y\).
\(x'\) is returned in
*oldKey
if oldKey is not null. \(y'\) is returned in*oldValue
if oldValue is not null. -
Otherwise the entry \(x \mapsto y\) is added.
Void value is returned in
*oldKey
if oldKey is not null. Void value is returned in*oldValue
if oldValue is not null.
Parameters
Arcadia_Thread
object.Return value
The value of the removed entry \((x' \mapsto y')\) if an entry for the given key if it was found. A Void value otherwise.
Errors
key
is a Void value.Set
Arcadia_Set
extends Arcadia_Collection
.
Arcadia_Set
represents a set of Arcadia_Value
objects.
Arcadia_Set_contains
Arcadia_BooleanValue
Arcadia_Set_contains
(
Arcadia_Thread* thread,
Arcadia_Set* self,
Arcadia_Value value
)
- If \(x\) is an Void value, then an Argument Type Invalid error is raised.
- Otherwise (that is, if \(x\) is not an Void value):
- If there exist one \(x'\) in the map such that \(x\) is equivalent to \(x'\), then Arcadia_BooleanValue_True is returned.
- Otherwise Arcadia_BooleanValue_False is returned.
Parameters
Arcadia_Thread
object.Arcadia_Set
object.Return value
Arcadia_BooleanValue_True
if \(x\) contained in this set.
Arcadia_BooleanValue_False
otherwise.
Arcadia_Set_get
Arcadia_Value
Arcadia_Set_get
(
Arcadia_Thread* thread,
Arcadia_Set self,
Arcadia_Value value
)
Get the value in this set.
More formally: Let \(x\) be the value to get.
- If \(x\) is an Void value, then an Argument Type Invalid error is raised.
- Otherwise (\(x\) is not an Void value) then there are two cases:
- If there exist one \(x'\) in the map such that \(x\) is equivalent to \(x'\), then \(x'\) is returned.
- Otherwise the Void value is returned.
Parameters
Arcadia_Thread
object.Return value
The value \(x'\) or the Void value.
Arcadia_Set_add
void
Arcadia_Set_add
(
Arcadia_Thread* thread,
Arcadia_Set self,
Arcadia_Value value,
Arcadia_Value* oldValue
)
Add value to this set.
More formally: Let \(x\) be the value to be added.
- If \(x\) is an Void value, then an Argument Type Invalid error is raised.
- Otherwise (\(x\) is not an Void value) then there are two cases:
-
If there exist one \(x'\) in the map such that \(x\) is equivalent to \(x'\), \(x'\) is replaced by \(x\) in this set.
\(x'\) is returned in
*oldValue
if oldValue is not null. -
Otherwise \(x\) is added to this set.
Void value is returned in
*oldValue
ifoldValue
is not a null pointer.
Parameters
Arcadia_Thread
object.Arcadia_Value
object or a null pointer.Return value
Arcadia_BooleanValue_True
if \(x\) was added to this set. Arcadia_BooleanValue_False
otherwise.
Arcadia_Set_remove
void
Arcadia_Set_remove
(
Arcadia_Thread* thread,
Arcadia_Set* self,
Arcadia_Value value,
Arcadia_Value *oldValue
)
Remove a value from this set.
More formally: Let \(x\) be the value to be removed.
- If \(x\) is an Void value, then an Argument Type Invalid error is raised.
- Otherwise (\(x\) is not an Void value) then there are two cases:
-
If there exist one \(x'\) in the map such that \(x\) is equivalent to \(x'\), \(x'\) is removed from this set.
\(x'\) is returned in
*oldValue
if oldValue is not null. -
Void value is returned in
*oldValue
ifoldValue
is not a null pointer.
Parameters
Arcadia_Thread
object.Arcadia_Value
object or a null pointer.Return value
Arcadia_BooleanValue_True
if value
was removed to this set. Arcadia_BooleanValue_False
otherwise.
Stack
Arcadia_Stack
extends Arcadia_Collection
.
Arcadia_Stack
represents a stack of Arcadia_Value
objects.
Arcadia_Stack_create
Arcadia_Stack*
Arcadia_Stack_create
(
Arcadia_Thread* thread
)
Parameters
Arcadia_Thread
object.Errors
Return value
A pointer to the Arcadia_Stack
value.
Arcadia_Stack_peek
Arcadia_Value
Arcadia_Stack_peek
(
Arcadia_Thread* thread,
Arcadia_Stack* self
)
Parameters
Arcadia_Thread
object.Return value
The value.
Errors
Arcadia_Stack_pop
Arcadia_Value
Arcadia_Stack_pop
(
Arcadia_Thread* thread,
Arcadia_Stack* self
)
Parameters
Arcadia_Thread
object.Return value
The value.
Errors
Arcadia_Stack_push
void
Arcadia_Stack_push
(
Arcadia_Thread* thread,
Arcadia_Stack* self,
Arcadia_Value value
)
Parameters
Arcadia_Thread
object.Errors
value
is a Void value.Arcadia_String
Arcadia_String
extends Arcadia_Object
.
Arcadia_String
represents an immutable sequence of Unicode code points in UTF8 encoding.
Arcadia_String derives fro Arcadia_Object and overrides the following methods:
- Arcadia_Object_isEqualTo
- Arcadia_Object_isNotEqualTo
- Arcadia_Object_getHash
Arcadia_String_create_pn
Arcadia_String*
Arcadia_String_create_pn
(
Arcadia_Thread* thread,
Arcadia_ImmutableByteArray* immutableByteArray
)
Parameters
Arcadia_Thread
object.Arcadia_ImmutableByteArray
objectReturn value
A pointer to the Arcadia_String
object.
Errors
immutableByteArray
is a null pointer.Arcadia_String_create
Arcadia_String*
Arcadia_String_create
(
Arcadia_Thread* thread,
Arcadia_Value value
)
Create a string from a value.
The following values are accepted:
The specified value may contain a Arcadia_ByteBuffer
object.
In that case, the string is created from the Bytes of the Byte buffer object.
A Arcadia_Status_EncodingInvalid
is raised if the Byte sequence of that Arcada_ByteBuffer
object is not a UTF8 Byte sequence.
The specified value may contain a Arcadia_ImmutableByteArray
object.
In that case, the string is created from the Arcadia_ImmutableByteArray
object.
A Arcadia_Status_EncodingInvalid
is raised if the Byte sequence of that Arcada_ImmutableByteArray
object is not a UTF8 Byte sequence.
The specified value may contain a Arcadia_String
object.
In that case, the string is created from the Arcadia_String
object.
The specified value may contain a Arcadia_StringBuffer
object.
In that case, the string is created from the Arcadia_StringBuffer
object.
The specified value may contain a Arcadia_ImmutableUtf8String
object.
In that case, the string is created from the Arcadia_ImmutableUtf8String
object.
Parameters
Arcadia_Thread
object.
Return value
A pointer to the string.
Errors
Arcadia_ByteBuffer
, Arcadia_String
, Arcadia_StringBuffer
, or Arcadia_ImmutableByteArray
.
Arcadia_ByteBuffer
or Arcadia_ImmutableByteArray
.
However, the Byte sequence of that Arcadia_ByteBuffer
or Arcadia_ImmutableByteArray
object is not a UTF8 Byte sequence.
Arcadia_String_endsWith_pn
Arcadia_BooleanValue
Arcadia_String_endsWith_pn
(
Arcadia_Thread* thread,
Arcadia_String const* self,
void const* bytes,
Arcadia_SizeValue numberOfBytes
)
Parameters
Arcadia_Thread
object.n
Bytes.p
.Return value
Arcadia_BooleanValue_True
if the sequence of Bytes is a suffix of this string's sequence of Bytes.
Arcadia_BooleanValue_False
otherwise.
Arcadia_String_startsWith_pn
Arcadia_BooleanValue
Arcadia_String_startsWith_pn
(
Arcadia_Thread* thread,
Arcadia_String const* self,
void const* bytes,
Arcadia_SizeValue numberOfBytes
)
Parameters
Arcadia_Thread
object.n
Bytes.p
.Return value
Arcadia_BooleanValue_True
if the sequence of Bytes is a prefix of this string's sequence of Bytes.
Arcadia_BooleanValue_False
otherwise.
Arcadia_String_isEqualTo_pn
Arcadia_BooleanValue
Arcadia_String_isEqualTo_pn
(
Arcadia_Thread* thread,
Arcadia_String const* self,
void const* bytes,
Arcadia_SizeValue numberOfBytes
)
Parameters
Arcadia_Thread
object.n
Bytes.p
.Return value
Arcadia_BooleanValue_True
if the sequence of Bytes is this string's sequence of Bytes.
Arcadia_BooleanValue_False
otherwise.
Arcadia_String_getNumberOfBytes
Arcadia_SizeValue
Arcadia_String_getNumberOfBytes
(
Arcadia_Thread* thread,
Arcadia_String const* self
)
Parameters
Arcadia_Thread
object.Return value
The size, in Bytes, of this string.
Arcadia_String_getByteAt
Arcadia_Natural8Value
Arcadia_String_getByteAt
(
Arcadia_String const* self,
Arcadia_SizeValue index
)
Parameters
Arcadia_Thread
object.[0,n)
where n
is the size, in Bytes, of this string.Return value
The Byte value.
Arcadia_String_toBoolean
Arcadia_BooleanValue
Arcadia_String_toBoolean
(
Arcadia_Thread* thread,
Arcadia_String const* self
)
Arcadia_BooleanValue
.
Parameters
Arcadia_Thread
object.Return value
The boolean value.
Errors
self
is a null pointer.true
and false
, both case sensitve.Arcadia_String_toInteger16
Arcadia_Integer16Value
Arcadia_String_toInteger16
(
Arcadia_Thread* thread,
Arcadia_String const* self
)
Arcadia_Integer16Value
.
Parameters
Arcadia_Thread
object.Return value
The integer value.
Errors
self
is a null pointer.Arcadia_Integer16Value
.Arcadia_String_toInteger32
Arcadia_Integer32Value
Arcadia_String_toInteger32
(
Arcadia_Thread* thread,
Arcadia_String const* self
)
Arcadia_Integer32Value
.
Parameters
Arcadia_Thread
object.Return value
The integer value.
Errors
self
is a null pointer.
Arcadia_Integer32Value
.
Arcadia_String_toInteger64
Arcadia_Integer64Value
Arcadia_String_toInteger64
(
Arcadia_Thread* thread,
Arcadia_String const* self
)
Arcadia_Integer64Value
.
Parameters
Arcadia_Thread
object.Return value
The integer value.
Errors
self
is a null pointer.
Arcadia_Integer64Value
.Arcadia_String_toInteger8
Arcadia_Integer8Value
Arcadia_String_toInteger8
(
Arcadia_Thread* thread,
Arcadia_String const* self
)
Arcadia_Integer8Value
.
Parameters
Arcadia_Thread
object.Return value
The integer value.
Errors
self
is a null pointer.
Arcadia_Integer8Value
.Arcadia_String_toNatural16
Arcadia_Natural16Value
Arcadia_Stringg_toNatural16
(
Arcadia_Thread* thread,
Arcadia_String const* self
)
Arcadia_Natural16Value
.
Parameters
Arcadia_Thread
object.Return value
The natural value.
Errors
self
is a null pointer.Arcadia_Natural16Value
.Arcadia_String_toNatural32
Arcadia_Natural32Value
Arcadia_String_toNatural32
(
Arcadia_Thread* thread,
Arcadia_String const* self
)
Arcadia_Natural32Value
.
Parameters
Arcadia_Thread
object.Return value
The natural value.
Errors
self
is a null pointer.Arcadia_Natural32Value
.Arcadia_String_toNatural64
Arcadia_Natural64Value
Arcadia_String_toNatural64
(
Arcadia_Thread* thread,
Arcadia_String const* self
)
Arcadia_Natural64Value
.
Parameters
Arcadia_Thread
object.Return value
The natural value.
Errors
self
is a null pointer.Arcadia_Natural64Value
.Arcadia_String_toNatural8
Arcadia_Natural8Value
Arcadia_String_toNatural8
(
Arcadia_Thread* thread,
Arcadia_String const* self
)
Arcadia_Natural8Value
.
Parameters
Arcadia_Thread
object.Return value
The natural value.
Errors
self
is a null pointer.Arcadia_Natural8Value
.Arcadia_String_toReal32
Arcadia_Real32Value
Arcadia_String_toReal32
(
Arcadia_Thread* thread,
Arcadia_String const* self
)
Arcadia_Real32Value
.
Parameters
Arcadia_Thread
object.Return value
The Arcadia_Real32Value
value.
Errors
self
is a null pointer.Arcadia_Real32Value
.Arcadia_String_toReal64
Arcadia_Real64Value
Arcadia_String_toReal64
(
Arcadia_Thread* thread,
Arcadia_String const* self
)
Arcadia_Real64Value
.
Parameters
Arcadia_Thread
object.Return value
The Arcadia_Real64Value
value.
Errors
self
is a null pointer.Arcadia_Real64Value
.Arcadia_String_toVoid
Arcadia_VoidValue
Arcadia_String_toVoid
(
Arcadia_Thread* thread,
Arcadia_String const* self
)
Arcadia_VoidValue
.
Parameters
Arcadia_Thread
object.Return value
The void value.
Errors
self
is a null pointer.void
, case sensitve.Arcadia_StringBuffer
Arcadia_StringBuffer
extends Arcadia_Object
.
Arcadia_StringBuffer
represents a mutable sequence of code points in UTF8 encoding.
Arcadia_StringBuffer_clear
void
Arcadia_StringBuffer_clear
(
Arcadia_Thread* thread,
Arcadia_StringBuffer* self
)
Parameters
Arcadia_Thread
object.Arcadia_StringBuffer_create
Arcadia_StringBuffer*
Arcadia_StringBuffer_create
(
Arcadia_Thread* thread
)
Parameters
Arcadia_Thread
object.Errors
Return value
A pointer to the Arcadia_StringBuffer
value.
Arcadia_StringBuffer_compareTo
Arcadia_Integer32Value*
Arcadia_StringBuffer_compareTo
(
Arcadia_Thread* thread,
Arcadia_StringBuffer* self,
Arcadia_Value other
)
Parameters
Arcadia_Thread
object.Arcadia.ImmutableUtf8String
, Arcadia.StringBuffer
, or Arcadia.String
.
Errors
Return value
- A negative value is returned if the string in this string buffer is lexicographically less than the other string.
- A positive value is returned if the string in this string buffer is lexicographically greater than the other string.
- If both strings are lexicographically equal, then zero is returned.
Remarks
Leta
and b
be UTF-8 strings of n and m Bytes, respectively.
Denote the i
-th Byte of a by a[i]
(given a
is not empty) and the i
-th Byte of b
by b[i]
(given that b
is not empty), respectively.
Then comparing a
and b
lexicographically means:
Let l := min(n,m)
.
If l
is 0
or a[i] = b[i]
for all i in [0, l-1]
, then
a
is lexicographically less thanb
ifn < m
a
is lexicographically greater thanb
ifn > m
a
andb
are lexicographically equal ifn = m
Otherwise there exists an i in [0, l - 1]
such that for all a[j] = b[j]
for all j < i
holds and a[i] != b[i]
.
In that case:
a
is lexicographically less thanb
ifa[i] < b[i]
a
is lexicographically greater thanb
ifa[i] > b[i]
Arcadia_StringBuffer_getNumberOfBytes
Arcadia_SizeValue
Arcadia_StringBuffer_getNumberOfBytes
(
Arcadia_Thread* thread,
Arcadia_StringBuffer self
)
Parameters
Arcadia_Thread
object.Return value
The number of Bytes in this string buffer.
Arcadia_StringBuffer_insertAt
void
Arcadia_StringBuffer_insertAt
(
Arcadia_Thread* thread,
Arcadia_StringBuffer* self,
Arcadia_SizeValue index,
Arcadia_Value value
)
Parameters
Arcadia_Thread
object.Arcadia.ImmutableByteArray
, Arcadia.ImmutableUtf8String
,
Arcadia.ByteBuffer
, Arcadia.StringBuffer
, or Arcadia.String
.
Errors
value
is not of an accepted type.index
is not within the bounds of [0,n] where n is the number of code points in this string buffer.value
is of type Arcadia.ImmutableByteArray
or Arcadia.ByteBuffer
and the Bytes are not a valid UTF-8 Byte sequence.Arcadia_StringBuffer_insertBack
void
Arcadia_StringBuffer_insertFront
(
Arcadia_Thread* thread,
Arcadia_StringBuffer* self,
Arcadia_Value value
)
Parameters
Arcadia_Thread
object.Arcadia.ImmutableByteArray
, Arcadia.ImmutableUtf8String
,
Arcadia.ByteBuffer
, Arcadia.StringBuffer
, or Arcadia.String
.
Errors
value
is not of an accepted type.value
is of type Arcadia.ImmutableByteArray
or Arcadia.ByteBuffer
and the Bytes are not a valid UTF-8 Byte sequence.Arcadia_StringBuffer_insertFront
void
Arcadia_StringBuffer_insertFront
(
Arcadia_Thread* thread,
Arcadia_StringBuffer* self,
Arcadia_Value value
)
Parameters
Arcadia_Thread
object.Arcadia.ImmutableByteArray
, Arcadia.ImmutableUtf8String
,
Arcadia.ByteBuffer
, Arcadia.StringBuffer
, or Arcadia.String
.
Errors
value
is not of an accepted type.value
is of type Arcadia.ImmutableByteArray
or Arcadia.ByteBuffer
and the Bytes are not a valid UTF-8 Byte sequence.Arcadia_StringBuffer_isEmpty
Arcadia_BooleanValue
Arcadia_StringBuffer_isEmpty
(
Arcadia_Thread* thread,
Arcadia_StringBuffer* self
)
Parameters
Arcadia_Thread
object.Return value
Arcadia_BooleanValue_True
if this string buffer is empty. Arcadia_BooleanValue_False
otherwise.
Errors
self
is a null pointer.