@@ -43,6 +43,8 @@ StrConstant declarations = "declarations"
43
43
StrConstant helpWave = "help"
44
44
// 1D Wave in each row having the line of the function or -1 for macros
45
45
StrConstant declarationLines = "lines"
46
+ // 1D Wave in each row having the procedure id for the corresponing element in lines
47
+ StrConstant procedureWave = "procs"
46
48
// database-like global multidimensional waves for storing parsing results to minimize time.
47
49
static StrConstant CsaveStrings = "saveStrings"
48
50
static Strconstant CSaveVariables = "saveVariables"
@@ -52,6 +54,8 @@ static Constant CsaveMaximum = 1024
52
54
53
55
Constant openKey = 46 // ".", the dot
54
56
57
+ StrConstant CB_selectAll = "<ALL>"
58
+
55
59
// List of igor7 structure elements.
56
60
static strConstant cstrTypes = "Variable|String|WAVE|NVAR|SVAR|DFREF|FUNCREF|STRUCT|char|uchar|int16|uint16|int32|uint32|int64|uint64|float|double"
57
61
// Loosely based on the WM procedure from the documentation
@@ -324,8 +328,8 @@ Function/S formatDecl(funcOrMacro, params, subtypeTag, returnType)
324
328
End
325
329
326
330
// Adds all kind of information to a list of function in current procedure
327
- Function addDecoratedFunctions ( module, procedure, declWave, lineWave)
328
- string module , procedure
331
+ Function addDecoratedFunctions ( procedure, declWave, lineWave)
332
+ STRUCT procedure & procedure
329
333
Wave /T declWave
330
334
Wave /D lineWave
331
335
@@ -337,7 +341,7 @@ Function addDecoratedFunctions(module, procedure, declWave, lineWave)
337
341
Wave /T helpWave = getHelpWave ()
338
342
339
343
// list normal, userdefined, override and static functions
340
- options = "KIND:18,WIN:" + procedure
344
+ options = "KIND:18,WIN:" + procedure. fullname
341
345
funcList = FunctionList ( "*" , ";" , options)
342
346
numMatches = ItemsInList ( funcList)
343
347
numEntries = DimSize ( declWave, 0 )
@@ -346,12 +350,12 @@ Function addDecoratedFunctions(module, procedure, declWave, lineWave)
346
350
idx = numEntries
347
351
for ( i = 0; i < numMatches; i += 1 )
348
352
func = StringFromList ( i , funcList)
349
- fi = FunctionInfo ( module + "#" + func, procedure)
353
+ fi = FunctionInfo ( procedure . module + "#" + func, procedure. name )
350
354
if ( ! cmpstr ( func, "Procedures Not Compiled" ))
351
355
fi = ReplaceNumberByKey ( "PROCLINE" , fi, 0 )
352
356
endif
353
357
if ( isEmpty ( fi))
354
- debugPrint ( "macro or other error for " + module + "#" + func)
358
+ debugPrint ( "macro or other error for " + procedure . module + "#" + func)
355
359
endif
356
360
returnType = interpretParamType ( NumberByKey ( "RETURNTYPE" , fi) , 0, fi)
357
361
threadsafeTag = interpretThreadsafeTag ( StringByKey ( "THREADSAFE" , fi))
@@ -637,18 +641,18 @@ Function/S getVariableName(strDefinition)
637
641
return strVariableName
638
642
End
639
643
640
- static Function resetLists ( decls, lines, helps)
644
+ static Function resetLists ( decls, lines, procs, helps)
641
645
Wave /T decls
642
646
Wave /D lines
643
- Wave /T helps
644
- Redimension / N= ( 0, -1 ) decls, lines, helps
647
+ Wave /T procs , helps
648
+ Redimension / N= ( 0, -1 ) decls, lines, procs , helps
645
649
End
646
650
647
651
// @todo IgorPro >= 7 supports SortColumns
648
- static Function sortListByLineNumber ( decls, lines, helps)
652
+ static Function sortListByLineNumber ( decls, lines, procs, helps)
649
653
Wave /T decls
650
654
Wave /D lines
651
- Wave /T helps
655
+ Wave /T procs , helps
652
656
653
657
// check if sort is necessary
654
658
if ( Dimsize ( decls, 0 ) * Dimsize ( lines, 0 ) == 0 )
@@ -659,18 +663,18 @@ static Function sortListByLineNumber(decls, lines, helps)
659
663
Duplicate / T/ FREE/ R= [][ 1 ] decls, declCol1
660
664
Duplicate / T/ FREE/ R= [][ 0 ] helps, helpCol0
661
665
Duplicate / T/ FREE/ R= [][ 1 ] helps, helpCol1
662
- Sort / A lines, lines, declCol0, declCol1, helpCol0, helpCol1
666
+ Sort / A { procs , lines} , lines, procs , declCol0, declCol1, helpCol0, helpCol1
663
667
decls[][ 0 ] = declCol0 [ p][ 0 ]
664
668
decls[][ 1 ] = declCol1 [ p][ 0 ]
665
669
helps[][ 0 ] = helpCol0 [ p][ 0 ]
666
670
helps[][ 1 ] = helpCol1 [ p][ 0 ]
667
671
End
668
672
669
673
// @todo IgorPro >= 7 supports SortColumns
670
- static Function sortListByName ( decls, lines, helps)
674
+ static Function sortListByName ( decls, lines, procs, helps)
671
675
Wave /T decls
672
676
Wave /D lines
673
- Wave /T helps
677
+ Wave /T procs , helps
674
678
675
679
// check if sort is necessary
676
680
if ( Dimsize ( decls, 0 ) * Dimsize ( lines, 0 ) == 0 )
@@ -681,7 +685,7 @@ static Function sortListByName(decls, lines, helps)
681
685
Duplicate / T/ FREE/ R= [][ 1 ] decls, declCol1
682
686
Duplicate / T/ FREE/ R= [][ 0 ] helps, helpCol0
683
687
Duplicate / T/ FREE/ R= [][ 1 ] helps, helpCol1
684
- Sort / A declCol1, lines, declCol0, declCol1, helpCol0, helpCol1
688
+ Sort / A declCol1, lines, procs , declCol0, declCol1, helpCol0, helpCol1
685
689
decls[][ 0 ] = declCol0 [ p][ 0 ]
686
690
decls[][ 1 ] = declCol1 [ p][ 0 ]
687
691
helps[][ 0 ] = helpCol0 [ p][ 0 ]
@@ -706,11 +710,12 @@ Function/S parseProcedure(procedure, [checksumIsCalculated])
706
710
// load global lists
707
711
Wave /T decls = getDeclWave ()
708
712
Wave /I lines = getLineWave ()
713
+ Wave /T procs = getProcWave ()
709
714
Wave /T helps = getHelpWave ()
710
715
711
716
// scan and add elements to lists
712
- resetLists ( decls, lines, helps)
713
- addDecoratedFunctions ( procedure. module , procedure . fullName , decls, lines)
717
+ resetLists ( decls, lines, procs , helps)
718
+ addDecoratedFunctions ( procedure, decls, lines)
714
719
715
720
WAVE /T procContent = getProcedureTextAsWave ( procedure. module, procedure. fullName)
716
721
addDecoratedConstants ( procContent, decls, lines)
@@ -1070,56 +1075,102 @@ End
1070
1075
1071
1076
// Returns 1 if the procedure file has content which we can show, 0 otherwise
1072
1077
Function updateListBoxHook ()
1073
- STRUCT procedure procedure
1074
- Variable returnState
1075
1078
1076
1079
String searchString = ""
1077
1080
1078
1081
// load global lists (for sort)
1079
1082
Wave /T decls = getDeclWave ()
1080
1083
Wave /I lines = getLineWave ()
1084
+ Wave /T procs = getProcWave ()
1081
1085
Wave /T helps = getHelpWave ()
1082
1086
1083
- // get procedure information
1084
- procedure. fullName = getCurrentItem ( procedure = 1 )
1085
- procedure. name = ProcedureWithoutModule ( procedure. fullName)
1086
- procedure. module = ModuleWithoutProcedure ( procedure. fullName)
1087
- procedure. id = procedure. module + "#" + RemoveEverythingAfter ( procedure. name, ".ipf" )
1088
- procedure. row = getSaveRow ( procedure. id)
1089
-
1090
- // load procedure
1091
- returnState = saveLoad ( procedure)
1092
- if ( returnState < 0 )
1093
- debugPrint ( "parsing Procedure" )
1094
- parseProcedure ( procedure)
1095
- // return state -2 means checksum already calculated and stored in global variable.
1096
- if ( ! ( returnState == -2 ))
1097
- setCheckSum ( procedure)
1098
- endif
1099
- // save information in "database"
1100
- saveResults ( procedure)
1101
- endif
1087
+ loadProcedures ( getCurrentItem ( procedure = 1 ))
1102
1088
1103
1089
// check if search is necessary
1104
1090
searchString = getGlobalStr ( "search" )
1105
1091
if ( strlen ( searchString) > 0 )
1106
- searchAndDelete ( decls, lines, helps, searchString)
1092
+ searchAndDelete ( decls, lines, procs , helps, searchString)
1107
1093
endif
1108
1094
1109
1095
// switch sort type
1110
1096
if ( returnCheckBoxSort ())
1111
- sortListByName ( decls, lines, helps)
1097
+ sortListByName ( decls, lines, procs , helps)
1112
1098
else
1113
- sortListByLineNumber ( decls, lines, helps)
1099
+ sortListByLineNumber ( decls, lines, procs , helps)
1114
1100
endif
1115
1101
1116
1102
return DimSize ( decls, 0 )
1117
1103
End
1118
1104
1119
- Function searchAndDelete ( decls, lines, helps, searchString)
1105
+ /// @brief load procedure(s)
1106
+ ///
1107
+ /// @see generateProcedureList
1108
+ ///
1109
+ /// @param fullName Procedure identifier from procList
1110
+ Function loadProcedures ( fullName)
1111
+ string fullName
1112
+
1113
+ variable returnState, i , numProcedures, oldDecls, numDecls
1114
+ STRUCT procedure procedure
1115
+ string procList = "" , niceList = ""
1116
+
1117
+ WAVE /T decls = getDeclWave ()
1118
+ WAVE /I lines = getLineWave ()
1119
+ Wave /T procs = getProcWave ()
1120
+ WAVE /T helps = getHelpWave ()
1121
+
1122
+ Make / FREE/ T/ N= ( 1, 2 ) fullDecls
1123
+ Make / FREE/ I / N= ( 1, 1 ) fullLines
1124
+ Make / FREE/ T/ N= ( 1, 1 ) fullProcs
1125
+ Make / FREE/ T/ N= ( 1, 2 ) fullHelps
1126
+
1127
+ procList = fullName
1128
+ if ( ! cmpstr ( fullName, CB_selectAll))
1129
+ procList = ""
1130
+ getProcedureList ( procList, niceList)
1131
+ endif
1132
+
1133
+ numProcedures = ItemsInList ( procList)
1134
+ numDecls = 0
1135
+ for ( i = 0; i < numProcedures; i += 1 )
1136
+ procedure. fullName = StringFromList ( i , procList)
1137
+ procedure. name = ProcedureWithoutModule ( procedure. fullName)
1138
+ procedure. module = ModuleWithoutProcedure ( procedure. fullName)
1139
+ procedure. id = procedure. module + "#" + RemoveEverythingAfter ( procedure. name, ".ipf" )
1140
+ procedure. row = getSaveRow ( procedure. id)
1141
+
1142
+ returnState = saveLoad ( procedure)
1143
+ if ( returnState < 0 )
1144
+ debugPrint ( "parsing Procedure" )
1145
+ parseProcedure ( procedure)
1146
+ if ( ! ( returnState == -2 )) // checksum stored in global variable.
1147
+ setCheckSum ( procedure)
1148
+ endif
1149
+ saveResults ( procedure)
1150
+ endif
1151
+
1152
+ oldDecls = numDecls
1153
+ numDecls += DimSize ( decls, 0 )
1154
+ if ( oldDecls == numDecls)
1155
+ continue
1156
+ endif
1157
+ Redimension / N= ( numDecls, -1 ) fullDecls, fullLines, fullProcs, fullHelps
1158
+ fullDecls[ oldDecls, numDecls - 1 ] = decls[ p - oldDecls]
1159
+ fullLines[ oldDecls, numDecls - 1 ] = lines[ p - oldDecls]
1160
+ fullProcs[ oldDecls, numDecls - 1 ] = procedure. fullName
1161
+ fullHelps[ oldDecls, numDecls - 1 ] = helps[ p - oldDecls]
1162
+ endfor
1163
+
1164
+ Duplicate / O/ T fullDecls decls
1165
+ Duplicate / O/ I fullLines lines
1166
+ Duplicate / O/ T fullHelps helps
1167
+ Duplicate / O/ T fullProcs procs
1168
+ End
1169
+
1170
+ Function searchAndDelete ( decls, lines, procs, helps, searchString)
1120
1171
Wave /T decls
1121
1172
Wave /I lines
1122
- Wave /T helps
1173
+ Wave /T procs , helps
1123
1174
String searchString
1124
1175
1125
1176
Variable i , numEntries
@@ -1131,16 +1182,16 @@ Function searchAndDelete(decls, lines, helps, searchString)
1131
1182
1132
1183
for ( i = numEntries - 1; i > 0; i -= 1 )
1133
1184
if ( strsearch ( decls[ i ][ 1 ] , searchString, 0, 2 ) == -1 )
1134
- DeletePoints / M=0 i , 1, decls, lines, helps
1185
+ DeletePoints / M=0 i , 1, decls, lines, procs , helps
1135
1186
endif
1136
1187
endfor
1137
1188
1138
1189
// prevent loss of dimension if no match was found at all.
1139
1190
if ( strsearch ( decls[ 0 ][ 1 ] , searchString, 0, 2 ) == -1 )
1140
1191
if ( Dimsize ( decls, 0 ) == 1 )
1141
- Redimension / N= ( 0, -1 ) decls, lines, helps
1192
+ Redimension / N= ( 0, -1 ) decls, lines, procs , helps
1142
1193
else
1143
- DeletePoints / M=0 i , 1, decls, lines, helps
1194
+ DeletePoints / M=0 i , 1, decls, lines, procs , helps
1144
1195
endif
1145
1196
endif
1146
1197
End
@@ -1155,24 +1206,22 @@ Function DeletePKGfolder()
1155
1206
End
1156
1207
1157
1208
// Shows the line/function for the function/macro with the given index into decl
1158
- // With no index just the procedure file is shown
1159
- Function showCode ( procedure, [ index] )
1160
- string procedure
1209
+ Function showCode ( index)
1161
1210
variable index
1162
1211
1163
- if ( ParamIsDefault ( index))
1164
- DisplayProcedure / W=$ procedure
1165
- return NaN
1166
- endif
1212
+ string procedure
1167
1213
1168
1214
Wave /T decl = getDeclWave ()
1169
1215
Wave /I lines = getLineWave ()
1216
+ Wave /T procs = getProcWave ()
1170
1217
1171
1218
if ( ! ( index >= 0 ) || index >= DimSize ( decl, 0 ) || index >= DimSize ( lines, 0 ))
1172
1219
Abort "Index out of range"
1173
1220
endif
1174
1221
1222
+ procedure = procs[ index]
1175
1223
if ( lines[ index] < 0 )
1224
+ debugPrint ( "No line definition found for selected item." )
1176
1225
string func = getShortFuncOrMacroName ( decl[ index][ 1 ])
1177
1226
DisplayProcedure / W=$ procedure func
1178
1227
else
@@ -1182,7 +1231,13 @@ End
1182
1231
1183
1232
// Returns a list of all procedures windows in ProcGlobal context
1184
1233
Function /S getGlobalProcWindows ()
1185
- string procList = getProcWindows ( "*" , "INDEPENDENTMODULE:0" )
1234
+ string filter, procList
1235
+
1236
+ filter = getGlobalStr ( "procFilter" )
1237
+ if ( ! cmpstr ( filter, "" ))
1238
+ filter = "*"
1239
+ endif
1240
+ procList = getProcWindows ( filter, "INDEPENDENTMODULE:0" )
1186
1241
1187
1242
return AddToItemsInList ( procList, suffix= " [ProcGlobal]" )
1188
1243
End
@@ -1191,8 +1246,13 @@ End
1191
1246
Function /S getIMProcWindows ( moduleName)
1192
1247
string moduleName
1193
1248
1194
- string regexp
1195
- sprintf regexp, "* [%s]" , moduleName
1249
+ string regexp, filter
1250
+
1251
+ filter = getGlobalStr ( "procFilter" )
1252
+ if ( ! cmpstr ( filter, "" ))
1253
+ filter = "*"
1254
+ endif
1255
+ sprintf regexp, "%s [%s]" , filter, moduleName
1196
1256
return getProcWindows ( regexp, "INDEPENDENTMODULE:1" )
1197
1257
End
1198
1258
@@ -1259,6 +1319,22 @@ Function/Wave getLineWave()
1259
1319
return wv
1260
1320
End
1261
1321
1322
+ /// @brief Get a wave which holds the procedures' full name
1323
+ ///
1324
+ /// @see getLineWave
1325
+ ///
1326
+ /// @returns 1D Wave having the procedure fullname in each row.
1327
+ Function /Wave getProcWave ()
1328
+ DFREF dfr = createDFWithAllParents ( pkgFolder)
1329
+ WAVE /Z/ T/ SDFR= dfr wv = $ procedureWave
1330
+
1331
+ if ( ! WaveExists ( wv))
1332
+ Make / T dfr:$ procedureWave/Wave = wv
1333
+ endif
1334
+
1335
+ return wv
1336
+ End
1337
+
1262
1338
// 2D-Wave with Strings
1263
1339
// Return refrence to (string) Wave/T
1264
1340
static Function/Wave getSaveStrings ()
0 commit comments