stdcxx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject svn commit: r422548 - in /incubator/stdcxx/trunk/tests: include/rw_ctype.h self/0.ctype.cpp src/ctype.cpp
Date Sun, 16 Jul 2006 21:57:24 GMT
Author: sebor
Date: Sun Jul 16 14:57:24 2006
New Revision: 422548

URL: http://svn.apache.org/viewvc?rev=422548&view=rev
Log:
2006-07-16  Martin Sebor  <sebor@roguewave.com>

	* rw_ctype.h (std::ctype<UserChar>): Defined specialization.
	(UserCtype<UserChar>): Defined in terms of the above.
	* src/ctype.cpp (std::ctype<UserChar>): Defined members.
	(UserCtype<UserChar>): Removed definitions of virtual members.
	* test/ctype.cpp (UserCtype::id): Exercised.

Modified:
    incubator/stdcxx/trunk/tests/include/rw_ctype.h
    incubator/stdcxx/trunk/tests/self/0.ctype.cpp
    incubator/stdcxx/trunk/tests/src/ctype.cpp

Modified: incubator/stdcxx/trunk/tests/include/rw_ctype.h
URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/tests/include/rw_ctype.h?rev=422548&r1=422547&r2=422548&view=diff
==============================================================================
--- incubator/stdcxx/trunk/tests/include/rw_ctype.h (original)
+++ incubator/stdcxx/trunk/tests/include/rw_ctype.h Sun Jul 16 14:57:24 2006
@@ -205,8 +205,10 @@
 #endif   // _RWSTD_NO_WCHAR_T
 
 
