Module: wine Branch: master Commit: 6c57f13a6b16ee220cb02087c7527d9edba607c3 URL: http://source.winehq.org/git/wine.git/?a=commit;h=6c57f13a6b16ee220cb02087c7...
Author: Piotr Caban piotr@codeweavers.com Date: Thu Aug 19 12:17:11 2010 +0200
msvcp90: Added basic_string<char> constructor (with no arguments) implementation.
---
dlls/msvcp90/msvcp90.h | 15 +++++++++++++ dlls/msvcp90/msvcp90.spec | 4 +- dlls/msvcp90/string.c | 49 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+), 2 deletions(-)
diff --git a/dlls/msvcp90/msvcp90.h b/dlls/msvcp90/msvcp90.h index 8d588ef..89d549b 100644 --- a/dlls/msvcp90/msvcp90.h +++ b/dlls/msvcp90/msvcp90.h @@ -109,3 +109,18 @@ typedef struct _rtti_object_locator const type_info *type_descriptor; const rtti_object_hierarchy *type_hierarchy; } rtti_object_locator; + +/* basic_string<char, char_traits<char>, allocator<char>> */ +#define BUF_SIZE_CHAR 16 +typedef struct _basic_string_char +{ + void *allocator; + union _data { + char buf[BUF_SIZE_CHAR]; + char *ptr; + } data; + size_t size; + size_t res; +} basic_string_char; + +void __stdcall MSVCP_allocator_char_deallocate(void*, char*, size_t); diff --git a/dlls/msvcp90/msvcp90.spec b/dlls/msvcp90/msvcp90.spec index 0542b63..2d6b312 100644 --- a/dlls/msvcp90/msvcp90.spec +++ b/dlls/msvcp90/msvcp90.spec @@ -753,10 +753,10 @@ @ stub -arch=win32 ??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@PBDI@Z @ stub -arch=win64 ??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@V?$_String_const_iterator@DU?$char_traits@D@std@@V?$allocator@D@2@@1@0@Z @ stub -arch=win32 ??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@PBDIABV?$allocator@D@1@@Z -@ stub -arch=win64 ??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@XZ +@ cdecl -arch=win64 ??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@XZ(ptr) MSVCP_basic_string_char_ctor @ stub -arch=win32 ??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@V?$_String_const_iterator@DU?$char_traits@D@std@@V?$allocator@D@2@@1@0@Z @ stub -arch=win64 ??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@_KD@Z -@ stub -arch=win32 ??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ +@ cdecl -arch=win32 -i386 -norelay ??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ() __thiscall_MSVCP_basic_string_char_ctor @ stub -arch=win64 ??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@_KDAEBV?$allocator@D@1@@Z @ stub -arch=win32 ??0?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAE@ABV01@@Z @ stub -arch=win64 ??0?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAA@AEBV01@@Z diff --git a/dlls/msvcp90/string.c b/dlls/msvcp90/string.c index 8b7c320..ddf8f88 100644 --- a/dlls/msvcp90/string.c +++ b/dlls/msvcp90/string.c @@ -16,6 +16,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
+#include "config.h" + #include <stdarg.h>
#include "msvcp90.h" @@ -462,3 +464,50 @@ unsigned short CDECL MSVCP_char_traits_short_not_eof(const unsigned short *in) { return (*in==(unsigned short)-1 ? 0 : *in); } + + +/* basic_string<char, char_traits<char>, allocator<char>> */ +/* Internal: basic_string_char_ptr - return pointer to stored string */ +static char* basic_string_char_ptr(basic_string_char *this) +{ + if(this->res == BUF_SIZE_CHAR-1) + return this->data.buf; + return this->data.ptr; +} + +/* Internal: basic_string_char_eos - sets string length, puts '\0' on the end */ +static void basic_string_char_eos(basic_string_char *this, size_t len) +{ + static const char nullbyte = '\0'; + + this->size = len; + MSVCP_char_traits_char_assign(basic_string_char_ptr(this)+len, &nullbyte); +} + +/* Internal: basic_string_char_tidy - initialize basic_string buffer, deallocates data */ +/* Caution: new_size have to be smaller than BUF_SIZE_CHAR */ +static void basic_string_char_tidy(basic_string_char *this, + MSVCP_BOOL built, int new_size) +{ + if(built && BUF_SIZE_CHAR<=this->res) { + char *ptr = this->data.ptr; + + if(new_size > 0) + MSVCP_char_traits_char__Copy_s(this->data.buf, BUF_SIZE_CHAR, ptr, new_size); + MSVCP_allocator_char_deallocate(this->allocator, ptr, this->res+1); + } + + this->res = BUF_SIZE_CHAR-1; + basic_string_char_eos(this, new_size); +} + +/* ??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ */ +/* ??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@XZ */ +DEFINE_THISCALL_WRAPPER(MSVCP_basic_string_char_ctor, 4) +basic_string_char* __stdcall MSVCP_basic_string_char_ctor(basic_string_char *this) +{ + TRACE("%p\n", this); + + basic_string_char_tidy(this, FALSE, 0); + return this; +}