1-- tolua: define class
2-- Written by Waldemar Celes
3-- TeCGraf/PUC-Rio
4-- Jul 1998
5-- $Id: define.lua,v 1.1 2009-07-09 13:44:38 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-- 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 ()
25 output(' tolua_constant(tolua_S,"'..self.lname..'",'..self.name..');')
26end
27
28-- Print method
29function classDefine:print (ident,close)
30 print(ident.."Define{")
31 print(ident.." name = '"..self.name.."',")
32 print(ident.." lname = '"..self.lname.."',")
33 print(ident.."}"..close)
34end
35
36
37-- Internal constructor
38function _Define (t)
39 setmetatable(t,classDefine)
40 t:buildnames()
41
42 if t.name == '' then
43  error("#invalid define")
44 end
45
46 append(t)
47 return t
48end
49
50-- Constructor
51-- Expects a string representing the constant name
52function Define (n)
53 return _Define{
54  name = n
55 }
56end
57
58
59