- Joined
- Feb 6, 2014
- Messages
- 2,466
Hello everyone. I want to learn how structs internally operates.
After creating structs and looking at the actual script generated by JassHelper, this is the function it generates (struct name is myStruct)
Correct me if I'm wrong, but from what I see, the
After creating structs and looking at the actual script generated by JassHelper, this is the function it generates (struct name is myStruct)
JASS:
//Generated allocator of myStruct
function s__myStruct__allocate takes nothing returns integer
local integer this=si__myStruct_F
if (this!=0) then
set si__myStruct_F=si__myStruct_V[this]
else
set si__myStruct_I=si__myStruct_I+1
set this=si__myStruct_I
endif
if (this>8190) then
return 0
endif
set si__myStruct_V[this]=-1
return this
endfunction
//Generated destructor of myStruct
function s__myStruct_deallocate takes integer this returns nothing
if this==null then
return
elseif (si__myStruct_V[this]!=-1) then
return
endif
set si__myStruct_V[this]=si__myStruct_F
set si__myStruct_F=this
endfunction
Correct me if I'm wrong, but from what I see, the
this
integer is the instance/index of the struct data. However, I can't figure out what is the si__myStruct_V[this]
and si__myStruct_F
for? Does the allocation and deallocation operate like this?
JASS:
8 4 2 9 7 this = 5
8 --- 2 9 7 this = 5
8 7 2 9 this = 4