News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Method overloading

Started by HSE, October 01, 2018, 10:57:00 AM

Previous topic - Next topic

HSE

Hi Biterider!

Playing with the idea of overloading, I make it to work after a while.
VirtualMethod macro MName:req, Args:vararg
    MNameO textequ @CatStr (&MName , argcount(Args)) 
    PrototypeMethod %ObjName, %MNameO, Args
%   ??Index = &ObjName&_VtlMtdCount + 1
%   &ObjName&_VtlMtdCount = ??Index
%   @CatStr(%ObjName, <_VtlMethod_Name_>, %??Index) textequ <MNameO>
%   @CatStr(%ObjName, <_VtlMethod_Proc_>, %??Index) textequ <offset @CatStr(&ObjName&,<_>, %MNameO)>
%   @CatStr(%ObjName, %MNameO,<_Access>) = ??MethodAccess
endm


Very clear in VirtualMethods: VirtualMethod  InitSerie, DWORD, DWORD, DWORD    ;-> Prioridad, Color, Modalidad
  VirtualMethodO InitSerie, DWORD, DWORD    ;-> Modalidad, Color o puntero a estructura


Not so nice when RedefineMethod:  RedefineMethod  Init, DWORD, DWORD, DWORD    ;-> Prioridad, Color, Modalidad
  VirtualMethodO  Init, DWORD, DWORD    ;-> Prioridad, Color, Modalidad

In this case the overloading is by number of arguments, but it's posible also by argument types.

I don't know if worth the additional preprocessing. Now I only testing without change main macros, instead I added VirtualMethodO, MethodO and OCallO.

Regards. HSE
Equations in Assembly: SmplMath

Biterider

Hi HSE
Interesting purposal  :t
I'll look into it, but I'm very busy atm. I'm working on the header translation and and an a name mangling concept to prevent object and method name collisions with existing APIs. COM is still a challenge to get the multiple definition styles in MS headers to work consistently in asm.
I'll come back to you.  ;)

Biterider

HSE

Equations in Assembly: SmplMath