Piotr Caban : msvcp71: Added strstream class implementation.

Alexandre Julliard julliard at winehq.org
Wed Oct 17 14:32:27 CDT 2012


Module: wine
Branch: master
Commit: a8f231b54685b5b4fd56203d980a929cd37f6c7b
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=a8f231b54685b5b4fd56203d980a929cd37f6c7b

Author: Piotr Caban <piotr at codeweavers.com>
Date:   Wed Oct 17 09:58:57 2012 +0200

msvcp71: Added strstream class implementation.

---

 dlls/msvcp71/ios.c        |  117 +++++++++++++++++++++++++++++++++++++++++++++
 dlls/msvcp71/msvcp71.spec |    8 ++--
 2 files changed, 121 insertions(+), 4 deletions(-)

diff --git a/dlls/msvcp71/ios.c b/dlls/msvcp71/ios.c
index 830d730..f1b354b 100644
--- a/dlls/msvcp71/ios.c
+++ b/dlls/msvcp71/ios.c
@@ -276,6 +276,14 @@ typedef struct {
     void (__cdecl *pfree)(void*);
 } strstreambuf;
 
+typedef struct {
+    basic_iostream_char base;
+    strstreambuf buf;
+    /* virtual inheritance
+     * basic_ios_char basic_ios;
+     */
+} strstream;
+
 extern const vtable_ptr MSVCP_iosb_vtable;
 
 /* ??_7ios_base at std@@6B@ */
@@ -467,6 +475,10 @@ extern const vtable_ptr MSVCP_basic_stringstream_short_vtable;
 /* ??_7strstreambuf at std@@6B */
 extern const vtable_ptr MSVCP_strstreambuf_vtable;
 
+static const int strstream_vbtable1[] = {0, sizeof(strstream)};
+static const int strstream_vbtable2[] = {0, sizeof(strstream)-FIELD_OFFSET(strstream, base.base2)};
+extern const vtable_ptr MSVCP_strstream_vtable;
+
 DEFINE_RTTI_DATA0(iosb, 0, ".?AV?$_Iosb at H@std@@");
 DEFINE_RTTI_DATA1(ios_base, 0, &iosb_rtti_base_descriptor, ".?AV?$_Iosb at H@std@@");
 DEFINE_RTTI_DATA2(basic_ios_char, 0, &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
@@ -615,6 +627,12 @@ DEFINE_RTTI_DATA8(basic_stringstream_short, sizeof(basic_stringstream_wchar),
         ".?AV?$basic_stringstream at GU?$char_traits at G@std@@V?$allocator at G@2@@std@@");
 DEFINE_RTTI_DATA1(strstreambuf, sizeof(strstreambuf),
         &basic_streambuf_char_rtti_base_descriptor, ".?AVstrstreambuf at std@@");
+DEFINE_RTTI_DATA8(strstream, sizeof(strstream),
+        &basic_istream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
+        &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
+        &basic_ostream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
+        &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
+        "?AVstrstream at std@@");
 
 #ifndef __GNUC__
 void __asm_dummy_vtables(void) {
@@ -829,6 +847,8 @@ void __asm_dummy_vtables(void) {
             VTABLE_ADD_FUNC(basic_streambuf_char_setbuf)
             VTABLE_ADD_FUNC(basic_streambuf_char_sync)
             VTABLE_ADD_FUNC(basic_streambuf_char_imbue));
+    __ASM_VTABLE(strstream,
+            VTABLE_ADD_FUNC(strstream_vector_dtor));
 #ifndef __GNUC__
 }
 #endif
@@ -12088,6 +12108,23 @@ void __thiscall strstreambuf__Init(strstreambuf *this, streamsize len, char *g,
         basic_streambuf_char_setp(&this->base, p, this->seekhigh);
 }
 
+/* ??0strstreambuf at std@@QAE at PACH0@Z */
+/* ??0strstreambuf at std@@QEAA at PEAC_J0@Z */
+/* ??0strstreambuf at std@@QAE at PADH0@Z */
+/* ??0strstreambuf at std@@QEAA at PEAD_J0@Z */
+/* ??0strstreambuf at std@@QAE at PAEH0@Z */
+/* ??0strstreambuf at std@@QEAA at PEAE_J0@Z */
+static strstreambuf* strstreambuf_ctor_get_put(strstreambuf *this, char *g, streamsize len, char *p)
+{
+    TRACE("(%p %p %ld %p)\n", this, g, len, p);
+
+    basic_streambuf_char_ctor(&this->base);
+    this->base.vtable = &MSVCP_strstreambuf_vtable;
+
+    strstreambuf__Init(this, len, g, p, 0);
+    return this;
+}
+
 /* ?_Tidy at strstreambuf@std@@IAEXXZ */
 /* ?_Tidy at strstreambuf@std@@IEAAXXZ */
 DEFINE_THISCALL_WRAPPER(strstreambuf__Tidy, 4)
@@ -12342,6 +12379,85 @@ int __thiscall strstreambuf_underflow(strstreambuf *this)
     return (unsigned char)(*gptr);
 }
 
