[PHP] "empty" is a reserved word in PHP, so rename empty() method

on STL classes to "is_empty()" (previously this was automatically
renamed to "c_empty()").
*** POTENTIAL INCOMPATIBILITY ***


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11772 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Olly Betts 2009-12-04 04:33:58 +00:00
commit 0633acd24f
3 changed files with 35 additions and 16 deletions

View file

@ -1,6 +1,12 @@
Version 1.3.41 (in progress) Version 1.3.41 (in progress)
============================ ============================
2009-12-04: olly
[PHP] "empty" is a reserved word in PHP, so rename empty() method
on STL classes to "is_empty()" (previously this was automatically
renamed to "c_empty()").
*** POTENTIAL INCOMPATIBILITY ***
2009-12-03: olly 2009-12-03: olly
[PHP] Add typemaps for long long and unsigned long long, and for [PHP] Add typemaps for long long and unsigned long long, and for
pointer to method. pointer to method.

View file

@ -30,8 +30,6 @@ namespace std {
map(const map<K,T> &); map(const map<K,T> &);
unsigned int size() const; unsigned int size() const;
%rename(is_empty) empty;
bool empty() const;
void clear(); void clear();
%extend { %extend {
T& get(const K& key) throw (std::out_of_range) { T& get(const K& key) throw (std::out_of_range) {
@ -55,6 +53,9 @@ namespace std {
std::map<K,T >::iterator i = self->find(key); std::map<K,T >::iterator i = self->find(key);
return i != self->end(); return i != self->end();
} }
bool is_empty() const {
return self->empty();
}
} }
}; };
@ -70,8 +71,6 @@ namespace std {
map(const map<K,T> &); map(const map<K,T> &);
unsigned int size() const; unsigned int size() const;
%rename(is_empty) empty;
bool empty() const;
void clear(); void clear();
%extend { %extend {
T& get(K key) throw (std::out_of_range) { T& get(K key) throw (std::out_of_range) {
@ -95,6 +94,9 @@ namespace std {
std::map<K,T >::iterator i = self->find(key); std::map<K,T >::iterator i = self->find(key);
return i != self->end(); return i != self->end();
} }
bool is_empty() const {
return self->empty();
}
} }
}; };
%enddef %enddef
@ -107,8 +109,6 @@ namespace std {
map(const map<K,T> &); map(const map<K,T> &);
unsigned int size() const; unsigned int size() const;
%rename(is_empty) empty;
bool empty() const;
void clear(); void clear();
%extend { %extend {
T get(const K& key) throw (std::out_of_range) { T get(const K& key) throw (std::out_of_range) {
@ -132,6 +132,9 @@ namespace std {
std::map<K,T >::iterator i = self->find(key); std::map<K,T >::iterator i = self->find(key);
return i != self->end(); return i != self->end();
} }
bool is_empty() const {
return self->empty();
}
} }
}; };
%enddef %enddef
@ -145,8 +148,6 @@ namespace std {
map(const map<K,T> &); map(const map<K,T> &);
unsigned int size() const; unsigned int size() const;
%rename(is_empty) empty;
bool empty() const;
void clear(); void clear();
%extend { %extend {
T get(K key) throw (std::out_of_range) { T get(K key) throw (std::out_of_range) {
@ -170,6 +171,9 @@ namespace std {
std::map<K,T >::iterator i = self->find(key); std::map<K,T >::iterator i = self->find(key);
return i != self->end(); return i != self->end();
} }
bool is_empty() const {
return self->empty();
}
} }
}; };
%enddef %enddef

View file

@ -27,7 +27,7 @@
}; };
*/ */
%define %std_deque_methods(T) %define %std_deque_methods_noempty(T)
typedef T &reference; typedef T &reference;
typedef const T& const_reference; typedef const T& const_reference;
@ -41,7 +41,6 @@
unsigned int size() const; unsigned int size() const;
unsigned int max_size() const; unsigned int max_size() const;
void resize(unsigned int n, T c = T()); void resize(unsigned int n, T c = T());
bool empty() const;
const_reference front(); const_reference front();
const_reference back(); const_reference back();
void push_front(const T& x); void push_front(const T& x);
@ -112,15 +111,25 @@
self->erase(self->begin()+i,self->begin()+j); self->erase(self->begin()+i,self->begin()+j);
} }
}; };
%enddef %enddef
#ifdef SWIGPHP
%define %std_deque_methods(T)
%extend {
bool is_empty() const {
return self->empty();
}
};
%enddef
#else
%define %std_deque_methods(T)
bool empty() const;
%enddef
#endif
namespace std { namespace std {
template<class T> class deque { template<class T> class deque {
public: public:
%std_deque_methods(T); %std_deque_methods(T);
}; };
} }