Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/gui/src/tolua/lua/define.lua @ 2030

Last change on this file since 2030 was 1650, checked in by rgrieder, 16 years ago

added preliminary automatic creation of tolua generator that creates the actual executable
(please don't ask about the egg-hen question…)

File size: 1.3 KB
Line 
1-- tolua: define class
2-- Written by Waldemar Celes
3-- TeCGraf/PUC-Rio
4-- Jul 1998
5-- $Id: define.lua,v 1.2 1999/07/28 22:21:08 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-- 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-- Print method
34function classDefine:print (ident,close)
35 print(ident.."Define{")
36 print(ident.." name = '"..self.name.."',")
37 print(ident.." lname = '"..self.lname.."',")
38 print(ident.."}"..close)
39end
40
41
42-- Internal constructor
43function _Define (t)
44 setmetatable(t,classDefine)
45 t:buildnames()
46
47 if t.name == '' then
48  error("#invalid define")
49 end
50
51 append(t)
52 return t
53end
54
55-- Constructor
56-- Expects a string representing the constant name
57function Define (n)
58 return _Define{
59  name = n
60 }
61end
62
63
Note: See TracBrowser for help on using the repository browser.