flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > fasm1 - I have to define Restore member

Thread Post new topic Reply to topic

Joined: 24 Mar 2012
Posts: 700
Location: Russian Federation, Sochi
ProMiNick 20 Nov 2019, 10:00
Problem self resolved - struct member conflict with assembler directive name:

macro interface definition
        match name tail, definition: \{
                        db \`name
                        load initial@struct byte from $$
                        if initial@struct = '.'
                                display 'Error: name of interface should not begin with a dot.',0Dh,0Ah
                        end if
                end virtual

                macro endi \\{
                        if $
                                display 'Error: definition of ',\`name,' contains illegal instructions.',0Dh,0Ah
                        end if
                        match =@guid,@guid \\\{
                                         display 'Error: missing GUID in definition of ',\`name,0Dh,0Ah
                                         err \\\}
                        restruc stdmethod
                        purge endi
                        irpv methods,method@vtbl \\\{
                                restore method@vtbl
                                ;define methods@vtbl methods
                                define@vtbl name,methods
                                define methods@\#name methods \\\}
                        IID_\#name equ @guid
                        restore @vtbl, @guid
                        ;define@vtbl methods@vtbl
                        ;match methods,methods@vtbl \\\{ \\\}
                        end virtual \\}

                ;match :,tail \\{  \\}
                match =extends parent:, tail \\{ method@vtbl equ methods@\\#parent \\} \}

        struc stdmethod args& \{ define method@vtbl . \}
        macro GUID ID& \{ define @guid ID
                purge GUID \}
        define @vtbl
        virtual at 0 }

macro define@vtbl name,[method]
        match no, @vtbl \{
                disply 'Error: define@vtbl is used outside of interface definition.',0Dh,0Ah
                err \}
        name#.#method PTR ?
        local value
        name#.com.interface = $ / sizeof.PTR

        restruc name
        struc name vtbl:? \{
                match , @struct \\{ define field@struct .,name,vtbl \\}
                match no, @struct \\{ . PTR vtbl
                        virtual at 0
                                .#method PTR ?
                                .\#\\.com.object = name#.com.interface
                        end virtual \\} \}
        restruc name#Vtbl
        struc name#Vtbl value \{ \local \..base
                label \..base
                .#method PTR value
                label . at \..base \}

macro comobject name
                db `name
                load initial@struct byte from $$
                if initial@struct = '.'
                        display 'Error: name of com object should not begin with a dot.',0Dh,0Ah
                end if
        end virtual

        macro endo \{
                if $
                        display 'Error: definition of ',`name,' contains illegal instructions.',0Dh,0Ah
                end if
                match =@guid,@guid \\{
                                 display 'Error: missing GUID in definition of ',`name,0Dh,0Ah
                                 err \\}
                restruc stdmethod
                purge endo
                CLSID_#name equ @guid
                restore @vtbl, @guid
                end virtual \}

        macro CLSID ID& \{ define @guid ID
                purge CLSID \}
        define @vtbl

        virtual at 0}

previously should be defined "struc PTR"    

define _DIRECTX1_H

