msvcirt: Implement ios constructors and assignment.

This commit is contained in:
Iván Matellanes 2015-07-04 16:24:53 +02:00 committed by Alexandre Julliard
parent 0dcb382a4e
commit bc01af8f8e
2 changed files with 54 additions and 29 deletions

View File

@ -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,7 +709,32 @@ 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);
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@PAVstreambuf@@@Z */
/* ??0ios@@QEAA@PEAVstreambuf@@@Z */
DEFINE_THISCALL_WRAPPER(ios_sb_ctor, 8)
ios* __thiscall ios_sb_ctor(ios *this, streambuf *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;
}
@ -716,17 +743,7 @@ ios* __thiscall ios_copy_ctor(ios *this, const ios *copy)
DEFINE_THISCALL_WRAPPER(ios_ctor, 4)
ios* __thiscall ios_ctor(ios *this)
{
FIXME("(%p) stub\n", this);
return this;
}
/* ??0ios@@QAE@PAVstreambuf@@@Z */
/* ??0ios@@QEAA@PEAVstreambuf@@@Z */
DEFINE_THISCALL_WRAPPER(ios_sb_ctor, 8)
ios* __thiscall ios_sb_ctor(ios *this, streambuf *sb)
{
FIXME("(%p %p) stub\n", this, sb);
return this;
return ios_sb_ctor(this, NULL);
}
/* ??1ios@@UAE@XZ */
@ -734,7 +751,12 @@ ios* __thiscall ios_sb_ctor(ios *this, streambuf *sb)
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@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@ios@@QBEAAJH@Z */

View File

@ -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)