Last change
on this file since 10257 was
5738,
checked in by landauf, 15 years ago
|
merged libraries2 back to trunk
|
-
Property svn:eol-style set to
native
|
File size:
1.4 KB
|
Rev | Line | |
---|
[1650] | 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 |
---|
| 17 | classDefine = { |
---|
[2710] | 18 | name = '', |
---|
[1650] | 19 | } |
---|
| 20 | classDefine.__index = classDefine |
---|
| 21 | setmetatable(classDefine,classFeature) |
---|
| 22 | |
---|
| 23 | -- register define |
---|
| 24 | function classDefine:register (pre) |
---|
[2710] | 25 | if not self:check_public_access() then |
---|
| 26 | return |
---|
| 27 | end |
---|
[1650] | 28 | |
---|
[2710] | 29 | pre = pre or '' |
---|
| 30 | output(pre..'tolua_constant(tolua_S,"'..self.lname..'",'..self.name..');') |
---|
[1650] | 31 | end |
---|
| 32 | |
---|
| 33 | -- Print method |
---|
| 34 | function classDefine:print (ident,close) |
---|
[2710] | 35 | print(ident.."Define{") |
---|
| 36 | print(ident.." name = '"..self.name.."',") |
---|
| 37 | print(ident.." lname = '"..self.lname.."',") |
---|
| 38 | print(ident.."}"..close) |
---|
[1650] | 39 | end |
---|
| 40 | |
---|
| 41 | |
---|
| 42 | -- Internal constructor |
---|
| 43 | function _Define (t) |
---|
[2710] | 44 | setmetatable(t,classDefine) |
---|
| 45 | t:buildnames() |
---|
[1650] | 46 | |
---|
[2710] | 47 | if t.name == '' then |
---|
| 48 | error("#invalid define") |
---|
| 49 | end |
---|
[1650] | 50 | |
---|
[2710] | 51 | append(t) |
---|
| 52 | return t |
---|
[1650] | 53 | end |
---|
| 54 | |
---|
| 55 | -- Constructor |
---|
| 56 | -- Expects a string representing the constant name |
---|
| 57 | function Define (n) |
---|
[2710] | 58 | return _Define { |
---|
| 59 | name = n |
---|
| 60 | } |
---|
[1650] | 61 | end |
---|
| 62 | |
---|
| 63 | |
---|
Note: See
TracBrowser
for help on using the repository browser.