 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
animeaime
Joined: 04 Nov 2008 Posts: 1045
|
Posted: Mon Jun 01, 2009 9:18 pm Post subject: |
|
|
| bmmclure wrote: | | It would be great if Class could automagically determine if a parameter should be a byref and pass it accordingly, but I don't think it's possible currently. |
I don't think it can ever be possible. For, even if there were a way to know if a parameter were ByRef or ByValue, Class_invoke would take the parameter as either ByRef or ByValue. If the called function has a ByRef parameter where Class_invoke has a ByValue parameter, it won't work as expected.
Well, technically, there is a way. Create a function for each of the 2^6 = 64 combinations - 6 parameters with 2 modes (ByRef and ByValue) for each parameter). Then, dynamically call the correct one based on the combination of ByRef and ByValue parameters for the function. Note: this is assuming it were possible to detect whether a parameter were ByRef or ByVal. Also, then there would need to be a function that returned the correct "Class_invoke" function for the specific combination of ByRef and ByValue parameters. Then, this function name would have to be stored in a variable, and used in a dynamic call.
In other words, in my opinion, it is never going to be possible. Or, even if it were, it wouldn't be efficient (at all ). However, like always, I'm open to suggestions . _________________ As always, if you have any further questions, don't hesitate to ask.
Add OOP to your scripts via the Class Library. Check out my scripts. |
|
| Back to top |
|
 |
bmcclure
Joined: 24 Nov 2007 Posts: 774
|
Posted: Tue Jun 02, 2009 5:16 am Post subject: |
|
|
I don't think it will be possible either, although that doesn't stop me from thinking it would sure be neat
As a workaround, assigning arbitrary variable names within the function call will work fine, though. It's just not as cool, heh.
By the way, I'm to the bug-squashing phase of my Core module for the DOM library, thanks to the Class library. Every supported DOM class has an interface and a real class implementing it. It's very exciting seeing the DOM gears all spinning together (thanks to your coding and assistance, of course )
--
Just probably a stupid idea, but what about passing a memory address (&var) to invoke instead of a ByRef, and then having the invoke function turn it into a ByRef by calling a static function template with the ByRef in the right spot (unfortunately that's the least efficient part of this, and I can't think of a better way in AHK)? I'm not even sure if that would work, or be efficient in the least, but if a memory address could be passed instead, that would avoid the caveat of only being able to use either-or. _________________ Ben
My Trac projects
My Wiki
[Broken] - My music |
|
| Back to top |
|
 |
animeaime
Joined: 04 Nov 2008 Posts: 1045
|
Posted: Tue Jun 02, 2009 5:58 am Post subject: |
|
|
Below is a mockup of the steps taken when calling Class_invoke.
1) You have a value that's passed ByRef to Invoke (e.g. a struct)
2) That parameter is passed to the called function
3) The called function needs to be able to extract the contents of the struct.
Below is the "shell" that's used for the Class_invoke function and its call. I'll post it and you can play with it. Hopefully you can figure something out.
| Code: | VarSetCapacity(Value, 16), NumPut(12, Value, 0), NumPut(23, Value, 4)
, NumPut(34, Value, 8), NumPut(45, Value, 12)
;Calling Invoke (passing a struct)
Invoke(Value)
;Class_invoke
Invoke(ByRef arg1)
{
CalledFunc(arg1)
}
;The called class function
CalledFunc(ByRef struct)
{
;should output 12 (the value for offset 0)
MsgBox, % NumGet(struct, 0)
} |
_________________ As always, if you have any further questions, don't hesitate to ask.
Add OOP to your scripts via the Class Library. Check out my scripts. |
|
| Back to top |
|
 |
bmcclure
Joined: 24 Nov 2007 Posts: 774
|
Posted: Tue Jun 02, 2009 9:13 pm Post subject: |
|
|
I'm getting a new error now when I try to test my DOM library. It has to do with the following function call in Class.ahk:
| Code: | | RemoveDuplicates(implementsThese, ",") |
Where is this function supposed to be located?
I found the function defined in a forum topic here.
Any chance you can turn it into a Class_ static so that there are no external requirements? _________________ Ben
My Trac projects
My Wiki
[Broken] - My music |
|
| Back to top |
|
 |
animeaime
Joined: 04 Nov 2008 Posts: 1045
|
Posted: Tue Jun 02, 2009 11:15 pm Post subject: |
|
|
| bmcclure wrote: | I'm getting a new error now when I try to test my DOM library. It has to do with the following function call in Class.ahk:
| Code: | | RemoveDuplicates(implementsThese, ",") |
Where is this function supposed to be located?
I found the function defined in a forum topic here.
Any chance you can turn it into a Class_ static so that there are no external requirements? |
Oops... Sorry about that. No, I just forgot to comment that line out. That functionality will be added shortly - it's going to be used in inheritence.
So, just comment that line out. Sorry about that.
Edit:
I commented out that line and uploaded the new version to the site. There are no feature additions / modifications, so you don't have to download the latest version. Just comment the line out if you get that error. _________________ As always, if you have any further questions, don't hesitate to ask.
Add OOP to your scripts via the Class Library. Check out my scripts.
Last edited by animeaime on Tue Jun 02, 2009 11:24 pm; edited 1 time in total |
|
| Back to top |
|
 |
