Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 66 lines (50 sloc) 1.406 kb
6774809 @NotFound initial support for extern function
authored
1 // winxedxx_namespace.cxx
2
3 // (C) 2012 Julián Albo "NotFound"
4
5 #include "winxedxx_namespace.h"
6
7 namespace WinxedXX
8 {
9
10 typedef std::map<std::string, WxxObjectPtr> symbols_t;
08b49ff @NotFound more improvements in runtime namespaces and a few cleaning
authored
11 typedef std::map<std::string, WxxNamespace *> childs_t;
6774809 @NotFound initial support for extern function
authored
12
13 WxxNamespace::WxxNamespace() :
14 parentns(0)
15 {
16 }
17
18 WxxNamespace::WxxNamespace(const std::string &name, WxxNamespace *parent) :
19 parentns(parent)
20 {
21 }
22
23 WxxObjectPtr WxxNamespace::get(const std::string &name)
24 {
25 symbols_t::const_iterator it = symbols.find(name);
26 if (it == symbols.end())
27 return winxedxxnull;
28 return WxxObjectPtr(it->second);
29 }
30
08b49ff @NotFound more improvements in runtime namespaces and a few cleaning
authored
31 WxxNamespace &WxxNamespace::childNamespace(const std::string &name)
32 {
33 childs_t::const_iterator it = childs.find(name);
34 if (it == childs.end()) {
35 WxxNamespace *child = new WxxNamespace(name, this);
36 childs[name] = child;
37 return *child;
38 }
39 return *it->second;
40 }
41
6774809 @NotFound initial support for extern function
authored
42 void WxxNamespace::set(const std::string &name, const WxxObjectPtr &value)
43 {
44 symbols[name] = value;
45 }
46
47 //**************************************************************
48
49 class WxxRootNamespace : WxxNamespace
50 {
51 friend WxxNamespace &getRootNamespace();
52 };
53
54 static WxxRootNamespace *rootnamespace = 0;
55
56 WxxNamespace &getRootNamespace()
57 {
58 if (! rootnamespace)
59 rootnamespace = new WxxRootNamespace();
60 return *rootnamespace;
61 }
62
63 } // namespace WinxedXX
64
65 // End of winxedxx_namespace.cxx
Something went wrong with that request. Please try again.