1. User32 And GDI32 Wrapper Feedback
- Posted by Lone_EverGreen_Ranger Jul 13, 2012
- 1778 views
Hello All,
So has anyone used my wrappers or taken a look at them? I spent a lot of time writing them. I was also thinking of making some more wrappers. Any bugs or anything that I may have missed in my current wrappers? I know these were kinda of large projects to take on, but I had fun doing them and I learned some more about the windows API and euphoria. So any feedback?
2. Re: User32 And GDI32 Wrapper Feedback
- Posted by EUWX Jul 13, 2012
- 1734 views
Hello All,
So has anyone used my wrappers or taken a look at them? I spent a lot of time writing them. I was also thinking of making some more wrappers. Any bugs or anything that I may have missed in my current wrappers? I know these were kinda of large projects to take on, but I had fun doing them and I learned some more about the windows API and euphoria. So any feedback?
I have not tried, but I looked at your code and it looks excellent.
without meaning to downgrade your effort, it is typical of the style of wrappers I have seen in this site, so it should work well.
If something does not work, blame Bill Gates because of changes in the never ending series of Windows versions.
3. Re: User32 And GDI32 Wrapper Feedback
- Posted by Lone_EverGreen_Ranger Jul 14, 2012
- 1638 views
Hello All,
So has anyone used my wrappers or taken a look at them? I spent a lot of time writing them. I was also thinking of making some more wrappers. Any bugs or anything that I may have missed in my current wrappers? I know these were kinda of large projects to take on, but I had fun doing them and I learned some more about the windows API and euphoria. So any feedback?
I have not tried, but I looked at your code and it looks excellent.
without meaning to downgrade your effort, it is typical of the style of wrappers I have seen in this site, so it should work well.
If something does not work, blame Bill Gates because of changes in the never ending series of Windows versions.
Thanks for the feedback. That sounds great. I may start work on a kerenl32 wrapper, as that would add tremendously to my already previous wrappers. I also have ideas for other wrappers as well. Thanks again for the feedback.
4. Re: User32 And GDI32 Wrapper Feedback
- Posted by coconut Jul 18, 2012
- 1610 views
Hello All,
So has anyone used my wrappers or taken a look at them? I spent a lot of time writing them. I was also thinking of making some more wrappers. Any bugs or anything that I may have missed in my current wrappers? I know these were kinda of large projects to take on, but I had fun doing them and I learned some more about the windows API and euphoria. So any feedback?
I fast look at user32.ew and found something doubtfull here:
procedure WinHelp(atom handle,sequence str,atom ex,atom ex2) c_proc(xWinHelp,{handle,str,ex,ex2}) end procedure
You can't pass a string to a WIN32 API function. Windows knows nothing about euphoria sequence. this should be something like that:
procedure WinHelp(atom handle,sequence str,atom ex,atom ex2) atom pStr pStr = allocate_string(str) c_proc(xWinHelp,{handle,pStr,ex,ex2}) free(pStr) end procedure
By the way I did a lot of win32 API wrapping in past years. Take a look at: win32 api wrappers. Others did alot of it too, look at Judith Evans IDE. WIN32 API is huge. You would better improve and expand what as already been done than starting all over.
This is not to critisize, this work is usefull.
Jacques
5. Re: User32 And GDI32 Wrapper Feedback
- Posted by Lone_EverGreen_Ranger Jul 18, 2012
- 1554 views
Hello All,
So has anyone used my wrappers or taken a look at them? I spent a lot of time writing them. I was also thinking of making some more wrappers. Any bugs or anything that I may have missed in my current wrappers? I know these were kinda of large projects to take on, but I had fun doing them and I learned some more about the windows API and euphoria. So any feedback?
I fast look at user32.ew and found something doubtfull here:
procedure WinHelp(atom handle,sequence str,atom ex,atom ex2) c_proc(xWinHelp,{handle,str,ex,ex2}) end procedure
You can't pass a string to a WIN32 API function. Windows knows nothing about euphoria sequence. this should be something like that:
procedure WinHelp(atom handle,sequence str,atom ex,atom ex2) atom pStr pStr = allocate_string(str) c_proc(xWinHelp,{handle,pStr,ex,ex2}) free(pStr) end procedure
By the way I did a lot of win32 API wrapping in past years. Take a look at: win32 api wrappers. Others did alot of it too, look at Judith Evans IDE. WIN32 API is huge. You would better improve and expand what as already been done than starting all over.
This is not to critisize, this work is usefull.
Jacques
Right, I understand. While starting from scratch may not have been the best approach, it was something rewarding to do. And as you noted, I will go back and fix anything I have missed.
6. Re: User32 And GDI32 Wrapper Feedback
- Posted by mattlewis (admin) Jul 19, 2012
- 1504 views
You can't pass a string to a WIN32 API function. Windows knows nothing about euphoria sequence. this should be something like that:
procedure WinHelp(atom handle,sequence str,atom ex,atom ex2) atom pStr pStr = allocate_string(str) c_proc(xWinHelp,{handle,pStr,ex,ex2}) free(pStr) end procedure
With euphoria 4.0, you can simplify this a bit so that you don't have to worry about memory management:
procedure WinHelp(atom handle,sequence str,atom ex,atom ex2) atom pStr c_proc(xWinHelp,{handle,allocate_string(str, 1),ex,ex2}) end procedure
Adding the extra 1 to the allocate_string() call causes the pointer to be freed once there are no more euphoria references to it.
Matt
7. Re: User32 And GDI32 Wrapper Feedback
- Posted by Lone_EverGreen_Ranger Jul 19, 2012
- 1470 views
You can't pass a string to a WIN32 API function. Windows knows nothing about euphoria sequence. this should be something like that:
procedure WinHelp(atom handle,sequence str,atom ex,atom ex2) atom pStr pStr = allocate_string(str) c_proc(xWinHelp,{handle,pStr,ex,ex2}) free(pStr) end procedure
With euphoria 4.0, you can simplify this a bit so that you don't have to worry about memory management:
procedure WinHelp(atom handle,sequence str,atom ex,atom ex2) atom pStr c_proc(xWinHelp,{handle,allocate_string(str, 1),ex,ex2}) end procedure
Adding the extra 1 to the allocate_string() call causes the pointer to be freed once there are no more euphoria references to it.
Matt
Thanks for the tip, Matt. Although I had already gone and fixed things using the old way. Oh well, no biggie, I'll keep this in mind for next time.
8. Re: User32 And GDI32 Wrapper Feedback
- Posted by ghaberek (admin) Jul 20, 2012
- 1411 views
With euphoria 4.0, you can simplify this a bit so that you don't have to worry about memory management:
procedure WinHelp(atom handle,sequence str,atom ex,atom ex2) atom pStr c_proc(xWinHelp,{handle,allocate_string(str, 1),ex,ex2}) end procedure
Adding the extra 1 to the allocate_string() call causes the pointer to be freed once there are no more euphoria references to it.
I'm really loving this feature, by the way. Here's a neat trick for passing optional "text" parameters that also accept NULL. I used this a lot when wrapping Newt.
namespace newt public procedure PushHelpLine( object text = NULL ) if sequence( text ) then text = allocate_string( text, 1 ) end if c_proc( x_newtPushHelpLine, {text} ) end procedure
So if you call newt:PushHelpLine() with no parameters, it passes NULL automatically, if you pass an atom (assumed to be a string pointer) it passes it through directly, and if you pass a sequence (a text string) it is allocated into memory, flagged for collection, and then passed to the function.
You could also pre-allocate your strings as constant pointers and let Euphoria clean them up when it's done, although I can't see a direct advantage to this one way or the other (unless you're using a lot of strings on a really really slow machine).
constant helpText = allocate_string( "This is my help text", 1 ) newt:Init(1) newt:PushHelpLine( helpText ) newt:WaitForKey() newt:Finished() -- helpText will be freed automatically when we're done
-Greg
9. Re: User32 And GDI32 Wrapper Feedback
- Posted by mattlewis (admin) Jul 20, 2012
- 1394 views
You could also pre-allocate your strings as constant pointers and let Euphoria clean them up when it's done, although I can't see a direct advantage to this one way or the other (unless you're using a lot of strings on a really really slow machine).
constant helpText = allocate_string( "This is my help text", 1 ) newt:Init(1) newt:PushHelpLine( helpText ) newt:WaitForKey() newt:Finished() -- helpText will be freed automatically when we're done
Adding the parameter to set the pointers to auto-cleanup won't actually do anything in this case. Those constants don't get dereferenced at the end. They're simply released when all of your program's memory goes away. For a time, we tried dereferencing everything when a program exited, but it caused problems.
Matt
10. Re: User32 And GDI32 Wrapper Feedback
- Posted by ghaberek (admin) Jul 20, 2012
- 1365 views
Adding the parameter to set the pointers to auto-cleanup won't actually do anything in this case. Those constants don't get dereferenced at the end. They're simply released when all of your program's memory goes away. For a time, we tried dereferencing everything when a program exited, but it caused problems.
So in that case I don't need to add the cleanup parameter? Good to know. I guess it always kind of worked that way, didn't it?
-Greg