void CppCodeGenerator::GenDefines( shared_ptr< ObjectBase > project) { set< wxString > macro_set; FindMacros( project, macro_set ); // la macro por defecto tiene valor -1 m_header->WriteLn( wxT("#define ID_DEFAULT wxID_ANY // Default") ); // debemos quitar la macro por defecto del conjunto set<wxString>::iterator it; it = macro_set.find( wxT("ID_DEFAULT") ); if ( it != macro_set.end() ) { macro_set.erase(it); } unsigned int id = m_firstID; if ( id < 1000 ) { wxLogWarning(wxT("First ID is Less than 1000")); } for (it = macro_set.begin() ; it != macro_set.end(); it++) { m_header->WriteLn( wxString::Format( wxT("#define %s %i"), it->c_str(), id ) ); id++; } m_header->WriteLn( wxT("") ); }
void CppCodeGenerator::GenDefines(PObjectBase project) { set<string> macro_set; FindMacros(project,macro_set); m_source->WriteLn(""); // la macro por defecto tiene valor -1 m_source->WriteLn("#define ID_DEFAULT -1 // Default"); // debemos quitar la macro por defecto del conjunto set<string>::iterator it; it = macro_set.find("ID_DEFAULT"); if (it != macro_set.end()) macro_set.erase(it); for (it = macro_set.begin() ; it != macro_set.end(); it++) { unsigned int id = 1000; ostringstream define; define << "#define " << *it << " " << id; m_source->WriteLn(define.str()); id++; } m_source->WriteLn(""); }
void CppCodeGenerator::FindMacros( shared_ptr< ObjectBase > obj, set< wxString >& macro_set ) { // recorre cada propiedad de cada objeto identificando aquellas // que sean macros, en cuyo caso la añade al conjunto. unsigned int i; for ( i = 0; i < obj->GetPropertyCount(); i++ ) { shared_ptr<Property> prop = obj->GetProperty( i ); if ( prop->GetType() == PT_MACRO ) { wxString value = prop->GetValue(); set< wxString >::iterator it = m_predMacros.find( value ); if ( it == m_predMacros.end() ) { macro_set.insert( prop->GetValue() ); } } } for ( i = 0; i < obj->GetChildCount(); i++ ) { FindMacros( obj->GetChild( i ), macro_set ); } }
void CppCodeGenerator::GenEnumIds(shared_ptr< ObjectBase > class_obj) { set<wxString> macro_set; FindMacros(class_obj,macro_set); set<wxString>::iterator it = macro_set.begin(); if ( it != macro_set.end()) { m_header->WriteLn( wxT("enum") ); m_header->WriteLn( wxT("{") ); m_header->Indent(); m_header->WriteLn( wxString::Format( wxT("%s = %i,"), it->c_str(), m_firstID ) ); it++; while ( it != macro_set.end() ) { m_header->WriteLn( *it + wxT(",") ); it++; } //m_header->WriteLn(id); m_header->Unindent(); m_header->WriteLn( wxT("};") ); m_header->WriteLn( wxT("") ); } }
void PHPCodeGenerator::GenDefines( PObjectBase project) { std::vector< wxString > macros; FindMacros( project, ¯os ); // Remove the default macro from the set, for backward compatiblity std::vector< wxString >::iterator it; it = std::find( macros.begin(), macros.end(), wxT("ID_DEFAULT") ); if ( it != macros.end() ) { // The default macro is defined to wxID_ANY m_source->WriteLn( wxT("const ID_DEFAULT = wxID_ANY; // Default") ); macros.erase(it); } unsigned int id = m_firstID; if ( id < 1000 ) { wxLogWarning(wxT("First ID is Less than 1000")); } for (it = macros.begin() ; it != macros.end(); it++) { // Don't redefine wx IDs m_source->WriteLn( wxString::Format( wxT("const %s = %i;"), it->c_str(), id ) ); id++; } if( !macros.empty() ) m_source->WriteLn( wxT("") ); }
void PHPCodeGenerator::FindMacros( PObjectBase obj, std::vector<wxString>* macros ) { // iterate through all of the properties of all objects, add the macros // to the vector unsigned int i; for ( i = 0; i < obj->GetPropertyCount(); i++ ) { PProperty prop = obj->GetProperty( i ); if ( prop->GetType() == PT_MACRO ) { wxString value = prop->GetValue(); if( value.IsEmpty() ) continue; // Skip wx IDs if ( ( ! value.Contains( wxT("XRCID" ) ) ) && ( m_predMacros.end() == m_predMacros.find( value ) ) ) { if ( macros->end() == std::find( macros->begin(), macros->end(), value ) ) { macros->push_back( value ); } } } } for ( i = 0; i < obj->GetChildCount(); i++ ) { FindMacros( obj->GetChild( i ), macros ); } }
void CppCodeGenerator::FindMacros(PObjectBase obj, set<string> ¯o_set) { // recorre cada propiedad de cada objeto identificando aquellas // que sean macros, en cuyo caso la añade al conjunto. unsigned int i; for (i=0; i<obj->GetPropertyCount(); i++) { PProperty prop = obj->GetProperty(i); if (prop->GetType() == PT_MACRO) macro_set.insert(prop->GetValue()); } for (i=0; i<obj->GetChildCount(); i++) { FindMacros(obj->GetChild(i),macro_set); } }