Minor changes in gen/ui_class.cpp/h files

This commit is contained in:
David Capello 2016-12-22 14:18:25 -03:00
parent 9e3a6f8fe2
commit 01a6fe6dbc
2 changed files with 15 additions and 14 deletions

View File

@ -80,7 +80,9 @@ static std::string convert_type(const std::string& name)
throw base::Exception("unknown widget name: " + name); throw base::Exception("unknown widget name: " + name);
} }
void gen_ui_class(TiXmlDocument* doc, const std::string& inputFn, const std::string& widgetId) void gen_ui_class(TiXmlDocument* doc,
const std::string& inputFn,
const std::string& widgetId)
{ {
std::cout std::cout
<< "// Don't modify, generated file from " << inputFn << "\n" << "// Don't modify, generated file from " << inputFn << "\n"
@ -133,9 +135,8 @@ void gen_ui_class(TiXmlDocument* doc, const std::string& inputFn, const std::str
<< " app::load_widget(\"" << base::get_file_name(inputFn) << "\", \"" << widgetId << "\", this);\n" << " app::load_widget(\"" << base::get_file_name(inputFn) << "\", \"" << widgetId << "\", this);\n"
<< " app::finder(this)\n"; << " app::finder(this)\n";
for (XmlElements::iterator it=widgets.begin(), end=widgets.end(); for (TiXmlElement* elem : widgets) {
it != end; ++it) { const char* id = elem->Attribute("id");
const char* id = (*it)->Attribute("id");
std::string cppid = convert_xmlid_to_cppid(id, false); std::string cppid = convert_xmlid_to_cppid(id, false);
std::cout std::cout
<< " >> \"" << id << "\" >> m_" << cppid << "\n"; << " >> \"" << id << "\" >> m_" << cppid << "\n";
@ -146,10 +147,9 @@ void gen_ui_class(TiXmlDocument* doc, const std::string& inputFn, const std::str
<< " }\n" << " }\n"
<< "\n"; << "\n";
for (XmlElements::iterator it=widgets.begin(), end=widgets.end(); for (TiXmlElement* elem : widgets) {
it != end; ++it) { std::string childType = convert_type(elem->Value());
std::string childType = convert_type((*it)->Value()); const char* id = elem->Attribute("id");
const char* id = (*it)->Attribute("id");
std::string cppid = convert_xmlid_to_cppid(id, false); std::string cppid = convert_xmlid_to_cppid(id, false);
std::cout std::cout
<< " " << childType << "* " << cppid << "() const { return m_" << cppid << "; }\n"; << " " << childType << "* " << cppid << "() const { return m_" << cppid << "; }\n";
@ -159,10 +159,9 @@ void gen_ui_class(TiXmlDocument* doc, const std::string& inputFn, const std::str
<< "\n" << "\n"
<< " private:\n"; << " private:\n";
for (XmlElements::iterator it=widgets.begin(), end=widgets.end(); for (TiXmlElement* elem : widgets) {
it != end; ++it) { std::string childType = convert_type(elem->Value());
std::string childType = convert_type((*it)->Value()); const char* id = elem->Attribute("id");
const char* id = (*it)->Attribute("id");
std::string cppid = convert_xmlid_to_cppid(id, false); std::string cppid = convert_xmlid_to_cppid(id, false);
std::cout std::cout
<< " " << childType << "* m_" << cppid << ";\n"; << " " << childType << "* m_" << cppid << ";\n";

View File

@ -1,5 +1,5 @@
// Aseprite Code Generator // Aseprite Code Generator
// Copyright (c) 2014 David Capello // Copyright (c) 2014-2016 David Capello
// //
// This file is released under the terms of the MIT license. // This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information. // Read LICENSE.txt for more information.
@ -11,6 +11,8 @@
#include <string> #include <string>
#include "tinyxml.h" #include "tinyxml.h"
void gen_ui_class(TiXmlDocument* doc, const std::string& inputFn, const std::string& widgetId); void gen_ui_class(TiXmlDocument* doc,
const std::string& inputFn,
const std::string& widgetId);
#endif #endif