1-- tolua: verbatim class 2-- Written by Waldemar Celes 3-- TeCGraf/PUC-Rio 4-- Jul 1998 5-- $Id: verbatim.lua,v 1.1 2009-07-09 13:44:57 fabraham Exp $ 6 7-- This code is free software; you can redistribute it and/or modify it. 8-- The software provided hereunder is on an "as is" basis, and 9-- the author has no obligation to provide maintenance, support, updates, 10-- enhancements, or modifications. 11 12 13 14-- Verbatim class 15-- Represents a line translated directed to the binding file. 16-- The following filds are stored: 17-- line = line text 18classVerbatim = { 19 line = '', 20 cond = nil, -- condition: where to generate the code (s=suport, r=register) 21} 22classVerbatim.__index = classVerbatim 23setmetatable(classVerbatim,classFeature) 24 25-- preamble verbatim 26function classVerbatim:preamble () 27 if self.cond == '' then 28 write(self.line) 29 end 30end 31 32-- support code 33function classVerbatim:supcode () 34 if strfind(self.cond,'s') then 35 write(self.line) 36 write('\n') 37 end 38end 39 40-- register code 41function classVerbatim:register () 42 if strfind(self.cond,'r') then 43 write(self.line) 44 end 45end 46 47 48-- Print method 49function classVerbatim:print (ident,close) 50 print(ident.."Verbatim{") 51 print(ident.." line = '"..self.line.."',") 52 print(ident.."}"..close) 53end 54 55 56-- Internal constructor 57function _Verbatim (t) 58 setmetatable(t,classVerbatim) 59 append(t) 60 return t 61end 62 63-- Constructor 64-- Expects a string representing the text line 65function Verbatim (l,cond) 66 if strsub(l,1,1) == '$' then 67 cond = 'sr' -- generates in both suport and register fragments 68 l = strsub(l,2) 69 end 70 return _Verbatim { 71 line = l, 72 cond = cond or '', 73 } 74end 75 76 77