Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/gui/src/tolua/lua/verbatim.lua @ 2907

Last change on this file since 2907 was 2710, checked in by rgrieder, 16 years ago

Merged buildsystem3 containing buildsystem2 containing Adi's buildsystem branch back to the trunk.
Please update the media directory if you were not using buildsystem3 before.

  • Property svn:eol-style set to native
File size: 1.7 KB
Line 
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 = {
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 (pre)
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)
53    end
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        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    }
76end
77
78
Note: See TracBrowser for help on using the repository browser.