-
Notifications
You must be signed in to change notification settings - Fork 1
/
ITL_ModuleWrapper.ahk
41 lines (35 loc) · 1.38 KB
/
ITL_ModuleWrapper.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
class ITL_ModuleWrapper extends ITL.ITL_ConstantMemberWrapperBaseClass
{
__New(typeInfo, lib)
{
local Base
if (this != ITL.ITL_ModuleWrapper)
{
Base.__New(typeInfo, lib)
ObjInsert(this, "__New", Func("ITL_AbstractClassConstructor"))
}
}
__Call(method, params*)
{
static DISPID_UNKNOWN := -1, INVOKEKIND_FUNC := 1
local id := DISPID_UNKNOWN, hr := 0, addr := 0, info
info := this[ITL.Properties.TYPE_TYPEINFO]
hr := DllCall(NumGet(NumGet(info+0), 10*A_PtrSize, "Ptr"), "Ptr", info, "Str*", method, "UInt", INVOKEKIND_FUNC, "Ptr*", id, "Int") ; ITypeInfo::GetIDsOfNames()
if (ITL_FAILED(hr) || id == DISPID_UNKNOWN)
{
throw Exception(ITL_FormatException("Failed to call method """ method """ on module """ this[ITL.Properties.TYPE_NAME] """."
, "ITypeInfo::GetIDsOfNames() failed."
, ErrorLevel, hr
, id == DISPID_UNKNOWN, "Invalid DISPID: " id)*)
}
hr := DllCall(NumGet(NumGet(info+0), 15*A_PtrSize, "Ptr"), "Ptr", info, "UInt", id, "UInt", 1, "Ptr*", addr, "Int") ; ITypeInfo::AddressOfMember()
if (ITL_FAILED(hr) || !addr)
{
throw Exception(ITL_FormatException("Failed to call method """ method """ on module """ this[ITL.Properties.TYPE_NAME] """."
, "ITypeInfo::AddressOfMember() failed."
, ErrorLevel, hr
, !addr, "Invalid member address: " addr)*)
}
return DllCall(addr, params*)
}
}