Skip to content

Commit 8282ebd

Browse files
committed
v2.0.0
1 parent c332752 commit 8282ebd

14 files changed

+1699
-793
lines changed

AutoItObject_Internal.au3

Lines changed: 431 additions & 177 deletions
Large diffs are not rendered by default.

CHANGELOG.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,42 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

77
## [Unreleased]
8+
9+
## [2.0.0] - 2017-07-07
810
### Added
911
- This CHANGELOG.md file
1012
- CONTRIBUTING.md file
1113
- Tests
14+
- __get
15+
- __set
16+
- __assign
17+
- __freeze
18+
- __isFrozen
19+
- __isSealed
20+
- __preventExtensions
21+
- __isExtensible
22+
- __lookupGetter
23+
- __lookupSetter
24+
- __seal
25+
- __case
26+
- internal use function __AOI_PropertyGetFromName
27+
- internal use function __AOI_PropertyGetFromId
28+
- internal use function __AOI_PropertyCreate
29+
- internal use function __AOI_GetPtrOffset
30+
- internal use function __AOI_GetPtrValue
31+
32+
### Changed
33+
- Moved project to it's own repository
34+
- __defineGetter and __defineSetter now also supports strings as second argument
35+
- __destructor now also supports strings as first argument
36+
- Split docs from readme into /docs/index.md
37+
- documentation blocks are now following a more standardized docblock standard.
38+
39+
### Removed
40+
- __lock
41+
42+
### Fixed
43+
- desctructor pointer wrong offset after lock propterty was added to the object structure.
1244

1345
## [1.0.3] - 2017-08-11
1446
### Added

