[Q] How to enumerate user class methods
If finding Clone() in Map Class, Clone() is found in it's prototype.
Example:
MsgBox(Map.HasProp("Clone")) ; -> true
MsgBox(Map.HasOwnProp("Clone")) ; -> false
for aName in Map.Prototype.OwnProps()
{
MsgBox(aName) ; -> __Class, ... , Clone, ...
}
But, In user class, I cannot enumerate a method with OwnProps().
Example:
class Class211
{
static iVarStatic := 0
iVarLocal := 0
static FuncStatic()
{
}
FuncLocal()
{
}
}
MsgBox(Class211.HasProp("FuncLocal")) ; -> false
MsgBox(Class211.HasProp("FuncStatic")) ; -> true
MsgBox(Class211.HasOwnProp("FuncLocal")) ; -> false
MsgBox(Class211.HasOwnProp("FuncStatic")) ; -> true
for aName, vData in Class211.OwnProps()
{
MsgBox(aName) ; -> iVarStatic, Prototype
}
for aName, vData in Class211.Prototype.OwnProps()
{
MsgBox(aName) ; -> __Class
}
Where, on earth, FuncStatic() and FuncLocal() properties are stored?
How can I enumerate them?
[Q] How to enumerate user class methods
- AstraVista
- Posts: 15
- Joined: 16 Feb 2024, 03:14
[Q] How to enumerate user class methods
AstraVista
Re: [Q] How to enumerate user class methods
https://www.autohotkey.com/docs/v2/lib/Object.htm#OwnPropsMethods are typically excluded from enumeration in the two-parameter mode, because evaluation of the property normally depends on whether the object has a corresponding getter or value, either in the same object or a base object. To avoid inconsistency when two variables are specified, OwnProps skips over own properties that have only a Call accessor function
Code: Select all
for aName in TestClass211.OwnProps() {
MsgBox(aName) ; -> iVarStatic, Prototype, TestFuncStatic
}
for aName in Class211.Prototype.OwnProps() {
MsgBox(aName) ; -> __Class, __init, TestFuncLocal
}
Did you edit the example or am I tripping? all your variable names started with "Test", chat is this real?
- AstraVista
- Posts: 15
- Joined: 16 Feb 2024, 03:14
Re: [Q] How to enumerate user class methods
Ah, thanks! Problem solved.
p.s. "Test" is omitted from editing...
p.s. "Test" is omitted from editing...
AstraVista
Who is online
Users browsing this forum: teadrinker and 45 guests