From e27cb2dec32bcf30071c844e4ca787d1c7bfd3a8 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 4 Jun 2018 20:15:23 +0200 Subject: [PATCH] parser-inc: provide various more STL headers and definitions This cuts down on various warnings generated by interrogate. --- dtool/src/dtoolbase/dtoolbase_cc.h | 3 + dtool/src/dtoolutil/config_dtoolutil.N | 1 + dtool/src/parser-inc/algorithm | 7 ++ dtool/src/parser-inc/atomic | 19 +++++ dtool/src/parser-inc/clocale | 1 + dtool/src/parser-inc/cstddef | 7 ++ dtool/src/parser-inc/cstdint | 1 + dtool/src/parser-inc/cstdio | 1 + dtool/src/parser-inc/cstring | 1 + dtool/src/parser-inc/ctime | 1 + dtool/src/parser-inc/cwchar | 8 ++ dtool/src/parser-inc/exception | 10 +++ dtool/src/parser-inc/initializer_list | 2 + dtool/src/parser-inc/iomanip | 6 ++ dtool/src/parser-inc/ios | 106 +++++++++++++++++++++++++ dtool/src/parser-inc/iosfwd | 74 +++++++++++++++++ dtool/src/parser-inc/iostream | 61 +------------- dtool/src/parser-inc/mutex | 28 +++++++ dtool/src/parser-inc/ostream | 12 +++ dtool/src/parser-inc/stdtypedefs.h | 4 +- dtool/src/parser-inc/streambuf | 14 ++++ dtool/src/parser-inc/string | 28 ++++++- dtool/src/parser-inc/utility | 16 ++++ 23 files changed, 350 insertions(+), 61 deletions(-) create mode 100644 dtool/src/parser-inc/atomic create mode 100644 dtool/src/parser-inc/clocale create mode 100644 dtool/src/parser-inc/cstddef create mode 100644 dtool/src/parser-inc/cstdint create mode 100644 dtool/src/parser-inc/cstdio create mode 100644 dtool/src/parser-inc/cstring create mode 100644 dtool/src/parser-inc/ctime create mode 100644 dtool/src/parser-inc/cwchar create mode 100644 dtool/src/parser-inc/exception create mode 100644 dtool/src/parser-inc/iomanip create mode 100644 dtool/src/parser-inc/ios create mode 100644 dtool/src/parser-inc/iosfwd create mode 100644 dtool/src/parser-inc/mutex create mode 100644 dtool/src/parser-inc/ostream create mode 100644 dtool/src/parser-inc/streambuf create mode 100644 dtool/src/parser-inc/utility diff --git a/dtool/src/dtoolbase/dtoolbase_cc.h b/dtool/src/dtoolbase/dtoolbase_cc.h index 2aa6dc6252..db12cc8737 100644 --- a/dtool/src/dtoolbase/dtoolbase_cc.h +++ b/dtool/src/dtoolbase/dtoolbase_cc.h @@ -33,7 +33,10 @@ #ifdef CPPPARSER #include +#include #include +#include +#include #define INLINE inline #define ALWAYS_INLINE inline diff --git a/dtool/src/dtoolutil/config_dtoolutil.N b/dtool/src/dtoolutil/config_dtoolutil.N index 2577aa3b24..07e763282f 100644 --- a/dtool/src/dtoolutil/config_dtoolutil.N +++ b/dtool/src/dtoolutil/config_dtoolutil.N @@ -3,6 +3,7 @@ forcetype ifstream forcetype fstream forcetype ios_base +forcetype basic_ios forcetype ios forcetype istream forcetype ostream diff --git a/dtool/src/parser-inc/algorithm b/dtool/src/parser-inc/algorithm index 6f409742c2..751a8ec2cb 100644 --- a/dtool/src/parser-inc/algorithm +++ b/dtool/src/parser-inc/algorithm @@ -20,5 +20,12 @@ #ifndef ALGORITHM_H #define ALGORITHM_H +namespace std { + template + constexpr const T &min(const T &a, const T &b); + template + constexpr const T &max(const T &a, const T &b); +} + #endif diff --git a/dtool/src/parser-inc/atomic b/dtool/src/parser-inc/atomic new file mode 100644 index 0000000000..a7e174937b --- /dev/null +++ b/dtool/src/parser-inc/atomic @@ -0,0 +1,19 @@ +#pragma once + +#include + +namespace std { + typedef enum memory_order { + memory_order_relaxed, + memory_order_consume, + memory_order_acquire, + memory_order_release, + memory_order_acq_rel, + memory_order_seq_cst + } memory_order; + + template struct atomic; + template struct atomic; + + struct atomic_flag; +} diff --git a/dtool/src/parser-inc/clocale b/dtool/src/parser-inc/clocale new file mode 100644 index 0000000000..a889a57372 --- /dev/null +++ b/dtool/src/parser-inc/clocale @@ -0,0 +1 @@ +#include diff --git a/dtool/src/parser-inc/cstddef b/dtool/src/parser-inc/cstddef new file mode 100644 index 0000000000..78ed8af5a5 --- /dev/null +++ b/dtool/src/parser-inc/cstddef @@ -0,0 +1,7 @@ +#pragma once + +#include + +namespace std { + enum class byte : unsigned char {}; +} diff --git a/dtool/src/parser-inc/cstdint b/dtool/src/parser-inc/cstdint new file mode 100644 index 0000000000..9a6118bd85 --- /dev/null +++ b/dtool/src/parser-inc/cstdint @@ -0,0 +1 @@ +#include diff --git a/dtool/src/parser-inc/cstdio b/dtool/src/parser-inc/cstdio new file mode 100644 index 0000000000..53c5fdf179 --- /dev/null +++ b/dtool/src/parser-inc/cstdio @@ -0,0 +1 @@ +#include diff --git a/dtool/src/parser-inc/cstring b/dtool/src/parser-inc/cstring new file mode 100644 index 0000000000..3b2f590027 --- /dev/null +++ b/dtool/src/parser-inc/cstring @@ -0,0 +1 @@ +#include diff --git a/dtool/src/parser-inc/ctime b/dtool/src/parser-inc/ctime new file mode 100644 index 0000000000..91fd18715f --- /dev/null +++ b/dtool/src/parser-inc/ctime @@ -0,0 +1 @@ +#include diff --git a/dtool/src/parser-inc/cwchar b/dtool/src/parser-inc/cwchar new file mode 100644 index 0000000000..598c31d9a3 --- /dev/null +++ b/dtool/src/parser-inc/cwchar @@ -0,0 +1,8 @@ +#pragma once + +#include + +namespace std { + struct mbstate_t; + typedef int wint_t; +} diff --git a/dtool/src/parser-inc/exception b/dtool/src/parser-inc/exception new file mode 100644 index 0000000000..d48d80620e --- /dev/null +++ b/dtool/src/parser-inc/exception @@ -0,0 +1,10 @@ +#pragma once + +namespace std { + class exception; + class bad_exception; + class nested_exception; + + typedef void (*unexpected_handler)(); + typedef void (*terminate_handler)(); +} diff --git a/dtool/src/parser-inc/initializer_list b/dtool/src/parser-inc/initializer_list index 57a3f7f6c1..289b0e4bf7 100644 --- a/dtool/src/parser-inc/initializer_list +++ b/dtool/src/parser-inc/initializer_list @@ -32,3 +32,5 @@ namespace std { typedef const E* const_iterator; }; } + +#endif diff --git a/dtool/src/parser-inc/iomanip b/dtool/src/parser-inc/iomanip new file mode 100644 index 0000000000..cc19f56b38 --- /dev/null +++ b/dtool/src/parser-inc/iomanip @@ -0,0 +1,6 @@ +#pragma once + +namespace std { + template void setfill(CharT c); + void setw(int); +} diff --git a/dtool/src/parser-inc/ios b/dtool/src/parser-inc/ios new file mode 100644 index 0000000000..4ea9143c4a --- /dev/null +++ b/dtool/src/parser-inc/ios @@ -0,0 +1,106 @@ +#pragma once + +#include + +// We actually want to wrap streampos as streamoff. +#define streampos streamoff + +namespace std { +#ifdef _WIN64 + typedef long long streamoff; + typedef long long streamsize; +#elif defined(_WIN32) + typedef long streamoff; + typedef int streamsize; +#else + typedef long long streamoff; + typedef ptrdiff_t streamsize; +#endif + + // We need to expose one method in each class to force it to publish. + // But we'd like to expose some of these methods anyway, so no + // problem. + class ios_base { + public: + class failure; + class Init; + enum event { + erase_event, + imbue_event, + copyfmt_event, + }; + + ios_base(const ios_base&) = delete; + ios_base &operator = (const ios_base&) = delete; + + __published: + enum seekdir { + beg = 0, + cur = 1, + end = 2, + }; + enum openmode { + }; + // Don't define these lest interrogate get tempted to actually + // substitute in the values, which are implementation-defined. + static const openmode app; + static const openmode binary; + static const openmode in; + static const openmode out; + static const openmode trunc; + protected: + // Force this to be a non-trivial type. + ios_base() {}; + }; + + template > + class basic_ios : public ios_base { + public: + typedef charT char_type; + typedef typename traits::int_type int_type; + typedef typename traits::pos_type pos_type; + typedef typename traits::off_type off_type; + typedef traits traits_type; + + __published: + typedef long fmtflags; + + bool good() const; + bool eof() const; + bool fail() const; + bool bad() const; + void clear(); + + protected: + basic_ios(); + }; + + ios_base &boolalpha(ios_base &str); + ios_base &noboolalpha(ios_base &str); + ios_base &showbase(ios_base &str); + ios_base &noshowbase(ios_base &str); + ios_base &showpoint(ios_base &str); + ios_base &noshowpoint(ios_base &str); + ios_base &showpos(ios_base &str); + ios_base &noshowpos(ios_base &str); + ios_base &skipws(ios_base &str); + ios_base &noskipws(ios_base &str); + ios_base &uppercase(ios_base &str); + ios_base &nouppercase(ios_base &str); + ios_base &unitbuf(ios_base &str); + ios_base &nounitbuf(ios_base &str); + ios_base &internal(ios_base &str); + ios_base &left(ios_base &str); + ios_base &right(ios_base &str); + ios_base &dec(ios_base &str); + ios_base &hex(ios_base &str); + ios_base &oct(ios_base &str); + ios_base &fixed(ios_base &str); + ios_base &scientific(ios_base &str); + ios_base &hexfloat(ios_base &str); + ios_base &defaultfloat(ios_base &str); + + enum class io_errc { + stream = 1 + }; +} diff --git a/dtool/src/parser-inc/iosfwd b/dtool/src/parser-inc/iosfwd new file mode 100644 index 0000000000..176982d433 --- /dev/null +++ b/dtool/src/parser-inc/iosfwd @@ -0,0 +1,74 @@ +#pragma once + +#include +#include +#include + +namespace std { + template class allocator; + + template > class basic_ios; + template > class basic_istream; + template > class basic_ostream; + template > class basic_iostream; + template, class Allocator = allocator > class basic_stringbuf; + + template, class Allocator = allocator > class basic_istringstream; + template, class Allocator = allocator > class basic_ostringstream; + template, class Allocator = allocator > class basic_stringstream; + + template > class basic_filebuf; + template > class basic_ifstream; + template > class basic_ofstream; + template > class basic_fstream; + + template, class Allocator = allocator > class basic_syncbuf; + template, class Allocator = allocator > class basic_osyncstream; + + template > class istreambuf_iterator; + template > class ostreambuf_iterator; + + typedef basic_ios ios; + typedef basic_ios wios; + + //typedef basic_istream istream; + //typedef basic_ostream ostream; + //typedef basic_iostream iostream; + class istream; + class ostream; + class iostream; + + typedef basic_stringbuf stringbuf; + typedef basic_istringstream istringstream; + typedef basic_ostringstream ostringstream; + typedef basic_stringstream stringstream; + + typedef basic_filebuf filebuf; + typedef basic_ifstream ifstream; + typedef basic_ofstream ofstream; + typedef basic_fstream fstream; + + typedef basic_syncbuf syncbuf; + typedef basic_osyncstream osyncstream; + + typedef basic_istream wistream; + typedef basic_ostream wostream; + typedef basic_iostream wiostream; + + typedef basic_stringbuf wstringbuf; + typedef basic_istringstream wistringstream; + typedef basic_ostringstream wostringstream; + typedef basic_stringstream wstringstream; + + typedef basic_filebuf wfilebuf; + typedef basic_ifstream wifstream; + typedef basic_ofstream wofstream; + typedef basic_fstream wfstream; + + typedef basic_syncbuf wsyncbuf; + typedef basic_osyncstream wosyncstream; + + template class fpos; + typedef fpos streampos; + typedef fpos wstreampos; +} diff --git a/dtool/src/parser-inc/iostream b/dtool/src/parser-inc/iostream index 170d1d03f9..a01e208740 100644 --- a/dtool/src/parser-inc/iostream +++ b/dtool/src/parser-inc/iostream @@ -21,64 +21,14 @@ #define IOSTREAM_H #include - -#ifdef _WIN64 -typedef long long streamoff; -typedef long long streamsize; -#elif defined(_WIN32) -typedef long streamoff; -typedef int streamsize; -#else -typedef long long streamoff; -typedef ptrdiff_t streamsize; -#endif +#include +#include +#include // We don't care (much) about the actual definition of the various // iostream classes, but we do need to know the classnames that are // available. -// We need to expose one method in each class to force it to publish. -// But we'd like to expose some of these methods anyway, so no -// problem. -class ios_base { -__published: - enum seekdir { - beg = 0, - cur = 1, - end = 2, - }; - enum openmode { - }; - // Don't define these lest interrogate get tempted to actually - // substitute in the values, which are implementation-defined. - static const openmode app; - static const openmode binary; - static const openmode in; - static const openmode out; - static const openmode trunc; -protected: - // Force this to be a non-trivial type. - ios_base() {}; -private: - ios_base(const ios_base &); -}; -class ios : public ios_base { -__published: - typedef long fmtflags; - - bool good() const; - bool eof() const; - bool fail() const; - bool bad() const; - void clear(); - -protected: - ios(); -}; - -// We actually want to wrap streampos as streamoff. -#define streampos streamoff - class ostream : virtual public ios { __published: ostream(const ostream&) = delete; @@ -130,11 +80,6 @@ __published: void close(); }; -class ostringstream : public ostream {}; -class istringstream : public istream {}; -class stringstream : public iostream {}; -class streambuf {}; - extern istream cin; extern ostream cout; extern ostream cerr; diff --git a/dtool/src/parser-inc/mutex b/dtool/src/parser-inc/mutex new file mode 100644 index 0000000000..b05214e512 --- /dev/null +++ b/dtool/src/parser-inc/mutex @@ -0,0 +1,28 @@ +#pragma once + +namespace std { + class mutex; + class recursive_mutex; + class timed_mutex; + class recursive_timed_mutex; + + struct defer_lock_t { + explicit defer_lock_t() = default; + }; + inline constexpr defer_lock_t defer_lock {}; + + struct try_to_lock_t { + explicit try_to_lock_t() = default; + }; + inline constexpr try_to_lock_t try_to_lock {}; + + struct adopt_lock_t { + explicit adopt_lock_t() = default; + }; + inline constexpr adopt_lock_t adopt_lock {}; + + template class lock_guard; + template class unique_lock; + + struct once_flag; +} diff --git a/dtool/src/parser-inc/ostream b/dtool/src/parser-inc/ostream new file mode 100644 index 0000000000..fb7f7ea51e --- /dev/null +++ b/dtool/src/parser-inc/ostream @@ -0,0 +1,12 @@ +#pragma once + +namespace std { + template + std::basic_ostream &ends(std::basic_ostream &os); + + template + std::basic_ostream &flush(std::basic_ostream &os); + + template + std::basic_ostream &endl(std::basic_ostream &os); +} diff --git a/dtool/src/parser-inc/stdtypedefs.h b/dtool/src/parser-inc/stdtypedefs.h index f971d7e1f2..873ba9425d 100644 --- a/dtool/src/parser-inc/stdtypedefs.h +++ b/dtool/src/parser-inc/stdtypedefs.h @@ -46,7 +46,9 @@ struct timeval; #else #define NULL ((void *)0) #endif -typedef decltype(nullptr) nullptr_t; +namespace std { + typedef decltype(nullptr) nullptr_t; +} // One day, we might extend interrogate to be able to parse this, // but we currently don't need it. diff --git a/dtool/src/parser-inc/streambuf b/dtool/src/parser-inc/streambuf new file mode 100644 index 0000000000..b46f0faef3 --- /dev/null +++ b/dtool/src/parser-inc/streambuf @@ -0,0 +1,14 @@ +#pragma once + +namespace std { + template class char_traits; + template<> class char_traits; + template<> class char_traits; + template<> class char_traits; + template<> class char_traits; + + template > class basic_streambuf; + + typedef basic_streambuf streambuf; + typedef basic_streambuf wstreambuf; +} diff --git a/dtool/src/parser-inc/string b/dtool/src/parser-inc/string index 4ca8f3fa12..d27aaf783f 100644 --- a/dtool/src/parser-inc/string +++ b/dtool/src/parser-inc/string @@ -21,10 +21,34 @@ #define STRING_H #include +#include namespace std { - template - class char_traits; + template struct char_traits; + + template<> struct char_traits { + using char_type = char; + using int_type = int; + using state_type = mbstate_t; + }; + + template<> struct char_traits { + using char_type = char16_t; + using int_type = uint_least16_t; + using state_type = mbstate_t; + }; + + template<> struct char_traits { + using char_type = char32_t; + using int_type = uint_least32_t; + using state_type = mbstate_t; + }; + + template<> struct char_traits { + using char_type = wchar_t; + using int_type = wint_t; + using state_type = mbstate_t; + }; template class basic_string { diff --git a/dtool/src/parser-inc/utility b/dtool/src/parser-inc/utility new file mode 100644 index 0000000000..119814b5c3 --- /dev/null +++ b/dtool/src/parser-inc/utility @@ -0,0 +1,16 @@ +#pragma once + +#include + +namespace std { + template void swap(T &a, T &b); + template void swap(T (&a)[N], T (&b)[N]); + + template struct remove_reference {typedef T type;}; + template struct remove_reference {typedef T type;}; + template struct remove_reference {typedef T type;}; + + template constexpr remove_reference::type &&move(T &&) noexcept; + + template struct pair; +}