Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/ggz/src/tolua/lua/feature.lua @ 3614

Last change on this file since 3614 was 2710, checked in by rgrieder, 16 years ago

Merged buildsystem3 containing buildsystem2 containing Adi's buildsystem branch back to the trunk.
Please update the media directory if you were not using buildsystem3 before.

  • Property svn:eol-style set to native
File size: 2.8 KB
Line 
1-- tolua: abstract feature class
2-- Written by Waldemar Celes
3-- TeCGraf/PUC-Rio
4-- Jul 1998
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-- Feature class
14-- Represents the base class of all mapped feature.
15classFeature = {
16}
17classFeature.__index = classFeature
18
19-- write support code
20function classFeature:supcode ()
21end
22
23-- output tag
24function classFeature:decltype ()
25end
26
27-- register feature
28function classFeature:register (pre)
29end
30
31-- translate verbatim
32function classFeature:preamble ()
33end
34
35-- check if it is a variable
36function classFeature:isvariable ()
37 return false
38end
39
40-- check if it requires collection
41function classFeature:requirecollection (t)
42    return false
43end
44
45-- build names
46function classFeature:buildnames ()
47    if self.name and self.name~='' then
48        local n = split(self.name,'@')
49        self.name = n[1]
50        if not n[2] then
51            n[2] = applyrenaming(n[1])
52        end
53        self.lname = n[2] or gsub(n[1],"%[.-%]","")
54        self.original_name = self.name
55        self.lname = clean_template(self.lname)
56    end
57    if not self.is_parameter then
58        self.name = getonlynamespace() .. self.name
59    end
60
61    local parent = classContainer.curr
62    if parent then
63        self.access = parent.curr_member_access
64    else
65    end
66end
67
68function classFeature:check_public_access()
69
70    if self.access and self.access ~= 0 then
71        return false
72    end
73
74    local parent = classContainer.curr
75    while parent do
76        if parent.access and parent.access ~= 0 then
77            return false
78        end
79        parent = parent.prox
80    end
81    return true
82end
83
84function clean_template(t)
85
86    return string.gsub(t, "[<>:, %*]", "_")
87end
88
89-- check if feature is inside a container definition
90-- it returns the container class name or nil.
91function classFeature:incontainer (which)
92    if self.parent then
93        local parent = self.parent
94        while parent do
95            if parent.classtype == which then
96                return parent.name
97            end
98            parent = parent.parent
99        end
100    end
101    return nil
102end
103
104function classFeature:inclass ()
105    return self:incontainer('class')
106end
107
108function classFeature:inmodule ()
109    return self:incontainer('module')
110end
111
112function classFeature:innamespace ()
113    return self:incontainer('namespace')
114end
115
116-- return C binding function name based on name
117-- the client specifies a prefix
118function classFeature:cfuncname (n)
119
120    if self.parent then
121        n = self.parent:cfuncname(n)
122    end
123
124    n = string.gsub(n..'_'.. (self.lname or self.name), "[<>:, \.%*&]", "_")
125
126    return n
127end
128
Note: See TracBrowser for help on using the repository browser.