winehq.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
March
February
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
January
2003
December
November
October
September
August
July
June
May
April
March
February
January
2002
December
November
October
September
August
July
June
May
April
March
February
January
2001
December
November
October
September
August
July
June
May
April
March
February
List overview
wine-commits
September 2009
----- 2025 -----
March 2025
February 2025
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
January 2004
----- 2003 -----
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003
----- 2002 -----
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
February 2002
January 2002
----- 2001 -----
December 2001
November 2001
October 2001
September 2001
August 2001
July 2001
June 2001
May 2001
April 2001
March 2001
February 2001
wine-commits@winehq.org
3 participants
866 discussions
Start a n
N
ew thread
Vincent Povirk : oleaut32: Use WIC to decode JPEG images.
by Alexandre Julliard
01 Sep '09
01 Sep '09
Module: wine Branch: master Commit: 0ac2a855ce4e7cb83201fbe598eefb8ee8a57fa5 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=0ac2a855ce4e7cb83201fbe59…
Author: Vincent Povirk <vincent(a)codeweavers.com> Date: Mon Aug 31 17:06:53 2009 -0500 oleaut32: Use WIC to decode JPEG images. --- dlls/oleaut32/olepicture.c | 178 +------------------------------------------- 1 files changed, 1 insertions(+), 177 deletions(-) diff --git a/dlls/oleaut32/olepicture.c b/dlls/oleaut32/olepicture.c index b4def3a..f3e7789 100644 --- a/dlls/oleaut32/olepicture.c +++ b/dlls/oleaut32/olepicture.c @@ -46,21 +46,6 @@ #include <stdio.h> #include <string.h> -#ifdef SONAME_LIBJPEG -/* This is a hack, so jpeglib.h does not redefine INT32 and the like*/ -#define XMD_H -#define UINT8 JPEG_UINT8 -#define UINT16 JPEG_UINT16 -#define boolean jpeg_boolean -#undef HAVE_STDLIB_H -# include <jpeglib.h> -#undef HAVE_STDLIB_H -#define HAVE_STDLIB_H 1 -#undef UINT8 -#undef UINT16 -#undef boolean -#endif - #ifdef HAVE_PNG_H #include <png.h> #endif @@ -1002,167 +987,6 @@ static HRESULT WINAPI OLEPictureImpl_IsDirty( return E_NOTIMPL; } -#ifdef SONAME_LIBJPEG - -static void *libjpeg_handle; -#define MAKE_FUNCPTR(f) static typeof(f) * p##f -MAKE_FUNCPTR(jpeg_std_error); -MAKE_FUNCPTR(jpeg_CreateDecompress); -MAKE_FUNCPTR(jpeg_read_header); -MAKE_FUNCPTR(jpeg_start_decompress); -MAKE_FUNCPTR(jpeg_read_scanlines); -MAKE_FUNCPTR(jpeg_finish_decompress); -MAKE_FUNCPTR(jpeg_destroy_decompress); -#undef MAKE_FUNCPTR - -static void *load_libjpeg(void) -{ - if((libjpeg_handle = wine_dlopen(SONAME_LIBJPEG, RTLD_NOW, NULL, 0)) != NULL) { - -#define LOAD_FUNCPTR(f) \ - if((p##f = wine_dlsym(libjpeg_handle, #f, NULL, 0)) == NULL) { \ - libjpeg_handle = NULL; \ - return NULL; \ - } - - LOAD_FUNCPTR(jpeg_std_error); - LOAD_FUNCPTR(jpeg_CreateDecompress); - LOAD_FUNCPTR(jpeg_read_header); - LOAD_FUNCPTR(jpeg_start_decompress); - LOAD_FUNCPTR(jpeg_read_scanlines); - LOAD_FUNCPTR(jpeg_finish_decompress); - LOAD_FUNCPTR(jpeg_destroy_decompress); -#undef LOAD_FUNCPTR - } - return libjpeg_handle; -} - -/* for the jpeg decompressor source manager. */ -static void _jpeg_init_source(j_decompress_ptr cinfo) { } - -static jpeg_boolean _jpeg_fill_input_buffer(j_decompress_ptr cinfo) { - ERR("(), should not get here.\n"); - return FALSE; -} - -static void _jpeg_skip_input_data(j_decompress_ptr cinfo,long num_bytes) { - TRACE("Skipping %ld bytes...\n", num_bytes); - cinfo->src->next_input_byte += num_bytes; - cinfo->src->bytes_in_buffer -= num_bytes; -} - -static jpeg_boolean _jpeg_resync_to_restart(j_decompress_ptr cinfo, int desired) { - ERR("(desired=%d), should not get here.\n",desired); - return FALSE; -} -static void _jpeg_term_source(j_decompress_ptr cinfo) { } -#endif /* SONAME_LIBJPEG */ - -static HRESULT OLEPictureImpl_LoadJpeg(OLEPictureImpl *This, BYTE *xbuf, ULONG xread) -{ -#ifdef SONAME_LIBJPEG - struct jpeg_decompress_struct jd; - struct jpeg_error_mgr jerr; - int ret; - JDIMENSION x; - JSAMPROW samprow,oldsamprow; - BITMAPINFOHEADER bmi; - LPBYTE bits; - HDC hdcref; - struct jpeg_source_mgr xjsm; - LPBYTE oldbits; - unsigned int i; - - if(!libjpeg_handle) { - if(!load_libjpeg()) { - ERR("Failed reading JPEG because unable to find %s\n", SONAME_LIBJPEG); - return E_FAIL; - } - } - - /* This is basically so we can use in-memory data for jpeg decompression. - * We need to have all the functions. - */ - xjsm.next_input_byte = xbuf; - xjsm.bytes_in_buffer = xread; - xjsm.init_source = _jpeg_init_source; - xjsm.fill_input_buffer = _jpeg_fill_input_buffer; - xjsm.skip_input_data = _jpeg_skip_input_data; - xjsm.resync_to_restart = _jpeg_resync_to_restart; - xjsm.term_source = _jpeg_term_source; - - jd.err = pjpeg_std_error(&jerr); - /* jpeg_create_decompress is a macro that expands to jpeg_CreateDecompress - see jpeglib.h - * jpeg_create_decompress(&jd); */ - pjpeg_CreateDecompress(&jd, JPEG_LIB_VERSION, sizeof(struct jpeg_decompress_struct)); - jd.src = &xjsm; - ret=pjpeg_read_header(&jd,TRUE); - jd.out_color_space = JCS_RGB; - pjpeg_start_decompress(&jd); - if (ret != JPEG_HEADER_OK) { - ERR("Jpeg image in stream has bad format, read header returned %d.\n",ret); - HeapFree(GetProcessHeap(),0,xbuf); - return E_FAIL; - } - - bits = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY, - (jd.output_height+1) * ((jd.output_width*jd.output_components + 3) & ~3) ); - samprow=HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,jd.output_width*jd.output_components); - - oldbits = bits; - oldsamprow = samprow; - while ( jd.output_scanline<jd.output_height ) { - x = pjpeg_read_scanlines(&jd,&samprow,1); - if (x != 1) { - ERR("failed to read current scanline?\n"); - break; - } - /* We have to convert from RGB to BGR, see MSDN/ BITMAPINFOHEADER */ - for(i=0;i<jd.output_width;i++,samprow+=jd.output_components) { - *(bits++) = *(samprow+2); - *(bits++) = *(samprow+1); - *(bits++) = *(samprow); - } - bits = (LPBYTE)(((UINT_PTR)bits + 3) & ~3); - samprow = oldsamprow; - } - bits = oldbits; - - bmi.biSize = sizeof(bmi); - bmi.biWidth = jd.output_width; - bmi.biHeight = -jd.output_height; - bmi.biPlanes = 1; - bmi.biBitCount = jd.output_components<<3; - bmi.biCompression = BI_RGB; - bmi.biSizeImage = jd.output_height*jd.output_width*jd.output_components; - bmi.biXPelsPerMeter = 0; - bmi.biYPelsPerMeter = 0; - bmi.biClrUsed = 0; - bmi.biClrImportant = 0; - - HeapFree(GetProcessHeap(),0,samprow); - pjpeg_finish_decompress(&jd); - pjpeg_destroy_decompress(&jd); - hdcref = GetDC(0); - This->desc.u.bmp.hbitmap=CreateDIBitmap( - hdcref, - &bmi, - CBM_INIT, - bits, - (BITMAPINFO*)&bmi, - DIB_RGB_COLORS - ); - ReleaseDC(0, hdcref); - This->desc.picType = PICTYPE_BITMAP; - OLEPictureImpl_SetBitmap(This); - HeapFree(GetProcessHeap(),0,bits); - return S_OK; -#else - ERR("Trying to load JPEG picture, but JPEG supported not compiled in.\n"); - return E_FAIL; -#endif -} - static HRESULT OLEPictureImpl_LoadDIB(OLEPictureImpl *This, BYTE *xbuf, ULONG xread) { BITMAPFILEHEADER *bfh = (BITMAPFILEHEADER*)xbuf; @@ -1891,7 +1715,7 @@ static HRESULT WINAPI OLEPictureImpl_Load(IPersistStream* iface,IStream*pStm) { hr = OLEPictureImpl_LoadWICDecoder(This, &CLSID_WICGifDecoder, xbuf, xread); break; case BITMAP_FORMAT_JPEG: /* JPEG */ - hr = OLEPictureImpl_LoadJpeg(This, xbuf, xread); + hr = OLEPictureImpl_LoadWICDecoder(This, &CLSID_WICJpegDecoder, xbuf, xread); break; case BITMAP_FORMAT_BMP: /* Bitmap */ hr = OLEPictureImpl_LoadDIB(This, xbuf, xread);
1
0
0
0
Vincent Povirk : gdiplus: Use WIC to decode ICO files.
by Alexandre Julliard
01 Sep '09
01 Sep '09
Module: wine Branch: master Commit: 9d149e606b153c72df6945596c003d4ec453026a URL:
http://source.winehq.org/git/wine.git/?a=commit;h=9d149e606b153c72df6945596…
Author: Vincent Povirk <vincent(a)codeweavers.com> Date: Mon Aug 31 16:56:47 2009 -0500 gdiplus: Use WIC to decode ICO files. --- dlls/gdiplus/Makefile.in | 1 + dlls/gdiplus/image.c | 134 ++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 119 insertions(+), 16 deletions(-) diff --git a/dlls/gdiplus/Makefile.in b/dlls/gdiplus/Makefile.in index de88d5e..87f8b6a 100644 --- a/dlls/gdiplus/Makefile.in +++ b/dlls/gdiplus/Makefile.in @@ -5,6 +5,7 @@ VPATH = @srcdir@ MODULE = gdiplus.dll IMPORTLIB = gdiplus IMPORTS = uuid shlwapi oleaut32 ole32 user32 gdi32 kernel32 +DELAYIMPORTS = windowscodecs C_SRCS = \ brush.c \ diff --git a/dlls/gdiplus/image.c b/dlls/gdiplus/image.c index 730d981..6c48663 100644 --- a/dlls/gdiplus/image.c +++ b/dlls/gdiplus/image.c @@ -31,6 +31,7 @@ #include "ole2.h" #include "initguid.h" +#include "wincodec.h" #include "gdiplus.h" #include "gdiplus_private.h" #include "wine/debug.h" @@ -1381,28 +1382,129 @@ GpStatus WINGDIPAPI GdipLoadImageFromFileICM(GDIPCONST WCHAR* filename,GpImage * return GdipLoadImageFromFile(filename, image); } -static GpStatus decode_image_olepicture_icon(IStream* stream, REFCLSID clsid, GpImage **image) +static const WICPixelFormatGUID *wic_pixel_formats[] = { + &GUID_WICPixelFormat16bppBGR555, + &GUID_WICPixelFormat24bppBGR, + &GUID_WICPixelFormat32bppBGR, + &GUID_WICPixelFormat32bppBGRA, + &GUID_WICPixelFormat32bppPBGRA, + NULL +}; + +static const PixelFormat wic_gdip_formats[] = { + PixelFormat16bppRGB555, + PixelFormat24bppRGB, + PixelFormat32bppRGB, + PixelFormat32bppARGB, + PixelFormat32bppPARGB, +}; + +static GpStatus decode_image_wic(IStream* stream, REFCLSID clsid, GpImage **image) { - IPicture *pic; + GpStatus status=Ok; + GpBitmap *bitmap; + HRESULT hr; + IWICBitmapDecoder *decoder; + IWICBitmapFrameDecode *frame; + IWICBitmapSource *source=NULL; + WICPixelFormatGUID wic_format; + PixelFormat gdip_format=0; + int i; + UINT width, height; + BitmapData lockeddata; + WICRect wrc; + HRESULT initresult; - TRACE("%p %p\n", stream, image); + initresult = CoInitialize(NULL); - if(!stream || !image) - return InvalidParameter; + hr = CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER, + &IID_IWICBitmapDecoder, (void**)&decoder); + if (FAILED(hr)) goto end; - if(OleLoadPicture(stream, 0, FALSE, &IID_IPicture, - (LPVOID*) &pic) != S_OK){ - TRACE("Could not load picture\n"); - return GenericError; + hr = IWICBitmapDecoder_Initialize(decoder, (IStream*)stream, WICDecodeMetadataCacheOnLoad); + if (SUCCEEDED(hr)) + hr = IWICBitmapDecoder_GetFrame(decoder, 0, &frame); + + if (SUCCEEDED(hr)) /* got frame */ + { + hr = IWICBitmapFrameDecode_GetPixelFormat(frame, &wic_format); + + if (SUCCEEDED(hr)) + { + for (i=0; wic_pixel_formats[i]; i++) + { + if (IsEqualGUID(&wic_format, wic_pixel_formats[i])) + { + source = (IWICBitmapSource*)frame; + IWICBitmapSource_AddRef(source); + gdip_format = wic_gdip_formats[i]; + break; + } + } + if (!source) + { + /* unknown format; fall back on 32bppARGB */ + hr = WICConvertBitmapSource(&GUID_WICPixelFormat32bppBGRA, (IWICBitmapSource*)frame, &source); + gdip_format = PixelFormat32bppARGB; + } + } + + if (SUCCEEDED(hr)) /* got source */ + { + hr = IWICBitmapSource_GetSize(source, &width, &height); + + if (SUCCEEDED(hr)) + status = GdipCreateBitmapFromScan0(width, height, 0, gdip_format, + NULL, &bitmap); + + if (SUCCEEDED(hr) && status == Ok) /* created bitmap */ + { + status = GdipBitmapLockBits(bitmap, NULL, ImageLockModeWrite, + gdip_format, &lockeddata); + if (status == Ok) /* locked bitmap */ + { + wrc.X = 0; + wrc.Width = width; + wrc.Height = 1; + for (i=0; i<height; i++) + { + wrc.Y = i; + hr = IWICBitmapSource_CopyPixels(source, &wrc, abs(lockeddata.Stride), + abs(lockeddata.Stride), (BYTE*)lockeddata.Scan0+lockeddata.Stride*i); + if (FAILED(hr)) break; + } + + GdipBitmapUnlockBits(bitmap, &lockeddata); + } + + if (SUCCEEDED(hr) && status == Ok) + *image = (GpImage*)bitmap; + else + { + *image = NULL; + GdipDisposeImage((GpImage*)bitmap); + } + } + + IWICBitmapSource_Release(source); + } + + IWICBitmapFrameDecode_Release(frame); } - *image = GdipAlloc(sizeof(GpImage)); - if(!*image) return OutOfMemory; - (*image)->type = ImageTypeUnknown; - (*image)->picture = pic; - (*image)->flags = ImageFlagsNone; + IWICBitmapDecoder_Release(decoder); - return Ok; +end: + if (SUCCEEDED(initresult)) CoUninitialize(); + + if (FAILED(hr) && status == Ok) status = hresult_to_status(hr); + + return status; +} + +static GpStatus decode_image_icon(IStream* stream, REFCLSID clsid, GpImage **image) +{ + return decode_image_wic(stream, &CLSID_WICIcoDecoder, image); } static GpStatus decode_image_olepicture_bitmap(IStream* stream, REFCLSID clsid, GpImage **image) @@ -2012,7 +2114,7 @@ static const struct image_codec codecs[NUM_CODECS] = { /* SigMask */ ico_sig_mask, }, NULL, - decode_image_olepicture_icon + decode_image_icon }, };
1
0
0
0
Aric Stewart : msctf: Correct handling if NULL for pdimFocus in ITfThreadMgr::SetFocus.
by Alexandre Julliard
01 Sep '09
01 Sep '09
Module: wine Branch: master Commit: ae51d05d780ae118001e01ab270d0c49ce98a8f1 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=ae51d05d780ae118001e01ab2…
Author: Aric Stewart <aric(a)codeweavers.com> Date: Mon Aug 31 14:48:40 2009 -0500 msctf: Correct handling if NULL for pdimFocus in ITfThreadMgr::SetFocus. --- dlls/msctf/threadmgr.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/dlls/msctf/threadmgr.c b/dlls/msctf/threadmgr.c index 9fb1b5d..4b21b56 100644 --- a/dlls/msctf/threadmgr.c +++ b/dlls/msctf/threadmgr.c @@ -389,7 +389,9 @@ static HRESULT WINAPI ThreadMgr_SetFocus( ITfThreadMgr* iface, ITfDocumentMgr *p TRACE("(%p) %p\n",This,pdimFocus); - if (!pdimFocus || FAILED(IUnknown_QueryInterface(pdimFocus,&IID_ITfDocumentMgr,(LPVOID*) &check))) + if (!pdimFocus) + check = NULL; + else if (FAILED(IUnknown_QueryInterface(pdimFocus,&IID_ITfDocumentMgr,(LPVOID*) &check))) return E_INVALIDARG; ITfThreadMgrEventSink_OnSetFocus((ITfThreadMgrEventSink*)&This->ThreadMgrEventSinkVtbl, check, This->focus);
1
0
0
0
Eric Pouech : msvcrt: Correctly handle the error cases in strtol and strtoul.
by Alexandre Julliard
01 Sep '09
01 Sep '09
Module: wine Branch: master Commit: 9eca2f81dc92f6e28ebe757262eb5b603166f3a2 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=9eca2f81dc92f6e28ebe75726…
Author: Eric Pouech <eric.pouech(a)orange.fr> Date: Mon Aug 31 21:36:45 2009 +0200 msvcrt: Correctly handle the error cases in strtol and strtoul. --- dlls/msvcrt/msvcrt.h | 3 ++ dlls/msvcrt/msvcrt.spec | 4 +- dlls/msvcrt/string.c | 64 ++++++++++++++++++++++++++++++++++++++++++++ dlls/msvcrt/tests/string.c | 40 +++++++++++++++++++++++++++ 4 files changed, 109 insertions(+), 2 deletions(-) diff --git a/dlls/msvcrt/msvcrt.h b/dlls/msvcrt/msvcrt.h index 7edcd6d..502703c 100644 --- a/dlls/msvcrt/msvcrt.h +++ b/dlls/msvcrt/msvcrt.h @@ -41,6 +41,9 @@ #include "windef.h" #include "winbase.h" +#define MSVCRT_LONG_MAX 0x7fffffffL +#define MSVCRT_ULONG_MAX 0xffffffffUL + typedef unsigned short MSVCRT_wchar_t; typedef unsigned short MSVCRT_wint_t; typedef unsigned short MSVCRT_wctype_t; diff --git a/dlls/msvcrt/msvcrt.spec b/dlls/msvcrt/msvcrt.spec index fd03647..5c475a0 100644 --- a/dlls/msvcrt/msvcrt.spec +++ b/dlls/msvcrt/msvcrt.spec @@ -767,8 +767,8 @@ @ cdecl strstr(str str) ntdll.strstr @ cdecl strtod(str ptr) MSVCRT_strtod @ cdecl strtok(str str) MSVCRT_strtok -@ cdecl strtol(str ptr long) ntdll.strtol -@ cdecl strtoul(str ptr long) ntdll.strtoul +@ cdecl strtol(str ptr long) MSVCRT_strtol +@ cdecl strtoul(str ptr long) MSVCRT_strtoul @ cdecl strxfrm(ptr str long) MSVCRT_strxfrm @ varargs swprintf(ptr wstr) MSVCRT_swprintf @ varargs swscanf(wstr wstr) MSVCRT_swscanf diff --git a/dlls/msvcrt/string.c b/dlls/msvcrt/string.c index 74beefb..aacf114 100644 --- a/dlls/msvcrt/string.c +++ b/dlls/msvcrt/string.c @@ -25,6 +25,7 @@ #include "config.h" #include <stdlib.h> +#include <errno.h> #include "msvcrt.h" #include "wine/debug.h" @@ -250,3 +251,66 @@ int CDECL __STRINGTOLD( MSVCRT__LDOUBLE *value, char **endptr, const char *str, #endif return 0; } + +/****************************************************************** + * strtol (MSVCRT.@) + */ +long int MSVCRT_strtol(const char* nptr, char** end, int base) +{ + /* wrapper to forward libc error code to msvcrt's error codes */ + long ret; + + errno = 0; + ret = strtol(nptr, end, base); + switch (errno) + { + case ERANGE: *MSVCRT__errno() = MSVCRT_ERANGE; break; + case EINVAL: *MSVCRT__errno() = MSVCRT_EINVAL; break; + default: + /* cope with the fact that we may use 64bit long integers on libc + * while msvcrt always uses 32bit long integers + */ + if (ret > MSVCRT_LONG_MAX) + { + ret = MSVCRT_LONG_MAX; + *MSVCRT__errno() = MSVCRT_ERANGE; + } + else if (ret < -MSVCRT_LONG_MAX - 1) + { + ret = -MSVCRT_LONG_MAX - 1; + *MSVCRT__errno() = MSVCRT_ERANGE; + } + break; + } + + return ret; +} + +/****************************************************************** + * strtoul (MSVCRT.@) + */ +unsigned long int MSVCRT_strtoul(const char* nptr, char** end, int base) +{ + /* wrapper to forward libc error code to msvcrt's error codes */ + unsigned long ret; + + errno = 0; + ret = strtoul(nptr, end, base); + switch (errno) + { + case ERANGE: *MSVCRT__errno() = MSVCRT_ERANGE; break; + case EINVAL: *MSVCRT__errno() = MSVCRT_EINVAL; break; + default: + /* cope with the fact that we may use 64bit long integers on libc + * while msvcrt always uses 32bit long integers + */ + if (ret > MSVCRT_ULONG_MAX) + { + ret = MSVCRT_ULONG_MAX; + *MSVCRT__errno() = MSVCRT_ERANGE; + } + break; + } + + return ret; +} diff --git a/dlls/msvcrt/tests/string.c b/dlls/msvcrt/tests/string.c index 96bcb7f..0999241 100644 --- a/dlls/msvcrt/tests/string.c +++ b/dlls/msvcrt/tests/string.c @@ -663,6 +663,45 @@ static void test_strtok(void) } } +static void test_strtol(void) +{ + char* e; + long l; + unsigned long ul; + + /* errno is only set in case of error, so reset errno to EBADF to check for errno modification */ + errno = EBADF; + l = strtol("-1234", &e, 0); + ok(l==-1234, "wrong value %ld\n", l); + ok(errno == EBADF, "wrong errno %d\n", errno); + errno = EBADF; + ul = strtoul("1234", &e, 0); + ok(ul==1234, "wrong value %lu\n", ul); + ok(errno == EBADF, "wrong errno %d\n", errno); + + errno = EBADF; + l = strtol("2147483647L", &e, 0); + ok(l==2147483647, "wrong value %ld\n", l); + ok(errno == EBADF, "wrong errno %d\n", errno); + errno = EBADF; + l = strtol("-2147483648L", &e, 0); + ok(l==-2147483647L - 1, "wrong value %ld\n", l); + ok(errno == EBADF, "wrong errno %d\n", errno); + errno = EBADF; + ul = strtoul("4294967295UL", &e, 0); + ok(ul==4294967295ul, "wrong value %lu\n", ul); + ok(errno == EBADF, "wrong errno %d\n", errno); + + errno = 0; + l = strtol("9223372036854775807L", &e, 0); + ok(l==2147483647, "wrong value %ld\n", l); + ok(errno == ERANGE, "wrong errno %d\n", errno); + errno = 0; + ul = strtoul("9223372036854775807L", &e, 0); + ok(ul==4294967295ul, "wrong value %lu\n", ul); + ok(errno == ERANGE, "wrong errno %d\n", errno); +} + START_TEST(string) { char mem[100]; @@ -706,4 +745,5 @@ START_TEST(string) test_mbcjisjms(); test_strtok(); test_wcscpy_s(); + test_strtol(); }
1
0
0
0
Jacek Caban : mshtml: Properly release DispatchEx data.
by Alexandre Julliard
01 Sep '09
01 Sep '09
Module: wine Branch: master Commit: b42243e8e7d83ca0b6084ba8ab6c4303626588b0 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=b42243e8e7d83ca0b6084ba8a…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Mon Aug 31 20:47:55 2009 +0200 mshtml: Properly release DispatchEx data. --- dlls/mshtml/dispex.c | 31 +++++++++++++++++++++++++++++++ dlls/mshtml/htmlcurstyle.c | 1 + dlls/mshtml/htmldoc.c | 1 + dlls/mshtml/htmlelemcol.c | 1 + dlls/mshtml/htmlevent.c | 4 +++- dlls/mshtml/htmllocation.c | 1 + dlls/mshtml/htmlnode.c | 1 + dlls/mshtml/htmlstyle.c | 1 + dlls/mshtml/htmlwindow.c | 1 + dlls/mshtml/mshtml_private.h | 1 + dlls/mshtml/omnavigator.c | 4 +++- 11 files changed, 45 insertions(+), 2 deletions(-) diff --git a/dlls/mshtml/dispex.c b/dlls/mshtml/dispex.c index b4cfe3f..b8937e7 100644 --- a/dlls/mshtml/dispex.c +++ b/dlls/mshtml/dispex.c @@ -946,9 +946,40 @@ BOOL dispex_query_interface(DispatchEx *This, REFIID riid, void **ppv) return TRUE; } +void release_dispex(DispatchEx *This) +{ + dynamic_prop_t *prop; + + if(!This->dynamic_data) + return; + + for(prop = This->dynamic_data->props; prop < This->dynamic_data->props + This->dynamic_data->prop_cnt; prop++) { + VariantClear(&prop->var); + heap_free(prop->name); + } + + heap_free(This->dynamic_data->props); + + if(This->dynamic_data->func_disps) { + unsigned i; + + for(i=0; i < This->data->data->func_disp_cnt; i++) { + if(This->dynamic_data->func_disps[i]) { + release_dispex(&This->dynamic_data->func_disps[i]->dispex); + heap_free(This->dynamic_data->func_disps[i]); + } + } + + heap_free(This->dynamic_data->func_disps); + } + + heap_free(This->dynamic_data); +} + void init_dispex(DispatchEx *dispex, IUnknown *outer, dispex_static_data_t *data) { dispex->lpIDispatchExVtbl = &DispatchExVtbl; dispex->outer = outer; dispex->data = data; + dispex->dynamic_data = NULL; } diff --git a/dlls/mshtml/htmlcurstyle.c b/dlls/mshtml/htmlcurstyle.c index a93bdb0..d622239 100644 --- a/dlls/mshtml/htmlcurstyle.c +++ b/dlls/mshtml/htmlcurstyle.c @@ -90,6 +90,7 @@ static ULONG WINAPI HTMLCurrentStyle_Release(IHTMLCurrentStyle *iface) if(!ref) { if(This->nsstyle) nsIDOMCSSStyleDeclaration_Release(This->nsstyle); + release_dispex(&This->dispex); heap_free(This); } diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c index 0b95229..9e32b27 100644 --- a/dlls/mshtml/htmldoc.c +++ b/dlls/mshtml/htmldoc.c @@ -215,6 +215,7 @@ static ULONG WINAPI HTMLDocument_Release(IHTMLDocument2 *iface) detach_selection(This); detach_ranges(This); release_nodes(This); + release_dispex(&This->dispex); ConnectionPointContainer_Destroy(&This->cp_container); diff --git a/dlls/mshtml/htmlelemcol.c b/dlls/mshtml/htmlelemcol.c index ba9a440..63fcb80 100644 --- a/dlls/mshtml/htmlelemcol.c +++ b/dlls/mshtml/htmlelemcol.c @@ -132,6 +132,7 @@ static ULONG WINAPI HTMLElementCollection_Release(IHTMLElementCollection *iface) if(!ref) { IUnknown_Release(This->ref_unk); + release_dispex(&This->dispex); heap_free(This->elems); heap_free(This); } diff --git a/dlls/mshtml/htmlevent.c b/dlls/mshtml/htmlevent.c index b73f865..ca7166c 100644 --- a/dlls/mshtml/htmlevent.c +++ b/dlls/mshtml/htmlevent.c @@ -176,8 +176,10 @@ static ULONG WINAPI HTMLEventObj_Release(IHTMLEventObj *iface) TRACE("(%p) ref=%d\n", This, ref); - if(!ref) + if(!ref) { + release_dispex(&This->dispex); heap_free(This); + } return ref; } diff --git a/dlls/mshtml/htmllocation.c b/dlls/mshtml/htmllocation.c index da3027e..8637838 100644 --- a/dlls/mshtml/htmllocation.c +++ b/dlls/mshtml/htmllocation.c @@ -82,6 +82,7 @@ static ULONG WINAPI HTMLLocation_Release(IHTMLLocation *iface) if(!ref) { if(This->doc && This->doc->location == This) This->doc->location = NULL; + release_dispex(&This->dispex); heap_free(This); } diff --git a/dlls/mshtml/htmlnode.c b/dlls/mshtml/htmlnode.c index 9b132b1..30fdac8 100644 --- a/dlls/mshtml/htmlnode.c +++ b/dlls/mshtml/htmlnode.c @@ -308,6 +308,7 @@ static ULONG WINAPI HTMLDOMNode_Release(IHTMLDOMNode *iface) if(!ref) { This->vtbl->destructor(This); + release_dispex(&This->dispex); heap_free(This); } diff --git a/dlls/mshtml/htmlstyle.c b/dlls/mshtml/htmlstyle.c index 612dc2f..a993702 100644 --- a/dlls/mshtml/htmlstyle.c +++ b/dlls/mshtml/htmlstyle.c @@ -554,6 +554,7 @@ static ULONG WINAPI HTMLStyle_Release(IHTMLStyle *iface) if(!ref) { if(This->nsstyle) nsIDOMCSSStyleDeclaration_Release(This->nsstyle); + release_dispex(&This->dispex); heap_free(This); } diff --git a/dlls/mshtml/htmlwindow.c b/dlls/mshtml/htmlwindow.c index 4f2a5de..d50eca1 100644 --- a/dlls/mshtml/htmlwindow.c +++ b/dlls/mshtml/htmlwindow.c @@ -93,6 +93,7 @@ static ULONG WINAPI HTMLWindow2_Release(IHTMLWindow2 *iface) if(!ref) { list_remove(&This->entry); + release_dispex(&This->dispex); heap_free(This); } diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index db127b5..ecae0a5 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -149,6 +149,7 @@ typedef struct { } DispatchEx; void init_dispex(DispatchEx*,IUnknown*,dispex_static_data_t*); +void release_dispex(DispatchEx*); BOOL dispex_query_interface(DispatchEx*,REFIID,void**); HRESULT dispex_get_dprop_ref(DispatchEx*,const WCHAR*,BOOL,VARIANT**); diff --git a/dlls/mshtml/omnavigator.c b/dlls/mshtml/omnavigator.c index 6e912d3..207464f 100644 --- a/dlls/mshtml/omnavigator.c +++ b/dlls/mshtml/omnavigator.c @@ -84,8 +84,10 @@ static ULONG WINAPI OmNavigator_Release(IOmNavigator *iface) TRACE("(%p) ref=%d\n", This, ref); - if(!ref) + if(!ref) { + release_dispex(&This->dispex); heap_free(This); + } return ref; }
1
0
0
0
Jacek Caban : mshtml: Added function object tests.
by Alexandre Julliard
01 Sep '09
01 Sep '09
Module: wine Branch: master Commit: 012004bcf95d8282e2425a148b002ce484a7dd36 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=012004bcf95d8282e2425a148…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Mon Aug 31 20:47:21 2009 +0200 mshtml: Added function object tests. --- dlls/mshtml/tests/script.c | 99 +++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 98 insertions(+), 1 deletions(-) diff --git a/dlls/mshtml/tests/script.c b/dlls/mshtml/tests/script.c index 157b00f..2c74ff7 100644 --- a/dlls/mshtml/tests/script.c +++ b/dlls/mshtml/tests/script.c @@ -129,6 +129,25 @@ static const char *debugstr_guid(REFIID riid) return buf; } +static int strcmp_wa(LPCWSTR strw, const char *stra) +{ + CHAR buf[512]; + WideCharToMultiByte(CP_ACP, 0, strw, -1, buf, sizeof(buf), NULL, NULL); + return lstrcmpA(stra, buf); +} + +static BSTR a2bstr(const char *str) +{ + BSTR ret; + int len; + + len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0); + ret = SysAllocStringLen(NULL, len); + MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len); + + return ret; +} + static HRESULT WINAPI PropertyNotifySink_QueryInterface(IPropertyNotifySink *iface, REFIID riid, void**ppv) { @@ -617,12 +636,76 @@ static HRESULT WINAPI ActiveScriptParse_AddScriptlet(IActiveScriptParse *iface, return E_NOTIMPL; } +static void test_func(IDispatchEx *obj) +{ + DISPID id, propput_arg = DISPID_PROPERTYPUT; + IDispatchEx *dispex; + IDispatch *disp; + EXCEPINFO ei; + DISPPARAMS dp; + BSTR str; + VARIANT var; + HRESULT hres; + + str = a2bstr("toString"); + hres = IDispatchEx_GetDispID(obj, str, fdexNameCaseSensitive, &id); + SysFreeString(str); + ok(hres == S_OK, "GetDispID failed: %08x\n", hres); + ok(id == DISPID_IOMNAVIGATOR_TOSTRING, "id = %x\n", id); + + memset(&dp, 0, sizeof(dp)); + memset(&ei, 0, sizeof(ei)); + VariantInit(&var); + hres = IDispatchEx_InvokeEx(obj, id, LOCALE_NEUTRAL, DISPATCH_PROPERTYGET, &dp, &var, &ei, NULL); + ok(hres == S_OK, "InvokeEx failed: %08x\n", hres); + ok(V_VT(&var) == VT_DISPATCH, "V_VT(var)=%d\n", V_VT(&var)); + ok(V_DISPATCH(&var) != NULL, "V_DISPATCH(var) == NULL\n"); + disp = V_DISPATCH(&var); + + memset(&dp, 0, sizeof(dp)); + memset(&ei, 0, sizeof(ei)); + VariantInit(&var); + hres = IDispatchEx_InvokeEx(obj, id, LOCALE_NEUTRAL, DISPATCH_PROPERTYGET, &dp, &var, &ei, NULL); + ok(hres == S_OK, "InvokeEx failed: %08x\n", hres); + ok(V_VT(&var) == VT_DISPATCH, "V_VT(var)=%d\n", V_VT(&var)); + ok(V_DISPATCH(&var) == disp, "V_DISPATCH(var) != disp\n"); + VariantClear(&var); + + hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex); + IDispatch_Release(disp); + ok(hres == S_OK, "Could not get IDispatchEx iface: %08x\n", hres); + + /* FIXME: Test InvokeEx(DISPATCH_METHOD) */ + + memset(&dp, 0, sizeof(dp)); + memset(&ei, 0, sizeof(ei)); + VariantInit(&var); + hres = IDispatchEx_Invoke(dispex, DISPID_VALUE, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_METHOD, &dp, &var, &ei, NULL); + ok(hres == S_OK, "InvokeEx failed: %08x\n", hres); + ok(V_VT(&var) == VT_BSTR, "V_VT(var)=%d\n", V_VT(&var)); + ok(!strcmp_wa(V_BSTR(&var), "[object]"), "V_BSTR(var) = %s\n", wine_dbgstr_w(V_BSTR(&var))); + VariantClear(&var); + + dp.cArgs = 1; + dp.rgvarg = &var; + dp.cNamedArgs = 1; + dp.rgdispidNamedArgs = &propput_arg; + V_VT(&var) = VT_I4; + V_I4(&var) = 100; + hres = IDispatchEx_InvokeEx(obj, id, LOCALE_NEUTRAL, DISPATCH_PROPERTYPUT, &dp, NULL, &ei, NULL); + ok(hres == E_NOTIMPL, "InvokeEx failed: %08x\n", hres); + + IDispatchEx_Release(dispex); +} + static HRESULT WINAPI ActiveScriptParse_ParseScriptText(IActiveScriptParse *iface, LPCOLESTR pstrCode, LPCOLESTR pstrItemName, IUnknown *punkContext, LPCOLESTR pstrDelimiter, CTXARG_T dwSourceContextCookie, ULONG ulStartingLine, DWORD dwFlags, VARIANT *pvarResult, EXCEPINFO *pexcepinfo) { - IDispatchEx *document; + IDispatchEx *document, *dispex; + IHTMLWindow2 *window; + IOmNavigator *navigator; IUnknown *unk; VARIANT var, arg; DISPPARAMS dp; @@ -737,6 +820,20 @@ static HRESULT WINAPI ActiveScriptParse_ParseScriptText(IActiveScriptParse *ifac IDispatchEx_Release(document); + hres = IDispatchEx_QueryInterface(window_dispex, &IID_IHTMLWindow2, (void**)&window); + ok(hres == S_OK, "Could not get IHTMLWindow2 iface: %08x\n", hres); + + hres = IHTMLWindow2_get_navigator(window, &navigator); + IHTMLWindow2_Release(window); + ok(hres == S_OK, "get_navigator failed: %08x\n", hres); + + hres = IOmNavigator_QueryInterface(navigator, &IID_IDispatchEx, (void**)&dispex); + IOmNavigator_Release(navigator); + ok(hres == S_OK, "Could not get IDispatchEx iface: %08x\n", hres); + + test_func(dispex); + IDispatchEx_Release(dispex); + return S_OK; }
1
0
0
0
Jacek Caban : mshtml: Added function object implementation.
by Alexandre Julliard
01 Sep '09
01 Sep '09
Module: wine Branch: master Commit: 65d0929cfc3cd137cccb858ca446bc2e2f79077f URL:
http://source.winehq.org/git/wine.git/?a=commit;h=65d0929cfc3cd137cccb858ca…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Mon Aug 31 20:46:41 2009 +0200 mshtml: Added function object implementation. --- dlls/mshtml/dispex.c | 167 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 161 insertions(+), 6 deletions(-) diff --git a/dlls/mshtml/dispex.c b/dlls/mshtml/dispex.c index 059ed66..b4cfe3f 100644 --- a/dlls/mshtml/dispex.c +++ b/dlls/mshtml/dispex.c @@ -35,12 +35,14 @@ typedef struct { DISPID id; BSTR name; tid_t tid; + int func_disp_idx; } func_info_t; struct dispex_data_t { DWORD func_cnt; func_info_t *funcs; func_info_t **name_table; + DWORD func_disp_cnt; struct list entry; }; @@ -50,10 +52,20 @@ typedef struct { LPWSTR name; } dynamic_prop_t; +typedef struct { + DispatchEx dispex; + const IUnknownVtbl *lpIUnknownVtbl; + DispatchEx *obj; + func_info_t *info; +} func_disp_t; + +#define FUNCUNKNOWN(x) ((IUnknown*) &(x)->lpIUnknownVtbl) + struct dispex_dynamic_data_t { DWORD buf_size; DWORD prop_cnt; dynamic_prop_t *props; + func_disp_t **func_disps; }; #define DISPID_DYNPROP_0 0x50000000 @@ -188,22 +200,23 @@ void release_typelib(void) ITypeLib_Release(typelib); } -static void add_func_info(dispex_data_t *data, DWORD *size, tid_t tid, DISPID id, ITypeInfo *dti) +static void add_func_info(dispex_data_t *data, DWORD *size, tid_t tid, const FUNCDESC *desc, ITypeInfo *dti) { HRESULT hres; - if(data->func_cnt && data->funcs[data->func_cnt-1].id == id) + if(data->func_cnt && data->funcs[data->func_cnt-1].id == desc->memid) return; if(data->func_cnt == *size) data->funcs = heap_realloc(data->funcs, (*size <<= 1)*sizeof(func_info_t)); - hres = ITypeInfo_GetDocumentation(dti, id, &data->funcs[data->func_cnt].name, NULL, NULL, NULL); + hres = ITypeInfo_GetDocumentation(dti, desc->memid, &data->funcs[data->func_cnt].name, NULL, NULL, NULL); if(FAILED(hres)) return; - data->funcs[data->func_cnt].id = id; + data->funcs[data->func_cnt].id = desc->memid; data->funcs[data->func_cnt].tid = tid; + data->funcs[data->func_cnt].func_disp_idx = desc->invkind == INVOKE_FUNC ? data->func_disp_cnt++ : -1; data->func_cnt++; } @@ -237,6 +250,7 @@ static dispex_data_t *preprocess_dispex_data(DispatchEx *This) data = heap_alloc(sizeof(dispex_data_t)); data->func_cnt = 0; + data->func_disp_cnt = 0; data->funcs = heap_alloc(size*sizeof(func_info_t)); list_add_tail(&dispex_data_list, &data->entry); @@ -251,7 +265,7 @@ static dispex_data_t *preprocess_dispex_data(DispatchEx *This) if(FAILED(hres)) break; - add_func_info(data, &size, *tid, funcdesc->memid, dti); + add_func_info(data, &size, *tid, funcdesc, dti); ITypeInfo_ReleaseFuncDesc(ti, funcdesc); } @@ -457,6 +471,142 @@ static HRESULT typeinfo_invoke(DispatchEx *This, func_info_t *func, WORD flags, return hres; } +#define FUNCTION_THIS(iface) DEFINE_THIS(func_disp_t, IUnknown, iface) + +static HRESULT WINAPI Function_QueryInterface(IUnknown *iface, REFIID riid, void **ppv) +{ + func_disp_t *This = FUNCTION_THIS(iface); + + if(IsEqualGUID(&IID_IUnknown, riid)) { + TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv); + *ppv = FUNCUNKNOWN(This); + }else if(dispex_query_interface(&This->dispex, riid, ppv)) { + return *ppv ? S_OK : E_NOINTERFACE; + }else { + *ppv = NULL; + return E_NOINTERFACE; + } + + IUnknown_AddRef((IUnknown*)*ppv); + return S_OK; +} + +static ULONG WINAPI Function_AddRef(IUnknown *iface) +{ + func_disp_t *This = FUNCTION_THIS(iface); + + TRACE("(%p)\n", This); + + return IDispatchEx_AddRef(DISPATCHEX(This->obj)); +} + +static ULONG WINAPI Function_Release(IUnknown *iface) +{ + func_disp_t *This = FUNCTION_THIS(iface); + + TRACE("(%p)\n", This); + + return IDispatchEx_Release(DISPATCHEX(This->obj)); +} + +static HRESULT function_value(IUnknown *iface, LCID lcid, WORD flags, DISPPARAMS *params, + VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller) +{ + func_disp_t *This = FUNCTION_THIS(iface); + HRESULT hres; + + switch(flags) { + case DISPATCH_METHOD: + hres = typeinfo_invoke(This->obj, This->info, flags, params, res, ei); + break; + default: + FIXME("Unimplemented flags %x\n", flags); + hres = E_NOTIMPL; + } + + return hres; +} + +#undef FUNCTION_THIS + +static const IUnknownVtbl FunctionUnkVtbl = { + Function_QueryInterface, + Function_AddRef, + Function_Release +}; + +static const dispex_static_data_vtbl_t function_dispex_vtbl = { + function_value, + NULL, + NULL +}; + +static dispex_static_data_t function_dispex = { + &function_dispex_vtbl, + LAST_tid, + NULL, + NULL +}; + +static func_disp_t *create_func_disp(DispatchEx *obj, func_info_t *info) +{ + func_disp_t *ret; + + ret = heap_alloc_zero(sizeof(func_disp_t)); + if(!ret) + return NULL; + + ret->lpIUnknownVtbl = &FunctionUnkVtbl; + init_dispex(&ret->dispex, FUNCUNKNOWN(ret), &function_dispex); + ret->obj = obj; + ret->info = info; + + return ret; +} + +static HRESULT function_invoke(DispatchEx *This, func_info_t *func, WORD flags, DISPPARAMS *dp, VARIANT *res, + EXCEPINFO *ei) +{ + HRESULT hres; + + switch(flags) { + case DISPATCH_METHOD: + hres = typeinfo_invoke(This, func, flags, dp, res, ei); + break; + case DISPATCH_PROPERTYGET: { + dispex_dynamic_data_t *dynamic_data; + + dynamic_data = get_dynamic_data(This, TRUE); + if(!dynamic_data) + return E_OUTOFMEMORY; + + if(!dynamic_data->func_disps) { + dynamic_data->func_disps = heap_alloc_zero(This->data->data->func_disp_cnt * sizeof(func_disp_t*)); + if(!dynamic_data->func_disps) + return E_OUTOFMEMORY; + } + + if(!dynamic_data->func_disps[func->func_disp_idx]) { + dynamic_data->func_disps[func->func_disp_idx] = create_func_disp(This, func); + if(!dynamic_data->func_disps[func->func_disp_idx]) + return E_OUTOFMEMORY; + } + + V_VT(res) = VT_DISPATCH; + V_DISPATCH(res) = (IDispatch*)DISPATCHEX(&dynamic_data->func_disps[func->func_disp_idx]->dispex); + IDispatch_AddRef(V_DISPATCH(res)); + hres = S_OK; + break; + } + default: + FIXME("Unimplemented flags %x\n", flags); + case DISPATCH_PROPERTYPUT: + hres = E_NOTIMPL; + } + + return hres; +} + #define DISPATCHEX_THIS(iface) DEFINE_THIS(DispatchEx, IDispatchEx, iface) static HRESULT WINAPI DispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv) @@ -698,7 +848,12 @@ static HRESULT WINAPI DispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lc return DISP_E_UNKNOWNNAME; } - return typeinfo_invoke(This, data->funcs+n, wFlags, pdp, pvarRes, pei); + if(data->funcs[n].func_disp_idx == -1) + hres = typeinfo_invoke(This, data->funcs+n, wFlags, pdp, pvarRes, pei); + else + hres = function_invoke(This, data->funcs+n, wFlags, pdp, pvarRes, pei); + + return hres; } static HRESULT WINAPI DispatchEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
1
0
0
0
Jacek Caban : mshtml: Moved dynamic_data allocation to separated function.
by Alexandre Julliard
01 Sep '09
01 Sep '09
Module: wine Branch: master Commit: 55d6bcb0369319fe72d962fd0e2a96a56b7f9366 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=55d6bcb0369319fe72d962fd0…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Mon Aug 31 20:46:03 2009 +0200 mshtml: Moved dynamic_data allocation to separated function. --- dlls/mshtml/dispex.c | 73 +++++++++++++++++++++++++------------------------ 1 files changed, 37 insertions(+), 36 deletions(-) diff --git a/dlls/mshtml/dispex.c b/dlls/mshtml/dispex.c index cf41bba..059ed66 100644 --- a/dlls/mshtml/dispex.c +++ b/dlls/mshtml/dispex.c @@ -343,55 +343,56 @@ static inline BOOL is_dynamic_dispid(DISPID id) return DISPID_DYNPROP_0 <= id && id <= DISPID_DYNPROP_MAX; } +static inline dispex_dynamic_data_t *get_dynamic_data(DispatchEx *This, BOOL alloc) +{ + return !alloc || This->dynamic_data + ? This->dynamic_data + : (This->dynamic_data = heap_alloc_zero(sizeof(dispex_dynamic_data_t))); +} + static HRESULT get_dynamic_prop(DispatchEx *This, const WCHAR *name, BOOL alloc, dynamic_prop_t **ret) { - dispex_dynamic_data_t *data = This->dynamic_data; + dispex_dynamic_data_t *data = get_dynamic_data(This, alloc); + unsigned i; - if(data) { - unsigned i; + if(!data) { + if(alloc) + return E_OUTOFMEMORY; - for(i=0; i < data->prop_cnt; i++) { - if(!strcmpW(data->props[i].name, name)) { - *ret = data->props+i; - return S_OK; - } - } + TRACE("not found %s\n", debugstr_w(name)); + return DISP_E_UNKNOWNNAME; } - if(alloc) { - TRACE("creating dynamic prop %s\n", debugstr_w(name)); - - if(!data) { - data = This->dynamic_data = heap_alloc_zero(sizeof(dispex_dynamic_data_t)); - if(!data) - return E_OUTOFMEMORY; + for(i=0; i < data->prop_cnt; i++) { + if(!strcmpW(data->props[i].name, name)) { + *ret = data->props+i; + return S_OK; } + } - if(!data->buf_size) { - data->props = heap_alloc(sizeof(dynamic_prop_t)*4); - if(!data->props) - return E_OUTOFMEMORY; - data->buf_size = 4; - }else if(data->buf_size == data->prop_cnt) { - dynamic_prop_t *new_props; - - new_props = heap_realloc(data->props, sizeof(dynamic_prop_t)*(data->buf_size<<1)); - if(!new_props) - return E_OUTOFMEMORY; + TRACE("creating dynamic prop %s\n", debugstr_w(name)); - data->props = new_props; - data->buf_size <<= 1; - } + if(!data->buf_size) { + data->props = heap_alloc(sizeof(dynamic_prop_t)*4); + if(!data->props) + return E_OUTOFMEMORY; + data->buf_size = 4; + }else if(data->buf_size == data->prop_cnt) { + dynamic_prop_t *new_props; - data->props[data->prop_cnt].name = heap_strdupW(name); - VariantInit(&data->props[data->prop_cnt].var); - *ret = data->props + data->prop_cnt++; + new_props = heap_realloc(data->props, sizeof(dynamic_prop_t)*(data->buf_size<<1)); + if(!new_props) + return E_OUTOFMEMORY; - return S_OK; + data->props = new_props; + data->buf_size <<= 1; } - TRACE("not found %s\n", debugstr_w(name)); - return DISP_E_UNKNOWNNAME; + data->props[data->prop_cnt].name = heap_strdupW(name); + VariantInit(&data->props[data->prop_cnt].var); + *ret = data->props + data->prop_cnt++; + + return S_OK; } HRESULT dispex_get_dprop_ref(DispatchEx *This, const WCHAR *name, BOOL alloc, VARIANT **ret)
1
0
0
0
Jacek Caban : mshtml: Move ITypeInfo::Invoke call to separated function.
by Alexandre Julliard
01 Sep '09
01 Sep '09
Module: wine Branch: master Commit: 2e2622efaa1b3c2a100e22fb5381404554c616e2 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=2e2622efaa1b3c2a100e22fb5…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Mon Aug 31 20:45:42 2009 +0200 mshtml: Move ITypeInfo::Invoke call to separated function. --- dlls/mshtml/dispex.c | 46 +++++++++++++++++++++++++++------------------- 1 files changed, 27 insertions(+), 19 deletions(-) diff --git a/dlls/mshtml/dispex.c b/dlls/mshtml/dispex.c index 0a09de7..cf41bba 100644 --- a/dlls/mshtml/dispex.c +++ b/dlls/mshtml/dispex.c @@ -430,6 +430,32 @@ static HRESULT dispex_value(DispatchEx *This, LCID lcid, WORD flags, DISPPARAMS return S_OK; } +static HRESULT typeinfo_invoke(DispatchEx *This, func_info_t *func, WORD flags, DISPPARAMS *dp, VARIANT *res, + EXCEPINFO *ei) +{ + ITypeInfo *ti; + IUnknown *unk; + UINT argerr=0; + HRESULT hres; + + hres = get_typeinfo(func->tid, &ti); + if(FAILED(hres)) { + ERR("Could not get type info: %08x\n", hres); + return hres; + } + + hres = IUnknown_QueryInterface(This->outer, tid_ids[func->tid], (void**)&unk); + if(FAILED(hres)) { + ERR("Could not get iface %s: %08x\n", debugstr_guid(tid_ids[func->tid]), hres); + return E_FAIL; + } + + hres = ITypeInfo_Invoke(ti, unk, func->id, flags, dp, res, ei, &argerr); + + IUnknown_Release(unk); + return hres; +} + #define DISPATCHEX_THIS(iface) DEFINE_THIS(DispatchEx, IDispatchEx, iface) static HRESULT WINAPI DispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv) @@ -570,10 +596,7 @@ static HRESULT WINAPI DispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lc VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller) { DispatchEx *This = DISPATCHEX_THIS(iface); - IUnknown *unk; - ITypeInfo *ti; dispex_data_t *data; - UINT argerr=0; int min, max, n; HRESULT hres; @@ -674,22 +697,7 @@ static HRESULT WINAPI DispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lc return DISP_E_UNKNOWNNAME; } - hres = get_typeinfo(data->funcs[n].tid, &ti); - if(FAILED(hres)) { - ERR("Could not get type info: %08x\n", hres); - return hres; - } - - hres = IUnknown_QueryInterface(This->outer, tid_ids[data->funcs[n].tid], (void**)&unk); - if(FAILED(hres)) { - ERR("Could not get iface %s: %08x\n", debugstr_guid(tid_ids[data->funcs[n].tid]), hres); - return E_FAIL; - } - - hres = ITypeInfo_Invoke(ti, unk, id, wFlags, pdp, pvarRes, pei, &argerr); - - IUnknown_Release(unk); - return hres; + return typeinfo_invoke(This, data->funcs+n, wFlags, pdp, pvarRes, pei); } static HRESULT WINAPI DispatchEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
1
0
0
0
Jacek Caban : dispex.idl: Added SID declarations.
by Alexandre Julliard
01 Sep '09
01 Sep '09
Module: wine Branch: master Commit: 6478f3d6e27470054d52ba6567ef1e73fbebaeaf URL:
http://source.winehq.org/git/wine.git/?a=commit;h=6478f3d6e27470054d52ba656…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Mon Aug 31 20:45:20 2009 +0200 dispex.idl: Added SID declarations. --- include/dispex.idl | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/include/dispex.idl b/include/dispex.idl index b44448e..b1759dd 100644 --- a/include/dispex.idl +++ b/include/dispex.idl @@ -23,6 +23,9 @@ import "oaidl.idl"; import "servprov.idl"; #endif +cpp_quote("DEFINE_GUID(SID_VariantConversion, 0x1f101481,0xbccd,0x11d0,0x93,0x36,0x00,0xa0,0xc9,0xd,0xca,0xa9);") +cpp_quote("DEFINE_GUID(SID_GetCaller, 0x4717cc40,0xbcb9,0x11d0,0x93,0x36,0x00,0xa0,0xc9,0xd,0xca,0xa9);") + cpp_quote("#define fdexNameCaseSensitive 0x00000001L") cpp_quote("#define fdexNameEnsure 0x00000002L") cpp_quote("#define fdexNameImplicit 0x00000004L")
1
0
0
0
← Newer
1
...
83
84
85
86
87
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
Results per page:
10
25
50
100
200