Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef GNASH_AS_NAMESPACE_H
00020 #define GNASH_AS_NAMESPACE_H
00021
00022 #include "string_table.h"
00023 #include <map>
00024
00025
00026 namespace gnash {
00027 namespace abc {
00028 class Class;
00029 }
00030 class ClassHierarchy;
00031 class string_table;
00032 }
00033
00034 namespace gnash {
00035 namespace abc {
00036
00038
00041
00045
00048 class Namespace
00049 {
00050 public:
00051
00053 Namespace()
00054 :
00055 _parent(0),
00056 _uri(0),
00057 _prefix(0),
00058 _scripts(),
00059 mRecursePrevent(false),
00060 _private(false),
00061 _protected(false),
00062 _package(false)
00063 {}
00064
00065 void markReachableResources() const { }
00066
00068 void setParent(Namespace* p) { _parent = p; }
00069
00070 Namespace* getParent() { return _parent; }
00071
00073 void setURI(string_table::key name) { _uri = name; }
00074
00076 string_table::key getURI() const { return _uri; }
00077
00079 string_table::key getPrefix() const { return _prefix; }
00080
00083 bool addScript(string_table::key name, Class* a)
00084 {
00085 if (getScriptInternal(name)) return false;
00086 _scripts[static_cast<std::size_t>(name)] = a;
00087 return true;
00088 }
00089
00090 void stubPrototype(ClassHierarchy& ch, string_table::key name);
00091
00094 Class* getScript(string_table::key name)
00095 {
00096 if (mRecursePrevent) return NULL;
00097
00098 Class* found = getScriptInternal(name);
00099
00100 if (found || !getParent()) return found;
00101
00102 mRecursePrevent = true;
00103 found = getParent()->getScript(name);
00104 mRecursePrevent = false;
00105 return found;
00106 }
00107
00108 void dump(string_table& st);
00109
00110 void setPrivate() { _private = true; }
00111 void unsetPrivate() { _private = false; }
00112 bool isPrivate() { return _private; }
00113
00114 void setProtected() { _protected = true; }
00115 void unsetProtected() { _protected = false; }
00116 bool isProtected() { return _protected; }
00117
00118 void setPackage() { _package = true; }
00119 void unsetPackage() { _package = false; }
00120 bool isPackage() { return _package; }
00121
00122 private:
00123
00124 Namespace* _parent;
00125 string_table::key _uri;
00126 string_table::key _prefix;
00127
00128 typedef std::map<string_table::key, Class*> container;
00129 container _scripts;
00130 mutable bool mRecursePrevent;
00131
00132 bool _private;
00133 bool _protected;
00134 bool _package;
00135
00136 Class* getScriptInternal(string_table::key name) const
00137 {
00138 container::const_iterator i;
00139
00140 if (_scripts.empty()) return NULL;
00141
00142 i = _scripts.find(name);
00143
00144 if (i == _scripts.end()) return NULL;
00145 return i->second;
00146 }
00147 };
00148
00149 }
00150 }
00151
00152 #endif