ORT_LANG_JSON(3)

NAME
ort_lang_c_source - generate JavaScript (TypeScript) interface to ort data

LIBRARY
libort-lang-javascript

SYNOPSIS
#include <sys/queue.h>
#include <stdio.h>
#include <ort.h>
#include <ort-lang-javascript.h>
int
ort_lang_javascript(const struct ort_lang_javascript *args, const struct config *cfg, FILE *f);

DESCRIPTION
Outputs a JavaScript (really TypeScript) file to f from the parsed configuration cfg with classes to populate HTML5 DOM trees with JSON produced by ort_lang_c_header(3) json_xxxx() functions and ort_lang_nodejs(3) exports. Parameters are in args. The values in args are as follows:

const char *ext_privMethods
    This string consists of classes and functions required by the produced code. It must be set to the contents of ortPrivate.ts.

The output is documented in typedoc.

RETURN VALUES
Returns zero on failure, non-zero on success. Failure only occurs with memory allocation errors or when writing to f.

FILES

ortPrivate.ts
    Helper classes and functions that must be specified as ext_privMethods in the configuration. This is usually installed in /usr/local/share/openradtool.

EXAMPLES
The following emits formatting routines to standard output as read from standard input. It assumes that buf has been initialised to the contents of ortPrivate.ts.

    struct config *cfg;
    struct ort_lang_javascript args;
    FILE *f;
    memset(&args, 0, sizeof(struct ort_lang_javascript));
    args.ext_privMethods = buf;
    if ((cfg = ort_config_alloc()) == NULL)
      err(1, NULL);
    if (!ort_parse_file(cfg, stdin, "<stdin>"))
      errx(1, "ort_parse_file");
    if (!ort_parse_close(cfg))
      errx(1, "ort_parse_close");
    if (!ort_lang_javascript(&args, cfg, stdout))
      err(1, "ort_lang_javascript");
    ort_config_free(cfg);

Alternatively, this could be converted into a string:

    char *buf = NULL;
    size_t bufsz = 0;
    /* Read and parse configuration as above... */
    if ((stream = open_memstream(&buf, &bufsz)) == NULL)
      err(1, "open_memstream");
    if (!ort_lang_javascript(&args, cfg, stream))
      err(1, "ort_lang_javascript");
    fclose(stream);
    /* Do something with buf of size bufsz. */
    free(buf);

SEE ALSO
pkg-config(1), ort(3)