flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > smart pointers in struct ?

Author
Thread Post new topic Reply to topic
Roman



Joined: 21 Apr 2012
Posts: 1820
Roman 17 May 2020, 14:32
For example we have two structs
Code:
struct A {
x dd 0;
y dd 0;
i  dd 0;
pBuffer dq 0;
SizeBytes dd 0;
t dd 0;
}

struct B {
pBuffer dq 0;
SizeBytes dd 0;
i dd 0;
p dq 0;
}

    

Fun1 get as parameter struct A or B
If macro not find pBuffer then in code no Fun1

For example Fun1 must do:
pBuffer = memalloc(SizeBytes);

Lets say smrtAllloc EQU 20
Then struct look like this:
Code:
struct A {
x dd 0;
y dd 0;
i  dd 0;
pBuffer smrtAllloc;
SizeBytes dd 0;
t dd 0;
}

struct B {
pBuffer smrtAllloc;
SizeBytes dd 0;
i dd 0;
p dq 0;
}
in code:
macro Fun1 B
macro Fun1 A
    

I know that we can easily do Fun1 B.pBuffer or Fun1 A.pBuffer in Fasm 1.73
Post 17 May 2020, 14:32
View user's profile Send private message Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 802
Location: Russian Federation, Sochi
ProMiNick 17 May 2020, 18:04
Thou mean something like this:
Code:
macro fun1 param {
        match :,param \{fun1: \}
        if (param eqtype 0) & (defined param#.pBuffer)
                push param
;or
;if defined sizeof.#param
;              push sizeof.#param

                call fun1
;end if
        end if }

fun1 hello

fun1:
hello = 1000
hello.pBuffer = 5     
Post 17 May 2020, 18:04
View user's profile Send private message Send e-mail Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1820
Roman 17 May 2020, 18:47
Thanks.
Very close how i want.
Post 17 May 2020, 18:47
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.