From aafef187ef856a36c3f8e599afea2dee44f08904 Mon Sep 17 00:00:00 2001 From: faketruth Date: Mon, 3 Oct 2011 19:25:04 +0000 Subject: Source for additional projects -jsoncpp -lua -tolua++ -WebServer -zlib -iniFile git-svn-id: http://mc-server.googlecode.com/svn/trunk@4 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- tolua++-1.0.93/src/bin/lua/module.lua | 68 +++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 tolua++-1.0.93/src/bin/lua/module.lua (limited to 'tolua++-1.0.93/src/bin/lua/module.lua') diff --git a/tolua++-1.0.93/src/bin/lua/module.lua b/tolua++-1.0.93/src/bin/lua/module.lua new file mode 100644 index 000000000..57dceb7d5 --- /dev/null +++ b/tolua++-1.0.93/src/bin/lua/module.lua @@ -0,0 +1,68 @@ +-- tolua: module class +-- Written by Waldemar Celes +-- TeCGraf/PUC-Rio +-- Jul 1998 +-- $Id: $ + +-- This code is free software; you can redistribute it and/or modify it. +-- The software provided hereunder is on an "as is" basis, and +-- the author has no obligation to provide maintenance, support, updates, +-- enhancements, or modifications. + + + +-- Module class +-- Represents module. +-- The following fields are stored: +-- {i} = list of objects in the module. +classModule = { + classtype = 'module' +} +classModule.__index = classModule +setmetatable(classModule,classContainer) + +-- register module +function classModule:register (pre) + pre = pre or '' + push(self) + output(pre..'tolua_module(tolua_S,"'..self.name..'",',self:hasvar(),');') + output(pre..'tolua_beginmodule(tolua_S,"'..self.name..'");') + local i=1 + while self[i] do + self[i]:register(pre..' ') + i = i+1 + end + output(pre..'tolua_endmodule(tolua_S);') + pop() +end + +-- Print method +function classModule:print (ident,close) + print(ident.."Module{") + print(ident.." name = '"..self.name.."';") + local i=1 + while self[i] do + self[i]:print(ident.." ",",") + i = i+1 + end + print(ident.."}"..close) +end + +-- Internal constructor +function _Module (t) + setmetatable(t,classModule) + append(t) + return t +end + +-- Constructor +-- Expects two string representing the module name and body. +function Module (n,b) + local t = _Module(_Container{name=n}) + push(t) + t:parse(strsub(b,2,strlen(b)-1)) -- eliminate braces + pop() + return t +end + + -- cgit v1.2.3