maug
Quick and dirty C mini-augmentation library.
Loading...
Searching...
No Matches
Serialize Code Generation Tool
Collaboration diagram for Serialize Code Generation Tool:

Serialize Code Generation Tool

This tool, located in $MAUG_ROOT/tools/serial.c, generates code based on the header files it is pointed at. In general, header files processed by this tool must meet the following requirements:
  • Struct fields are defined one per line.
  • Constants (e.g. for array counts) are defined in the same file.
  • Types of struct fields should be maug, native, or defined earlier in the same header. Field types that are not any of these must be predefined in Serialize Tool Custom Types, with appropriate serialize/deserialize callbacks provided in another translation unit at link time.
There may be additional restrictions to these that are not noted here.

Serialize Tool Custom Types

Custom typedefs should be provided in msercust.h in the following format:

#  define parse_field_type_table( f ) \
      parse_field_type_table_base( f ) \
      f( custom_type_a,              101 ) \
      f( struct custom_type_b,       102 ) \
In this example, custom_type_a is the name of the type and 101 is its ID. The IDs start from 100 and there can be thousands.If custom_type_a is provided here, a callback of type mserialize_cb_t() and mdeserialize_cb_t() (called mseralize_custom_type_a and mdeserialize_custom_type_b) must be provided by a linked translation unit.For struct custom_type_b, the callbacks would be called mseralize_struct_custom_type_b() and mdeseralize_struct_custom_type_b().