@@ -333,31 +333,34 @@ Function addDecoratedConstants(module, procedureWithoutModule, declWave, lineWa
333
333
Variable numLines, i , idx, numEntries, numMatches
334
334
String procText, re, def, name
335
335
336
+ // get procedure code
336
337
procText = getProcedureText ( module, procedureWithoutModule)
337
338
numLines = ItemsInList ( procText, "\r " )
339
+
340
+ // search code and return wavLineNumber
338
341
Make / FREE/ N= ( numLines) / T text = StringFromList ( p, procText, "\r " )
339
-
340
342
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
343
349
if ( ! V_Value) // no matches
344
- KillWaves / Z W_Index
345
350
return 0
346
351
endif
347
352
348
- Wave W_Index
349
- numMatches = DimSize ( W_Index, 0 )
353
+ numMatches = DimSize ( wavLineNumber, 0 )
350
354
numEntries = DimSize ( declWave, 0 )
351
-
352
355
Redimension / N= ( numEntries + numMatches, -1 ) declWave, lineWave
353
356
354
357
idx = numEntries
355
358
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
357
360
358
361
declWave[ idx][ 0 ] = createMarkerForType ( LowerStr ( def))
359
362
declWave[ idx][ 1 ] = name
360
- lineWave[ idx] = W_Index [ i ]
363
+ lineWave[ idx] = wavLineNumber [ i ]
361
364
idx += 1
362
365
endfor
363
366
@@ -372,36 +375,38 @@ Function addDecoratedMacros(module, procedureWithoutModule, declWave, lineWave)
372
375
Variable numLines, i , idx, numEntries, numMatches
373
376
String procText, re, def, name, arguments, type
374
377
378
+ // get procedure code
375
379
procText = getProcedureText ( module, procedureWithoutModule)
376
380
numLines = ItemsInList ( procText, "\r " )
377
381
382
+ // search code and return wavLineNumber
378
383
Make / FREE/ N= ( numLines) / T text = StringFromList ( p, procText, "\r " )
379
384
// 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 /
380
385
// macro should have no arguments. Handled for backwards compatibility.
381
386
// help for regex on https://regex101.com/
382
387
re = "^(?i)[[:space:]]*(window|macro|proc)[[:space:]]+([^[:space:]]+)[[:space:]]*\( (.*)\) [[:space:]]*[:]?[[:space:]]*([^[:space:]\/ ]*).*"
383
388
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
385
394
if ( ! V_Value) // no matches
386
- KillWaves / Z W_Index
387
395
return 0
388
396
endif
389
397
390
- Wave W_Index
391
- numMatches = DimSize ( W_Index, 0 )
398
+ numMatches = DimSize ( wavLineNumber, 0 )
392
399
numEntries = DimSize ( declWave, 0 )
393
400
Redimension / N= ( numEntries + numMatches, -1 ) declWave, lineWave
394
401
395
402
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
397
404
// def containts window/macro/proc
398
405
// type contains Panel/Layout for subclasses of window macros
399
406
declWave[ idx][ 0 ] = createMarkerForType ( LowerStr ( def))
400
407
declWave[ idx][ 1 ] = name + "(" + trimArgument ( arguments, "," , strListSepStringOutput = ", " ) + ")" + " : " + type
401
- lineWave[ idx] = W_Index [( idx - numEntries)]
408
+ lineWave[ idx] = wavLineNumber [( idx - numEntries)]
402
409
endfor
403
-
404
- KillWaves / Z W_Index
405
410
End
406
411
407
412
Function addDecoratedStructure ( module, procedureWithoutModule, declWave, lineWave, [ parseVariables] )
@@ -416,26 +421,30 @@ Function addDecoratedStructure(module, procedureWithoutModule, declWave, lineWa
416
421
variable numLines, i , idx, numEntries, numMatches
417
422
string procText, reStart, reEnd, name, StaticKeyword
418
423
424
+ // get procedure code
419
425
procText = getProcedureText ( module, procedureWithoutModule)
420
426
numLines = ItemsInList ( procText, "\r " )
421
427
if ( numLines == 0 )
422
428
debugPrint ( "no Content in Procedure " + procedureWithoutModule)
423
429
endif
424
- Make / FREE/ N= ( numLines) / T text = StringFromList ( p, procText, "\r " )
425
430
431
+ // search code and return wavLineNumber
432
+ Make / FREE/ N= ( numLines) / T text = StringFromList ( p, procText, "\r " )
426
433
// 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
427
434
// help for regex on https://regex101.com/
428
435
reStart = "^(?i)[[:space:]]*((?:static[[:space:]])?)[[:space:]]*structure[[:space:]]+([^[:space:]\/ ]+)[[:space:]\/ ]?.*"
429
436
Grep / Q/ INDX/ E= reStart text
430
437
Wave W_Index
431
438
Duplicate / FREE W_Index wavStructureStart
432
439
KillWaves / Z W_Index
440
+ KillStrings / Z S_fileName
433
441
WaveClear W_Index
434
442
if ( ! V_Value) // no matches
435
443
return 0
436
444
endif
437
445
numMatches = DimSize ( wavStructureStart, 0 )
438
446
447
+ // optionally analyze structure elements
439
448
if ( parseVariables)
440
449
// regexp: match case insensitive endstructure followed by (space or /) and anything else or just a lineend
441
450
// does not match endstructure23 but endstructure//
@@ -444,6 +453,7 @@ Function addDecoratedStructure(module, procedureWithoutModule, declWave, lineWa
444
453
Wave W_Index
445
454
Duplicate / FREE W_Index wavStructureEnd
446
455
KillWaves / Z W_Index
456
+ KillStrings / Z S_fileName
447
457
WaveClear W_Index
448
458
if ( numMatches != DimSize ( wavStructureEnd, 0 ))
449
459
numMatches = 0
@@ -458,15 +468,18 @@ Function addDecoratedStructure(module, procedureWithoutModule, declWave, lineWa
458
468
SplitString / E= reStart text[ wavStructureStart[( idx - numEntries)]] , StaticKeyword, name
459
469
declWave[ idx][ 0 ] = createMarkerForType ( LowerStr ( StaticKeyword) + "structure" ) // no " " between static and structure needed
460
470
declWave[ idx][ 1 ] = name
471
+
472
+ // optionally parse structure elements
461
473
if ( parseVariables)
462
474
Duplicate / FREE/ R= [( wavStructureStart[( idx - numEntries)]) , ( wavStructureEnd[( idx - numEntries)])] text, temp
463
475
declWave[ idx][ 1 ] += getStructureElements ( temp)
464
- WaveClear temp
465
-
476
+ WaveClear temp
466
477
endif
478
+
467
479
lineWave[ idx] = wavStructureStart[( idx - numEntries)]
468
480
endfor
469
-
481
+
482
+ WaveClear wavStructureStart, wavStructureEnd
470
483
End
471
484
472
485
// input wave (wavStructure) contains text of Structure lineseparated.
@@ -484,17 +497,19 @@ Function/S getStructureElements(wavStructure)
484
497
return ""
485
498
endif
486
499
487
- // parse code for returning wavLineNumber and wavContent
500
+ // search code and return wavLineNumber and wavContent
488
501
Duplicate / T/ FREE/ R= [ 1, ( numElements-1 )] wavStructure wavContent
489
502
regExp = "^(?i)[[:space:]]*(" + cstrTypes + ")[[:space:]]+(?:\/ [a-z]+[[:space:]]*)*([^\/ ]*)(?:[\/ ].*)?"
490
503
Grep / Q/ INDX/ E= regExp wavContent
491
504
Wave W_Index
505
+ Duplicate / FREE W_Index wavLineNumber
506
+ KillWaves / Z W_Index
507
+ KillStrings / Z S_fileName
508
+ WaveClear W_Index
492
509
if ( ! V_Value) // no matches
493
- DebugPrint ( "No Elements found" )
510
+ DebugPrint ( "Structure with no Elements found" )
494
511
return "()"
495
512
endif
496
- Duplicate / FREE W_Index wavLineNumber
497
- KillWaves / Z W_Index
498
513
499
514
// extract Variable types and names inside each content line to return lstTypes and lstNames
500
515
lstTypes = ""
@@ -738,10 +753,20 @@ Function saveResetStorage()
738
753
Wave savedVariablesWave = getSaveVariables ()
739
754
Wave /T SavedStringsWave = getSaveStrings ()
740
755
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
742
760
saveReParse ()
743
- Killwaves / Z savedVariablesWave, SavedStringsWave, SavedWavesWave
761
+ setGlobalStr ( "parsingChecksum" , "" )
762
+ setGlobalVar ( "checksumTime" , NaN )
763
+ setGlobalVar ( "parsingTime" , NaN )
744
764
765
+ // kill
766
+ Killwaves / Z savedVariablesWave, SavedStringsWave, SavedWavesWave
767
+ killGlobalStr ( "parsingChecksum" )
768
+ killGlobalVar ( "checksumTime" )
769
+ killGlobalvar ( "parsingTime" )
745
770
End
746
771
747
772
// Returns a list with the following optional suffixes removed:
767
792
// returns code of procedure in module
768
793
Function /S getProcedureText ( module, procedureWithoutModule)
769
794
String module, procedureWithoutModule
795
+ String strProcedure
796
+
770
797
if ( isProcGlobal ( module))
771
798
debugPrint ( module + " is in ProcGlobal" )
772
- return ProcedureText ( "" , 0, procedureWithoutModule)
799
+ strProcedure = ProcedureText ( "" , 0, procedureWithoutModule)
800
+ return strProcedure
773
801
else
774
802
debugPrint ( procedureWithoutModule + " is in " + module)
775
803
return ProcedureText ( "" , 0, procedureWithoutModule + " [" + module + "]" )
@@ -870,6 +898,7 @@ Function/S getModuleList()
870
898
871
899
moduleList = IndependentModuleList ( ";" )
872
900
moduleList = ListMatch ( moduleList, "!WM*" , ";" ) // skip WM modules
901
+ moduleList = ListMatch ( moduleList, "!RCP*" , ";" ) // skip WM's Resize Controls modul
873
902
String module = GetIndependentModuleName ()
874
903
875
904
if ( ! debuggingEnabled && ! isProcGlobal ( module))
0 commit comments