Page 1 of 1
Aliased types?
Posted: Sun Nov 30, 2003 7:30 pm
by Hi-Toro
I don't urgently need this, but I had this idea while trying to (unsuccessfully) convert dsound.h (if anyone's done it, please let me know!) -- the ability to define 'aliases' for types used in various APIs. For example:
Code: Select all
Alias HANDLE .l
Alias HWND .l
Alias BOOL .b
; ... etc...
mywindow.HWND = WindowFromPoint_ (BLAH BLAH BLAH)
; mywindow is then a .l handle...
Might be useful for porting of sources from other languages/APIs, so you don't have to keep checking for the 'PB equivalent' type while translating sources...
Posted: Wed Feb 21, 2007 3:59 am
by mr daniel reed
Hitorro check this out
I found a a way to accomplish this using macros,
Code: Select all
Macro HWND
l
EndMacro
Global hMyWnd.HWND
I know, it looks horrible, but it works!
Posted: Wed Feb 21, 2007 12:56 pm
by Rescator
Yeah no kidding, it's starting to look like C *laughs*.
Posted: Wed Feb 21, 2007 2:03 pm
by mr daniel reed
It'd be great if they would make it a define macro instead.
Like:
#Define HWND .l
This would be a hell of alot cleaner than my previous post.
Posted: Thu Feb 22, 2007 3:04 pm
by DoubleDutch
It can be done on one line though - maybe neater?
Code: Select all
Macro HWND : l : EndMacro
a.HWND=4
b=3
c= a+b
Debug c
Nested Macros would make it look nicer, you then make an...
Alias(HWND,l)
macro!
Posted: Tue Feb 27, 2007 12:31 pm
by remi_meier
I would like to see this too. With macros there is a big problem at the
moment. When I try to add the type 'i' (for a dynamic integer type),
with a macro like
Code: Select all
CompilerIf #Is32bit
Macro i
l
EndMacro
CompilerElse
Macro i
q
EndMacro
CompilerEndIf
I mustn't use the variable name "i", "q", "l" anymore because of things
like
Code: Select all
For i = 0 to 10
For l = 0 to 20
Next
Next