Needs some more fleshing out
This section lists the primitive functions and types that are required for
the code produced by asdlGen
to correctly compile. Note this is a language
independent presentation.
All languages require the following
The input and output stream that the reader and writer functions expect.
The type of integers, possibly a "bignum" type.
The type of strings
The type of identifiers
Read and write a constructor and length tags out in ASDL integer format. Both should use the languages standard integer types rather than a "bignum" types.
Read and write the int type out in ASDL integer format.
Read and write the string type out in the ASDL string format.
Read and write the identifier type out in the ASDL identifier format.
Signal a fatal error.
C and SML have libraries that use a bignum type
rather than the a fixnum for the ASDL int type. To have the int type
be a bignum in C use the flag --base_include cii_big_base.h
. In
SML the flags are --base_signature BIG_BASE
and
--base_structure BigBase
.
For code that does not use polymorphic list and option the following extra types are needed along with the corresponding read and write functions
The list and option types for integers.
The list an option types for strings.
The list an option types for identifiers.
For code that supports polymorphic list and options the following extra functions are required
Functions whose first argument is a read or write function for a specific type that reads or writes a list of that type.
Functions whose first argument is a read or write function for a specific type that reads or writes a option of that type.
--mono_types=false
for C
For the --mono_types false
option in C these function expect functions
pointers that correspond to the following C typedefs
typedef void *(*generic_reader_ty)(instream_ty s);
typedef void (*generic_writer_ty)(void *x,outstream_ty s);
Function pointer with different argument types are distinct types in C that
can not be safely cast between because they may differ in calling
conventions. asdlGen
solves this problem by automatically generating
function stubs that internally cast the void*
pointers for each option
and list type. These reader and writer functions are prefixed
generic_
. There also should be list_ty
and opt_ty
typedefs.