Hi to all, some time ago I had the idea of making "invoke", "stdcall", and all that stuff capable of handling ada syntax but since I think I will never finish it I decided to post my incomplete code just for if someone want to finish it.
macro proto name, [args]{
common
local count
count = 0
PROTO # name = 1
forward
count = count + 1
argPROTO # name # args = count
common
countPROTO # name = count
}
proto MessageBox,\
hWnd,\ ; handle of owner window
lpText,\ ; address of text in message box
lpCaption,\ ; address of title of message box
uType ; style of message box
macro adainv name, [args]
{
common
local count, passed
count = 0
if ~defined PROTO # name
display "There is no procedure nor proto with name """, `name, """"
err
end if
forward
if 1
match arg ==> value, args
\{
if ~defined argPROTO \# name \# arg
display \`arg, " is not an argument of ", \`name
err
end if
if defined arg \# passed
display "Argument ", \`arg, " of ", \`name, " already passed"
err
end if
arg \# passed equ 1 ; To signal arg was passed
count = count + 1
else
\}
display "Invalid argument"
err
end if
common
local arg_list
arg_list equ
if countPROTO # name > count
display "At least an argument is missing"
err
end if
; ##### At this point we are ready to reorder the arguments (if needed) before calling the procedure/function
}
adainv MessageBox, hWnd => 0, lpText => text, lpCaption => NULL, uType => MB_ICONINFORMATION
adainv MessageBox, uType => MB_ICONINFORMATION, lpCaption => NULL, lpText => text, hWnd => 0
adainv MessageBox, lpCaption => NULL, hWnd => 0, lpText => text, uType => MB_ICONINFORMATION
Note that the macro doesn't handle unnamed args (which violates the ada syntax).
Well I don't know, I think it could be nice that FASM package supports it but I a very bad macro writer and is to hard for me making it :'(