Skip to content

Commit

Permalink
v2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
genius257 committed Jul 7, 2018
1 parent c332752 commit 8282ebd
Show file tree
Hide file tree
Showing 14 changed files with 1,699 additions and 793 deletions.
608 changes: 431 additions & 177 deletions AutoItObject_Internal.au3

Large diffs are not rendered by default.

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

## [Unreleased]

## [2.0.0] - 2017-07-07
### Added
- This CHANGELOG.md file
- CONTRIBUTING.md file
- Tests
- __get
- __set
- __assign
- __freeze
- __isFrozen
- __isSealed
- __preventExtensions
- __isExtensible
- __lookupGetter
- __lookupSetter
- __seal
- __case
- internal use function __AOI_PropertyGetFromName
- internal use function __AOI_PropertyGetFromId
- internal use function __AOI_PropertyCreate
- internal use function __AOI_GetPtrOffset
- internal use function __AOI_GetPtrValue

### Changed
- Moved project to it's own repository
- __defineGetter and __defineSetter now also supports strings as second argument
- __destructor now also supports strings as first argument
- Split docs from readme into /docs/index.md
- documentation blocks are now following a more standardized docblock standard.

### Removed
- __lock

### Fixed
- desctructor pointer wrong offset after lock propterty was added to the object structure.

