📄 docripper.cpp
字号:
sName += subSectionName;
ScriptSection* pSect = mpCurClassSect->GetSubsection( sName.c_str() );
if ( CheckIfUncommented( ctx, *pSect ) )
{
delete pSection;
return;
}
pSect->AddReference( pSection );
mpCurClassSect->AddSection( pSection );
}
void RipperDocGen::LinkSuperClassRefs()
{
MMemberListT clLst;
// collect all classes in the context tree
mpFileBinderCtx->GetContextList( clLst, SP_CTX_CLASS );
for( size_t i = 0; i != clLst.size(); ++i )
{
spClass& cl = *((spClass*)clLst[i]);
// FIXME:: why sometimes GetUserData() returns NULL?
if ( !cl.GetUserData() )
continue;
ScriptSection* pClSect = (ScriptSection*)cl.GetUserData();
ScriptSection* pSuperSect = pClSect->GetSubsection("Derived from");
for( size_t n = 0; n != cl.m_SuperClassNames.size(); ++n )
{
wxString& superClName = cl.m_SuperClassNames[n];
spClass* pFound = NULL;
for( size_t k = 0; k != clLst.size(); ++k )
{
if ( clLst[k]->GetName() == superClName )
{
pFound = (spClass*)clLst[k];
break;
}
}
if ( !pFound )
{
ScriptSection* pNotFound =
new ScriptSection( superClName, wxEmptyString, 0, &mDeadRefTempl );
pSuperSect->AddReference( pNotFound );
}
else
if ( pFound->GetUserData() )
pSuperSect->AddReference(
(ScriptSection*)pFound->GetUserData() );
}
}
}
void RipperDocGen::ProcessFile( const char* sourceFile )
{
wxSTD cout << "Processing file " << sourceFile << "..." << wxSTD endl;
spFile* pCtx = mpParser->ParseFile( sourceFile );
if ( pCtx == NULL )
{
wxSTD cout << "Cannot open file " << sourceFile << ", skipped..." << wxSTD endl;
return;
}
VisitAll( *pCtx, true );
mpFileBinderCtx->AddMember( pCtx );
}
// implementations of "visiting procedures"
void RipperDocGen::VisitEnumeration( spEnumeration& en )
{
// FOR NOW:: do not reference "nameless" enums
if ( en.GetName().empty() ) return;
if ( CheckIfUncommented( en, *mpEnumIdx ) )
return;
wxString body;
body += m_Tags[TAG_BOLD].start;
AppendMulitilineStr( body, en.m_EnumContent );
body += m_Tags[TAG_BOLD].end;
wxString line;
AppendHighlightedSource( line, body );
AppendComments( en, line );
mpEnumIdx->AddSection(
new ScriptSection( en.GetName(), line,
&mSubContentTempl,
GetRefTemplFor( en ) ), 1
);
}
void RipperDocGen::VisitTypeDef( spTypeDef& td )
{
if ( CheckIfUncommented( td, *mpTypeDefIdx ) )
return;
wxString body;
body += m_Tags[TAG_BOLD].start;
body += "typdef ";
body += m_Tags[TAG_BOLD].end;
AppendMulitilineStr( body, td.m_OriginalType );
body += td.m_OriginalType;
body += ' ';
body += m_Tags[TAG_BOLD].start;
body += td.GetName();
body += m_Tags[TAG_BOLD].end;
wxString line;
AppendHighlightedSource( line, body );
AppendComments( td, line );
mpTypeDefIdx->AddSection(
new ScriptSection( td.GetName(), line,
&mSubContentTempl,
GetRefTemplFor( td ) ), true
);
}
void RipperDocGen::VisitPreprocessorLine( spPreprocessorLine& pd )
{
if ( pd.mDefType != SP_PREP_DEF_REDEFINE_SYMBOL )
return;
if ( CheckIfUncommented( pd, *mpMacroIdx ) )
return;
wxString body;
body += m_Tags[TAG_FIXED_FONT].start;
wxString coloredLine = pd.m_Line;
AppendHighlightedSource( coloredLine, pd.m_Line );
AppendMulitilineStr( body, coloredLine );
body += m_Tags[TAG_FIXED_FONT].end;
AppendComments( pd, body );
mpMacroIdx->AddSection(
new ScriptSection( pd.GetName(), body,
&mSubContentTempl,
GetRefTemplFor( pd ) ), true
);
}
void RipperDocGen::VisitClass( spClass& cl )
{
// FOR NOW:: do not document nested classes -
// nicier visiting method yet needed
if ( cl.IsInClass() )
{
SkipChildren(); // spVisitor's method
return;
}
wxString body;
AppendComments( cl, body );
mpCurClassSect =
new ScriptSection( cl.GetName(), body, &mSuperContentTempl, &mRefTempl );
// set up reference in the class context, pointing back
// to the section where this class is represented
cl.SetUserData( mpCurClassSect );
ScriptSection* pSuper = new ScriptSection( "Derived from" ,wxEmptyString, &mOutLine1Templ,0, 1 );
ScriptSection* pPublic = new ScriptSection( "Public members" ,wxEmptyString, &mOutLineTempl,0, 1 );
ScriptSection* pProtected = new ScriptSection( "Protected members" ,wxEmptyString, &mOutLineTempl,0, 1 );
ScriptSection* pPrivate = new ScriptSection( "Private members" ,wxEmptyString, &mOutLineTempl,0, 1 );
pPublic->AddSection( new ScriptSection( "Operations", wxEmptyString, &mOutLine1Templ, 0, 1 ) );
pPublic->AddSection( new ScriptSection( "Attributes", wxEmptyString, &mOutLine1Templ, 0, 1 ) );
pProtected->AddSection( new ScriptSection( "Operations", wxEmptyString, &mOutLine1Templ, 0, 1 ) );
pProtected->AddSection( new ScriptSection( "Attributes", wxEmptyString, &mOutLine1Templ, 0, 1 ) );
pPrivate->AddSection( new ScriptSection( "Operations", wxEmptyString, &mOutLine1Templ, 0, 1 ) );
pPrivate->AddSection( new ScriptSection( "Attributes", wxEmptyString, &mOutLine1Templ, 0, 1 ) );
mpCurClassSect->AddSection( pSuper );
mpCurClassSect->AddSection( pPublic );
mpCurClassSect->AddSection( pProtected );
mpCurClassSect->AddSection( pPrivate );
mpClassIdx->AddSection( mpCurClassSect, true );
}
void RipperDocGen::VisitAttribute( spAttribute& attr )
{
wxString body;
body += m_Tags[TAG_BOLD].start;
body += attr.m_Type;
body += m_Tags[TAG_BOLD].end;
body += m_Tags[TAG_ITALIC].start;
body += ' ';
body += attr.GetName();
body += m_Tags[TAG_ITALIC].end;
wxString line;
AppendHighlightedSource( line, body );
AppendComments( attr, line );
ScriptSection* pSection =
new ScriptSection( GetScopedName( attr ), line,
&mSubContentTempl,
GetRefTemplFor( attr ) );
if ( attr.mIsConstant )
mpConstIdx->AddSection( pSection, true );
else
if ( !attr.IsInClass() )
{
if ( CheckIfUncommented( attr, *mpGlobalVarsIdx ) )
return;
mpGlobalVarsIdx->AddSection( pSection, true );
}
else
AddToCurrentClass( pSection, attr, "Attributes" );
}
void RipperDocGen::VisitOperation( spOperation& op )
{
wxString body;
AppendHighlightedSource( body, op.GetFullName(m_Tags) );
AppendComments( op, body );
ScriptSection* pSection =
new ScriptSection( GetScopedName( op ), body,
&mSubContentTempl,
GetRefTemplFor( op ) );
if ( !op.IsInClass() )
{
if ( CheckIfUncommented( op, *mpGlobalFuncIdx ) )
return;
mpGlobalFuncIdx->AddSection( pSection, 1 );
}
else
AddToCurrentClass( pSection, op, "Operations" );
}
bool RipperDocGen::OnSaveDocument( ScriptStream& WXUNUSED(stm) )
{
LinkSuperClassRefs();
// FOR NOW:: doesn't work yet
//mpTopIdx->RemoveEmptySections();
return 1; // saving can proceed now
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -