@@ -333,31 +333,34 @@ Function addDecoratedConstants(module, procedureWithoutModule, declWave, lineWa
333333 Variable numLines, i , idx, numEntries, numMatches
334334 String procText, re, def, name
335335
336+ // get procedure code
336337 procText = getProcedureText ( module, procedureWithoutModule)
337338 numLines = ItemsInList ( procText, "\r " )
339+
340+ // search code and return wavLineNumber
338341 Make / FREE/ N= ( numLines) / T text = StringFromList ( p, procText, "\r " )
339-
340342 re = "^(?i)[[:space:]]*((?:override)?(?:static)?[[:space:]]*(?:Str)?Constant)[[:space:]]+(.*)=.*"
341- Grep / Q/ INDX/ E= re text
342-
343+ Grep / Q/ INDX/ E= re text
344+ Wave W_Index
345+ Duplicate / FREE W_Index wavLineNumber
346+ KillWaves / Z W_Index
347+ KillStrings / Z S_fileName
348+ WaveClear W_Index
343349 if ( ! V_Value) // no matches
344- KillWaves / Z W_Index
345350 return 0
346351 endif
347352
348- Wave W_Index
349- numMatches = DimSize ( W_Index, 0 )
353+ numMatches = DimSize ( wavLineNumber, 0 )
350354 numEntries = DimSize ( declWave, 0 )
351-
352355 Redimension / N= ( numEntries + numMatches, -1 ) declWave, lineWave
353356
354357 idx = numEntries
355358 for ( i = 0; i < numMatches; i += 1 )
356- SplitString / E= re text[ W_Index [ i ]] , def, name
359+ SplitString / E= re text[ wavLineNumber [ i ]] , def, name
357360
358361 declWave[ idx][ 0 ] = createMarkerForType ( LowerStr ( def))
359362 declWave[ idx][ 1 ] = name
360- lineWave[ idx] = W_Index [ i ]
363+ lineWave[ idx] = wavLineNumber [ i ]
361364 idx += 1
362365 endfor
363366
@@ -372,36 +375,38 @@ Function addDecoratedMacros(module, procedureWithoutModule, declWave, lineWave)
372375 Variable numLines, i , idx, numEntries, numMatches
373376 String procText, re, def, name, arguments, type
374377
378+ // get procedure code
375379 procText = getProcedureText ( module, procedureWithoutModule)
376380 numLines = ItemsInList ( procText, "\r " )
377381
382+ // search code and return wavLineNumber
378383 Make / FREE/ N= ( numLines) / T text = StringFromList ( p, procText, "\r " )
379384 // regexp: match case insensitive (?i) spaces don't matter. search for window or macro or proc. Macro Name is the the next non-space character followed by brackets () where the arguments are. At the end there might be a colon, specifying the type of macro and a comment beginning with /
380385 // macro should have no arguments. Handled for backwards compatibility.
381386 // help for regex on https://regex101.com/
382387 re = "^(?i)[[:space:]]*(window|macro|proc)[[:space:]]+([^[:space:]]+)[[:space:]]*\( (.*)\) [[:space:]]*[:]?[[:space:]]*([^[:space:]\/ ]*).*"
383388 Grep / Q/ INDX/ E= re text
384-
389+ Wave W_Index
390+ Duplicate / FREE W_Index wavLineNumber
391+ KillWaves / Z W_Index
392+ KillStrings / Z S_fileName
393+ WaveClear W_Index
385394 if ( ! V_Value) // no matches
386- KillWaves / Z W_Index
387395 return 0
388396 endif
389397
390- Wave W_Index
391- numMatches = DimSize ( W_Index, 0 )
398+ numMatches = DimSize ( wavLineNumber, 0 )
392399 numEntries = DimSize ( declWave, 0 )
393400 Redimension / N= ( numEntries + numMatches, -1 ) declWave, lineWave
394401
395402 for ( idx = numEntries; idx < ( numEntries + numMatches) ; idx +=1 )
396- SplitString / E= re text[ W_Index [( idx - numEntries)]] , def, name, arguments, type
403+ SplitString / E= re text[ wavLineNumber [( idx - numEntries)]] , def, name, arguments, type
397404 // def containts window/macro/proc
398405 // type contains Panel/Layout for subclasses of window macros
399406 declWave[ idx][ 0 ] = createMarkerForType ( LowerStr ( def))
400407 declWave[ idx][ 1 ] = name + "(" + trimArgument ( arguments, "," , strListSepStringOutput = ", " ) + ")" + " : " + type
401- lineWave[ idx] = W_Index [( idx - numEntries)]
408+ lineWave[ idx] = wavLineNumber [( idx - numEntries)]
402409 endfor
403-
404- KillWaves / Z W_Index
405410End
406411
407412Function addDecoratedStructure ( module, procedureWithoutModule, declWave, lineWave, [ parseVariables] )
@@ -416,26 +421,30 @@ Function addDecoratedStructure(module, procedureWithoutModule, declWave, lineWa
416421 variable numLines, i , idx, numEntries, numMatches
417422 string procText, reStart, reEnd, name, StaticKeyword
418423
424+ // get procedure code
419425 procText = getProcedureText ( module, procedureWithoutModule)
420426 numLines = ItemsInList ( procText, "\r " )
421427 if ( numLines == 0 )
422428 debugPrint ( "no Content in Procedure " + procedureWithoutModule)
423429 endif
424- Make / FREE/ N= ( numLines) / T text = StringFromList ( p, procText, "\r " )
425430
431+ // search code and return wavLineNumber
432+ Make / FREE/ N= ( numLines) / T text = StringFromList ( p, procText, "\r " )
426433 // regexp: match case insensitive (?i) leading spaces don't matter. optional static statement. search for structure name which contains no spaces. followed by an optional space and nearly anything like inline comments
427434 // help for regex on https://regex101.com/
428435 reStart = "^(?i)[[:space:]]*((?:static[[:space:]])?)[[:space:]]*structure[[:space:]]+([^[:space:]\/ ]+)[[:space:]\/ ]?.*"
429436 Grep / Q/ INDX/ E= reStart text
430437 Wave W_Index
431438 Duplicate / FREE W_Index wavStructureStart
432439 KillWaves / Z W_Index
440+ KillStrings / Z S_fileName
433441 WaveClear W_Index
434442 if ( ! V_Value) // no matches
435443 return 0
436444 endif
437445 numMatches = DimSize ( wavStructureStart, 0 )
438446
447+ // optionally analyze structure elements
439448 if ( parseVariables)
440449 // regexp: match case insensitive endstructure followed by (space or /) and anything else or just a lineend
441450 // does not match endstructure23 but endstructure//
@@ -444,6 +453,7 @@ Function addDecoratedStructure(module, procedureWithoutModule, declWave, lineWa
444453 Wave W_Index
445454 Duplicate / FREE W_Index wavStructureEnd
446455 KillWaves / Z W_Index
456+ KillStrings / Z S_fileName
447457 WaveClear W_Index
448458 if ( numMatches != DimSize ( wavStructureEnd, 0 ))
449459 numMatches = 0
@@ -458,15 +468,18 @@ Function addDecoratedStructure(module, procedureWithoutModule, declWave, lineWa
458468 SplitString / E= reStart text[ wavStructureStart[( idx - numEntries)]] , StaticKeyword, name
459469 declWave[ idx][ 0 ] = createMarkerForType ( LowerStr ( StaticKeyword) + "structure" ) // no " " between static and structure needed
460470 declWave[ idx][ 1 ] = name
471+
472+ // optionally parse structure elements
461473 if ( parseVariables)
462474 Duplicate / FREE/ R= [( wavStructureStart[( idx - numEntries)]) , ( wavStructureEnd[( idx - numEntries)])] text, temp
463475 declWave[ idx][ 1 ] += getStructureElements ( temp)
464- WaveClear temp
465-
476+ WaveClear temp
466477 endif
478+
467479 lineWave[ idx] = wavStructureStart[( idx - numEntries)]
468480 endfor
469-
481+
482+ WaveClear wavStructureStart, wavStructureEnd
470483End
471484
472485// input wave (wavStructure) contains text of Structure lineseparated.
@@ -484,17 +497,19 @@ Function/S getStructureElements(wavStructure)
484497 return ""
485498 endif
486499
487- // parse code for returning wavLineNumber and wavContent
500+ // search code and return wavLineNumber and wavContent
488501 Duplicate / T/ FREE/ R= [ 1, ( numElements-1 )] wavStructure wavContent
489502 regExp = "^(?i)[[:space:]]*(" + cstrTypes + ")[[:space:]]+(?:\/ [a-z]+[[:space:]]*)*([^\/ ]*)(?:[\/ ].*)?"
490503 Grep / Q/ INDX/ E= regExp wavContent
491504 Wave W_Index
505+ Duplicate / FREE W_Index wavLineNumber
506+ KillWaves / Z W_Index
507+ KillStrings / Z S_fileName
508+ WaveClear W_Index
492509 if ( ! V_Value) // no matches
493- DebugPrint ( "No Elements found" )
510+ DebugPrint ( "Structure with no Elements found" )
494511 return "()"
495512 endif
496- Duplicate / FREE W_Index wavLineNumber
497- KillWaves / Z W_Index
498513
499514 // extract Variable types and names inside each content line to return lstTypes and lstNames
500515 lstTypes = ""
@@ -738,10 +753,20 @@ Function saveResetStorage()
738753 Wave savedVariablesWave = getSaveVariables ()
739754 Wave /T SavedStringsWave = getSaveStrings ()
740755 Wave /WAVE SavedWavesWave = getSaveWaves ()
741- // if waves are in use. Mark for ReParse
756+
757+ // if objects are in use they can not be killed. reset before killing
758+
759+ // reset
742760 saveReParse ()
743- Killwaves / Z savedVariablesWave, SavedStringsWave, SavedWavesWave
761+ setGlobalStr ( "parsingChecksum" , "" )
762+ setGlobalVar ( "checksumTime" , NaN )
763+ setGlobalVar ( "parsingTime" , NaN )
744764
765+ // kill
766+ Killwaves / Z savedVariablesWave, SavedStringsWave, SavedWavesWave
767+ killGlobalStr ( "parsingChecksum" )
768+ killGlobalVar ( "checksumTime" )
769+ killGlobalvar ( "parsingTime" )
745770End
746771
747772// Returns a list with the following optional suffixes removed:
767792// returns code of procedure in module
768793Function /S getProcedureText ( module, procedureWithoutModule)
769794 String module, procedureWithoutModule
795+ String strProcedure
796+
770797 if ( isProcGlobal ( module))
771798 debugPrint ( module + " is in ProcGlobal" )
772- return ProcedureText ( "" , 0, procedureWithoutModule)
799+ strProcedure = ProcedureText ( "" , 0, procedureWithoutModule)
800+ return strProcedure
773801 else
774802 debugPrint ( procedureWithoutModule + " is in " + module)
775803 return ProcedureText ( "" , 0, procedureWithoutModule + " [" + module + "]" )
@@ -870,6 +898,7 @@ Function/S getModuleList()
870898
871899 moduleList = IndependentModuleList ( ";" )
872900 moduleList = ListMatch ( moduleList, "!WM*" , ";" ) // skip WM modules
901+ moduleList = ListMatch ( moduleList, "!RCP*" , ";" ) // skip WM's Resize Controls modul
873902 String module = GetIndependentModuleName ()
874903
875904 if ( ! debuggingEnabled && ! isProcGlobal ( module))
0 commit comments