Fawkes API Fawkes Development Version
tolua_generator.h
1
2/***************************************************************************
3 * tolua_generator.h - ToLua++ Interface generator
4 *
5 * Created: Tue Mar 11 15:30:09 2008
6 * Copyright 2006-2008 Tim Niemueller [www.niemueller.de]
7 *
8 ****************************************************************************/
9
10/* This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Library General Public License for more details.
19 *
20 * Read the full text in the LICENSE.GPL file in the doc directory.
21 */
22
23#ifndef _INTERFACES_GENERATOR_TOLUA_GENERATOR_H_
24#define _INTERFACES_GENERATOR_TOLUA_GENERATOR_H_
25
26#include "constant.h"
27#include "enum_constant.h"
28#include "field.h"
29#include "message.h"
30#include "pseudomap.h"
31
32#include <stdio.h>
33#include <string>
34#include <vector>
35
37{
38public:
39 ToLuaInterfaceGenerator(std::string directory,
40 std::string interface_name,
41 std::string config_basename,
42 std::string author,
43 std::string year,
44 std::string creation_date,
45 std::string data_comment,
46 const unsigned char * hash,
47 size_t hash_size,
48 const std::vector<InterfaceConstant> & constants,
49 const std::vector<InterfaceEnumConstant> &enum_constants,
50 const std::vector<InterfaceField> & data_fields,
51 const std::vector<InterfacePseudoMap> & pseudo_maps,
52 const std::vector<InterfaceMessage> & messages);
54
55 void write_toluaf(FILE *f);
56
57 void write_header(FILE *f, std::string filename);
58 void write_constants_h(FILE *f);
59 void write_messages_h(FILE *f);
60 void write_message_superclass_h(FILE *f);
61 void write_superclass_h(FILE *f);
62 void write_lua_code(FILE *f, std::string classname);
63 void
64 write_methods_h(FILE *f, std::string /* indent space */ is, std::vector<InterfaceField> fields);
65 void write_methods_h(FILE * f,
66 std::string /* indent space */ is,
67 std::vector<InterfaceField> fields,
68 std::vector<InterfacePseudoMap> pseudo_maps);
69 void write_message_ctor_dtor_h(FILE * f,
70 std::string /* indent space */ is,
71 std::string classname,
72 std::vector<InterfaceField> fields);
73 void write_ctor_dtor_h(FILE *f, std::string /* indent space */ is, std::string classname);
74
75 void generate();
76
77 const char *convert_type(std::string c_type);
78
79private:
80 std::vector<InterfaceConstant> constants;
81 std::vector<InterfaceEnumConstant> enum_constants;
82 std::vector<InterfaceField> data_fields;
83 std::vector<InterfacePseudoMap> pseudo_maps;
84 std::vector<InterfaceMessage> messages;
85
86 std::string dir;
87 std::string filename_tolua;
88 std::string filename_h;
89 std::string class_name;
90 std::string gendate;
91 std::string author;
92 std::string year;
93 std::string creation_date;
94 std::string data_comment;
95
96 const unsigned char *hash;
97 size_t hash_size;
98};
99
100#endif
Generator that transforms input from the InterfaceParser into valid ToLua++ package file.
void write_methods_h(FILE *f, std::string is, std::vector< InterfaceField > fields)
Write methods to h file.
void write_lua_code(FILE *f, std::string classname)
Write additional Lua code to file.
void write_superclass_h(FILE *f)
Write superclass methods.
void write_messages_h(FILE *f)
Write messages to h file.
ToLuaInterfaceGenerator(std::string directory, std::string interface_name, std::string config_basename, std::string author, std::string year, std::string creation_date, std::string data_comment, const unsigned char *hash, size_t hash_size, const std::vector< InterfaceConstant > &constants, const std::vector< InterfaceEnumConstant > &enum_constants, const std::vector< InterfaceField > &data_fields, const std::vector< InterfacePseudoMap > &pseudo_maps, const std::vector< InterfaceMessage > &messages)
Constructor.
void write_header(FILE *f, std::string filename)
Write header to file.
~ToLuaInterfaceGenerator()
Destructor.
void write_message_superclass_h(FILE *f)
Write superclass methods.
void write_ctor_dtor_h(FILE *f, std::string is, std::string classname)
Write constructor and destructor to h file.
const char * convert_type(std::string c_type)
Convert C type to Lua type.
void write_message_ctor_dtor_h(FILE *f, std::string is, std::string classname, std::vector< InterfaceField > fields)
Write constructor and destructor for message to h file.
void write_constants_h(FILE *f)
Write constants to h file.
void write_toluaf(FILE *f)
Write h file.
void generate()
Generator cpp and h files.