javascriptcore/jsstringref

Bindings for JSStringRef.h.

Types

JSChar = uint16
A UTF-16 code unit. (On macOS JSChar is unsigned short; the wchar_t branch only applies to MSVC-like targets we skip.)

Procs

proc JSStringCreateWithCharacters(chars: ptr JSChar; numChars: csize_t): JSStringRef {.
    header: "<JavaScriptCore/JavaScript.h>", importc, cdecl, ...raises: [],
    tags: [], forbids: [].}
Creates a string from a UTF-16 buffer. Ownership follows the Create Rule.
proc JSStringCreateWithUTF8CString(str: cstring): JSStringRef {.
    header: "<JavaScriptCore/JavaScript.h>", importc, cdecl, ...raises: [],
    tags: [], forbids: [].}
Creates a string from a null-terminated UTF-8 string. Create Rule.
proc JSStringGetCharactersPtr(str: JSStringRef): ptr JSChar {.
    header: "<JavaScriptCore/JavaScript.h>", importc, cdecl, ...raises: [],
    tags: [], forbids: [].}
Returns the borrowed backing buffer. Valid until str is released.
proc JSStringGetLength(str: JSStringRef): csize_t {.
    header: "<JavaScriptCore/JavaScript.h>", importc, cdecl, ...raises: [],
    tags: [], forbids: [].}
Returns the length in UTF-16 code units (not bytes, not graphemes).
proc JSStringGetMaximumUTF8CStringSize(str: JSStringRef): csize_t {.
    header: "<JavaScriptCore/JavaScript.h>", importc, cdecl, ...raises: [],
    tags: [], forbids: [].}
Upper bound (in bytes, including the NUL) for the UTF-8 conversion.
proc JSStringGetUTF8CString(str: JSStringRef; buffer: cstring;
                            bufferSize: csize_t): csize_t {.
    header: "<JavaScriptCore/JavaScript.h>", importc, cdecl, ...raises: [],
    tags: [], forbids: [].}
Copies the NUL-terminated UTF-8 form into buffer. Returns bytes written including the NUL. Partial on a too-small buffer.
proc JSStringIsEqual(a, b: JSStringRef): bool {.
    header: "<JavaScriptCore/JavaScript.h>", importc, cdecl, ...raises: [],
    tags: [], forbids: [].}
Tests whether two strings match.
proc JSStringIsEqualToUTF8CString(a: JSStringRef; b: cstring): bool {.
    header: "<JavaScriptCore/JavaScript.h>", importc, cdecl, ...raises: [],
    tags: [], forbids: [].}
Tests whether a string matches a NUL-terminated UTF-8 string.
proc JSStringRelease(str: JSStringRef) {.
    header: "<JavaScriptCore/JavaScript.h>", importc, cdecl, ...raises: [],
    tags: [], forbids: [].}
Releases a string.
proc JSStringRetain(str: JSStringRef): JSStringRef {.
    header: "<JavaScriptCore/JavaScript.h>", importc, cdecl, ...raises: [],
    tags: [], forbids: [].}
Retains a string.