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