3 #include "core/idlast/namespace.h"
9 using namespace awful::awic
;
12 void awful::awic::GenerateAttrTraits( std::ostream
& Out_
,
13 const idlast::Class
* pClass_
,
14 const idlast::Attribute
* pAttr_
,
17 string
FullClassName( pClass_
->getName() );
18 const idlast::Namespace
* pCurrentNS
= pClass_
->getNamespace();
19 while( pCurrentNS
->getParent() )
21 FullClassName
= pCurrentNS
->getName() + "::" + FullClassName
;
22 pCurrentNS
= pCurrentNS
->getParent();
26 std::stringstream tagstring
;
27 tagstring
<< "class_traits< " << FullClassName
<< " >::attribute_tags::" << pAttr_
->getName();
28 OutputFlags( Out_
, pAttr_
->getFlags(), tagstring
.str() );
30 std::stringstream typestring
;
31 PrintType( typestring
, pAttr_
->getType() );
34 digest
.write( pAttr_
->getName().c_str(), pAttr_
->getName().size() );
36 digest
.write( typestring
.str().c_str(), typestring
.str().size() );
38 Out_
<< "\ttemplate< class C > struct attribute_traits< C,\n"
39 "\t\t" << tagstring
.str() << " >\n"
41 "\t\ttypedef " << typestring
.str() <<
45 PrintTypeCategory( Out_
, pAttr_
->getType() );
47 Out_
<< " category;\n";
49 bool bGenerateGetSet
= pAttr_
->testFlag( "Scriptable", true );
50 bool bMutable
= pAttr_
->testFlag( "Mutable", true );
51 bool bReadOnly
= pAttr_
->testFlag( "ReadOnly", false );
56 Out_
<< "\t\ttypedef type& ( C::* accessor_type )();\n"
57 "\t\ttypedef const type& ( C::* getter_type )() const;\n\n";
59 else if( bGenerateGetSet
)
61 Out_
<< "\t\ttypedef const type& ( C::* getter_type )() const;\n";
66 Out_
<< "\t\ttypedef type& ( C::* getter_mutable_type )();\n";
67 Out_
<< "\t\ttypedef void ( C::* setter_type )( const type& );\n\n";
72 Out_
<< "\t\tstatic uint32_t Digest() { return 0x" << std::hex
<< digest
.result() << "; }\n"
73 "\t\tstatic const char* Name() { return \"" << pAttr_
->getName() << "\"; }\n\n";
77 Out_
<< "\t\tstatic type C::* MemberPointer() { return &C::m_" << pAttr_
->getName() << "; }\n";
81 Out_
<< "\t\tstatic getter_type Getter() { return &C::get" << pAttr_
->getName() << "; }\n";
86 Out_
<< "\t\tstatic getter_mutable_type GetterMutable() { return &C::get" << pAttr_
->getName() << "; }\n";
87 Out_
<< "\t\tstatic setter_type Setter() { return &C::set" << pAttr_
->getName() << "; }\n";
93 Out_
<< "\t\tstatic accessor_type Accessor() { return &C::" << pAttr_
->getName() << "; }\n"
94 "\t\tstatic getter_type Getter() { return &C::" << pAttr_
->getName() << "; }\n";