~ubuntu-branches/debian/squeeze/freeciv/squeeze

« back to all changes in this revision

Viewing changes to dependencies/tolua/namespace.lua

  • Committer: Bazaar Package Importer
  • Author(s): Jordi Mallach
  • Date: 2008-07-08 18:34:23 UTC
  • mfrom: (5.1.9 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080708183423-c80u1h25xmj6h9s0
Tags: 2.1.5-2
Export datarootdir=/usr/share in debian/rules, so make calls can
have a correct value for LOCALEDIR (closes: #489455). Thanks Loïc Minier
for the help to solve this.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
-- tolua: namespace class
 
2
-- Written by Waldemar Celes
 
3
-- TeCGraf/PUC-Rio
 
4
-- Jul 2003
 
5
-- $Id: namespace.lua 10334 2005-04-26 22:08:24Z vas $
 
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