Pull upstream changes from TELY UI
This commit is contained in:
1 parent
7147ad52a2
commit
d5c98d5288
20 files changed
+17900
-10682
No files matched your search
@@ -1,4 +1,5 @@
|
||||
#include "dn_json_builder.h"
|
||||
#include <inttypes.h>
|
||||
|
||||
static void DN_JSB_Indent_(DN_JSBBuilder *builder, char *buf, size_t buf_size, size_t depth)
|
||||
{
|
||||
@@ -221,6 +222,78 @@ DN_JSBResult DN_JSB_ValueNumber(DN_JSBBuilder *builder, char *buf, size_t buf_si
|
||||
return result;
|
||||
}
|
||||
|
||||
static DN_JSBResult DN_JSB_ValueUnsigned_(DN_JSBBuilder *builder, char *buf, size_t buf_size, uint64_t value)
|
||||
{
|
||||
DN_JSBResult result = DN_JSB_BeginWriteValue_(builder, buf, buf_size);
|
||||
if (result == DN_JSBResult_Success) {
|
||||
result = DN_JSB_AppendF_(builder, buf, buf_size, "%" PRIu64, value);
|
||||
DN_JSB_FinishWriteValue_(builder, result);
|
||||
}
|
||||
if (builder->error == DN_JSBResult_Success)
|
||||
builder->error = result;
|
||||
return result;
|
||||
}
|
||||
|
||||
static DN_JSBResult DN_JSB_ValueSigned_(DN_JSBBuilder *builder, char *buf, size_t buf_size, int64_t value)
|
||||
{
|
||||
DN_JSBResult result = DN_JSB_BeginWriteValue_(builder, buf, buf_size);
|
||||
if (result == DN_JSBResult_Success) {
|
||||
result = DN_JSB_AppendF_(builder, buf, buf_size, "%" PRId64, value);
|
||||
DN_JSB_FinishWriteValue_(builder, result);
|
||||
}
|
||||
if (builder->error == DN_JSBResult_Success)
|
||||
builder->error = result;
|
||||
return result;
|
||||
}
|
||||
|
||||
DN_JSBResult DN_JSB_ValueU8(DN_JSBBuilder *builder, char *buf, size_t buf_size, uint8_t value)
|
||||
{
|
||||
DN_JSBResult result = DN_JSB_ValueUnsigned_(builder, buf, buf_size, value);
|
||||
return result;
|
||||
}
|
||||
|
||||
DN_JSBResult DN_JSB_ValueU16(DN_JSBBuilder *builder, char *buf, size_t buf_size, uint16_t value)
|
||||
{
|
||||
DN_JSBResult result = DN_JSB_ValueUnsigned_(builder, buf, buf_size, value);
|
||||
return result;
|
||||
}
|
||||
|
||||
DN_JSBResult DN_JSB_ValueU32(DN_JSBBuilder *builder, char *buf, size_t buf_size, uint32_t value)
|
||||
{
|
||||
DN_JSBResult result = DN_JSB_ValueUnsigned_(builder, buf, buf_size, value);
|
||||
return result;
|
||||
}
|
||||
|
||||
DN_JSBResult DN_JSB_ValueU64(DN_JSBBuilder *builder, char *buf, size_t buf_size, uint64_t value)
|
||||
{
|
||||
DN_JSBResult result = DN_JSB_ValueUnsigned_(builder, buf, buf_size, value);
|
||||
return result;
|
||||
}
|
||||
|
||||
DN_JSBResult DN_JSB_ValueI8(DN_JSBBuilder *builder, char *buf, size_t buf_size, int8_t value)
|
||||
{
|
||||
DN_JSBResult result = DN_JSB_ValueSigned_(builder, buf, buf_size, value);
|
||||
return result;
|
||||
}
|
||||
|
||||
DN_JSBResult DN_JSB_ValueI16(DN_JSBBuilder *builder, char *buf, size_t buf_size, int16_t value)
|
||||
{
|
||||
DN_JSBResult result = DN_JSB_ValueSigned_(builder, buf, buf_size, value);
|
||||
return result;
|
||||
}
|
||||
|
||||
DN_JSBResult DN_JSB_ValueI32(DN_JSBBuilder *builder, char *buf, size_t buf_size, int32_t value)
|
||||
{
|
||||
DN_JSBResult result = DN_JSB_ValueSigned_(builder, buf, buf_size, value);
|
||||
return result;
|
||||
}
|
||||
|
||||
DN_JSBResult DN_JSB_ValueI64(DN_JSBBuilder *builder, char *buf, size_t buf_size, int64_t value)
|
||||
{
|
||||
DN_JSBResult result = DN_JSB_ValueSigned_(builder, buf, buf_size, value);
|
||||
return result;
|
||||
}
|
||||
|
||||
DN_JSBResult DN_JSB_BeginWriteValue_(DN_JSBBuilder *builder, char *buf, size_t buf_size)
|
||||
{
|
||||
DN_JSBDepth *top = DN_JSB_PeekDepth_(builder, 0);
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define DN_JSON_BUILDER_H
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#if !defined(__cplusplus)
|
||||
#include <stdbool.h>
|
||||
@@ -63,6 +64,14 @@ DN_JSBResult DN_JSB_ValueStringF (DN_JSBBuilder *builder, char *buf, size_t
|
||||
DN_JSBResult DN_JSB_ValueBool (DN_JSBBuilder *builder, char *buf, size_t buf_size, bool flag);
|
||||
DN_JSBResult DN_JSB_ValueNull (DN_JSBBuilder *builder, char *buf, size_t buf_size);
|
||||
DN_JSBResult DN_JSB_ValueNumber (DN_JSBBuilder *builder, char *buf, size_t buf_size, double number);
|
||||
DN_JSBResult DN_JSB_ValueU8 (DN_JSBBuilder *builder, char *buf, size_t buf_size, uint8_t value);
|
||||
DN_JSBResult DN_JSB_ValueU16 (DN_JSBBuilder *builder, char *buf, size_t buf_size, uint16_t value);
|
||||
DN_JSBResult DN_JSB_ValueU32 (DN_JSBBuilder *builder, char *buf, size_t buf_size, uint32_t value);
|
||||
DN_JSBResult DN_JSB_ValueU64 (DN_JSBBuilder *builder, char *buf, size_t buf_size, uint64_t value);
|
||||
DN_JSBResult DN_JSB_ValueI8 (DN_JSBBuilder *builder, char *buf, size_t buf_size, int8_t value);
|
||||
DN_JSBResult DN_JSB_ValueI16 (DN_JSBBuilder *builder, char *buf, size_t buf_size, int16_t value);
|
||||
DN_JSBResult DN_JSB_ValueI32 (DN_JSBBuilder *builder, char *buf, size_t buf_size, int32_t value);
|
||||
DN_JSBResult DN_JSB_ValueI64 (DN_JSBBuilder *builder, char *buf, size_t buf_size, int64_t value);
|
||||
|
||||
DN_JSBDepth * DN_JSB_PeekDepth_ (DN_JSBBuilder *builder, size_t offset);
|
||||
bool DN_JSB_PushDepth_ (DN_JSBBuilder *builder, DN_JSBDepthType type);
|
||||
|
||||
@@ -780,7 +780,7 @@ DN_TestCore DN_SHA3_TestSuite(DN_Arena *arena)
|
||||
|
||||
// NOTE: Test SHA3 against some deterministic inputs generated from a PRNG
|
||||
for (DN_TestScopeF(&result, "[%.*s] Deterministic random inputs", DN_Str8PrintFmt(hash_name))) {
|
||||
DN_Pcg32 rng = DN_Pcg32Init(0xd48e'be21'2af8'733d);
|
||||
DN_Pcg32 rng = DN_Pcg32Init(0xd48ebe212af8733d);
|
||||
for (DN_USize index = 0; index < 128; index++) {
|
||||
// NOTE: Create a 4kb buffer with the deterministic contents
|
||||
char src[4096] = {};
|
||||
@@ -800,7 +800,7 @@ DN_TestCore DN_SHA3_TestSuite(DN_Arena *arena)
|
||||
|
||||
void DN_SHA3_TestSuiteThenOutput(DN_Str8FromTestCoreFlags flags)
|
||||
{
|
||||
DN_Arena arena = DN_ArenaFromHeap(DN_Megabytes(1), DN_Kilobytes(64), DN_MemFlags_Nil, DN_OS_HeapInitDefault(), "DN SHA3 Tests");
|
||||
DN_Arena arena = DN_ArenaFromHeap(DN_Megabytes(1), DN_Kilobytes(64), DN_MemListFlags_Nil, DN_Os_HeapInitDefault(), "DN SHA3 Tests");
|
||||
DN_TestCore test = DN_SHA3_TestSuite(&arena);
|
||||
DN_Str8 output = DN_Str8FromTestCore(&test, &arena, flags);
|
||||
printf("%.*s", DN_Str8PrintFmt(output));
|
||||
|
||||
Reference in new issue
Block a user