chromium/third_party/skia/src/utils/SkJSON.cpp

/*
 * Copyright 2018 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#include "src/utils/SkJSON.h"

#include "include/core/SkData.h"
#include "include/core/SkRefCnt.h"
#include "include/core/SkStream.h"
#include "include/core/SkString.h"
#include "include/private/base/SkDebug.h"
#include "include/private/base/SkMalloc.h"
#include "include/private/base/SkTo.h"
#include "include/utils/SkParse.h"
#include "src/base/SkArenaAlloc.h"
#include "src/base/SkUTF.h"

#include <cmath>
#include <cstdint>
#include <cstdlib>
#include <limits>
#include <new>
#include <tuple>
#include <vector>

namespace skjson {

// #define SK_JSON_REPORT_ERRORS

static_assert;
static_assert;

static constexpr size_t kRecAlign =;

void Value::init_tagged(Tag t) {}

// Pointer values store a type (in the lower kTagBits bits) and a pointer.
void Value::init_tagged_pointer(Tag t, void* p) {}

NullValue::NullValue() {}

BoolValue::BoolValue(bool b) {}

NumberValue::NumberValue(int32_t i) {}

NumberValue::NumberValue(float f) {}

// Vector recs point to externally allocated slabs with the following layout:
//
//   [size_t n] [REC_0] ... [REC_n-1] [optional extra trailing storage]
//
// Long strings use extra_alloc_size == 1 to store the \0 terminator.
//
template <typename T, size_t extra_alloc_size = 0>
static void* MakeVector(size_t vec_size, const void* src, size_t src_size, SkArenaAlloc& alloc) {}

template <typename T, size_t extra_alloc_size = 0>
static void* MakeVector(size_t vec_size, const void* src, SkArenaAlloc& alloc) {}

ArrayValue::ArrayValue(const Value* src, size_t size, SkArenaAlloc& alloc) {}

// Strings have two flavors:
//
// -- short strings (len <= 7) -> these are stored inline, in the record
//    (one byte reserved for null terminator/type):
//
//        [str] [\0]|[max_len - actual_len]
//
//    Storing [max_len - actual_len] allows the 'len' field to double-up as a
//    null terminator when size == max_len (this works 'cause kShortString == 0).
//
// -- long strings (len > 7) -> these are externally allocated vectors (VectorRec<char>).
//
// The string data plus a null-char terminator are copied over.
//
namespace {

// An internal string builder with a fast 8 byte short string load path
// (for the common case where the string is not at the end of the stream).
class FastString final : public Value {};

} // namespace

StringValue::StringValue(const char* src, SkArenaAlloc& alloc)
    :{}

StringValue::StringValue(const char* src, size_t size, SkArenaAlloc& alloc) {}

ObjectValue::ObjectValue(const Member* src, size_t size, SkArenaAlloc& alloc) {}


// Boring public Value glue.

static int inline_strcmp(const char a[], const char b[]) {}

const Member* ObjectValue::find(const char* key) const {}

Value& ObjectValue::writable(const char* key, SkArenaAlloc& alloc) const {}

namespace {

// Lexer/parser inspired by rapidjson [1], sajson [2] and pjson [3].
//
// [1] https://github.com/Tencent/rapidjson/
// [2] https://github.com/chadaustin/sajson
// [3] https://pastebin.com/hnhSTL3h


// bit 0 (0x01) - plain ASCII string character
// bit 1 (0x02) - whitespace
// bit 2 (0x04) - string terminator (" \\ \0 [control chars] **AND } ]** <- see matchString notes)
// bit 3 (0x08) - 0-9
// bit 4 (0x10) - 0-9 e E .
// bit 5 (0x20) - scope terminator (} ])
static constexpr uint8_t g_token_flags[256] =;

static inline bool is_ws(char c)       {}
static inline bool is_eostring(char c) {}
static inline bool is_digit(char c)    {}
static inline bool is_numeric(char c)  {}
static inline bool is_eoscope(char c)  {}

static inline const char* skip_ws(const char* p) {}

static inline float pow10(int32_t exp) {}

class DOMParser {};

void Write(const Value& v, SkWStream* stream) {}

} // namespace

SkString Value::toString() const {}

static constexpr size_t kMinChunkSize =;

DOM::DOM(const char* data, size_t size)
    :{}

void DOM::write(SkWStream* stream) const {}

} // namespace skjson