1-- tolua: define class
2-- Written by Waldemar Celes
3-- TeCGraf/PUC-Rio
4-- Jul 1998
5-- $Id$
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-- Define class
14-- Represents a numeric const definition
15-- The following filds are stored:
16--   name = constant name
17classDefine = {
18 name = '',
19}
20classDefine.__index = classDefine
21setmetatable(classDefine,classFeature)
22
23-- register define
24function classDefine:register (pre)
25	if not self:check_public_access() then
26		return
27	end
28
29 pre = pre or ''
30 output(pre..'tolua_constant(tolua_S,"'..self.lname..'",'..self.name..');')
31end
32
33---
34-- LuaDoc Patch
35-- outputs an empty(without documentation) LuaDoc interface
36-- by klapeto (http://cegui.org.uk/forum/viewtopic.php?f=7&t=6784)
37function classDefine:output_luadoc()
38	if not self:check_public_access() then
39		return
40	end
41	if (self.parent~=nil) then
42		output('---\n')
43		output('-- @field [parent=#'..cleanseType(self.parent.name)..'] #string '..self.lname..'\n')
44	else
45		output('---\n')
46		output('-- @field [parent=#global] #string '..self.lname..'\n')
47	end
48end
49
50-- Print method
51function classDefine:print (ident,close)
52 print(ident.."Define{")
53 print(ident.." name = '"..self.name.."',")
54 print(ident.." lname = '"..self.lname.."',")
55 print(ident.."}"..close)
56end
57
58
59-- Internal constructor
60function _Define (t)
61 setmetatable(t,classDefine)
62 t:buildnames()
63
64 if t.name == '' then
65  error("#invalid define")
66 end
67
68 append(t)
69 return t
70end
71
72-- Constructor
73-- Expects a string representing the constant name
74function Define (n)
75 return _Define{
76  name = n
77 }
78end
79
80
81