From a683a420a9e43705c972b5e74d55e319729e1a81 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Thu, 29 Jul 2010 19:53:02 +0000 Subject: SWORD25: Importing original sources svn-id: r53171 --- engines/sword25/util/pluto/pptest.lua | 168 ++++++++++++++++++++++++++++++++++ 1 file changed, 168 insertions(+) create mode 100755 engines/sword25/util/pluto/pptest.lua (limited to 'engines/sword25/util/pluto/pptest.lua') diff --git a/engines/sword25/util/pluto/pptest.lua b/engines/sword25/util/pluto/pptest.lua new file mode 100755 index 0000000000..144da3ee80 --- /dev/null +++ b/engines/sword25/util/pluto/pptest.lua @@ -0,0 +1,168 @@ +-- $Id$ + +require "pluto" + +permtable = { 1234 } + +perms = { [coroutine.yield] = 1, [permtable] = 2 } + +twithmt = {} +setmetatable( twithmt, { __call = function() return 21 end } ) + +function testfenv() + return abc +end + +setfenv(testfenv, { abc = 456 }) + +function fa(i) + local ia = i + 1 + return fb(ia) +end + +function fb(i) + local ib = i + 1 + ib = ib + fc(ib) + return ib +end + +function fc(i) + local ic = i + 1 + coroutine.yield() + return ic*2 +end + +function func() + return 4 +end + +thr = coroutine.create(fa) +coroutine.resume(thr, 2) + +testtbl = { a = 2, [2] = 4 } + +function funcreturningclosure(n) + return function() + return n + end +end + +function nestedfunc(n) + return (function(m) return m+2 end)(n+3) +end + +testloopa = {} +testloopb = { testloopa = testloopa } +testloopa.testloopb = testloopb + +sharedref = {} +refa = {sharedref = sharedref} +refb = {sharedref = sharedref} + +sptable = { a = 3 } + +setmetatable(sptable, { + __persist = function(tbl) + local a = tbl.a + return function() + return { a = a+3 } + end + end +}) + +literaludata = boxinteger(71) + +function booleanpersist(udata) + local b = unboxboolean(udata) + return function() + return boxboolean(b) + end +end + +function makecounter() + local a = 0 + return { + inc = function() a = a + 1 end, + cur = function() return a end + } +end + +function uvinthreadfunc() + local a = 1 + local b = function() + a = a+1 + coroutine.yield() + a = a+1 + end + a = a+1 + b() + a = a+1 + return a +end + +uvinthread = coroutine.create(uvinthreadfunc) +coroutine.resume(uvinthread) + +niinmt = { a = 3 } +setmetatable(niinmt, {__newindex = function(key, val) end }) + + + + +local function GenerateObjects() + local Table = {} + + function Table:Func() + return { Table, self } + end + + function uvcycle() + return Table:Func() + end +end + +GenerateObjects() + + + +function debuginfo(foo) + foo = foo + foo + return debug.getlocal(1,1) +end + +rootobj = { + testfalse = false, + testtrue = true, + testseven = 7, + testfoobar = "foobar", + testfuncreturnsfour = func, + testnil = nil, + testthread = thr, + testperm = permtable, + testmt = twithmt, + testtbl = testtbl, + testfenv = testfenv, + testclosure = funcreturningclosure(11), + testnilclosure = funcreturningclosure(nil), + testnest = nestedfunc, + testludata = createludata(), + testlooptable = testloopa, + testsharedrefa = refa, + testsharedrefb = refb, + testsptable = sptable, + testliteraludata = literaludata, + testspudata1 = boxboolean(true), + testspudata2 = boxboolean(false), + testsharedupval = makecounter(), + testuvinthread = uvinthread, + testniinmt = niinmt, + testuvcycle = uvcycle, + testdebuginfo = debuginfo +} + +buf = pluto.persist(perms, rootobj) + +onerror() +outfile = io.open("test.plh", "wb") +outfile:write(buf) +outfile:close() -- cgit v1.2.3 From 293bf95c01f76c8d812a300eb038854f1246ab3d Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sat, 31 Jul 2010 09:53:02 +0000 Subject: SWORD25: Replacing headers with ScummVM ones plus original (C) svn-id: r53188 --- engines/sword25/util/pluto/pptest.lua | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 engines/sword25/util/pluto/pptest.lua (limited to 'engines/sword25/util/pluto/pptest.lua') diff --git a/engines/sword25/util/pluto/pptest.lua b/engines/sword25/util/pluto/pptest.lua old mode 100755 new mode 100644 -- cgit v1.2.3