[3/3] msvcirt: Implement ios constructors and assignment (try 2)
Iván Matellanes
matellanesivan at gmail.com
Sat Jul 4 09:24:53 CDT 2015
---
dlls/msvcirt/msvcirt.c | 67 ++++++++++++++++++++++++++++++++++----------
dlls/msvcirt/tests/msvcirt.c | 16 ++---------
2 files changed, 54 insertions(+), 29 deletions(-)
diff --git a/dlls/msvcirt/msvcirt.c b/dlls/msvcirt/msvcirt.c
index 36d0215..04c195d 100644
--- a/dlls/msvcirt/msvcirt.c
+++ b/dlls/msvcirt/msvcirt.c
@@ -71,6 +71,8 @@ typedef struct {
CRITICAL_SECTION lock;
} ios;
+ios* __thiscall ios_assign(ios*, const ios*);
+
/* class ostream */
typedef struct _ostream {
const vtable_ptr *vtable;
@@ -707,17 +709,12 @@ void __thiscall streambuf_dbp(streambuf *this)
DEFINE_THISCALL_WRAPPER(ios_copy_ctor, 8)
ios* __thiscall ios_copy_ctor(ios *this, const ios *copy)
{
- FIXME("(%p %p) stub\n", this, copy);
- return this;
-}
-
-/* ??0ios@@IAE at XZ */
-/* ??0ios@@IEAA at XZ */
-DEFINE_THISCALL_WRAPPER(ios_ctor, 4)
-ios* __thiscall ios_ctor(ios *this)
-{
- FIXME("(%p) stub\n", this);
- return this;
+ TRACE("(%p %p)\n", this, copy);
+ this->vtable = &MSVCP_ios_vtable;
+ this->sb = NULL;
+ this->delbuf = 0;
+ InitializeCriticalSection(&this->lock);
+ return ios_assign(this, copy);
}
/* ??0ios@@QAE at PAVstreambuf@@@Z */
@@ -725,16 +722,41 @@ ios* __thiscall ios_ctor(ios *this)
DEFINE_THISCALL_WRAPPER(ios_sb_ctor, 8)
ios* __thiscall ios_sb_ctor(ios *this, streambuf *sb)
{
- FIXME("(%p %p) stub\n", this, sb);
+ TRACE("(%p %p)\n", this, sb);
+ this->vtable = &MSVCP_ios_vtable;
+ this->sb = sb;
+ this->state = sb ? IOSTATE_goodbit : IOSTATE_badbit;
+ this->special[0] = this->special[1] = 0;
+ this->delbuf = 0;
+ this->tie = NULL;
+ this->flags = 0;
+ this->precision = 6;
+ this->fill = ' ';
+ this->width = 0;
+ this->do_lock = -1;
+ InitializeCriticalSection(&this->lock);
return this;
}
+/* ??0ios@@IAE at XZ */
+/* ??0ios@@IEAA at XZ */
+DEFINE_THISCALL_WRAPPER(ios_ctor, 4)
+ios* __thiscall ios_ctor(ios *this)
+{
+ return ios_sb_ctor(this, NULL);
+}
+
/* ??1ios@@UAE at XZ */
/* ??1ios@@UEAA at XZ */
DEFINE_THISCALL_WRAPPER(ios_dtor, 4)
void __thiscall ios_dtor(ios *this)
{
- FIXME("(%p) stub\n", this);
+ TRACE("(%p)\n", this);
+ if (this->delbuf && this->sb)
+ MSVCRT_operator_delete(this->sb);
+ this->sb = NULL;
+ this->state = IOSTATE_badbit;
+ DeleteCriticalSection(&this->lock);
}
/* ??4ios@@IAEAAV0 at ABV0@@Z */
@@ -742,7 +764,15 @@ void __thiscall ios_dtor(ios *this)
DEFINE_THISCALL_WRAPPER(ios_assign, 8)
ios* __thiscall ios_assign(ios *this, const ios *rhs)
{
- FIXME("(%p %p) stub\n", this, rhs);
+ TRACE("(%p %p)\n", this, rhs);
+ this->state = rhs->state;
+ if (!this->sb)
+ this->state |= IOSTATE_badbit;
+ this->tie = rhs->tie;
+ this->flags = rhs->flags;
+ this->precision = (char) rhs->precision;
+ this->fill = rhs->fill;
+ this->width = (char) rhs->width;
return this;
}
@@ -926,7 +956,14 @@ ios* __cdecl ios_hex(ios *this)
DEFINE_THISCALL_WRAPPER(ios_init, 8)
void __thiscall ios_init(ios *this, streambuf *sb)
{
- FIXME("(%p %p) stub\n", this, sb);
+ TRACE("(%p %p)\n", this, sb);
+ if (this->delbuf && this->sb)
+ MSVCRT_operator_delete(this->sb);
+ this->sb = sb;
+ if (sb == NULL)
+ this->state |= IOSTATE_badbit;
+ else
+ this->state &= ~IOSTATE_badbit;
}
/* ?iword at ios@@QBEAAJH at Z */
diff --git a/dlls/msvcirt/tests/msvcirt.c b/dlls/msvcirt/tests/msvcirt.c
index 19a2ebc..af70280 100644
--- a/dlls/msvcirt/tests/msvcirt.c
+++ b/dlls/msvcirt/tests/msvcirt.c
@@ -818,7 +818,6 @@ static void test_ios(void)
/* constructor/destructor */
call_func2(p_ios_sb_ctor, &ios_obj, NULL);
-todo_wine {
ok(ios_obj.sb == NULL, "expected %p got %p\n", NULL, ios_obj.sb);
ok(ios_obj.state == IOSTATE_badbit, "expected %x got %x\n", IOSTATE_badbit, ios_obj.state);
ok(ios_obj.special[0] == 0, "expected 0 got %d\n", ios_obj.special[0]);
@@ -848,7 +847,6 @@ todo_wine {
call_func1(p_ios_ctor, &ios_obj);
ok(ios_obj.sb == NULL, "expected %p got %p\n", NULL, ios_obj.sb);
ok(ios_obj.state == IOSTATE_badbit, "expected %x got %x\n", IOSTATE_badbit, ios_obj.state);
-}
/* init */
ios_obj.state |= 0x8;
@@ -856,10 +854,8 @@ todo_wine {
ok(ios_obj.sb == psb, "expected %p got %p\n", psb, ios_obj.sb);
ok(ios_obj.state == 0x8, "expected %x got %x\n", 0x8, ios_obj.state);
call_func2(p_ios_init, &ios_obj, NULL);
-todo_wine {
ok(ios_obj.sb == NULL, "expected %p got %p\n", NULL, ios_obj.sb);
ok(ios_obj.state == (0x8|IOSTATE_badbit), "expected %x got %x\n", (0x8|IOSTATE_badbit), ios_obj.state);
-}
ios_obj.sb = psb;
ios_obj.delbuf = 1;
call_func2(p_ios_init, &ios_obj, psb);
@@ -868,19 +864,15 @@ todo_wine {
/* copy constructor */
call_func2(p_ios_copy_ctor, &ios_obj, &ios_obj2);
-todo_wine {
ok(ios_obj.sb == NULL, "expected %p got %p\n", NULL, ios_obj.sb);
ok(ios_obj.state == (ios_obj2.state|IOSTATE_badbit), "expected %x got %x\n", (ios_obj2.state|IOSTATE_badbit), ios_obj.state);
ok(ios_obj.delbuf == 0, "expected 0 got %d\n", ios_obj.delbuf);
-}
ok(ios_obj.tie == ios_obj2.tie, "expected %p got %p\n", ios_obj2.tie, ios_obj.tie);
ok(ios_obj.flags == ios_obj2.flags, "expected %x got %x\n", ios_obj2.flags, ios_obj.flags);
- todo_wine ok(ios_obj.precision == (char)0xab, "expected %d got %d\n", (char)0xab, ios_obj.precision);
+ ok(ios_obj.precision == (char)0xab, "expected %d got %d\n", (char)0xab, ios_obj.precision);
ok(ios_obj.fill == (char)0xab, "expected %d got %d\n", (char)0xab, ios_obj.fill);
-todo_wine {
ok(ios_obj.width == (char)0xab, "expected %d got %d\n", (char)0xab, ios_obj.width);
ok(ios_obj.do_lock == -1, "expected -1 got %d\n", ios_obj.do_lock);
-}
/* assignment */
ios_obj.state = 0x8;
@@ -892,22 +884,18 @@ todo_wine {
ios_obj.width = 0;
ios_obj.do_lock = 2;
call_func2(p_ios_assign, &ios_obj, &ios_obj2);
-todo_wine {
ok(ios_obj.sb == NULL, "expected %p got %p\n", NULL, ios_obj.sb);
ok(ios_obj.state == (ios_obj2.state|IOSTATE_badbit), "expected %x got %x\n", (ios_obj2.state|IOSTATE_badbit), ios_obj.state);
-}
ok(ios_obj.delbuf == 2, "expected 2 got %d\n", ios_obj.delbuf);
-todo_wine {
ok(ios_obj.tie == ios_obj2.tie, "expected %p got %p\n", ios_obj2.tie, ios_obj.tie);
ok(ios_obj.flags == ios_obj2.flags, "expected %x got %x\n", ios_obj2.flags, ios_obj.flags);
ok(ios_obj.precision == (char)0xab, "expected %d got %d\n", (char)0xab, ios_obj.precision);
ok(ios_obj.fill == (char)0xab, "expected %d got %d\n", (char)0xab, ios_obj.fill);
ok(ios_obj.width == (char)0xab, "expected %d got %d\n", (char)0xab, ios_obj.width);
-}
ok(ios_obj.do_lock == 2, "expected 2 got %d\n", ios_obj.do_lock);
ios_obj.delbuf = 0;
call_func1(p_ios_dtor, &ios_obj);
- todo_wine ok(ios_obj.state == IOSTATE_badbit, "expected %x got %x\n", IOSTATE_badbit, ios_obj.state);
+ ok(ios_obj.state == IOSTATE_badbit, "expected %x got %x\n", IOSTATE_badbit, ios_obj.state);
}
START_TEST(msvcirt)
--
2.1.4
More information about the wine-patches
mailing list