interface IDirectDraw extends IUnknown
  GUID                          6C14DB80-A733-11CE-A521-0020AF0BE560
  Compact                       stdmethod(IDirectDraw *THIS)
  CreateClipper                 stdmethod(IDirectDraw *THIS, DWORD dwFlags, LPDIRECTDRAWCLIPPER *lplpDDClipper, IUnknown *pUnkOuter)
  CreatePalette                 stdmethod(IDirectDraw *THIS, DirectDrawPaletteCapsFlags dwFlags, LPPALETTEENTRY lpDDColorArray, LPDIRECTDRAWPALETTE *lplpDDPalette, IUnknown *pUnkOuter)
  CreateSurface                 stdmethod(IDirectDraw *THIS, LPDDSURFACEDESC lpDDSurfaceDesc, LPDIRECTDRAWSURFACE *lplpDDSurface, IUnknown *pUnkOuter)
  DuplicateSurface              stdmethod(IDirectDraw *THIS, LPDIRECTDRAWSURFACE lpDDSurface, LPDIRECTDRAWSURFACE *lplpDupDDSurface)
  EnumDisplayModes              stdmethod(IDirectDraw *THIS, DirectDrawEnumDisplayModesFlags dwFlags, LPDDSURFACEDESC lpDDSurfaceDesc, LPVOID lpContext, LPDDENUMMODESCALLBACK lpEnumModesCallback)
  EnumSurfaces                  stdmethod(IDirectDraw *THIS, DirectDrawEnumSurfacesFlags dwFlags, LPDDSURFACEDESC lpDDSurfaceDesc, LPVOID lpContext, LPDDENUMSURFACESCALLBACK lpEnumSurfacesCallback)
  FlipToGDISurface              stdmethod(IDirectDraw *THIS)
  GetCaps                       stdmethod(IDirectDraw *THIS, LPDDCAPS lpDDDriverCaps, LPDDCAPS lpDDHELCaps)
  GetDisplayMode                stdmethod(IDirectDraw *THIS, LPDDSURFACEDESC lpDDSurfaceDesc)
  GetFourCCCodes                stdmethod(IDirectDraw *THIS, LPDWORD lpNumCodes, LPDWORD lpCodes)
  GetGDISurface                 stdmethod(IDirectDraw *THIS, LPDIRECTDRAWSURFACE *lplpGDIDDSSurface)
  GetMonitorFrequency           stdmethod(IDirectDraw *THIS, LPDWORD lpdwFrequency)
  GetScanLine                   stdmethod(IDirectDraw *THIS, LPDWORD lpdwScanLine)
  GetVerticalBlankStatus        stdmethod(IDirectDraw *THIS, LPBOOL lpbIsInVB)
  Initialize                    stdmethod(IDirectDraw *THIS, GUID * lpGUID)
  RestoreDisplayMode            stdmethod(IDirectDraw *THIS)
  SetCooperativeLevel           stdmethod(IDirectDraw *THIS, HWND hWnd, DirectDrawSetCooperativeLevelFlags dwFlags)
  SetDisplayMode                stdmethod(IDirectDraw *THIS, DWORD dwWidth, DWORD dwHeight, DWORD dwBPP)
  WaitForVerticalBlank          stdmethod(IDirectDraw *THIS, DirectDrawWaitForVerticalBlankFlags dwFlags, HANDLE hEvent)

interface IDirectDrawSurface extends IUnknown
  GUID                          6C14DB81-A733-11CE-A521-0020AF0BE560
  AddAttachedSurface            stdmethod(IDirectDraw *THIS, LPDIRECTDRAWSURFACE lpDDSAttachedSurface)
  AddOverlayDirtyRect           stdmethod(IDirectDraw *THIS, LPRECT lpRect)
  Blt                           stdmethod(IDirectDraw *THIS, LPRECT lpDestRect, LPDIRECTDRAWSURFACE lpDDSrcSurface, LPRECT lpSrcRect, DirectDrawBltFlags dwFlags, LPDDBLTFX lpDDBltFx)
  BltBatch                      stdmethod(IDirectDraw *THIS, LPDDBLTBATCH lpDDBltBatch, DWORD dwCount, DWORD dwFlags)
  BltFast                       stdmethod(IDirectDraw *THIS, DWORD dwX, DWORD dwY, LPDIRECTDRAWSURFACE lpDDSrcSurface, LPRECT lpSrcRect, DWORD dwTrans)
  DeleteAttachedSurface         stdmethod(IDirectDraw *THIS, DWORD dwFlags, LPDIRECTDRAWSURFACE lpDDSurface)
  EnumAttachedSurfaces          stdmethod(IDirectDraw *THIS, LPVOID lpContext, LPDDENUMSURFACESCALLBACK lpEnumSurfacesCallback)
  EnumOverlayZOrders            stdmethod(IDirectDraw *THIS, DirectDrawEnumOverlayZOrderFlags dwFlags, LPVOID lpContext, LPDDENUMSURFACESCALLBACK lpfnCallback)
  Flip                          stdmethod(IDirectDraw *THIS, LPDIRECTDRAWSURFACE lpDDSurfaceTargetOverride, DirectDrawFlipFlags dwFlags)
  GetAttachedSurface            stdmethod(IDirectDraw *THIS, LPDDSCAPS lpDDSCaps, [out] LPDIRECTDRAWSURFACE *lplpDDAttachedSurface)
  GetBltStatus                  stdmethod(IDirectDraw *THIS, DirectDrawGetBltStatusFlags dwFlags)
  GetCaps                       stdmethod(IDirectDraw *THIS, LPDDSCAPS lpDDSCaps)
  GetClipper                    stdmethod(IDirectDraw *THIS, LPDIRECTDRAWCLIPPER *lplpDDClipper)
  GetColorKey                   stdmethod(IDirectDraw *THIS, DirectDrawSurfaceSetGetColorKeyFlags dwFlags, LPDDCOLORKEY lpDDColorKey)
  GetDC                         stdmethod(IDirectDraw *THIS, HDC *phDC)
  GetFlipStatus                 stdmethod(IDirectDraw *THIS, DWORD dwFlags)
  GetOverlayPosition            stdmethod(IDirectDraw *THIS, LPLONG lplX, LPLONG lplY)
  GetPalette                    stdmethod(IDirectDraw *THIS, LPDIRECTDRAWPALETTE * lplpDDPalette)
  GetPixelFormat                stdmethod(IDirectDraw *THIS, LPDDPIXELFORMAT lpDDPixelFormat)
  GetSurfaceDesc                stdmethod(IDirectDraw *THIS, LPDDSURFACEDESC lpDDSurfaceDesc)
  Initialize                    stdmethod(IDirectDraw *THIS, LPDIRECTDRAW lpDD, LPDDSURFACEDESC lpDDSurfaceDesc)
  IsLost                        stdmethod(IDirectDraw *THIS)
  Lock                          stdmethod(IDirectDraw *THIS, LPRECT lpDestRect,LPDDSURFACEDESC lpDDSurfaceDesc, DirectDrawSurfaceLockFlags dwFlags, HANDLE hEvent)
  ReleaseDC                     stdmethod(IDirectDraw *THIS, HDC hDC)
  \Restore                      stdmethod(IDirectDraw *THIS)
  SetClipper                    stdmethod(IDirectDraw *THIS, LPDIRECTDRAWCLIPPER lpDDClipper)
  SetColorKey                   stdmethod(IDirectDraw *THIS, DirectDrawSurfaceSetGetColorKeyFlags dwFlags, LPDDCOLORKEY lpDDColorKey)
  SetOverlayPosition            stdmethod(IDirectDraw *THIS, LONG lX, LONG lY)
  SetPalette                    stdmethod(IDirectDraw *THIS, LPDIRECTDRAWPALETTE lpDDPalette)
  Unlock                        stdmethod(IDirectDraw *THIS, LPVOID lp)
  UpdateOverlay                 stdmethod(IDirectDraw *THIS, LPRECT lpSrcRect, LPDIRECTDRAWSURFACE lpDDDestSurface, LPRECT lpDestRect, DirectDrawSurfaceOverlayFlags dwFlags, LPDDOVERLAYFX lpDDOverlayFx)
  UpdateOverlayDisplay          stdmethod(IDirectDraw *THIS, DWORD dwFlags)
  UpdateOverlayZOrder           stdmethod(IDirectDraw *THIS, DirectDrawUpdateOverlayZOrderFlags dwFlags, LPDIRECTDRAWSURFACE lpDDSReference)