+static inline basic_ios_char* strstream_to_basic_ios(strstream *ptr)
+{
+    return (basic_ios_char*)((char*)ptr+strstream_vbtable1[1]);
+}
+
+static inline strstream* strstream_from_basic_ios(basic_ios_char *ptr)
+{
+    return (strstream*)((char*)ptr-strstream_vbtable1[1]);
+}
+
+/* ??0strstream at std@@QAE at PADHH@Z */
+/* ??0strstream at std@@QEAA at PEAD_JH@Z */
+DEFINE_THISCALL_WRAPPER(strstream_ctor, 20)
+strstream* __thiscall strstream_ctor(strstream *this, char *buf, streamsize size, int mode, MSVCP_bool virt_init)
+{
+    basic_ios_char *basic_ios;
+
+    TRACE("(%p %p %ld %d %d)\n", this, buf, size, mode, virt_init);
+
+    if(virt_init) {
+        this->base.base1.vbtable = strstream_vbtable1;
+        this->base.base2.vbtable = strstream_vbtable2;
+        basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
+        basic_ios_char_ctor(basic_ios);
+    }else {
+        basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
+    }
+
+    strstreambuf_ctor_get_put(&this->buf, buf, size,
+            buf && (mode & OPENMODE_app) ? buf+strlen(buf) : buf);
+    basic_iostream_char_ctor(&this->base, &this->buf.base, FALSE);
+    basic_ios->base.vtable = &MSVCP_strstream_vtable;
+    return this;
+}
+
+/* ??1strstream at std@@UAE at XZ */
+/* ??1strstream at std@@UEAA at XZ */
+DEFINE_THISCALL_WRAPPER(strstream_dtor, 4)
+void __thiscall strstream_dtor(basic_ios_char *base)
+{
+    strstream *this = strstream_from_basic_ios(base);
+
+    TRACE("(%p)\n", this);
+
+    basic_iostream_char_dtor(basic_iostream_char_to_basic_ios(&this->base));
+    strstreambuf_dtor(&this->buf);
+}
+
+static void strstream_vbase_dtor(strstream *this)
+{
+    TRACE("(%p)\n", this);
+
+    strstream_dtor(strstream_to_basic_ios(this));
+    basic_ios_char_dtor(basic_istream_char_get_basic_ios(&this->base.base1));
+}
+
+DEFINE_THISCALL_WRAPPER(strstream_vector_dtor, 8)
+strstream* __thiscall strstream_vector_dtor(basic_ios_char *base, unsigned int flags)
+{
+    strstream *this = strstream_from_basic_ios(base);
+
+    TRACE("(%p %x)\n", this, flags);
+
+    if(flags & 2) {
+        /* we have an array, with the number of elements stored before the first object */
+        INT_PTR i, *ptr = (INT_PTR *)this-1;
+
+        for(i=*ptr-1; i>=0; i--)
+            strstream_vbase_dtor(this+i);
+        MSVCRT_operator_delete(ptr);
+    } else {
+        strstream_vbase_dtor(this);
+        if(flags & 1)
+            MSVCRT_operator_delete(this);
+    }
+
+    return this;
+}
+
 static void __cdecl setprecision_func(ios_base *base, streamsize prec)
 {
     ios_base_precision_set(base, prec);
@@ -12690,6 +12806,7 @@ void init_io(void *base)
     init_basic_stringstream_wchar_rtti(base);
     init_basic_stringstream_short_rtti(base);
     init_strstreambuf_rtti(base);
+    init_strstream_rtti(base);
 #endif
 
     basic_filebuf_char_ctor_file(&filebuf_char_stdin, stdin);
diff --git a/dlls/msvcp71/msvcp71.spec b/dlls/msvcp71/msvcp71.spec
index a8c3869..0e3928d 100644
--- a/dlls/msvcp71/msvcp71.spec
+++ b/dlls/msvcp71/msvcp71.spec
@@ -1003,8 +1003,8 @@
 @ stub -arch=win32 ??0money_base at std@@QAE at I@Z
 @ stub -arch=win64 ??0money_base at std@@QEAA at _K@Z
 @ stub -arch=win32 ??0ostrstream at std@@QAE at PADHH@Z
-@ stub -arch=win32 ??0strstream at std@@QAE at PADHH@Z
-@ stub -arch=win64 ??0strstream at std@@QEAA at PEAD_JH@Z
+@ thiscall -arch=win32 ??0strstream at std@@QAE at PADHH@Z(ptr ptr long long long) strstream_ctor
+@ cdecl -arch=win64 ??0strstream at std@@QEAA at PEAD_JH@Z(ptr ptr long long long) strstream_ctor
 @ stub -arch=win32 ??0time_base at std@@QAE at I@Z
 @ stub -arch=win64 ??0time_base at std@@QEAA at _K@Z
 @ stub -arch=win32 ??1?$_Mpunct at D@std@@MAE at XZ
@@ -1207,8 +1207,8 @@
 @ stub -arch=win64 ??1money_base at std@@UEAA at XZ
 @ stub -arch=win32 ??1ostrstream at std@@UAE at XZ
 @ stub -arch=win64 ??1ostrstream at std@@UEAA at XZ
-@ stub -arch=win32 ??1strstream at std@@UAE at XZ
-@ stub -arch=win64 ??1strstream at std@@UEAA at XZ
+@ thiscall -arch=win32 ??1strstream at std@@UAE at XZ(ptr) strstream_dtor
+@ cdecl -arch=win64 ??1strstream at std@@UEAA at XZ(ptr) strstream_dtor
 @ thiscall -arch=win32 ??1strstreambuf at std@@UAE at XZ(ptr) strstreambuf_dtor
 @ cdecl -arch=win64 ??1strstreambuf at std@@UEAA at XZ(ptr) strstreambuf_dtor
 @ stub -arch=win32 ??1time_base at std@@UAE at XZ




More information about the wine-cvs mailing list