Make Language::classLookup() and enumLookup() static.
This will allow to reuse them in the code that doesn't have access to a Language object, such as DoxygenTranslator implementation. These methods didn't really use any of Language object non-static fields anyhow, the only one they did use (classtypes or enumtypes, respectively), was only used for caching and can just as well be made local to the function itself as long as we use other global variables anyhow.
This commit is contained in:
parent
8b83976f4c
commit
0d4f0683be
2 changed files with 13 additions and 11 deletions
|
|
@ -318,8 +318,6 @@ none_comparison(NewString("$arg != 0")),
|
|||
director_ctor_code(NewString("")),
|
||||
director_prot_ctor_code(0),
|
||||
symtabs(NewHash()),
|
||||
classtypes(NewHash()),
|
||||
enumtypes(NewHash()),
|
||||
overloading(0),
|
||||
multiinput(0),
|
||||
cplus_runtime(0),
|
||||
|
|
@ -346,8 +344,6 @@ directors(0) {
|
|||
|
||||
Language::~Language() {
|
||||
Delete(symtabs);
|
||||
Delete(classtypes);
|
||||
Delete(enumtypes);
|
||||
Delete(director_ctor_code);
|
||||
Delete(none_comparison);
|
||||
this_ = 0;
|
||||
|
|
@ -3209,11 +3205,13 @@ Node *Language::symbolLookup(String *s, const_String_or_char_ptr scope) {
|
|||
* Tries to locate a class from a type definition
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
Node *Language::classLookup(const SwigType *s) const {
|
||||
Node *Language::classLookup(const SwigType *s) {
|
||||
static Hash *classtypes = 0;
|
||||
|
||||
Node *n = 0;
|
||||
|
||||
/* Look in hash of cached values */
|
||||
n = Getattr(classtypes, s);
|
||||
n = classtypes ? Getattr(classtypes, s) : 0;
|
||||
if (!n) {
|
||||
Symtab *stab = 0;
|
||||
SwigType *ty1 = SwigType_typedef_resolve_all(s);
|
||||
|
|
@ -3268,6 +3266,8 @@ Node *Language::classLookup(const SwigType *s) const {
|
|||
}
|
||||
if (acceptable_prefix) {
|
||||
SwigType *cs = Copy(s);
|
||||
if (!classtypes)
|
||||
classtypes = NewHash();
|
||||
Setattr(classtypes, cs, n);
|
||||
Delete(cs);
|
||||
} else {
|
||||
|
|
@ -3294,10 +3294,12 @@ Node *Language::classLookup(const SwigType *s) const {
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
Node *Language::enumLookup(SwigType *s) {
|
||||
static Hash *enumtypes = 0;
|
||||
|
||||
Node *n = 0;
|
||||
|
||||
/* Look in hash of cached values */
|
||||
n = Getattr(enumtypes, s);
|
||||
n = enumtypes ? Getattr(enumtypes, s) : 0;
|
||||
if (!n) {
|
||||
Symtab *stab = 0;
|
||||
SwigType *lt = SwigType_ltype(s);
|
||||
|
|
@ -3338,6 +3340,8 @@ Node *Language::enumLookup(SwigType *s) {
|
|||
if (n) {
|
||||
/* Found a match. Look at the prefix. We only allow simple types. */
|
||||
if (Len(prefix) == 0) { /* Simple type */
|
||||
if (!enumtypes)
|
||||
enumtypes = NewHash();
|
||||
Setattr(enumtypes, Copy(s), n);
|
||||
} else {
|
||||
n = 0;
|
||||
|
|
|
|||
|
|
@ -225,8 +225,8 @@ public:
|
|||
virtual Hash* symbolAddScope(const_String_or_char_ptr scope);
|
||||
virtual Hash* symbolScopeLookup(const_String_or_char_ptr scope);
|
||||
virtual Hash* symbolScopePseudoSymbolLookup(const_String_or_char_ptr scope);
|
||||
virtual Node *classLookup(const SwigType *s) const; /* Class lookup */
|
||||
virtual Node *enumLookup(SwigType *s); /* Enum lookup */
|
||||
static Node *classLookup(const SwigType *s); /* Class lookup */
|
||||
static Node *enumLookup(SwigType *s); /* Enum lookup */
|
||||
virtual int abstractClassTest(Node *n); /* Is class really abstract? */
|
||||
virtual int is_assignable(Node *n); /* Is variable assignable? */
|
||||
virtual String *runtimeCode(); /* returns the language specific runtime code */
|
||||
|
|
@ -349,8 +349,6 @@ protected:
|
|||
|
||||
private:
|
||||
Hash *symtabs; /* symbol tables */
|
||||
Hash *classtypes;
|
||||
Hash *enumtypes;
|
||||
int overloading;
|
||||
int multiinput;
|
||||
int cplus_runtime;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue