void CppCodeGenerator::GenSettings(PObjectInfo info, PObjectBase obj) { string _template; PCodeInfo code_info = info->GetCodeInfo("C++"); if (!code_info) return; _template = code_info->GetTemplate("settings"); if (_template != "") { CppTemplateParser parser(obj,_template); string code = parser.ParseTemplate(); if (code != "") m_source->WriteLn(code); } // procedemos recursivamente con las clases base for (unsigned int i=0; i< info->GetBaseClassCount(); i++) { PObjectInfo base_info = info->GetBaseClass(i); GenSettings(base_info,obj); } }
void PHPCodeGenerator::GenBaseIncludes( PObjectInfo info, PObjectBase obj, std::vector< wxString >* includes, std::set< wxString >* templates ) { if ( !info ) { return; } // Process all the base classes recursively for ( unsigned int i = 0; i < info->GetBaseClassCount(); i++ ) { PObjectInfo base_info = info->GetBaseClass( i ); GenBaseIncludes( base_info, obj, includes, templates ); } PCodeInfo code_info = info->GetCodeInfo( wxT("PHP") ); if ( code_info ) { PHPTemplateParser parser( obj, code_info->GetTemplate( wxT("include") ), m_i18n, m_useRelativePath, m_basePath ); wxString include = parser.ParseTemplate(); if ( !include.empty() ) { if ( templates->insert( include ).second ) { AddUniqueIncludes( include, includes ); } } } }
void PHPCodeGenerator::GenDefinedEventHandlers( PObjectInfo info, PObjectBase obj ) { PCodeInfo code_info = info->GetCodeInfo( wxT( "PHP" ) ); if ( code_info ) { wxString _template = code_info->GetTemplate( wxT("generated_event_handlers") ); if ( !_template.empty() ) { PHPTemplateParser parser( obj, _template, m_i18n, m_useRelativePath, m_basePath ); wxString code = parser.ParseTemplate(); if ( !code.empty() ) { m_source->WriteLn(code); } } } // Proceeding recursively with the base classes for ( unsigned int i = 0; i < info->GetBaseClassCount(); i++ ) { PObjectInfo base_info = info->GetBaseClass( i ); GenDefinedEventHandlers( base_info, obj ); } }
void PHPCodeGenerator::GetAddToolbarCode( PObjectInfo info, PObjectBase obj, wxArrayString& codelines ) { wxString _template; PCodeInfo code_info = info->GetCodeInfo( wxT( "PHP" ) ); if ( !code_info ) return; _template = code_info->GetTemplate( wxT( "toolbar_add" ) ); if ( !_template.empty() ) { PHPTemplateParser parser( obj, _template, m_i18n, m_useRelativePath, m_basePath ); wxString code = parser.ParseTemplate(); if ( !code.empty() ) { if( codelines.Index( code ) == wxNOT_FOUND ) codelines.Add( code ); } } // Proceeding recursively with the base classes for ( unsigned int i = 0; i < info->GetBaseClassCount(); i++ ) { PObjectInfo base_info = info->GetBaseClass( i ); GetAddToolbarCode( base_info, obj, codelines ); } }
bool PHPCodeGenerator::GenEventEntry( PObjectBase obj, PObjectInfo obj_info, const wxString& templateName, const wxString& handlerName, bool disconnect ) { wxString _template; PCodeInfo code_info = obj_info->GetCodeInfo( wxT("PHP") ); if ( code_info ) { _template = code_info->GetTemplate( wxString::Format( wxT("evt_%s%s"), disconnect ? wxT("dis") : wxT(""), templateName.c_str() ) ); if ( disconnect && _template.empty() ) { _template = code_info->GetTemplate( wxT("evt_") + templateName ); _template.Replace( wxT("Connect"), wxT("Disconnect"), true ); } if ( !_template.empty() ) { if( disconnect ) { if( m_disconnecMode == wxT("handler_name")) _template.Replace( wxT("#handler"), wxT("handler = array(@$this, \"") + handlerName + wxT("\")") ); else if(m_disconnecMode == wxT("source_name")) _template.Replace( wxT("#handler"), wxT("null") ); //wxT("$this->") + obj->GetProperty(wxT("name"))->GetValueAsString() ); } else _template.Replace( wxT("#handler"), wxT("array(@$this, \"") + handlerName + wxT("\")") ); PHPTemplateParser parser( obj, _template, m_i18n, m_useRelativePath, m_basePath ); m_source->WriteLn( parser.ParseTemplate() ); return true; } } for ( unsigned int i = 0; i < obj_info->GetBaseClassCount(); i++ ) { PObjectInfo base_info = obj_info->GetBaseClass( i ); if ( GenEventEntry( obj, base_info, templateName, handlerName, disconnect ) ) { return true; } } return false; }