diff --git a/SWIG/Lib/python/std_alloc.i b/SWIG/Lib/python/std_alloc.i new file mode 100644 index 000000000..35dc051be --- /dev/null +++ b/SWIG/Lib/python/std_alloc.i @@ -0,0 +1 @@ +%include diff --git a/SWIG/Lib/python/std_iostream.i b/SWIG/Lib/python/std_iostream.i index 8ceb23d6a..43d6b0c24 100644 --- a/SWIG/Lib/python/std_iostream.i +++ b/SWIG/Lib/python/std_iostream.i @@ -1,8 +1,8 @@ namespace std { -%pythoncallback(1) endl; -%pythoncallback(1) ends; -%pythoncallback(1) flush; +%callback(1) endl; +%callback(1) ends; +%callback(1) flush; } %include diff --git a/SWIG/Lib/python/std_sstream.i b/SWIG/Lib/python/std_sstream.i new file mode 100644 index 000000000..6647df8cd --- /dev/null +++ b/SWIG/Lib/python/std_sstream.i @@ -0,0 +1 @@ +%include diff --git a/SWIG/Lib/python/std_streambuf.i b/SWIG/Lib/python/std_streambuf.i index f48860c62..44b9bb4d7 100644 --- a/SWIG/Lib/python/std_streambuf.i +++ b/SWIG/Lib/python/std_streambuf.i @@ -1,87 +1 @@ -%include -%{ -#include -%} - -namespace std { - - template - class basic_streambuf - { - public: - // Types: - typedef _CharT char_type; - typedef _Traits traits_type; - typedef typename traits_type::int_type int_type; - typedef typename traits_type::pos_type pos_type; - typedef typename traits_type::off_type off_type; - - typedef basic_streambuf __streambuf_type; - - public: - virtual - ~basic_streambuf(); - - // Locales: - locale - pubimbue(const locale &__loc); - - locale - getloc() const; - - // Buffer and positioning: - __streambuf_type* - pubsetbuf(char_type* __s, streamsize __n); - - pos_type - pubseekoff(off_type __off, ios_base::seekdir __way, - ios_base::openmode __mode = std::ios_base::in | std::ios_base::out); - - pos_type - pubseekpos(pos_type __sp, - ios_base::openmode __mode = std::ios_base::in | std::ios_base::out); - - int - pubsync() ; - - // Get and put areas: - // Get area: - streamsize - in_avail(); - - int_type - snextc(); - - int_type - sbumpc(); - - int_type - sgetc(); - - streamsize - sgetn(char_type* __s, streamsize __n); - - // Putback: - int_type - sputbackc(char_type __c); - - int_type - sungetc(); - - // Put area: - int_type - sputc(char_type __c); - - streamsize - sputn(const char_type* __s, streamsize __n); - - protected: - basic_streambuf(); - - }; -} - -namespace std { - %template(streambuf) basic_streambuf >; - %template(wstreambuf) basic_streambuf >; -} +%include diff --git a/SWIG/Lib/std/std_alloc.i b/SWIG/Lib/std/std_alloc.i new file mode 100644 index 000000000..44dc8dc3e --- /dev/null +++ b/SWIG/Lib/std/std_alloc.i @@ -0,0 +1,77 @@ +namespace std +{ + /** + * @brief The "standard" allocator, as per [20.4]. + * + * The private _Alloc is "SGI" style. (See comments at the top + * of stl_alloc.h.) + * + * The underlying allocator behaves as follows. + * - __default_alloc_template is used via two typedefs + * - "__single_client_alloc" typedef does no locking for threads + * - "__alloc" typedef is threadsafe via the locks + * - __new_alloc is used for memory requests + * + * (See @link Allocators allocators info @endlink for more.) + */ + template + class allocator + { + public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef _Tp* pointer; + typedef const _Tp* const_pointer; + typedef _Tp& reference; + typedef const _Tp& const_reference; + typedef _Tp value_type; + + template + struct rebind; + + allocator() throw(); + + allocator(const allocator&) throw(); + template + allocator(const allocator<_Tp1>&) throw(); + ~allocator() throw(); + + + pointer + address(reference __x) const; + + + const_pointer + address(const_reference __x) const; + + + // NB: __n is permitted to be 0. The C++ standard says nothing + // about what the return value is when __n == 0. + _Tp* + allocate(size_type __n, const void* = 0); + + // __p is not permitted to be a null pointer. + void + deallocate(pointer __p, size_type __n); + + size_type + max_size() const throw(); + + void construct(pointer __p, const _Tp& __val); + void destroy(pointer __p); + }; + + template<> + class allocator + { + public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef void* pointer; + typedef const void* const_pointer; + typedef void value_type; + + template + struct rebind; + }; +} // namespace std diff --git a/SWIG/Lib/std/std_basic_string.i b/SWIG/Lib/std/std_basic_string.i index d07ed4c43..8f82012b6 100644 --- a/SWIG/Lib/std/std_basic_string.i +++ b/SWIG/Lib/std/std_basic_string.i @@ -1,5 +1,6 @@ %include %include +%include %include %{ @@ -8,7 +9,7 @@ namespace std { - template > + template , typename _Alloc = std::allocator<_CharT> > class basic_string { #if !defined(SWIG_STD_MODERN_STL) || defined(SWIG_STD_NOMODERN_STL) @@ -181,7 +182,7 @@ namespace std { #ifdef %swig_basic_string // Add swig/language extra methods - %swig_basic_string(std::basic_string<_CharT >); + %swig_basic_string(std::basic_string<_CharT, _Traits, _Alloc >); #endif #ifdef SWIG_EXPORT_ITERATOR_METHODS @@ -223,27 +224,27 @@ namespace std { replace(iterator __i1, iterator __i2, const_iterator __k1, const_iterator __k2); #endif - std::basic_string<_CharT>& operator +=(const basic_string& v); + basic_string& operator +=(const basic_string& v); %newobject __add__; %newobject __radd__; %extend { - std::basic_string<_CharT>* __add__(const basic_string& v) { - std::basic_string<_CharT>* res = new std::basic_string<_CharT>(*self); + std::basic_string<_CharT,_Traits,_Alloc >* __add__(const basic_string& v) { + std::basic_string<_CharT,_Traits,_Alloc >* res = new std::basic_string<_CharT,_Traits,_Alloc >(*self); *res += v; return res; } - std::basic_string<_CharT>* __radd__(const basic_string& v) { - std::basic_string<_CharT>* res = new std::basic_string<_CharT>(v); + std::basic_string<_CharT,_Traits,_Alloc >* __radd__(const basic_string& v) { + std::basic_string<_CharT,_Traits,_Alloc >* res = new std::basic_string<_CharT,_Traits,_Alloc >(v); *res += *self; return res; } - const std::basic_string<_CharT>& __str__() { + std::basic_string<_CharT,_Traits,_Alloc > __str__() { return *self; - } + } std::basic_ostream<_CharT, std::char_traits<_CharT> >& __rlshift__(std::basic_ostream<_CharT, std::char_traits<_CharT> >& out) { diff --git a/SWIG/Lib/std/std_iostream.i b/SWIG/Lib/std/std_iostream.i index 849c5fdf8..e07387b5a 100644 --- a/SWIG/Lib/std/std_iostream.i +++ b/SWIG/Lib/std/std_iostream.i @@ -11,7 +11,7 @@ namespace std { // 27.6.2.1 Template class basic_ostream - template + template > class basic_ostream : virtual public basic_ios<_CharT, _Traits> { public: @@ -33,22 +33,29 @@ namespace std // 27.6.2.5.3 basic_ostream::operator<< basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& (*__pf)(basic_ostream<_CharT, _Traits>&)); + basic_ostream<_CharT, _Traits>& operator<<(basic_ios<_CharT, _Traits>& (*__pf)(basic_ios<_CharT, _Traits>&)); - + + basic_ostream<_CharT, _Traits>& operator<<(ios_base& (*__pf) (ios_base&)); // 27.6.2.5.2 Arithmetic Inserters + basic_ostream<_CharT, _Traits>& operator<<(long __n); + + basic_ostream<_CharT, _Traits>& operator<<(unsigned long __n); + basic_ostream<_CharT, _Traits>& operator<<(bool __n); + basic_ostream<_CharT, _Traits>& operator<<(short __n); @@ -56,9 +63,11 @@ namespace std basic_ostream<_CharT, _Traits>& operator<<(unsigned short __n); + basic_ostream<_CharT, _Traits>& operator<<(int __n); + basic_ostream<_CharT, _Traits>& operator<<(unsigned int __n); @@ -68,6 +77,8 @@ namespace std basic_ostream<_CharT, _Traits>& operator<<(unsigned long long __n); + + basic_ostream<_CharT, _Traits>& operator<<(double __f); @@ -77,12 +88,22 @@ namespace std basic_ostream<_CharT, _Traits>& operator<<(long double __f); + basic_ostream<_CharT, _Traits>& operator<<(const void* __p); basic_ostream<_CharT, _Traits>& operator<<(basic_streambuf<_CharT, _Traits>* __sb); + %extend { + std::basic_ostream<_CharT, _Traits >& + operator<<(const std::basic_string<_CharT,_Traits, std::allocator<_CharT> >& s) + { + *self << s; + return *self; + } + } + // Unformatted output: basic_ostream<_CharT, _Traits>& put(char_type __c); @@ -103,18 +124,10 @@ namespace std basic_ostream<_CharT, _Traits>& seekp(off_type, ios_base::seekdir); - %extend { - std::basic_ostream<_CharT, _Traits>& - operator<<(const std::basic_string<_CharT>& s) - { - *self << s; - return *self; - } - } }; // 27.6.1.1 Template class basic_istream - template + template > class basic_istream : virtual public basic_ios<_CharT, _Traits> { public: @@ -247,7 +260,7 @@ namespace std }; // 27.6.1.5 Template class basic_iostream - template + template > class basic_iostream : public basic_istream<_CharT, _Traits>, public basic_ostream<_CharT, _Traits> @@ -284,15 +297,15 @@ namespace std extern std::wostream wcerr; extern std::wostream wclog; - template + template > std::basic_ostream<_CharT, _Traits>& endl(std::basic_ostream<_CharT, _Traits>&); - template + template > std::basic_ostream<_CharT, _Traits>& ends(std::basic_ostream<_CharT, _Traits>&); - template + template > std::basic_ostream<_CharT, _Traits>& flush(std::basic_ostream<_CharT, _Traits>&); } diff --git a/SWIG/Lib/std/std_sstream.i b/SWIG/Lib/std/std_sstream.i new file mode 100644 index 000000000..c79087eb0 --- /dev/null +++ b/SWIG/Lib/std/std_sstream.i @@ -0,0 +1,179 @@ +%include +%include +%include +%include +%include +%include +%include + +%{ +#include +%} + + +namespace std +{ + template, + typename _Alloc = allocator<_CharT> > + class basic_stringbuf : public basic_streambuf<_CharT, _Traits> + { + public: + // Types: + typedef _CharT char_type; + typedef _Traits traits_type; +// 251. basic_stringbuf missing allocator_type + typedef _Alloc allocator_type; + typedef typename traits_type::int_type int_type; + typedef typename traits_type::pos_type pos_type; + typedef typename traits_type::off_type off_type; + + public: + // Constructors: + explicit + basic_stringbuf(ios_base::openmode __mode = ios_base::in | ios_base::out); + + explicit + basic_stringbuf(const basic_string& __str, + ios_base::openmode __mode = ios_base::in | ios_base::out); + + // Get and set: + basic_string + str() const; + + void + str(const basic_string& __s); + + }; + + + // 27.7.2 Template class basic_istringstream + template, + typename _Alloc = allocator<_CharT> > + class basic_istringstream : public basic_istream<_CharT, _Traits> + { + public: + // Types: + typedef _CharT char_type; + typedef _Traits traits_type; +// 251. basic_stringbuf missing allocator_type + typedef _Alloc allocator_type; + typedef typename traits_type::int_type int_type; + typedef typename traits_type::pos_type pos_type; + typedef typename traits_type::off_type off_type; + + + public: + // Constructors: + explicit + basic_istringstream(ios_base::openmode __mode = ios_base::in); + + explicit + basic_istringstream(const basic_string& __str, + ios_base::openmode __mode = ios_base::in); + + ~basic_istringstream(); + + // Members: + basic_stringbuf<_CharT, _Traits, _Alloc>* + rdbuf() const; + + basic_string + str() const; + + void + str(const basic_string& __s); + }; + + + // 27.7.3 Template class basic_ostringstream + template, + typename _Alloc = allocator<_CharT> > + class basic_ostringstream : public basic_ostream<_CharT, _Traits> + { + public: + // Types: + typedef _CharT char_type; + typedef _Traits traits_type; +// 251. basic_stringbuf missing allocator_type + typedef _Alloc allocator_type; + typedef typename traits_type::int_type int_type; + typedef typename traits_type::pos_type pos_type; + typedef typename traits_type::off_type off_type; + + + public: + // Constructors/destructor: + explicit + basic_ostringstream(ios_base::openmode __mode = ios_base::out); + + explicit + basic_ostringstream(const basic_string& __str, + ios_base::openmode __mode = ios_base::out); + + ~basic_ostringstream(); + + // Members: + basic_stringbuf<_CharT, _Traits, _Alloc>* + rdbuf() const; + + basic_string + str() const; + +#if 0 + void + str(const basic_string& __s); +#endif + }; + + + // 27.7.4 Template class basic_stringstream + template, + typename _Alloc = allocator<_CharT> > + class basic_stringstream : public basic_iostream<_CharT, _Traits> + { + public: + // Types: + typedef _CharT char_type; + typedef _Traits traits_type; +// 251. basic_stringbuf missing allocator_type + typedef _Alloc allocator_type; + typedef typename traits_type::int_type int_type; + typedef typename traits_type::pos_type pos_type; + typedef typename traits_type::off_type off_type; + + public: + // Constructors/destructors + explicit + basic_stringstream(ios_base::openmode __m = ios_base::out | ios_base::in); + + explicit + basic_stringstream(const basic_string& __str, + ios_base::openmode __m = ios_base::out | ios_base::in); + + ~basic_stringstream(); + + // Members: + basic_stringbuf<_CharT, _Traits, _Alloc>* + rdbuf() const; + + basic_string + str() const; + + void + str(const basic_string& __s); + }; + + +} // namespace std + + +namespace std { + %template(istringstream) basic_istringstream, allocator >; + %template(ostringstream) basic_ostringstream, allocator >; + %template(stringstream) basic_stringstream, allocator >; + + + %template(wistringstream) basic_istringstream, allocator >; + %template(wostringstream) basic_ostringstream, allocator >; + %template(wstringstream) basic_stringstream, allocator >; +} diff --git a/SWIG/Lib/std/std_string.i b/SWIG/Lib/std/std_string.i index 6c75b4c5c..7ffe0c61f 100644 --- a/SWIG/Lib/std/std_string.i +++ b/SWIG/Lib/std/std_string.i @@ -4,6 +4,9 @@ namespace std { - %std_comp_methods(basic_string); - typedef basic_string string; + %std_comp_methods(basic_string, std::allocator >); + typedef basic_string, std::allocator > string; } + + +%template(string) std::basic_string, std::allocator >; diff --git a/SWIG/Lib/std/std_wstring.i b/SWIG/Lib/std/std_wstring.i index dd78d0254..58fa05889 100644 --- a/SWIG/Lib/std/std_wstring.i +++ b/SWIG/Lib/std/std_wstring.i @@ -9,6 +9,8 @@ namespace std { - %std_comp_methods(basic_string); - typedef basic_string wstring; + %std_comp_methods(basic_string, std::allocator >); + typedef basic_string, std::allocator > wstring; } + +%template(wstring) std::basic_string, std::allocator >;