]>
Commit | Line | Data |
---|---|---|
cecfc5e7 VZ |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: No names yet. | |
3 | // Purpose: Contrib. demo | |
4 | // Author: Aleksandras Gluchovas | |
5 | // Modified by: | |
6 | // Created: 22/09/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Aleskandars Gluchovas | |
8bc17f14 | 9 | // Licence: wxWindows licence |
cecfc5e7 VZ |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
cecfc5e7 VZ |
12 | // For compilers that support precompilation, includes "wx/wx.h". |
13 | #include "wx/wxprec.h" | |
14 | ||
15 | #ifdef __BORLANDC__ | |
16 | #pragma hdrstop | |
17 | #endif | |
18 | ||
19 | #ifndef WX_PRECOMP | |
20 | #include "wx/wx.h" | |
21 | #endif | |
22 | ||
d5939a20 | 23 | #ifndef __DARWIN__ |
ad053960 GD |
24 | # include <malloc.h> |
25 | #endif | |
cecfc5e7 VZ |
26 | #include <stdio.h> |
27 | ||
28 | #include "srcparser.h" | |
29 | ||
30 | /***** Implementation for class spVisitor *****/ | |
31 | ||
32 | void spVisitor::VisitAll( spContext& atContext, | |
d12e3536 VZ |
33 | bool sortContent |
34 | ) | |
cecfc5e7 | 35 | { |
eda6fa91 WS |
36 | mSiblingSkipped = false; |
37 | mChildSkipped = false; | |
d12e3536 | 38 | mContextMask = SP_CTX_ANY; // FIXME:: should be an arg. |
cecfc5e7 | 39 | |
d12e3536 | 40 | if ( sortContent && !atContext.IsSorted() ) |
cecfc5e7 | 41 | |
d12e3536 | 42 | atContext.SortMembers(); |
cecfc5e7 | 43 | |
d12e3536 | 44 | mpCurCxt = &atContext; // FIXME:: this is dirty, restoring it each time |
cecfc5e7 | 45 | |
d12e3536 | 46 | if ( atContext.GetContextType() & mContextMask ) |
cecfc5e7 | 47 | |
d12e3536 | 48 | atContext.AcceptVisitor( *this ); |
cecfc5e7 | 49 | |
d12e3536 | 50 | MMemberListT& members = atContext.GetMembers(); |
cecfc5e7 | 51 | |
d12e3536 VZ |
52 | for( size_t i = 0; i != members.size(); ++i ) |
53 | { | |
54 | if ( mSiblingSkipped ) | |
eda6fa91 | 55 | |
d12e3536 | 56 | return; |
cecfc5e7 | 57 | |
d12e3536 VZ |
58 | if ( !mChildSkipped ) |
59 | { | |
60 | size_t prevSz = members.size(); | |
cecfc5e7 | 61 | |
d12e3536 VZ |
62 | // visit members of the context recursivelly |
63 | VisitAll( *members[i], sortContent ); | |
cecfc5e7 | 64 | |
d12e3536 | 65 | if ( members.size() != prevSz ) |
cecfc5e7 | 66 | |
d12e3536 | 67 | --i; // current member was removed! |
cecfc5e7 | 68 | |
d12e3536 VZ |
69 | mChildSkipped = 0; |
70 | } | |
71 | } | |
cecfc5e7 VZ |
72 | } |
73 | ||
74 | void spVisitor::RemoveCurrentContext() | |
75 | { | |
d12e3536 | 76 | if ( mpCurCxt->GetParent() ) |
cecfc5e7 | 77 | |
d12e3536 | 78 | mpCurCxt->GetParent()->RemoveChild( mpCurCxt ); |
cecfc5e7 VZ |
79 | } |
80 | ||
81 | void spVisitor::SkipSiblings() | |
82 | { | |
eda6fa91 | 83 | mSiblingSkipped = true; |
cecfc5e7 VZ |
84 | } |
85 | ||
86 | void spVisitor::SkipChildren() | |
87 | { | |
eda6fa91 | 88 | mChildSkipped = true; |
cecfc5e7 VZ |
89 | } |
90 | ||
91 | void spVisitor::SetFilter( int contextMask ) | |
92 | { | |
d12e3536 | 93 | mContextMask = contextMask; |
cecfc5e7 VZ |
94 | } |
95 | ||
96 | /***** Implementation for class spComment *****/ | |
97 | ||
98 | bool spComment::IsMultiline() const | |
99 | { | |
d12e3536 | 100 | return mIsMultiline; |
cecfc5e7 VZ |
101 | } |
102 | ||
103 | bool spComment::StartsParagraph() const | |
104 | { | |
d12e3536 | 105 | return mStartsPar; |
cecfc5e7 VZ |
106 | } |
107 | ||
e49cde67 | 108 | wxString& spComment::GetText() |
cecfc5e7 | 109 | { |
e49cde67 | 110 | return m_Text; |
cecfc5e7 VZ |
111 | } |
112 | ||
e49cde67 | 113 | wxString spComment::GetText() const |
cecfc5e7 | 114 | { |
e49cde67 | 115 | return m_Text; |
cecfc5e7 VZ |
116 | } |
117 | ||
118 | /***** Implementation for class spContext *****/ | |
119 | ||
120 | spContext::spContext() | |
121 | ||
2af95167 | 122 | : m_pParent ( NULL ), |
d12e3536 | 123 | mpFirstOccurence( NULL ), |
eda6fa91 | 124 | mAlreadySorted ( false ), |
cecfc5e7 | 125 | |
d12e3536 VZ |
126 | mSrcLineNo (-1), |
127 | mSrcOffset (-1), | |
128 | mContextLength(-1), | |
129 | mLastScrLineNo(-1), | |
cecfc5e7 | 130 | |
d12e3536 VZ |
131 | mHeaderLength (-1), |
132 | mFooterLength (-1), | |
cecfc5e7 | 133 | |
d12e3536 VZ |
134 | mFirstCharPos (-1), |
135 | mLastCharPos (-1), | |
cecfc5e7 | 136 | |
d12e3536 | 137 | mVisibility( SP_VIS_PRIVATE ), |
cecfc5e7 | 138 | |
eda6fa91 WS |
139 | mIsVirtualContext ( false ), |
140 | mVirtualContextHasChildren( false ), | |
cecfc5e7 | 141 | |
d12e3536 | 142 | mpUserData( NULL ) |
cecfc5e7 VZ |
143 | {} |
144 | ||
145 | void spContext::RemoveChildren() | |
146 | { | |
d12e3536 | 147 | for( size_t i = 0; i != mMembers.size(); ++i ) |
eda6fa91 | 148 | |
d12e3536 | 149 | delete mMembers[i]; |
cecfc5e7 | 150 | |
d12e3536 | 151 | mMembers.erase( mMembers.begin(), mMembers.end() ); |
cecfc5e7 VZ |
152 | } |
153 | ||
154 | spContext::~spContext() | |
155 | { | |
d12e3536 | 156 | RemoveChildren(); |
cecfc5e7 | 157 | |
d12e3536 | 158 | for( size_t i = 0; i != mComments.size(); ++i ) |
eda6fa91 | 159 | |
d12e3536 | 160 | delete mComments[i]; |
cecfc5e7 VZ |
161 | } |
162 | ||
163 | bool spContext::IsSorted() | |
164 | { | |
d12e3536 | 165 | return mAlreadySorted; |
cecfc5e7 VZ |
166 | } |
167 | ||
168 | void spContext::GetContextList( MMemberListT& lst, int contextMask ) | |
169 | { | |
d12e3536 VZ |
170 | for( size_t i = 0; i != mMembers.size(); ++i ) |
171 | { | |
172 | spContext& member = *mMembers[i]; | |
cecfc5e7 | 173 | |
d12e3536 | 174 | if ( member.GetContextType() & contextMask ) |
cecfc5e7 | 175 | |
d12e3536 | 176 | lst.push_back( &member ); |
cecfc5e7 | 177 | |
d12e3536 VZ |
178 | // collect required contexts recursively |
179 | member.GetContextList( lst, contextMask ); | |
180 | } | |
cecfc5e7 VZ |
181 | } |
182 | ||
183 | bool spContext::HasComments() | |
184 | { | |
d12e3536 | 185 | return ( mComments.size() != 0 ); |
cecfc5e7 VZ |
186 | } |
187 | ||
188 | void spContext::RemoveChild( spContext* pChild ) | |
189 | { | |
d12e3536 | 190 | for( size_t i = 0; i != mMembers.size(); ++i ) |
cecfc5e7 | 191 | |
d12e3536 VZ |
192 | if ( mMembers[i] == pChild ) |
193 | { | |
194 | mMembers.erase( &mMembers[i] ); | |
cecfc5e7 | 195 | |
d12e3536 VZ |
196 | delete pChild; |
197 | return; | |
198 | } | |
cecfc5e7 | 199 | |
eda6fa91 | 200 | // the given child should exist on the parent's list |
d12e3536 | 201 | wxASSERT( 0 ); |
cecfc5e7 VZ |
202 | } |
203 | ||
204 | spContext* spContext::GetEnclosingContext( int mask ) | |
205 | { | |
d12e3536 | 206 | spContext* cur = this->GetParent(); |
cecfc5e7 | 207 | |
eda6fa91 WS |
208 | while ( cur && !(cur->GetContextType() & mask) ) |
209 | ||
d12e3536 | 210 | cur = cur->GetParent(); |
cecfc5e7 | 211 | |
d12e3536 | 212 | return cur; |
cecfc5e7 VZ |
213 | } |
214 | ||
215 | bool spContext::PositionIsKnown() | |
216 | { | |
d12e3536 | 217 | return ( mSrcOffset != (-1) && mContextLength != (-1) ); |
cecfc5e7 VZ |
218 | } |
219 | ||
220 | bool spContext::IsVirtualContext() | |
221 | { | |
d12e3536 | 222 | return mIsVirtualContext; |
cecfc5e7 VZ |
223 | } |
224 | ||
225 | bool spContext::VitualContextHasChildren() | |
226 | { | |
d12e3536 | 227 | return mVirtualContextHasChildren; |
cecfc5e7 VZ |
228 | } |
229 | ||
2af95167 | 230 | wxString spContext::GetVirtualContextBody() |
cecfc5e7 | 231 | { |
d12e3536 | 232 | wxASSERT( mIsVirtualContext ); |
cecfc5e7 | 233 | |
d12e3536 | 234 | return mVirtualContextBody; |
cecfc5e7 VZ |
235 | } |
236 | ||
2af95167 | 237 | wxString spContext::GetFooterOfVirtualContextBody() |
cecfc5e7 | 238 | { |
d12e3536 | 239 | wxASSERT( mIsVirtualContext ); |
cecfc5e7 | 240 | |
d12e3536 | 241 | return mVittualContextFooter; |
cecfc5e7 VZ |
242 | } |
243 | ||
244 | ||
2af95167 WS |
245 | void spContext::SetVirtualContextBody( const wxString& body, |
246 | bool hasChildren, | |
247 | const wxString& footer ) | |
cecfc5e7 | 248 | { |
d12e3536 | 249 | mVirtualContextHasChildren = hasChildren; |
cecfc5e7 | 250 | |
d12e3536 VZ |
251 | mVirtualContextBody = body; |
252 | mVittualContextFooter = footer; | |
cecfc5e7 | 253 | |
d12e3536 | 254 | // atuomaticllay becomes virtual context |
cecfc5e7 | 255 | |
eda6fa91 | 256 | mIsVirtualContext = true; |
cecfc5e7 VZ |
257 | } |
258 | ||
fa1af598 | 259 | wxString spContext::GetBody( spContext* pCtx ) |
cecfc5e7 | 260 | { |
eda6fa91 | 261 | if ( ( pCtx == NULL || pCtx == this ) && mIsVirtualContext ) |
d12e3536 | 262 | return mVirtualContextBody; |
cecfc5e7 | 263 | |
d12e3536 | 264 | if ( GetParent() ) |
d12e3536 VZ |
265 | return GetParent()->GetBody( ( pCtx != NULL ) ? pCtx : this ); |
266 | else | |
fa1af598 | 267 | return wxEmptyString; // source-fragment cannot be found |
cecfc5e7 VZ |
268 | } |
269 | ||
fa1af598 | 270 | wxString spContext::GetHeader( spContext* pCtx ) |
cecfc5e7 | 271 | { |
d12e3536 | 272 | if ( GetParent() ) |
d12e3536 VZ |
273 | return GetParent()->GetHeader( ( pCtx != NULL ) ? pCtx : this ); |
274 | else | |
fa1af598 | 275 | return wxEmptyString; // source-fragment cannot be found |
cecfc5e7 VZ |
276 | } |
277 | ||
278 | bool spContext::IsFirstOccurence() | |
279 | { | |
d12e3536 | 280 | return ( mpFirstOccurence != 0 ); |
cecfc5e7 VZ |
281 | } |
282 | ||
283 | spContext* spContext::GetFirstOccurence() | |
284 | { | |
eda6fa91 | 285 | // this object should not itself be |
d12e3536 VZ |
286 | // the first occurence of the context |
287 | wxASSERT( mpFirstOccurence != 0 ); | |
cecfc5e7 | 288 | |
d12e3536 | 289 | return mpFirstOccurence; |
cecfc5e7 VZ |
290 | } |
291 | ||
292 | void spContext::AddMember( spContext* pMember ) | |
293 | { | |
d12e3536 | 294 | mMembers.push_back( pMember ); |
cecfc5e7 | 295 | |
2af95167 | 296 | pMember->m_pParent = this; |
cecfc5e7 VZ |
297 | } |
298 | ||
299 | void spContext::AddComment( spComment* pComment ) | |
300 | { | |
d12e3536 | 301 | mComments.push_back( pComment ); |
cecfc5e7 VZ |
302 | } |
303 | ||
304 | MMemberListT& spContext::GetMembers() | |
305 | { | |
d12e3536 | 306 | return mMembers; |
cecfc5e7 VZ |
307 | } |
308 | ||
2af95167 | 309 | spContext* spContext::FindContext( const wxString& identifier, |
d12e3536 VZ |
310 | int contextType, |
311 | bool searchSubMembers | |
312 | ) | |
cecfc5e7 | 313 | { |
d12e3536 VZ |
314 | for( size_t i = 0; i != mMembers.size(); ++i ) |
315 | { | |
316 | spContext& member = *mMembers[i]; | |
cecfc5e7 | 317 | |
eda6fa91 | 318 | if ( member.GetName() == identifier && |
d12e3536 VZ |
319 | ( contextType & member.GetContextType() ) |
320 | ) | |
cecfc5e7 | 321 | |
d12e3536 | 322 | return &member; |
cecfc5e7 | 323 | |
d12e3536 VZ |
324 | if ( searchSubMembers ) |
325 | { | |
eda6fa91 | 326 | spContext* result = |
d12e3536 | 327 | member.FindContext( identifier, contextType, 1 ); |
cecfc5e7 | 328 | |
d12e3536 VZ |
329 | if ( result ) return result; |
330 | } | |
331 | } | |
cecfc5e7 | 332 | |
d12e3536 | 333 | return 0; |
cecfc5e7 VZ |
334 | } |
335 | ||
336 | void spContext::RemoveThisContext() | |
337 | { | |
2af95167 WS |
338 | if ( m_pParent ) |
339 | m_pParent->RemoveChild( this ); | |
d12e3536 VZ |
340 | else |
341 | // context should have a parent | |
3a87625f | 342 | wxFAIL_MSG("Context should have a parent"); |
cecfc5e7 VZ |
343 | } |
344 | ||
345 | spContext* spContext::GetOutterContext() | |
346 | { | |
2af95167 | 347 | return m_pParent; |
cecfc5e7 VZ |
348 | } |
349 | ||
350 | bool spContext::HasOutterContext() | |
351 | { | |
2af95167 | 352 | return ( m_pParent != 0 ); |
cecfc5e7 VZ |
353 | } |
354 | ||
355 | bool spContext::IsInFile() | |
356 | { | |
d12e3536 | 357 | return ( GetOutterContext()->GetContextType() == SP_CTX_FILE ); |
cecfc5e7 VZ |
358 | } |
359 | ||
360 | bool spContext::IsInNameSpace() | |
361 | { | |
d12e3536 | 362 | return ( GetOutterContext()->GetContextType() == SP_CTX_NAMESPACE ); |
cecfc5e7 VZ |
363 | } |
364 | ||
365 | bool spContext::IsInClass() | |
366 | { | |
d12e3536 | 367 | return ( GetOutterContext()->GetContextType() == SP_CTX_CLASS ); |
cecfc5e7 VZ |
368 | } |
369 | ||
370 | bool spContext::IsInOperation() | |
371 | { | |
d12e3536 | 372 | return ( GetOutterContext()->GetContextType() == SP_CTX_OPERATION ); |
cecfc5e7 VZ |
373 | } |
374 | ||
375 | spClass& spContext::GetClass() | |
376 | { | |
d12e3536 | 377 | wxASSERT( GetOutterContext()->GetType() == SP_CTX_CLASS ); |
2af95167 | 378 | return *((spClass*)m_pParent ); |
cecfc5e7 VZ |
379 | } |
380 | ||
381 | spFile& spContext::GetFile() | |
382 | { | |
d12e3536 | 383 | wxASSERT( GetOutterContext()->GetType() == SP_CTX_FILE ); |
2af95167 | 384 | return *((spFile*)m_pParent ); |
cecfc5e7 VZ |
385 | } |
386 | ||
387 | spNameSpace& spContext::GetNameSpace() | |
388 | { | |
d12e3536 | 389 | wxASSERT( GetOutterContext()->GetType() == SP_CTX_NAMESPACE ); |
2af95167 | 390 | return *((spNameSpace*)m_pParent ); |
cecfc5e7 VZ |
391 | } |
392 | ||
393 | spOperation& spContext::GetOperation() | |
394 | { | |
d12e3536 | 395 | wxASSERT( GetOutterContext()->GetType() == SP_CTX_OPERATION ); |
2af95167 | 396 | return *((spOperation*)m_pParent ); |
cecfc5e7 VZ |
397 | } |
398 | ||
399 | /***** Implementation for class spClass *****/ | |
400 | ||
401 | void spClass::SortMembers() | |
402 | { | |
d12e3536 | 403 | // TBD:: |
cecfc5e7 VZ |
404 | } |
405 | ||
406 | /***** Implementation for class spOperation *****/ | |
407 | ||
408 | spOperation::spOperation() | |
409 | ||
eda6fa91 | 410 | : mHasDefinition( false ) |
59734eb5 VZ |
411 | { |
412 | mIsConstant = | |
413 | mIsVirtual = | |
414 | mHasDefinition = false; | |
415 | } | |
cecfc5e7 | 416 | |
fa1af598 | 417 | wxString spOperation::GetFullName(MarkupTagsT tags) |
cecfc5e7 | 418 | { |
fa1af598 WS |
419 | wxString txt = tags[TAG_BOLD].start + m_RetType; |
420 | txt += _T(" "); | |
8bc17f14 | 421 | txt += m_Name; |
fa1af598 | 422 | txt += _T("( "); |
d12e3536 | 423 | txt += tags[TAG_BOLD].end; |
eda6fa91 | 424 | |
d12e3536 VZ |
425 | for( size_t i = 0; i != mMembers.size(); ++i ) |
426 | { | |
427 | // DBG:: | |
428 | wxASSERT( mMembers[i]->GetContextType() == SP_CTX_PARAMETER ); | |
cecfc5e7 | 429 | |
d12e3536 | 430 | spParameter& param = *((spParameter*)mMembers[i]); |
cecfc5e7 | 431 | |
d12e3536 | 432 | if ( i != 0 ) |
fa1af598 | 433 | txt += _T(", "); |
eda6fa91 | 434 | |
d12e3536 | 435 | txt += tags[TAG_BOLD].start; |
eda6fa91 | 436 | |
821d644d | 437 | txt += param.m_Type; |
cecfc5e7 | 438 | |
d12e3536 VZ |
439 | txt += tags[TAG_BOLD].end; |
440 | txt += tags[TAG_ITALIC].start; | |
cecfc5e7 | 441 | |
fa1af598 | 442 | txt += _T(" "); |
8bc17f14 | 443 | txt += param.m_Name; |
cecfc5e7 | 444 | |
fa1af598 | 445 | if ( !param.m_InitVal.empty() ) |
d12e3536 | 446 | { |
fa1af598 | 447 | txt += _T(" = "); |
d12e3536 | 448 | txt += tags[TAG_BOLD].start; |
cecfc5e7 | 449 | |
fa1af598 | 450 | txt += param.m_InitVal; |
cecfc5e7 | 451 | |
d12e3536 VZ |
452 | txt += tags[TAG_BOLD].end; |
453 | } | |
cecfc5e7 | 454 | |
d12e3536 VZ |
455 | txt += tags[TAG_ITALIC].end;; |
456 | } | |
cecfc5e7 | 457 | |
d12e3536 VZ |
458 | txt += tags[TAG_BOLD].start; |
459 | txt += " )"; | |
460 | txt += tags[TAG_BOLD].end; | |
cecfc5e7 | 461 | |
d12e3536 | 462 | // TBD:: constantness of method |
cecfc5e7 | 463 | |
d12e3536 | 464 | return txt; |
cecfc5e7 VZ |
465 | } |
466 | ||
467 | /***** Implemenentation for class spPreprocessorLine *****/ | |
468 | ||
fa1af598 | 469 | wxString spPreprocessorLine::CPP_GetIncludedFileNeme() const |
cecfc5e7 | 470 | { |
d12e3536 | 471 | wxASSERT( GetStatementType() == SP_PREP_DEF_INCLUDE_FILE ); |
cecfc5e7 | 472 | |
d12e3536 | 473 | size_t i = 0; |
cecfc5e7 | 474 | |
fa1af598 | 475 | while( i < m_Line.length() && m_Line[i] != _T('"') && m_Line[i] != _T('<') ) |
eda6fa91 | 476 | |
d12e3536 | 477 | ++i; |
cecfc5e7 | 478 | |
d12e3536 | 479 | ++i; |
cecfc5e7 | 480 | |
d12e3536 | 481 | size_t start = i; |
cecfc5e7 | 482 | |
fa1af598 | 483 | while( i < m_Line.length() && m_Line[i] != _T('"') && m_Line[i] != _T('>') ) |
cecfc5e7 | 484 | |
d12e3536 | 485 | ++i; |
cecfc5e7 | 486 | |
c69a7d10 | 487 | if ( start < m_Line.length() ) |
d12e3536 | 488 | { |
fa1af598 | 489 | wxString fname; |
c69a7d10 | 490 | fname.append( m_Line, start, ( i - start ) ); |
cecfc5e7 | 491 | |
d12e3536 VZ |
492 | return fname; |
493 | } | |
494 | else | |
fa1af598 | 495 | return wxEmptyString; // syntax error probably |
cecfc5e7 VZ |
496 | } |
497 | ||
498 | ||
499 | ||
500 | /***** Implemenentation for class SourceParserBase *****/ | |
501 | ||
502 | SourceParserBase::SourceParserBase() | |
503 | ||
d12e3536 VZ |
504 | : mpFileBuf( NULL ), |
505 | mFileBufSz( 0 ), | |
cecfc5e7 | 506 | |
d12e3536 | 507 | mpPlugin( NULL ) |
cecfc5e7 VZ |
508 | {} |
509 | ||
510 | SourceParserBase::~SourceParserBase() | |
511 | { | |
d12e3536 | 512 | if ( mpFileBuf ) free( mpFileBuf ); |
cecfc5e7 | 513 | |
d12e3536 | 514 | if ( mpPlugin ) delete mpPlugin; |
cecfc5e7 VZ |
515 | } |
516 | ||
517 | spFile* SourceParserBase::ParseFile( const char* fname ) | |
518 | { | |
d12e3536 | 519 | // FIXME:: the below should not be fixed! |
cecfc5e7 | 520 | |
d12e3536 | 521 | const size_t MAX_BUF_SIZE = 1024*256; |
cecfc5e7 | 522 | |
d12e3536 | 523 | if ( !mpFileBuf ) mpFileBuf = (char*)malloc( MAX_BUF_SIZE ); |
cecfc5e7 | 524 | |
d12e3536 | 525 | mFileBufSz = MAX_BUF_SIZE; |
cecfc5e7 | 526 | |
d12e3536 | 527 | FILE* fp = fopen( fname, "rt" ); |
cecfc5e7 | 528 | |
42389ac7 | 529 | if ( !fp ) return NULL; |
cecfc5e7 | 530 | |
d12e3536 | 531 | int sz = fread( mpFileBuf, 1, mFileBufSz, fp ); |
cecfc5e7 | 532 | |
d12e3536 | 533 | return Parse( mpFileBuf, mpFileBuf + sz ); |
cecfc5e7 VZ |
534 | } |
535 | ||
536 | void SourceParserBase::SetPlugin( SourceParserPlugin* pPlugin ) | |
537 | { | |
d12e3536 | 538 | if ( mpPlugin ) delete mpPlugin; |
cecfc5e7 | 539 | |
d12e3536 | 540 | mpPlugin = pPlugin; |
cecfc5e7 | 541 | } |
d12e3536 VZ |
542 | |
543 | // =========================================================================== | |
544 | // debug methods | |
545 | // =========================================================================== | |
546 | ||
547 | #ifdef __WXDEBUG__ | |
548 | ||
549 | void spContext::Dump(const wxString& indent) const | |
550 | { | |
551 | DumpThis(indent); | |
552 | ||
553 | // increase it for the children | |
554 | wxString indentChild = indent + " "; | |
555 | ||
556 | for ( MMemberListT::const_iterator i = mMembers.begin(); | |
557 | i != mMembers.end(); | |
558 | i++ ) { | |
559 | (*i)->Dump(indentChild); | |
560 | } | |
561 | } | |
562 | ||
eda6fa91 | 563 | void spContext::DumpThis(const wxString& WXUNUSED(indent)) const |
d12e3536 VZ |
564 | { |
565 | wxFAIL_MSG("abstract base class can't be found in parser tree!"); | |
566 | } | |
567 | ||
568 | void spParameter::DumpThis(const wxString& indent) const | |
569 | { | |
570 | wxLogDebug("%sparam named '%s' of type '%s'", | |
821d644d | 571 | indent.c_str(), m_Name.c_str(), m_Type.c_str()); |
d12e3536 VZ |
572 | } |
573 | ||
574 | void spAttribute::DumpThis(const wxString& indent) const | |
575 | { | |
576 | wxLogDebug("%svariable named '%s' of type '%s'", | |
821d644d | 577 | indent.c_str(), m_Name.c_str(), m_Type.c_str()); |
d12e3536 VZ |
578 | } |
579 | ||
580 | void spOperation::DumpThis(const wxString& indent) const | |
581 | { | |
582 | wxString protection; | |
42389ac7 | 583 | if ( !mScope.empty() ) { |
d12e3536 VZ |
584 | switch ( mVisibility ) { |
585 | case SP_VIS_PUBLIC: | |
586 | protection = "public"; | |
587 | break; | |
588 | ||
589 | case SP_VIS_PROTECTED: | |
590 | protection = "protected"; | |
591 | break; | |
592 | ||
593 | case SP_VIS_PRIVATE: | |
594 | protection = "private"; | |
595 | break; | |
596 | ||
597 | default: | |
598 | wxFAIL_MSG("unknown protection type"); | |
599 | } | |
600 | } | |
601 | else { | |
602 | protection = "global"; | |
603 | } | |
604 | ||
60ec1c87 WS |
605 | wxString constStr,virtualStr; |
606 | if(mIsConstant) constStr = _T("const "); | |
607 | if(mIsVirtual) virtualStr = _T("virtual "); | |
608 | ||
d12e3536 VZ |
609 | wxLogDebug("%s%s%s%s function named '%s::%s' of type '%s'", |
610 | indent.c_str(), | |
60ec1c87 WS |
611 | constStr.c_str(), |
612 | virtualStr.c_str(), | |
d12e3536 | 613 | protection.c_str(), |
821d644d | 614 | mScope.c_str(), m_Name.c_str(), m_RetType.c_str()); |
d12e3536 VZ |
615 | } |
616 | ||
617 | void spPreprocessorLine::DumpThis(const wxString& indent) const | |
618 | { | |
619 | wxString kind; | |
620 | switch ( mDefType ) { | |
621 | case SP_PREP_DEF_DEFINE_SYMBOL: | |
622 | kind = "define"; | |
623 | break; | |
624 | ||
625 | case SP_PREP_DEF_REDEFINE_SYMBOL: | |
626 | kind = "redefine"; | |
627 | break; | |
628 | ||
629 | case SP_PREP_DEF_INCLUDE_FILE: | |
630 | kind.Printf("include (%s)", CPP_GetIncludedFileNeme().c_str()); | |
631 | break; | |
632 | ||
633 | case SP_PREP_DEF_OTHER: | |
634 | kind = "other"; | |
635 | break; | |
636 | ||
637 | } | |
638 | ||
639 | wxLogDebug("%spreprocessor statement: %s", | |
640 | indent.c_str(), kind.c_str()); | |
641 | } | |
642 | ||
643 | void spClass::DumpThis(const wxString& indent) const | |
644 | { | |
645 | wxString base; | |
33882d15 WS |
646 | for ( StrListT::const_iterator i = m_SuperClassNames.begin(); |
647 | i != m_SuperClassNames.end(); | |
d12e3536 | 648 | i++ ) { |
8bc17f14 | 649 | if ( !base.empty() ) |
d12e3536 VZ |
650 | base += ", "; |
651 | base += *i; | |
652 | } | |
653 | ||
654 | if ( !base ) | |
655 | base = "none"; | |
656 | ||
657 | wxString kind; | |
658 | switch ( mClassSubType ) { | |
659 | case SP_CLTYPE_CLASS: | |
660 | kind = "class"; | |
661 | break; | |
662 | ||
663 | case SP_CLTYPE_TEMPLATE_CLASS: | |
664 | kind = "template class"; | |
665 | break; | |
666 | ||
667 | case SP_CLTYPE_STRUCTURE: | |
668 | kind = "struc"; | |
669 | break; | |
670 | ||
671 | case SP_CLTYPE_UNION: | |
672 | kind = "union"; | |
673 | break; | |
674 | ||
675 | case SP_CLTYPE_INTERFACE: | |
676 | kind = "interface"; | |
677 | break; | |
678 | ||
679 | default: | |
680 | wxFAIL_MSG("unknown class subtype"); | |
681 | } | |
682 | ||
683 | wxLogDebug("%s%s named '%s' (base classes: %s)", | |
684 | indent.c_str(), kind.c_str(), | |
8bc17f14 | 685 | m_Name.c_str(), base.c_str()); |
d12e3536 VZ |
686 | } |
687 | ||
688 | void spEnumeration::DumpThis(const wxString& indent) const | |
689 | { | |
690 | wxLogDebug("%senum named '%s'", | |
8bc17f14 | 691 | indent.c_str(), m_Name.c_str()); |
d12e3536 VZ |
692 | } |
693 | ||
694 | void spTypeDef::DumpThis(const wxString& indent) const | |
695 | { | |
696 | wxLogDebug("%stypedef %s = %s", | |
c69a7d10 | 697 | indent.c_str(), m_Name.c_str(), m_OriginalType.c_str()); |
d12e3536 VZ |
698 | } |
699 | ||
700 | void spFile::DumpThis(const wxString& indent) const | |
701 | { | |
702 | wxLogDebug("%sfile '%s'", | |
60ec1c87 | 703 | indent.c_str(), m_FileName.c_str()); |
d12e3536 VZ |
704 | } |
705 | ||
706 | #endif // __WXDEBUG__ |