diff options
author | chai <chaifix@163.com> | 2021-11-08 10:53:42 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-11-08 10:53:42 +0800 |
commit | 5f46b4102c179680d613b6b9e0e6d392318030d2 (patch) | |
tree | 16527828dc89133f7af41acf6f5c13c23743e7ef /ThirdParty/tolua-5.2.4/src/bin/lua/verbatim.lua | |
parent | 138d3f4d3d6e2aaf5ba34f89af15ef85ea074357 (diff) |
+ tolua
Diffstat (limited to 'ThirdParty/tolua-5.2.4/src/bin/lua/verbatim.lua')
-rw-r--r-- | ThirdParty/tolua-5.2.4/src/bin/lua/verbatim.lua | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/ThirdParty/tolua-5.2.4/src/bin/lua/verbatim.lua b/ThirdParty/tolua-5.2.4/src/bin/lua/verbatim.lua new file mode 100644 index 0000000..1581092 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/bin/lua/verbatim.lua @@ -0,0 +1,76 @@ +-- tolua: verbatim class +-- Written by Waldemar Celes +-- TeCGraf/PUC-Rio +-- Jul 1998 +-- $Id: verbatim.lua,v 1.3 2009/11/24 16:45:15 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. + + + +-- Verbatim class +-- Represents a line translated directed to the binding file. +-- The following filds are stored: +-- line = line text +classVerbatim = { + line = '', + cond = nil, -- condition: where to generate the code (s=suport, r=register) +} +classVerbatim.__index = classVerbatim +setmetatable(classVerbatim,classFeature) + +-- preamble verbatim +function classVerbatim:preamble () + if self.cond == '' then + write(self.line) + end +end + +-- support code +function classVerbatim:supcode () + if strfind(self.cond,'s') then + write(self.line) + write('\n') + end +end + +-- register code +function classVerbatim:register () + if strfind(self.cond,'r') then + write(self.line) + end +end + + +-- Print method +function classVerbatim:print (ident,close) + print(ident.."Verbatim{") + print(ident.." line = '"..self.line.."',") + print(ident.."}"..close) +end + + +-- Internal constructor +function _Verbatim (t) + setmetatable(t,classVerbatim) + append(t) + return t +end + +-- Constructor +-- Expects a string representing the text line +function Verbatim (l,cond) + if strsub(l,1,1) == '$' then + cond = 'sr' -- generates in both suport and register fragments + l = strsub(l,2) + end + return _Verbatim { + line = l, + cond = cond or '', + } +end + + |