## [1.0.3] - 2017-08-11
### Added
Expand Down
8 changes: 4 additions & 4 deletions Examples/04 - Advanced - Practical example.au3
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Func GUI($title, $width = Default, $height = Default, $left = Default, $top = De
$IDispatch.__defineGetter("onExit", Wnd_onExit)
$IDispatch.__defineGetter("graphics", Wnd_graphics)
$IDispatch.__destructor(Wnd_Destructor)
$IDispatch.__lock
$IDispatch.__preventExtensions
Return $IDispatch
EndFunc

Expand Down Expand Up @@ -138,7 +138,7 @@ Func Wnd_graphics($oSelf)
$IDispatch.__defineGetter("DrawRect", Graphics_DrawRect)
$IDispatch.__defineGetter("FillRect", Graphics_FillRect)
$IDispatch.__destructor(Graphics_Dispose)
$IDispatch.__lock
$IDispatch.__preventExtensions
$oSelf.val = $IDispatch
Return $IDispatch
EndIf
Expand Down Expand Up @@ -171,7 +171,7 @@ Func Pen($color=Default, $width=Default)
$IDispatch.__defineSetter("hwnd", PrivateProperty);PrivateProperty is defined in AutoItObject_Internal.au3
$IDispatch.__defineGetter("color", Pen_color)
$IDispatch.__destructor(Pen_Dispose)
$IDispatch.__lock
$IDispatch.__preventExtensions
Return $IDispatch
EndFunc

Expand All @@ -191,7 +191,7 @@ Func Brush($color=Default)
$IDispatch.__defineSetter("hwnd", PrivateProperty);PrivateProperty is defined in AutoItObject_Internal.au3
$IDispatch.__defineGetter("color", Brush_color)
$IDispatch.__destructor(Brush_Dispose)
$IDispatch.__lock
$IDispatch.__preventExtensions
Return $IDispatch
EndFunc

Expand Down
164 changes: 0 additions & 164 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,167 +16,3 @@ EndFunc
MsgBox(0, "", $myCar.DisplayCar)
```

## **TODO:**
* ~Garbage collection~ **_Added in v1.0.3 with the exception of interface methods_**
* ~Method support~ **_Added in v0.1.2_**
* ~Support for more/all AutoIt variable-types~ **_Added in v1.0.0_**
* ~Accessors~ **_Added in v0.1.0_**
* Inheritance
* ~equivalent of @error and @extended~ **_Added in v1.0.0_**


## **Methods:**

### __defineGetter

#### **Syntax**

__defineGetter("property", Function)

#### **Description:**

set the get-accessor

#### **Parameters:**

Type | Name | description
--- | --- | ---
String | "property" | The property to set the get accessor
Function | Function | Function to be called when getting the property value

### __defineSetter

#### **Syntax**

__defineSetter("property", Function)

#### **Description:**

set the set-accessor

#### **Parameters:**

Type | Name | description
--- | --- | ---
String | "property" | The property to set the get accessor
Function | Function | Function to be called when setting the property value

### __keys

#### **Syntax**

__keys()

#### **Description:**

get all property names defined in object

#### **Parameters:**

Type | Name | description
--- | --- | ---

### __unset

#### **Syntax**

__unset("property")

#### **Description:**

delete a property from the object

#### **Parameters:**

Type | Name | description
--- | --- | ---
String | "property" | The property to delete

### __lock

#### **Syntax**

__lock()

#### **Description:**

prevents creation/changing of any properties, except values in already defined properties. To prevent value change of a property, use `__defineSetter`

#### **Parameters:**

Type | Name | description
--- | --- | ---

### __destructor

#### **Syntax**

__destructor(DestructorFunction)

#### **Description:**

DestructorFunction is called when the lifetime of the object ends

Type | Name | description
--- | --- | ---
Function | DestructorFunction | Function to be called when lifetime of the object ends

## **Other**

### Function

#### **Syntax**

Function([AccessorObject])

#### **Description:**

The callback function used with accessors
Function is a placeholder for the application-defined function name

#### **Parameters:**

Type | Name | description
--- | --- | ---
IDispatch | AccessorObject | A IDispatch object used to access passed data and self

### AccessorObject

#### **Description:**

A locked IDispatch object, used with Accessor callback Function

#### **Properties:**

Type | Name | description | Access
--- | --- | --- | ---
IDispatch | parent | The IDispatch object containing the accessor.<br/>**WARNING:** accessing other properties via this object will still trigger accessors. Be careful | Read only
IDispatch | arguments | A locked IDispatch object.<br />For more info, see ArgumentsObject
*Any* | ret | The value passed in the set-accessor. This is not used by the get-accessor | Read and Write
*Any* | val | The value of the property the accessor is bound to | Read and Write

### ArgumentsObject

#### **Description:**

A locked IDispatch object, used with the AccessorObject

#### **Properties:**

Type | Name | description | Access
--- | --- | --- | ---
int32 | length | number of arguments passed with the call | Read and Write
Array | values | the arguments passed with the call | Read and Write

### DestructorFunction([self])

#### **Description:**

the callback function used with destructors

#### **Parameters:**

Type | Name | description
--- | --- | ---
IDispatch | self | The IDispatch object containing the destructor
86 changes: 86 additions & 0 deletions Tests/Collection class.au3
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#include "..\AutoItObject_Internal.au3"

Func Collection($items)
Local $class = IDispatch()

$class.__name = "Collection"
$class.__defineSetter("__name", PrivateProperty)
$class.__defineGetter("getArrayableItems", Collection_getArrayableItems)
$class.items = $class.getArrayableItems($items)
$class.__defineSetter("items", PrivateProperty)
$class.__defineGetter("get", Collection_Get)

Return $class
EndFunc

Func Collection_Get($this)
Local $arguments = $this.arguments
Local $length = $arguments.length
If $length<1 Or $length>2 Then Return SetError(1)
Local $items = $arguments.values
Local $path = StringSplit($items[0], ".", 2)
Local $return = $this.parent.items
Local $value
For $segment In $path
$value = Execute("$return["&$segment&"]")
If @error==0 Then
$return = $value
ContinueLoop
EndIf
$value = Execute("$return['"&$segment&"']")
If @error==0 Then
$return = $value
ContinueLoop
EndIf
If IsObj($items) And Execute("$items.__name") == "Collection" Then
$value = $return.items.get($segment)
If @error==0 Then
$return = $value
ContinueLoop
EndIf
Else
$value = Execute("$return."&$segment)
If @error==0 Then
$return = $value
ContinueLoop
EndIf
EndIf
Return $length==2?$items[1]:Null;SetError(2, 0, $length==2?$items[1]:Null)
Next
Return $return
EndFunc

Func Collection_getArrayableItems($this)
Local $arguments = $this.arguments
If $arguments.length <> 1 Then Return SetError(1)
Local $items = $arguments.values[0]
If IsArray($items) Then
Return $items
ElseIf IsObj($items) And Execute("$items.__name") == "Collection" Then
Return $items.items
Else
Local $return = [$items]
Return $return
EndIf
EndFunc

#cs
$oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc")
Func _ErrFunc($oError)
ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _
@TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _
@TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _
@TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _
@TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _
@TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _
@TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _
@TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _
@TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _
@TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF)
EndFunc
#ce

$a = "success"
$collection = Collection($a)
MsgBox(0, "", $collection.get("0.0", "failure"));FIXME: currently does not support multi-dimentional
Exit
Loading

0 comments on commit 8282ebd

Please sign in to comment.