Examples/04 - Advanced - Practical example.au3

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Func GUI($title, $width = Default, $height = Default, $left = Default, $top = De
5454
$IDispatch.__defineGetter("onExit", Wnd_onExit)
5555
$IDispatch.__defineGetter("graphics", Wnd_graphics)
5656
$IDispatch.__destructor(Wnd_Destructor)
57-
$IDispatch.__lock
57+
$IDispatch.__preventExtensions
5858
Return $IDispatch
5959
EndFunc
6060

@@ -138,7 +138,7 @@ Func Wnd_graphics($oSelf)
138138
$IDispatch.__defineGetter("DrawRect", Graphics_DrawRect)
139139
$IDispatch.__defineGetter("FillRect", Graphics_FillRect)
140140
$IDispatch.__destructor(Graphics_Dispose)
141-
$IDispatch.__lock
141+
$IDispatch.__preventExtensions
142142
$oSelf.val = $IDispatch
143143
Return $IDispatch
144144
EndIf
@@ -171,7 +171,7 @@ Func Pen($color=Default, $width=Default)
171171
$IDispatch.__defineSetter("hwnd", PrivateProperty);PrivateProperty is defined in AutoItObject_Internal.au3
172172
$IDispatch.__defineGetter("color", Pen_color)
173173
$IDispatch.__destructor(Pen_Dispose)
174-
$IDispatch.__lock
174+
$IDispatch.__preventExtensions
175175
Return $IDispatch
176176
EndFunc
177177

@@ -191,7 +191,7 @@ Func Brush($color=Default)
191191
$IDispatch.__defineSetter("hwnd", PrivateProperty);PrivateProperty is defined in AutoItObject_Internal.au3
192192
$IDispatch.__defineGetter("color", Brush_color)
193193
$IDispatch.__destructor(Brush_Dispose)
194-
$IDispatch.__lock
194+
$IDispatch.__preventExtensions
195195
Return $IDispatch
196196
EndFunc
197197

README.md

Lines changed: 0 additions & 164 deletions
Original file line numberDiff line numberDiff line change
@@ -16,167 +16,3 @@ EndFunc
1616
1717
MsgBox(0, "", $myCar.DisplayCar)
1818
```
19-
20-
## **TODO:**
21-
* ~Garbage collection~ **_Added in v1.0.3 with the exception of interface methods_**
22-
* ~Method support~ **_Added in v0.1.2_**
23-
* ~Support for more/all AutoIt variable-types~ **_Added in v1.0.0_**
24-
* ~Accessors~ **_Added in v0.1.0_**
25-
* Inheritance
26-
* ~equivalent of @error and @extended~ **_Added in v1.0.0_**
27-
28-
29-
## **Methods:**
30-
31-
### __defineGetter
32-
33-
#### **Syntax**
34-
35-
__defineGetter("property", Function)
36-
37-
#### **Description:**
38-
39-
set the get-accessor
40-
41-
#### **Parameters:**
42-
43-
Type | Name | description
44-
--- | --- | ---
45-
String | "property" | The property to set the get accessor
46-
Function | Function | Function to be called when getting the property value
47-
48-
### __defineSetter
49-
50-
#### **Syntax**
51-
52-
__defineSetter("property", Function)
53-
54-
#### **Description:**
55-
56-
set the set-accessor
57-
58-
#### **Parameters:**
59-
60-
Type | Name | description
61-
--- | --- | ---
62-
String | "property" | The property to set the get accessor
63-
Function | Function | Function to be called when setting the property value
64-
65-
### __keys
66-
67-
#### **Syntax**
68-
69-
__keys()
70-
71-
#### **Description:**
72-
73-
get all property names defined in object
74-
75-
#### **Parameters:**
76-
77-
Type | Name | description
78-
--- | --- | ---
79-
80-
### __unset
81-
82-
#### **Syntax**
83-
84-
__unset("property")
85-
86-
#### **Description:**
87-
88-
delete a property from the object
89-
90-
#### **Parameters:**
91-
92-
Type | Name | description
93-
--- | --- | ---
94-
String | "property" | The property to delete
95-
96-
### __lock
97-
98-
#### **Syntax**
99-
100-
__lock()
101-
102-
#### **Description:**
103-
104-
prevents creation/changing of any properties, except values in already defined properties. To prevent value change of a property, use `__defineSetter`
105-
106-
#### **Parameters:**
107-
108-
Type | Name | description
109-
--- | --- | ---
110-
111-
### __destructor
112-
113-
#### **Syntax**
114-
115-
__destructor(DestructorFunction)
116-
117-
#### **Description:**
118-
119-
DestructorFunction is called when the lifetime of the object ends
120-
121-
Type | Name | description
122-
--- | --- | ---
123-
Function | DestructorFunction | Function to be called when lifetime of the object ends
124-
125-
## **Other**
126-
127-
### Function
128-
129-
#### **Syntax**
130-
131-
Function([AccessorObject])
132-
133-
#### **Description:**
134-
135-
The callback function used with accessors
136-
Function is a placeholder for the application-defined function name
137-
138-
#### **Parameters:**
139-
140-
Type | Name | description
141-
--- | --- | ---
142-
IDispatch | AccessorObject | A IDispatch object used to access passed data and self
143-
144-
### AccessorObject
145-
146-
#### **Description:**
147-
148-
A locked IDispatch object, used with Accessor callback Function
149-
150-
#### **Properties:**
151-
152-
Type | Name | description | Access
153-
--- | --- | --- | ---
154-
IDispatch | parent | The IDispatch object containing the accessor.<br/>**WARNING:** accessing other properties via this object will still trigger accessors. Be careful | Read only
155-
IDispatch | arguments | A locked IDispatch object.<br />For more info, see ArgumentsObject
156-
*Any* | ret | The value passed in the set-accessor. This is not used by the get-accessor | Read and Write
157-
*Any* | val | The value of the property the accessor is bound to | Read and Write
158-
159-
### ArgumentsObject
160-
161-
#### **Description:**
162-
163-
A locked IDispatch object, used with the AccessorObject
164-
165-
#### **Properties:**
166-
167-
Type | Name | description | Access
168-
--- | --- | --- | ---
169-
int32 | length | number of arguments passed with the call | Read and Write
170-
Array | values | the arguments passed with the call | Read and Write
171-
172-
### DestructorFunction([self])
173-
174-
#### **Description:**
175-
176-
the callback function used with destructors
177-
178-
#### **Parameters:**
179-
180-
Type | Name | description
181-
--- | --- | ---
182-
IDispatch | self | The IDispatch object containing the destructor

Tests/Collection class.au3

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#include "..\AutoItObject_Internal.au3"
2+
3+
Func Collection($items)
4+
Local $class = IDispatch()
5+
6+
$class.__name = "Collection"
7+
$class.__defineSetter("__name", PrivateProperty)
8+
$class.__defineGetter("getArrayableItems", Collection_getArrayableItems)
9+
$class.items = $class.getArrayableItems($items)
10+
$class.__defineSetter("items", PrivateProperty)
11+
$class.__defineGetter("get", Collection_Get)
12+
13+
Return $class
14+
EndFunc
15+
16+
Func Collection_Get($this)
17+
Local $arguments = $this.arguments
18+
Local $length = $arguments.length
19+
If $length<1 Or $length>2 Then Return SetError(1)
20+
Local $items = $arguments.values
21+
Local $path = StringSplit($items[0], ".", 2)
22+
Local $return = $this.parent.items
23+
Local $value
24+
For $segment In $path
25+
$value = Execute("$return["&$segment&"]")
26+
If @error==0 Then
27+
$return = $value
28+
ContinueLoop
29+
EndIf
30+
$value = Execute("$return['"&$segment&"']")
31+
If @error==0 Then
32+
$return = $value
33+
ContinueLoop
34+
EndIf
35+
If IsObj($items) And Execute("$items.__name") == "Collection" Then
36+
$value = $return.items.get($segment)
37+
If @error==0 Then
38+
$return = $value
39+
ContinueLoop
40+
EndIf
41+
Else
42+
$value = Execute("$return."&$segment)
43+
If @error==0 Then
44+
$return = $value
45+
ContinueLoop
46+
EndIf
47+
EndIf
48+
Return $length==2?$items[1]:Null;SetError(2, 0, $length==2?$items[1]:Null)
49+
Next
50+
Return $return
51+
EndFunc
52+
53+
Func Collection_getArrayableItems($this)
54+
Local $arguments = $this.arguments
55+
If $arguments.length <> 1 Then Return SetError(1)
56+
Local $items = $arguments.values[0]
57+
If IsArray($items) Then
58+
Return $items
59+
ElseIf IsObj($items) And Execute("$items.__name") == "Collection" Then
60+
Return $items.items
61+
Else
62+
Local $return = [$items]
63+
Return $return
64+
EndIf
65+
EndFunc
66+
67+
#cs
68+
$oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc")
69+
Func _ErrFunc($oError)
70+
ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _
71+
@TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _
72+
@TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _
73+
@TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _
74+
@TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _
75+
@TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _
76+
@TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _
77+
@TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _
78+
@TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _
79+
@TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF)
80+
EndFunc
81+
#ce
82+
83+
$a = "success"
84+
$collection = Collection($a)
85+
MsgBox(0, "", $collection.get("0.0", "failure"));FIXME: currently does not support multi-dimentional
86+
Exit

0 commit comments

Comments
 (0)