Browse Source

parser-inc: provide various more STL headers and definitions

This cuts down on various warnings generated by interrogate.
rdb 7 years ago
parent
commit
e27cb2dec3

+ 3 - 0
dtool/src/dtoolbase/dtoolbase_cc.h

@@ -33,7 +33,10 @@
 
 #ifdef CPPPARSER
 #include <iostream>
+#include <iomanip>
 #include <string>
+#include <utility>
+#include <algorithm>
 
 #define INLINE inline
 #define ALWAYS_INLINE inline

+ 1 - 0
dtool/src/dtoolutil/config_dtoolutil.N

@@ -3,6 +3,7 @@ forcetype ifstream
 forcetype fstream
 
 forcetype ios_base
+forcetype basic_ios<char>
 forcetype ios
 forcetype istream
 forcetype ostream

+ 7 - 0
dtool/src/parser-inc/algorithm

@@ -20,5 +20,12 @@
 #ifndef ALGORITHM_H
 #define ALGORITHM_H
 
+namespace std {
+  template<class T>
+  constexpr const T &min(const T &a, const T &b);
+  template<class T>
+  constexpr const T &max(const T &a, const T &b);
+}
+
 #endif
 

+ 19 - 0
dtool/src/parser-inc/atomic

@@ -0,0 +1,19 @@
+#pragma once
+
+#include <stdint.h>
+
+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<class T> struct atomic;
+  template<class T> struct atomic<T*>;
+
+  struct atomic_flag;
+}

+ 1 - 0
dtool/src/parser-inc/clocale

@@ -0,0 +1 @@
+#include <locale.h>

+ 7 - 0
dtool/src/parser-inc/cstddef

@@ -0,0 +1,7 @@
+#pragma once
+
+#include <stddef.h>
+
+namespace std {
+  enum class byte : unsigned char {};
+}

+ 1 - 0
dtool/src/parser-inc/cstdint

@@ -0,0 +1 @@
+#include <stdint.h>

+ 1 - 0
dtool/src/parser-inc/cstdio

@@ -0,0 +1 @@
+#include <stdio.h>

+ 1 - 0
dtool/src/parser-inc/cstring

@@ -0,0 +1 @@
+#include <string.h>

+ 1 - 0
dtool/src/parser-inc/ctime

@@ -0,0 +1 @@
+#include <time.h>

+ 8 - 0
dtool/src/parser-inc/cwchar

@@ -0,0 +1,8 @@
+#pragma once
+
+#include <stdtypedefs.h>
+
+namespace std {
+  struct mbstate_t;
+  typedef int wint_t;
+}

+ 10 - 0
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)();
+}

+ 2 - 0
dtool/src/parser-inc/initializer_list

@@ -32,3 +32,5 @@ namespace std {
     typedef const E* const_iterator;
   };
 }
+
+#endif

+ 6 - 0
dtool/src/parser-inc/iomanip

@@ -0,0 +1,6 @@
+#pragma once
+
+namespace std {
+  template<class CharT> void setfill(CharT c);
+  void setw(int);
+}

+ 106 - 0
dtool/src/parser-inc/ios

@@ -0,0 +1,106 @@
+#pragma once
+
+#include <iosfwd>
+
+// 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 charT, class traits = char_traits<charT> >
+  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
+  };
+}

+ 74 - 0
dtool/src/parser-inc/iosfwd

