Last change
on this file since 2040 was
2040,
checked in by rgrieder, 16 years ago
|
reverted those svn:eol-style "native" properties: Tomorrow then.
|
File size:
1.2 KB
|
Line | |
---|
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 = { |
---|
19 | classtype = 'namespace', |
---|
20 | name = '', |
---|
21 | } |
---|
22 | classNamespace.__index = classNamespace |
---|
23 | setmetatable(classNamespace,classModule) |
---|
24 | |
---|
25 | -- Print method |
---|
26 | function classNamespace:print (ident,close) |
---|
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) |
---|
35 | end |
---|
36 | |
---|
37 | -- Internal constructor |
---|
38 | function _Namespace (t) |
---|
39 | setmetatable(t,classNamespace) |
---|
40 | append(t) |
---|
41 | return t |
---|
42 | end |
---|
43 | |
---|
44 | -- Constructor |
---|
45 | -- Expects the name and the body of the namespace. |
---|
46 | function Namespace (n,b) |
---|
47 | local c = _Namespace(_Container{name=n}) |
---|
48 | push(c) |
---|
49 | c:parse(strsub(b,2,strlen(b)-1)) -- eliminate braces |
---|
50 | pop() |
---|
51 | end |
---|
52 | |
---|
Note: See
TracBrowser
for help on using the repository browser.