Jump to content

tylo

Developers
  • Posts

    270
  • Joined

  • Last visited

1 Follower

About tylo

  • Birthday 07/05/1964

Profile Information

  • Location
    Norway

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

tylo's Achievements

Universalist

Universalist (6/7)

2

Reputation

  1. This should be present in the documentation of IsDeclared(), if it isn't already.
  2. I guess that would be nice. However it's a little work involved (even if I use code from autoit). On the other hand, "declaring" functions to be used from a plugin dll is nice documentation of where the function is coming from. e.g.$hDll = PluginOpen("my.dll") #Compiler_PlugIn_Funcs=myfunc ... myfunc("Parm") ... PluginClose($hDll) @jpm: I'll look at it - thanks.
  3. You won't have to... Au3Check v1.54: - added: Support for #compiler_plugin_funcs=<func-list> directive. - replaced: -U option with -v 3. Output format is a little changed. JdeB: I wanted native support for this directive so it works outside of Scite too. The native support won't conflict with the external support you made, but you can remove it in next Scite release.
  4. Au3Check 1.53: - Fixed: Extended block nesting levels from 20 to 128. - Added: Allow callback args in Call(). Replace the line %Call 1 <UDF> to %Call 1 <UDF_P> in the .dat file for this to work.
  5. v1.52 released. Ok, not much response on 1.51, but v1.52 produces a very easy to use list of unreferenced functions and variables. For various reasons, the -u option, which produced a list of referenced symbols, is no longer available because it is inaccurate. -U now produces a list of line segments that can be removed, e.g C:\Program Files\AutoIt3\Include\Array.au3(115,1) : (153): _ArrayDeleteIt means that the code in lines 115-153 in Array.au3 can be removed from a compiled script. For variables, a pragmatic approach is used. It only lists explicitly declared global variables that are not referenced later. If many variables are declared on one line, only the first variable is listed - if none of the variables are referenced. e.g. 21: Global $var1, $var2 = 1, _ 22: $var3lists only the first variable if none of the variables are referenced later. Line 21-22 is output for removal: C:\test\test.au3(21,1) : (22): $var1This approach is required for Enums BTW, because if one enum value is referenced, the whole group of enums should be concidered referenced. (taking away one, changes the value of the subsequent enums). Note also that a declared global variable which is initialized with a function or an expression containing a function is concidered referenced. This is because the function may have side effects and therefore the line should not be removed (even though the declared variable is never referenced later). The directive #uses introduced in 1.51 is now renamed to #forceref, as jpm specified. Again it has two purposes, one is to avoid -w 5 warnings: Func _ArrayCreate($v_0, $v_1 = 0, $v_2 = 0, $v_3 = 0, $v_4 = 0, $v_5 = 0, $v_6 = 0, $v_7 = 0, $v_8 = 0, $v_9 = 0, $v_10 = 0, $v_11 = 0, $v_12 = 0, $v_13 = 0, $v_14 = 0, $v_15 = 0, $v_16 = 0, $v_17 = 0, $v_18 = 0, $v_19 = 0, $v_20 = 0) #forceref $v_0, $v_1, $v_2, $v_3, $v_4, $v_5, $v_6, $v_7, $v_8, $v_9, $v_10, $v_11, $v_12, $v_13, $v_14, $v_15, $v_16, $v_17, $v_18, $v_19, $v_20 Local $i_UBound = @NumParams Local $av_Array[$i_UBound] Local $i_Index For $i_Index = 0 To ($i_UBound - 1) $av_Array[$i_Index] = Eval("v_" & String($i_Index)) Next Return $av_Array EndFunc ;==>_ArrayCreateThe other purpose of #forceref is to avoid global variables and functions to appear in the unreference symbols list, e.g. if called via Call($fn). Note 1: you can use -U - to output unreference symbols to stdout. Note 2: au3check.dat must contain a line with: "*COM_EventObj" in order to accept the macro @COM_EventObj used as a COM object. Please check the .dat file.
  6. au3check v1.51: fixed: unused global variables was not in the listadded: file and position reference to all symbols when using -u or -U. You may use dash - to output to stdout."unused" global variables that are initialized with a function-expr are now in the used list (-u)reverted to -w 5 as in v1.49. -w 6 is now warn on Dim.added: new directive: #uses follwed by a comma separated list of function and/or variable names. It serves two purposes:to prevent unused local vars warnings (-w 5) to force inclusion of symbols in the used list (-u)Maybe it would be better with only one symbol list which had marked used/unused, and sorted by file/pos/symbol. There are additionally a few issues I want to discuss on this. Later.Cheers.
  7. It shouldn't be a necessary for all library code to pass all warning test, IMO. For example where Eval() is used (e.g in ArrayCreate), you'll have to make dummy code (as Valik showed) to avoid them. A warnings flags that there may be a logical error or unclean code, but it may also be perfectly correct code. jpm: I intended to add file and line references to where symbols are defined, but forgot it. You'll have to wait for next release. However, I now have concerns for how useful the -u and -U options are, because they can not detect usage of functions and variables accessed via Call($fnName) and Eval($varName). That's the downside of introducing such flexible functionality. au3check is clever enough to detect usage of callback functions set in e.g. AdlibEnable("myadlib"), as long as the function names are given as string literals, which is normally the case - but not so for Call() and Eval(). The other concern is how to utilize the produced lists to remove unused code. When I add file and line reference to definitions of the symbols, it should be easy to exclude non-used functions by simply cutting the lines where these are defined. However, global variables are more tricky. Valik's concerns with unused vars initialized with a function, put me on the track. E.g. in Global $g_app, $g_status = MyInit()$g_status may not be used by any code, but MyInit() must for sure be called, so you cannot simply remove the line. That would also falsely remove the $g_app declaration. In any case, when multiple variables are declared on the same line, the line probably must be batch edited to remove certain declarations. So there are two cases where you should keep lines of code containing unused variable declarations: 1) When multiple global variables are declared on one line, and some are unused, don't bother to remove certain variable declarations - just keep the line. 2) When a variable is initialized with an expression that contains a function call, I will not mark that variable as unused as of next version (even though it may not never be used), because the function call itself must be retained. I.e the line will be kept.
  8. -w 5 is a quasi check, but warns on declared (and possible initialized) only variables, like in your first example. Your second code actually accesses $var again by assigning to it (but it is still not used), so it let it pass. -w 5 in v1.49 is now -w 6, and is stricter. Only local variables are warned on, so unused declared local variables cannot be modified by a different function as a side effect. You'll have to pass it as a ByRef, and in that case it will be used, and no warnings are issued.
  9. Version 1.50! added: accept @COM_EventObj as a COM object. You can add macros to the .dat file that are accepted as COM object like: *COM_EventObj. @COM_EventObj must be added previously too.fixed: ReDim not allowed as variable declarator and initialization is not allowed.fixed: -u usedsym.txt now includes functions referenced as "callbacks".new option: -U unusedsym.txt creates a list of defined, but not used global symbols.warning option: -w 5 (warn on unused local variables. No warning for variables assigned to after declaration). Default off.warning option: -w 6 (warn on unused local variables. Stricter than -w 5). Default off.warning option: -w 7 (warn when using Dim as variable declarator. Note that no warning is issued when Dim is used on an existing variable, because Dim is then an "operator" like ReDim, and not a declarator). Default off.compiled with VC++ 6.Cheers.
  10. Ok, I'll disable the warning by default. MHz's _Test() function only assigns values to $i - it never actually uses it in an expression. But it incorrectly throws a warning, because in a For loop you may use the control variable simply as a counter to repeat N times, without accessing $i inside the loop. Will fix that too. I could relax it somewhat, so code like this does not throw a warning: Local $var $var = 1I.e. declaration alone will produce warning, but an additional assignment to it will count as usage (although it is not). Will at least consider it. v1.50 will treat @COM_EventObj as a COM variable, and allow COM method/attributes calls on it. If it is likely that more macros will become COM object, I should either allow to add entries in the .dat file (more work), or open for every macro to be accessed as COM objects.
  11. Yeah, the new version detects a misspelling in the .dat file. Change the second last line from %TraySetItemOnEvent 2 <UDF> to %TrayItemSetOnEvent 2 <UDF>
  12. Happy new Year. I've uploaded au3check v1.49 - Optional warning for variables declared, but not used in function (default on). - Reverted to disallow empty arguments in COM method calls. For the other developers, I have added a new option: -u <file>. This outputs a near minimum[*] list of UDFs and global variable names that are actually used in your program. This lists the functions and global var declarations that must be part of your program - all other funcs and global var declarations can be removed. Should be very useful when compiling to exe to reduce size of the executable. Simple example: Global $g_W = 1024 Global $g_Y = 2006 Global $g_N = NextYear() MsgBox(0, "Year", $g_N) Exit Func NextYear() Verify($g_Y) Return $g_Y + 1 EndFunc Func Verify($y) Return ($y = @YEAR) EndFunc Func NotUsed($dummy) Local $t = 1 Return 0 EndFunc Using option -u out.txt will output: $N $Y NextYear Verify Note that NotUsed($dummy) is not part of the list, and that $dummy and $t gets warnings that they are not used. Can be turned off with the option: -w- 5 [*] If you have $A = 1 and $B = $A, au3check will consider $A as used because it is a right hand side expression. However, if $B is never used as a RHS expression, $A wouldn't need to be included in the list either, but this is a minor thing. However, the list of functions is a true minimum. Cheers
  13. Uh, you tell me. I only remeber that Sven added that syntax at some point. I think MS languages allow it on COM objects. Not sure if it was changed to require 'default' later in autoit.
  14. I've uploaded au3check v1.48 Just two minor updates: - Allow empty expressions as COM method args. E.g: $obj.method(1,,,,$val) - Allow multiple tabs/spaces before cont. char _.
  15. Au3Check 1.47 released. Uploaded to public au3check area - link from first post.
×
×
  • Create New...