// this script was compiled with wurst 1.8.1.0-jenkins-Wurst-1366 globals integer array D_nextFree integer D_firstFree=0 integer D_maxIndex=0 integer array D_typeId integer array D_B_A_x endglobals native testFail takes string msg returns nothing native testSuccess takes nothing returns nothing function initGlobals takes nothing returns nothing endfunction function error takes string msg returns nothing call BJDebugMsg(msg + "\n" + "") endfunction function new_D takes nothing returns integer local integer this if D_firstFree == 0 then if D_maxIndex < 32768 then set D_maxIndex = D_maxIndex + 1 set this = D_maxIndex set D_typeId[this] = 1 else call error("Out of memory: Could not create D.") set this = 0 endif else set D_firstFree = D_firstFree - 1 set this = D_nextFree[D_firstFree] set D_typeId[this] = 1 endif return this endfunction function init_test takes nothing returns nothing local integer d = new_D() if D_typeId[d] == 0 then if d == 0 then call error("Nullpointer exception when calling D.setX") else call error("Called D.setX on invalid object.") endif endif set D_B_A_x[d] = 4 if D_typeId[d] == 0 then if d == 0 then call error("Nullpointer exception when calling D.getX") else call error("Called D.getX on invalid object.") endif endif if D_B_A_x[d] != 4 then call testFail("foo fail") endif call testSuccess() endfunction function main takes nothing returns nothing call initGlobals() call init_test() endfunction function config takes nothing returns nothing endfunction