summaryrefslogtreecommitdiff
path: root/src/lua/verbatim.lua
blob: 9dae0dc32a8c5f5d969d4d5eeb4d8c7168acda54 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
-- tolua: verbatim class
-- Written by Waldemar Celes
-- TeCGraf/PUC-Rio
-- Jul 1998
-- $Id: verbatim.lua,v 1.2 2001/11/26 23:00:27 darkgod 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 = '',
 _base = classFeature,
}
settag(classVerbatim,tolua_tag)

-- preamble verbatim
function classVerbatim:preamble ()
 if not self.cond then
  write(self.line)
 end
end

-- support code
function classVerbatim:supcode ()
 if self.cond then
  write(self.line)
  write('\n')
 end
end

-- register code
function classVerbatim:register ()
 if self.cond 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)
 t._base = classVerbatim
 settag(t,tolua_tag)
 append(t)
 return t
end

-- Constructor
-- Expects a string representing the text line
function Verbatim (l)
 local c
 if strsub(l,1,1) == '$' then
  c = 1
  l = strsub(l,2)
 end
 return _Verbatim {
  line = l,
  cond = c
 }
end