@@ -0,0 +1,74 @@
+#pragma once
+
+#include <streambuf>
+#include <stdtypedefs.h>
+#include <string>
+
+namespace std {
+  template<class T> class allocator;
+
+  template<class charT, class traits = char_traits<charT> > class basic_ios;
+  template<class charT, class traits = char_traits<charT> > class basic_istream;
+  template<class charT, class traits = char_traits<charT> > class basic_ostream;
+  template<class charT, class traits = char_traits<charT> > class basic_iostream;
+  template<class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> > class basic_stringbuf;
+
+  template<class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> > class basic_istringstream;
+  template<class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> > class basic_ostringstream;
+  template<class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> > class basic_stringstream;
+
+  template<class charT, class traits = char_traits<charT> > class basic_filebuf;
+  template<class charT, class traits = char_traits<charT> > class basic_ifstream;
+  template<class charT, class traits = char_traits<charT> > class basic_ofstream;
+  template<class charT, class traits = char_traits<charT> > class basic_fstream;
+
+  template<class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> > class basic_syncbuf;
+  template<class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> > class basic_osyncstream;
+
+  template<class charT, class traits = char_traits<charT> > class istreambuf_iterator;
+  template<class charT, class traits = char_traits<charT> > class ostreambuf_iterator;
+
+  typedef basic_ios<char> ios;
+  typedef basic_ios<wchar_t> wios;
+
+  //typedef basic_istream<char> istream;
+  //typedef basic_ostream<char> ostream;
+  //typedef basic_iostream<char> iostream;
+  class istream;
+  class ostream;
+  class iostream;
+
+  typedef basic_stringbuf<char> stringbuf;
+  typedef basic_istringstream<char> istringstream;
+  typedef basic_ostringstream<char> ostringstream;
+  typedef basic_stringstream<char> stringstream;
+
+  typedef basic_filebuf<char> filebuf;
+  typedef basic_ifstream<char> ifstream;
+  typedef basic_ofstream<char> ofstream;
+  typedef basic_fstream<char> fstream;
+
+  typedef basic_syncbuf<char> syncbuf;
+  typedef basic_osyncstream<char> osyncstream;
+
+  typedef basic_istream<wchar_t> wistream;
+  typedef basic_ostream<wchar_t> wostream;
+  typedef basic_iostream<wchar_t> wiostream;
+
+  typedef basic_stringbuf<wchar_t> wstringbuf;
+  typedef basic_istringstream<wchar_t> wistringstream;
+  typedef basic_ostringstream<wchar_t> wostringstream;
+  typedef basic_stringstream<wchar_t> wstringstream;
+
+  typedef basic_filebuf<wchar_t> wfilebuf;
+  typedef basic_ifstream<wchar_t> wifstream;
+  typedef basic_ofstream<wchar_t> wofstream;
+  typedef basic_fstream<wchar_t> wfstream;
+
+  typedef basic_syncbuf<wchar_t> wsyncbuf;
+  typedef basic_osyncstream<wchar_t> wosyncstream;
+
+  template<class state> class fpos;
+  typedef fpos<mbstate_t> streampos;
+  typedef fpos<mbstate_t> wstreampos;
+}

+ 3 - 58
dtool/src/parser-inc/iostream

@@ -21,64 +21,14 @@
 #define IOSTREAM_H
 
 #include <stdtypedefs.h>
-
-#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 <ios>
+#include <streambuf>
+#include <ostream>
 
 // 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;

+ 28 - 0
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 Mutex> class lock_guard;
+  template<class Mutex> class unique_lock;
+
+  struct once_flag;
+}

+ 12 - 0
dtool/src/parser-inc/ostream

@@ -0,0 +1,12 @@
+#pragma once
+
+namespace std {
+  template<class CharT, class Traits>
+  std::basic_ostream<CharT, Traits> &ends(std::basic_ostream<CharT, Traits> &os);
+
+  template<class CharT, class Traits>
+  std::basic_ostream<CharT, Traits> &flush(std::basic_ostream<CharT, Traits> &os);
+
+  template<class CharT, class Traits>
+  std::basic_ostream<CharT, Traits> &endl(std::basic_ostream<CharT, Traits> &os);
+}

+ 3 - 1
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.

+ 14 - 0
dtool/src/parser-inc/streambuf

@@ -0,0 +1,14 @@
+#pragma once
+
+namespace std {
+  template<class charT> class char_traits;
+  template<> class char_traits<char>;
+  template<> class char_traits<char16_t>;
+  template<> class char_traits<char32_t>;
+  template<> class char_traits<wchar_t>;
+
+  template<class charT, class traits = char_traits<charT> > class basic_streambuf;
+
+  typedef basic_streambuf<char> streambuf;
+  typedef basic_streambuf<wchar_t> wstreambuf;
+}

+ 26 - 2
dtool/src/parser-inc/string

@@ -21,10 +21,34 @@
 #define STRING_H
 
 #include <stdtypedefs.h>
+#include <cwchar>
 
 namespace std {
-  template<class charT>
-  class char_traits;
+  template<class charT> struct char_traits;
+
+  template<> struct char_traits<char> {
+    using char_type = char;
+    using int_type = int;
+    using state_type = mbstate_t;
+  };
+
+  template<> struct char_traits<char16_t> {
+    using char_type = char16_t;
+    using int_type = uint_least16_t;
+    using state_type = mbstate_t;
+  };
+
+  template<> struct char_traits<char32_t> {
+    using char_type = char32_t;
+    using int_type = uint_least32_t;
+    using state_type = mbstate_t;
+  };
+
+  template<> struct char_traits<wchar_t> {
+    using char_type = wchar_t;
+    using int_type = wint_t;
+    using state_type = mbstate_t;
+  };
 
   template<class ctype>
   class basic_string {

+ 16 - 0
dtool/src/parser-inc/utility

@@ -0,0 +1,16 @@
+#pragma once
+
+#include <initializer_list>
+
+namespace std {
+  template<class T> void swap(T &a, T &b);
+  template<class T, size_t N> void swap(T (&a)[N], T (&b)[N]);
+
+  template<class T> struct remove_reference      {typedef T type;};
+  template<class T> struct remove_reference<T&>  {typedef T type;};
+  template<class T> struct remove_reference<T&&> {typedef T type;};
+
+  template<class T> constexpr remove_reference<T>::type &&move(T &&) noexcept;
+
+  template<class T1, class T2> struct pair;
+}