From bdcfbb4e3a404a0646396bc8bbd081bbe37a197f Mon Sep 17 00:00:00 2001 From: Derek Bankieris Date: Mon, 31 Oct 2016 09:10:33 -0500 Subject: [PATCH] Restore debug functions #341 --- .../Interface_Code_Gen/ClassValues.cpp | 27 +++++++++++++ .../codegen/Interface_Code_Gen/ClassValues.hh | 2 + .../Interface_Code_Gen/ConstructValues.cpp | 2 + .../codegen/Interface_Code_Gen/EnumValues.cpp | 21 ++++++++++ .../codegen/Interface_Code_Gen/EnumValues.hh | 2 + .../Interface_Code_Gen/FieldDescription.cpp | 39 +++++++++++++++++++ .../Interface_Code_Gen/FieldDescription.hh | 2 + .../Interface_Code_Gen/FieldVisitor.cpp | 2 +- 8 files changed, 96 insertions(+), 1 deletion(-) diff --git a/trick_source/codegen/Interface_Code_Gen/ClassValues.cpp b/trick_source/codegen/Interface_Code_Gen/ClassValues.cpp index 3a59bd94..dd6316a9 100644 --- a/trick_source/codegen/Interface_Code_Gen/ClassValues.cpp +++ b/trick_source/codegen/Interface_Code_Gen/ClassValues.cpp @@ -274,3 +274,30 @@ bool ClassValues::isCompat15() { bool ClassValues::isInStandardNamespace() { return namespaces.size() && !namespaces[0].compare("std"); } + +std::ostream & operator << (std::ostream & ostream, ClassValues & cv) { + ostream << " name = " << cv.name << std::endl ; + ostream << " mangled_name = " << cv.mangled_type_name << std::endl ; + ostream << " file_name = " << cv.file_name << std::endl ; + ostream << " namespaces =" ; + for (auto& name : cv.getNamespaces()) { + ostream << " " << name ; + } + ostream << std::endl ; + ostream << " parent classes =" ; + for (auto& clazz : cv.getContainerClasses()) { + ostream << " " << clazz ; + } + ostream << std::endl ; + ostream << " has_init_attr_friend = " << cv.has_init_attr_friend << std::endl ; + ostream << " is_pod = " << cv.is_pod << std::endl ; + ostream << " is_abstract = " << cv.is_abstract << std::endl ; + ostream << " has_default_constructor = " << cv.has_default_constructor << std::endl ; + ostream << " has_public_destructor = " << cv.has_public_destructor << std::endl ; + + for (auto& field : cv.getFieldDescriptions()) { + ostream << field << std::endl ; + } + + return ostream ; +} diff --git a/trick_source/codegen/Interface_Code_Gen/ClassValues.hh b/trick_source/codegen/Interface_Code_Gen/ClassValues.hh index fe8b6d10..df113dde 100644 --- a/trick_source/codegen/Interface_Code_Gen/ClassValues.hh +++ b/trick_source/codegen/Interface_Code_Gen/ClassValues.hh @@ -82,6 +82,8 @@ class ClassValues : public ConstructValues { bool isCompat15() ; bool isInStandardNamespace(); + friend std::ostream & operator << (std::ostream & os , ClassValues & cv ) ; + private: std::vector< FieldDescription * > field_descripts ; diff --git a/trick_source/codegen/Interface_Code_Gen/ConstructValues.cpp b/trick_source/codegen/Interface_Code_Gen/ConstructValues.cpp index 2d87a69f..886b427b 100644 --- a/trick_source/codegen/Interface_Code_Gen/ConstructValues.cpp +++ b/trick_source/codegen/Interface_Code_Gen/ConstructValues.cpp @@ -40,6 +40,7 @@ void ConstructValues::getNamespacesAndClasses( const clang::DeclContext * Ctx ) for (ContextsTy::reverse_iterator I = Contexts.rbegin(), E = Contexts.rend(); I != E; ++I) { if (const clang::NamespaceDecl *nd = clang::dyn_cast(*I)) { if (! nd->isAnonymousNamespace()) { + //std::cout << "namespace " << nd->getIdentifier()->getName().str() << std::endl ; std::string temp_name = nd->getIdentifier()->getName().str() ; if ( temp_name.compare("std") and temp_name.compare("__1")) { addNamespace(nd->getIdentifier()->getName().str()) ; @@ -47,6 +48,7 @@ void ConstructValues::getNamespacesAndClasses( const clang::DeclContext * Ctx ) } } else if (const clang::RecordDecl *rd = clang::dyn_cast(*I)) { if (rd->getIdentifier()) { + //std::cout << "in class " << rd->getName().str() << std::endl ; if (const clang::ClassTemplateSpecializationDecl *td = clang::dyn_cast(*I)) { std::string text; llvm::raw_string_ostream stream(text); diff --git a/trick_source/codegen/Interface_Code_Gen/EnumValues.cpp b/trick_source/codegen/Interface_Code_Gen/EnumValues.cpp index 4d4d6841..36e5f4dc 100644 --- a/trick_source/codegen/Interface_Code_Gen/EnumValues.cpp +++ b/trick_source/codegen/Interface_Code_Gen/EnumValues.cpp @@ -17,3 +17,24 @@ void EnumValues::setHasDefinition( bool in ) { bool EnumValues::getHasDefinition() { return has_definition ; } + +std::ostream & operator << (std::ostream & ostream , EnumValues & ev ) { + ostream << " name = " << ev.name << std::endl ; + ostream << " file_name = " << ev.file_name << std::endl ; + ostream << " namespaces =" ; + for (auto& name : ev.getNamespaces()) { + ostream << " " << name ; + } + ostream << std::endl ; + ostream << " parent classes =" ; + for (auto& clazz : ev.getContainerClasses()) { + ostream << " " << clazz ; + } + ostream << std::endl ; + + for (auto& pair : ev.getPairs()) { + ostream << " " << pair.first << " " << pair.second << std::endl ; + } + + return ostream ; +} diff --git a/trick_source/codegen/Interface_Code_Gen/EnumValues.hh b/trick_source/codegen/Interface_Code_Gen/EnumValues.hh index e1d5a7b6..2a1e4662 100644 --- a/trick_source/codegen/Interface_Code_Gen/EnumValues.hh +++ b/trick_source/codegen/Interface_Code_Gen/EnumValues.hh @@ -39,6 +39,8 @@ class EnumValues : public ConstructValues { return enum_values; } + friend std::ostream & operator << (std::ostream & os , EnumValues & ev ) ; + private: /** List of enums and their values */ diff --git a/trick_source/codegen/Interface_Code_Gen/FieldDescription.cpp b/trick_source/codegen/Interface_Code_Gen/FieldDescription.cpp index 30fe42a6..47ba3467 100644 --- a/trick_source/codegen/Interface_Code_Gen/FieldDescription.cpp +++ b/trick_source/codegen/Interface_Code_Gen/FieldDescription.cpp @@ -524,3 +524,42 @@ int FieldDescription::getArrayDim(unsigned int dim_num) { void FieldDescription::addArrayDim( int in_dim ) { array_sizes[num_dims++] = in_dim ; } + +std::ostream & operator << (std::ostream & ostream , FieldDescription & fieldDescription ) { + ostream << " name = " << fieldDescription.name << std::endl ; + ostream << " file_name = " << fieldDescription.file_name << std::endl ; + ostream << " namespaces =" ; + for (auto& name : fieldDescription.getNamespaces()) { + ostream << " " << fieldDescription ; + } + ostream << std::endl ; + ostream << " parent classes =" ; + for (auto& clazz : fieldDescription.getContainerClasses()) { + ostream << " " << clazz ; + } + ostream << std::endl ; + ostream << " line_no = " << fieldDescription.line_no << std::endl ; + ostream << " container_class = " << fieldDescription.container_class << std::endl ; + ostream << " type_name = " << fieldDescription.type_name << std::endl ; + ostream << " mangled_type_name = " << fieldDescription.mangled_type_name << std::endl ; + ostream << " type_enum_string = " << fieldDescription.type_enum_string << std::endl ; + ostream << " units = " << fieldDescription.units << std::endl ; + ostream << " io = " << fieldDescription.io << std::endl ; + ostream << " description = " << fieldDescription.description << std::endl ; + ostream << " access = " << fieldDescription.access << std::endl ; + ostream << " is_bitfield = " << fieldDescription.is_bitfield << std::endl ; + ostream << " bitfield_width = " << fieldDescription.bitfield_width << std::endl ; + ostream << " bitfield_start_bit = " << fieldDescription.bitfield_start_bit << std::endl ; + ostream << " bitfield_word_offset = " << fieldDescription.bitfield_word_offset << std::endl ; + ostream << " num_dims = " << fieldDescription.num_dims << std::endl ; + ostream << " array_sizes =" ; + for( unsigned int ii = 0 ; ii < 8 ; ii++ ) { + ostream << " " << fieldDescription.array_sizes[ii] ; + } + ostream << std::endl ; + ostream << " is_enum = " << fieldDescription.is_enum << std::endl ; + ostream << " is_record = " << fieldDescription.is_record << std::endl ; + ostream << " is_static = " << fieldDescription.is_static << std::endl ; + + return ostream ; +} diff --git a/trick_source/codegen/Interface_Code_Gen/FieldDescription.hh b/trick_source/codegen/Interface_Code_Gen/FieldDescription.hh index 2c5ac447..811398ea 100644 --- a/trick_source/codegen/Interface_Code_Gen/FieldDescription.hh +++ b/trick_source/codegen/Interface_Code_Gen/FieldDescription.hh @@ -93,6 +93,8 @@ class FieldDescription : public ConstructValues { /** Adds an array dimension to the field */ void addArrayDim( int in_dim ) ; + friend std::ostream & operator << (std::ostream & os , FieldDescription & cv ) ; + private: /** Line number in current file where field is */ diff --git a/trick_source/codegen/Interface_Code_Gen/FieldVisitor.cpp b/trick_source/codegen/Interface_Code_Gen/FieldVisitor.cpp index 1faf3567..7ec914fc 100644 --- a/trick_source/codegen/Interface_Code_Gen/FieldVisitor.cpp +++ b/trick_source/codegen/Interface_Code_Gen/FieldVisitor.cpp @@ -296,7 +296,7 @@ bool FieldVisitor::ProcessTemplate(std::string in_name , clang::CXXRecordDecl * if ( debug_level >= 4 ) { std::cout << "Added template class from FieldVisitor ProcessTemplate " ; std::cout << in_name << std::endl ; - //std::cout << *fdes << std::endl ; + std::cout << *fdes << std::endl ; } }