1. RE: DLL Automatic Wrapper Generator
- Posted by bensler at mail.com Feb 28, 2002
- 527 views
Here is the wrapper file that is generated by DAWG using the link_list from my previous post ... Chris <win32_wrap.e> -- wrapper file generated using dawg.e by Chris Bensler ------------------------------------------------------------ include dll_wrap.e -- link to the DLL's global constant user32_dll = link_dll("user32.dll") global constant gdi32_dll = link_dll("gdi32.dll") global constant winmm_dll = link_dll("winmm.dll") -- link to the c_func's global constant xLoadIconA = link_c_func(user32_dll, "LoadIconA", {C_UINT,C_INT}, C_INT) global constant xLoadCursorA = link_c_func(user32_dll, "LoadCursorA", {C_UINT,C_INT}, C_INT) global constant xRegisterClassExA = link_c_func(user32_dll, "RegisterClassExA", {C_UINT}, C_INT) global constant xCreateWindowExA = link_c_func(user32_dll, "CreateWindowExA", _INT,C_INT,C_INT,C_INT,C_INT,C_INT,C_INT,C_INT,C_INT,C_INT,C_INT,C_INT}, C_INT) global constant xGetMessageA = link_c_func(user32_dll, "GetMessageA", {C_INT,C_INT,C_INT,C_INT}, C_INT) global constant xBeginPaint = link_c_func(user32_dll, "BeginPaint", {C_INT,C_UINT}, C_INT) global constant xDefWindowProcA = link_c_func(user32_dll, "DefWindowProcA", {C_INT,C_INT,C_INT,C_INT}, C_INT) global constant xGetStockObject = link_c_func(gdi32_dll, "GetStockObject", {C_INT}, C_INT) -- link to the c_proc's global constant xShowWindow = link_c_proc(user32_dll, "ShowWindow", {C_INT,C_INT}) global constant xUpdateWindow = link_c_proc(user32_dll, "UpdateWindow", {C_INT}) global constant xTranslateMessage = link_c_proc(user32_dll, "TranslateMessage", {C_INT}) global constant xDispatchMessageA = link_c_proc(user32_dll, "DispatchMessageA", {C_INT}) global constant xGetClientRect = link_c_proc(user32_dll, "GetClientRect", {C_INT,C_UINT}) global constant xDrawTextA = link_c_proc(user32_dll, "DrawTextA", {C_INT,C_INT,C_INT,C_INT,C_INT}) global constant xEndPaint = link_c_proc(user32_dll, "EndPaint", {C_INT,C_INT}) global constant xPostQuitMessage = link_c_proc(user32_dll, "PostQuitMessage", {C_INT}) global constant xPlaySound = link_c_proc(winmm_dll, "PlaySound", {C_INT,C_INT,C_INT}) ----------------------------- -- c_func wrappers -- global function LoadIconA(atom arg1,atom arg2) return c_func(xLoadIconA,{arg1,arg2}) end function global function LoadCursorA(atom arg1,atom arg2) return c_func(xLoadCursorA,{arg1,arg2}) end function global function RegisterClassExA(atom arg1) return c_func(xRegisterClassExA,{arg1}) end function global function CreateWindowExA(atom arg1,atom arg2,atom arg3,atom arg4,atom arg5,atom arg6,atom arg7,atom arg8,atom arg9,atom arg10,atom arg11,atom arg12) return c_func(xCreateWindowExA,{arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12}) end function global procedure ShowWindow(atom arg1,atom arg2) c_proc(xShowWindow,{arg1,arg2}) end procedure global procedure UpdateWindow(atom arg1) c_proc(xUpdateWindow,{arg1}) end procedure global function GetMessageA(atom arg1,atom arg2,atom arg3,atom arg4) return c_func(xGetMessageA,{arg1,arg2,arg3,arg4}) end function global procedure TranslateMessage(atom arg1) c_proc(xTranslateMessage,{arg1}) end procedure global procedure DispatchMessageA(atom arg1) c_proc(xDispatchMessageA,{arg1}) end procedure global function BeginPaint(atom arg1,atom arg2) return c_func(xBeginPaint,{arg1,arg2}) end function global procedure GetClientRect(atom arg1,atom arg2) c_proc(xGetClientRect,{arg1,arg2}) end procedure global procedure DrawTextA(atom arg1,atom arg2,atom arg3,atom arg4,atom arg5) c_proc(xDrawTextA,{arg1,arg2,arg3,arg4,arg5}) end procedure global procedure EndPaint(atom arg1,atom arg2) c_proc(xEndPaint,{arg1,arg2}) end procedure global procedure PostQuitMessage(atom arg1) c_proc(xPostQuitMessage,{arg1}) end procedure global function DefWindowProcA(atom arg1,atom arg2,atom arg3,atom arg4) return c_func(xDefWindowProcA,{arg1,arg2,arg3,arg4}) end function global function GetStockObject(atom arg1) return c_func(xGetStockObject,{arg1}) end function global procedure PlaySound(atom arg1,atom arg2,atom arg3) c_proc(xPlaySound,{arg1,arg2,arg3}) end procedure
2. RE: DLL Automatic Wrapper Generator
- Posted by Andy Serpa <renegade at earthling.net> Feb 28, 2002
- 493 views
> Let me know what you think. I would like to get some test results > before I give it to the archives. > Looks good. One thing I would like to see is the ability to define a string argument in c function, and be able to pass to the generated wrapper function a Euphoria sequence/string. The function would automatically allocate_string(), call the c_func, then free() it. And if I pass an atom to the function instead, then it will assume it is a pointer and skip that step...
3. RE: DLL Automatic Wrapper Generator
- Posted by bensler at mail.com Feb 28, 2002
- 495 views
It does already handle passing strings, and does the work for them, even for the retVal of a c_func, but not objects yet. This version is still a rough prototype. I will probably allow for more flexibility. Any sequence used as an arg variable or retVal will be treated as such in the wrapper. if you define: {"Function",{C_INT,{},C_INT,etc},{}} the wrapper would look like this: (I haven't tested this yet) global function Function(integer arg1, sequence arg2, integer arg3, etc) atom ret atom tmp2 allocate_string(arg2) ret = c_func(xFunction,{arg1,tmp2,arg3,etc}) free(tmp2) return peek_string(ret) end function If all the args are sequences, it would allocate for all of them. It shouldn't be hard to fix it to work for pointers or atoms. Chris Andy Serpa wrote: > > > Let me know what you think. I would like to get some test results > > before I give it to the archives. > > > > Looks good. One thing I would like to see is the ability to define a > string argument in c function, and be able to pass to the generated > wrapper function a Euphoria sequence/string. The function would > automatically allocate_string(), call the c_func, then free() it. And > if I pass an atom to the function instead, then it will assume it is a > pointer and skip that step... > >
4. RE: DLL Automatic Wrapper Generator
- Posted by bensler at mail.com Mar 01, 2002
- 476 views
I've updated DAWG to handle object arguments for string parameters. I also fixed a couple little bugs I discovered when I did a detailed test. This is what you can do with DAWG: <TEST.EXW> include dawg.e constant DLL_List={ {"some.dll", { {"Some_Proc",{{},C_INT,C_ULONG}}, {"Some_Func",{{},{},{},{}},C_CHAR}, {"Another_Func",{C_SHORT,C_LONG},{}}, {"Variable"} } } } build_wrapper("test_wrap.e",DLL_List,1) puts(2,"done") <END TEST.EXW> This is what is generated: <TEST_WRAP.E> -- wrapper file generated using dawg.e by Chris Bensler -- link to the DLL's global constant some_dll = link_dll("some.dll") -- link to the c_var's global constant Variable_var = link_c_var(some_dll, "Variable") -- link to the c_func's global constant xSome_Func = link_c_func(some_dll, "Some_Func", {C_POINTER,C_POINTER,C_POINTER,C_POINTER}, C_CHAR) global constant xAnother_Func = link_c_func(some_dll, "Another_Func", {C_SHORT,C_LONG}, C_POINTER) -- link to the c_proc's global constant xSome_Proc = link_c_proc(some_dll, "Some_Proc", {C_POINTER,C_LONG,C_POINTER}) ----------------------------- -- c_func wrappers -- global function Some_Func(object arg1,object arg2,object arg3,object arg4) atom ret atom tmp1,tmp2,tmp3,tmp4 if sequence(arg1) then tmp1 = allocate_string(arg1) else tmp1 = arg1 end if if sequence(arg2) then tmp2 = allocate_string(arg2) else tmp2 = arg2 end if if sequence(arg3) then tmp3 = allocate_string(arg3) else tmp3 = arg3 end if if sequence(arg4) then tmp4 = allocate_string(arg4) else tmp4 = arg4 end if ret = c_func(xSome_Func,{tmp1,tmp2,tmp3,tmp4}) free(tmp1) free(tmp2) free(tmp3) free(tmp4) return ret end function global function Another_Func(integer arg1,integer arg2) return peek_string(c_func(xAnother_Func,{arg1,arg2})) end function ----------------------------- -- c_proc wrappers -- global procedure Some_Proc(object arg1,integer arg2,atom arg3) atom tmp1 if sequence(arg1) then tmp1 = allocate_string(arg1) else tmp1 = arg1 end if c_proc(xSome_Proc,{tmp1,arg2,arg3}) free(tmp1) end procedure <END TEST_WRAP.E> Chris bensler at mail.com wrote: > It does already handle passing strings, and does the work for them, even > > for the retVal of a c_func, but not objects yet. > This version is still a rough prototype. I will probably allow for more > flexibility. > > Any sequence used as an arg variable or retVal will be treated as such > in the wrapper. > > if you define: > {"Function",{C_INT,{},C_INT,etc},{}} > > the wrapper would look like this: (I haven't tested this yet) > global function Function(integer arg1, sequence arg2, integer arg3, etc) > atom ret > atom tmp2 > allocate_string(arg2) > ret = c_func(xFunction,{arg1,tmp2,arg3,etc}) > free(tmp2) > return peek_string(ret) > end function > > If all the args are sequences, it would allocate for all of them. > > It shouldn't be hard to fix it to work for pointers or atoms. > > > Chris > > > Andy Serpa wrote: > > > > > Let me know what you think. I would like to get some test results > > > before I give it to the archives. > > > > > > > Looks good. One thing I would like to see is the ability to define a > > string argument in c function, and be able to pass to the generated > > wrapper function a Euphoria sequence/string. The function would > > automatically allocate_string(), call the c_func, then free() it. And > > if I pass an atom to the function instead, then it will assume it is a > > pointer and skip that step... > > > >
5. RE: DLL Automatic Wrapper Generator
- Posted by Andy Serpa <renegade at earthling.net> Mar 01, 2002
- 481 views
bensler at mail.com wrote: > I've updated DAWG to handle object arguments for string parameters. > I also fixed a couple little bugs I discovered when I did a detailed > test. > ALMOST perfect. But what I had in mind would be skip the "free" step also if you pass it an atom for a string argument. In other words, the function should only free() it if the function allocate_string()'s it -- in my mind the whole reason you would be passing a pointer instead of the actual string was if you had pre-allocated it, and wanted it to stay allocated after the function call, otherwise you would just pass the string directly. See what I mean? But good work -- I will definitely find this useful. I will vote for it when you put it in the archive...
6. RE: DLL Automatic Wrapper Generator
- Posted by bensler at mail.com Mar 01, 2002
- 493 views
I noticed that just after posting last time. It's already fixed. This is the line generated now. if sequence(argX) then free(tmpX) end if Chris Andy Serpa wrote: > > bensler at mail.com wrote: > > I've updated DAWG to handle object arguments for string parameters. > > I also fixed a couple little bugs I discovered when I did a detailed > > test. > > > > ALMOST perfect. But what I had in mind would be skip the "free" step > also if you pass it an atom for a string argument. > > In other words, the function should only free() it if the function > allocate_string()'s it -- in my mind the whole reason you would be > passing a pointer instead of the actual string was if you had > pre-allocated it, and wanted it to stay allocated after the function > call, otherwise you would just pass the string directly. See what I > mean? > > But good work -- I will definitely find this useful. I will vote for it > > when you put it in the archive... > >
7. RE: DLL Automatic Wrapper Generator
- Posted by Bernie Ryan <xotron at localnet.com> Mar 01, 2002
- 464 views
bensler at mail.com wrote: > Hello all, > > I've created a DLL Automatic Wrapper Generator. > > You give it a link_list, and build a wrapper on the fly. > The generated wrapper can then be used without having to define the > link_list. Chris If you check out my library that I wrote last year. It also has the same capability as yours; in addtion it also has all of the win32 functions already wrapped. All you have to do is describe any DLL FUNCTION or STRUCTURE and then you will be able to use it. It supports both unicode and ascii strings. http://www.rapideuphoria.com/w32engin.zip Bernie
8. RE: DLL Automatic Wrapper Generator
- Posted by bensler at mail.com Mar 01, 2002
- 487 views
Hi Bernie, I looked at it before when you released it. First of all, try doing a search for DLL or wrapper in the archives. Does it say anything about your library? I am not about to spend the time to look at every file in the archives to see if what I need is there. My hope is that I can create some libraries for the archives, even IF they are already available, that will be more accurately described, and hopefully easier to use. Second, your implementation seemed difficult to use, and I didn't find any demos of how it works. Third, you library is shrouded. I put in my junk pile the same day I dl'd it. No offense to you, but I don't like the idea of not sharing my code. It makes it 20 times more difficult to understand what it is the library is supposed to do. Four, I'm hoping that my library will be a stepping stone towards the creation, distribution, and sharing of wrapper libraries. How many people have spent the time to write a partial wrapper for win32, but didn't bother to share it with the rest of us? Chris Bernie Ryan wrote: > > bensler at mail.com wrote: > > Hello all, > > > > I've created a DLL Automatic Wrapper Generator. > > > > You give it a link_list, and build a wrapper on the fly. > > The generated wrapper can then be used without having to define the > > link_list. > > Chris > If you check out my library that I wrote last year. > It also has the same capability as yours; in addtion it > also has all of the win32 functions already wrapped. > All you have to do is describe any DLL FUNCTION or > STRUCTURE and then you will be able to use it. > It supports both unicode and ascii strings. > > http://www.rapideuphoria.com/w32engin.zip > > Bernie > >
9. RE: DLL Automatic Wrapper Generator
- Posted by Bernie Ryan <xotron at localnet.com> Mar 01, 2002
- 480 views
bensler at mail.com wrote: > Hi Bernie, > > I looked at it before when you released it. > > First of all, try doing a search for DLL or wrapper in the archives. > Does it say anything about your library? I am not about to spend the > time to look at every file in the archives to see if what I need is > there. The discriptions in the archive are written by RDS and do not accurately describe many of the zip files in the archive. > > My hope is that I can create some libraries for the archives, even IF > they are already available, that will be more accurately described, and > hopefully easier to use. > > Second, your implementation seemed difficult to use, and I didn't > find any demos of how it works. The zip file contains 3 demos. It contains a utility to use window's resources. It also contains 5 text files that explain how to use things. > > Third, you library is shrouded. I put in my junk pile the same day I > dl'd it. No offense to you, but I don't like the idea of not sharing my > code. It makes it 20 times more difficult to understand what it is the > library is supposed to do. The library is shrouded because I did not want it to become so extremely modified so that it is difficult to maintain. The library allows anyone to extended it without having to be bothered by the internal working mechanisms. > Four, I'm hoping that my library will be a stepping stone towards the > creation, distribution, and sharing of wrapper libraries. How many > people have spent the time to write a partial wrapper for win32, but > didn't bother to share it with the rest of us? If I didn't want to share it it wouldn't be in the archive. I placed other code in the archive that is not shrouded. Bernie
10. RE: DLL Automatic Wrapper Generator
- Posted by bensler at mail.com Mar 01, 2002
- 454 views
Sorry Bernie, You misinterpretted what I was saying. I was just saying, I look at your lib before, and it overwhelmed me. I couldn't find a demo of how to use piston. I looked at the docs, but they just confused me. The fact that your code was shrouded simply turned me off. Nothing to do with the fact of not being shared. I learn from looking and examining the library is the easiest way for me to learn how to use it. By wrappers not being shared in the archives, I was referring to open source wrappers, for general use, not yours. Sorry I gave you that impression. I've wrapped all the links that are in win32libv0551. One wrapper for each dll. Just to see how it works (found some bugs in DAWG). I plan to contribute those in the hopes that they will be added to, and made more complete. Also that they can be incorporated into win32lib quite easily, I think. DAWG and the DLL_link_list template program for the wrappers will be distributed with them. Hopefully, the simplicty of use, and convenience will promote people to add to it. Chris Bernie Ryan wrote: > > bensler at mail.com wrote: > > Hi Bernie, > > > > I looked at it before when you released it. > > > > First of all, try doing a search for DLL or wrapper in the archives. > > Does it say anything about your library? I am not about to spend the > > time to look at every file in the archives to see if what I need is > > there. > > The discriptions in the archive are written by RDS and do > not accurately describe many of the zip files in the > archive. > > > > > My hope is that I can create some libraries for the archives, even IF > > they are already available, that will be more accurately described, and > > hopefully easier to use. > > > > Second, your implementation seemed difficult to use, and I didn't > > find any demos of how it works. > > The zip file contains 3 demos. > It contains a utility to use window's resources. > It also contains 5 text files that explain how to use things. > > > > > Third, you library is shrouded. I put in my junk pile the same day I > > dl'd it. No offense to you, but I don't like the idea of not sharing my > > code. It makes it 20 times more difficult to understand what it is the > > library is supposed to do. > > > The library is shrouded because I did not want it to become > so extremely modified so that it is difficult to maintain. > The library allows anyone to extended it without having > to be bothered by the internal working mechanisms. > > > Four, I'm hoping that my library will be a stepping stone towards the > > creation, distribution, and sharing of wrapper libraries. How many > > people have spent the time to write a partial wrapper for win32, but > > didn't bother to share it with the rest of us? > > If I didn't want to share it it wouldn't be in the archive. > > I placed other code in the archive that is not shrouded. > > Bernie > >