Last change
on this file since 7142 was
5738,
checked in by landauf, 15 years ago
|
merged libraries2 back to trunk
|
-
Property svn:eol-style set to
native
|
File size:
1.2 KB
|
Rev | Line | |
---|
[1650] | 1 | -- tolua: namespace class |
---|
| 2 | -- Written by Waldemar Celes |
---|
| 3 | -- TeCGraf/PUC-Rio |
---|
| 4 | -- Jul 2003 |
---|
| 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 | -- Namespace class |
---|
| 14 | -- Represents a namesapce definition. |
---|
| 15 | -- Stores the following fields: |
---|
| 16 | -- name = class name |
---|
| 17 | -- {i} = list of members |
---|
| 18 | classNamespace = { |
---|
[2710] | 19 | classtype = 'namespace', |
---|
| 20 | name = '', |
---|
[1650] | 21 | } |
---|
| 22 | classNamespace.__index = classNamespace |
---|
| 23 | setmetatable(classNamespace,classModule) |
---|
| 24 | |
---|
| 25 | -- Print method |
---|
| 26 | function classNamespace:print (ident,close) |
---|
[2710] | 27 | print(ident.."Namespace{") |
---|
| 28 | print(ident.." name = '"..self.name.."',") |
---|
| 29 | local i=1 |
---|
| 30 | while self[i] do |
---|
| 31 | self[i]:print(ident.." ",",") |
---|
| 32 | i = i+1 |
---|
| 33 | end |
---|
| 34 | print(ident.."}"..close) |
---|
[1650] | 35 | end |
---|
| 36 | |
---|
| 37 | -- Internal constructor |
---|
| 38 | function _Namespace (t) |
---|
[2710] | 39 | setmetatable(t,classNamespace) |
---|
| 40 | append(t) |
---|
| 41 | return t |
---|
[1650] | 42 | end |
---|
| 43 | |
---|
| 44 | -- Constructor |
---|
| 45 | -- Expects the name and the body of the namespace. |
---|
| 46 | function Namespace (n,b) |
---|
[2710] | 47 | local c = _Namespace(_Container{name=n}) |
---|
| 48 | push(c) |
---|
| 49 | c:parse(strsub(b,2,strlen(b)-1)) -- eliminate braces |
---|
| 50 | pop() |
---|
[1650] | 51 | end |
---|
| 52 | |
---|
Note: See
TracBrowser
for help on using the repository browser.