Author Topic: c++ interface translate  (Read 1318 times)

ToutEnMasm

  • Member
  • *****
  • Posts: 1184
    • EditMasm
c++ interface translate
« on: February 05, 2016, 07:29:07 PM »
i am working on the translation for masm of c++ interface.
One (win10) isn't very easy to understand
Quote
interface DX_DECLARE_INTERFACE("2cd906a8-12e2-11dc-9fed-001143a055f9") ID2D1Brush  : public ID2D1Resource
{
   
   
    //
    // Sets the opacity for when the brush is drawn over the entire fill of the brush.
    //
    STDMETHOD_(void, SetOpacity)(
        FLOAT opacity
        ) PURE;
   
   
    //
    // Sets the transform that applies to everything drawn by the brush.
    //
    STDMETHOD_(void, SetTransform)(
        _In_ CONST D2D1_MATRIX_3X2_F *transform
        ) PURE;
   
    STDMETHOD_(FLOAT, GetOpacity)(
        ) CONST PURE;
   
    STDMETHOD_(void, GetTransform)(
        _Out_ D2D1_MATRIX_3X2_F *transform
        ) CONST PURE;
   
    COM_DECLSPEC_NOTHROW
    void
    SetTransform(
        CONST D2D1_MATRIX_3X2_F &transform
        ) 
    {
        SetTransform(&transform);
    }
}; // interface ID2D1Brush
The SetTransform is repeated twice,The first is the normal form of an Interface Function and the second look like the declaration of an api.
How to interpret This?.
The second SetTransform is it part of the interface or not ?.
Is this form correct ?

Quote
;+-----------------------------------------------------------------------------
;
;  Interface:
;      ID2D1Brush
;
;  Synopsis:
;      The root brush interface. All brushes can be used to fill or pen a geometry.
; The SetTransform is said overloaded
;
;------------------------------------------------------------------------------
sIID_ID2D1Brush TEXTEQU <{02cd906a8H,012e2H,011dcH,{09fH,0edH,000H,011H,043H,0a0H,055H,0f9H}}>

ID2D1Brush_SetOpacity TYPEDEF  PROTO :XMASM ,opacity:REAL4
FID2D1Brush_SetOpacity TYPEDEF PTR  ID2D1Brush_SetOpacity

ID2D1Brush_SetTransform TYPEDEF  PROTO :XMASM ,transform:XMASM
FID2D1Brush_SetTransform TYPEDEF PTR  ID2D1Brush_SetTransform

ID2D1Brush_GetTransform TYPEDEF  PROTO :XMASM ,transform:XMASM
FID2D1Brush_GetTransform TYPEDEF PTR  ID2D1Brush_GetTransform


      INTERFACE_ID2D1Brush   MACRO
      SetOpacity      FID2D1Brush_SetOpacity  ?
      SetTransform      FID2D1Brush_SetTransform  ?
      GetOpacity                      comethod1 ?
      GetTransform      FID2D1Brush_GetTransform  ?
      ENDM

STID2D1Brush   STRUCT
   INTERFACE_ID2D1Resource
   INTERFACE_ID2D1Brush
STID2D1Brush   ENDS

 
ID2D1Brush MACRO  Function:REQ, args:VARARG
   ; definition de la macro locale InvokeInterface
    LOCAL InvokeInterface, arg
    FOR arg, <args>     ;verifier que edx n'est pas dans la liste d'arguments args
        IFIDNI <&arg>, <PPVREGISTER>   ;
            .ERR <%PPVREGISTER is not allowed as a coinvoke parameter>
        ENDIF
    ENDM
    IFIDNI <&pInterface>, <PPVREGISTER>
        .ERR <PPVREGISTER is not allowed as a coinvoke parameter>
    ENDIF
   ;InvokeInterface = concatene ...CATSTR(concatene) MACRO instruction MASM32   
   ;---------- on doit mettre ppv en premier argument -----------------------------------
    InvokeInterface CATSTR <invoke (STID2D1Brush PTR[PPVREGISTER]).>,<&Function,ppvID2D1Brush>
    IFNB <args>     ; add the list of parameter arguments if any
        InvokeInterface CATSTR InvokeInterface, <, >, <&args>
    ENDIF
   ;   forme les lignes de codes
    mov PPVREGISTER, ppvID2D1Brush
    mov PPVREGISTER, [PPVREGISTER]
    InvokeInterface
ENDM      


Fa is a musical note to play with CL

Zen

  • Member
  • ****
  • Posts: 962
  • slightly red-shifted
Re: c++ interface translate
« Reply #1 on: May 01, 2016, 04:23:07 AM »
Hi, TOUTENMASM,
Sorry, I just noticed this post,...you've probably already figured it out.

Does ID2D1Resource have a SetTransform method ?
Notice how in the C++ ID2D1Brush Interface declaration, all the methods have normal parentheses () after the method name, in which the method parameters are listed ? This is the form of a virtual function, isn't it ? And in the declaration of SetTransform, after the normal parenthesis, there is a line with the curly braces, as follows,...
Code: [Select]
{
        SetTransform(&transform);
}

That version of the SetTransform ends with a semicolon, which means it is a statement...I think that this form is like an implementation,...probably invoking the SetTransform method of ID2D1Resource.

But, I'm guessing,...I've forgotten all the COM stuff that I learned,...before I lost my mind to old age and dementia,...sorry,...:bgrin:

...Of course, in MASM assembly language,...you don't have inheritance. So you would just implement the SetTransform method however you want, and call it with a pointer from the vtable,...am I right ? Really,...in all seriousness,...that explanation confused even me (ha, ha),... :icon_eek:
« Last Edit: May 01, 2016, 05:58:57 AM by Zen »
Zen

qWord

  • Member
  • *****
  • Posts: 1449
  • The base type of a type is the type itself
    • SmplMath macros
Re: c++ interface translate
« Reply #2 on: May 01, 2016, 09:01:35 AM »
SetTransform is an overloaded method (in c++) and only the first version (STDMETHOD_(...)) is part of COM interface.
MREAL macros - when you need floating point arithmetic while assembling!

Zen

  • Member
  • ****
  • Posts: 962
  • slightly red-shifted
Re: c++ interface translate
« Reply #3 on: May 03, 2016, 04:59:23 AM »
Ah, ha,...well, that was going to be my next guess,...:bgrin:
Good to hear from you QWORD,...
Zen