Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/external/tolua/lua/verbatim.lua @ 6514

Last change on this file since 6514 was 5738, checked in by landauf, 15 years ago

merged libraries2 back to trunk

  • Property svn:eol-style set to native
File size: 1.7 KB
RevLine 
[1650]1-- tolua: verbatim class
2-- Written by Waldemar Celes
3-- TeCGraf/PUC-Rio
4-- Jul 1998
5-- $Id: verbatim.lua,v 1.3 2000/01/24 20:41:16 celes 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 = {
[2710]19    line = '',
20    cond = nil,    -- condition: where to generate the code (s=suport, r=register)
[1650]21}
22classVerbatim.__index = classVerbatim
23setmetatable(classVerbatim,classFeature)
24
25-- preamble verbatim
26function classVerbatim:preamble ()
[2710]27    if self.cond == '' then
28        write(self.line)
29    end
[1650]30end
31
32-- support code
33function classVerbatim:supcode ()
[2710]34    if strfind(self.cond,'s') then
35        write(self.line)
36        write('\n')
37    end
[1650]38end
39
40-- register code
41function classVerbatim:register (pre)
[2710]42    if strfind(self.cond,'r') then
43        write(self.line)
44    end
[1650]45end
46
47
48-- Print method
49function classVerbatim:print (ident,close)
[2710]50    print(ident.."Verbatim{")
51    print(ident.." line = '"..self.line.."',")
52    print(ident.."}"..close)
53    end
[1650]54
55
56-- Internal constructor
57function _Verbatim (t)
[2710]58    setmetatable(t,classVerbatim)
59    append(t)
60    return t
[1650]61end
62
63-- Constructor
64-- Expects a string representing the text line
65function Verbatim (l,cond)
[2710]66    if strsub(l,1,1) == "'" then
67        l = strsub(l,2)
68    elseif strsub(l,1,1) == '$' then
69        cond = 'sr'       -- generates in both suport and register fragments
70        l = strsub(l,2)
71    end
72    return _Verbatim {
73        line = l,
74        cond = cond or '',
75    }
[1650]76end
77
78
Note: See TracBrowser for help on using the repository browser.