#define BYTEVECTOR_REF(s, i) (* (BYTEVECTOR_LOC ((s), (i))))
#define BYTEVECTOR_SET(s, i, c) ((* (BYTEVECTOR_LOC ((s), (i)))) = (c))
+/* Unicode string operations */
+
+#define UNICODE_STRING_CP_LENGTH(u) \
+ (OBJECT_DATUM (MEMORY_REF ((u), UNICODE_STRING_LENGTH_INDEX)))
+
+#define UNICODE_STRING_FLAGS(u) \
+ (OBJECT_TYPE (MEMORY_REF ((u), UNICODE_STRING_LENGTH_INDEX)))
+
+/* This must be kept in sync with "runtime/string.scm". */
+#define UNICODE_STRING_BYTES_PER_CP(u) \
+ ((((UNICODE_STRING_FLAGS (u)) & 0x3) == 0) \
+ ? 3 \
+ : ((UNICODE_STRING_FLAGS (u)) & 0x3))
+
+#define UNICODE_STRING_BYTE_LENGTH(u) \
+ ((UNICODE_STRING_CP_LENGTH (u)) * (UNICODE_STRING_BYTES_PER_CP (u)))
+
+#define UNICODE_STRING_POINTER(u) \
+ ((uint8_t *) (MEMORY_LOC ((u), UNICODE_STRING_DATA)))
+
/* Legacy string operations */
/* Legacy strings are laid out exactly the same way as bytevectors,
* An object that points to one other object (extra indirection).
* Used by the compiler to share objects.
*/
-#define CELL_CONTENTS 0
+#define CELL_CONTENTS 0
/* BYTEVECTOR
* Format consists of the normal non-marked vector header
#define BYTEVECTOR_LENGTH_INDEX 1
#define BYTEVECTOR_LENGTH_SIZE 1
#define BYTEVECTOR_DATA 2
+
+#define UNICODE_STRING_HEADER 0
+#define UNICODE_STRING_LENGTH_INDEX 1
+#define UNICODE_STRING_DATA 2
\f
/* COMPILED_PROCEDURE */
#define COMP_PROCEDURE_ADDRESS 0
return ((LEGACY_STRING_P (object))
|| (BYTEVECTOR_P (object))
|| ((UNICODE_STRING_P (object))
- // This tests that the ustring-cp-size is == 1, meaning
- // one byte per code point. This must be kept in sync
- // with "runtime/ustring.scm".
- && (((OBJECT_TYPE (MEMORY_REF (object, BYTEVECTOR_LENGTH_INDEX)))
- & 0x03)
- == 0x01)));
+ && ((UNICODE_STRING_BYTES_PER_CP (object)) == 1)));
}
SCHEME_OBJECT