yeptris 0.6.59 → 0.6.60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +98 -20
- package/dist/yeptris.mjs +1 -1
- package/dist/yeptris.wasm +0 -0
- package/package.json +1 -1
- package/src/index.d.ts +224 -7
- package/src/index.js +729 -63
- package/src/yeptris_wasm.c +381 -5
package/src/yeptris_wasm.c
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
#include "yeptris/events.h"
|
|
17
17
|
#include "yeptris/json.h"
|
|
18
18
|
#include "yeptris/parse.h"
|
|
19
|
+
#include "yeptris/validate.h"
|
|
19
20
|
#include "yeptris/version.h"
|
|
20
21
|
|
|
21
22
|
static char *g_out;
|
|
@@ -334,19 +335,29 @@ int yeptris_wasm_load_all(const char *data, size_t len) {
|
|
|
334
335
|
return rc;
|
|
335
336
|
}
|
|
336
337
|
|
|
337
|
-
/*
|
|
338
|
-
* the
|
|
339
|
-
*
|
|
338
|
+
/* The dump-options face (emit.h's yeptris_emit_options): canonical
|
|
339
|
+
* selects the engine's fixed form (flow collections, quoted strings,
|
|
340
|
+
* typed words, shortest floats); best_width folds flow collections
|
|
341
|
+
* after a value once the line exceeds it (<= 0 rides the library
|
|
342
|
+
* default, 80 — the libyaml parity). The defaults (0, 0) are
|
|
343
|
+
* byte-identical to the no-options yeptris_serialize: opts_width
|
|
344
|
+
* answers 80 for best_width <= 0 and canonical 0 is the fidelity
|
|
345
|
+
* mode. */
|
|
340
346
|
EMSCRIPTEN_KEEPALIVE
|
|
341
|
-
int
|
|
347
|
+
int yeptris_wasm_dump_ex(const char *data, size_t len, int canonical, int best_width) {
|
|
342
348
|
YeptrisStatus st = YEPTRIS_OK;
|
|
343
349
|
YeptrisDocument doc = yeptris_parse(data, len, &st);
|
|
344
350
|
if (doc == NULL || st != YEPTRIS_OK) {
|
|
345
351
|
capture_error();
|
|
346
352
|
return (int)st;
|
|
347
353
|
}
|
|
354
|
+
yeptris_emit_options opts;
|
|
355
|
+
memset(&opts, 0, sizeof opts);
|
|
356
|
+
opts.size = (uint32_t)sizeof opts; /* the size-versioned contract */
|
|
357
|
+
opts.canonical = canonical;
|
|
358
|
+
opts.best_width = best_width;
|
|
348
359
|
size_t out_len = 0;
|
|
349
|
-
char *out =
|
|
360
|
+
char *out = yeptris_serialize_ex(doc, &opts, &out_len);
|
|
350
361
|
yeptris_document_free(doc);
|
|
351
362
|
if (out == NULL) {
|
|
352
363
|
snprintf(last_error, sizeof last_error, "serialization failed");
|
|
@@ -359,6 +370,14 @@ int yeptris_wasm_dump(const char *data, size_t len) {
|
|
|
359
370
|
return YEPTRIS_OK;
|
|
360
371
|
}
|
|
361
372
|
|
|
373
|
+
/* JSON in -> canonical YAML out (JSON is a subset of YAML 1.2 flow, so
|
|
374
|
+
* the one parse engine takes it; the emitter's canonical form is
|
|
375
|
+
* byte-stable across round trips). */
|
|
376
|
+
EMSCRIPTEN_KEEPALIVE
|
|
377
|
+
int yeptris_wasm_dump(const char *data, size_t len) {
|
|
378
|
+
return yeptris_wasm_dump_ex(data, len, 0, 0);
|
|
379
|
+
}
|
|
380
|
+
|
|
362
381
|
EMSCRIPTEN_KEEPALIVE
|
|
363
382
|
const char *yeptris_wasm_last_error(void) { return last_error; }
|
|
364
383
|
|
|
@@ -465,3 +484,360 @@ void yeptris_wasm_events_free(void) {
|
|
|
465
484
|
g_ev_count = 0;
|
|
466
485
|
g_ev_arena_len = 0;
|
|
467
486
|
}
|
|
487
|
+
|
|
488
|
+
/* ---- the tolerant per-document stream iterator (parse.h) ----------------
|
|
489
|
+
*
|
|
490
|
+
* loadAll is all-or-nothing: one bad document fails the whole stream.
|
|
491
|
+
* The stream iterator walks document by document: a parse-class failure
|
|
492
|
+
* surfaces as ONE failed item (the failed document's own line/col via
|
|
493
|
+
* the iterator's status accessor) and the walk RESUMES at the next
|
|
494
|
+
* line-start marker — the valid documents after a bad one are kept.
|
|
495
|
+
* The MEMORY/ENCODING classes are stream-fatal; the iterator is done.
|
|
496
|
+
*
|
|
497
|
+
* The wasm boundary needs a RETAINED walk (one next() per JS call),
|
|
498
|
+
* which means the shim retains two things across calls: the iterator
|
|
499
|
+
* handle and a COPY of the input — the engine iterator only borrows
|
|
500
|
+
* its buffer until free, and the host's feed pointer dies when the
|
|
501
|
+
* JS call that opened the walk returns. Lifecycle mirrors the events
|
|
502
|
+
* face: open (feed, copy, construct), next() repeatedly, close always
|
|
503
|
+
* (the JS generator's finally is the owner).
|
|
504
|
+
*
|
|
505
|
+
* The base four functions only (new/next/status/free) — this face
|
|
506
|
+
* ships against the v0.6.60 engine, whose iterator predates the slice
|
|
507
|
+
* accessors; the frame document crosses as JSON through the same
|
|
508
|
+
* g_out discipline every answer uses (a frame is a dcount==1 forest,
|
|
509
|
+
* so serialize_json answers it directly — the load path). */
|
|
510
|
+
static yeptris_stream_iter *g_it;
|
|
511
|
+
static char *g_it_buf; /* the borrowed input's retained copy */
|
|
512
|
+
static size_t g_it_buf_len;
|
|
513
|
+
static int g_it_frame; /* 1: g_out carries a document JSON; 0: none */
|
|
514
|
+
static int g_it_index; /* the last next() step's consumed stream index */
|
|
515
|
+
|
|
516
|
+
EMSCRIPTEN_KEEPALIVE
|
|
517
|
+
int yeptris_wasm_each_open(const char *data, size_t len) {
|
|
518
|
+
if (g_it != NULL) { /* defensive: the previous walk was not closed */
|
|
519
|
+
yeptris_stream_iter_free(g_it);
|
|
520
|
+
g_it = NULL;
|
|
521
|
+
}
|
|
522
|
+
free(g_it_buf);
|
|
523
|
+
g_it_buf = NULL;
|
|
524
|
+
g_it_buf_len = 0;
|
|
525
|
+
g_it_frame = 0;
|
|
526
|
+
g_it_index = 0;
|
|
527
|
+
g_it_buf = (char *)malloc(len > 0 ? len : 1);
|
|
528
|
+
if (g_it_buf == NULL) {
|
|
529
|
+
capture_plain("stream iterator allocation failed");
|
|
530
|
+
return YEPTRIS_ERROR_MEMORY;
|
|
531
|
+
}
|
|
532
|
+
if (len > 0) {
|
|
533
|
+
memcpy(g_it_buf, data, len);
|
|
534
|
+
}
|
|
535
|
+
g_it_buf_len = len;
|
|
536
|
+
g_it = yeptris_stream_iter_new(g_it_buf, len, NULL);
|
|
537
|
+
if (g_it == NULL) {
|
|
538
|
+
free(g_it_buf);
|
|
539
|
+
g_it_buf = NULL;
|
|
540
|
+
g_it_buf_len = 0;
|
|
541
|
+
capture_plain("stream iterator allocation failed");
|
|
542
|
+
return YEPTRIS_ERROR_MEMORY;
|
|
543
|
+
}
|
|
544
|
+
return YEPTRIS_OK;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
EMSCRIPTEN_KEEPALIVE
|
|
548
|
+
int yeptris_wasm_each_next(void) {
|
|
549
|
+
if (g_it == NULL) {
|
|
550
|
+
capture_plain("the walk is closed");
|
|
551
|
+
return YEPTRIS_ERROR_ARG;
|
|
552
|
+
}
|
|
553
|
+
YeptrisDocument doc = NULL;
|
|
554
|
+
size_t index = 0;
|
|
555
|
+
YeptrisStatus st = yeptris_stream_iter_next(g_it, &doc, &index);
|
|
556
|
+
g_it_index = (int)index;
|
|
557
|
+
if (st == YEPTRIS_OK && doc == NULL) { /* the stream is over */
|
|
558
|
+
g_it_frame = 0;
|
|
559
|
+
return YEPTRIS_OK;
|
|
560
|
+
}
|
|
561
|
+
if (st == YEPTRIS_OK) {
|
|
562
|
+
size_t out_len = 0;
|
|
563
|
+
char *out = yeptris_serialize_json(doc, &out_len);
|
|
564
|
+
yeptris_document_free(doc);
|
|
565
|
+
if (out == NULL) {
|
|
566
|
+
capture_plain("serialization failed");
|
|
567
|
+
return YEPTRIS_ERROR_MEMORY;
|
|
568
|
+
}
|
|
569
|
+
publish_out(out, out_len);
|
|
570
|
+
g_it_frame = 1;
|
|
571
|
+
return YEPTRIS_OK;
|
|
572
|
+
}
|
|
573
|
+
/* A failed document (parse/depth class; the walk may continue) or
|
|
574
|
+
* a stream-fatal verdict (MEMORY/ENCODING; it may not). The why
|
|
575
|
+
* rides the engine's error channel; the position rides the
|
|
576
|
+
* iterator's per-document status accessor — the authoritative
|
|
577
|
+
* source for the failed document's own mark. */
|
|
578
|
+
g_it_frame = 0;
|
|
579
|
+
capture_error();
|
|
580
|
+
uint32_t line = 0;
|
|
581
|
+
uint32_t col = 0;
|
|
582
|
+
yeptris_stream_iter_status(g_it, &line, &col);
|
|
583
|
+
last_error_line = (int)line;
|
|
584
|
+
last_error_column = (int)col;
|
|
585
|
+
return (int)st;
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
/* 1 when the last successful next() published a document JSON into
|
|
589
|
+
* g_out; 0 when the stream is over (the JS door's end sentinel). */
|
|
590
|
+
EMSCRIPTEN_KEEPALIVE
|
|
591
|
+
int yeptris_wasm_each_frame(void) { return g_it_frame; }
|
|
592
|
+
|
|
593
|
+
/* The 0-based stream index the last next() consumed — failures
|
|
594
|
+
* consume an index too, so the yield order is the stream's. */
|
|
595
|
+
EMSCRIPTEN_KEEPALIVE
|
|
596
|
+
int yeptris_wasm_each_index(void) { return g_it_index; }
|
|
597
|
+
|
|
598
|
+
EMSCRIPTEN_KEEPALIVE
|
|
599
|
+
void yeptris_wasm_each_close(void) {
|
|
600
|
+
yeptris_stream_iter_free(g_it);
|
|
601
|
+
g_it = NULL;
|
|
602
|
+
free(g_it_buf);
|
|
603
|
+
g_it_buf = NULL;
|
|
604
|
+
g_it_buf_len = 0;
|
|
605
|
+
g_it_frame = 0;
|
|
606
|
+
g_it_index = 0;
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
/* ---- validation (validate.h) -------------------------------------------
|
|
610
|
+
*
|
|
611
|
+
* The engine ships three validation doors — the SCHEMA-FAMILY walk
|
|
612
|
+
* (yeptris_validate, the YeptrisSchema kind rides as a plain int
|
|
613
|
+
* parameter), the one-shot JSON SCHEMA walk (yeptris_json_schema_
|
|
614
|
+
* validate) and the COMPILED economy (yeptris_schema_compile /
|
|
615
|
+
* yeptris_schema_validate / yeptris_schema_free: parse the schema
|
|
616
|
+
* once, validate many streams).
|
|
617
|
+
*
|
|
618
|
+
* Diagnostics cross as DATA, never as pointers: the whole report
|
|
619
|
+
* drains once into the same g_out arena the JSON answers use, spelled
|
|
620
|
+
* as one JSON array of raw records
|
|
621
|
+
*
|
|
622
|
+
* {"code":N,"path":"...","message":"...","line":N,"col":N,"offset":N}
|
|
623
|
+
*
|
|
624
|
+
* `path` is the engine's JSON-pointer instance path ("/a/b/0", ~0/~1
|
|
625
|
+
* escaped; "" at the root), `message` its bounded detail. The
|
|
626
|
+
* code -> keyword mapping is binding-owned (the same law the ruby/py
|
|
627
|
+
* faces follow) and lives in src/index.js — the shim carries the raw
|
|
628
|
+
* record only. The report frees inside the shim on every path; the
|
|
629
|
+
* JS answer arrives via the g_out discipline (read + out_free), so
|
|
630
|
+
* nothing engine-owned survives the call.
|
|
631
|
+
*
|
|
632
|
+
* Statuses through the wasm boundary: YEPTRIS_OK (valid) and
|
|
633
|
+
* YEPTRIS_ERROR_SCHEMA (invalid: the report carries diagnostics) both
|
|
634
|
+
* publish the array; every other status is a call failure —
|
|
635
|
+
* last_error carries the why, g_out is untouched. The host reads
|
|
636
|
+
* g_out for statuses 0 and 9 only.
|
|
637
|
+
*
|
|
638
|
+
* The compiled handle crosses as an opaque i32 (a wasm32 pointer):
|
|
639
|
+
* the host stores it and hands it back; free rides
|
|
640
|
+
* yeptris_wasm_schema_free. A compile failure answers 0 with
|
|
641
|
+
* last_error set. The engine carries NO schema KIND on the compile
|
|
642
|
+
* door (a compiled handle is a JSON-Schema document by
|
|
643
|
+
* validate.h's contract) — the family kind selection lives on the
|
|
644
|
+
* validate door, exactly as the C surface spells it. */
|
|
645
|
+
|
|
646
|
+
/* A growable append buffer for the report JSON. */
|
|
647
|
+
typedef struct {
|
|
648
|
+
char *p;
|
|
649
|
+
size_t len, cap;
|
|
650
|
+
int failed;
|
|
651
|
+
} yw_buf;
|
|
652
|
+
|
|
653
|
+
static void yw_buf_grow(yw_buf *b, size_t need) {
|
|
654
|
+
if (b->failed || b->len + need <= b->cap) {
|
|
655
|
+
return;
|
|
656
|
+
}
|
|
657
|
+
size_t ncap = b->cap ? b->cap : 256;
|
|
658
|
+
while (ncap < b->len + need) {
|
|
659
|
+
ncap *= 2;
|
|
660
|
+
}
|
|
661
|
+
char *np = (char *)realloc(b->p, ncap);
|
|
662
|
+
if (np == NULL) {
|
|
663
|
+
free(b->p);
|
|
664
|
+
b->p = NULL;
|
|
665
|
+
b->failed = 1;
|
|
666
|
+
return;
|
|
667
|
+
}
|
|
668
|
+
b->p = np;
|
|
669
|
+
b->cap = ncap;
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
static void yw_buf_puts(yw_buf *b, const char *s) {
|
|
673
|
+
size_t n = strlen(s);
|
|
674
|
+
yw_buf_grow(b, n + 1);
|
|
675
|
+
if (b->failed) {
|
|
676
|
+
return;
|
|
677
|
+
}
|
|
678
|
+
memcpy(b->p + b->len, s, n);
|
|
679
|
+
b->len += n;
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
/* Appends s as one JSON string literal: quote, escape (the bounded
|
|
683
|
+
* detail text can carry quotes, backslashes and control characters —
|
|
684
|
+
* the instance's own scalars appear in it), close. */
|
|
685
|
+
static void yw_buf_putjson(yw_buf *b, const char *s) {
|
|
686
|
+
yw_buf_grow(b, 1);
|
|
687
|
+
if (b->failed) {
|
|
688
|
+
return;
|
|
689
|
+
}
|
|
690
|
+
b->p[b->len++] = '"';
|
|
691
|
+
for (const unsigned char *c = (const unsigned char *)s; *c != '\0'; c++) {
|
|
692
|
+
char esc[8];
|
|
693
|
+
switch (*c) {
|
|
694
|
+
case '"':
|
|
695
|
+
yw_buf_puts(b, "\\\"");
|
|
696
|
+
break;
|
|
697
|
+
case '\\':
|
|
698
|
+
yw_buf_puts(b, "\\\\");
|
|
699
|
+
break;
|
|
700
|
+
case '\b':
|
|
701
|
+
yw_buf_puts(b, "\\b");
|
|
702
|
+
break;
|
|
703
|
+
case '\f':
|
|
704
|
+
yw_buf_puts(b, "\\f");
|
|
705
|
+
break;
|
|
706
|
+
case '\n':
|
|
707
|
+
yw_buf_puts(b, "\\n");
|
|
708
|
+
break;
|
|
709
|
+
case '\r':
|
|
710
|
+
yw_buf_puts(b, "\\r");
|
|
711
|
+
break;
|
|
712
|
+
case '\t':
|
|
713
|
+
yw_buf_puts(b, "\\t");
|
|
714
|
+
break;
|
|
715
|
+
default:
|
|
716
|
+
if (*c < 0x20) {
|
|
717
|
+
snprintf(esc, sizeof esc, "\\u%04x", (unsigned)*c);
|
|
718
|
+
yw_buf_puts(b, esc);
|
|
719
|
+
} else {
|
|
720
|
+
yw_buf_grow(b, 1);
|
|
721
|
+
if (b->failed) {
|
|
722
|
+
return;
|
|
723
|
+
}
|
|
724
|
+
b->p[b->len++] = (char)*c;
|
|
725
|
+
}
|
|
726
|
+
break;
|
|
727
|
+
}
|
|
728
|
+
if (b->failed) {
|
|
729
|
+
return;
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
yw_buf_grow(b, 2);
|
|
733
|
+
if (b->failed) {
|
|
734
|
+
return;
|
|
735
|
+
}
|
|
736
|
+
b->p[b->len++] = '"';
|
|
737
|
+
b->p[b->len] = '\0';
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
static void yw_buf_putint(yw_buf *b, long v) {
|
|
741
|
+
char tmp[32];
|
|
742
|
+
snprintf(tmp, sizeof tmp, "%ld", v);
|
|
743
|
+
yw_buf_puts(b, tmp);
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
/* Drains the whole report into g_out as the JSON array and frees the
|
|
747
|
+
* report — exactly once, on every path. rep may be NULL (an empty
|
|
748
|
+
* answer: the parse-failed statuses never reach here, but an engine
|
|
749
|
+
* that hands back no report for a valid empty stream does). */
|
|
750
|
+
static int yeptris_wasm_publish_report(yeptris_validate_report *rep) {
|
|
751
|
+
size_t n = rep != NULL ? yeptris_validate_report_count(rep) : 0;
|
|
752
|
+
yw_buf b;
|
|
753
|
+
memset(&b, 0, sizeof b);
|
|
754
|
+
yw_buf_puts(&b, "[");
|
|
755
|
+
for (size_t i = 0; i < n; i++) {
|
|
756
|
+
const yeptris_diagnostic *d = yeptris_validate_report_at(rep, i);
|
|
757
|
+
if (d == NULL) {
|
|
758
|
+
break;
|
|
759
|
+
}
|
|
760
|
+
if (i != 0) {
|
|
761
|
+
yw_buf_puts(&b, ",");
|
|
762
|
+
}
|
|
763
|
+
yw_buf_puts(&b, "{\"code\":");
|
|
764
|
+
yw_buf_putint(&b, (long)d->code);
|
|
765
|
+
yw_buf_puts(&b, ",\"path\":");
|
|
766
|
+
yw_buf_putjson(&b, d->path);
|
|
767
|
+
yw_buf_puts(&b, ",\"message\":");
|
|
768
|
+
yw_buf_putjson(&b, d->detail);
|
|
769
|
+
yw_buf_puts(&b, ",\"line\":");
|
|
770
|
+
yw_buf_putint(&b, (long)d->line);
|
|
771
|
+
yw_buf_puts(&b, ",\"col\":");
|
|
772
|
+
yw_buf_putint(&b, (long)d->col);
|
|
773
|
+
yw_buf_puts(&b, ",\"offset\":");
|
|
774
|
+
yw_buf_putint(&b, (long)d->offset);
|
|
775
|
+
yw_buf_puts(&b, "}");
|
|
776
|
+
}
|
|
777
|
+
yw_buf_puts(&b, "]");
|
|
778
|
+
yeptris_validate_report_free(rep);
|
|
779
|
+
if (b.failed) {
|
|
780
|
+
return YEPTRIS_ERROR_MEMORY;
|
|
781
|
+
}
|
|
782
|
+
/* Ownership moves to g_out: yeptris_wasm_out_free releases it via
|
|
783
|
+
* yeptris_free (plain free) — the same allocator this realloc/malloc
|
|
784
|
+
* pair rides, so the hand-off is symmetric. */
|
|
785
|
+
publish_out(b.p, b.len);
|
|
786
|
+
return YEPTRIS_OK;
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
/* The status a validate call answers with: OK and ERROR_SCHEMA both
|
|
790
|
+
* publish the report; the caller (JS) reads g_out for those two and
|
|
791
|
+
* treats the rest as a call failure. */
|
|
792
|
+
static int yeptris_wasm_validate_status(YeptrisStatus st, yeptris_validate_report *rep) {
|
|
793
|
+
if (st != YEPTRIS_OK && st != YEPTRIS_ERROR_SCHEMA) {
|
|
794
|
+
capture_error();
|
|
795
|
+
return (int)st;
|
|
796
|
+
}
|
|
797
|
+
if (yeptris_wasm_publish_report(rep) != 0) {
|
|
798
|
+
capture_plain("diagnostic serialization failed");
|
|
799
|
+
return YEPTRIS_ERROR_MEMORY;
|
|
800
|
+
}
|
|
801
|
+
return (int)st;
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
/* The SCHEMA-FAMILY walk: schema_kind is YeptrisSchema (resolve.h) —
|
|
805
|
+
* the engine validates that the kind IS a validation family and
|
|
806
|
+
* answers YEPTRIS_ERROR_ARG otherwise. */
|
|
807
|
+
EMSCRIPTEN_KEEPALIVE
|
|
808
|
+
int yeptris_wasm_validate(const char *data, size_t len, int schema_kind) {
|
|
809
|
+
yeptris_validate_report *rep = NULL;
|
|
810
|
+
YeptrisStatus st = yeptris_validate(data, len, (YeptrisSchema)schema_kind, &rep);
|
|
811
|
+
return yeptris_wasm_validate_status(st, rep);
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
/* The one-shot JSON SCHEMA walk (draft 2020-12 subset; validate.h). */
|
|
815
|
+
EMSCRIPTEN_KEEPALIVE
|
|
816
|
+
int yeptris_wasm_json_schema_validate(const char *schema, size_t schema_len, const char *data,
|
|
817
|
+
size_t len) {
|
|
818
|
+
yeptris_validate_report *rep = NULL;
|
|
819
|
+
YeptrisStatus st = yeptris_json_schema_validate(schema, schema_len, data, len, &rep);
|
|
820
|
+
return yeptris_wasm_validate_status(st, rep);
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
/* The COMPILED economy. The handle is an opaque wasm32 pointer the
|
|
824
|
+
* host stores verbatim; 0 = compile failed (last_error carries the
|
|
825
|
+
* why). */
|
|
826
|
+
EMSCRIPTEN_KEEPALIVE
|
|
827
|
+
yeptris_schema *yeptris_wasm_schema_compile(const char *bytes, size_t n) {
|
|
828
|
+
yeptris_schema *s = yeptris_schema_compile(bytes, n);
|
|
829
|
+
if (s == NULL) {
|
|
830
|
+
capture_error();
|
|
831
|
+
}
|
|
832
|
+
return s;
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
EMSCRIPTEN_KEEPALIVE
|
|
836
|
+
int yeptris_wasm_schema_validate(yeptris_schema *s, const char *data, size_t len) {
|
|
837
|
+
yeptris_validate_report *rep = NULL;
|
|
838
|
+
YeptrisStatus st = yeptris_schema_validate(s, data, len, &rep);
|
|
839
|
+
return yeptris_wasm_validate_status(st, rep);
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
EMSCRIPTEN_KEEPALIVE
|
|
843
|
+
void yeptris_wasm_schema_free(yeptris_schema *s) { yeptris_schema_free(s); }
|