Browse Source

Add functional header to parser-inc (#126)

* Support for the functional header

* Add unordered_map and initializer_list

* Add unordered_set header

* Fix spacing, and remove unecessary defines

* Add missing definitions to memory header

* Use variadic templates in functional header
tobspr 9 years ago
parent
commit
c0fd29d822

+ 153 - 0
dtool/src/parser-inc/functional

@@ -0,0 +1,153 @@
+/**
+ * PANDA 3D SOFTWARE
+ * Copyright (c) Carnegie Mellon University.  All rights reserved.
+ *
+ * All use of this software is subject to the terms of the revised BSD
+ * license.  You should have received a copy of this license along
+ * with this source code in a file named "LICENSE."
+ *
+ * @file functional
+ * @author tobspr
+ * @date 2016-11-01
+ */
+
+// This file, and all the other files in this directory, aren't
+// intended to be compiled--they're just parsed by CPPParser (and
+// interrogate) in lieu of the actual system headers, to generate the
+// interrogate database.
+
+#ifndef FUNCTIONAL_H
+#define FUNCTIONAL_H
+
+#include <stddef.h>
+
+namespace std {
+
+  // base (deprecated):
+  template <class Arg, class Result> struct unary_function;
+  template <class Arg1, class Arg2, class Result> struct binary_function;
+ 
+  // reference_wrapper:
+  template <class T> class reference_wrapper;
+
+  // arithmetic operations:
+  template <class T> struct plus;
+  template <class T> struct minus;
+  template <class T> struct multiplies;
+  template <class T> struct divides;
+  template <class T> struct modulus;
+  template <class T> struct negate;
+ 
+  // comparisons:
+  template <class T> struct equal_to;
+  template <class T> struct not_equal_to;
+  template <class T> struct greater;
+  template <class T> struct less;
+  template <class T> struct greater_equal;
+  template <class T> struct less_equal;
+ 
+  // logical operations:
+  template <class T> struct logical_and;
+  template <class T> struct logical_or;
+  template <class T> struct logical_not;
+ 
+  // bitwise operations:
+  template <class T> struct bit_and;
+  template <class T> struct bit_or;
+  template <class T> struct bit_xor;
+ 
+  // negators:
+  template <class Predicate> class unary_negate;
+  template <class Predicate>  class binary_negate;
+ 
+  // bind:
+  template<class T> struct is_bind_expression;
+  template<class T> struct is_placeholder;
+
+  namespace placeholders {
+    // M is the implementation-defined number of placeholders
+    // (8 should be enough for interrogate)
+    extern char _1;
+    extern char _2;
+    extern char _3;
+    extern char _4;
+    extern char _5;
+    extern char _6;
+    extern char _7;
+    extern char _8;
+  }
+ 
+  // binders (deprecated):
+  template <class Fn> class binder1st;
+  template <class Fn> class binder2nd;
+
+  // adaptors (deprecated):
+  template <class Arg, class Result> class pointer_to_unary_function;
+  template <class Arg1, class Arg2, class Result>
+    class pointer_to_binary_function;
+ 
+  // adaptors (deprecated):
+  template<class S, class T> class mem_fun_t;
+  template<class S, class T, class A> class mem_fun1_t;
+  template<class S, class T> class mem_fun_ref_t;
+  template<class S, class T, class A> class mem_fun1_ref_t;
+  template <class S, class T> class const_mem_fun_t;
+  template <class S, class T, class A> class const_mem_fun1_t;
+  template <class S, class T> class const_mem_fun_ref_t;
+  template <class S, class T, class A> class const_mem_fun1_ref_t;
+ 
+
+  // polymorphic function wrappers:
+  class bad_function_call;
+
+  // hash function base template:
+  template <class T> struct hash;
+ 
+  // Hash function specializations
+  template <> struct hash<bool>;
+  template <> struct hash<char>;
+  template <> struct hash<signed char>;
+  template <> struct hash<unsigned char>;
+  template <> struct hash<char16_t>;
+  template <> struct hash<char32_t>;
+  template <> struct hash<wchar_t>;
+  template <> struct hash<short>;
+  template <> struct hash<unsigned short>;
+  template <> struct hash<int>;
+  template <> struct hash<unsigned int>;
+  template <> struct hash<long>;
+  template <> struct hash<long long>;
+  template <> struct hash<unsigned long>;
+  template <> struct hash<unsigned long long>;
+  template <> struct hash<float>;
+  template <> struct hash<double>;
+  template <> struct hash<long double>;
+  template<class T> struct hash<T*>;
+   
+  template <class T> class reference_wrapper {
+  public :
+    // types
+    typedef T type;
+    typedef void   result_type;      // not always defined
+    typedef void argument_type;    // not always defined
+    typedef void  first_argument_type;  // not always defined
+    typedef void  second_argument_type; // not always defined
+  };
+
+  template<class T> struct is_bind_expression {};
+  // : integral_constant<bool, true> {};
+
+  class bad_function_call : public std::exception {};
+
+  // template<class> class function; // undefined
+   
+  template< class R, class... ArgTypes >
+  class function {
+  public:
+    typedef R result_type;
+  };
+
+}
+
+
+#endif

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

@@ -0,0 +1,34 @@
+/**
+ * PANDA 3D SOFTWARE
+ * Copyright (c) Carnegie Mellon University.  All rights reserved.
+ *
+ * All use of this software is subject to the terms of the revised BSD
+ * license.  You should have received a copy of this license along
+ * with this source code in a file named "LICENSE."
+ *
+ * @file initializer_list
+ * @author tobspr
+ * @date 2016-11-01
+ */
+
+// This file, and all the other files in this directory, aren't
+// intended to be compiled--they're just parsed by CPPParser (and
+// interrogate) in lieu of the actual system headers, to generate the
+// interrogate database.
+
+#ifndef INITIALIZER_LIST_H
+#define INITIALIZER_LIST_H
+
+#include <stdtypedefs.h>
+
+namespace std {
+  template<class E> class initializer_list {
+  public:
+    typedef E value_type;
+    typedef const E& reference;
+    typedef const E& const_reference;
+    typedef size_t size_type;
+    typedef const E* iterator;
+    typedef const E* const_iterator;
+  };
+}

+ 163 - 23
dtool/src/parser-inc/memory

@@ -1,16 +1,15 @@
-// Filename: allocator
-// Created by:  drose (12May00)
-//
-////////////////////////////////////////////////////////////////////
-//
-// PANDA 3D SOFTWARE
-// Copyright (c) Carnegie Mellon University.  All rights reserved.
-//
-// All use of this software is subject to the terms of the revised BSD
-// license.  You should have received a copy of this license along
-// with this source code in a file named "LICENSE."
-//
-////////////////////////////////////////////////////////////////////
+/**
+ * PANDA 3D SOFTWARE
+ * Copyright (c) Carnegie Mellon University.  All rights reserved.
+ *
+ * All use of this software is subject to the terms of the revised BSD
+ * license.  You should have received a copy of this license along
+ * with this source code in a file named "LICENSE."
+ *
+ * @file memory
+ * @author tobspr
+ * @date 2016-11-01
+ */
 
 // This file, and all the other files in this directory, aren't
 // intended to be compiled--they're just parsed by CPPParser (and
@@ -21,6 +20,8 @@
 #define ALLOCATOR_H
 
 #include <stdtypedefs.h>
+#include <iterator>
+
 
 #ifdef GCC_STYLE_ALLOCATOR
 
@@ -33,16 +34,155 @@ public:
 #else  // GCC_STYLE_ALLOCATOR
 
 namespace std {
-  template<class Type>
-  class allocator {
-  public:
-    typedef Type *pointer;
-    typedef const Type *const_pointer;
-    typedef size_t size_type;
-
-    pointer allocate(size_type n, allocator<void>::const_pointer hint = 0);
-    void deallocate(pointer p, size_type n);
-  };
+
+    // pointer traits
+    template <class Ptr> struct pointer_traits;
+    template <class T> struct pointer_traits<T*>;
+ 
+    // pointer safety
+    enum class pointer_safety { relaxed, preferred, strict };
+    
+    // allocator argument tag
+    struct allocator_arg_t { };
+    constexpr allocator_arg_t allocator_arg = allocator_arg_t();
+ 
+    // uses_allocator
+    template <class T, class Alloc> struct uses_allocator;
+ 
+    // allocator traits
+    template <class Alloc> struct allocator_traits;
+ 
+    // the default allocator:
+    template <class T> class allocator;
+    template <> class allocator<void>;
+    
+    // raw storage iterator:
+    template <class OutputIterator, class T> class raw_storage_iterator;
+ 
+    // class template unique_ptr:
+    template <class T> class default_delete;
+    template <class T> class default_delete<T[]>;
+    template <class T, class D = default_delete<T>> class unique_ptr;
+    template <class T, class D> class unique_ptr<T[], D>;
+    // class bad_weak_ptr:
+    class bad_weak_ptr;
+ 
+    // class template shared_ptr:
+    template<class T> class shared_ptr;
+    // class template weak_ptr:
+    template<class T> class weak_ptr;
+ 
+    // class template owner_less:
+    template<class T> class owner_less;
+ 
+    // class template enable_shared_from_this:
+    template<class T> class enable_shared_from_this;
+ 
+    //  hash support
+    template <class T> struct hash;
+    template <class T, class D> struct hash<unique_ptr<T, D> >;
+    template <class T> struct hash<shared_ptr<T> >;
+ 
+    // auto_ptr (deprecated)
+    template <class X> class auto_ptr;
+
+    template <class Ptr> struct pointer_traits {
+        typedef Ptr         pointer;
+        typedef Ptr         element_type;
+        typedef ptrdiff_t   difference_type;
+ 
+        template <class U> using rebind = U; 
+    };
+
+    template <class T> struct pointer_traits<T*> {
+        typedef T*          pointer;
+        typedef T           element_type;
+        typedef ptrdiff_t   difference_type;
+ 
+        template <class U> using rebind = U*;
+    };
+
+
+    template <class Alloc> struct allocator_traits {
+        typedef Alloc allocator_type;
+ 
+        typedef typename Alloc::value_type value_type;
+ 
+        typedef void* pointer;
+        typedef const void* const_pointer;
+        typedef void* void_pointer;
+        typedef const void* const_void_pointer;
+ 
+        typedef std::ptrdiff_t difference_type;
+        typedef size_t size_type;
+ 
+        struct propagate_on_container_copy_assignment;
+        struct propagate_on_container_move_assignment;
+        struct propagate_on_container_swap;
+        struct is_always_equal;
+ 
+        template <class T> using rebind_alloc = size_t;
+        template <class T> using rebind_traits = allocator_traits<rebind_alloc<T> >;
+    };
+
+    template <class T> class allocator;
+    // specialize for void:
+    template <> class allocator<void> {
+    public:
+        typedef void*           pointer;
+        typedef const void*     const_pointer;
+        // reference-to-void members are impossible.
+        typedef void            value_type;
+        template <class U> struct rebind { typedef allocator<U> other; };
+    };
+    template <class T> class allocator {
+    public:
+        struct true_type_; // do not depend on type_traits header
+        typedef size_t          size_type;
+        typedef ptrdiff_t       difference_type;
+        typedef T*              pointer;
+        typedef const T*        const_pointer;
+        typedef T&              reference;
+        typedef const T&        const_reference;
+        typedef T               value_type;
+        template <class U> struct rebind { typedef allocator<U> other; };
+        typedef true_type_       propagate_on_container_move_assignment;
+        typedef true_type_       is_always_equal;
+ 
+    };
+
+    template <class OutputIterator, class T>
+    class raw_storage_iterator
+        : public iterator<output_iterator_tag,void,void,void,void> {
+    public:
+    };
+
+
+    template <class T> struct default_delete {};
+ 
+    template <class T> struct default_delete<T[]> {};
+
+    //  unique_ptr for single objects
+    template <class T, class D = default_delete<T>> class unique_ptr {
+    public:
+        typedef T* pointer;
+        typedef T  element_type;
+        typedef D  deleter_type;
+    };
+ 
+    class bad_weak_ptr: public std::exception {};
+
+    template<class T> class shared_ptr {
+    public:
+        typedef T element_type;
+    };
+
+    template<class T> class weak_ptr {
+    public:
+        typedef T element_type;
+    };
+
+    template<class T> class enable_shared_from_this {};
 }
 
 #endif  // GCC_STYLE_ALLOCATOR

+ 84 - 0
dtool/src/parser-inc/unordered_map

@@ -0,0 +1,84 @@
+/**
+ * PANDA 3D SOFTWARE
+ * Copyright (c) Carnegie Mellon University.  All rights reserved.
+ *
+ * All use of this software is subject to the terms of the revised BSD
+ * license.  You should have received a copy of this license along
+ * with this source code in a file named "LICENSE."
+ *
+ * @file unordered_map
+ * @author tobspr
+ * @date 2016-11-01
+ */
+
+// This file, and all the other files in this directory, aren't
+// intended to be compiled--they're just parsed by CPPParser (and
+// interrogate) in lieu of the actual system headers, to generate the
+// interrogate database.
+
+#ifndef UNORDERED_MAP_H
+#define UNORDERED_MAP_H
+
+#include <stdtypedefs.h>
+#include <stdcompare.h>
+#include <pair>
+#include <initializer_list>
+#include <functional>
+
+namespace std {
+ 
+  template <class Key,
+    class T,
+    class Hash = hash<Key>,
+    class Pred = std::equal_to<Key>,
+    class Allocator = std::allocator<std::pair<const Key, T> > >
+  class unordered_map
+  {
+  public:
+    // types
+    typedef Key key_type;
+    typedef Key value_type;
+    typedef Hash hasher;
+    typedef Pred key_equal;
+    typedef Allocator allocator_type;
+    typedef typename allocator_type::pointer pointer;
+    typedef typename allocator_type::const_pointer const_pointer;
+    typedef typename allocator_type::reference reference;
+    typedef typename allocator_type::const_reference const_reference;
+    typedef size_t size_type;
+    typedef std::ptrdiff_t difference_type;
+    class iterator;
+    class const_iterator;
+    class local_iterator;
+    class const_local_iterator;
+  };
+
+  template <class Key,
+  class T,
+  class Hash = hash<Key>,
+  class Pred = std::equal_to<Key>,
+  class Allocator = std::allocator<std::pair<const Key, T> > >
+  class unordered_multimap
+  {
+  public:
+    // types
+    typedef Key key_type;
+    typedef Key value_type;
+    typedef Hash hasher;
+    typedef Pred key_equal;
+    typedef Allocator allocator_type;
+    typedef typename allocator_type::pointer pointer;
+    typedef typename allocator_type::const_pointer const_pointer;
+    typedef typename allocator_type::reference reference;
+    typedef typename allocator_type::const_reference const_reference;
+    typedef size_t size_type;
+    typedef std::ptrdiff_t difference_type;
+    class iterator;
+    class const_iterator;
+    class local_iterator;
+    class const_local_iterator;
+  };
+
+} // namespace std
+
+#endif

+ 83 - 0
dtool/src/parser-inc/unordered_set

@@ -0,0 +1,83 @@
+/**
+ * PANDA 3D SOFTWARE
+ * Copyright (c) Carnegie Mellon University.  All rights reserved.
+ *
+ * All use of this software is subject to the terms of the revised BSD
+ * license.  You should have received a copy of this license along
+ * with this source code in a file named "LICENSE."
+ *
+ * @file unordered_set
+ * @author tobspr
+ * @date 2016-11-01
+ */
+
+// This file, and all the other files in this directory, aren't
+// intended to be compiled--they're just parsed by CPPParser (and
+// interrogate) in lieu of the actual system headers, to generate the
+// interrogate database.
+
+#ifndef UNORDERED_SET_H
+#define UNORDERED_SET_H
+
+#include <stdtypedefs.h>
+#include <stdcompare.h>
+#include <pair>
+#include <initializer_list>
+#include <functional>
+
+namespace std {
+
+  template <class Key,
+    class Hash = hash<Key>,
+    class Pred = std::equal_to<Key>,
+    class Allocator = std::allocator<Key> >
+  class unordered_set
+  {
+  public:
+    // types
+    typedef Key key_type;
+    typedef Key value_type;
+    typedef Hash hasher;
+    typedef Pred key_equal;
+    typedef Allocator allocator_type;
+    typedef typename allocator_type::pointer pointer;
+    typedef typename allocator_type::const_pointer const_pointer;
+    typedef typename allocator_type::reference reference;
+    typedef typename allocator_type::const_reference  const_reference;
+    typedef size_t size_type;
+    typedef std::ptrdiff_t difference_type;
+   
+    class iterator;
+    class const_iterator;
+    class local_iterator;
+    class const_local_iterator;
+  };
+
+  template <class Key,
+    class Hash = hash<Key>,
+    class Pred = std::equal_to<Key>,
+    class Allocator = std::allocator<Key> >
+  class unordered_multiset
+  {
+  public:
+    // types
+    typedef Key key_type;
+    typedef Key value_type;
+    typedef Hash hasher;
+    typedef Pred key_equal;
+    typedef Allocator allocator_type;
+    typedef typename allocator_type::pointer pointer;
+    typedef typename allocator_type::const_pointer    const_pointer;
+    typedef typename allocator_type::reference reference;
+    typedef typename allocator_type::const_reference  const_reference;
+    typedef size_t size_type;
+    typedef std::ptrdiff_t difference_type;
+    class iterator;
+    class const_iterator;
+    class local_iterator;
+    class const_local_iterator;
+  };
+
+} // namespace std
+
+#endif