From 5f46b4102c179680d613b6b9e0e6d392318030d2 Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 8 Nov 2021 10:53:42 +0800 Subject: + tolua --- .../tolua-5.2.4/src/bin/lua-5.0/enumerate.lua | 83 ++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 ThirdParty/tolua-5.2.4/src/bin/lua-5.0/enumerate.lua (limited to 'ThirdParty/tolua-5.2.4/src/bin/lua-5.0/enumerate.lua') diff --git a/ThirdParty/tolua-5.2.4/src/bin/lua-5.0/enumerate.lua b/ThirdParty/tolua-5.2.4/src/bin/lua-5.0/enumerate.lua new file mode 100644 index 0000000..42d856d --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/bin/lua-5.0/enumerate.lua @@ -0,0 +1,83 @@ +-- tolua: enumerate class +-- Written by Waldemar Celes +-- TeCGraf/PUC-Rio +-- Jul 1998 +-- $Id: enumerate.lua,v 1.1 2009-07-09 13:44:01 fabraham Exp $ + +-- 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. + + +-- Enumerate class +-- Represents enumeration +-- The following fields are stored: +-- {i} = list of constant names +classEnumerate = { +} +classEnumerate.__index = classEnumerate +setmetatable(classEnumerate,classFeature) + +-- register enumeration +function classEnumerate:register () + local nspace = getnamespace(classContainer.curr) + local i=1 + while self[i] do + output(' tolua_constant(tolua_S,"'..self.lnames[i]..'",'..nspace..self[i]..');') + i = i+1 + end +end + +-- Print method +function classEnumerate:print (ident,close) + print(ident.."Enumerate{") + print(ident.." name = "..self.name) + local i=1 + while self[i] do + print(ident.." '"..self[i].."'("..self.lnames[i].."),") + i = i+1 + end + print(ident.."}"..close) +end + +-- Internal constructor +function _Enumerate (t) + setmetatable(t,classEnumerate) + append(t) + appendenum(t) + return t +end + +-- Constructor +-- Expects a string representing the enumerate body +function Enumerate (n,b) + local t = split(strsub(b,2,-2),',') -- eliminate braces + local i = 1 + local e = {n=0} + while t[i] do + local tt = split(t[i],'=') -- discard initial value + e.n = e.n + 1 + e[e.n] = tt[1] + i = i+1 + end + -- set lua names + i = 1 + e.lnames = {} + while e[i] do + local t = split(e[i],'@') + e[i] = t[1] + if not t[2] then + t[2] = applyrenaming(t[1]) + end + e.lnames[i] = t[2] or t[1] + i = i+1 + end + e.name = n + if n~="" then + Typedef("int "..n) + end + return _Enumerate(e) +end + + -- cgit v1.1-26-g67d0