Ok, here is the latest update - download the
zip. It's cleaned, polished, and really sparkles - you BETTER ooh and ah. GOT IT?!
Ok, anyway. This release comes at a weird time. Just as I was about to have the website up to date (a little more to go), this update comes along. So, sadly, it will still be some time before the site is updated, but the site looks amazinig (cleaner and more organized), and these features will make a great addition.
I'm calling this Class V2, however, it's backward compatable - its like USB 2.0 - still can plug into a 1.1 world, but works MUCH better when 2.0 compliant. You can use the new design, or the old. I would, however, recommend the new, and here's why...
This new releas comes with a newly organized Node.ahk to start making your own classes. The template is setup with all the bells and whistles that come with Class V2. The code has commented remarks to help get you started and tell you what is optional, what is not, and what to do if you don't want user-defined values. Also, Rectangle has been updated with the V2 layout, so check it out as a model.
I used bmcclure's layout from their IniFile code to format Node.ahk. I really like how it was neat and organized.
New in this release:
1) static values - via %ClassName%_constant. This function is an optional function that allows storing static values (shared by all members of the class). You set the values inside the function (via static values), and extract them using a function call.
Syntax:
Code:
Node_constant(variable, setValue = "")
Returns the value associated with the specified variable (or the empty string, if the variable isn't one of the variables stored). Passing a value for setValue will set the value associated with the specified variable (returning the previous). There is no way to "clear" (store the empty string) in the internal variables.
Also, there is a Class function which can be used to dynamically retrieve these constants.
Syntax:
Code:
Class_constant(ClassNameOrObject, variable, setValue = "")
If ClassNameOrObject is an integer, it is interpreted as a class object (whose class name is retieved and used). Else, ClassNameOrObject is interpreted as a class name. The class' constant function is dynamically called using the class name. If the function doesn't exist, the empty string is returned. As a note, this is NOT added as a Class Option. This means that the class' "constant" function is reserved for this use. Declaring a "constant" function for another use may have negative side-effects. I could have it as a class option (if required), but for performance reasons, I opted against this. I'll fix it if yal want it to be a class option.
2) Functions that are used to store the structure (types) of the built-in values and another for user-defined values. These functions are dynamically called when destroying and cloning the object. This is part of the new V2 design. See Node.ahk for use and Rectangle/Rectangle_test.ahk to see how to use it with user-defined values. Since the call is dynamic, if there are no user-defined values, then nothing needs to be done. Also, you don't need to change the destroy function or clone function when you change your structure. Only change the functions getBuiltInValues() and getUserDefinedValues() to reflect the changes.
3) Ability to clone objects. All V2 objects are setup to be cloneable by default. This new structure makes it very easy to clone and destroy objects (along with user-defined values)
There is a three-prong clone method.
Syntax:
Code:
Node_clone(NodeObject, DeepCopy = true)
If DeepCopy = 0 (or the empty string), a shallow copy is done; if DeepCopy = -1, a "settings only" copy is done; else, a deep copy is done (default)
All three clone built-in types (string, int, uint, etc.). The difference is what it does for "obj" types (including wrappers). A shallow copy copies the address directly. A deep copy performs a recursive clone (dynamically cloning objects). A "settings only" clone does not set an "obj" type (leaves it 0). It is up to the Class' clone function to decide what to do. Node.ahk is formatted to allow easily doing this.
As a note, Vector, Array, and the wrappers are cloneable. Wrappers will clone the exact same way regardless the type of clone (DeepCopy is a parameter for consistency only). Vector and Array only have Deep copy added. A "settings only" copy doesn't apply, and I'm not sure what should be done for a shallow copy, so it is not yet added yet (taking suggestions).
4) Int64 and UInt64 wrappers make their debut. UInt64 is supported in v1.0.48+ , see
NumGet/NumPut for details. You can also use Int64 or UInt64 as a value's type.
As always, any questions can be asked on the forum.