// this script was compiled with wurst 1.8.1.0-jenkins-Wurst-1365 globals integer array A_nextFree integer A_firstFree=0 integer A_maxIndex=0 integer array A_typeId integer array D_c endglobals native testSuccess takes nothing returns nothing function initGlobals takes nothing returns nothing set A_firstFree = 0 set A_maxIndex = 0 endfunction function A_onDestroy takes integer this returns nothing endfunction function B_onDestroy takes integer this returns nothing call A_onDestroy(this) endfunction function C_onDestroy takes integer this returns nothing call testSuccess() call B_onDestroy(this) endfunction function D_onDestroy takes integer this returns nothing loop exitwhen not (D_c[this] < 4) set D_c[this] = D_c[this] + 1 endloop call C_onDestroy(this) endfunction function error takes string msg returns nothing call BJDebugMsg(msg + "\n" + "") endfunction function dealloc_D takes integer obj returns nothing if A_typeId[obj] == 0 then call error("Double free: object of type D") else set A_nextFree[A_firstFree] = obj set A_firstFree = A_firstFree + 1 set A_typeId[obj] = 0 endif endfunction function destroyD takes integer this returns nothing call D_onDestroy(this) call dealloc_D(this) endfunction function dispatch_D_destroyD takes integer this returns nothing if A_typeId[this] == 0 then if this == 0 then call error("Nullpointer exception when calling D.D") else call error("Called D.D on invalid object.") endif endif call destroyD(this) endfunction function alloc_D takes nothing returns integer local integer this if A_firstFree == 0 then if A_maxIndex < 32768 then set A_maxIndex = A_maxIndex + 1 set this = A_maxIndex set A_typeId[this] = 4 else call error("Out of memory: Could not create D.") set this = 0 endif else set A_firstFree = A_firstFree - 1 set this = A_nextFree[A_firstFree] set A_typeId[this] = 4 endif return this endfunction function D_init takes integer this returns nothing endfunction function C_init takes integer this returns nothing endfunction function B_init takes integer this returns nothing endfunction function A_init takes integer this returns nothing endfunction function construct_A takes integer this returns nothing call A_init(this) endfunction function construct_B takes integer this returns nothing call construct_A(this) call B_init(this) endfunction function construct_C takes integer this returns nothing call construct_B(this) call C_init(this) endfunction function construct_D takes integer this, integer i returns nothing call construct_C(this) call D_init(this) set D_c[this] = i endfunction function new_D takes integer i returns integer local integer this = alloc_D() call construct_D(this, i) return this endfunction function init_Test takes nothing returns nothing local integer d = new_D(0) call dispatch_D_destroyD(d) endfunction function main takes nothing returns nothing call initGlobals() call init_Test() endfunction function config takes nothing returns nothing endfunction