▲ | frumiousirc 6 days ago | |
The way to do this starts with not hard-wiring the code generation step. Instead, make codegen a function of BOTH a data schema object and a code template (eg expressed in Jinja2 template language - or ZeroMQ GSL where I first saw this approach). The codegen stage is then simply the application of the template to the data schema to produce a code artifact. The templates are written assuming the data schema is provided following a meta-schema (eg JSON Schema for a data schema in JSON). One can develop, eg per-language templates to produce serialization code or intra-language converters between serialization forms (on wire) and application friendly forms. The extra effort to develop a template for a particular target is amortized as it will work across all data schemas that adhere to a common meta-schema. The "codegen" stage can of course be given non "code" templates to produce, eg, reference documentation about the data schema in different formats like HTML, text, nroff/man, etc. | ||
▲ | mdaniel 6 days ago | parent [-] | |
I didn't recognize the GSL citation, so for others: - https://github.com/zeromq/gsl/blob/v4.1.5/examples/fsm_c.gsl whew, this readme has everything - XML in, text out: https://github.com/zeromq/gsl#:~:text=feed%20it%20some%20dat... - a whole section on software engineering https://github.com/zeromq/gsl#model-oriented-programming - they support COBOL https://github.com/zeromq/gsl#cobol - and then a project 11 years old with "we're going to document these functions one day" https://github.com/zeromq/gsl#global-functions What a journey that was |