PageRenderTime 39ms CodeModel.GetById 35ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/src/tools/wrappers-generator/contexted_node.e

http://github.com/tybor/Liberty
Specman e | 77 lines | 48 code | 10 blank | 19 comment | 3 complexity | fae1ee401dff05c8d0a5e6ec65281240 MD5 | raw file
 1deferred class CONTEXTED_NODE
 2   -- A Gccxml node with "context" attribute
 3
 4inherit
 5   GCCXML_NODE
 6
 7insert
 8   SHARED_COLLECTIONS
 9
10feature {ANY}
11   context: UNICODE_STRING
12      do
13         Result := attribute_at(once U"context")
14      ensure
15         Result /= Void
16      end
17
18   namespace: C_NAMESPACE
19      local
20         symbol: NAMED_NODE
21      do
22         -- unused contexted: CONTEXTED_NODE
23         if not namespace_retrieved then
24            sedb_breakpoint
25            -- Some elements have a context which is their actual
26            -- namespace; other like fields referes to their container;
27            -- also in C++ things like a typedef may be containted into a
28            -- struct. Therefore the actual namespace is contained in
29            -- context of Current or in the node referred by context.
30
31            cached_namespace := namespaces.reference_at(context)
32            if cached_namespace = Void then
33               -- Recursively look for the namespace
34               from
35                  print("Looking for context " + context.as_utf8 + " namespace: ")
36                  symbol := symbols.reference_at(context.as_utf8)
37               until
38                  cached_namespace /= Void
39               loop
40                  print(" symbol " + symbol.out)
41                  check
42                     symbol /= Void
43                  end
44                  print(" symbol: " + symbol.out)
45                  cached_namespace ?= symbol
46                  symbol := symbols.reference_at(symbol.attribute_at(once U"context").as_utf8)
47               end
48            end
49
50            check
51               cached_namespace /= Void
52            end
53            namespace_retrieved := True
54         end
55
56         Result := cached_namespace
57      ensure
58         Result /= Void
59      end
60
61feature {} -- Implementation
62   cached_namespace: C_NAMESPACE
63
64   namespace_retrieved: BOOLEAN
65
66end -- class CONTEXTED_NODE
67-- Copyright (C) 2008-2017: ,2009,2010 Paolo Redaelli
68-- wrappers-generator  is free software: you can redistribute it and/or modify it
69-- under the terms of the GNU General Public License as publhed by the Free
70-- Software Foundation, either version 2 of the License, or (at your option)
71-- any later version.
72-- wrappers-generator is distributed in the hope that it will be useful, but
73-- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
74-- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
75-- more details.
76-- You should have received a copy of the GNU General Public License along with
77-- th program.  If not, see <http://www.gnu.org/licenses/>.