Piotr Caban : msvcp71: Added ostrstream class implementation.

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


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

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

msvcp71: Added ostrstream class implementation.

---

 dlls/msvcp71/ios.c        |   95 +++++++++++++++++++++++++++++++++++++++++++++
 dlls/msvcp71/msvcp71.spec |    6 +-
 2 files changed, 98 insertions(+), 3 deletions(-)

diff --git a/dlls/msvcp71/ios.c b/dlls/msvcp71/ios.c
index f1b354b..b9af853 100644
--- a/dlls/msvcp71/ios.c
+++ b/dlls/msvcp71/ios.c
@@ -277,6 +277,14 @@ typedef struct {
 } strstreambuf;
 
 typedef struct {
+    basic_ostream_char base;
+    strstreambuf buf;
+    /* virtual inheritance
+     * basic_ios_char basic_ios;
+     */
+} ostrstream;
+
+typedef struct {
     basic_iostream_char base;
     strstreambuf buf;
     /* virtual inheritance
@@ -475,6 +483,9 @@ extern const vtable_ptr MSVCP_basic_stringstream_short_vtable;
 /* ??_7strstreambuf at std@@6B */
 extern const vtable_ptr MSVCP_strstreambuf_vtable;
 
+static const int ostrstream_vbtable[] = {0, sizeof(ostrstream)};
+extern const vtable_ptr MSVCP_ostrstream_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;
@@ -627,6 +638,10 @@ 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_DATA4(ostrstream, sizeof(ostrstream),
+        &basic_ostream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
+        &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
+        "?AVostrstream 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,
@@ -847,6 +862,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(ostrstream,
+            VTABLE_ADD_FUNC(ostrstream_vector_dtor));
     __ASM_VTABLE(strstream,
             VTABLE_ADD_FUNC(strstream_vector_dtor));
 #ifndef __GNUC__
@@ -12379,6 +12396,83 @@ int __thiscall strstreambuf_underflow(strstreambuf *this)
     return (unsigned char)(*gptr);
 }
 
+static inline basic_ios_char* ostrstream_to_basic_ios(ostrstream *ptr)
+{
+    return (basic_ios_char*)((char*)ptr+ostrstream_vbtable[1]);
+}
+
+static inline ostrstream* ostrstream_from_basic_ios(basic_ios_char *ptr)
+{
+    return (ostrstream*)((char*)ptr-ostrstream_vbtable[1]);
+}
+
+/* ??0ostrstream at std@@QAE at PADHH@Z */
+DEFINE_THISCALL_WRAPPER(ostrstream_ctor, 20)
+ostrstream* __thiscall ostrstream_ctor(ostrstream *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.vbtable = ostrstream_vbtable;
+        basic_ios = basic_ostream_char_get_basic_ios(&this->base);
+        basic_ios_char_ctor(basic_ios);
+    }else {
+        basic_ios = basic_ostream_char_get_basic_ios(&this->base);
+    }
+
+    strstreambuf_ctor_get_put(&this->buf, buf, size,
+            buf && (mode & OPENMODE_app) ? buf+strlen(buf) : buf);
+    basic_ostream_char_ctor(&this->base, &this->buf.base, FALSE, FALSE);
+    basic_ios->base.vtable = &MSVCP_ostrstream_vtable;
+    return this;
+}
+
+/* ??1ostrstream at std@@UAE at XZ */
+/* ??1ostrstream at std@@UEAA at XZ */
+DEFINE_THISCALL_WRAPPER(ostrstream_dtor, 4)
+void __thiscall ostrstream_dtor(basic_ios_char *base)
+{
+    ostrstream *this = ostrstream_from_basic_ios(base);
+
+    TRACE("(%p)\n", this);
+
+    basic_ostream_char_dtor(basic_ostream_char_to_basic_ios(&this->base));
+    strstreambuf_dtor(&this->buf);
+}
+
+static void ostrstream_vbase_dtor(ostrstream *this)
+{
+    TRACE("(%p)\n", this);
+
+    ostrstream_dtor(ostrstream_to_basic_ios(this));
+    basic_ios_char_dtor(basic_ostream_char_get_basic_ios(&this->base));
+}
+
+DEFINE_THISCALL_WRAPPER(ostrstream_vector_dtor, 8)
+ostrstream* __thiscall ostrstream_vector_dtor(basic_ios_char *base, unsigned int flags)
+{
+    ostrstream *this = ostrstream_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--)
+            ostrstream_vbase_dtor(this+i);
+        MSVCRT_operator_delete(ptr);
+    } else {
+        ostrstream_vbase_dtor(this);
+        if(flags & 1)
+            MSVCRT_operator_delete(this);
+    }
+
+    return this;
+}
+
 static inline basic_ios_char* strstream_to_basic_ios(strstream *ptr)
 {
     return (basic_ios_char*)((char*)ptr+strstream_vbtable1[1]);
@@ -12807,6 +12901,7 @@ void init_io(void *base)
     init_basic_stringstream_short_rtti(base);
     init_strstreambuf_rtti(base);
     init_strstream_rtti(base);
+    init_ostrstream_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 0e3928d..726bfd8 100644
--- a/dlls/msvcp71/msvcp71.spec
+++ b/dlls/msvcp71/msvcp71.spec
@@ -1002,7 +1002,7 @@
 @ stub -arch=win64 ??0messages_base at std@@QEAA at _K@Z
 @ 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
+@ thiscall -arch=win32 ??0ostrstream at std@@QAE at PADHH@Z(ptr ptr long long long) ostrstream_ctor
 @ 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
@@ -1205,8 +1205,8 @@
 @ stub -arch=win64 ??1messages_base at std@@UEAA at XZ
 @ stub -arch=win32 ??1money_base at std@@UAE at XZ
 @ 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
+@ thiscall -arch=win32 ??1ostrstream at std@@UAE at XZ(ptr) ostrstream_dtor
+@ cdecl -arch=win64 ??1ostrstream at std@@UEAA at XZ(ptr) ostrstream_dtor
 @ 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




More information about the wine-cvs mailing list