list of every object type/property/method

Discuss the future of the AutoHotkey language
User avatar
jeeswg
Posts: 4309
Joined: 19 Dec 2016, 01:58
Location: UK

list of every object type/property/method

10 Feb 2018, 23:47

[updated: 2018-05-01]

- Partly in preparation for an objects tutorial, and partly in preparation for looking at updating/creating scripts to backport the AHK v2 GUI/Menu objects to AHK v1. I've created a list of AHK object types and their methods/properties.
- It is intended as a companion to this thread:
list of every command/function/variable from across all versions - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=7&t=27321&p=131642#p131642
- Please mention any issues/omissions. Thanks.

==================================================

Lists of methods/properties(/keys/meta-functions) for different object types.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus


List of object types for different objects as reported by the Type() function.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus


Script to retrieve the object type for different objects via the Type() function.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus


==================================================

List:
Object
BoundFunc Object
ClipboardAll Object
Enumerator Object
Exception Object
File Object
Func Object
GUI Object
GuiControl Object
Menu/MenuBar Object
RegExMatch Object
SafeArray

Links:
Object
https://lexikos.github.io/v2/docs/objects/Object.htm
Objects
https://lexikos.github.io/v2/docs/Objects.htm

[BoundFunc Object]
Function Objects
https://lexikos.github.io/v2/docs/objects/Functor.htm#BoundFunc

[ClipboardAll Object]
Clipboard and ClipboardAll
https://lexikos.github.io/v2/docs/misc/Clipboard.htm#clipboardall-object

[Enumerator Object]
Enumerator
https://lexikos.github.io/v2/docs/objects/Enumerator.htm

[Exception Object]
Throw
https://lexikos.github.io/v2/docs/commands/Throw.htm#Exception

File Object
https://lexikos.github.io/v2/docs/objects/File.htm

Func Object
https://lexikos.github.io/v2/docs/objects/Func.htm

GUI Object
https://lexikos.github.io/v2/docs/objects/Gui.htm

GuiControl Object
https://lexikos.github.io/v2/docs/objects/GuiControl.htm
ListView (GUI)
https://lexikos.github.io/v2/docs/commands/ListView.htm#BuiltIn
TreeView (GUI)
https://lexikos.github.io/v2/docs/commands/TreeView.htm#BuiltIn

Menu/MenuBar Object
https://lexikos.github.io/v2/docs/objects/Menu.htm

[RegExMatch Object]
RegExMatch
https://lexikos.github.io/v2/docs/commands/RegExMatch.htm#MatchObject

[SafeArray]
ComObjArray()
https://lexikos.github.io/v2/docs/commands/ComObjArray.htm

==================================================

See also:
[GuiControlGet/GuiControl sections]
v2-changes
https://autohotkey.com/v2/v2-changes.htm
ComObjType
https://lexikos.github.io/v2/docs/commands/ComObjType.htm
Type
https://lexikos.github.io/v2/docs/commands/Type.htm

==================================================

Relating to File.__Handle query:
[File.__Handle / File.Handle, which is available in which version]

Menu object - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=37&t=41973&p=191381#p191381
AutoHotkey v2 alpha (UPDATES) - Page 2 - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=37&t=2120&p=195810#p195810

==================================================

Relating to meta-functions query:
[which methods are meta-functions]

[unofficial source]
[it lists: __New, __Delete, __Get, __Set, __Call, __Init]
Classes in AHK, a Dissection (Advanced) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=7&t=6177
A meta-function is a class method that doesn't get explicitly called, but gets called when something happens to the object. Meta-functions are called from the base object not the instance.

[contradictory information in the documentation]
Objects
https://lexikos.github.io/v2/docs/Objects.htm
Meta-functions define what happens when a key is requested but not found within the target object.
...
To run code when the last reference to an object is being released, implement the __Delete meta-function.

[from an old version of the documentation, it suggests that all meta-functions are methods]
[re. the question: what is the overlap between meta-functions/methods]
Arrays of arrays and the [,,] operator. - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=278&p=2262#p2262
Meta-functions are methods defined by an object's base which can define exactly how the object should act when an unknown key is requested.

