2 #include "core/idlast/namespace.h"
5 using namespace awful::idlast
;
7 Pointer
< Namespace
> Namespace::addNamespace( Namespace
* pNamespace_
)
9 Pointer
< Namespace
> pNS
= m_Namespaces
.get( pNamespace_
->getName() );
13 if( !m_Namespaces
.add( pNamespace_
) )
16 pNamespace_
->m_pParent
= this;
20 Pointer
< Namespace
> Namespace::findNamespace( std::string Name_
) const
22 Pointer
< Namespace
> pNS
= m_Namespaces
.get( Name_
);
29 return m_pParent
->findNamespace( Name_
);
32 Pointer
< Class
> Namespace::findClass( std::string Name_
, bool bStruct_
) const
34 Pointer
< Class
> pClass
;
37 pClass
= m_Structs
.get( Name_
);
39 pClass
= m_Classes
.get( Name_
);
47 return m_pParent
->findClass( Name_
, bStruct_
);
50 void Namespace::resolveRefs() const
52 std::stack
< const Namespace
* > WorkStack
;
54 WorkStack
.push( this );
55 while( !WorkStack
.empty() )
57 const Namespace
* pCurrentNamespace
= WorkStack
.top();
60 // Push child namespaces on the stack
61 const Dictionary
< Namespace
>& Namespaces
= pCurrentNamespace
->getNamespaces();
62 Dictionary
< Namespace
>::const_iterator nsit
;
63 for( nsit
= Namespaces
.begin(); nsit
!= Namespaces
.end(); ++nsit
)
64 WorkStack
.push( nsit
->second
);
67 const Dictionary
< Class
>& Classes
= pCurrentNamespace
->getClasses();
68 Dictionary
< Class
>::const_iterator clit
;
69 for( clit
= Classes
.begin(); clit
!= Classes
.end(); ++clit
)
70 clit
->second
->resolveRefs( false );
73 const Dictionary
< Class
>& Structs
= pCurrentNamespace
->getStructs();
74 Dictionary
< Class
>::const_iterator stit
;
75 for( stit
= Structs
.begin(); stit
!= Structs
.end(); ++stit
)
76 stit
->second
->resolveRefs( true );
79 // Iterate through classes again to resolve the polymorphism flag
80 WorkStack
.push( this );
81 while( !WorkStack
.empty() )
83 const Namespace
* pCurrentNamespace
= WorkStack
.top();
86 // Push child namespaces on the stack
87 const Dictionary
< Namespace
>& Namespaces
= pCurrentNamespace
->getNamespaces();
88 Dictionary
< Namespace
>::const_iterator nsit
;
89 for( nsit
= Namespaces
.begin(); nsit
!= Namespaces
.end(); ++nsit
)
90 WorkStack
.push( nsit
->second
);
93 const Dictionary
< Class
>& Classes
= pCurrentNamespace
->getClasses();
94 Dictionary
< Class
>::const_iterator clit
;
95 for( clit
= Classes
.begin(); clit
!= Classes
.end(); ++clit
)
96 clit
->second
->resolvePolymorphism();