flat assembler
Message board for the users of flat assembler.

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

Author
Thread Post new topic Reply to topic
ProMiNick



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

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

                macro endi \\{
                        if $
                                display 'Error: definition of ',\`name,' contains illegal instructions.',0Dh,0Ah
                                err
                        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
                         \\\common
                                ;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
 common
        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
 forward
                                .#method PTR ?
 common
                                .\#\\.com.object = name#.com.interface
                        end virtual \\} \}
        restruc name#Vtbl
        struc name#Vtbl value \{ \local \..base
                label \..base
 forward
                .#method PTR value
 common
                label . at \..base \}
}

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

        macro endo \{
                if $
                        display 'Error: definition of ',`name,' contains illegal instructions.',0Dh,0Ah
                        err
                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}

EOF
requirements:
previously should be defined "struc PTR"    


interfaces/directx1.inc:
Code:
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)
endi

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)
endi

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)
endi

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)
endi

EOF    


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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.