animeaime
Joined: 04 Nov 2008 Posts: 1045
|
Posted: Tue Jun 02, 2009 11:20 pm Post subject: |
|
|
I just realized, I don't think the site mentions how to declare that a class implements an interface. To do this, put the comma-delimited list of implemented interfaces in square brackets "[".
For example, the Vector_initClass function looks like this:
| Code: | Vector_initClass()
{
;Vector implements List
static ClassName := "Vector(Cloneable)[List]"
return &ClassName
} |
Edit:
I've updated the page on Interfaces with this information. _________________ As always, if you have any further questions, don't hesitate to ask.
Add OOP to your scripts via the Class Library. Check out my scripts. |
|
| Back to top |
|
 |
bmcclure
Joined: 24 Nov 2007 Posts: 774
|
Posted: Wed Jun 03, 2009 12:46 am Post subject: |
|
|
Thanks for the info; I had included the RemoveDuplicates function to satisfy the dependency, but I'll just comment it out.
--
Oops, I was specifying it as:
ClassName(Options) implements [Interfaces]
Must have been an old syntax; I'll update that in my interfaces! Thanks for the notice. _________________ Ben
My Trac projects
My Wiki
[Broken] - My music |
|
| Back to top |
|
 |
animeaime
Joined: 04 Nov 2008 Posts: 1045
|
Posted: Wed Jun 03, 2009 2:43 am Post subject: |
|
|
| bmcclure wrote: | | Thanks for the info; I had included the RemoveDuplicates function to satisfy the dependency, but I'll just comment it out. |
Yeah, sorry about that. I'll include a copy of it as a Class function when it gets used.
The version I'll be using has the first parameter ByRef and won't return the list. I slightly modified the version of RemoveDuplicates posted by [VxE]
| bmmclure wrote: | Oops, I was specifying it as:
ClassName(Options) implements [Interfaces]
Must have been an old syntax; I'll update that in my interfaces! Thanks for the notice. |
That syntax is supported, by it wastes memory, so I've leaning to the standard of omitting the " implements " part. Also, when inheritence gets added, the function you saw which makes use of RemoveDuplicates, Class_getImplements, and another function, Class_getExtends, will handle the details of handling extended and implemented classes - this will be part of the v3 design (which will allow inheritence). _________________ As always, if you have any further questions, don't hesitate to ask.
Add OOP to your scripts via the Class Library. Check out my scripts. |
|
| Back to top |
|
 |
bmcclure
Joined: 24 Nov 2007 Posts: 774
|
Posted: Wed Jun 03, 2009 6:40 am Post subject: |
|
|
Very cool stuff
I'm systematically testing each DOM class for consistency with the DOM level 3 specification, and to squash the many remaining bugs in my code, then I will be ready for the first release of the DOM level 3 interfaces and class library.
Will I need to update the syntax of everything to be supported by Class v3, or will it be backwards compatible? Assuming the latter, but I just want to make sure. It might take me a little bit to switch everything over  _________________ Ben
My Trac projects
My Wiki
[Broken] - My music |
|
| Back to top |
|
 |
