bool TemplateParser::ParseProperty() { wxString childName; wxString propname = ParsePropertyName( &childName ); PProperty property = m_obj->GetProperty(propname); if ( NULL == property.get() ) { wxLogError( wxT("The property '%s' does not exist for objects of class '%s'"), propname.c_str(), m_obj->GetClassName().c_str() ); return true; } if ( childName.empty() ) { wxString code = PropertyToCode(property); m_out << code; } else { m_out << property->GetChildFromParent( childName ); } // LogDebug("parsing property %s",propname.c_str()); return true; }
wxString ObjectBase::GetChildFromParentProperty( const wxString& parentName, const wxString& childName ) { PProperty property = GetProperty( parentName ); if (property) return property->GetChildFromParent( childName ); else return wxEmptyString; }
void PHPCodeGenerator::GenEvents( PObjectBase class_obj, const EventVector &events, bool disconnect ) { if ( events.empty() ) { return; } if( disconnect ) { m_source->WriteLn( wxT("// Disconnect Events") ); } else { m_source->WriteLn(); m_source->WriteLn( wxT("// Connect Events") ); } PProperty propName = class_obj->GetProperty( wxT("name") ); if ( !propName ) { wxLogError(wxT("Missing \"name\" property on \"%s\" class. Review your XML object description"), class_obj->GetClassName().c_str()); return; } wxString class_name = propName->GetValue(); if ( class_name.empty() ) { wxLogError( wxT("Object name cannot be null") ); return; } wxString base_class; wxString handlerName; PProperty propSubclass = class_obj->GetProperty( wxT("subclass") ); if ( propSubclass ) { wxString subclass = propSubclass->GetChildFromParent( wxT("name") ); if ( !subclass.empty() ) { base_class = subclass; } } if ( base_class.empty() ) base_class = wxT("wx") + class_obj->GetClassName(); if ( events.size() > 0 ) { for ( size_t i = 0; i < events.size(); i++ ) { PEvent event = events[i]; handlerName = event->GetValue(); wxString templateName = wxString::Format( wxT("connect_%s"), event->GetName().c_str() ); PObjectBase obj = event->GetObject(); if ( !GenEventEntry( obj, obj->GetObjectInfo(), templateName, handlerName, disconnect ) ) { wxLogError( wxT("Missing \"evt_%s\" template for \"%s\" class. Review your XML object description"), templateName.c_str(), class_name.c_str() ); } } } }