Michael Heilmann's Arcadia Ring 1
This is the documentation for Michael Heilmann's Arcadia Ring 1. Arcadia Ring 1 facilitates the creation of C programs - in particular interpreters - that are portable, maintainable, as well as safe. Arcadia Ring 1 is available at michaelheilmann.com/Arcadia/Ring1.
Files
You can find the sources of Arcadia Ring 1 in my GitHub repository https://github.com/michaelheilmann/arcadia. The subdirectory of Arcadia Ring 1 in the repository is here https://github.com/michaelheilmann/arcadia/tree/main/Runtime/Ring1.
- The (sources of the) library resides in the directory https://github.com/michaelheilmann/arcadia/tree/main/Runtime/Ring1/Library
- The (sources of) tests reside in the directory https://github.com/michaelheilmann/arcadia/tree/main/Runtime/Ring1/Tests
- The (sources of this very documentation you are reading) documentation reside in the directory https://github.com/michaelheilmann/arcadia/tree/main/Runtime/Ring1/Documentation
Arcadia Ring 1 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 1 relies on Arcadia ARMS.
Foundational Types
Arcadia_BooleanValue
typedef implementation detail Arcadia_BooleanValue
Arcadia_BooleanValue_True
#define Arcadia_BooleanValue_True implementation detail
true.
It converts to 1 in arithmetic expressions.
Arcadia_BooleanValue_False
#define Arcadia_BooleanValue_False implementation detail
false.
It converts to 0 in arithmetic expressions.
Arcadia_ForeignProcedureValue
typedef implementation detail Arcadia_ForeignProcedureValue;
Arcadia_ForeignProcedureValue_Null
#define Arcadia_ForeignProcedureValue_Null implementation detail
((void*)0).
Arcadia_ForeignProcedureValue_NumberOfBits
#define Arcadia_ForeignProcedureValue_NumberOfBits implementation detail
Arcadia_ForeignProcedureValue_NumberOfBytes
#define Arcadia_ForeignProcedureValue_NumberOfBytes implementation detail
Arcadia_ForeignProcedureValue_NumberOfBits divided by 8.
Arcadia_Integer*Value
typedef implementation detail Arcadia_IntegerSuffix Value
8, 16, 32, or 64.
Arcadia_Integer*Value_NumberOfBits
#define Arcadia_IntegerSuffix Value_NumberOfBits implementation detail
Arcadia_IntegerSuffix occupies
where 8, 16, 32, or 64.
The value is always equal to the value of the respective Arcadia_Integer*Value_NumberOfBytes
#define Arcadia_IntegerSuffix Value_NumberOfBytes implementation detail
Arcadia_IntegerSuffix Value occupies
where 8, 16, 32, or 64.
The value is always equal to Arcadia_IntegerSuffix Value_NumberOfBits divided by 8.
Arcadia_Integer*Value_Maximum
#define Arcadia_IntegerSuffix Value_Maximum implementation detail
Arcadia_IntegerSuffix Value type
where 8, 16, 32, or 64.
The following table denotes the value of the constant for the respective
| Value | |
| 8 | 127 |
| 16 | 32767 |
| 32 | 2147483647 |
| 64 | 9223372036854775807 |
Arcadia_Integer*Value_Minimum
#define Arcadia_IntegerSuffix Value_Minimum implementation detail
Arcadia_IntegerSuffix Value type
where 8, 16, 32, or 64.
The following table denotes the value of the constant for the respective
| Value | |
| 8 | -128 |
| 16 | -32768 |
| 32 | -2147483648 |
| 64 | -9223372036854775808 |
Arcadia_Integer*Value_Literal
#define Arcadia_IntegerSuffix Value_Literal(x) implementation detail
Arcadia_IntegerSuffix Value in C source code
where 8, 16, 32, or 64.
The following table denotes the expansions of the macro:
| Value | |
| 8 | x |
| 16 | x |
| 32 | x |
| 64 | x##LL |
Arcadia_Natural*Value
typedef implementation detail Arcadia_NaturalSuffix Value
8, 16, 32, or 64.
Arcadia_Natural*Value_NumberOfBits
#define Arcadia_NaturalSuffix Value_NumberOfBits implementation detail
Arcadia_NaturalSuffix occupies
where 8, 16, 32, or 64.
The value is always equal to the value of the respective Arcadia_Natural*Value_NumberOfBytes
#define Arcadia_IntegerSuffix Value_NumberOfBytes implementation detail
Arcadia_NaturalSuffix Value occupies
where 8, 16, 32, or 64.
The value is always equal to Arcadia_NaturalSuffix Value_NumberOfBits divided by 8.
Arcadia_Natural*Value_Minimum
#define Arcadia_NaturalSuffix Value_Minimum implementation detail
Arcadia_NaturalSuffix Value type
where 8, 16, 32, or 64.
| Value | |
| 8 | 0 |
| 16 | 0 |
| 32 | 0 |
| 64 | 0 |
Arcadia_Natural*Value_Maximum
#define Arcadia_NaturalSuffix Value_Maximum implementation detail
Arcadia_NaturalSuffix Value type
where 8, 16, 32, or 64.
The following table denotes the value of the constant for the respective Suffix
Constant | Value |
| 8 | 255 |
| 16 | 65535 |
| 32 | 4294967295 |
| 64 | 18446744073709551615 |
Arcadia_Natural*Value_Literal
#define Arcadia_NatualSuffix Value_Literal(x) implementation detail
Arcadia_NaturalSuffix Value in C source code
where 8, 16, 32, or 64.
The following table denotes the expansions of the macro:
| Value | |
| 8 | x |
| 16 | x |
| 32 | x##U |
| 64 | x##ULL |
Arcadia_ObjectReferenceValue
typedef implementation detail Arcadia_ObjectReferenceValue
Arcadia_ObjectReferenceValue type is a pointer which assume the value Arcadia_ObjectReferenceValue_Null or point to a Arcadia_Object or derived type value.
Arcadia_ObjectReferenceValue_Null
#define Arcadia_ObjectReferenceValue_Null implementation detail
((void*)0).
Arcadia_ObjectReferenceValue_NumberOfBits
#define Arcadia_ObjectReferenceValue_NumberOfBits implementation detail
Arcadia_ObjectReferenceValue_NumberOfBytes
#define Arcadia_ObjectReferenceValue_NumberOfBytes implementation detail
Arcadia_ObjectReferenceValue_NumberOfBits divided by 8.
Arcadia_Real*Value
typedef implementation detail Arcadia_RealSuffix Value
32 or 64.
Arcadia_Real*Value_NumberOfBits
The macros in this section all include the 32 and 64.
#define Arcadia_RealSuffix Value_NumberOfBits implementation detail
Arcadia_VoidValue occupies
where 32 or 64.
This is a positive multiple of 8.
Arcadia_Real*Value_NumberOfBytes
#define Arcadia_RealSuffix Value_NumberOfBytes implementation detail
Arcadia_RealSuffix Value occupies
where 32 or 64.
The value is always equal to Arcadia_RealSuffix Value_NumberOfBits divided by 8.
Arcadia_Real*Value_Maximum
#define Arcadia_RealSuffix Value_Maximum implementation detail
Arcadia_RealSuffix Value type.
The following table denotes the value of the constant for the respective Suffix
Constant | Value |
| 32 | +FLT_MAX |
| 64 | +DBL_MAX |
Arcadia_Real*Value_Minimum
#define Arcadia_RealSuffix Value_Minimum implementation detail
Arcadia_RealSuffix Value type
where 32 or 64.
summary>
The following table denotes the value of the constant for the respective
| Value | |
| 32 | -FLT_MAX |
| 64 | -DBL_MAX |
Size Type
typedef implementation detail Arcadia_SizeValue
An alias for the builtin size_t type.
typedef implementation detail Arcadia_SizeValue
size_t type.
Arcadia_SizeValue_NumberOfBits
#define Arcadia_SizeValue_NumberOfBits implementation detail
Arcadia_SizeValue occupies.
This is a positive multiple of 8.
This number must one of 32 or 64, otherwise the environment is not supported by Arcadia Ring 1.
This restriction may be relaxed in future versions of Arcadia Ring 1.
Arcadia_SizeValue_NumberOfBytes
#define Arcadia_SizeValue_NumberOfBytes implementation detail
Arcadia_SizeValue occupies.
The value is always equal to Arcadia_SizeValue divided by 8.
Arcadia_SizeValue_Maximum
#define Arcadia_SizeValue_Maximum implementation detail
Arcadia_SizeValue type.
Arcadia_SizeValue_Minimum
#define Arcadia_SizeValue_Minimum implementation detail
Arcadia_SizeValue type.
Arcadia_SizeValue_Literal
#define Arcadia_SizeValue_Literal(x) implementation detail
Arcadia_SizeValue in C source code.
Arcadia_VoidValue
typedef implementation detail Arcadia_VoidValue
Arcadia_VoidValue_Void.
Arcadia_VoidValue is an unsigned integral type.
Arcadia_VoidValue_Void
#define Arcadia_VoidValue_Void implementation detail
Arcadia_VoidValue.
Arcadia_VoidValue_NumberOfBits
#define Arcadia_VoidValue_NumberOfBits implementation detail
Arcadia_VoidValue occupies.
This is a positive multiple of 8.
Arcadia_VoidValue_NumberOfBytes
#define Arcadia_VoidValue_NumberOfBytes implementation detail
Arcadia_VoidValue occupies.
The value is always equal to Arcadia_VoidValue divided by 8.
Union Types
Arcadia_Value
typedef struct { implementation detail } Arcadia_Value
Arcadia_Value is a tagged union of values supported by the runtime.
It consists of a tag indicating the value stored in the union and the union of the values.
The following table lists all possible tags and their corresponding type.
| Tag | Type |
| Arcadia_ValueTag_Atom | Arcadia_AtomValue |
| Arcadia_ValueTag_Boolean | Arcadia_BooleanValue |
| Arcadia_ValueTag_Integer16 | Arcadia_Integer16Value |
| Arcadia_ValueTag_Integer32 | Arcadia_Integer32Value |
| Arcadia_ValueTag_Integer64 | Arcadia_Integer64Value |
| Arcadia_ValueTag_Integer8 | Arcadia_Integer8Value |
| Arcadia_ValueTag_Natural16 | Arcadia_Natural16Value |
| Arcadia_ValueTag_Natural32 | Arcadia_Natural32Value |
| Arcadia_ValueTag_Natural64 | Arcadia_Natural64Value |
| Arcadia_ValueTag_Natural8 | Arcadia_Natural8Value |
| Arcadia_ValueTag_ObjectReference | Arcadia_ObjectReferenceValue |
| Arcadia_ValueTag_Real32 | Arcadia_Real32Value |
| Arcadia_ValueTag_Real64 | Arcadia_Real64Value |
| Arcadia_ValueTag_Size | Arcadia_SizeValue |
| Arcadia_ValueTag_Type | Arcadia_TypeValue |
| Arcadia_ValueTag_Void | Arcadia_VoidValue |
For each type, Arcadia_Value has three functions associated:
bool Arcadia_Value_is
void Arcadia_Value_set
The following table lists the valid combinations of
| Atom | atom |
| Boolean | boolean |
| Integer16 | integer16 |
| Integer32 | integer32 |
| Integer64 | integer64 |
| Integer8 | integer8 |
| Natural16 | natural16 |
| Natural32 | natural32 |
| Natural64 | natural64 |
| Natural8 | natural8 |
| Real32 | reall32 |
| Real64 | real64 |
| ObjectReference | objectReference |
| Size | size |
| Type | type |
| Void | void |
Arcadia_Value_is returns true if
the Arcadia_Value stores a value of the type corresponding to false.
Arcadia_Value_set assigns the Arcadia_Value
a value of the type corresponding to
Arcadia_Value_get get the value stored in
the Arcadia_Value. The behavior of Arcadia_Value_set is undefined if the value does not store a value of the
type corresponding to
Arcadia_Value_hash
Arcadia_Size
Arcadia_Value_hash
(
Arcadia_Thread* thread,
Arcadia_Value* self
);
Arcadia_Value.Parameters
Arcadia_Thread object.Arcadia_Value object.Return value
The hash of the value of the value of thisArcadia_Value object.
Arcadia_Value_isEqualTo
Arcadia_BooleanValue
Arcadia_Value_isEqualTo
(
Arcadia_Thread* thread,
Arcadia_Value* self,
Arcadia_Value* other
);
Arcadia_Value object to the value of another Arcadia_Value object.
Parameters
Arcadia_Thread object.Arcadia_Value object.Arcadia_Value object.Return value
Arcadia_BooleanValue_True if the value of this Arcadia_Value object is equal to the value of the other Arcadia_Value object.
Arcadia_BooleanValue_False otherwise.
Status codes and status variables
Status Codes
R provides a status type and symbolic constants for its values. That type denotes success or failure of program (or a part of it) as well as information on the reason for the failure.
typedef
Arcadia_Status is a natural number type of a width of 32 Bit.
#definer Arcadia_Status_Success
is the symbolic constant of the type Arcadia_Status has the value ((Arcadia_Status)0).
It denotes success and is guaranteed to be defined to the value 0 of the underlaying natural number
type of Arcadia_Status as well as to be the only symbolic constant starting with Arcadia_Status_ having
defined to that value.
Symbolic constants of the form
#definer Arcadia_Status_
where Success provide information on failure of a program (or a part of it).
The following table denotes the value of the constant for the respective
Name | Value |
AccessDenied | An access was denied. |
AllocationFailed | An allocation failed. |
ArgumentTypeInvalid | The type of an argument is invalid. |
ArgumentValueInvalid | The value of an argument is invalid. |
ConversionFailed | A conversion failed. |
DivisionByZero | An divions by zero was detected. |
EncodingInvalid | An encoding is invalid. |
EnvironmentFailed | The environment failed. |
Exists | Something exists (but should not). |
Found | Something was found. |
Initialized | Something was initialized (but should not have been initialized). |
LexicalError | A lexical error. |
NotExists | Something does not exist. |
NotFound | Something was not found. |
NumberOfArgumentsInvalid | The number of arguments is invalid. |
OperationFailed | An operation failed. |
OperationInvalid | An operation is invalid. |
SemanticalError | A semantical error. |
SyntacticalError | A syntactical error. |
TestFailed | A test failed. This is used by the built-in tests that ensure correctness. |
TypeExists | A type exists (but should not). |
TypeNotExists | A type does not exist (but should). |
Uninitialized | Something was uninitialized (but should have been initialized). |
Status Variable
Arcadia.Ring1 provides by-thread status variable.
Arcadia_Status
Arcadia_Thread_getStatus
(
Arcadia_Thread* thread
);
gets the value of the status variable. The initial value of the status variable is Arcadia_Status_Success.
void
Arcadia_Thread_setStatus
(
Arcadia_Thread* thread,
Arcadia_Status status
);
sets the value of the status variable to the value status.
Jumps and jump targets
Jumps and Jump Targets
Arcadia.Ring1 provides non-local jumps by allowing to save and restore the C program state.
typedef
is a type of which its values are stack allocated.
void Arcadia_Thread_pushJumpTarget(Arcadia_Thread* thread, Arcadia_JumpTarget* jumpTarget);
Push a jump target on top of the jump target stack. Initially, the jump target stack is empty.
void Arcadia_Thread_popJumpTarget(Arcadia_Thread* thread);
Pop the jump target on top of the jump target stack. The jump target stack must not be empty.
void Arcadia_jump(Arcadia_Thread* thread);
Jump to the jump target on top of the jump target stack. The jump target stack must not be empty.
#define Arcadia_JumpTarget_save(jumpTarget)
Macro to save the current C program state into a jump target.
The canonical way of using Arcadia_Thread_pushJumpTarget, Arcadia_Thread_popJumpTarget, and
Arcadia_Thread_jump is the following.
Arcadia_Thread_pushJumpTarget(thread, &jumpTarget);
if (Arcadia_JumpTarget_save(thread, &jumpTarget)) {
Arcadia_Thread_popJumpTarget(thread);
} else {
Arcadia_Thread_popJumpTarget(thread);
}
The if-branch is always entered at first as the Arcadia_JumpTarget_save() at
its first invocation returns logically true. If the program at Arcadia_Thread_jump()), then Arcadia_Thread_popJumpTarget(); and Arcadia_Thread_JumpTarget_save() is re-evaluated and returns
logically false and Arcadia_Thread_popJumpTarget(); and
One usage example is the implementation of the Arcadia_safeExecute function.
void Arcadia_safeExecute(Arcadia_Thread* thread, void (*f)(Arcadia_Thread*)) {
Arcadia_JumpTarget jumpTarget;
Arcadia_Thread_pushJumpTarget(thread, &jumpTarget);
if (Arcadia_Thread_JumpTarget_save(thread, &jumpTarget)) {
f();
Arcadia_Thread_popJumpTarget(thread);
}
}
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.
Object Lifetime and Method Invocation
An ordinary method may be invoked on an Arcadia_Object or derived object only if the object
is fully constructed and has not entered finalization.
At the point of invocation, the receiver must be a GC root or transitively reachable from a GC root.
It must remain reachable throughout the invocation, including during garbage collections triggered
by nested calls. A C pointer, including self, does not by itself constitute a GC root.
The caller is responsible for satisfying these preconditions. An ordinary method is not required to
root its receiver automatically. Temporary roots can be established through the Arcadia value stack
or Arcadia_Object_lock; an owning object can retain references through its visit callback.
Constructors and finalizers are lifecycle operations rather than ordinary method invocations. A finalizer must not assume that another unreachable managed object remains valid: the garbage collector does not guarantee finalization order.
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_ByteArray
Arcadia_ByteArray extends Arcadia_Object.
Arcadia_ByteArray represents a mutable sequence of Bytes.
Arcadia_ByteArray_getAt
Arcadia_Natural8Value
Arcadia_ByteArray_getAt
(
Arcadia_Thread* thread,
Arcadia_ByteArray const* self,
Arcadia_SizeValue index
)
Parameters
Arcadia_Thread object.[0,n) where n is the size of this Byte array.Return value
The Byte value.
Arcadia_ByteArray_getBytes
void const*
Arcadia_ByteArray_getBytes
(
Arcadia_Thread* thread,
Arcadia_ByteArray const* self
)
Parameters
Arcadia_Thread object.Return value
A pointer to the Bytes in this Byte array.
Arcadia_ByteArray_getNumberOfBytes
Arcadia_SizeValue
Arcadia_ByteArray_getNumberOfBytes
(
Arcadia_Thread* thread,
Arcadia_ByteArray const* self
)
Parameters
Arcadia_Thread object.Return value
The size of this Byte array.
Arcadia_ByteArray_getSize
Arcadia_SizeValue
Arcadia_ByteArray_getSize
(
Arcadia_Thread* thread,
Arcadia_ByteArray const* self
)
Parameters
Arcadia_Thread object.Return value
The size of this Byte array.
Arcadia_ByteArray_isEmpty
Arcadia_BooleanValue
Arcadia_ByteArray_isEmpty
(
Arcadia_Thread* thread,
Arcadia_ByteArray* self
)
Parameters
Arcadia_Thread object.Return value
Arcadia_BooleanValue_True if this Byte array is empty. Arcadia_BooleanValue_False otherwise.
Errors
self is a null pointer.Arcadia_ByteArrayBuilder
Arcadia_ByteArrayBuilder extends Arcadia_Object.
Arcadia_ByteArrayBuilder represents a mutable sequence of Bytes.
Arcadia_ByteArrayBuilder_clear
void
Arcadia_ByteArrayBuilder_clear
(
Arcadia_Thread* thread,
Arcadia_ByteArrayBuilder* self
)
Parameters
Arcadia_Thread object.Arcadia_ByteArrayBuilder_create
Arcadia_ByteArrayBuilder*
Arcadia_ByteArrayBuilder_create
(
Arcadia_Thread* thread
)
Parameters
Arcadia_Thread object.Errors
Return value
A pointer to the Arcadia_ByteArrayBuilder object.
Arcadia_ByteArrayBuilder_getBytes
void const*
Arcadia_ByteArrayBuilder_getBytes
(
Arcadia_Thread* thread,
Arcadia_ByteArrayBuilder const* self
)
Parameters
Arcadia_Thread object.Return value
A pointer to the Bytes in this Byte buffer.
Arcadia_ByteArrayBuilder_getNumberOfBytes
Arcadia_SizeValue
Arcadia_ByteArrayBuilder_getNumberOfBytes
(
Arcadia_Thread* thread,
Arcadia_ByteArrayBuilder const* self
)
Parameters
Arcadia_Thread object.Return value
The size of this Byte buffer.
Arcadia_ByteArrayBuilder_getSize
Arcadia_SizeValue
Arcadia_ByteArrayBuilder_getSize
(
Arcadia_Thread* thread,
Arcadia_ByteArrayBuilder const* self
)
Parameters
Arcadia_Thread object.Return value
The size of this Byte buffer.
Arcadia_ByteArrayBuilder_insertBackBytes
void
Arcadia_ByteArrayBuilder_insertBackBytes
(
Arcadia_Thread* thread,
Arcadia_ByteArrayBuilder* 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_ByteArrayBuilder_insertBytes
void
Arcadia_ByteArrayBuilder_insertBytes
(
Arcadia_Thread* thread,
Arcadia_ByteArrayBuilder* 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_ByteArrayBuilder_insertFrontBytes
void
Arcadia_ByteArrayBuilder_insertFrontBytes
(
Arcadia_Thread* thread,
Arcadia_ByteArrayBuilder* 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_ByteArrayBuilder_endsWith_pn
Arcadia_BooleanValue
Arcadia_ByteArrayBuilder_endsWith_pn
(
Arcadia_Thread* thread,
Arcadia_ByteArrayBuilder 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_ByteArrayBuilder_startsWith_pn
Arcadia_BooleanValue
Arcadia_ByteArrayBuilder_startsWith_pn
(
Arcadia_Thread* thread,
Arcadia_ByteArrayBuilder* 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_ByteArrayBuilder_isEqualTo_pn
(
Arcadia_Thread* thread,
Arcadia_ByteArrayBuilder* 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_ByteArrayBuilder_isEqualTo
Arcadia_BooleanValue
Arcadia_ByteArrayBuilder_isEqualTo
(
Arcadia_Thread* thread,
Arcadia_ByteArrayBuilder const* self,
Arcadia_ByteArrayBuilder 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_ByteArrayBuilder_getAt
Arcadia_Natural8Value
Arcadia_ByteArrayBuilder_getAt
(
Arcadia_Thread* thread,
Arcadia_ByteArrayBuilder 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_ByteArrayBuilder_isEmpty
Arcadia_BooleanValue
Arcadia_ByteArrayBuilder_isEmpty
(
Arcadia_Thread* thread,
Arcadia_ByteArrayBuilder* 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_ByteArrayBuilder_swap
void
Arcadia_ByteArrayBuilder_swap
(
Arcadia_Thread* thread,
Arcadia_ByteArrayBuilder* self,
Arcadia_ByteArrayBuilder* other
)
Parameters
Arcadia_Thread object.Errors
self is a null pointer.other is a null pointer.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_createFromBoolean
Arcadia_String*
Arcadia_String_createFromBoolean
(
Arcadia_Thread* thread,
Arcadia_BooleanValue booleanValue
)
Arcadia_BooleanValue value.
The Arcadia_BooleanValue value is converted to the strings true, if its value is Arcadia_BooleanValue_True, and false, if its value is Arcadia_BooleanValue_False, respectively.
Parameters
Arcadia_Thread object.Arcadia_BooleanValue to be converted into the string value.Return value
A pointer to the Arcadia_String object.
Errors
Arcadia_String_createFromInteger16
Arcadia_String*
Arcadia_String_createFromInteger16
(
Arcadia_Thread* thread,
Arcadia_Integer16Value integer16Value
)
Arcadia_Integer16Value value.
The Arcadia_Integer16Value value is converted to the decimal integer number literal string.
Parameters
Arcadia_Thread object.Arcadia_Integer16Value to be converted into the string value.Return value
A pointer to the Arcadia_String object.
Errors
Arcadia_String_createFromInteger32
Arcadia_String*
Arcadia_String_createFromInteger32
(
Arcadia_Thread* thread,
Arcadia_Integer32Value integer32Value
)
Arcadia_Integer32Value value.
The Arcadia_Integer32Value value is converted to the decimal integer number literal string.
Parameters
Arcadia_Thread object.Arcadia_Integer32Value to be converted into the string value.Return value
A pointer to the Arcadia_String object.
Errors
Arcadia_String_createFromInteger64
Arcadia_String*
Arcadia_String_createFromInteger64
(
Arcadia_Thread* thread,
Arcadia_Integer64Value integer64Value
)
Arcadia_Integer64Value value.
The Arcadia_Integer64Value value is converted to the decimal integer number literal string.
Parameters
Arcadia_Thread object.Arcadia_Integer64Value to be converted into the string value.Return value
A pointer to the Arcadia_String object.
Errors
Arcadia_String_createFromInteger8
Arcadia_String*
Arcadia_String_createFromInteger8
(
Arcadia_Thread* thread,
Arcadia_Integer8Value integer8Value
)
Arcadia_Integer8Value value.
The Arcadia_Integer8Value value is converted to the decimal integer number literal string.
Parameters
Arcadia_Thread object.Arcadia_Integer8Value to be converted into the string value.Return value
A pointer to the Arcadia_String object.
Errors
Arcadia_String_createFromNatural16
Arcadia_String*
Arcadia_String_createFromNatural16
(
Arcadia_Thread* thread,
Arcadia_Natural16Value natural64Value
)
Arcadia_Natural16Value value.
The Arcadia_Natural16Value value is converted to the decimal natural number literal string.
Parameters
Arcadia_Thread object.Arcadia_Natural16Value to be converted into the string value.Return value
A pointer to the Arcadia_String object.
Errors
Arcadia_String_createFromNatural32
Arcadia_String*
Arcadia_String_createFromNatural32
(
Arcadia_Thread* thread,
Arcadia_Natural32Value natural64Value
)
Arcadia_Natural32Value value.
The Arcadia_Natural32Value value is converted to the decimal natural number literal string.
Parameters
Arcadia_Thread object.Arcadia_Natural32Value to be converted into the string value.Return value
A pointer to the Arcadia_String object.
Errors
Arcadia_String_createFromNatural64
Arcadia_String*
Arcadia_String_createFromNatural64
(
Arcadia_Thread* thread,
Arcadia_Natural64Value natural64Value
)
Arcadia_Natural64Value value.
The Arcadia_Natural64Value value is converted to the decimal natural number literal string.
Parameters
Arcadia_Thread object.Arcadia_Natural64Value to be converted into the string value.Return value
A pointer to the Arcadia_String object.
Errors
Arcadia_String_createFromNatural8
Arcadia_String*
Arcadia_String_createFromNatural8
(
Arcadia_Thread* thread,
Arcadia_Natural8Value natural64Value
)
Arcadia_Natural8Value value.
The Arcadia_Natural8Value value is converted to the decimal natural number literal string.
Parameters
Arcadia_Thread object.Arcadia_Natural8Value to be converted into the string value.Return value
A pointer to the Arcadia_String object.
Errors
Arcadia_String_createFromReal32
Arcadia_String*
Arcadia_String_createFromReal32
(
Arcadia_Thread* thread,
Arcadia_Real32Value real32Value
)
Arcadia_Real3lValue value.
The Arcadia_Real32Value value is converted to the decimal real number literal string.
Parameters
Arcadia_Thread object.Arcadia_Real32Value to be converted into the string value.Return value
A pointer to the Arcadia_String object.
Errors
Arcadia_String_createFromReal64
Arcadia_String*
Arcadia_String_createFromReal64
(
Arcadia_Thread* thread,
Arcadia_Real64Value real64Value
)
Arcadia_Real64Value value.
The Arcadia_Real64Value value is converted to the decimal real number literal string.
Parameters
Arcadia_Thread object.Arcadia_Real64Value to be converted into the string value.Return value
A pointer to the Arcadia_String object.
Errors
Arcadia_String_createFromVoid
Arcadia_String*
Arcadia_String_createFromBoolean
(
Arcadia_Thread* thread,
Arcadia_VoidValue voidValue
)
Arcadia_VoidValue value.
The Arcadia_VoidValue value is converted to the string void.
Parameters
Arcadia_Thread object.Arcadia_VoidValue to be converted into the string value.Return value
A pointer to the Arcadia_String object.
Errors
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_getBytes
Arcadia_Natural8Value const*
Arcadia_String_getBytes
(
Arcadia_Thread* thread,
Arcadia_String const* self
)
Parameters
Arcadia_Thread object.Return value
A pointer to the 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_StringBuilder
Arcadia_StringBuilder extends Arcadia_Object.
Arcadia_StringBuilder represents a mutable sequence of code points in UTF8 encoding.
Arcadia_StringBuilder_clear
void
Arcadia_StringBuilder_clear
(
Arcadia_Thread* thread,
Arcadia_StringBuilder* self
)
Parameters
Arcadia_Thread object.Arcadia_StringBuilder_create
Arcadia_StringBuilder*
Arcadia_StringBuilder_create
(
Arcadia_Thread* thread
)
Parameters
Arcadia_Thread object.Errors
Return value
A pointer to the Arcadia_StringBuilder value.
Arcadia_StringBuilder_compareTo
Arcadia_Integer32Value*
Arcadia_StringBuilder_compareTo
(
Arcadia_Thread* thread,
Arcadia_StringBuilder* self,
Arcadia_Value other
)
Parameters
Arcadia_Thread object.Arcadia.ImmutableUtf8String, Arcadia.StringBuilder, 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
ais lexicographically less thanbifn < mais lexicographically greater thanbifn > maandbare 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:
ais lexicographically less thanbifa[i] < b[i]ais lexicographically greater thanbifa[i] > b[i]
Arcadia_StringBuilder_getNumberOfBytes
Arcadia_SizeValue
Arcadia_StringBuilder_getNumberOfBytes
(
Arcadia_Thread* thread,
Arcadia_StringBuilder self
)
Parameters
Arcadia_Thread object.Return value
The number of Bytes in this string buffer.
Arcadia_StringBuilder_insertAt
void
Arcadia_StringBuilder_insertAt
(
Arcadia_Thread* thread,
Arcadia_StringBuilder* self,
Arcadia_SizeValue index,
Arcadia_Value value
)
Parameters
Arcadia_Thread object.Arcadia.ImmutableByteArray, Arcadia.ImmutableUtf8String,
Arcadia.ByteBuffer, Arcadia.StringBuilder, 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_StringBuilder_insertBack
void
Arcadia_StringBuilder_insertFront
(
Arcadia_Thread* thread,
Arcadia_StringBuilder* self,
Arcadia_Value value
)
Parameters
Arcadia_Thread object.Arcadia.ImmutableByteArray, Arcadia.ImmutableUtf8String,
Arcadia.ByteBuffer, Arcadia.StringBuilder, 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_StringBuilder_insertFront
void
Arcadia_StringBuilder_insertFront
(
Arcadia_Thread* thread,
Arcadia_StringBuilder* self,
Arcadia_Value value
)
Parameters
Arcadia_Thread object.Arcadia.ImmutableByteArray, Arcadia.ImmutableUtf8String,
Arcadia.ByteBuffer, Arcadia.StringBuilder, 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_StringBuilder_isEmpty
Arcadia_BooleanValue
Arcadia_StringBuilder_isEmpty
(
Arcadia_Thread* thread,
Arcadia_StringBuilder* 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.Numeric functions
Arcadia_ceil*
Type
Arcadia_ceilSuffix
(
Arcadia_Thread* thread,
Type x
)
x.The following table lists the combinations of
Real32Value | Arcadia_Real32Value |
Real64Value | Arcadia_Real64Value |
Parameters
Arcadia_Thread object.
If x is ±0, ±∞, or not a number, then x is returned.
Return value
The ceil of x.
Arcadia_clamp*
Type
Arcadia_clampSuffix
(
Arcadia_Thread* thread,
Type value,
Type lower,
Type upper
)
The following table lists the combinations of
Integer8Value | Arcadia_Integer8Value |
Integer16Value | Arcadia_Integer16Value |
Integer32Value | Arcadia_Integer32Value |
Integer64Value | Arcadia_Integer64Value |
Natural8Value | Arcadia_Natural8Value |
Natural16Value | Arcadia_Natural16Value |
Natural32Value | Arcadia_Natural32Value |
Natural64Value | Arcadia_Natural64Value |
Real32Value | Arcadia_Real32Value |
Real64Value | Arcadia_Real64Value |
SizeValue | Arcadia_SizeValue |
Parameters
Arcadia_Thread object.This function returns the value value clamped to the range [lower, upper].
Errors
lower > upperReturn value
The value value clamped to the range [lower, upper].
Arcadia_cos*
Type
Arcadia_cosSuffix
(
Arcadia_Thread* thread,
Type x
)
x.The following table lists the combinations of
Real32Value | Arcadia_Real32Value |
Real64Value | Arcadia_Real64Value |
Parameters
Arcadia_Thread object.
This function returns the cosine of x.
If x is ±0 then the result is 1.
If x is ±∞ or not a number then the result is not a number.
Return value
The cosine of x.
Arcadia_countLeadingZeroes*
Arcadia_SizeValue
Arcadia_countLeadingZeroesSuffix
(
Arcadia_Thread* thread,
Type value
)
The following table lists the combinations of
Integer8Value | Arcadia_Integer8Value |
Integer16Value | Arcadia_Integer16Value |
Integer32Value | Arcadia_Integer32Value |
Integer64Value | Arcadia_Integer64Value |
Natural8Value | Arcadia_Natural8Value |
Natural16Value | Arcadia_Natural16Value |
Natural32Value | Arcadia_Natural32Value |
Natural64Value | Arcadia_Natural64Value |
SizeValue | Arcadia_SizeValue |
This function returns the number of leading zeroes of the binary representation of value.
| Arcadia_Thread* thread | A pointer to the Arcadia_Thread object. |
| The value. |
The number of leading zeroes.
Arcadia_countSignificandBits*
Arcadia_SizeValue
Arcadia_countSignificandBitsSuffix
(
Arcadia_Thread* thread,
Type value
)
The following table lists the combinations of
Integer8Value | Arcadia_Integer8Value |
Integer16Value | Arcadia_Integer16Value |
Integer32Value | Arcadia_Integer32Value |
Integer64Value | Arcadia_Integer64Value |
Natural8Value | Arcadia_Natural8Value |
Natural16Value | Arcadia_Natural16Value |
Natural32Value | Arcadia_Natural32Value |
Natural64Value | Arcadia_Natural64Value |
SizeValue | Arcadia_SizeValue |
This function returns the number of significand Bits of the binary representation of value.
| Arcadia_Thread* thread | A pointer to the Arcadia_Thread object. |
| The value. |
The number of significand Bits.
Arcadia_countTrailingZeroes*
Arcadia_SizeValue
Arcadia_countTrailingZeroesSuffix
(
Arcadia_Thread* thread,
Type value
)
The following table lists the combinations of
Integer8Value | Arcadia_Integer8Value |
Integer16Value | Arcadia_Integer16Value |
Integer32Value | Arcadia_Integer32Value |
Integer64Value | Arcadia_Integer64Value |
Natural8Value | Arcadia_Natural8Value |
Natural16Value | Arcadia_Natural16Value |
Natural32Value | Arcadia_Natural32Value |
Natural64Value | Arcadia_Natural64Value |
SizeValue | Arcadia_SizeValue |
This function returns the number of trailing zeroes of the binary representation of value.
| Arcadia_Thread* thread | A pointer to the Arcadia_Thread object. |
| The value. |
The number of leading zeroes.
Arcadia_floor*
Type
Arcadia_floorSuffix
(
Arcadia_Thread* thread,
Type x
)
x.The following table lists the combinations of
Real32Value | Arcadia_Real32Value |
Real64Value | Arcadia_Real64Value |
Parameters
Arcadia_Thread object.
If x is ±0, ±∞, or not a number, then x is returned.
Return value
The floor of x.
Arcadia_hash*
Arcadia_SizeValue
Arcadia_hashSuffix
(
Arcadia_Thread* thread,
Type x
)
The following table lists the combinations of
BooleanValue | Arcadia_BooleanValue |
ForeignProcedureValue | Arcadia_ForeignProcedureValue |
Integer8Value | Arcadia_Integer8Value |
Integer16Value | Arcadia_Integer16Value |
Integer32Value | Arcadia_Integer32Value |
Integer64Value | Arcadia_Integer64Value |
Natural8Value | Arcadia_Natural8Value |
Natural16Value | Arcadia_Natural16Value |
Natural32Value | Arcadia_Natural32Value |
Natural64Value | Arcadia_Natural64Value |
Real32Value | Arcadia_Real32Value |
Real64Value | Arcadia_Real64Value |
SizeValue | Arcadia_SizeValue |
VoidValue | Arcadia_VoidValue |
Parameters
Arcadia_Thread object.Return value
Return hash of x.
Arcadia_isPowerOfTwo*
Arcadia_BooleanValue
Arcadia_isPowerOfTwoSuffix
(
Arcadia_Thread* thread,
Type x
)
The following table lists the combinations of
Integer8Value | Arcadia_Integer8Value |
Integer16Value | Arcadia_Integer16Value |
Integer32Value | Arcadia_Integer32Value |
Integer64Value | Arcadia_Integer64Value |
Natural8Value | Arcadia_Natural8Value |
Natural16Value | Arcadia_Natural16Value |
Natural32Value | Arcadia_Natural32Value |
Natural64Value | Arcadia_Natural64Value |
SizeValue | Arcadia_SizeValue |
Parameters
Arcadia_Thread object.Return value
Arcadia_BooleanValue_True if the value x/ is a power of two.
Arcadia_BooleanValue_False otherwise.
Arcadia_maximum*
Type
Arcadia_maximumSuffix
(
Arcadia_Thread* thread,
Type x,
Type y
)
The following table lists the combinations of
Integer8Value | Arcadia_Integer8Value |
Integer16Value | Arcadia_Integer16Value |
Integer32Value | Arcadia_Integer32Value |
Integer64Value | Arcadia_Integer64Value |
Natural8Value | Arcadia_Natural8Value |
Natural16Value | Arcadia_Natural16Value |
Natural32Value | Arcadia_Natural32Value |
Natural64Value | Arcadia_Natural64Value |
SizeValue | Arcadia_SizeValue |
Parameters
Arcadia_Thread object.Return value
Return the maximum of x and y.
Arcadia_minimum*
Type
Arcadia_minimumSuffix
(
Arcadia_Thread* thread,
Type x,
Type y
)
The following table lists the combinations of
Integer8Value | Arcadia_Integer8Value |
Integer16Value | Arcadia_Integer16Value |
Integer32Value | Arcadia_Integer32Value |
Integer64Value | Arcadia_Integer64Value |
Natural8Value | Arcadia_Natural8Value |
Natural16Value | Arcadia_Natural16Value |
Natural32Value | Arcadia_Natural32Value |
Natural64Value | Arcadia_Natural64Value |
SizeValue | Arcadia_SizeValue |
Parameters
Arcadia_Thread object.Return value
Return the minimum of x and y.
Arcadia_nextPowerOfTwoGreaterThan*
Type
Arcadia_nextPowerOfTwoGreaterThanSuffix
(
Arcadia_Thread* thread,
Type x
)
The following table lists the combinations of
Integer8Value | Arcadia_Integer8Value |
Integer16Value | Arcadia_Integer16Value |
Integer32Value | Arcadia_Integer32Value |
Integer64Value | Arcadia_Integer64Value |
Natural8Value | Arcadia_Natural8Value |
Natural16Value | Arcadia_Natural16Value |
Natural32Value | Arcadia_Natural32Value |
Natural64Value | Arcadia_Natural64Value |
SizeValue | Arcadia_SizeValue |
Parameters
Arcadia_Thread object.Errors
x is not representable by the type Return value
Return the next power of two greater than x.
Arcadia_nextPowerOfTwoGreaterThanOrEqualTo*
Type
Arcadia_nextPowerOfTwoGreaterThanOrEqualToSuffix
(
Arcadia_Thread* thread,
Type x
)
The following table lists the combinations of
Integer8Value | Arcadia_Integer8Value |
Integer16Value | Arcadia_Integer16Value |
Integer32Value | Arcadia_Integer32Value |
Integer64Value | Arcadia_Integer64Value |
Natural8Value | Arcadia_Natural8Value |
Natural16Value | Arcadia_Natural16Value |
Natural32Value | Arcadia_Natural32Value |
Natural64Value | Arcadia_Natural64Value |
SizeValue | Arcadia_SizeValue |
Parameters
Arcadia_Thread object.Errors
x is not representable by the type Return value
Return the next power of two greater than or equal to x.
Arcadia_quotientRemainder*
void
Arcadia_quotientRemainderSuffix
(
Arcadia_Thread* thread,
Type dividend,
Type divisor,
Type * quotient,
Type * remainder
)
The following table lists the combinations of
Integer8Value | Arcadia_Integer8Value |
Integer16Value | Arcadia_Integer16Value |
Integer32Value | Arcadia_Integer32Value |
Integer64Value | Arcadia_Integer64Value |
Natural8Value | Arcadia_Natural8Value |
Natural16Value | Arcadia_Natural16Value |
Natural32Value | Arcadia_Natural32Value |
Natural64Value | Arcadia_Natural64Value |
SizeValue | Arcadia_SizeValue |
This function computes the quotient and the remainder .
The quotient is stored in *quotient and the divisor is stored in *remainder.
Parameters
Arcadia_Thread object.Errors
quotient or remainder is zero.Arcadia_safeAddFull*
void
Arcadia_safeAddFullSuffix
(
Arcadia_Thread* thread,
Type augend,
Type addend,
Type * sumHigh,
Type * sumLow
)
The following table lists the combinations of
Natural16Value | Arcadia_Natural16Value |
Natural32Value | Arcadia_Natural32Value |
Natural64Value | Arcadia_Natural64Value |
Natural8Value | Arcadia_Natural8Value |
SizeValue | Arcadia_SizeValue |
Arcadia_Thread object.Arcadia_safeMultiply*
void
Arcadia_safeMultiplySuffix
(
Arcadia_Thread* thread,
Type x,
Type y
)
The following table lists the combinations of
Natural8Value | Arcadia_Natural8Value |
Natural16Value | Arcadia_Natural16Value |
Natural32Value | Arcadia_Natural32Value |
Natural64Value | Arcadia_Natural64Value |
SizeValue | Arcadia_SizeValue |
Parameters
Arcadia_Thread object.Return value
Return the maximum of x and y.
Arcadia_sin*
Type
Arcadia_sinSuffix
(
Arcadia_Thread* thread,
Type x
)
x.The following table lists the combinations of
Real32Value | Arcadia_Real32Value |
Real64Value | Arcadia_Real64Value |
Parameters
Arcadia_Thread object.
This function returns the sine of x.
If x is ±0 then the result is 0.
If x is ±∞ or not a number then the result is not a number.
Return value
The sine of x.
Arcadia_sqrt*
Type
Arcadia_sqrtSuffix
(
Arcadia_Thread* thread,
Type x
)
x.The following table lists the combinations of
Real32Value | Arcadia_Real32Value |
Real64Value | Arcadia_Real64Value |
Parameters
Arcadia_Thread object.
This function returns the square root of x.
If x is less than -0 or not a number, then not a number os returned.
If x is +∞ or ±∞0, then x is returned unmodified.
Return value
The square root of x.
Arcadia_Real*Value_getBits
Arcadia_NaturalBits
Arcadia_RealBits Value_getBits
(
Arcadia_Thread* thread,
Arcadia_RealBits Value self
)
Arcadia_RealSuffix Value
where 32 or 64.
Parameters
Arcadia_Thread object.Return value
Return the bits of the Real value as a Natural value.
Time and date functions
Arcadia_getTickCount
Arcadia_Natural64Value
Arcadia_getTickCount
(
Arcadia_Thread* thread
)
Parameters
Arcadia_Thread object.Return value
The time, in milliseconds, since an unspecified momentn in the past.
Unicode functions
Arcadia_Unicode_EncodeCodePointCallbackContext
typedef void Arcadia_Unicode_EncodeCodePointCallbackContext;
Arcadia_Unicode_EncodeCodePointCallbackContext* to denote an opaque pointer passed as a callback.Arcadia_EncodeCodePointCallbackFunction
typedef void
(Arcadia_EncodeCodePointCallbackFunction)
(
Arcadia_Thread* thread,
Arcadia_EncodeCodePointCallbackContext* context,
const Arcadia_Natural8Value* bytes,
Arcadia_SizeValue numberOfBytes
)
Parameters
Arcadia_Thread object.numberOfBytes Bytes.bytes.Arcadia_encodeCodePointsUtf8
void
Arcadia_encodeCodePointUtf8
(
Arcadia_Thread* thread,
const Arcadia_Natural32Value* codePoints,
Arcadia_SizeValue numberOfCodePoints,
Arcadia_EncodeCodePointCallbackContext* context,
Arcadia_EncodeCodePointCallbackFunction* function
)
Parameters
Arcadia_Thread object.numberOfCodePoints Arcadia_Natural32Value values.
Each Arcadia_Natural32Value in the range of a Unicode code point.Arcadia_Natural32Value in the array pointed to by codePoints.
Errors
codePoint does not represent an Unicode code pointcodePoints is a null pointercodePoints is a null pointerArcadia_Unicode_isUTF8
Arcadia_BooleanValue
Arcadia_Unicode_isUTF8
(
Arcadia_Thread* thread,
const void* bytes,
Arcadia_SizeValue numberOfBytes,
Arcadia_SizeValue* numberOfSymbols
)
Parameters
Arcadia_Thread object.numberOfBytes Bytes.bytes.bytes.
If this function terminates and this pointer is not null, the variable is assigned the number of symbols decoded successfully so far.
Return value
Arcadia_BooleanValue_True if the sequence of numberOfBytes Bytes pointed to by bytes is an UTF-8 sequence of Bytes.
Arcadia_BooleanValue_False otherwise.
Memory functions
Arcadia_Memory_allocateUnmanaged
void*
Arcadia_Memory_allocateUnmanaged
(
Arcadia_Thread* thread
)
Parameters
Arcadia_Thread object.Return value
A pointer to the first Byte of the memory region.
Errors
Arcadia_Memory_compare
Arcadia_Integer8Value
Arcadia_Memory_compare
(
Arcadia_Thread* thread,
const void* p,
const void* q,
Arcadia_SizeValue n
)
Parameters
Arcadia_Thread object.Return value
A positive value if the first memory region is greater than the first memory region. A negative value if the first memory region is less than the second memory region. Zero if both memory regions are equal.
Remarks
A memory region (p,n) is equal to a memory region (q,n) if for all 0<e; i < p[i] = q[i] holds.
Otherwise there exists a least 0<e; i < n such that p[i] &neq; q[i] holds and consequently either p[i] < q[i] or p[i] > q[i] holds:
if p[i] &neq; q[i] holds then p is less than q and if p[i] > q[i] holds then p is greater than q.
Arcadia_Memory_copy
void
Arcadia_Memory_copy
(
Arcadia_Thread* thread,
void* target,
const void* source,
Arcadia_SizeValue numberOfBytes
)
Parameters
Arcadia_Thread object.Arcadia_Memory_deallocateUnmanaged
void
Arcadia_Memory_deallocateUnmanaged
(
Arcadia_Thread* thread,
void* p
)
Parameters
Arcadia_Thread object.Arcadia_Memory_fill
void
Arcadia_Memory_fill
(
Arcadia_Thread* thread,
void* bytes,
Arcadia_SizeValue numberOfBytes
Arcadia_Natural8Value value
)
Parameters
Arcadia_Thread object.Arcadia_Memory_reallocateUnmanaged
void*
Arcadia_Memory_reallocateUnmanaged
(
Arcadia_Thread* thread
)
Parameters
Arcadia_Thread object.Return value
A pointer to the first Byte of the new memory region.
Errors
Remarks
The succesful reallocation of a memory region (p,n) to a memory region (q,m) effectively means:
The old memory region p of size n was deallocated, the new memory region q of size m was allocated.
Furthermore, the first bytes k = min(n,m) Bytes of the old memory region and the new memory region have the same values.
If the reallocation fails, then the memory region (p,n) is not modified.
Miscellaneous functions
Arcadia_getNumberOfCores
Arcadia_Natural64Value
Arcadia_getNumberOfCores
(
Arcadia_Thread* thread
)
Parameters
Arcadia_Thread object.Return value
The number of CPU cores.
Arcadia_getPageSize
Arcadia_Natural64Value
Arcadia_getPageSize
(
Arcadia_Thread* thread
)
Parameters
Arcadia_Thread object.Return value
The memory page size.
Arcadia_Configuration_CompilerC
#define Arcadia_Configuration_CompilerC /* implementation */
Arcadia_Configuration_CompilerC_* constants.
Arcadia_Configuration_CompilerC_Gcc
#define Arcadia_Configuration_CompilerC_Gcc /* implementation */
Arcadia_Configuration_CompilerC_* symbol constants.
This symbolic constant denotes the GCC C compiler.
Arcadia_Configuration_CompilerC_Clang
#define Arcadia_Configuration_CompilerC_Clang /* implementation */
Arcadia_Configuration_CompilerC_* symbol constants.
This symbolic constant denotes the CLANG C compiler.
Arcadia_Configuration_CompilerC_Msvc
#define Arcadia_Configuration_CompilerC_Gcc /* implementation */
Arcadia_Configuration_CompilerC_* symbol constants.
This symbolic constant denotes the MSVC C compiler.
Arcadia_Configuration_Version_Major
#define Arcadia_Configuration_Version_Major /* implementation */
Arcadia_Configuration_Version_Major
#define Arcadia_Configuration_Version_Major /* implementation */
Arcadia_Configuration_OperatingSystem_Cygwin
#define Arcadia_Configuration_OperatingSystem_Cygwin /* implementation */
Arcadia_Configuration_OperatingSystem_* symbol constants.
This symbolic constant denotes the CYGWIN operating system.
Arcadia_Configuration_OperatingSystem_Ios
#define Arcadia_Configuration_OperatingSystem_Ios /* implementation */
Arcadia_Configuration_OperatingSystem_* symbol constants.
This symbolic constant denotes the IOS operating system.
Arcadia_Configuration_OperatingSystem_IosEmulator
#define Arcadia_Configuration_OperatingSystem_IosEmulator /* implementation */
Arcadia_Configuration_OperatingSystem_* symbol constants.
This symbolic constant denotes the IOS EMULATOR operating system.
Arcadia_Configuration_OperatingSystem_Linux
#define Arcadia_Configuration_OperatingSystem_Linux /* implementation */
Arcadia_Configuration_OperatingSystem_* symbol constants.
This symbolic constant denotes the LINUX operating system.
Arcadia_Configuration_OperatingSystem_Macos
#define Arcadia_Configuration_OperatingSystem_Macos /* implementation */
Arcadia_Configuration_OperatingSystem_* symbol constants.
This symbolic constant denotes the MACOS operating system.
Arcadia_Configuration_OperatingSystem_Mingw
#define Arcadia_Configuration_OperatingSystem_Mingw /* implementation */
Arcadia_Configuration_OperatingSystem_* symbol constants.
This symbolic constant denotes a MINGW operating system.
Arcadia_Configuration_OperatingSystem_Msys
#define Arcadia_Configuration_OperatingSystem_Msys /* implementation */
Arcadia_Configuration_OperatingSystem_* symbol constants.
This symbolic constant denotes an MSYS operating system.
Arcadia_Configuration_OperatingSystem_Unix
#define Arcadia_Configuration_OperatingSystem_Unix /* implementation */
Arcadia_Configuration_OperatingSystem_* symbol constants.
This symbolic constant denotes a UNIX operating system.
Arcadia_Configuration_OperatingSystem_Windows
#define Arcadia_Configuration_OperatingSystem_Windows /* implementation */
Arcadia_Configuration_OperatingSystem_* symbol constants.
This symbolic constant denotes the WINDOWS operating system.
Annotations
Arcadia_Likely
#define Arcadia_Likely(expression) implementation detail
Parameters
For example, given typical programs, it is likely that malloc for a small size of memory is very likely to succeed.
Hence, in the following code snipped, we tell tell the compiler that the test for success of a call to malloc is likely to to evaluate to logically true and
the code in branch (A) is likely to be executed whilst consequently the code in branch (X) is not likely to be execute.
void* p = malloc(sizeof(char));
if (Arcadia_Likely(p)) {
/* (A) Foaming with joy, continue execution. */
} else {
/* (X) In the heart with pain, abort execution. */
}
Arcadia_NoReturn
#define Arcadia_NoReturn() implementation detail
Arcadia_ThreadLocal
#define Arcadia_ThreadLocal() implementation detail
Arcadia_Unlikely
#define Arcadia_Unlikely(expression) implementation detail
Parameters
For example, given typical programs, it is likely that malloc for a small size of memory is very likely to succeed.
Hence, in the following code snipped, we tell tell the compiler that the test for failure of a call to malloc is likely to to evaluate to logically false and
the code in branch (A) is likely to be executed whilst consequently the code in branch (X) is not likely to be execute.
char *p = malloc(sizeof(char));
if (Arcadia_Unlikely(!p)) {
/* (X) In the heart with pain, abort execution. */
} else {
/* (A) Foaming with joy, continue execution. */
}