animeaime
Joined: 04 Nov 2008 Posts: 1045
|
Posted: Wed Jun 03, 2009 7:10 am Post subject: |
|
|
| bmcclure wrote: | Will I need to update the syntax of everything to be supported by Class v3, or will it be backwards compatible? Assuming the latter, but I just want to make sure. It might take me a little bit to switch everything over  |
Classes will be backwards compatible. However, there will need to be a few changes to meet v3 design if you want to inherit from the class or have the class extend another class. So, yes it will still work. But no, without changes, you won't be able to use inheritence with the class.
However, to make a class meet v3 design, you will only need to perform minor changes to the class.
If someone is interested, remember how the idea of a markup language for the Class Library was suggested by rulfzid?
If this idea could come to fruit, then the only changes that would be required is to change the "build" function of the markup. For example, you would format your class into the mark-up language. Then, you would "Class"ify the the ini (rulfzid's wording). So, when the v3 standard appears, the only required change would be in the "build" function.
If someone was interested in doing this, I'm sure there would be many in the community with input for ideas - so, don't feel that you would have to bear the burden alone. Remember, there are 15000+ people watching the progress of this library. _________________ As always, if you have any further questions, don't hesitate to ask.
Add OOP to your scripts via the Class Library. Check out my scripts. |
|
| Back to top |
|
 |
bmcclure
Joined: 24 Nov 2007 Posts: 774
|
Posted: Wed Jun 03, 2009 8:03 am Post subject: |
|
|
I started work a couple weeks ago on a ClassHelper class which reads a class definition from a file and creates an class file from it. I'll easily be able to expand it to v3 format when it's ready, and before too long I'll probably have a release version. It could even be turned into an Gui app that allows you to visually create a class.
It's somewhat ironic... I could really use the ClassHelper when making the DOM classes, but one of the features of the ClassHelper is reading class definitions from XML, which requires the DOM library  _________________ Ben
My Trac projects
My Wiki
[Broken] - My music |
|
| Back to top |
|
 |
animeaime
Joined: 04 Nov 2008 Posts: 1045
|
Posted: Wed Jun 03, 2009 8:08 am Post subject: |
|
|
| bmcclure wrote: | I started work a couple weeks ago on a ClassHelper class which reads a class definition from a file and creates an class file from it. I'll easily be able to expand it to v3 format when it's ready, and before too long I'll probably have a release version. It could even be turned into an Gui app that allows you to visually create a class.
It's somewhat ironic... I could really use the ClassHelper when making the DOM classes, but one of the features of the ClassHelper is reading class definitions from XML, which requires the DOM library  |
Why does it require XML? - there should be nothing that requires nesting. It should be possible to create an INI format (using only sections and keys) that could be "class"ified. _________________ As always, if you have any further questions, don't hesitate to ask.
Add OOP to your scripts via the Class Library. Check out my scripts. |
|
| Back to top |
|
 |
bmcclure
Joined: 24 Nov 2007 Posts: 774
|
Posted: Wed Jun 03, 2009 2:03 pm Post subject: |
|
|
Definitely don't need xml, but it sure would keep things looking clean and I would prefer it to an ini file. I lan to support the proposed ini syntax as well, but I always like options. _________________ Ben
My Trac projects
My Wiki
[Broken] - My music |
|
| Back to top |
|
 |
bmcclure
Joined: 24 Nov 2007 Posts: 774
|
Posted: Wed Jun 03, 2009 11:19 pm Post subject: |
|
|
Is an Int type long enough to store a full timestamp (in milliseconds)? If not, would I need to store it as a string?
From the DOM specification:
| Quote: | | For Java, DOMTimeStamp is bound to the long type. For ECMAScript, DOMTimeStamp is bound to the Date type because the range of the integer type is too small. |
----
Just a note: My DOM tests have been working properly so far! I've only tested a few of the classes (DOMImplementationRegistry (a 'factory class' per se, and the only class name that's required to be known since you can use class_invoke for everything else), DOMImplementationSource, DOMImplementation, DOMConfiguration, DOMConfigurationParameter, DOMSetting, DOMDocument, DOMElement, DOMAttr, DOMNode, DOMNamedNodeMap, DOMNodeList, DOMText, DOMCharacterData... and probably others I haven't realized) ... and so far they are working together perfectly, and it's a lot faster than I expected, given all that is going on in the background with the DOM.
These days before the first release (maybe hours) of the DOM for AHK are very exciting! Thanks very much for all of your help with this library and in these topics. _________________ Ben
My Trac projects
My Wiki
[Broken] - My music |
|
| Back to top |
|
 |
animeaime
Joined: 04 Nov 2008 Posts: 1045
|
Posted: Thu Jun 04, 2009 2:31 am Post subject: |
|
|
| bmmclure wrote: | | Is an Int type long enough to store a full timestamp (in milliseconds)? If not, would I need to store it as a string? |
I'm not sure. However, I can say that there are 86 400 000ms in 1 day.
| Code: | 1 Day 24 Hours 60 minutes 60 seconds 1000 miliseconds
1 day 1 hour 1 minute 1 second |
Canceling units, that's 24 * 60 * 60 * 1000 ms (86 400 000 ms) = 1 day
| DllCall -> Int wrote: | | A 32-bit integer (the most common integer type), whose range is -2147483648 (-0x80000000) to 2147483647 (0x7FFFFFFF). An Int is sometimes called a "Long". |
So, an int ("long") can handle values up to 2,147,483,647 (2 billion+).
According to google calculator, 2 147 483 647 milliseconds (2 ^ 31 - 1 ms) = 24.8551348 days
So, my answer is, I think so... especially if the timestamp is only to handle a single day, then a definite #$!! yeah!
Note: Of course, if you use a UINT, you have double that range (but no negative numbers). _________________ As always, if you have any further questions, don't hesitate to ask.
Add OOP to your scripts via the Class Library. Check out my scripts. |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|