View previous topic :: View next topic |
Author |
Message |
JJR
Joined: 22 Feb 2004 Posts: 1104
|
Posted: Wed Apr 28, 2004 3:31 am Post subject: Win32 BOOL Type Equivalence |
|
|
Inside OS.java, there are native definitions:
public static final native boolean BringWindowToTop( int hWnd );
In DWT's current OS.d module, we have:
extern(Windows):
...
bit BringWindowToTop(int hWnd);
...
The actual Windows C function call is:
BOOL BringWindowToTop( HWND hWnd );
My question: how does boolean or bit map to windows BOOL? Isn't the windows BOOL an integer? If Java is using boolean to map to BOOL, is it safe to use the D bit to map also? If the real BOOL is really an integer type, woundn't it be more accurate (and safer?) to use the same type to access the function from D? |
|
Back to top |
|
|
brad Site Admin
Joined: 22 Feb 2004 Posts: 490 Location: Atlanta, GA USA
|
Posted: Wed Apr 28, 2004 7:37 am Post subject: |
|
|
change all the bits to bool. It is aliased in Object.d anyway. There was a discussion about it elsewhere in the forum. _________________ I really like the vest! |
|
Back to top |
|
|
andy
Joined: 15 Mar 2004 Posts: 71
|
Posted: Wed Apr 28, 2004 10:42 am Post subject: |
|
|
Is that binary-compatible with what C does? (I believe C just uses an integer) _________________ "Complacency is a far more dangerous attitude than outrage." - Naomi Littlebear |
|
Back to top |
|
|
JJR
Joined: 22 Feb 2004 Posts: 1104
|
Posted: Wed Apr 28, 2004 12:43 pm Post subject: |
|
|
brad wrote: | change all the bits to bool. It is aliased in Object.d anyway. There was a discussion about it elsewhere in the forum. |
Um... That wasn't quite my question. I agree we should do that for all situations where a "bit" is used.
But these C window functions are prefixed with BOOL, which is not the same as a bit (or bool). Someone decided to use "bit" to interface to the function in D based on SWT's decision to use boolean. Is the windows definition of BOOL correctly mapped to D bit. Maybe we should be using a simple "int" for that. |
|
Back to top |
|
|
brad Site Admin
Joined: 22 Feb 2004 Posts: 490 Location: Atlanta, GA USA
|
Posted: Wed Apr 28, 2004 1:18 pm Post subject: |
|
|
I see (said the blind man). Maybe int is safer. _________________ I really like the vest! |
|
Back to top |
|
|
larsivi Site Admin
Joined: 27 Mar 2004 Posts: 453 Location: Trondheim, Norway
|
Posted: Wed Apr 28, 2004 2:29 pm Post subject: |
|
|
From std.c.windows.windows:
|
|
Back to top |
|
|
JJR
Joined: 22 Feb 2004 Posts: 1104
|
Posted: Wed Apr 28, 2004 2:38 pm Post subject: |
|
|
larsivi wrote: | From std.c.windows.windows:
|
Thanks! That's exactly what I wanted to know. We should use the BOOL on these extern declarations then (or create our own alias).
The other point is that perhaps we don't need these declared in dwt.internal.win32.os.d afterall. We should probably just import std.c.windows.windows or an equivalent into OS.d at this spot. The work is already done for us, no? |
|
Back to top |
|
|
andy
Joined: 15 Mar 2004 Posts: 71
|
Posted: Sat May 01, 2004 11:54 am Post subject: |
|
|
dwt.internal.win32.os is already done, actually. I've been using it thus far, in dwt.internal and dwt.graphics.
For the type names, I've avoided all the pointless win32 type aliases and just used the native D type instead (in the case of BOOL, plain old int)
I can change things to use std.windows instead, I suppose, which may be benificial in that it does hammer the types down a tad better. I'll do that once dwt.graphics compiles. _________________ "Complacency is a far more dangerous attitude than outrage." - Naomi Littlebear |
|
Back to top |
|
|
JJR
Joined: 22 Feb 2004 Posts: 1104
|
Posted: Sat May 01, 2004 12:19 pm Post subject: |
|
|
andy wrote: | dwt.internal.win32.os is already done, actually. I've been using it thus far, in dwt.internal and dwt.graphics. |
I didn't realize this. If so, we're a lot further along then I realized. I haven't been keeping track of what's been getting done in win32.
andy wrote: | For the type names, I've avoided all the pointless win32 type aliases and just used the native D type instead (in the case of BOOL, plain old int) |
That's fine for functionality for now.... might be better for readability if it's done with proper decoration later.
andy wrote: | I can change things to use std.windows instead, I suppose, which may be benificial in that it does hammer the types down a tad better. I'll do that once dwt.graphics compiles. |
I think this would be a good idea... it reduces the number of source files as well. Although, If it works as is right now.... don't worry about it. We can leave it for later.
As for dwt.graphics.... Brad has updated the DWT project in subversion using the framework I sent him. This new one is in the "trunk" directory. When you get graphics working, we'll see that it gets put into trunk.dwt.graphics (and see how it ties in).... we'll also need to make sure that your win32 is the same as what's in there. I've got a new makefile in the trunk.dwt directory. You may have to change or replace it once you submit your graphics package.
If you need a hand with getting graphics to compile, give me a holler...
Once the graphics package is done, that'll leave the widgets/events/dispatcher/threading stuff to do.
Thanks for all the work you've done.
-John R. |
|
Back to top |
|
|
jcc7
Joined: 22 Feb 2004 Posts: 657 Location: Muskogee, OK, USA
|
Posted: Sat May 01, 2004 6:53 pm Post subject: Using std.c.windows.windows |
|
|
andy wrote: | I can change things to use std.windows instead, I suppose, which may be benificial in that it does hammer the types down a tad better. I'll do that once dwt.graphics compiles. | I don't know if importing std.c.windows.windows is such a good idea. It's not complete, and Walter has a habit of arbitrarily adding definitions to it. Projects that compiled in an earlier version of DMD fail in a later version due to more complete windows headers in Phobos.
I'm not saying you can't use std.c.windows.windows, I'm just mentioning a possible drawback. For example, Walter has added stuff to it with DMD 0.86 (I'm guessing porting Empire inspired him), and now Stewart SDWF doesn't compile anymore. |
|
Back to top |
|
|
andy
Joined: 15 Mar 2004 Posts: 71
|
Posted: Sat May 01, 2004 7:12 pm Post subject: |
|
|
Excellent point.
It's not broken, so it's probably best not to fix it. _________________ "Complacency is a far more dangerous attitude than outrage." - Naomi Littlebear |
|
Back to top |
|
|
JJR
Joined: 22 Feb 2004 Posts: 1104
|
Posted: Sat May 01, 2004 10:31 pm Post subject: |
|
|
True... no need to touch it now.... But wasn't there a more complete D windows import done by someone else? I think it was directly converted from the SDK. That one would be the most complete. |
|
Back to top |
|
|
brad Site Admin
Joined: 22 Feb 2004 Posts: 490 Location: Atlanta, GA USA
|
Posted: Sat May 01, 2004 10:37 pm Post subject: |
|
|
Forgive me if I offend: it was one of the Japanese guys... _________________ I really like the vest! |
|
Back to top |
|
|
jcc7
Joined: 22 Feb 2004 Posts: 657 Location: Muskogee, OK, USA
|
Posted: Sat May 01, 2004 11:39 pm Post subject: Windows Headers |
|
|
JJR wrote: | But wasn't there a more complete D windows import done by someone else? | I think Y. Tomino's port is the most complete one out there. It's created by a Perl script IIRC.
I've used it. It's very thorough. (I think it's being used by Dig-Dug, too.) |
|
Back to top |
|
|
JJR
Joined: 22 Feb 2004 Posts: 1104
|
Posted: Sun May 02, 2004 4:58 pm Post subject: |
|
|
Thanks,
I may consider trying it out at some point with DWT, fust for fun. It'll be interesting to see how the window module fits in.
Later,
John |
|
Back to top |
|
|
|