[from the AHK v1.1.28.00 source code, __New is a meta-function]
[so meta-functions mentioned in official sources: __New, __Delete, __Get, __Set, __Call]
// find and execute a specific meta-function (__new or __delete) but don't want any base
...
LPTSTR Object::sMetaFuncName[] = { _T("__Get"), _T("__Set"), _T("__Call"), _T("__Delete"), _T("__New") };


[EDIT:] Edits:
Menu.Standard -> Menu.AddStandard
Last edited by jeeswg on 01 May 2018, 18:06, edited 19 times in total.
User avatar
nnnik
Posts: 2805
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: list of every object type/property/method

11 Feb 2018, 05:56

Also Next is not a Method for all objects - it's only available for Enumerator Objects.
Recommends AHK Studio
Helgef
Posts: 2914
Joined: 17 Jul 2016, 01:02
Contact:

Re: list of every object type/property/method

11 Feb 2018, 07:01

There are (at least) three types of built-in enumerator objects,

Code: [Select all] [Download] GeSHi © Codebox Plus

Gui.Enumerator
ComObjArray.Enumerator
Object.Enumerator
User avatar
nnnik
Posts: 2805
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: list of every object type/property/method

11 Feb 2018, 08:24

I would add _NewEnum, __New,__Delete and __Init as Meta-Functions.
Without adding them the distinction between Meta-Functions and not Meta-Functions becomes pointless.
And yeah __Class is a key.
Recommends AHK Studio
User avatar
jeeswg
Posts: 4309
Joined: 19 Dec 2016, 01:58
Location: UK

Re: list of every object type/property/method

11 Feb 2018, 10:29

- @Helgef: I've added BoundFunc, it appears to only have one method, Call.
- I meant to collect a list of types returned by the Type() function, I will look into that and update the OP. Thanks. [EDIT: Done. See OP. Do notify of any omissions. Cheers.]

- @nnnik: I've split the 'Object' list into two: those items on the 'Object' page, and 'further'. 'Next' is now in the 'further' list, I believe it's better in that list, than not listed as a method for standard objects at all.
- The documentation mentions __Delete as a meta-function. I'm unsure about __Init/__New, although they seem like strong candidates. I was more unsure about _NewEnum/Next.
- Thanks re. '__Class', I've removed the question mark.
User avatar
nnnik
Posts: 2805
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: list of every object type/property/method

11 Feb 2018, 19:36

With .next you mention something that does not even exist for every object. Why?
It is only part of the enumerators, not part of any normal object.
Writing it into further is just wrong.

A distinction between 2 groups exists because there are reasons for this distinction.
If you do not find things that are unique to a specific group then there is simply no reason for the existence then we should remove it.
In order to create any valueable distinction that holds any general value you either need to remove __Delete or add __New.
Since you want to stick to the documentation and keep __Delete you need to add __New which leaves __Init and _NewEnum.
Whether you mention __Init or not. But if you do mention it it should be in the same group as __New.
Which leaves us with _NewEnum. In order to decide whether _NewEnum is a Meta Function or not we should simply compare the differences between the 2 groups.

-Methods: Called by the programmer in explicit calls. Used to modify the state the object is in or gain information about it's state.
-Meta Functions: Called by AutoHotkey when specifics actions are taken on the object. Used by the programmer to completely modify the behaviour of an object when these actions are taken.
-_NewEnum: Mostly called by AutoHotkey when the for loop is used. Can be used to completely modify how the object is enumerated during a for loop. It is rarely called manually though it is difficult to define a single reason for doing so.

I think _NewEnum is a better fit for Meta Functions than Methods and if you disagree, it might be difficult to come up with an easy distinction between methods and meta functions.
Recommends AHK Studio
Helgef
Posts: 2914
Joined: 17 Jul 2016, 01:02
Contact:

Re: list of every object type/property/method

12 Feb 2018, 05:52

I agree with nnnik.

Code: [Select all] [Download] GeSHi © Codebox Plus

[Object]
Object
e.g. MyClass [for a class instance]
Class [for a class object]


Specifically, it returns Class for an Object having a __class key. If an Object, say obj, lacks such a key it will report (recursively) obj.base.__class (or Object if not found.)

Code: [Select all] [Download] GeSHi © Codebox Plus

Object.Enumerator [for a built-in or custom object enumerator]

