From 8e2efc19390423299a22ad730410f51f7c5539db Mon Sep 17 00:00:00 2001 From: Piotr Caban Date: Fri, 22 Jun 2012 10:28:05 +0200 Subject: [PATCH] msvcp90: Added basic_ostream::operator<<(base type) implementation. --- dlls/msvcp90/ios.c | 223 ++++++++++++++++++++++++++++++++++++++-------- dlls/msvcp90/locale.c | 26 ++++++ dlls/msvcp90/msvcp90.h | 18 ++++ dlls/msvcp90/msvcp90.spec | 12 +-- 4 files changed, 237 insertions(+), 42 deletions(-) diff --git a/dlls/msvcp90/ios.c b/dlls/msvcp90/ios.c index 9a615797323..d367f8c91a4 100644 --- a/dlls/msvcp90/ios.c +++ b/dlls/msvcp90/ios.c @@ -3701,8 +3701,24 @@ basic_ostream_char* __thiscall basic_ostream_char_write(basic_ostream_char *this DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_short, 8) basic_ostream_char* __thiscall basic_ostream_char_print_short(basic_ostream_char *this, short val) { - FIXME("(%p %d) stub\n", this, val); - return NULL; + basic_ios_char *base = basic_ostream_char_get_basic_ios(this); + int state = IOSTATE_goodbit; + + TRACE("(%p %d)\n", this, val); + + if(basic_ostream_char_sentry_create(this)) { + basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base); + const num_put *numput = num_put_char_use_facet(strbuf->loc); + ostreambuf_iterator_char dest = {0, strbuf}; + + num_put_char_put_long(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), + (ios_base_flags_get(&base->base) & FMTFLAG_basefield & (FMTFLAG_oct | FMTFLAG_hex)) + ? (LONG)((unsigned short)val) : (LONG)val); + } + basic_ostream_char_sentry_destroy(this); + + basic_ios_char_setstate(base, state); + return this; } /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@G@Z */ @@ -3710,44 +3726,72 @@ basic_ostream_char* __thiscall basic_ostream_char_print_short(basic_ostream_char DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_ushort, 8) basic_ostream_char* __thiscall basic_ostream_char_print_ushort(basic_ostream_char *this, unsigned short val) { - FIXME("(%p %d) stub\n", this, val); - return NULL; + basic_ios_char *base = basic_ostream_char_get_basic_ios(this); + int state = IOSTATE_goodbit; + + TRACE("(%p %u)\n", this, val); + + if(basic_ostream_char_sentry_create(this)) { + basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base); + const num_put *numput = num_put_char_use_facet(strbuf->loc); + ostreambuf_iterator_char dest = {0, strbuf}; + + num_put_char_put_ulong(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val); + } + basic_ostream_char_sentry_destroy(this); + + basic_ios_char_setstate(base, state); + return this; } /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@H@Z */ /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@H@Z */ +/* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@J@Z */ +/* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@J@Z */ DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_int, 8) basic_ostream_char* __thiscall basic_ostream_char_print_int(basic_ostream_char *this, int val) { - FIXME("(%p %d) stub\n", this, val); - return NULL; + basic_ios_char *base = basic_ostream_char_get_basic_ios(this); + int state = IOSTATE_goodbit; + + TRACE("(%p %d)\n", this, val); + + if(basic_ostream_char_sentry_create(this)) { + basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base); + const num_put *numput = num_put_char_use_facet(strbuf->loc); + ostreambuf_iterator_char dest = {0, strbuf}; + + num_put_char_put_long(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val); + } + basic_ostream_char_sentry_destroy(this); + + basic_ios_char_setstate(base, state); + return this; } /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@I@Z */ /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@I@Z */ +/* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@K@Z */ +/* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@K@Z */ DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_uint, 8) basic_ostream_char* __thiscall basic_ostream_char_print_uint(basic_ostream_char *this, unsigned int val) { - FIXME("(%p %d) stub\n", this, val); - return NULL; -} + basic_ios_char *base = basic_ostream_char_get_basic_ios(this); + int state = IOSTATE_goodbit; -/* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@J@Z */ -/* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@J@Z */ -DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_long, 8) -basic_ostream_char* __thiscall basic_ostream_char_print_long(basic_ostream_char *this, LONG val) -{ - FIXME("(%p %d) stub\n", this, val); - return NULL; -} + TRACE("(%p %u)\n", this, val); -/* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@K@Z */ -/* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@K@Z */ -DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_ulong, 8) -basic_ostream_char* __thiscall basic_ostream_char_print_ulong(basic_ostream_char *this, ULONG val) -{ - FIXME("(%p %d) stub\n", this, val); - return NULL; + if(basic_ostream_char_sentry_create(this)) { + basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base); + const num_put *numput = num_put_char_use_facet(strbuf->loc); + ostreambuf_iterator_char dest = {0, strbuf}; + + num_put_char_put_ulong(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val); + } + basic_ostream_char_sentry_destroy(this); + + basic_ios_char_setstate(base, state); + return this; } /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@M@Z */ @@ -3755,8 +3799,22 @@ basic_ostream_char* __thiscall basic_ostream_char_print_ulong(basic_ostream_char DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_float, 8) basic_ostream_char* __thiscall basic_ostream_char_print_float(basic_ostream_char *this, float val) { - FIXME("(%p %f) stub\n", this, val); - return NULL; + basic_ios_char *base = basic_ostream_char_get_basic_ios(this); + int state = IOSTATE_goodbit; + + TRACE("(%p %f)\n", this, val); + + if(basic_ostream_char_sentry_create(this)) { + basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base); + const num_put *numput = num_put_char_use_facet(strbuf->loc); + ostreambuf_iterator_char dest = {0, strbuf}; + + num_put_char_put_double(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val); + } + basic_ostream_char_sentry_destroy(this); + + basic_ios_char_setstate(base, state); + return this; } /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@N@Z */ @@ -3764,8 +3822,45 @@ basic_ostream_char* __thiscall basic_ostream_char_print_float(basic_ostream_char DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_double, 12) basic_ostream_char* __thiscall basic_ostream_char_print_double(basic_ostream_char *this, double val) { - FIXME("(%p %lf) stub\n", this, val); - return NULL; + basic_ios_char *base = basic_ostream_char_get_basic_ios(this); + int state = IOSTATE_goodbit; + + TRACE("(%p %lf)\n", this, val); + + if(basic_ostream_char_sentry_create(this)) { + basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base); + const num_put *numput = num_put_char_use_facet(strbuf->loc); + ostreambuf_iterator_char dest = {0, strbuf}; + + num_put_char_put_double(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val); + } + basic_ostream_char_sentry_destroy(this); + + basic_ios_char_setstate(base, state); + return this; +} + +/* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@O@Z */ +/* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@O@Z */ +DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_ldouble, 12) +basic_ostream_char* __thiscall basic_ostream_char_print_ldouble(basic_ostream_char *this, double val) +{ + basic_ios_char *base = basic_ostream_char_get_basic_ios(this); + int state = IOSTATE_goodbit; + + TRACE("(%p %lf)\n", this, val); + + if(basic_ostream_char_sentry_create(this)) { + basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base); + const num_put *numput = num_put_char_use_facet(strbuf->loc); + ostreambuf_iterator_char dest = {0, strbuf}; + + num_put_char_put_ldouble(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val); + } + basic_ostream_char_sentry_destroy(this); + + basic_ios_char_setstate(base, state); + return this; } /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */ @@ -3782,8 +3877,22 @@ basic_ostream_char* __thiscall basic_ostream_char_print_streambuf(basic_ostream_ DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_ptr, 8) basic_ostream_char* __thiscall basic_ostream_char_print_ptr(basic_ostream_char *this, const void *val) { - FIXME("(%p %p) stub\n", this, val); - return NULL; + basic_ios_char *base = basic_ostream_char_get_basic_ios(this); + int state = IOSTATE_goodbit; + + TRACE("(%p %p)\n", this, val); + + if(basic_ostream_char_sentry_create(this)) { + basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base); + const num_put *numput = num_put_char_use_facet(strbuf->loc); + ostreambuf_iterator_char dest = {0, strbuf}; + + num_put_char_put_ptr(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val); + } + basic_ostream_char_sentry_destroy(this); + + basic_ios_char_setstate(base, state); + return this; } /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@_J@Z */ @@ -3791,8 +3900,22 @@ basic_ostream_char* __thiscall basic_ostream_char_print_ptr(basic_ostream_char * DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_int64, 12) basic_ostream_char* __thiscall basic_ostream_char_print_int64(basic_ostream_char *this, __int64 val) { - FIXME("(%p) stub\n", this); - return NULL; + basic_ios_char *base = basic_ostream_char_get_basic_ios(this); + int state = IOSTATE_goodbit; + + TRACE("(%p)\n", this); + + if(basic_ostream_char_sentry_create(this)) { + basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base); + const num_put *numput = num_put_char_use_facet(strbuf->loc); + ostreambuf_iterator_char dest = {0, strbuf}; + + num_put_char_put_int64(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val); + } + basic_ostream_char_sentry_destroy(this); + + basic_ios_char_setstate(base, state); + return this; } /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@_K@Z */ @@ -3800,8 +3923,22 @@ basic_ostream_char* __thiscall basic_ostream_char_print_int64(basic_ostream_char DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_uint64, 12) basic_ostream_char* __thiscall basic_ostream_char_print_uint64(basic_ostream_char *this, unsigned __int64 val) { - FIXME("(%p) stub\n", this); - return NULL; + basic_ios_char *base = basic_ostream_char_get_basic_ios(this); + int state = IOSTATE_goodbit; + + TRACE("(%p)\n", this); + + if(basic_ostream_char_sentry_create(this)) { + basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base); + const num_put *numput = num_put_char_use_facet(strbuf->loc); + ostreambuf_iterator_char dest = {0, strbuf}; + + num_put_char_put_uint64(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val); + } + basic_ostream_char_sentry_destroy(this); + + basic_ios_char_setstate(base, state); + return this; } /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@_N@Z */ @@ -3809,8 +3946,22 @@ basic_ostream_char* __thiscall basic_ostream_char_print_uint64(basic_ostream_cha DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_bool, 8) basic_ostream_char* __thiscall basic_ostream_char_print_bool(basic_ostream_char *this, MSVCP_bool val) { - FIXME("(%p %x) stub\n", this, val); - return NULL; + basic_ios_char *base = basic_ostream_char_get_basic_ios(this); + int state = IOSTATE_goodbit; + + TRACE("(%p %x)\n", this, val); + + if(basic_ostream_char_sentry_create(this)) { + basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base); + const num_put *numput = num_put_char_use_facet(strbuf->loc); + ostreambuf_iterator_char dest = {0, strbuf}; + + num_put_char_put_bool(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val); + } + basic_ostream_char_sentry_destroy(this); + + basic_ios_char_setstate(base, state); + return this; } /* ?endl@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@1@AAV21@@Z */ diff --git a/dlls/msvcp90/locale.c b/dlls/msvcp90/locale.c index 88f02e397bf..cf7da777ef6 100644 --- a/dlls/msvcp90/locale.c +++ b/dlls/msvcp90/locale.c @@ -5403,6 +5403,32 @@ unsigned int __cdecl num_put_char__Getcat(const locale_facet **facet, const loca return LC_NUMERIC; } +num_put* num_put_char_use_facet(const locale *loc) +{ + static num_put *obj = NULL; + + _Lockit lock; + const locale_facet *fac; + + _Lockit_ctor_locktype(&lock, _LOCK_LOCALE); + fac = locale__Getfacet(loc, num_put_char_id.id); + if(fac) { + _Lockit_dtor(&lock); + return (num_put*)fac; + } + + if(obj) + return obj; + + num_put_char__Getcat(&fac, loc); + obj = (num_put*)fac; + locale_facet__Incref(&obj->facet); + locale_facet_register(&obj->facet); + _Lockit_dtor(&lock); + + return obj; +} + /* ?_Put@?$num_put@DV?$ostreambuf_iterator@DU?$char_traits@D@std@@@std@@@std@@ABA?AV?$ostreambuf_iterator@DU?$char_traits@D@std@@@2@V32@PBDI@Z */ /* ?_Put@?$num_put@DV?$ostreambuf_iterator@DU?$char_traits@D@std@@@std@@@std@@AEBA?AV?$ostreambuf_iterator@DU?$char_traits@D@std@@@2@V32@PEBD_K@Z */ ostreambuf_iterator_char* __cdecl num_put_char__Put(const num_put *this, ostreambuf_iterator_char *ret, diff --git a/dlls/msvcp90/msvcp90.h b/dlls/msvcp90/msvcp90.h index cc7a2aa073e..ba6b2c2dde8 100644 --- a/dlls/msvcp90/msvcp90.h +++ b/dlls/msvcp90/msvcp90.h @@ -573,5 +573,23 @@ typedef struct { _Cvtvec cvt; } num_put; +num_put* num_put_char_use_facet(const locale*); +ostreambuf_iterator_char* __thiscall num_put_char_put_long(const num_put*, ostreambuf_iterator_char*, + ostreambuf_iterator_char, ios_base*, char, LONG); +ostreambuf_iterator_char* __thiscall num_put_char_put_ulong(const num_put*, ostreambuf_iterator_char*, + ostreambuf_iterator_char, ios_base*, char, ULONG); +ostreambuf_iterator_char* __thiscall num_put_char_put_double(const num_put*, ostreambuf_iterator_char*, + ostreambuf_iterator_char, ios_base*, char, double); +ostreambuf_iterator_char* __thiscall num_put_char_put_ldouble(const num_put*, ostreambuf_iterator_char*, + ostreambuf_iterator_char, ios_base*, char, double); +ostreambuf_iterator_char* __thiscall num_put_char_put_ptr(const num_put*, ostreambuf_iterator_char*, + ostreambuf_iterator_char, ios_base*, char, const void*); +ostreambuf_iterator_char* __thiscall num_put_char_put_int64(const num_put*, ostreambuf_iterator_char*, + ostreambuf_iterator_char, ios_base*, char, __int64); +ostreambuf_iterator_char* __thiscall num_put_char_put_uint64(const num_put*, ostreambuf_iterator_char*, + ostreambuf_iterator_char, ios_base*, char, unsigned __int64); +ostreambuf_iterator_char* __thiscall num_put_char_put_bool(const num_put*, ostreambuf_iterator_char*, + ostreambuf_iterator_char, ios_base*, char, MSVCP_bool); + void init_io(void); void free_io(void); diff --git a/dlls/msvcp90/msvcp90.spec b/dlls/msvcp90/msvcp90.spec index be5457ab1b3..c41f781b786 100644 --- a/dlls/msvcp90/msvcp90.spec +++ b/dlls/msvcp90/msvcp90.spec @@ -1582,16 +1582,16 @@ @ cdecl -arch=win64 ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@H@Z(ptr long) basic_ostream_char_print_int @ thiscall -arch=win32 ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@I@Z(ptr long) basic_ostream_char_print_uint @ cdecl -arch=win64 ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@I@Z(ptr long) basic_ostream_char_print_uint -@ thiscall -arch=win32 ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@J@Z(ptr long) basic_ostream_char_print_long -@ cdecl -arch=win64 ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@J@Z(ptr long) basic_ostream_char_print_long -@ thiscall -arch=win32 ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@K@Z(ptr long) basic_ostream_char_print_ulong -@ cdecl -arch=win64 ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@K@Z(ptr long) basic_ostream_char_print_ulong +@ thiscall -arch=win32 ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@J@Z(ptr long) basic_ostream_char_print_int +@ cdecl -arch=win64 ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@J@Z(ptr long) basic_ostream_char_print_int +@ thiscall -arch=win32 ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@K@Z(ptr long) basic_ostream_char_print_uint +@ cdecl -arch=win64 ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@K@Z(ptr long) basic_ostream_char_print_uint @ thiscall -arch=win32 ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@M@Z(ptr float) basic_ostream_char_print_float @ cdecl -arch=win64 ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@M@Z(ptr float) basic_ostream_char_print_float @ thiscall -arch=win32 ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@N@Z(ptr double) basic_ostream_char_print_double @ cdecl -arch=win64 ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@N@Z(ptr double) basic_ostream_char_print_double -@ stub -arch=win32 ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@O@Z -@ stub -arch=win64 ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@O@Z +@ thiscall -arch=win32 ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@O@Z(ptr double) basic_ostream_char_print_ldouble +@ cdecl -arch=win64 ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@O@Z(ptr double)basic_ostream_char_print_ldouble @ thiscall -arch=win32 ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z(ptr ptr) basic_ostream_char_print_func @ cdecl -arch=win64 ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z(ptr ptr) basic_ostream_char_print_func @ thiscall -arch=win32 ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAV?$basic_ios@DU?$char_traits@D@std@@@1@AAV21@@Z@Z(ptr ptr) basic_ostream_char_print_func_basic_ios -- 2.11.4.GIT