Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: sandbox_light/src/external/tolua/lua/namespace.lua @ 7190

Last change on this file since 7190 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
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
18classNamespace = {
19    classtype = 'namespace',
20    name = '',
21}
22classNamespace.__index = classNamespace
23setmetatable(classNamespace,classModule)
24
25-- Print method
26function 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)
35end
36
37-- Internal constructor
38function _Namespace (t)
39    setmetatable(t,classNamespace)
40    append(t)
41    return t
42end
43
44-- Constructor
45-- Expects the name and the body of the namespace.
46function 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()
51end
52
Note: See TracBrowser for help on using the repository browser.