Object.Enumerator is only returned for built-in enumerator unless you explicitly set obj.base.__class := "Object.Enumerator".

? P base

P for property is correct.

Extra, type() can return the name of a com class object, eg,

Code: [Select all] [Download] GeSHi © Codebox Plus

ie := ComObjCreate("InternetExplorer.Application")
msgbox type(ie)
ie.quit()

Cheers

Edit, tried to clarify, on the phone. :?
User avatar
jeeswg
Posts: 4309
Joined: 19 Dec 2016, 01:58
Location: UK

Re: list of every object type/property/method

14 Feb 2018, 02:30

- @nnnik: Re. 'Next'. The key question is: what built-in methods/properties are commonly redefined in custom AHK classes, 'Next' is one of them.
- Re. distinction. Built-in AHK methods/properties are listed, they are separated based on which are listed on the 'Object' documentation page.
- Re. meta-functions. I'm concerned that potentially any method can be considered a meta-function, if you can find a roundabout justification. It might be simpler to ignore _NewEnum and Next as special cases relating to enumeration, (you yourself mentioned a distinction between built-in methods that do/don't relate to enumerators,) and thus I would settle for the same 6 meta-functions as GeekDude did in his classes tutorial: 'CDGINS'.
- ... Although I might say overall, that the question of, which methods are meta-functions, doesn't really matter, the documentation appears to contradict itself, causing confusion, and new readers may be unsure of how important the distinction is, and may try to seek clarification (which could take a lot of time, and which would yield no definitive answers at present). If there was an official source that just said: these are the meta-functions, that could bring the matter to a satisfactory close.
- ... The concept of meta-functions is at least important though, as regards working with class objects directly, there may be other points.
- Out of interest, would you consider 'Next' a meta-function, or any of the other methods that don't start with '_'? What about base or __Class?
- It looks like meta-functions are under review:
v2-thoughts
https://autohotkey.com/v2/v2-thoughts.htm

- @Helgef: Good tips about checking for the __Class key. Important information, thanks.
- Is there any good evidence that __Class is a key, and that base is a property? Perhaps that __Class has a value and works with HasKey (so is a key), and that base doesn't, however, you can assign it in a get/set like manner and it doesn't use parentheses (implying a property).
- Thanks re. Type() and COM objects, I've added a few examples above.
User avatar
nnnik
Posts: 2805
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: list of every object type/property/method

14 Feb 2018, 03:42

No none of the other methods qualify - as you have already seen by my defintion. next simply does not qualify because it modifies the behaviour of an object other than its own.
The rest does not match the definition that I gave. You can argue that enumeration is not something that should be supported by every object - however in AutoHotkey every Object is a Map/Dictionary data type - and that data type gets enumerated.
Then again _NewEnum is the only method that does not directly interfere with the normal flow of information and it doesn't need to be defined in a base either but can be in the object itself - however same goes for __New and __Init
I would call .base a meta-property simply because it defines the base object. ( a sort of meta object ). __Class is a normal key.

I see that you are having troubles ordering things accordingly if objects grow too large - thats because you don't know of interfaces yet.
I would move __New, __Set, __Get and so on to a section named "class". next does not belong there and would only add confusion.

BTW in the Exception Object everything is a normal key. They are not properties.
Recommends AHK Studio
User avatar
jeeswg
Posts: 4309
Joined: 19 Dec 2016, 01:58
Location: UK

Re: list of every object type/property/method

14 Feb 2018, 13:10

- Thanks re. the Exception object, I've corrected the OP to state keys instead of properties. Btw the documentation says 'properties', hence why I originally listed them as properties:
Throw
https://autohotkey.com/docs/commands/Throw.htm
Exception(Message [, What, Extra])

Creates an object with the following properties
- I've written some example code for checking whether something is a key or a property, here:
object classes: redefine __Set() temporarily / general queries - Page 4 - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=42674&p=200499#p200499

- Having trouble ordering what? In what way are interfaces significant?
- I've ordered everything in the OP by key/method/property, and I split any lists in the same way that the documentation did.
- I've dealt with raw interfaces where you call the methods in the verb tables directly (e.g. for Explorer), and simpler IDispatch interfaces, that AHK can handle directly e.g. COM with Internet Explorer/Excel/Word. So I'm not sure what you mean by 'don't know of interfaces yet'. Are you describing custom complex classes written in AHK as interfaces?
User avatar
nnnik
Posts: 2805
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: list of every object type/property/method

