Skip to content

Commit c332752

Browse files
committed
Initial commit for independent repository with standardized format and guidelines
1 parent 00ec666 commit c332752

14 files changed

Lines changed: 1041 additions & 26 deletions

AutoItObject_Internal.au3

Lines changed: 38 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,43 @@
88
#include <Memory.au3>
99
#include <WinAPISys.au3>
1010

11-
Global Const $IID_IUnknown = "{00000000-0000-0000-C000-000000000046}"
12-
Global Const $IID_IDispatch = "{00020400-0000-0000-C000-000000000046}"
13-
Global Const $IID_IConnectionPointContainer = "{B196B284-BAB4-101A-B69C-00AA00341D07}"
14-
15-
Global Const $DISPATCH_METHOD = 1
16-
Global Const $DISPATCH_PROPERTYGET = 2
17-
Global Const $DISPATCH_PROPERTYPUT = 4
18-
Global Const $DISPATCH_PROPERTYPUTREF = 8
19-
20-
Global Const $DISP_E_UNKNOWNINTERFACE = 0x80020001
21-
Global Const $DISP_E_MEMBERNOTFOUND = 0x80020003
22-
Global Const $DISP_E_PARAMNOTFOUND = 0x80020004
23-
Global Const $DISP_E_TYPEMISMATCH = 0x80020005
24-
Global Const $DISP_E_UNKNOWNNAME = 0x80020006
25-
Global Const $DISP_E_NONAMEDARGS = 0x80020007
26-
Global Const $DISP_E_BADVARTYPE = 0x80020008
27-
Global Const $DISP_E_EXCEPTION = 0x80020009
28-
Global Const $DISP_E_OVERFLOW = 0x8002000A
29-
Global Const $DISP_E_BADINDEX = 0x8002000B
30-
Global Const $DISP_E_UNKNOWNLCID = 0x8002000C
31-
Global Const $DISP_E_ARRAYISLOCKED = 0x8002000D
32-
Global Const $DISP_E_BADPARAMCOUNT = 0x8002000E
33-
Global Const $DISP_E_PARAMNOTOPTIONAL = 0x8002000F
34-
Global Const $DISP_E_BADCALLEE = 0x80020010
35-
Global Const $DISP_E_NOTACOLLECTION = 0x80020011
11+
If Not IsDeclared("IID_IUnknown") Then Global Const $IID_IUnknown = "{00000000-0000-0000-C000-000000000046}"
12+
If Not IsDeclared("IID_IDispatch") Then Global Const $IID_IDispatch = "{00020400-0000-0000-C000-000000000046}"
13+
If Not IsDeclared("IID_IConnectionPointContainer") Then Global Const $IID_IConnectionPointContainer = "{B196B284-BAB4-101A-B69C-00AA00341D07}"
14+
15+
If Not IsDeclared("DISPATCH_METHOD") Then Global Const $DISPATCH_METHOD = 1
16+
If Not IsDeclared("DISPATCH_PROPERTYGET") Then Global Const $DISPATCH_PROPERTYGET = 2
17+
If Not IsDeclared("DISPATCH_PROPERTYPUT") Then Global Const $DISPATCH_PROPERTYPUT = 4
18+
If Not IsDeclared("DISPATCH_PROPERTYPUTREF") Then Global Const $DISPATCH_PROPERTYPUTREF = 8
19+
20+
If Not IsDeclared("S_OK") Then Global Const $S_OK = 0x00000000
21+
If Not IsDeclared("E_NOTIMPL") Then Global Const $E_NOTIMPL = 0x80004001
22+
If Not IsDeclared("E_NOINTERFACE") Then Global Const $E_NOINTERFACE = 0x80004002
23+
If Not IsDeclared("E_POINTER") Then Global Const $E_POINTER = 0x80004003
24+
If Not IsDeclared("E_ABORT") Then Global Const $E_ABORT = 0x80004004
25+
If Not IsDeclared("E_FAIL") Then Global Const $E_FAIL = 0x80004005
26+
If Not IsDeclared("E_ACCESSDENIED") Then Global Const $E_ACCESSDENIED = 0x80070005
27+
If Not IsDeclared("E_HANDLE") Then Global Const $E_HANDLE = 0x80070006
28+
If Not IsDeclared("E_OUTOFMEMORY") Then Global Const $E_OUTOFMEMORY = 0x8007000E
29+
If Not IsDeclared("E_INVALIDARG") Then Global Const $E_INVALIDARG = 0x80070057
30+
If Not IsDeclared("E_UNEXPECTED") Then Global Const $E_UNEXPECTED = 0x8000FFFF
31+
32+
If Not IsDeclared("DISP_E_UNKNOWNINTERFACE") Then Global Const $DISP_E_UNKNOWNINTERFACE = 0x80020001
33+
If Not IsDeclared("DISP_E_MEMBERNOTFOUND") Then Global Const $DISP_E_MEMBERNOTFOUND = 0x80020003
34+
If Not IsDeclared("DISP_E_PARAMNOTFOUND") Then Global Const $DISP_E_PARAMNOTFOUND = 0x80020004
35+
If Not IsDeclared("DISP_E_TYPEMISMATCH") Then Global Const $DISP_E_TYPEMISMATCH = 0x80020005
36+
If Not IsDeclared("DISP_E_UNKNOWNNAME") Then Global Const $DISP_E_UNKNOWNNAME = 0x80020006
37+
If Not IsDeclared("DISP_E_NONAMEDARGS") Then Global Const $DISP_E_NONAMEDARGS = 0x80020007
38+
If Not IsDeclared("DISP_E_BADVARTYPE") Then Global Const $DISP_E_BADVARTYPE = 0x80020008
39+
If Not IsDeclared("DISP_E_EXCEPTION") Then Global Const $DISP_E_EXCEPTION = 0x80020009
40+
If Not IsDeclared("DISP_E_OVERFLOW") Then Global Const $DISP_E_OVERFLOW = 0x8002000A
41+
If Not IsDeclared("DISP_E_BADINDEX") Then Global Const $DISP_E_BADINDEX = 0x8002000B
42+
If Not IsDeclared("DISP_E_UNKNOWNLCID") Then Global Const $DISP_E_UNKNOWNLCID = 0x8002000C
43+
If Not IsDeclared("DISP_E_ARRAYISLOCKED") Then Global Const $DISP_E_ARRAYISLOCKED = 0x8002000D
44+
If Not IsDeclared("DISP_E_BADPARAMCOUNT") Then Global Const $DISP_E_BADPARAMCOUNT = 0x8002000E
45+
If Not IsDeclared("DISP_E_PARAMNOTOPTIONAL") Then Global Const $DISP_E_PARAMNOTOPTIONAL = 0x8002000F
46+
If Not IsDeclared("DISP_E_BADCALLEE") Then Global Const $DISP_E_BADCALLEE = 0x80020010
47+
If Not IsDeclared("DISP_E_NOTACOLLECTION") Then Global Const $DISP_E_NOTACOLLECTION = 0x80020011
3648

