@@ -53,9 +53,11 @@ static strConstant cstrTypes = "Variable|String|WAVE|NVAR|SVAR|DFREF|FUNCREF|STR
53
53
// Loosely based on the WM procedure from the documentation
54
54
// Returns a human readable string for the given parameter/return type.
55
55
// See the documentation for FunctionInfo for the exact values.
56
- Function /S interpretParamType ( ptype, paramOrReturn)
56
+ Function /S interpretParamType ( ptype, paramOrReturn, funcInfo )
57
57
variable ptype, paramOrReturn
58
+ string funcInfo
58
59
60
+ string typeName
59
61
string typeStr = ""
60
62
61
63
if ( paramOrReturn != 0 && paramOrReturn != 1 )
@@ -117,7 +119,11 @@ Function/S interpretParamType(ptype, paramOrReturn)
117
119
elseif ( ptype & 0x100 )
118
120
typeStr += "dfref"
119
121
elseif ( ptype & 0x200 )
120
- typeStr += "struct"
122
+ if ( GetStructureArgument ( funcInfo, typeName))
123
+ typeStr += typeName
124
+ else
125
+ typeStr += "struct"
126
+ endif
121
127
elseif ( ptype & 0x400 )
122
128
typeStr += "funcref"
123
129
endif
@@ -191,7 +197,7 @@ Function/S interpretParameters(funcInfo)
191
197
192
198
for ( i = 0; i < numParams; i += 1 )
193
199
sprintf key, "PARAM_%d_TYPE" , i
194
- paramType = interpretParamType ( NumberByKey ( key, funcInfo) , 1 )
200
+ paramType = interpretParamType ( NumberByKey ( key, funcInfo) , 1, funcInfo )
195
201
196
202
if ( i == numParams - numOptParams)
197
203
str += "["
@@ -211,6 +217,34 @@ Function/S interpretParameters(funcInfo)
211
217
return str
212
218
End
213
219
220
+ // check if Function has as a structure as first parameter
221
+ //
222
+ // the structure definition has to be in the first line after the function definition
223
+ //
224
+ // @param[in] funcInfo output of FunctionInfo for the function in question
225
+ // @param[out] structureName matched name of the structure as string.
226
+ // Not changed if 0 is returned.
227
+ //
228
+ // @returns 1 if function has such a parameter, 0 otherwise
229
+ Function GetStructureArgument ( funcInfo, structureName)
230
+ string funcInfo
231
+ string & structureName
232
+
233
+ string declaration, re, str0
234
+
235
+ if ( NumberByKey ( "PARAM_0_TYPE" , funcInfo) & ( 0x200 | 0x1000 )) // struct | pass-by-reference
236
+ declaration = getFunctionLine ( 1, funcInfo)
237
+ re = "(?i)^\s *struct\s +(\w +)\s +"
238
+ SplitString / E= ( re) declaration, str0
239
+ if ( V_flag == 1 )
240
+ structureName = str0
241
+ return 1
242
+ endif
243
+ endif
244
+
245
+ return 0
246
+ End
247
+
214
248
// Returns a cmd for the given fill *and* stroke color
215
249
Function /S getColorDef ( color)
216
250
string color
@@ -313,7 +347,7 @@ Function addDecoratedFunctions(module, procedure, declWave, lineWave)
313
347
if ( isEmpty ( fi))
314
348
debugPrint ( "macro or other error for " + module + "#" + func)
315
349
endif
316
- returnType = interpretParamType ( NumberByKey ( "RETURNTYPE" , fi) ,0 )
350
+ returnType = interpretParamType ( NumberByKey ( "RETURNTYPE" , fi) , 0, fi )
317
351
threadsafeTag = interpretThreadsafeTag ( StringByKey ( "THREADSAFE" , fi))
318
352
specialTag = interpretSpecialTag ( StringByKey ( "SPECIAL" , fi))
319
353
subtypeTag = interpretSubtypeTag ( StringByKey ( "SUBTYPE" , fi))
@@ -339,7 +373,7 @@ Function addDecoratedConstants(module, procedureWithoutModule, declWave, lineWav
339
373
String procText, re, def, name
340
374
341
375
// get procedure code
342
- procText = getProcedureText ( module, procedureWithoutModule)
376
+ procText = getProcedureText ( "" , 0, module, procedureWithoutModule)
343
377
numLines = ItemsInList ( procText, "\r " )
344
378
345
379
// search code and return wavLineNumber
@@ -382,7 +416,7 @@ Function addDecoratedMacros(module, procedureWithoutModule, declWave, lineWave)
382
416
String procText, re, def, name, arguments, type
383
417
384
418
// get procedure code
385
- procText = getProcedureText ( module, procedureWithoutModule)
419
+ procText = getProcedureText ( "" , 0, module, procedureWithoutModule)
386
420
numLines = ItemsInList ( procText, "\r " )
387
421
388
422
// search code and return wavLineNumber
@@ -428,7 +462,7 @@ Function addDecoratedStructure(module, procedureWithoutModule, declWave, lineWav
428
462
string procText, reStart, reEnd, name, StaticKeyword
429
463
430
464
// get procedure code
431
- procText = getProcedureText ( module, procedureWithoutModule)
465
+ procText = getProcedureText ( "" , 0, module, procedureWithoutModule)
432
466
numLines = ItemsInList ( procText, "\r " )
433
467
if ( numLines == 0 )
434
468
debugPrint ( "no Content in Procedure " + procedureWithoutModule)
@@ -498,7 +532,7 @@ Function addDecoratedMenu(module, procedureWithoutModule, declWave, lineWave)
498
532
String currentMenu = ""
499
533
500
534
// get procedure code
501
- procText = getProcedureText ( module, procedureWithoutModule)
535
+ procText = getProcedureText ( "" , 0, module, procedureWithoutModule)
502
536
numLines = ItemsInList ( procText, "\r " )
503
537
504
538
// search code and return wavLineNumber
@@ -878,18 +912,57 @@ Function/S nicifyProcedureList(list)
878
912
return niceList
879
913
End
880
914
881
- // returns code of procedure in module
915
+ // Get the specified line of code from a function
882
916
//
883
- // @param module independent module
884
- // @param procedure procedure without module definition
885
- Function /S getProcedureText ( module, procedure)
886
- string module, procedure
917
+ // @see getProcedureText
918
+ //
919
+ // @param funcInfo output of FunctionInfo for the function in question
920
+ // @param lineNo line number relative to the function definition
921
+ // set to -1 to return lines before the procedure that are not part of the preceding macro or function
922
+ // see `DisplayHelpTopic ( "ProcedureText" ) `
923
+ //
924
+ // @returns lines of code from a function inside a procedure file
925
+ Function /S getFunctionLine ( lineNo, funcInfo)
926
+ variable lineNo
927
+ string funcInfo
928
+
929
+ string funcName, module, procedure, context
930
+ variable linesOfContext
931
+
932
+ funcName = StringByKey ( "NAME" , funcInfo)
933
+ module = StringByKey ( "INDEPENDENTMODULE" , funcInfo)
934
+ procedure = StringByKey ( "PROCWIN" , funcInfo)
935
+
936
+ linesOfContext = lineNo < 0 ? lineNo : 0
937
+ context = getProcedureText ( funcName, linesOfContext, module, procedure)
938
+
939
+ if ( lineNo < 0 )
940
+ return context
941
+ endif
942
+
943
+ return StringFromList ( lineNo, context, "\r " )
944
+ End
945
+
946
+ // get code of procedure in module
947
+ //
948
+ // see `DisplayHelpTopic ( "ProcedureText" ) `
949
+ //
950
+ // @param funcName Name of Function. Leave blank to get full procedure text
951
+ // @param linesOfContext line numbers in addition to the function definition. Set to 0 to return only the function.
952
+ // set to -1 to return lines before the procedure that are not part of the preceding macro or function
953
+ // @param module independent module
954
+ // @param procedure procedure without module definition
955
+ // @return multi-line string with function definition
956
+ Function /S getProcedureText ( funcName, linesOfContext, module, procedure)
957
+ string funcName, module, procedure
958
+ variable linesOfContext
887
959
888
960
if ( ! isProcGlobal ( module))
961
+ debugPrint ( procedure + " is not in ProcGlobal" )
889
962
procedure = procedure + " [" + module + "]"
890
963
endif
891
964
892
- return ProcedureText ( "" , 0 , procedure)
965
+ return ProcedureText ( funcName , linesOfContext , procedure)
893
966
End
894
967
895
968
// Returns 1 if the procedure file has content which we can show, 0 otherwise
@@ -1152,7 +1225,7 @@ static Function setCheckSum(procedure)
1152
1225
1153
1226
timer = timerStart ()
1154
1227
1155
- procText = getProcedureText ( procedure. module, procedure. name)
1228
+ procText = getProcedureText ( "" , 0, procedure. module, procedure. name)
1156
1229
returnValue = setGlobalStr ( "parsingChecksum" , Hash ( procText, 1 ))
1157
1230
1158
1231
setCheckSumTime ( timerStop ( timer))
0 commit comments