GroggyOtter / ahkv2_definition_rewrite

Full update of the definition file for THQBY's AHKv2 support addon.
66 stars 7 forks source link

ComObjQuery can be 2 or 3 parameters #6

Closed TJGinis closed 4 months ago

TJGinis commented 5 months ago

From line 14316 (as of 6/12/24):

ComObjQuery(ComObj, IIDorSID, IID) => Object

from the docs:

InterfaceComObj := ComObjQuery(ComObj, SID, IID) InterfaceComObj := ComObjQuery(ComObj, IID)

As a result VSCode reports an error for the two parameter mode.

GroggyOtter commented 5 months ago

Thanks for taking time to report this.
I've fixed it so that won't happen anymore as well as updated the parameter definitions.

This will be included in the next update.

If you want an immediate fix, open up your ahk2.d.ahk, scroll down to around line 14300, and replace the ComObjQuery JSDoc block with this one:

/**
* @description {@link https://www.autohotkey.com/docs/v2/lib/ComObjQuery.htm|`ComObjQuery()`}  
* Queries a COM object for an interface or service.  
* @param {(Object|Integer)} ComObj  
* A COM wrapper object, interface pointer, or object with a Ptr property which returns an interface pointer.  
* IIDs and SIDs use GUID format: `{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}`  
* @param {(String)} IIDorSID  
* This can be an IID (interface identifier) or an SID (service identifier) and should be in GUID format.  
* If this is a service identifier, an IID must be passed in to the 3rd param.  
* @param {(String)} [IID]  
* The 3rd parameter should be an IID (interface identifier) and only be used when the second parameter is an SID.  
* @returns {(Object)}  
* A COM wrapper object based on the IID  
* - `IID_IDispatch` => ({@link https://www.autohotkey.com/docs/v2/lib/ComObject.htm|ComObject}) VT_Dispatch (9)  
*   The script can call properties/methods using normal {@link https://www.autohotkey.com/docs/v2/Objects.htm#Usage_Objects|object syntax}.
* - `Any other IID` => ({@link https://www.autohotkey.com/docs/v2/lib/ComValue.htm|ComValue}) - VT_UNKNOWN (13)  
*   Provides a `Ptr` property that can be passed to {@link https://www.autohotkey.com/docs/v2/lib/DllCall.htm|DllCall()} or {@link https://www.autohotkey.com/docs/v2/lib/ComCall.htm|ComCall}.
* @throws Error - Any failure, such as "interface not supported."
* @see {@link https://www.autohotkey.com/docs/v2/lib/ComObjGet.htm|ComObjGet()}
* {@link https://www.autohotkey.com/docs/v2/lib/ComCall.htm|ComCall()}
* {@link https://www.autohotkey.com/docs/v2/lib/ComObjActive.htm|ComObjActive()}
* @example <caption></caption>  
* @returns {string} 
*/
ComObjQuery(ComObj, IIDorSID [, IID]) => Object
GroggyOtter commented 4 months ago

Fixed with v1.3