3749
Global Const $tagVARIANT = "ushort vt;ushort r1;ushort r2;ushort r3;PTR data;PTR data2"
3850
Global Const $tagDISPPARAMS = "ptr rgvargs;ptr rgdispidNamedArgs;dword cArgs;dword cNamedArgs;"
@@ -617,4 +629,4 @@ EndFunc
617629

618630
Func PrivateProperty()
619631
Return SetError(1, 1, 0)
620-
EndFunc
632+
EndFunc

CHANGELOG.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Changelog
2+
All notable changes to this project will be documented in this file
3+
4+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
5+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6+
7+
## [Unreleased]
8+
### Added
9+
- This CHANGELOG.md file
10+
- CONTRIBUTING.md file
11+
- Tests
12+
13+
## [1.0.3] - 2017-08-11
14+
### Added
15+
- __desctructor
16+
- Garbage collection, with the exception of interface methods
17+
18+
## [1.0.2] - 2017-08-09
19+
### Added
20+
- Parameters for assigning custom methods as IDispatch object internal functionality
21+
- __keys
22+
- PrivateProperty method for ease of use, when making private IDispatch object properties
23+
24+
## [1.0.1] - 2016-08-06
25+
### Added
26+
- Local scope for internal variables used by IDispatch object functionality
27+
28+
## [1.0.0] - 2016-08-06
29+
### Added
30+
- README.md file
31+
- __unset
32+
- __lock
33+
- Accessors can set error code via setError
34+
- Supprt for __all__ AutoIt variable types
35+
36+
## [0.1.2] - 2016-12-21
37+
### Added
38+
- __defineMethod
39+
- Method support for objects
40+
41+
## [0.1.1] - 2016-11-25
42+
### Changed
43+
- Fix script breaking typo in Idispatch function, reported by [Chimp on the AutoIt forum thread](https://www.autoitscript.com/forum/topic/185720-autoitobject-pure-autoit/#elComment_1333941)
44+
45+
## [0.1.0] - 2016-11-24
46+
### Added
47+
- First iteration of the AutoItObject_Internal library
48+
- Accessors via __defineGetter and __defineSetter

CONTRIBUTING.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Contributing
2+
3+
## Using the issue tracker
4+
5+
The issue tracker on GitHub is the preferred channel for bug reports and feature requests.
6+
7+
## Pull requests
8+

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2017 genius257
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Tests/Exporter/Exporter.au3

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#include-once
2+
;https://github.com/sebastianbergmann/exporter/blob/2.0/src/Exporter.php
3+
4+
Func Au3ExporterExporter_Export($value, $indentation = 0)
5+
Return Au3ExporterExporter_RecursiveExport($value, $indentation)
6+
EndFunc
7+
8+
Func Au3ExporterExporter_RecursiveExport(ByRef $value, $indentation, $processed = Null)
9+
If $value == Null Then Return "null"
10+
11+
If $value == True Then Return "true"
12+
13+
If $value == False Then Return "false"
14+
15+
If IsFloat($value) And Int($value) == $value Then Return StringFormat("%s.0", $value)
16+
17+
If IsPtr($value) Or IsHWnd($value) Then Return StringFormat("resource(%d) of type (%s)", $value, VarGetType($value))
18+
19+
if IsString($value) Then
20+
If StringRegExp("[^\x09-\x0d\x1b\x20-\xff]", $value) Then Return "Binary String: 0x" & $value ;https://github.com/sebastianbergmann/exporter/blob/2.0/src/Exporter.php#L235
21+
22+
Return "'" & StringRegExpReplace($value, "(\r\n|\n\r|\r)", @CRLF) & "'"
23+
EndIf
24+
25+
Local $whitespace = StringRepeat(" ", 4 * $indentation)
26+
27+
;~ If Not $processed Then $processed = new Context
28+
29+
;Local $key = $processed->contains($value)
30+
If IsArray($value) Then
31+
#cs
32+
If Not $key == False Then Return "Array &" & $key
33+
34+
Local $array = $value
35+
$key = $processed->add($value)
36+
$values = ""
37+
38+
If UBound($array) > 0 Then
39+
Local $k
40+
For $k=0 To UBound($array)-1
41+
Local $v = $array[$k]
42+
$values &= StringFormat("%s %s => %s" & @CRLF, $whitespace, Au3ExporterExporter_RecursiveExport($k, $indentation), Au3ExporterExporter_RecursiveExport($value($k), $indentation + 1, $processed))
43+
Next
44+
Local $values = "\n" & $values & $whitespace
45+
EndIf
46+
Return StringFormat("Array &%s (%s)", $key, $values)
47+
#ce
48+
EndIf
49+
50+
If IsObj($value) Then
51+
#cs
52+
Local $class = get_class($value)
53+
54+
Local $hash = $processed->contains($value)
55+
If $hash Then Return StringFormat("%s Object &%s", $class, $hash)
56+
57+
$hash = $processed->add($value)
58+
$values = ""
59+
$array = $this->toArray($value)
60+
61+
If UBound($array) > 0 Then
62+
Local $k
63+
For $k=0 To UBound($array)-1
64+
Local $v = $array[$k]
65+
$values &= StringFormat("%s %s => %s" & @CRLF, $whitespace, Au3ExporterExporter_RecursiveExport($k, $indentation), Au3ExporterExporter_RecursiveExport($v, $indentation + 1, $processed))
66+
Next
67+
$values = @CRLF & $value & $whitespace
68+
EndIf
69+
Return StringFormat("%s Object &%s (%s)", $class, $hash, $values)
70+
#ce
71+
EndIf
72+
73+
;Return var_export($value)
74+
$return = String($value)
75+
Return $return?$return:VarGetType($value)
76+
EndFunc
77+
78+
Func StringRepeat($sChar, $nCount); https://www.autoitscript.com/forum/topic/140190-stringrepeat-very-fast-using-memset/
79+
$tBuffer = DLLStructCreate("char[" & $nCount & "]")
80+
DllCall("msvcrt.dll", "ptr:cdecl", "memset", "ptr", DLLStructGetPtr($tBuffer), "int", Asc($sChar), "int", $nCount)
81+
Return DLLStructGetData($tBuffer, 1)
82+
EndFunc

Tests/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
**Unit** and **Exporter** folders are a attempt to dublicate PHPUnit, but as functions only, as testing the object library with the obhject library seems like a bad idea.

0 commit comments

Comments
 (0)