Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/external/tolua/lua/feature.lua @ 10312

Last change on this file since 10312 was 5738, checked in by landauf, 15 years ago

merged libraries2 back to trunk

  • Property svn:eol-style set to native
File size: 2.8 KB
RevLine 
[1650]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)
[2710]42    return false
[1650]43end
44
45-- build names
46function classFeature:buildnames ()
[2710]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
[1650]60
[2710]61    local parent = classContainer.curr
62    if parent then
63        self.access = parent.curr_member_access
64    else
65    end
[1650]66end
67
68function classFeature:check_public_access()
69
[2710]70    if self.access and self.access ~= 0 then
71        return false
72    end
[1650]73
[2710]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
[1650]82end
83
84function clean_template(t)
85
[2710]86    return string.gsub(t, "[<>:, %*]", "_")
[1650]87end
88
89-- check if feature is inside a container definition
90-- it returns the container class name or nil.
91function classFeature:incontainer (which)
[2710]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
[1650]102end
103
104function classFeature:inclass ()
[2710]105    return self:incontainer('class')
[1650]106end
107
108function classFeature:inmodule ()
[2710]109    return self:incontainer('module')
[1650]110end
111
112function classFeature:innamespace ()
[2710]113    return self:incontainer('namespace')
[1650]114end
115
116-- return C binding function name based on name
117-- the client specifies a prefix
118function classFeature:cfuncname (n)
119
[2710]120    if self.parent then
121        n = self.parent:cfuncname(n)
122    end
[1650]123
[2710]124    n = string.gsub(n..'_'.. (self.lname or self.name), "[<>:, \.%*&]", "_")
[1650]125
[2710]126    return n
[1650]127end
128
Note: See TracBrowser for help on using the repository browser.