npm stats
  • Search
  • About
  • Repo
  • Sponsor
  • more
    • Search
    • About
    • Repo
    • Sponsor

Made by Antonio Ramirez

hyperschema-c

0.4.0

@GitHub Actions

npmHomeRepoSnykSocket
Downloads:12
$ npm install hyperschema-c
DailyWeeklyMonthlyYearly

hyperschema-c

C code generation for Hyperschema. Transforms schema definitions into C structs with preencode/encode/decode functions using libcompact.

npm i hyperschema-c

Usage

const CHyperschema = require('hyperschema-c')

const schema = CHyperschema.from('./spec')

// Get generated C source as strings
const { header, source } = schema.toCode()

// Or write the generated files to disk
CHyperschema.toDisk(schema, './output')

toDisk writes:

output/
  <target>.h
  <target>.c
  schema.json
  CMakeLists.txt

where <target> is derived from the schema's namespaces — <ns>_schema for a single namespace, <ns1>_<ns2>_schema for multiple. A schema in namespace hc produces hc_schema.h and hc_schema.c.

License

Apache-2.0