+_RWSTD_NAMESPACE (std) {
+
 _RWSTD_SPECIALIZED_CLASS
-class _TEST_EXPORT UserCtype<UserChar>
+class _TEST_EXPORT ctype<UserChar>
     : public std::locale::facet, public UserCtypeBase
 {
     typedef std::locale::facet Base;
@@ -215,7 +217,10 @@
     typedef UserChar char_type;
 
     explicit
-    UserCtype (const int* = 0, const int* = 0, _RWSTD_SIZE_T = 0);
+    ctype (_RWSTD_SIZE_T = 0);
+
+    explicit
+    ctype (const int*, const int*, _RWSTD_SIZE_T = 0);
 
     bool
     is (mask m, char_type c) const {
@@ -317,6 +322,22 @@
 
     virtual const char_type*
     do_narrow (const char_type*, const char_type*, char, char*) const;
+};
+
+}   // namespace std
+
+
+_RWSTD_SPECIALIZED_CLASS
+class _TEST_EXPORT UserCtype<UserChar>
+    : public std::ctype<UserChar>
+{
+    typedef std::ctype<UserChar> Base;
+public:
+
+    typedef UserChar char_type;
+
+    explicit
+    UserCtype (const int* = 0, const int* = 0, _RWSTD_SIZE_T = 0);
 };
 
 

Modified: incubator/stdcxx/trunk/tests/self/0.ctype.cpp
URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/tests/self/0.ctype.cpp?rev=422548&r1=422547&r2=422548&view=diff
==============================================================================
--- incubator/stdcxx/trunk/tests/self/0.ctype.cpp (original)
+++ incubator/stdcxx/trunk/tests/self/0.ctype.cpp Sun Jul 16 14:57:24 2006
@@ -106,6 +106,23 @@
 
 template <class charT>
 void
+test_id (charT*, const char *cname)
+{
+    rw_info (0, 0, __LINE__, "UserCtype<%s>::id", cname);
+
+    std::locale::id* const pid_b = &std::ctype<charT>::id;
+    std::locale::id* const pid_d = &UserCtype<charT>::id;
+
+    rw_assert (pid_b == pid_d, 0, __LINE__,
+               "&ctype<%s>::id == &UserCtype<%1$s>::id "
+               "(%#p == %2$#p, got %#p)",
+               cname, pid_b, pid_d);
+}
+
+/***********************************************************************/
+
+template <class charT>
+void
 test_is (charT*, const char *cname,
          std::ctype_base::mask m,
          const char *chars, std::size_t n_chars)
@@ -397,6 +414,8 @@
 
 /***********************************************************************/
 
+/* extern */ int opt_id;
+
 /* extern */ int opt_is;
 /* extern */ int opt_scan_is;
 /* extern */ int opt_scan_not;
@@ -420,6 +439,8 @@
                  "UserCtype<%s>::%s() tests disabled",  \
                  cname, # func)
 
+    TEST (id);
+
     TEST (is);
     TEST (scan_is);
     TEST (scan_not);
@@ -455,6 +476,7 @@
                     "",
                     0,
                     run_test,
+                    "|-id~ "
                     "|-is~ "
                     "|-scan_is~ "
                     "|-scan_not~ "
@@ -462,6 +484,7 @@
                     "|-tolower~ "
                     "|-widen~ "
                     "|-narrow~ ",
+                    &opt_id,
                     &opt_is,
                     &opt_scan_is,
                     &opt_scan_not,

Modified: incubator/stdcxx/trunk/tests/src/ctype.cpp
URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/tests/src/ctype.cpp?rev=422548&r1=422547&r2=422548&view=diff
==============================================================================
--- incubator/stdcxx/trunk/tests/src/ctype.cpp (original)
+++ incubator/stdcxx/trunk/tests/src/ctype.cpp Sun Jul 16 14:57:24 2006
@@ -1261,9 +1261,26 @@
 
 /**************************************************************************/
 
-UserCtype<UserChar>::
-UserCtype (const int *chars, const int *masks, size_t refs)
-    : Base (refs), UserCtypeBase ("wchar_t")
+_RWSTD_NAMESPACE (std) {
+
+
+std::locale::id
+ctype<UserChar>::
+id;
+
+
+ctype<UserChar>::
+ctype (size_t refs)
+    : Base (refs), UserCtypeBase ("UserChar")
+{
+    masks_ = _rw_char_masks;
+    chars_ = 0;
+}
+
+
+ctype<UserChar>::
+ctype (const int *chars, const int *masks, size_t refs)
+    : Base (refs), UserCtypeBase ("UserChar")
 {
     if (0 == masks) {
         // when masks is null so must chars
@@ -1276,7 +1293,7 @@
 }
 
 
-bool UserCtype<UserChar>::
+bool ctype<UserChar>::
 do_is (mask m, char_type ch) const
 {
     _rw_funcall (*this, mf_is);
@@ -1297,8 +1314,8 @@
 }
 
 
-const UserCtype<UserChar>::char_type*
-UserCtype<UserChar>::
+const ctype<UserChar>::char_type*
+ctype<UserChar>::
 do_is (const char_type *lo, const char_type *hi, mask *vec) const
 {
     _rw_funcall (*this, mf_is_range);
@@ -1337,8 +1354,8 @@
 }
 
 
-const UserCtype<UserChar>::char_type*
-UserCtype<UserChar>::
+const ctype<UserChar>::char_type*
+ctype<UserChar>::
 do_scan_is (mask m, const char_type *lo, const char_type *hi) const
 {
     _rw_funcall (*this, mf_scan_is);
@@ -1369,8 +1386,8 @@
 }
 
 
-const UserCtype<UserChar>::char_type*
-UserCtype<UserChar>::
+const ctype<UserChar>::char_type*
+ctype<UserChar>::
 do_scan_not (mask m, const char_type *lo, const char_type *hi) const
 {
     _rw_funcall (*this, mf_scan_not);
@@ -1404,8 +1421,8 @@
 }
 
 
-UserCtype<UserChar>::char_type
-UserCtype<UserChar>::
+ctype<UserChar>::char_type
+ctype<UserChar>::
 do_toupper (char_type ch) const
 {
     _rw_funcall (*this, mf_toupper);
@@ -1433,8 +1450,8 @@
 }
 
 
-const UserCtype<UserChar>::char_type*
-UserCtype<UserChar>::
+const ctype<UserChar>::char_type*
+ctype<UserChar>::
 do_toupper (char_type *lo, const char_type *hi) const
 {
     _rw_funcall (*this, mf_toupper_range);
@@ -1463,8 +1480,8 @@
 }
 
 
-UserCtype<UserChar>::char_type
-UserCtype<UserChar>::
+ctype<UserChar>::char_type
+ctype<UserChar>::
 do_tolower (char_type ch) const
 {
     _rw_funcall (*this, mf_tolower);
@@ -1491,8 +1508,8 @@
 }
 
 
-const UserCtype<UserChar>::char_type*
-UserCtype<UserChar>::
+const ctype<UserChar>::char_type*
+ctype<UserChar>::
 do_tolower (char_type *lo, const char_type *hi) const
 {
     _rw_funcall (*this, mf_tolower_range);
@@ -1520,8 +1537,8 @@
 }
 
 
-UserCtype<UserChar>::char_type
-UserCtype<UserChar>::
+ctype<UserChar>::char_type
+ctype<UserChar>::
 do_widen (char ch) const
 {
     _rw_funcall (*this, mf_widen);
@@ -1549,7 +1566,7 @@
 
 
 const char*
-UserCtype<UserChar>::
+ctype<UserChar>::
 do_widen (const char *lo, const char *hi, char_type *dst) const
 {
     _rw_funcall (*this, mf_widen_range);
@@ -1589,7 +1606,7 @@
 }
 
 
-char UserCtype<UserChar>::
+char ctype<UserChar>::
 do_narrow (char_type ch, char dfault) const
 {
     _rw_funcall (*this, mf_narrow);
@@ -1616,8 +1633,8 @@
 }
 
 
-const UserCtype<UserChar>::char_type*
-UserCtype<UserChar>::
+const ctype<UserChar>::char_type*
+ctype<UserChar>::
 do_narrow (const char_type *lo, const char_type *hi, char dflt, char *dst) const
 {
     _rw_funcall (*this, mf_narrow_range);
@@ -1649,4 +1666,22 @@
     }
 
     return lo;
+}
+
+}   // namespace std
+
+/**************************************************************************/
+
+UserCtype<UserChar>::
+UserCtype (const int *chars, const int *masks, size_t refs)
+    : Base (refs)
+{
+    if (0 == masks) {
+        // when masks is null so must chars
+        RW_ASSERT (0 == chars);
+        masks = _rw_char_masks;
+    }
+
+    chars_ = chars;
+    masks_ = masks;
 }



Mime
View raw message