tolua_generator.h

00001  
00002 /***************************************************************************
00003  *  tolua_generator.h - ToLua++ Interface generator
00004  *
00005  *  Created: Tue Mar 11 15:30:09 2008
00006  *  Copyright  2006-2008  Tim Niemueller [www.niemueller.de]
00007  *
00008  ****************************************************************************/
00009 
00010 /*  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version.
00014  *
00015  *  This program is distributed in the hope that it will be useful,
00016  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  *  GNU Library General Public License for more details.
00019  *
00020  *  Read the full text in the LICENSE.GPL file in the doc directory.
00021  */
00022 
00023 #ifndef __INTERFACES_GENERATOR_TOLUA_GENERATOR_H_
00024 #define __INTERFACES_GENERATOR_TOLUA_GENERATOR_H_
00025 
00026 #include "field.h"
00027 #include "constant.h"
00028 #include "enum_constant.h"
00029 #include "message.h"
00030 #include "pseudomap.h"
00031 
00032 #include <vector>
00033 #include <string>
00034 #include <stdio.h>
00035 
00036 class ToLuaInterfaceGenerator
00037 {
00038  public:
00039   ToLuaInterfaceGenerator(std::string directory, std::string interface_name,
00040                           std::string config_basename, std::string author,
00041                           std::string year, std::string creation_date,
00042                           std::string data_comment,
00043                           const unsigned char *hash, size_t hash_size,
00044                           const std::vector<InterfaceConstant> &constants,
00045                           const std::vector<InterfaceEnumConstant> &enum_constants,
00046                           const std::vector<InterfaceField> &data_fields,
00047                           const std::vector<InterfacePseudoMap> &pseudo_maps,
00048                           const std::vector<InterfaceMessage> &messages
00049                           );
00050   ~ToLuaInterfaceGenerator();
00051 
00052   void write_toluaf(FILE *f);
00053 
00054   void write_header(FILE *f, std::string filename);
00055   void write_constants_h(FILE *f);
00056   void write_messages_h(FILE *f);
00057   void write_superclass_h(FILE *f);
00058   void write_methods_h(FILE *f,
00059                        std::string /* indent space */ is,
00060                        std::vector<InterfaceField> fields);
00061   void write_methods_h(FILE *f, std::string /* indent space */ is,
00062                        std::vector<InterfaceField> fields,
00063                        std::vector<InterfacePseudoMap> pseudo_maps);
00064   void write_message_ctor_dtor_h(FILE *f, std::string /* indent space */ is,
00065                                  std::string classname,
00066                                  std::vector<InterfaceField> fields);
00067   void write_ctor_dtor_h(FILE *f, std::string /* indent space */ is,
00068                          std::string classname);
00069 
00070   void generate();
00071 
00072   const char * convert_type(std::string c_type);
00073 
00074  private:
00075   std::vector<InterfaceConstant>     constants;
00076   std::vector<InterfaceEnumConstant> enum_constants;
00077   std::vector<InterfaceField>        data_fields;
00078   std::vector<InterfacePseudoMap>    pseudo_maps;
00079   std::vector<InterfaceMessage>      messages;
00080 
00081   std::string dir;
00082   std::string filename_tolua;
00083   std::string filename_h;
00084   std::string class_name;
00085   std::string gendate;
00086   std::string author;
00087   std::string year;
00088   std::string creation_date;
00089   std::string data_comment;
00090 
00091   const unsigned char *hash;
00092   size_t hash_size;
00093 };
00094 
00095 
00096 #endif

Generated on Tue Feb 22 13:31:23 2011 for Fawkes API by  doxygen 1.4.7