AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

v1.0.46 released: SubStr() and more expression operators
Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Announcements
View previous topic :: View next topic  
Author Message
majkinetor



Joined: 24 May 2006
Posts: 3589
Location: Belgrade

PostPosted: Wed May 30, 2007 3:22 pm    Post subject: Reply with quote

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 Shocked
What happend to you Chris... Very Happy
_________________
Back to top
View user's profile Send private message MSN Messenger
PhiLho



Joined: 27 Dec 2005
Posts: 6721
Location: France (near Paris)

PostPosted: Wed May 30, 2007 3:30 pm    Post subject: Reply with quote

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... Very Happy
He was too bugged by a blue/violet monster...
Or more realistically, he got usable code! Smile
Great news, all this is eagerly expected since a long time.
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
SKAN



Joined: 26 Dec 2005
Posts: 5574

PostPosted: Wed May 30, 2007 5:07 pm    Post subject: Reply with quote

Chris wrote:
For the next release, JGR has written the code to support built-in callbacks.


Surprised Very Happy

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


Very Happy

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

Thanks Smile
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10463

PostPosted: Wed May 30, 2007 5:11 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message Send e-mail
majkinetor



Joined: 24 May 2006
Posts: 3589
Location: Belgrade

PostPosted: Wed May 30, 2007 5:31 pm    Post subject: Reply with quote

Have you thought about internal hooks (with JGR code, again )?
_________________
Back to top
View user's profile Send private message MSN Messenger
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10463

PostPosted: Wed May 30, 2007 5:36 pm    Post subject: Reply with quote

Not yet.
Back to top
View user's profile Send private message Send e-mail
JGR



Joined: 15 Jun 2006
Posts: 52
Location: Unavailable until ~30th August

PostPosted: Wed May 30, 2007 6:15 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
PhiLho



Joined: 27 Dec 2005
Posts: 6721
Location: France (near Paris)

PostPosted: Wed May 30, 2007 6:29 pm    Post subject: Reply with quote

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.
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
Sean



Joined: 12 Feb 2007
Posts: 1240

PostPosted: Thu May 31, 2007 2:08 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
PhiLho



Joined: 27 Dec 2005
Posts: 6721
Location: France (near Paris)

PostPosted: Thu May 31, 2007 9:03 am    Post subject: Reply with quote

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.
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
Captain Hook
Guest





PostPosted: Thu May 31, 2007 9:15 am    Post subject: Reply with quote

majkinetor wrote:
Have you thought about internal hooks (with JGR code, again )?
I think that it wouldn't be monstrous to have this possibility... Very Happy Very Happy Very Happy It would be certainly a means of extending the capabilities of Autohotkey, and to do things like Dock more easily...
Back to top
Sean



Joined: 12 Feb 2007
Posts: 1240

PostPosted: Thu May 31, 2007 10:00 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
majkinetor



Joined: 24 May 2006
Posts: 3589
Location: Belgrade

PostPosted: Thu May 31, 2007 2:00 pm    Post subject: Reply with quote

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.
_________________


Last edited by majkinetor on Thu May 31, 2007 8:56 pm; edited 1 time in total
Back to top
View user's profile Send private message MSN Messenger
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10463

PostPosted: Thu May 31, 2007 5:43 pm    Post subject: Reply with quote

In v1.0.46.17, A_UserName was fixed (it had been broken by v1.0.46.16).
Back to top
View user's profile Send private message Send e-mail
Captain Hook
Guest





PostPosted: Thu May 31, 2007 7:07 pm    Post subject: Reply with quote

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 ? Very Happy Very Happy Very Happy
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...
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Announcements All times are GMT
Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8  Next
Page 5 of 8

 
Jump to:  
You cannot post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group