flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > Fill struct like in c

Author
Thread Post new topic Reply to topic
Roman



Joined: 21 Apr 2012
Posts: 815
Roman
I create Fasm macro fill.
Code:
fb_infor it is struct.
Fill fb_infor,.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO,\
                      .pNext = NULL,\
                      .renderPass = 0,\
                      .attachmentCount = 2,\
                      .pAttachments = attachments0,\
                      .width = 12,\
                      .height = 12,\
                      .layers = 1
    

But how do without ,\
Like this in Fasm ?
Code:
Fill fb_infor,.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO,
                      .pNext = NULL,
                      .renderPass = 0,
                      .attachmentCount = 2,
                      .pAttachments = attachments0,
                      .width = 12,
                      .height = 12,
                      .layers = 1
    
Post 17 Mar 2016, 11:19
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7795
Location: Kraków, Poland
Tomasz Grysztar
It may not be possible with fasm 1 macros, but with the fasm g engine you could do something like this:
Code:
macro __fill sname,arg&
        irp definition, arg
                match name==value, definition
                        display `sname,`name,' filled with value ',`value,13,10
                        ; store value at sname#name
                else
                        display 'invalid syntax: ',`definition,13,10
                end match
        end irp
end macro

macro Fill sname,first&
        macro ? line&
                match single=, ,line
                        __fill sname,single
                else
                        __fill sname,line
                        purge ?
                end match
        end macro
        first
end macro



Fill fb_infor,.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO,
                      .pNext = NULL, 
                      .renderPass = 0, 
                      .attachmentCount = 2, 
                      .pAttachments = attachments0, 
                      .width = 12, 
                      .height = 12, 
                      .layers = 1    
Post 17 Mar 2016, 12:20
View user's profile Send private message Visit poster's website Reply with quote
l_inc



Joined: 23 Oct 2009
Posts: 881
l_inc
Tomasz Grysztar
Quote:
It may not be possible with fasm 1 macros

It is possible, but not nice. I guess the following syntax for structure definition would be well perceived:
Code:
Fill fb_infor :
   sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO
   pNext = NULL
   ;...
ends fb_infor    

This is also possible with fasm 1, but it may further simplify and robustify implementation if every line in the structure definition required to specify a keyword at the beginning like item .

P.S. I actually missed that Fill is a macro, and not a structure identifier, and fb_infor is a structure identifier, and not a structure type identifier. In any case implementing the fill in fasm 1 would require to go into the internals of the struct macro. In the requested syntax it would be enough (but again, not nice) to enumerate the list fields@VkFramebufferCreateInfo and to redefine the field names with macros, but the name VkFramebufferCreateInfo should then be made exposed by the struct macros.

_________________
Faith is a superposition of knowledge and fallacy
Post 17 Mar 2016, 13:05
View user's profile Send private message 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-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.