AutoHotkey Community

It is currently May 25th, 2012, 7:14 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 113 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7, 8  Next
Author Message
 Post subject:
PostPosted: May 30th, 2007, 3:22 pm 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
Quote:
For the next release, JGR has written the code to support built-in callbacks. I also hope to work on the mechanism for the standard library and a built-in Extract/InsertInteger.

OMFG :shock:
What happend to you Chris... :D

_________________
Image


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 30th, 2007, 3:30 pm 
Offline

Joined: December 27th, 2005, 1:46 pm
Posts: 6837
Location: France (near Paris)
Yes, it makes sense, I came up with this hypothetical code:
Code:
pfn := CallBack("EnumerateWindows", "UInt", "UInt", "Int")   ; hWnd, lParam, returns BOOL
DllCall("EnumWindows", "FunP", pfn, "UInt", 0)   ; lParam

EnumerateWindows(_hWnd, _lParam)
{
   global winList
   
   winList .= _hWnd . "|"

   Return 1 ; Continue enumeration
}

I think the last parameter must be the return type, in some special DLLs it can be something other than 0/1 or true/false.

majkinetor wrote:
What happend to you Chris... :D
He was too bugged by a blue/violet monster...
Or more realistically, he got usable code! :-)
Great news, all this is eagerly expected since a long time.

_________________
Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 30th, 2007, 5:07 pm 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8775
Chris wrote:
For the next release, JGR has written the code to support built-in callbacks.


:o :D

Chris wrote:
I also hope to work on the mechanism for the standard library and a built-in Extract/InsertInteger.


:D

I wish it would be like Laszlo's Encode, Decode binary numbers

Thanks :)


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 30th, 2007, 5:11 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
The interface is actually planned to be simpler than that:

Code:
; In the below, 2 is the number of parameters and MyExtra is any integer to be passed to the callback as the first parameter. MyExtra allows a given function to be used by more than one type of callback, which is a a flexiblity that's thought to worth seeing an extra parameter in the first position all the time:
EnumWindowsProcStub:=RegisterCallback("EnumWindowsProc", 2, MyExtra)
...
DllCall("EnumWindows","UInt",EnumWindowsProcStub,"UInt",0)
EnumWindowsProc(extra, winid, otherparam)
{
   ...
   return 1
}
The code is very small; there is no string support like DllCall. Since there is no declaring of parameters or types (just the parameter count), it is up to the script to do any necessary conversions or type-casting (though that is unnecessary in most cases).

PhiLho wrote:
I think the last parameter must be the return type, in some special DLLs it can be something other than 0/1 or true/false.
There is currently no ability to customize it, so perhaps the hard-coded support for a 32-bit return value is suitable for 99.9% of callbacks found in nature. I'll ask JGR.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 30th, 2007, 5:31 pm 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
Have you thought about internal hooks (with JGR code, again )?

_________________
Image


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 30th, 2007, 5:36 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Not yet.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 30th, 2007, 6:15 pm 
Offline

Joined: June 15th, 2006, 6:29 am
Posts: 59
Location: Oriel College
PhiLho wrote:
Quote:
I think the last parameter must be the return type, in some special DLLs it can be something other than 0/1 or true/false.

In almost any callback function the return value will be some sort of 32 bit integer, which may represent a pointer, value, boolean, etc.
The only cases where it might conceivably be any different are if the callback uses a highly non-standard calling convention, in which case you couldn't use AHK for it anyway, or if the callback expects something to be returned on the FPU stack or something equally exotic, which this callback implementation does not support. I have never seen a callback function that fell into those two categories on windows, but it's possible I suppose.
In which case you'd have to write your own callback dll. If you did parameter conversion to a sensible calling convention, then you could probably have your callback dll call AHKs callback function and transmute the returned value.
This is not really an issue.

JGR


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 30th, 2007, 6:29 pm 
Offline

Joined: December 27th, 2005, 1:46 pm
Posts: 6837
Location: France (near Paris)
OK, fine for me. Do you think all parameters are 32bit too?
I saw implementations of callbacks that where just a bunch of template functions, with 1, 2, ... n parameters, all with the same type of parameters.

_________________
Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 31st, 2007, 2:08 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
PhiLho wrote:
OK, fine for me. Do you think all parameters are 32bit too?

I think the stack is aligned on 4byte, so no real difference among char/short/long, but I may be wrong and not so sure about it when int64/double presents which I suppose rare anyway.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 31st, 2007, 9:03 am 
Offline

Joined: December 27th, 2005, 1:46 pm
Posts: 6837
Location: France (near Paris)
You are right.
I found in The Old New Thing : The history of calling conventions, part 3 a link to an MSDN page which leaded to the Argument Passing and Naming Conventions page which states:
MSDN wrote:
All arguments are widened to 32 bits when they are passed. Return values are also widened to 32 bits and returned in the EAX register, except for 8-byte structures, which are returned in the EDX:EAX register pair. Larger structures are returned in the EAX register as pointers to hidden return structures. Parameters are pushed onto the stack from right to left.

64bit parameters are indeed rare, and can be handled as two 32bit parameters anyway.

_________________
Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 31st, 2007, 9:15 am 
majkinetor wrote:
Have you thought about internal hooks (with JGR code, again )?
I think that it wouldn't be monstrous to have this possibility... :D :D :D It would be certainly a means of extending the capabilities of Autohotkey, and to do things like Dock more easily...


Top
  
Reply with quote  
 Post subject:
PostPosted: May 31st, 2007, 10:00 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
PhiLho wrote:
64bit parameters are indeed rare, and can be handled as two 32bit parameters anyway.

Sure, however, what I meant by not sure was about the alignment size: still 4 byte or become 8 byte.
I heard that using 4byte impacts substantial performance penalty for Double, so some compliers uses dynamic stack alignment of 8byte, when Doubles are involved.

I tested and noticed a while ago that AHK's DllCall() still uses 4byte stack alignment even with int64 parameters (:not tested with Double, btw).
But, I can't really assume it with Callback as the stack is prepared by APIs/the system, although it's highly likely as the DllCall() worked flawlessly with 4byte alignment by AHK.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 31st, 2007, 2:00 pm 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
Quote:
I think that it wouldn't be monstrous to have this possibility...
Monstrous? What is monstrous in hooks ? You can easily create malitious scripts in any language. You can easily kill a man with the spoon.

The fact is - if hooks are also internal, I don't see posibilities for more low level changes except for better struct support. The AHK would be extremely powerful, beyond competition. With hooks and after callbacks, any kind of OS manipulation will be possible. After all, AHK is automatition language, and it doesn't have many things to do in forign processes except simulating user input which is enough for small number of things and most of all, depend on 3td party application.

I doubt it would be much more complex then callbacks but I can easily be wrong.

_________________
Image


Last edited by majkinetor on May 31st, 2007, 8:56 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 31st, 2007, 5:43 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
In v1.0.46.17, A_UserName was fixed (it had been broken by v1.0.46.16).


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 31st, 2007, 7:07 pm 
majkinetor wrote:
Monstrous? What is monstrous in hooks ?

It isn't Captain Hook that can find that hooking is monstruous. But ... may be a blue monster with long teeth can do marvelous things with a hook ? :D :D :D
Hooking is a tool. And like a knife, it can make a good steak or the page one of the Sun... It depends only on the way you use it. It was jeust a joke, majkinetor...


Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 113 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7, 8  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group