@@ -26,27 +26,25 @@ class ITL_InterfaceWrapper extends ITL.ITL_WrapperBaseClass
26
26
, INVOKEKIND_FUNC := 1
27
27
, VT_USERDEFINED := 29 , VT_RECORD := 36 , VT_UNKNOWN := 13 , VT_PTR := 26
28
28
, TYPEKIND_RECORD := 1 , TYPEKIND_INTERFACE := 3
29
- local paramCount, dispparams, rgvarg := 0 , hr, info, dispid := DISPID_UNKNOWN, instance, excepInfo, err_index := - 1 , result, variant, index := - 1 , funcdesc := 0 , vt, fnFill ; , fn
29
+ local paramCount, dispparams, rgvarg := 0 , hr, info, dispid := DISPID_UNKNOWN, typeName, instance, excepInfo, err_index := - 1 , result, variant, index := - 1 , funcdesc := 0 , vt, fnFill ; , fn
30
30
, refHandle, refInfo := 0 , refAttr := 0 , refKind, tdesc, indirectionLevel
31
31
32
32
paramCount := params.maxIndex () > 0 ? params.maxIndex () : 0 ; the ternary is necessary, otherwise it would hold an empty string, causing calculations to fail
33
33
, info := this.base[ITL.Properties.TYPE_TYPEINFO]
34
34
, instance := this[ITL.Properties.INSTANCE_POINTER]
35
+ , typeName := this.base[ITL.Properties.TYPE_NAME]
35
36
36
37
; init structures
37
38
if (VarSetCapacity (dispparams, sizeof_DISPPARAMS, 00 ) < sizeof_DISPPARAMS)
38
39
{
39
- ; throw Exception("Out of memory.", -1)
40
40
throw Exception(ITL_FormatException(" Out of memory" , " Memory allocation for DISPPARAMS failed." , ErrorLevel )* )
41
41
}
42
42
if (VarSetCapacity (result, sizeof_VARIANT, 00 ) < sizeof_VARIANT)
43
43
{
44
- ; throw Exception("Out of memory.", -1)
45
44
throw Exception(ITL_FormatException(" Out of memory" , " Memory allocation for the result VARIANT failed." , ErrorLevel )* )
46
45
}
47
46
if (VarSetCapacity (excepInfo, sizeof_EXCEPINFO, 00 ) < sizeof_EXCEPINFO)
48
47
{
49
- ; throw Exception("Out of memory.", -1)
50
48
throw Exception(ITL_FormatException(" Out of memory" , " Memory allocation for EXCEPINFO failed." , ErrorLevel )* )
51
49
}
52
50
@@ -63,9 +61,8 @@ class ITL_InterfaceWrapper extends ITL.ITL_WrapperBaseClass
63
61
}
64
62
}
65
63
*/
66
- ; throw Exception("GetIDsOfNames() for """ method """ failed.", -1, ITL_FormatError(hr))
67
- throw Exception(ITL_FormatException(" Failed to call a method."
68
- , " ITypeInfo::GetIDsOfNames() for "" " method " "" failed."
64
+ throw Exception(ITL_FormatException(" Failed to call method "" " typeName " ::" method " ()"" !"
65
+ , " ITypeInfo::GetIDsOfNames() failed."
69
66
, ErrorLevel , hr
70
67
, dispid ! = DISPID_UNKNOWN, " Invalid DISPID: " dispid)* )
71
68
}
@@ -78,28 +75,25 @@ class ITL_InterfaceWrapper extends ITL.ITL_WrapperBaseClass
78
75
hr := DllCall (NumGet (NumGet (info+ 0 ), 24 * A_PtrSize , " Ptr" ), " Ptr" , info, " UInt" , dispid, " UInt" , INVOKEKIND_FUNC, " UInt*" , index) ; ITypeInfo2::GetFuncIndexOfMemId(_this, dispid, invkind, [out] index)
79
76
if (ITL_FAILED(hr) || index == - 1 )
80
77
{
81
- ; throw Exception("ITypeInfo2::GetFuncIndexOfMemId() failed.", -1, ITL_FormatError(hr))
82
- throw Exception(ITL_FormatException(" Failed to call a method."
83
- , " ITypeInfo2::GetFuncIndexOfMemId() for "" " method " "" failed."
78
+ throw Exception(ITL_FormatException(" Failed to call method "" " typeName " ::" method " ()"" !"
79
+ , " ITypeInfo2::GetFuncIndexOfMemId() failed."
84
80
, ErrorLevel , hr
85
81
, index == - 1 , " Invalid function index: " index)* )
86
82
}
87
83
88
84
hr := DllCall (NumGet (NumGet (info+ 0 ), 05 * A_PtrSize , " Ptr" ), " Ptr" , info, " UInt" , index, " Ptr*" , funcdesc) ; ITypeInfo::GetFuncDesc(_this, index, [out] funcdesc)
89
85
if (ITL_FAILED(hr) || ! funcdesc)
90
86
{
91
- ; throw Exception("ITypeInfo::GetFuncDesc() failed.", -1, ITL_FormatError(hr))
92
- throw Exception(ITL_FormatException(" Failed to call a method."
93
- , " ITypeInfo::GetFuncDesc() for "" " method " "" (index " index " ) failed."
87
+ throw Exception(ITL_FormatException(" Failed to call method "" " typeName " ::" method " ()"" !"
88
+ , " ITypeInfo::GetFuncDesc() failed (index " index " )."
94
89
, ErrorLevel , hr
95
90
, ! funcdesc, " Invalid FUNCDESC pointer: " funcdesc)* )
96
91
}
97
92
98
93
paramArray := NumGet (1 * funcdesc, 04 + A_PtrSize , " Ptr" ) ; FUNCDESC::lprgelemdescParam
99
94
if (! paramArray)
100
95
{
101
- ; throw Exception("Array of parameter descriptions could not be read.", -1)
102
- throw Exception(ITL_FormatException(" Failed to call a method."
96
+ throw Exception(ITL_FormatException(" Failed to call method "" " typeName " ::" method " ()"" !"
103
97
, " The array of parameter descriptions (FUNCDESC::lprgelemdescParam) could not be read."
104
98
, ErrorLevel , ""
105
99
, ! paramArray, " Invalid ELEMDESC[] pointer: " paramArray)* )
@@ -129,15 +123,15 @@ class ITL_InterfaceWrapper extends ITL.ITL_WrapperBaseClass
129
123
hr := DllCall (NumGet (NumGet (info+ 0 ), 14 * A_PtrSize , " Ptr" ), " Ptr" , info, " UInt" , refHandle, " Ptr*" , refInfo, " Int" ) ; ITypeInfo::GetRefTypeInfo()
130
124
if (ITL_FAILED(hr) || ! refInfo)
131
125
{
132
- throw Exception(ITL_FormatException(" Failed to call a method. "
126
+ throw Exception(ITL_FormatException(" Failed to call method "" " typeName " :: " method " () "" ! "
133
127
, " ITypeInfo::GetRefTypeInfo() for param " A_Index " (handle: " refHandle " ) failed."
134
128
, ErrorLevel , hr
135
129
, ! refInfo, " Invalid ITypeInfo pointer: " refInfo)* )
136
130
}
137
131
hr := DllCall (NumGet (NumGet (refInfo+ 0 ), 03 * A_PtrSize , " Ptr" ), " Ptr" , refInfo, " Ptr*" , refAttr, " Int" ) ; ITypeInfo::GetTypeAttr()
138
132
if (ITL_FAILED(hr) || ! refAttr)
139
133
{
140
- throw Exception(ITL_FormatException(" Failed to call a method. "
134
+ throw Exception(ITL_FormatException(" Failed to call method "" " typeName " :: " method " () "" ! "
141
135
, " ITypeInfo::GetTypeAttr() for param " A_Index " failed."
142
136
, ErrorLevel , hr
143
137
, ! refAttr, " Invalid TYPEATTR pointer: " refAttr)* )
@@ -156,7 +150,7 @@ class ITL_InterfaceWrapper extends ITL.ITL_WrapperBaseClass
156
150
{
157
151
if (indirectionLevel < 1 )
158
152
{
159
- throw Exception(ITL_FormatException(" Failed to call a method. "
153
+ throw Exception(ITL_FormatException(" Failed to call method "" " typeName " :: " method " () "" ! "
160
154
, " Interfaces cannot be passed by value."
161
155
, ErrorLevel , ""
162
156
, indirectionLevel < 1 , " Invalid indirection level: " indirectionLevel)* )
@@ -166,7 +160,7 @@ class ITL_InterfaceWrapper extends ITL.ITL_WrapperBaseClass
166
160
else
167
161
{
168
162
ObjRelease(refInfo) ; cleanup
169
- throw Exception(ITL_FormatException(" Failed to call a method. "
163
+ throw Exception(ITL_FormatException(" Failed to call method "" " typeName " :: " method " () "" ! "
170
164
, " Cannot handle other wrappers than interfaces and structures."
171
165
, ErrorLevel , "" )* )
172
166
}
@@ -207,13 +201,12 @@ class ITL_InterfaceWrapper extends ITL.ITL_WrapperBaseClass
207
201
if (fnFill)
208
202
DllCall (fnFill, " Ptr" , & excepInfo)
209
203
hr := (hr := NumGet (excepInfo, 08 + 5 * A_PtrSize , " Int" )) ? hr : NumGet (excepInfo, 00 , " UShort" ) ; get EXCEPINFO::scode or EXCEPINFO::wCode
210
- throw Exception(ITL_FormatException(" Failed to call a method. "
204
+ throw Exception(ITL_FormatException(" Failed to call method "" " typeName " :: " method " () "" ! "
211
205
, " The called method raised an exception: Source="" " StrGet (NumGet (excepInfo, 04 , " Ptr" )) " "" , Message="" " StrGet (NumGet (excepInfo, 04 + A_PtrSize , " Ptr" )) " "" "
212
206
, ErrorLevel , hr)* )
213
207
}
214
- ; throw Exception("""" method "()"" could not be called.", -1, ITL_FormatError(hr))
215
- throw Exception(ITL_FormatException(" Failed to call a method."
216
- , " ITypeInfo::Invoke() failed for "" " method " "" ."
208
+ throw Exception(ITL_FormatException(" Failed to call method "" " typeName " ::" method " ()"" !"
209
+ , " ITypeInfo::Invoke() failed."
217
210
, ErrorLevel , hr
218
211
, (hr == DISP_E_TYPEMISMATCH || hr == DISP_E_PARAMNOTFOUND || hr == DISP_E_BADVARTYPE), " Invalid argument: #" err_index)* )
219
212
}
@@ -228,37 +221,34 @@ class ITL_InterfaceWrapper extends ITL.ITL_WrapperBaseClass
228
221
static DISPATCH_PROPERTYGET := 0x2 , DISPATCH_METHOD := 0x1
229
222
, DISPID_UNKNOWN := - 1
230
223
, sizeof_DISPPARAMS := 8 + 2 * A_PtrSize , sizeof_EXCEPINFO := 12 + 5 * A_PtrSize , sizeof_VARIANT := 8 + 2 * A_PtrSize
231
- local dispparams, hr, info, dispid := DISPID_UNKNOWN, instance, excepInfo, err_index, result
224
+ local dispparams, hr, info, dispid := DISPID_UNKNOWN, instance, excepInfo, err_index, result, typeName
232
225
233
226
if (property ! = " base" && ! ITL.Properties.IsInternalProperty(property)) ; ignore base and internal properties (handled by ITL_WrapperBaseClass)
234
227
{
235
228
; init structures
236
229
if (VarSetCapacity (dispparams, sizeof_DISPPARAMS, 00 ) ! = sizeof_DISPPARAMS)
237
230
{
238
- ; throw Exception("Out of memory.", -1)
239
231
throw Exception(ITL_FormatException(" Out of memory" , " Memory allocation for DISPPARAMS failed." , ErrorLevel )* )
240
232
}
241
233
if (VarSetCapacity (result, sizeof_VARIANT, 00 ) ! = sizeof_VARIANT)
242
234
{
243
- ; throw Exception("Out of memory.", -1)
244
235
throw Exception(ITL_FormatException(" Out of memory" , " Memory allocation for the result VARIANT failed." , ErrorLevel )* )
245
236
}
246
237
if (VarSetCapacity (excepInfo, sizeof_EXCEPINFO, 00 ) ! = sizeof_EXCEPINFO)
247
238
{
248
- ; throw Exception("Out of memory.", -1)
249
239
throw Exception(ITL_FormatException(" Out of memory" , " Memory allocation for EXCEPINFO failed." , ErrorLevel )* )
250
240
}
251
241
252
242
info := this.base[ITL.Properties.TYPE_TYPEINFO]
253
243
, instance := this[ITL.Properties.INSTANCE_POINTER]
244
+ , typeName := this.base[ITL.Properties.TYPE_NAME]
254
245
255
246
; get MEMBERID for the method to be retrieved:
256
247
hr := DllCall (NumGet (NumGet (info+ 0 ), 10 * A_PtrSize , " Ptr" ), " Ptr" , info, " Str*" , property, " UInt" , 1 , " UInt*" , dispid, " Int" ) ; ITypeInfo::GetIDsOfNames()
257
248
if (ITL_FAILED(hr) || dispid == DISPID_UNKNOWN)
258
249
{
259
- ; throw Exception("GetIDsOfNames() for """ property """ failed.", -1, ITL_FormatError(hr))
260
- throw Exception(ITL_FormatException(" Failed to retrieve a property."
261
- , " ITypeInfo::GetIDsOfNames() for "" " property " "" failed."
250
+ throw Exception(ITL_FormatException(" Failed to retrieve property "" " typeName " ::" property " "" !"
251
+ , " ITypeInfo::GetIDsOfNames() failed."
262
252
, ErrorLevel , hr
263
253
, dispid == DISPID_UNKNOWN, " Invalid DISPID: " dispid)* )
264
254
}
@@ -268,9 +258,8 @@ class ITL_InterfaceWrapper extends ITL.ITL_WrapperBaseClass
268
258
hr := DllCall (NumGet (NumGet (info+ 0 ), 11 * A_PtrSize , " Ptr" ), " Ptr" , info, " Ptr" , instance, " UInt" , dispid, " UShort" , DISPATCH_METHOD | DISPATCH_PROPERTYGET, " Ptr" , & dispparams, " Ptr" , & result, " Ptr" , & excepInfo, " Ptr" , 0 , " Int" ) ; ITypeInfo::Invoke()
269
259
if (ITL_FAILED(hr))
270
260
{
271
- ; throw Exception("""" property """ could not be retrieved.", -1, ITL_FormatError(hr))
272
- throw Exception(ITL_FormatException(" Failed to retrieve a property."
273
- , " ITypeInfo::Invoke() for "" " property " "" failed."
261
+ throw Exception(ITL_FormatException(" Failed to retrieve property "" " typeName " ::" property " "" !"
262
+ , " ITypeInfo::Invoke() failed."
274
263
, ErrorLevel , hr)* )
275
264
}
276
265
return ITL_VARIANT_GetValue(& result) ; return the result, i.e. the value of the property
@@ -287,7 +276,7 @@ class ITL_InterfaceWrapper extends ITL.ITL_WrapperBaseClass
287
276
, sizeof_DISPPARAMS := 8 + 2 * A_PtrSize , sizeof_EXCEPINFO := 12 + 5 * A_PtrSize
288
277
, VT_UNKNOWN := 13 , VT_DISPATCH := 9
289
278
, DISP_E_MEMBERNOTFOUND := - 2147352573
290
- local variant, dispparams, hr, info, dispid := DISPID_UNKNOWN, vt, instance, excepInfo, err_index := 0 , variant
279
+ local variant, dispparams, hr, info, dispid := DISPID_UNKNOWN, vt, instance, excepInfo, err_index := 0 , variant, typeName
291
280
292
281
; need to store it that way as "DISPID_PROPERTYPUT := -3, &DISPID_PROPERTYPUT" would be a STRING address
293
282
if (! DISPID_PROPERTYPUT)
@@ -298,12 +287,10 @@ class ITL_InterfaceWrapper extends ITL.ITL_WrapperBaseClass
298
287
; init structures
299
288
if (VarSetCapacity (dispparams, sizeof_DISPPARAMS, 00 ) ! = sizeof_DISPPARAMS)
300
289
{
301
- ; throw Exception("Out of memory.", -1)
302
290
throw Exception(ITL_FormatException(" Out of memory" , " Memory allocation for DISPPARAMS failed." , ErrorLevel )* )
303
291
}
304
292
if (VarSetCapacity (excepInfo, sizeof_EXCEPINFO, 00 ) ! = sizeof_EXCEPINFO)
305
293
{
306
- ; throw Exception("Out of memory.", -1)
307
294
throw Exception(ITL_FormatException(" Out of memory" , " Memory allocation for EXCEPINFO failed." , ErrorLevel )* )
308
295
}
309
296
@@ -317,14 +304,14 @@ class ITL_InterfaceWrapper extends ITL.ITL_WrapperBaseClass
317
304
318
305
info := this.base[ITL.Properties.TYPE_TYPEINFO]
319
306
, instance := this[ITL.Properties.INSTANCE_POINTER]
307
+ , typeName := this.base[ITL.Properties.TYPE_NAME]
320
308
321
309
; get MEMBERID for the property to be set:
322
310
hr := DllCall (NumGet (NumGet (info+ 0 ), 10 * A_PtrSize , " Ptr" ), " Ptr" , info, " Str*" , property, " UInt" , 1 , " UInt*" , dispid, " Int" ) ; ITypeInfo::GetIDsOfNames()
323
311
if (ITL_FAILED(hr) || dispid == DISPID_UNKNOWN) ; an error code was returned or the ID is invalid
324
312
{
325
- ; throw Exception("GetIDsOfNames() for """ property """ failed.", -1, ITL_FormatError(hr))
326
- throw Exception(ITL_FormatException(" Failed to set a property."
327
- , " ITypeInfo::GetIDsOfNames() for "" " property " "" failed."
313
+ throw Exception(ITL_FormatException(" Failed to set property "" " typeName " ::" property " "" to "" " value " "" !"
314
+ , " ITypeInfo::GetIDsOfNames() failed."
328
315
, ErrorLevel , hr
329
316
, dispid == DISPID_UNKNOWN, " Invalid DISPID: " dispid)* )
330
317
}
@@ -342,9 +329,8 @@ class ITL_InterfaceWrapper extends ITL.ITL_WrapperBaseClass
342
329
}
343
330
else if (hr ! = DISP_E_MEMBERNOTFOUND) ; if member not found, retry below with DISPATCH_PROPERTYPUT
344
331
{
345
- ; throw Exception("""" property """ could not be set.", -1, ITL_FormatError(hr)) ; otherwise an error occured
346
- throw Exception(ITL_FormatException(" Failed to set a property."
347
- , " ITypeInfo::Invoke() for "" " property " "" failed."
332
+ throw Exception(ITL_FormatException(" Failed to set property "" " typeName " ::" property " "" to "" " value " "" !" ; otherwise an error occured
333
+ , " ITypeInfo::Invoke() failed."
348
334
, ErrorLevel , hr)* )
349
335
}
350
336
}
@@ -354,9 +340,8 @@ class ITL_InterfaceWrapper extends ITL.ITL_WrapperBaseClass
354
340
hr := DllCall (NumGet (NumGet (info+ 0 ), 11 * A_PtrSize , " Ptr" ), " Ptr" , info, " Ptr" , instance, " UInt" , dispid, " UShort" , DISPATCH_PROPERTYPUT, " Ptr" , & dispparams, " Ptr*" , 0 , " Ptr" , & excepInfo, " UInt*" , err_index, " Int" ) ; ITypeInfo::Invoke()
355
341
if (ITL_FAILED(hr))
356
342
{
357
- ; throw Exception("""" property """ could not be set.", -1, ITL_FormatError(hr))
358
- throw Exception(ITL_FormatException(" Failed to set a property."
359
- , " ITypeInfo::Invoke() for "" " property " "" failed."
343
+ throw Exception(ITL_FormatException(" Failed to set property "" " typeName " ::" property " "" to "" " value " "" !"
344
+ , " ITypeInfo::Invoke() failed."
360
345
, ErrorLevel , hr)* )
361
346
}
362
347
return value ; return the original value to allow "a := obj.prop := value" and similar
0 commit comments