interface IDirectDrawPalette extends IUnknown
  GUID                          6C14DB84-A733-11CE-A521-0020AF0BE560
  GetCaps                       stdmethod(IDirectDraw *THIS, DirectDrawPaletteCapsFlags *lpdwCaps)
  GetEntries                    stdmethod(IDirectDraw *THIS, DWORD dwFlags, DWORD dwBase, DWORD dwNumEntries, LPPALETTEENTRY lpEntries)
  Initialize                    stdmethod(IDirectDraw *THIS, LPDIRECTDRAW lpDD, DWORD dwFlags, LPPALETTEENTRY lpDDColorTable)
  SetEntries                    stdmethod(IDirectDraw *THIS, DWORD dwFlags, DWORD dwStartingEntry, DWORD dwCount, LPPALETTEENTRY lpEntries)

interface IDirectDrawClipper extends IUnknown
  GUID                          6C14DB85-A733-11CE-A521-0020AF0BE560
  GetClipList                   stdmethod(IDirectDraw *THIS, LPRECT lpRect, LPRGNDATA lpClipList, LPDWORD lpdwSize)
  GetHWnd                       stdmethod(IDirectDraw *THIS, HWND * hWnd)
  Initialize                    stdmethod(IDirectDraw *THIS, LPDIRECTDRAW lpDD, DWORD dwFlags)
  IsClipListChanged             stdmethod(IDirectDraw *THIS, BOOL * lpbChanged)
  SetClipList                   stdmethod(IDirectDraw *THIS, LPRGNDATA lpClipList, DWORD dwFlags)
  SetHWnd                       stdmethod(IDirectDraw *THIS, DWORD dwFlags, HWND hWnd)


I was amazed that was no needance to add "@","$","%",",' or smthing else at end of Restore method but was just enoght to prepend it with "\"
That is not worked in common case. but it remains partialy useful
EOF - is alt+0+2+6

I don`t like to refer by "you" to one person.
My soul requires acronim "thou" instead.
Post 20 Nov 2019, 10:00
View user's profile Send private message Send e-mail Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum

Copyright © 1999-2023, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.