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
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
August 2009
----- 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
4 participants
1042 discussions
Start a n
N
ew thread
Vincent Povirk : windowscodecs: Implement Initialize for the PNG decoder.
by Alexandre Julliard
28 Aug '09
28 Aug '09
Module: wine Branch: master Commit: 7d74dba5b80274ea36ee5f27f9510e92ceae12f3 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=7d74dba5b80274ea36ee5f27f…
Author: Vincent Povirk <vincent(a)codeweavers.com> Date: Thu Aug 13 17:50:16 2009 -0500 windowscodecs: Implement Initialize for the PNG decoder. --- dlls/windowscodecs/pngformat.c | 201 +++++++++++++++++++++++++++++++++++++++- 1 files changed, 199 insertions(+), 2 deletions(-) diff --git a/dlls/windowscodecs/pngformat.c b/dlls/windowscodecs/pngformat.c index 864a5bd..bd0482b 100644 --- a/dlls/windowscodecs/pngformat.c +++ b/dlls/windowscodecs/pngformat.c @@ -45,6 +45,19 @@ static void *libpng_handle; #define MAKE_FUNCPTR(f) static typeof(f) * p##f MAKE_FUNCPTR(png_create_read_struct); MAKE_FUNCPTR(png_create_info_struct); +MAKE_FUNCPTR(png_destroy_read_struct); +MAKE_FUNCPTR(png_error); +MAKE_FUNCPTR(png_get_bit_depth); +MAKE_FUNCPTR(png_get_color_type); +MAKE_FUNCPTR(png_get_image_height); +MAKE_FUNCPTR(png_get_image_width); +MAKE_FUNCPTR(png_get_io_ptr); +MAKE_FUNCPTR(png_set_bgr); +MAKE_FUNCPTR(png_set_gray_to_rgb); +MAKE_FUNCPTR(png_set_read_fn); +MAKE_FUNCPTR(png_read_end); +MAKE_FUNCPTR(png_read_image); +MAKE_FUNCPTR(png_read_info); #undef MAKE_FUNCPTR static void *load_libpng(void) @@ -58,6 +71,19 @@ static void *load_libpng(void) } LOAD_FUNCPTR(png_create_read_struct); LOAD_FUNCPTR(png_create_info_struct); + LOAD_FUNCPTR(png_destroy_read_struct); + LOAD_FUNCPTR(png_error); + LOAD_FUNCPTR(png_get_bit_depth); + LOAD_FUNCPTR(png_get_color_type); + LOAD_FUNCPTR(png_get_image_height); + LOAD_FUNCPTR(png_get_image_width); + LOAD_FUNCPTR(png_get_io_ptr); + LOAD_FUNCPTR(png_set_bgr); + LOAD_FUNCPTR(png_set_gray_to_rgb); + LOAD_FUNCPTR(png_set_read_fn); + LOAD_FUNCPTR(png_read_end); + LOAD_FUNCPTR(png_read_image); + LOAD_FUNCPTR(png_read_info); #undef LOAD_FUNCPTR } @@ -67,6 +93,15 @@ static void *load_libpng(void) typedef struct { const IWICBitmapDecoderVtbl *lpVtbl; LONG ref; + png_structp png_ptr; + png_infop info_ptr; + png_infop end_info; + BOOL initialized; + int bpp; + int width, height; + UINT stride; + const WICPixelFormatGUID *format; + BYTE *image_bits; } PngDecoder; static HRESULT WINAPI PngDecoder_QueryInterface(IWICBitmapDecoder *iface, REFIID iid, @@ -110,6 +145,9 @@ static ULONG WINAPI PngDecoder_Release(IWICBitmapDecoder *iface) if (ref == 0) { + if (This->png_ptr) + ppng_destroy_read_struct(&This->png_ptr, &This->info_ptr, &This->end_info); + HeapFree(GetProcessHeap(), 0, This->image_bits); HeapFree(GetProcessHeap(), 0, This); } @@ -123,11 +161,165 @@ static HRESULT WINAPI PngDecoder_QueryCapability(IWICBitmapDecoder *iface, IStre return E_NOTIMPL; } +static void user_read_data(png_structp png_ptr, png_bytep data, png_size_t length) +{ + IStream *stream = ppng_get_io_ptr(png_ptr); + HRESULT hr; + ULONG bytesread; + + hr = IStream_Read(stream, data, length, &bytesread); + if (FAILED(hr) || bytesread != length) + { + ppng_error(png_ptr, "failed reading data"); + } +} + static HRESULT WINAPI PngDecoder_Initialize(IWICBitmapDecoder *iface, IStream *pIStream, WICDecodeOptions cacheOptions) { - FIXME("(%p,%p,%x): stub\n", iface, pIStream, cacheOptions); - return E_NOTIMPL; + PngDecoder *This = (PngDecoder*)iface; + LARGE_INTEGER seek; + HRESULT hr; + png_bytep *row_pointers=NULL; + UINT image_size; + UINT i; + int color_type, bit_depth; + TRACE("(%p,%p,%x)\n", iface, pIStream, cacheOptions); + + /* initialize libpng */ + This->png_ptr = ppng_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); + if (!This->png_ptr) return E_FAIL; + + This->info_ptr = ppng_create_info_struct(This->png_ptr); + if (!This->info_ptr) + { + ppng_destroy_read_struct(&This->png_ptr, (png_infopp)NULL, (png_infopp)NULL); + This->png_ptr = NULL; + return E_FAIL; + } + + This->end_info = ppng_create_info_struct(This->png_ptr); + if (!This->info_ptr) + { + ppng_destroy_read_struct(&This->png_ptr, &This->info_ptr, (png_infopp)NULL); + This->png_ptr = NULL; + return E_FAIL; + } + + /* set up setjmp/longjmp error handling */ + if (setjmp(png_jmpbuf(This->png_ptr))) + { + ppng_destroy_read_struct(&This->png_ptr, &This->info_ptr, &This->end_info); + HeapFree(GetProcessHeap(), 0, row_pointers); + This->png_ptr = NULL; + return E_FAIL; + } + + /* seek to the start of the stream */ + seek.QuadPart = 0; + hr = IStream_Seek(pIStream, seek, STREAM_SEEK_SET, NULL); + if (FAILED(hr)) return hr; + + /* set up custom i/o handling */ + ppng_set_read_fn(This->png_ptr, pIStream, user_read_data); + + /* read the header */ + ppng_read_info(This->png_ptr, This->info_ptr); + + /* choose a pixel format */ + color_type = ppng_get_color_type(This->png_ptr, This->info_ptr); + bit_depth = ppng_get_bit_depth(This->png_ptr, This->info_ptr); + + switch (color_type) + { + case PNG_COLOR_TYPE_GRAY: + This->bpp = bit_depth; + switch (bit_depth) + { + case 1: This->format = &GUID_WICPixelFormatBlackWhite; break; + case 2: This->format = &GUID_WICPixelFormat2bppGray; break; + case 4: This->format = &GUID_WICPixelFormat4bppGray; break; + case 8: This->format = &GUID_WICPixelFormat8bppGray; break; + case 16: This->format = &GUID_WICPixelFormat16bppGray; break; + default: + ERR("invalid grayscale bit depth: %i\n", bit_depth); + return E_FAIL; + } + break; + case PNG_COLOR_TYPE_GRAY_ALPHA: + /* WIC does not support grayscale alpha formats so use RGBA */ + ppng_set_gray_to_rgb(This->png_ptr); + case PNG_COLOR_TYPE_RGB_ALPHA: + This->bpp = bit_depth * 4; + switch (bit_depth) + { + case 8: + ppng_set_bgr(This->png_ptr); + This->format = &GUID_WICPixelFormat32bppBGRA; + break; + case 16: This->format = &GUID_WICPixelFormat64bppRGBA; break; + default: + ERR("invalid RGBA bit depth: %i\n", bit_depth); + return E_FAIL; + } + break; + case PNG_COLOR_TYPE_PALETTE: + This->bpp = bit_depth; + switch (bit_depth) + { + case 1: This->format = &GUID_WICPixelFormat1bppIndexed; break; + case 2: This->format = &GUID_WICPixelFormat2bppIndexed; break; + case 4: This->format = &GUID_WICPixelFormat4bppIndexed; break; + case 8: This->format = &GUID_WICPixelFormat8bppIndexed; break; + default: + ERR("invalid indexed color bit depth: %i\n", bit_depth); + return E_FAIL; + } + break; + case PNG_COLOR_TYPE_RGB: + This->bpp = bit_depth * 3; + switch (bit_depth) + { + case 8: + ppng_set_bgr(This->png_ptr); + This->format = &GUID_WICPixelFormat24bppBGR; + break; + case 16: This->format = &GUID_WICPixelFormat48bppRGB; break; + default: + ERR("invalid RGB color bit depth: %i\n", bit_depth); + return E_FAIL; + } + break; + default: + ERR("invalid color type %i\n", color_type); + return E_FAIL; + } + + /* read the image data */ + This->width = ppng_get_image_width(This->png_ptr, This->info_ptr); + This->height = ppng_get_image_height(This->png_ptr, This->info_ptr); + This->stride = This->width * This->bpp; + image_size = This->stride * This->height; + + This->image_bits = HeapAlloc(GetProcessHeap(), 0, image_size); + if (!This->image_bits) return E_OUTOFMEMORY; + + row_pointers = HeapAlloc(GetProcessHeap(), 0, sizeof(png_bytep)*This->height); + if (!row_pointers) return E_OUTOFMEMORY; + + for (i=0; i<This->height; i++) + row_pointers[i] = This->image_bits + i * This->stride; + + ppng_read_image(This->png_ptr, row_pointers); + + HeapFree(GetProcessHeap(), 0, row_pointers); + row_pointers = NULL; + + ppng_read_end(This->png_ptr, This->end_info); + + This->initialized = TRUE; + + return S_OK; } static HRESULT WINAPI PngDecoder_GetContainerFormat(IWICBitmapDecoder *iface, @@ -232,6 +424,11 @@ HRESULT PngDecoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv) This->lpVtbl = &PngDecoder_Vtbl; This->ref = 1; + This->png_ptr = NULL; + This->info_ptr = NULL; + This->end_info = NULL; + This->initialized = FALSE; + This->image_bits = NULL; ret = IUnknown_QueryInterface((IUnknown*)This, iid, ppv); IUnknown_Release((IUnknown*)This);
1
0
0
0
Vincent Povirk : windowscodecs: Implement GetFrameCount for PNG decoder.
by Alexandre Julliard
28 Aug '09
28 Aug '09
Module: wine Branch: master Commit: f62620432123573369edcd533e946eaaf550108d URL:
http://source.winehq.org/git/wine.git/?a=commit;h=f62620432123573369edcd533…
Author: Vincent Povirk <vincent(a)codeweavers.com> Date: Thu Aug 13 17:02:19 2009 -0500 windowscodecs: Implement GetFrameCount for PNG decoder. --- dlls/windowscodecs/pngformat.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dlls/windowscodecs/pngformat.c b/dlls/windowscodecs/pngformat.c index 8fa4a47..864a5bd 100644 --- a/dlls/windowscodecs/pngformat.c +++ b/dlls/windowscodecs/pngformat.c @@ -182,8 +182,8 @@ static HRESULT WINAPI PngDecoder_GetThumbnail(IWICBitmapDecoder *iface, static HRESULT WINAPI PngDecoder_GetFrameCount(IWICBitmapDecoder *iface, UINT *pCount) { - FIXME("(%p,%p): stub\n", iface, pCount); - return E_NOTIMPL; + *pCount = 1; + return S_OK; } static HRESULT WINAPI PngDecoder_GetFrame(IWICBitmapDecoder *iface,
1
0
0
0
Vincent Povirk : windowscodecs: Implement GetContainerFormat for PNG decoder.
by Alexandre Julliard
28 Aug '09
28 Aug '09
Module: wine Branch: master Commit: 25f3802b369ed8a3f003fa922241a9868a80740c URL:
http://source.winehq.org/git/wine.git/?a=commit;h=25f3802b369ed8a3f003fa922…
Author: Vincent Povirk <vincent(a)codeweavers.com> Date: Thu Aug 13 17:01:42 2009 -0500 windowscodecs: Implement GetContainerFormat for PNG decoder. --- dlls/windowscodecs/pngformat.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dlls/windowscodecs/pngformat.c b/dlls/windowscodecs/pngformat.c index 47dfd72..8fa4a47 100644 --- a/dlls/windowscodecs/pngformat.c +++ b/dlls/windowscodecs/pngformat.c @@ -133,8 +133,8 @@ static HRESULT WINAPI PngDecoder_Initialize(IWICBitmapDecoder *iface, IStream *p static HRESULT WINAPI PngDecoder_GetContainerFormat(IWICBitmapDecoder *iface, GUID *pguidContainerFormat) { - FIXME("(%p,%p): stub\n", iface, pguidContainerFormat); - return E_NOTIMPL; + memcpy(pguidContainerFormat, &GUID_ContainerFormatPng, sizeof(GUID)); + return S_OK; } static HRESULT WINAPI PngDecoder_GetDecoderInfo(IWICBitmapDecoder *iface,
1
0
0
0
Vincent Povirk : windowscodecs: Register the PNG decoder.
by Alexandre Julliard
28 Aug '09
28 Aug '09
Module: wine Branch: master Commit: 59810aa4f41da40cd09c46a6bf237545fa3d63df URL:
http://source.winehq.org/git/wine.git/?a=commit;h=59810aa4f41da40cd09c46a6b…
Author: Vincent Povirk <vincent(a)codeweavers.com> Date: Thu Aug 13 16:41:35 2009 -0500 windowscodecs: Register the PNG decoder. --- dlls/windowscodecs/regsvr.c | 36 +++++++++++++++++++++++++++++++++++- 1 files changed, 35 insertions(+), 1 deletions(-) diff --git a/dlls/windowscodecs/regsvr.c b/dlls/windowscodecs/regsvr.c index 12ef7d8..81218b9 100644 --- a/dlls/windowscodecs/regsvr.c +++ b/dlls/windowscodecs/regsvr.c @@ -777,7 +777,7 @@ static struct regsvr_coclass const coclass_list[] = { /*********************************************************************** * decoder list */ -static const BYTE mask_all[] = {0xff,0xff,0xff,0xff,0xff,0xff}; +static const BYTE mask_all[] = {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff}; static const BYTE bmp_magic[] = {0x42,0x4d}; @@ -838,6 +838,30 @@ static struct decoder_pattern const jpeg_patterns[] = { {0} }; +static const BYTE png_magic[] = {137,80,78,71,13,10,26,10}; + +static GUID const * const png_formats[] = { + &GUID_WICPixelFormatBlackWhite, + &GUID_WICPixelFormat2bppGray, + &GUID_WICPixelFormat4bppGray, + &GUID_WICPixelFormat8bppGray, + &GUID_WICPixelFormat16bppGray, + &GUID_WICPixelFormat32bppBGRA, + &GUID_WICPixelFormat64bppRGBA, + &GUID_WICPixelFormat1bppIndexed, + &GUID_WICPixelFormat2bppIndexed, + &GUID_WICPixelFormat4bppIndexed, + &GUID_WICPixelFormat8bppIndexed, + &GUID_WICPixelFormat24bppBGR, + &GUID_WICPixelFormat48bppRGB, + NULL +}; + +static struct decoder_pattern const png_patterns[] = { + {8,0,png_magic,mask_all,0}, + {0} +}; + static struct regsvr_decoder const decoder_list[] = { { &CLSID_WICBmpDecoder, "The Wine Project", @@ -879,6 +903,16 @@ static struct regsvr_decoder const decoder_list[] = { jpeg_formats, jpeg_patterns }, + { &CLSID_WICPngDecoder, + "The Wine Project", + "PNG Decoder", + "1.0.0.0", + &GUID_VendorMicrosoft, + "image/png", + ".png", + png_formats, + png_patterns + }, { NULL } /* list terminator */ };
1
0
0
0
Vincent Povirk : windowscodecs: Add stub PNG decoder.
by Alexandre Julliard
28 Aug '09
28 Aug '09
Module: wine Branch: master Commit: 568c739082d902f595d4717ca9fae046165220c3 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=568c739082d902f595d4717ca…
Author: Vincent Povirk <vincent(a)codeweavers.com> Date: Sat Aug 8 18:49:33 2009 -0500 windowscodecs: Add stub PNG decoder. --- dlls/windowscodecs/Makefile.in | 2 + dlls/windowscodecs/clsfactory.c | 1 + dlls/windowscodecs/pngformat.c | 250 ++++++++++++++++++++++++++++++++ dlls/windowscodecs/regsvr.c | 6 + dlls/windowscodecs/wincodecs_private.h | 1 + 5 files changed, 260 insertions(+), 0 deletions(-) diff --git a/dlls/windowscodecs/Makefile.in b/dlls/windowscodecs/Makefile.in index f7dd011..d78fbf9 100644 --- a/dlls/windowscodecs/Makefile.in +++ b/dlls/windowscodecs/Makefile.in @@ -5,6 +5,7 @@ VPATH = @srcdir@ MODULE = windowscodecs.dll IMPORTLIB = windowscodecs IMPORTS = uuid ole32 advapi32 kernel32 +EXTRAINCL = @PNGINCL@ C_SRCS = \ bmpdecode.c \ @@ -18,6 +19,7 @@ C_SRCS = \ jpegformat.c \ main.c \ palette.c \ + pngformat.c \ propertybag.c \ regsvr.c \ stream.c \ diff --git a/dlls/windowscodecs/clsfactory.c b/dlls/windowscodecs/clsfactory.c index ca4bf05..af3ce51 100644 --- a/dlls/windowscodecs/clsfactory.c +++ b/dlls/windowscodecs/clsfactory.c @@ -44,6 +44,7 @@ typedef struct { static classinfo wic_classes[] = { {&CLSID_WICImagingFactory, ImagingFactory_CreateInstance}, {&CLSID_WICBmpDecoder, BmpDecoder_CreateInstance}, + {&CLSID_WICPngDecoder, PngDecoder_CreateInstance}, {&CLSID_WICBmpEncoder, BmpEncoder_CreateInstance}, {&CLSID_WICGifDecoder, GifDecoder_CreateInstance}, {&CLSID_WICIcoDecoder, IcoDecoder_CreateInstance}, diff --git a/dlls/windowscodecs/pngformat.c b/dlls/windowscodecs/pngformat.c new file mode 100644 index 0000000..47dfd72 --- /dev/null +++ b/dlls/windowscodecs/pngformat.c @@ -0,0 +1,250 @@ +/* + * Copyright 2009 Vincent Povirk for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "config.h" +#include "wine/port.h" + +#include <stdarg.h> + +#ifdef HAVE_PNG_H +#include <png.h> +#endif + +#define COBJMACROS + +#include "windef.h" +#include "winbase.h" +#include "objbase.h" +#include "wincodec.h" + +#include "wincodecs_private.h" + +#include "wine/debug.h" +#include "wine/library.h" + +WINE_DEFAULT_DEBUG_CHANNEL(wincodecs); + +#ifdef SONAME_LIBPNG + +static void *libpng_handle; +#define MAKE_FUNCPTR(f) static typeof(f) * p##f +MAKE_FUNCPTR(png_create_read_struct); +MAKE_FUNCPTR(png_create_info_struct); +#undef MAKE_FUNCPTR + +static void *load_libpng(void) +{ + if((libpng_handle = wine_dlopen(SONAME_LIBPNG, RTLD_NOW, NULL, 0)) != NULL) { + +#define LOAD_FUNCPTR(f) \ + if((p##f = wine_dlsym(libpng_handle, #f, NULL, 0)) == NULL) { \ + libpng_handle = NULL; \ + return NULL; \ + } + LOAD_FUNCPTR(png_create_read_struct); + LOAD_FUNCPTR(png_create_info_struct); + +#undef LOAD_FUNCPTR + } + return libpng_handle; +} + +typedef struct { + const IWICBitmapDecoderVtbl *lpVtbl; + LONG ref; +} PngDecoder; + +static HRESULT WINAPI PngDecoder_QueryInterface(IWICBitmapDecoder *iface, REFIID iid, + void **ppv) +{ + PngDecoder *This = (PngDecoder*)iface; + TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv); + + if (!ppv) return E_INVALIDARG; + + if (IsEqualIID(&IID_IUnknown, iid) || IsEqualIID(&IID_IWICBitmapDecoder, iid)) + { + *ppv = This; + } + else + { + *ppv = NULL; + return E_NOINTERFACE; + } + + IUnknown_AddRef((IUnknown*)*ppv); + return S_OK; +} + +static ULONG WINAPI PngDecoder_AddRef(IWICBitmapDecoder *iface) +{ + PngDecoder *This = (PngDecoder*)iface; + ULONG ref = InterlockedIncrement(&This->ref); + + TRACE("(%p) refcount=%u\n", iface, ref); + + return ref; +} + +static ULONG WINAPI PngDecoder_Release(IWICBitmapDecoder *iface) +{ + PngDecoder *This = (PngDecoder*)iface; + ULONG ref = InterlockedDecrement(&This->ref); + + TRACE("(%p) refcount=%u\n", iface, ref); + + if (ref == 0) + { + HeapFree(GetProcessHeap(), 0, This); + } + + return ref; +} + +static HRESULT WINAPI PngDecoder_QueryCapability(IWICBitmapDecoder *iface, IStream *pIStream, + DWORD *pdwCapability) +{ + FIXME("(%p,%p,%p): stub\n", iface, pIStream, pdwCapability); + return E_NOTIMPL; +} + +static HRESULT WINAPI PngDecoder_Initialize(IWICBitmapDecoder *iface, IStream *pIStream, + WICDecodeOptions cacheOptions) +{ + FIXME("(%p,%p,%x): stub\n", iface, pIStream, cacheOptions); + return E_NOTIMPL; +} + +static HRESULT WINAPI PngDecoder_GetContainerFormat(IWICBitmapDecoder *iface, + GUID *pguidContainerFormat) +{ + FIXME("(%p,%p): stub\n", iface, pguidContainerFormat); + return E_NOTIMPL; +} + +static HRESULT WINAPI PngDecoder_GetDecoderInfo(IWICBitmapDecoder *iface, + IWICBitmapDecoderInfo **ppIDecoderInfo) +{ + FIXME("(%p,%p): stub\n", iface, ppIDecoderInfo); + return E_NOTIMPL; +} + +static HRESULT WINAPI PngDecoder_CopyPalette(IWICBitmapDecoder *iface, + IWICPalette *pIPalette) +{ + FIXME("(%p,%p): stub\n", iface, pIPalette); + return E_NOTIMPL; +} + +static HRESULT WINAPI PngDecoder_GetMetadataQueryReader(IWICBitmapDecoder *iface, + IWICMetadataQueryReader **ppIMetadataQueryReader) +{ + FIXME("(%p,%p): stub\n", iface, ppIMetadataQueryReader); + return E_NOTIMPL; +} + +static HRESULT WINAPI PngDecoder_GetPreview(IWICBitmapDecoder *iface, + IWICBitmapSource **ppIBitmapSource) +{ + FIXME("(%p,%p): stub\n", iface, ppIBitmapSource); + return E_NOTIMPL; +} + +static HRESULT WINAPI PngDecoder_GetColorContexts(IWICBitmapDecoder *iface, + UINT cCount, IWICColorContext **ppIColorContexts, UINT *pcActualCount) +{ + FIXME("(%p,%u,%p,%p)\n", iface, cCount, ppIColorContexts, pcActualCount); + return E_NOTIMPL; +} + +static HRESULT WINAPI PngDecoder_GetThumbnail(IWICBitmapDecoder *iface, + IWICBitmapSource **ppIThumbnail) +{ + TRACE("(%p,%p)\n", iface, ppIThumbnail); + return WINCODEC_ERR_CODECNOTHUMBNAIL; +} + +static HRESULT WINAPI PngDecoder_GetFrameCount(IWICBitmapDecoder *iface, + UINT *pCount) +{ + FIXME("(%p,%p): stub\n", iface, pCount); + return E_NOTIMPL; +} + +static HRESULT WINAPI PngDecoder_GetFrame(IWICBitmapDecoder *iface, + UINT index, IWICBitmapFrameDecode **ppIBitmapFrame) +{ + FIXME("(%p,%u,%p): stub\n", iface, index, ppIBitmapFrame); + return E_NOTIMPL; +} + +static const IWICBitmapDecoderVtbl PngDecoder_Vtbl = { + PngDecoder_QueryInterface, + PngDecoder_AddRef, + PngDecoder_Release, + PngDecoder_QueryCapability, + PngDecoder_Initialize, + PngDecoder_GetContainerFormat, + PngDecoder_GetDecoderInfo, + PngDecoder_CopyPalette, + PngDecoder_GetMetadataQueryReader, + PngDecoder_GetPreview, + PngDecoder_GetColorContexts, + PngDecoder_GetThumbnail, + PngDecoder_GetFrameCount, + PngDecoder_GetFrame +}; + +HRESULT PngDecoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv) +{ + PngDecoder *This; + HRESULT ret; + + TRACE("(%p,%s,%p)\n", pUnkOuter, debugstr_guid(iid), ppv); + + *ppv = NULL; + + if (pUnkOuter) return CLASS_E_NOAGGREGATION; + + if (!libpng_handle && !load_libpng()) + { + ERR("Failed reading PNG because unable to find %s\n",SONAME_LIBPNG); + return E_FAIL; + } + + This = HeapAlloc(GetProcessHeap(), 0, sizeof(PngDecoder)); + if (!This) return E_OUTOFMEMORY; + + This->lpVtbl = &PngDecoder_Vtbl; + This->ref = 1; + + ret = IUnknown_QueryInterface((IUnknown*)This, iid, ppv); + IUnknown_Release((IUnknown*)This); + + return ret; +} + +#else /* !HAVE_PNG_H */ + +HRESULT PngDecoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv) +{ + ERR("Trying to load PNG picture, but PNG supported not compiled in.\n"); + return E_FAIL; +} + +#endif diff --git a/dlls/windowscodecs/regsvr.c b/dlls/windowscodecs/regsvr.c index 2ee1a89..12ef7d8 100644 --- a/dlls/windowscodecs/regsvr.c +++ b/dlls/windowscodecs/regsvr.c @@ -735,6 +735,12 @@ static struct regsvr_coclass const coclass_list[] = { "windowscodecs.dll", "Apartment" }, + { &CLSID_WICPngDecoder, + "WIC PNG Decoder", + NULL, + "windowscodecs.dll", + "Apartment" + }, { &CLSID_WICBmpEncoder, "WIC BMP Encoder", NULL, diff --git a/dlls/windowscodecs/wincodecs_private.h b/dlls/windowscodecs/wincodecs_private.h index e03b6c4..de719d2 100644 --- a/dlls/windowscodecs/wincodecs_private.h +++ b/dlls/windowscodecs/wincodecs_private.h @@ -22,6 +22,7 @@ extern HRESULT FormatConverter_CreateInstance(IUnknown *pUnkOuter, REFIID riid, void** ppv); extern HRESULT ImagingFactory_CreateInstance(IUnknown *pUnkOuter, REFIID riid, void** ppv); extern HRESULT BmpDecoder_CreateInstance(IUnknown *pUnkOuter, REFIID riid, void** ppv); +extern HRESULT PngDecoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv); extern HRESULT BmpEncoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv); extern HRESULT GifDecoder_CreateInstance(IUnknown *pUnkOuter, REFIID riid, void** ppv); extern HRESULT IcoDecoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv);
1
0
0
0
Vincent Povirk : include: Add WIC pixel formats needed for PNG.
by Alexandre Julliard
28 Aug '09
28 Aug '09
Module: wine Branch: master Commit: bf13be2000dbe7e286069573f846df9718fc6ed2 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=bf13be2000dbe7e286069573f…
Author: Vincent Povirk <vincent(a)codeweavers.com> Date: Tue Aug 18 17:54:22 2009 -0500 include: Add WIC pixel formats needed for PNG. --- include/wincodec.idl | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) diff --git a/include/wincodec.idl b/include/wincodec.idl index b2d7cff..06475b0 100644 --- a/include/wincodec.idl +++ b/include/wincodec.idl @@ -126,7 +126,11 @@ cpp_quote("DEFINE_GUID(GUID_WICPixelFormat2bppIndexed, 0x6fddc324,0x4e03,0x4bfe, cpp_quote("DEFINE_GUID(GUID_WICPixelFormat4bppIndexed, 0x6fddc324,0x4e03,0x4bfe,0xb1,0x85,0x3d,0x77,0x76,0x8d,0xc9,0x03);") cpp_quote("DEFINE_GUID(GUID_WICPixelFormat8bppIndexed, 0x6fddc324,0x4e03,0x4bfe,0xb1,0x85,0x3d,0x77,0x76,0x8d,0xc9,0x04);") +cpp_quote("DEFINE_GUID(GUID_WICPixelFormatBlackWhite, 0x6fddc324,0x4e03,0x4bfe,0xb1,0x85,0x3d,0x77,0x76,0x8d,0xc9,0x05);") +cpp_quote("DEFINE_GUID(GUID_WICPixelFormat2bppGray, 0x6fddc324,0x4e03,0x4bfe,0xb1,0x85,0x3d,0x77,0x76,0x8d,0xc9,0x06);") +cpp_quote("DEFINE_GUID(GUID_WICPixelFormat4bppGray, 0x6fddc324,0x4e03,0x4bfe,0xb1,0x85,0x3d,0x77,0x76,0x8d,0xc9,0x07);") cpp_quote("DEFINE_GUID(GUID_WICPixelFormat8bppGray, 0x6fddc324,0x4e03,0x4bfe,0xb1,0x85,0x3d,0x77,0x76,0x8d,0xc9,0x08);") +cpp_quote("DEFINE_GUID(GUID_WICPixelFormat16bppGray, 0x6fddc324,0x4e03,0x4bfe,0xb1,0x85,0x3d,0x77,0x76,0x8d,0xc9,0x0b);") cpp_quote("DEFINE_GUID(GUID_WICPixelFormat16bppBGR555, 0x6fddc324,0x4e03,0x4bfe,0xb1,0x85,0x3d,0x77,0x76,0x8d,0xc9,0x09);") cpp_quote("DEFINE_GUID(GUID_WICPixelFormat16bppBGR565, 0x6fddc324,0x4e03,0x4bfe,0xb1,0x85,0x3d,0x77,0x76,0x8d,0xc9,0x0a);") @@ -135,6 +139,9 @@ cpp_quote("DEFINE_GUID(GUID_WICPixelFormat32bppBGR, 0x6fddc324,0x4e03,0x4bfe,0xb cpp_quote("DEFINE_GUID(GUID_WICPixelFormat32bppBGRA, 0x6fddc324,0x4e03,0x4bfe,0xb1,0x85,0x3d,0x77,0x76,0x8d,0xc9,0x0f);") cpp_quote("DEFINE_GUID(GUID_WICPixelFormat32bppPBGRA, 0x6fddc324,0x4e03,0x4bfe,0xb1,0x85,0x3d,0x77,0x76,0x8d,0xc9,0x10);") +cpp_quote("DEFINE_GUID(GUID_WICPixelFormat48bppRGB, 0x6fddc324,0x4e03,0x4bfe,0xb1,0x85,0x3d,0x77,0x76,0x8d,0xc9,0x15);") +cpp_quote("DEFINE_GUID(GUID_WICPixelFormat64bppRGBA, 0x6fddc324,0x4e03,0x4bfe,0xb1,0x85,0x3d,0x77,0x76,0x8d,0xc9,0x16);") + typedef struct WICRect { INT X; INT Y;
1
0
0
0
Jacek Caban : jscript: Added RegExp.test implementation.
by Alexandre Julliard
28 Aug '09
28 Aug '09
Module: wine Branch: master Commit: 39521de78404146d7dd9795f333f51f076e916e5 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=39521de78404146d7dd9795f3…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Thu Aug 27 21:34:20 2009 +0200 jscript: Added RegExp.test implementation. --- dlls/jscript/regexp.c | 17 +++++++++++++++-- dlls/jscript/tests/regexp.js | 20 ++++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/dlls/jscript/regexp.c b/dlls/jscript/regexp.c index 5c473d4..b675008 100644 --- a/dlls/jscript/regexp.c +++ b/dlls/jscript/regexp.c @@ -3646,8 +3646,21 @@ static HRESULT RegExp_exec(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS static HRESULT RegExp_test(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp) { - FIXME("\n"); - return E_NOTIMPL; + match_result_t match; + VARIANT_BOOL b; + HRESULT hres; + + TRACE("\n"); + + hres = run_exec(dispex, arg_cnt(dp) ? get_arg(dp,0) : NULL, lcid, ei, NULL, &match, NULL, NULL, &b); + if(FAILED(hres)) + return hres; + + if(retv) { + V_VT(retv) = VT_BOOL; + V_BOOL(retv) = b; + } + return S_OK; } static HRESULT RegExp_value(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp, diff --git a/dlls/jscript/tests/regexp.js b/dlls/jscript/tests/regexp.js index 27c1afb..a839adb 100644 --- a/dlls/jscript/tests/regexp.js +++ b/dlls/jscript/tests/regexp.js @@ -71,6 +71,26 @@ m = re.exec(); ok(m === null, "m is not null"); ok(re.lastIndex === 0, "re.lastIndex = " + re.lastIndex); +b = re.test(" a "); +ok(b === true, "re.test(' a ') returned " + b); +ok(re.lastIndex === 3, "re.lastIndex = " + re.lastIndex); + +b = re.test(" a "); +ok(b === false, "re.test(' a ') returned " + b); +ok(re.lastIndex === 0, "re.lastIndex = " + re.lastIndex); + +re = /\[([^\[]+)\]/g; +m = re.exec(" [test] "); +ok(re.lastIndex === 7, "re.lastIndex = " + re.lastIndex); +ok(m.index === 1, "m.index = " + m.index); +ok(m.input === " [test] ", "m.input = " + m.input); +ok(m.length === 2, "m.length = " + m.length); +ok(m[0] === "[test]", "m[0] = " + m[0]); +ok(m[1] === "test", "m[1] = " + m[1]); + +b = /a*/.test(); +ok(b === true, "/a*/.test() returned " + b); + m = "abcabc".match(/ca/); ok(typeof(m) === "object", "typeof m is not object"); ok(m.length === 1, "m.length is not 1");
1
0
0
0
Jacek Caban : jscript: Added RegExp.exec implementation.
by Alexandre Julliard
28 Aug '09
28 Aug '09
Module: wine Branch: master Commit: 132009469c4f7f275b1b5deb1b48a11ace46373e URL:
http://source.winehq.org/git/wine.git/?a=commit;h=132009469c4f7f275b1b5deb1…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Thu Aug 27 21:34:01 2009 +0200 jscript: Added RegExp.exec implementation. --- dlls/jscript/regexp.c | 144 +++++++++++++++++++++++++++++++++++++++++- dlls/jscript/tests/regexp.js | 51 +++++++++++++++- 2 files changed, 192 insertions(+), 3 deletions(-) diff --git a/dlls/jscript/regexp.c b/dlls/jscript/regexp.c index 754de36..5c473d4 100644 --- a/dlls/jscript/regexp.c +++ b/dlls/jscript/regexp.c @@ -3496,11 +3496,151 @@ static HRESULT RegExp_toString(DispatchEx *dispex, LCID lcid, WORD flags, DISPPA return E_NOTIMPL; } +static HRESULT create_match_array(script_ctx_t *ctx, BSTR input, const match_result_t *result, + const match_result_t *parens, DWORD parens_cnt, LCID lcid, jsexcept_t *ei, IDispatch **ret) +{ + DispatchEx *array; + VARIANT var; + int i; + HRESULT hres = S_OK; + + static const WCHAR indexW[] = {'i','n','d','e','x',0}; + static const WCHAR inputW[] = {'i','n','p','u','t',0}; + static const WCHAR zeroW[] = {'0',0}; + + hres = create_array(ctx, parens_cnt+1, &array); + if(FAILED(hres)) + return hres; + + for(i=0; i < parens_cnt; i++) { + V_VT(&var) = VT_BSTR; + V_BSTR(&var) = SysAllocStringLen(parens[i].str, parens[i].len); + if(!V_BSTR(&var)) { + hres = E_OUTOFMEMORY; + break; + } + + hres = jsdisp_propput_idx(array, i+1, lcid, &var, ei, NULL/*FIXME*/); + SysFreeString(V_BSTR(&var)); + if(FAILED(hres)) + break; + } + + while(SUCCEEDED(hres)) { + V_VT(&var) = VT_I4; + V_I4(&var) = result->str-input; + hres = jsdisp_propput_name(array, indexW, lcid, &var, ei, NULL/*FIXME*/); + if(FAILED(hres)) + break; + + V_VT(&var) = VT_BSTR; + V_BSTR(&var) = input; + hres = jsdisp_propput_name(array, inputW, lcid, &var, ei, NULL/*FIXME*/); + if(FAILED(hres)) + break; + + V_BSTR(&var) = SysAllocStringLen(result->str, result->len); + if(!V_BSTR(&var)) { + hres = E_OUTOFMEMORY; + break; + } + hres = jsdisp_propput_name(array, zeroW, lcid, &var, ei, NULL/*FIXME*/); + SysFreeString(V_BSTR(&var)); + break; + } + + if(FAILED(hres)) { + jsdisp_release(array); + return hres; + } + + *ret = (IDispatch*)_IDispatchEx_(array); + return S_OK; +} + +static HRESULT run_exec(DispatchEx *dispex, VARIANT *arg, LCID lcid, jsexcept_t *ei, BSTR *input, + match_result_t *match, match_result_t **parens, DWORD *parens_cnt, VARIANT_BOOL *ret) +{ + RegExpInstance *regexp; + DWORD parens_size = 0, last_index = 0, length; + const WCHAR *cp; + BSTR string; + HRESULT hres; + + if(!is_class(dispex, JSCLASS_REGEXP)) { + FIXME("Not a RegExp\n"); + return E_NOTIMPL; + } + + regexp = (RegExpInstance*)dispex; + + if(arg) { + hres = to_string(regexp->dispex.ctx, arg, ei, &string); + if(FAILED(hres)) + return hres; + }else { + string = SysAllocStringLen(NULL, 0); + if(!string) + return E_OUTOFMEMORY; + } + + length = SysStringLen(string); + if(regexp->jsregexp->flags & JSREG_GLOB) + last_index = regexp->last_index; + + cp = string + last_index; + hres = regexp_match_next(®exp->dispex, FALSE, string, length, &cp, parens, parens ? &parens_size : NULL, + parens_cnt, match); + if(FAILED(hres)) { + SysFreeString(string); + return hres; + } + + if(hres == S_OK) { + regexp->last_index = cp-string; + *ret = VARIANT_TRUE; + }else { + regexp->last_index = 0; + *ret = VARIANT_FALSE; + } + + if(input) + *input = string; + return S_OK; +} + static HRESULT RegExp_exec(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp) { - FIXME("\n"); - return E_NOTIMPL; + match_result_t *parens = NULL, match; + DWORD parens_cnt = 0; + VARIANT_BOOL b; + BSTR string; + HRESULT hres; + + TRACE("\n"); + + hres = run_exec(dispex, arg_cnt(dp) ? get_arg(dp,0) : NULL, lcid, ei, &string, &match, &parens, &parens_cnt, &b); + if(FAILED(hres)) + return hres; + + if(retv) { + if(b) { + IDispatch *ret; + + hres = create_match_array(dispex->ctx, string, &match, parens, parens_cnt, lcid, ei, &ret); + if(SUCCEEDED(hres)) { + V_VT(retv) = VT_DISPATCH; + V_DISPATCH(retv) = ret; + } + }else { + V_VT(retv) = VT_NULL; + } + } + + heap_free(parens); + SysFreeString(string); + return hres; } static HRESULT RegExp_test(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp, diff --git a/dlls/jscript/tests/regexp.js b/dlls/jscript/tests/regexp.js index b246284..27c1afb 100644 --- a/dlls/jscript/tests/regexp.js +++ b/dlls/jscript/tests/regexp.js @@ -17,11 +17,60 @@ */ -var m, re; +var m, re, b; re = /a+/; ok(re.lastIndex === 0, "re.lastIndex = " + re.lastIndex); +m = re.exec(" aabaaa"); +ok(re.lastIndex === 3, "re.lastIndex = " + re.lastIndex); +ok(m.index === 1, "m.index = " + m.index); +ok(m.input === " aabaaa", "m.input = " + m.input); +ok(m.length === 1, "m.length = " + m.length); +ok(m[0] === "aa", "m[0] = " + m[0]); + +m = re.exec(" aabaaa"); +ok(re.lastIndex === 3, "re.lastIndex = " + re.lastIndex); +ok(m.index === 1, "m.index = " + m.index); +ok(m.input === " aabaaa", "m.input = " + m.input); +ok(m.length === 1, "m.length = " + m.length); +ok(m[0] === "aa", "m[0] = " + m[0]); + +re = /a+/g; +ok(re.lastIndex === 0, "re.lastIndex = " + re.lastIndex); + +m = re.exec(" aabaaa"); +ok(re.lastIndex === 3, "re.lastIndex = " + re.lastIndex); +ok(m.index === 1, "m.index = " + m.index); +ok(m.input === " aabaaa", "m.input = " + m.input); +ok(m.length === 1, "m.length = " + m.length); +ok(m[0] === "aa", "m[0] = " + m[0]); + +m = re.exec(" aabaaa"); +ok(re.lastIndex === 7, "re.lastIndex = " + re.lastIndex); +ok(m.index === 4, "m.index = " + m.index); +ok(m.input === " aabaaa", "m.input = " + m.input); +ok(m.length === 1, "m.length = " + m.length); +ok(m[0] === "aaa", "m[0] = " + m[0]); + +m = re.exec(" aabaaa"); +ok(re.lastIndex === 0, "re.lastIndex = " + re.lastIndex); +ok(m === null, "m is not null"); + +re.exec(" a"); +ok(re.lastIndex === 16, "re.lastIndex = " + re.lastIndex); + +m = re.exec(" a"); +ok(m === null, "m is not null"); +ok(re.lastIndex === 0, "re.lastIndex = " + re.lastIndex); + +m = re.exec(" a"); +ok(re.lastIndex === 2, "re.lastIndex = " + re.lastIndex); + +m = re.exec(); +ok(m === null, "m is not null"); +ok(re.lastIndex === 0, "re.lastIndex = " + re.lastIndex); + m = "abcabc".match(/ca/); ok(typeof(m) === "object", "typeof m is not object"); ok(m.length === 1, "m.length is not 1");
1
0
0
0
Jacek Caban : jscript: Added RegExp.lastIndex implementation.
by Alexandre Julliard
28 Aug '09
28 Aug '09
Module: wine Branch: master Commit: 0b939338c86eb0e30c5ca975db781185069a63d6 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=0b939338c86eb0e30c5ca975d…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Thu Aug 27 21:33:32 2009 +0200 jscript: Added RegExp.lastIndex implementation. --- dlls/jscript/regexp.c | 18 ++++++++++++++++-- dlls/jscript/tests/regexp.js | 7 ++++--- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/dlls/jscript/regexp.c b/dlls/jscript/regexp.c index 1f874e2..754de36 100644 --- a/dlls/jscript/regexp.c +++ b/dlls/jscript/regexp.c @@ -82,6 +82,7 @@ typedef struct { JSRegExp *jsregexp; BSTR str; + DWORD last_index; } RegExpInstance; static const WCHAR sourceW[] = {'s','o','u','r','c','e',0}; @@ -3471,8 +3472,21 @@ static HRESULT RegExp_multiline(DispatchEx *dispex, LCID lcid, WORD flags, DISPP static HRESULT RegExp_lastIndex(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp) { - FIXME("\n"); - return E_NOTIMPL; + TRACE("\n"); + + switch(flags) { + case DISPATCH_PROPERTYGET: { + RegExpInstance *regexp = (RegExpInstance*)dispex; + V_VT(retv) = VT_I4; + V_I4(retv) = regexp->last_index; + break; + } + default: + FIXME("unimplemented flags: %x\n", flags); + return E_NOTIMPL; + } + + return S_OK; } static HRESULT RegExp_toString(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp, diff --git a/dlls/jscript/tests/regexp.js b/dlls/jscript/tests/regexp.js index 4d6e60d..b246284 100644 --- a/dlls/jscript/tests/regexp.js +++ b/dlls/jscript/tests/regexp.js @@ -17,7 +17,10 @@ */ -var m; +var m, re; + +re = /a+/; +ok(re.lastIndex === 0, "re.lastIndex = " + re.lastIndex); m = "abcabc".match(/ca/); ok(typeof(m) === "object", "typeof m is not object"); @@ -208,8 +211,6 @@ ok(r.length === 2, "r.length = " + r.length); ok(r[0] === "1", "r[0] = " + r[0]); ok(r[1] === "2", "r[1] = " + r[1]); -var re; - re = /abc[^d]/g; ok(re.source === "abc[^d]", "re.source = '" + re.source + "', expected 'abc[^d]'");
1
0
0
0
Andrew Eikum : ole32: Overwrite previous CompObj instead of failing.
by Alexandre Julliard
28 Aug '09
28 Aug '09
Module: wine Branch: master Commit: a0d262c545ef23bbdf739021daba446a66ccc752 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=a0d262c545ef23bbdf739021d…
Author: Andrew Eikum <aeikum(a)codeweavers.com> Date: Thu Aug 27 13:03:26 2009 -0500 ole32: Overwrite previous CompObj instead of failing. --- dlls/ole32/storage32.c | 4 +- dlls/ole32/tests/storage32.c | 66 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 2 deletions(-) diff --git a/dlls/ole32/storage32.c b/dlls/ole32/storage32.c index b06578b..ac53510 100644 --- a/dlls/ole32/storage32.c +++ b/dlls/ole32/storage32.c @@ -7193,9 +7193,9 @@ static HRESULT STORAGE_WriteCompObj( LPSTORAGE pstg, CLSID *clsid, debugstr_w(lpszUserType), debugstr_w(szClipName), debugstr_w(szProgIDName)); - /* Create a CompObj stream if it doesn't exist */ + /* Create a CompObj stream */ r = IStorage_CreateStream(pstg, szwStreamName, - STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &pstm ); + STGM_CREATE | STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &pstm ); if( FAILED (r) ) return r; diff --git a/dlls/ole32/tests/storage32.c b/dlls/ole32/tests/storage32.c index 5fef82c..fec854e 100644 --- a/dlls/ole32/tests/storage32.c +++ b/dlls/ole32/tests/storage32.c @@ -1405,6 +1405,71 @@ static void test_simple(void) DeleteFileA(filenameA); } +static void test_fmtusertypestg(void) +{ + IStorage *stg; + IEnumSTATSTG *stat; + HRESULT hr; + static const WCHAR fileW[] = {'f','m','t','t','e','s','t',0}; + static WCHAR userTypeW[] = {'S','t','g','U','s','r','T','y','p','e',0}; + static WCHAR strmNameW[] = {1,'C','o','m','p','O','b','j',0}; + + hr = StgCreateDocfile( fileW, STGM_CREATE | STGM_SHARE_EXCLUSIVE | STGM_READWRITE, 0, &stg); + ok(hr == S_OK, "should succeed, res=%x\n", hr); + + if (SUCCEEDED(hr)) + { + /* try to write the stream */ + hr = WriteFmtUserTypeStg(stg, 0, userTypeW); + ok(hr == S_OK, "should succeed, res=%x\n", hr); + + /* check that the stream was created */ + hr = IStorage_EnumElements(stg, 0, NULL, 0, &stat); + ok(hr == S_OK, "should succeed, res=%x\n", hr); + if (SUCCEEDED(hr)) + { + BOOL found = FALSE; + STATSTG statstg; + DWORD got; + while ((hr = IEnumSTATSTG_Next(stat, 1, &statstg, &got)) == S_OK && got == 1) + { + if (lstrcmpW(statstg.pwcsName, strmNameW) == 0) + found = TRUE; + else + ok(0, "found unexpected stream or storage\n"); + } + ok(found == TRUE, "expected storage to contain stream \\0001CompObj\n"); + IEnumSTATSTG_Release(stat); + } + + /* re-write the stream */ + hr = WriteFmtUserTypeStg(stg, 0, userTypeW); + ok(hr == S_OK, "should succeed, res=%x\n", hr); + + /* check that the stream is still there */ + hr = IStorage_EnumElements(stg, 0, NULL, 0, &stat); + ok(hr == S_OK, "should succeed, res=%x\n", hr); + if (SUCCEEDED(hr)) + { + BOOL found = FALSE; + STATSTG statstg; + DWORD got; + while ((hr = IEnumSTATSTG_Next(stat, 1, &statstg, &got)) == S_OK && got == 1) + { + if (lstrcmpW(statstg.pwcsName, strmNameW) == 0) + found = TRUE; + else + ok(0, "found unexpected stream or storage\n"); + } + ok(found == TRUE, "expected storage to contain stream \\0001CompObj\n"); + IEnumSTATSTG_Release(stat); + } + + IStorage_Release(stg); + DeleteFileW( fileW ); + } +} + START_TEST(storage32) { CHAR temp[MAX_PATH]; @@ -1431,4 +1496,5 @@ START_TEST(storage32) test_writeclassstg(); test_readonly(); test_simple(); + test_fmtusertypestg(); }
1
0
0
0
← Newer
1
...
10
11
12
13
14
15
16
...
105
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
Results per page:
10
25
50
100
200