' PBXA64/PBXB64 JSON core constants and lightweight runtime types
' JSON itself is protocol/data-format support, not a Windows DLL.
#IF NOT %DEF(PBX_JSON_CORE_PBI)
#DEFINE PBX_JSON_CORE_PBI
#INCLUDE ONCE "Legacy/Platform/win_types.inc"

' JSON value kinds
%EQUATE `PBX_JSON_TYPE_INVALID = 0
%EQUATE `PBX_JSON_TYPE_NULL = 1
%EQUATE `PBX_JSON_TYPE_FALSE = 2
%EQUATE `PBX_JSON_TYPE_TRUE = 3
%EQUATE `PBX_JSON_TYPE_NUMBER = 4
%EQUATE `PBX_JSON_TYPE_STRING = 5
%EQUATE `PBX_JSON_TYPE_ARRAY = 6
%EQUATE `PBX_JSON_TYPE_OBJECT = 7

' Parser flags
%EQUATE `PBX_JSON_PARSE_DEFAULT = 0
%EQUATE `PBX_JSON_PARSE_ALLOW_COMMENTS = &H00000001
%EQUATE `PBX_JSON_PARSE_ALLOW_TRAILING_COMMA = &H00000002
%EQUATE `PBX_JSON_PARSE_ALLOW_SINGLE_QUOTES = &H00000004
%EQUATE `PBX_JSON_PARSE_ALLOW_HEX_NUMBERS = &H00000008
%EQUATE `PBX_JSON_PARSE_ALLOW_INF_NAN = &H00000010
%EQUATE `PBX_JSON_PARSE_REQUIRE_TOP_OBJECT = &H00000100
%EQUATE `PBX_JSON_PARSE_REQUIRE_TOP_ARRAY = &H00000200
%EQUATE `PBX_JSON_PARSE_UTF8_STRICT = &H00001000
%EQUATE `PBX_JSON_PARSE_MAX_DEPTH_DEFAULT = 512

' Writer flags
%EQUATE `PBX_JSON_WRITE_COMPACT = 0
%EQUATE `PBX_JSON_WRITE_PRETTY = &H00000001
%EQUATE `PBX_JSON_WRITE_SORT_KEYS = &H00000002
%EQUATE `PBX_JSON_WRITE_ESCAPE_SLASH = &H00000004
%EQUATE `PBX_JSON_WRITE_ENSURE_ASCII = &H00000008
%EQUATE `PBX_JSON_WRITE_CANONICAL = &H00000010

' Error/result codes
%EQUATE `PBX_JSON_OK = 0
%EQUATE `PBX_JSON_ERR_GENERIC = -1
%EQUATE `PBX_JSON_ERR_OUT_OF_MEMORY = -2
%EQUATE `PBX_JSON_ERR_INVALID_HANDLE = -3
%EQUATE `PBX_JSON_ERR_INVALID_ARG = -4
%EQUATE `PBX_JSON_ERR_SYNTAX = -10
%EQUATE `PBX_JSON_ERR_UNEXPECTED_EOF = -11
%EQUATE `PBX_JSON_ERR_BAD_ESCAPE = -12
%EQUATE `PBX_JSON_ERR_BAD_NUMBER = -13
%EQUATE `PBX_JSON_ERR_DEPTH_LIMIT = -14
%EQUATE `PBX_JSON_ERR_DUPLICATE_KEY = -15
%EQUATE `PBX_JSON_ERR_PATH_NOT_FOUND = -30
%EQUATE `PBX_JSON_ERR_TYPE_MISMATCH = -31
%EQUATE `PBX_JSON_ERR_INDEX_RANGE = -32

' Common MIME/media types and encodings
%EQUATE `PBX_MIME_APPLICATION_JSON = "application/json"
%EQUATE `PBX_MIME_APPLICATION_PROBLEM_JSON = "application/problem+json"
%EQUATE `PBX_MIME_APPLICATION_JSON_PATCH = "application/json-patch+json"
%EQUATE `PBX_MIME_APPLICATION_MERGE_PATCH_JSON = "application/merge-patch+json"
%EQUATE `PBX_MIME_APPLICATION_NDJSON = "application/x-ndjson"
%EQUATE `PBX_MIME_TEXT_EVENT_STREAM = "text/event-stream"
%EQUATE `PBX_CHARSET_UTF8 = "utf-8"

TYPE PBX_JSON_SPAN
    pText AS QUAD
    cbText AS QUAD
END TYPE

TYPE PBX_JSON_LOCATION
    lineNo AS DWORD
    colNo AS DWORD
    byteOffset AS QUAD
END TYPE

TYPE PBX_JSON_ERROR_INFO
    code AS LONG
    location AS PBX_JSON_LOCATION
    messagePtr AS QUAD
END TYPE

#ENDIF
