Skip to content

Commit a751df4

Browse files
committed
v1.0.1
Fixed missing Local specification within Invoke
1 parent 13db9f2 commit a751df4

3 files changed

Lines changed: 79 additions & 6 deletions

File tree

AutoItObject_Internal.au3

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#cs ----------------------------------------------------------------------------
22
AutoIt Version : 3.3.14.2
33
Author.........: genius257
4-
Version........: 1.0.0
4+
Version........: 1.0.1
55
#ce ----------------------------------------------------------------------------
66

77
#include-once
@@ -441,7 +441,7 @@ Func Invoke($pSelf, $dispIdMember, $riid, $lcid, $wFlags, $pDispParams, $pVarRes
441441
If (Not(BitAND($wFlags, $DISPATCH_PROPERTYGET)=0)) Then
442442
$_tVARIANT = DllStructCreate($tagVARIANT, $pVarResult)
443443
If Not($tProperty.__getter = 0) Then
444-
$oIDispatch = IDispatch()
444+
Local $oIDispatch = IDispatch()
445445
$oIDispatch.val = 0
446446
$oIDispatch.ret = 0
447447
$oIDispatch.parent = ObjCreateInterface($pSelf,$IID_IDispatch)
@@ -470,7 +470,7 @@ Func Invoke($pSelf, $dispIdMember, $riid, $lcid, $wFlags, $pDispParams, $pVarRes
470470
Else
471471
$tDISPPARAMS = DllStructCreate($tagDISPPARAMS, $pDispParams)
472472
If Not ($tProperty.__setter=0) Then
473-
$oIDispatch = IDispatch()
473+
Local $oIDispatch = IDispatch()
474474
$oIDispatch.val = 0
475475
$oIDispatch.ret = 0
476476
$oIDispatch.parent = ObjCreateInterface($pSelf,$IID_IDispatch)

AutoItObject_Internal_Example.au3

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#include <WINAPI.au3>
2+
#include "AutoItObject_Internal.au3"
3+
4+
;~ #AutoIt3Wrapper_UseX64=Y
5+
;~ #AutoIt3Wrapper_Run_Au3Check=N
6+
7+
$AutoItError = ObjEvent("AutoIt.Error", "ErrFunc") ; Install a custom error handler
8+
9+
Func ErrFunc($oError)
10+
ConsoleWrite("!>COM Error !"&@CRLF&"!>"&@TAB&"Number: "&Hex($oError.Number,8)&@CRLF&"!>"&@TAB&"Windescription: "&StringRegExpReplace($oError.windescription,"\R$","")&@CRLF&"!>"&@TAB&"Source: "&$oError.source&@CRLF&"!>"&@TAB&"Description: "&$oError.description&@CRLF&"!>"&@TAB&"Helpfile: "&$oError.helpfile&@CRLF&"!>"&@TAB&"Helpcontext: "&$oError.helpcontext&@CRLF&"!>"&@TAB&"Lastdllerror: "&$oError.lastdllerror&@CRLF&"!>"&@TAB&"Scriptline: "&$oError.scriptline&@CRLF)
11+
EndFunc ;==>ErrFunc
12+
13+
$oItem = IDispatch()
14+
15+
$oItem.a = "a"
16+
$oItem.b = "b"
17+
$oItem.c = "c"
18+
$oItem.z = "z"
19+
20+
$oItem.__unset("z")
21+
22+
$oItem.__defineGetter('a',Getter)
23+
$oItem.__defineSetter('a',Setter)
24+
25+
$oItem.ab = $oItem.a&$oItem.b
26+
$oItem.abc = $oItem.a&$oItem.b&$oItem.c
27+
$oItem.abc = $oItem.abc&$oItem.abc
28+
29+
$oItem.f = Test
30+
Execute("($oItem.f)('a')");we use execute, due to Au3Check bug. For more, see: https://www.autoitscript.com/trac/autoit/ticket/3560
31+
MsgBox(0, "", "a: "&$oItem.a&@CRLF&"b: "&$oItem.b&@CRLF&"c: "&$oItem.c&@CRLF&"ab: "&$oItem.ab&@CRLF&"abc: "&$oItem.abc)
32+
$oItem.f = MsgBox
33+
Call($oItem.f,0,"","test")
34+
35+
$oItem.__lock();locking the object
36+
37+
$oItem.z = "z"; this will fail because of lock, see console. Also @error is set to non zero
38+
39+
Func Test($string)
40+
MsgBox(0, "UserFunction: Test", $string)
41+
EndFunc
42+
43+
Func Getter($oThis)
44+
Return $oThis.val&$oThis.parent.b
45+
EndFunc
46+
47+
Func Setter($oThis)
48+
$oThis.val=$oThis.ret
49+
EndFunc

README.md

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,31 @@ Provides object creation via IDispatch interface in an attempt to add more OOP t
44
**Things to be added:**
55
* Garbage collection
66
* ~Method support~ **_Added in v0.1.2_**
7-
* Support for more/all AutoIt variable-types
8-
* Accessors
7+
* ~Support for more/all AutoIt variable-types~ **_Added in v1.0.0_**
8+
* ~Accessors~ **_Added in v0.1.0_**
99
* Inheritance
10-
* equivalent of @error and @extended
10+
* ~equivalent of @error and @extended~ **_Added in v1.0.0_**
11+
12+
`__defineGetter("property", Function)`
13+
14+
set the get accessor
15+
16+
17+
`__defineSetter("property", Function)`
18+
19+
set the set accessor
20+
21+
22+
~~`__defineMethod("Property", "Function")`~~ deprecated in v1.0.0
23+
24+
~~Set a function as a property value~~
25+
26+
27+
`__unset("property")`
28+
29+
delete a property from the object
30+
31+
32+
`__lock()`
33+
34+
prevents creation/changing of any properties, except values in already defined properties. To prevent value change of a property, use `__defineSetter`

0 commit comments

Comments
 (0)