14 Feb 2018, 17:28

jeeswg wrote:- Having trouble ordering what? In what way are interfaces significant?
- I've ordered everything in the OP by key/method/property, and I split any lists in the same way that the documentation did.
- I've dealt with raw interfaces where you call the methods in the verb tables directly (e.g. for Explorer), and simpler IDispatch interfaces, that AHK can handle directly e.g. COM with Internet Explorer/Excel/Word. So I'm not sure what you mean by 'don't know of interfaces yet'. Are you describing custom complex classes written in AHK as interfaces?

Interfaces are probably only second to Inheritance when it comes to importance in OOP.
Although there is no language representation of Interfaces in Autohotkey, any decent OOP object will use them for designing purposes.

An Interface is a set of methods or properties with specific names that do specific things to a type of object.
For example Push and Pop could be part of a Stack Interface. You know what Push and Pop does. And using it on this object will have specific effects.
This is important because now any object can support this interface and any code that was written for this interface can be used with such an object.
I will explain it in detail in the Advanced OOP Tutorial - for better examples you can have a look at Java.
Recommends AHK Studio
lexikos
Posts: 5904
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: list of every object type/property/method

17 Feb 2018, 17:22

From an external/interface viewpoint, key-value pairs are a sub-type of properties. A property is just something you can get or set. The caller of an interface is not supposed to be concerned about how the property or method is implemented.

Meta-functions are not invoked like normal methods. They must be defined in the object's base, not in the object itself. If you call a method in script (or when for calls _NewEnum or Next), the __Call meta-function is invoked for that method call. This does not occur when a meta-function is invoked internally. However, this might only apply to v1.x and v2.0-alpha.

The distinction between meta-functions and normal methods should be easy, because all meta-functions are given an obvious prefix (this implies that standard methods are not given the prefix, not that the prefix has only this meaning).

nnnik wrote:Then again _NewEnum is the only method that does not directly interfere with the normal flow of information and it doesn't need to be defined in a base either but can be in the object itself - however same goes for __New and __Init
No, the same does not go for __New or __Init. When they are called by the new operator, they are called via the class object, not via the new instance. There is no way to define __Init in the object itself prior to it being called, but you can assign a value to this.__New without interfering with the __New meta-function.

Code: [Select all] [Download] GeSHi © Codebox Plus

class C {
; __new := "foo" ; Causes "Duplicate declaration."
_ := this.__new := "foo"
__new() {
MsgBox "new"
}
}
o := new C
MsgBox o.__new
If you call __New or __Init directly, they can be defined in the object itself, but the same is true for anything you call directly.

jeeswg wrote:[contradictory information in the documentation]
It could just as well have said "Methods define ..." and still been correct. It doesn't say all meta-functions.

On the other hand, it was probably written that way because __get/set/call were the only meta-functions at the time.
User avatar
jeeswg
Posts: 4309
Joined: 19 Dec 2016, 01:58
Location: UK

Re: list of every object type/property/method

17 Feb 2018, 17:59

- @lexikos: Many thanks for your detailed response.
- I read the documentation and thought: there are exactly 3 meta-functions, they are called when keys/methods aren't found. But your explanation makes a lot of sense. Also, changing(/declining) grammar standards in schools might lead people to miss meanings when older styles are used.
- Meta-functions have an obvious prefix (__Call/__Delete/__Get/__Init/__New/__Set), but what about __Class which has the same prefix (a meta-property?), base (a standard property?), _NewEnum (1 underscore to match Explorer objects perhaps, would it have 2 or 0 underscores otherwise).
- And not that it's crucially important, but, can any of the other methods, e.g. Next, be logically argued to be meta-functions? I.e. anything that you can find a way to invoke indirectly.

- I've changed my lists to use 'PK' (a property which is known to be a standard AutoHotkey array key) instead of 'K'.
- I've added the ClipboardAll Object to the list.

Return to “AutoHotkey v2 Development”

Who is online

Users browsing this forum: No registered users and 1 guest