(** Code generation. *) (* Memory info command for virtual domains. (C) Copyright 2008 Richard W.M. Jones, Red Hat Inc. http://libvirt.org/ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *) (** This module is concerned with actually generating code for types, parsers, etc. We generate two output files, [kernel.mli] is the interface to the kernel structures, and [kernel.ml] is the implementation. *) (** {2 Generate types} *) val generate_types : (string * Struct_classify.shape_field_struct list * Struct_classify.content_field_struct list) list -> Camlp4.PreCast.Syntax.Ast.str_item * Camlp4.PreCast.Syntax.Ast.sig_item (** [generate_types structures] generates the internal types used to store variants of each structure, including: - shape field structures - content field structures *) (** {2 Generate parsers} *) val generate_parsers : (string * Struct_classify.parser_ list) list -> Camlp4.PreCast.Syntax.Ast.str_item * Camlp4.PreCast.Syntax.Ast.sig_item * (string, string) Hashtbl.t (** [generate_parsers] generates the parser functions. We cannot generate the complete code here because we don't want camlp4 parsing this file to substitute bitmatch code yet. So we only generate labels, which get substituted by the contents of the returned hash table in {!output_implem}. *) (** {2 Output final files} *) val output_interf : output_file:string -> Camlp4.PreCast.Syntax.Ast.sig_item -> Camlp4.PreCast.Syntax.Ast.sig_item -> unit (** Output the interface file. *) val output_implem : output_file:string -> Camlp4.PreCast.Syntax.Ast.str_item -> Camlp4.PreCast.Syntax.Ast.str_item -> (string, string) Hashtbl.t -> unit (** Output the implementation file. *)