The native unicode support is very easy to use now that the pre-processor allows some more complex macros.
repargu MACRO arg ;; UNICODE version
LOCAL nustr
IF (OPATTR arg) AND 8000h ;; is it a "string"...?
.data
nustr dw arg,0 ;; write arg to .DATA section
.code
EXITM <ADDR nustr> ;; append name to ADDR operator
ELSE
EXITM <arg> ;; else return arg
ENDIF
ENDM
ufn MACRO FuncName:REQ,args:VARARG
arg equ <invoke FuncName> ;; construct invoke and function name
FOR var,<args> ;; loop through all arguments
arg CATSTR arg,<,>,repargu(var) ;; replace quotes and append arg
ENDM
arg ;; write the invoke macro
ENDM
urv MACRO FuncName:REQ,args:VARARG
arg equ <invoke FuncName> ;; construct invoke and function name
FOR var,<args> ;; loop through all arguments
arg CATSTR arg,<,>,repargu(var) ;; replace quotes and append arg
ENDM
arg ;; write the invoke macro
EXITM <eax>
ENDM
-------------------
Just append the "W" at the end of the API name, change
the macro to "urv" and BINGO,Instant UNICODE support.
mov retval, urv(MessageBoxW,hWnd,"Testing the RV macro","Title",MB_OK)
not to be picky...but is there any convention as to where the 'u' goes between the ASCII/UNICODE macro.
Point is case being "fn" becomes "ufn", but "reparg" becomes" "repargu".
just an idea...
instead of using only "u" could we use "uni" ?
I say that because a single "u" is easier to miss than "uni" !!!
There could be other ways too...PREPENDING "uni_" or APPENDING "_uni"
This is just an idea...I won't bug you about this any more :cheekygreen: totally upto you ! :)
I am much more interested in readability that some arbitrary convention.
The other factor is to keep the macro name short. Things like this_is_a_unicode_macro_that_returns_a_dword_value don't improve readability but they sure increase the typing.
I agree !!!
>>...some arbitrary convention.
Yes I know...somebody starts spewing words like "convention", "standards", "guidelines", etc, I'd feel like slapping them too. :)
I know I'd said I will not bug you...I'm STILL NOT going to bug you...just a small point. :)
The thought was for new programmers, you know...patterns are easier to learn (like the ...Ex thing with the Win32 API)..., thats all. :)
How about a pre-include UNICODE flag which selects which macro set and function equates (ie. GetWindowText EQU GetWindowTextA) to use?
I was happy reading this:
Quote
The native unicode support is very easy to use now that the pre-processor allows some more complex macros.
and try:
Quote
;chaine DW 'U','N','I',"C","O","D","E",0
chaine DW "UNICODE",0
answer of ml error A2084:constant value too large
only the form chaine DW 'U','N','I',"C","O","D","E",0 is accepted.
Is there another macro who do that ?
/masm32/macros/ucmacros.asm
-> WSTR and uni$()
Thanks