On 5/14/2014 09:56, Henri Verbeet wrote:
+[
- local,
- object,
- uuid(a2296057-ea42-4099-983b-539fb6505426)
+] +interface ID2D1Bitmap : ID2D1Image +{
- D2D1_SIZE_F GetSize();
- D2D1_SIZE_U GetPixelSize();
- D2D1_PIXEL_FORMAT GetPixelFormat();
- void GetDpi(
[out] float *dpi_x,
[out] float *dpi_y
- );
- HRESULT CopyFromBitmap(
[in, optional] const D2D1_POINT_2U *dst_point,
[in] ID2D1Bitmap *bitmap,
[in, optional] const D2D1_RECT_U *src_rect
- );
- HRESULT CopyFromRenderTarget(
[in, optional] const D2D1_POINT_2U *dst_point,
[in] ID2D1RenderTarget *render_target,
[in, optional] const D2D1_RECT_U *src_rect
- );
- HRESULT CopyFromMemory(
[in, optional] const D2D1_RECT_U *dst_rect,
[in] const void *src_data,
[in] UINT32 pitch
- );
+}
I don't think it makes sense to match msdn here regarding [optional] attribute, and that's why:
- 'optional' without 'defaultvalue' has no effect on headers, as far as I can see; - you can't mix 'optional' with required arguments like that, midl will refuse to process such idl, optional arguments should be at the end of arguments list only; - msdn says that it only applies to VARIANT and VARIANT* types, not sure about that, probably it's meant to talk about typelib generation only. And we don't need a typelib for d2d1 anyway.
It makes sense imo to eventually make widl more midl-compliant adding similar consistency checks, like 'optional' position, also duplicated guids in typelibs come to mind.
It's up to you to keep it as it is, just pointing out potential problems.
On 14 May 2014 08:26, Nikolay Sivov bunglehead@gmail.com wrote:
I don't think it makes sense to match msdn here regarding [optional] attribute, and that's why:
- 'optional' without 'defaultvalue' has no effect on headers, as far as I
can see;
- you can't mix 'optional' with required arguments like that, midl will
refuse to process such idl, optional arguments should be at the end of arguments list only;
I didn't try processing this with midl myself, but are you quite sure about that? The d2d1.h in the PSDK has these annotated with "_In_opt_", and presumably it's generated with midl.
On 5/14/2014 12:05, Henri Verbeet wrote:
On 14 May 2014 08:26, Nikolay Sivov bunglehead@gmail.com wrote:
I don't think it makes sense to match msdn here regarding [optional] attribute, and that's why:
- 'optional' without 'defaultvalue' has no effect on headers, as far as I
can see;
- you can't mix 'optional' with required arguments like that, midl will
refuse to process such idl, optional arguments should be at the end of arguments list only;
I didn't try processing this with midl myself, but are you quite sure about that?
Yes, I tested that some time ago, and double-checked just now. Method like this:
--- HRESULT method([in, optional] float arg, [in] float arg2); ---
produces midl error 2090:
.\test_tlb.idl(44) : error MIDL2090 : optional parameters must come after required parameters : [ Procedure 'method' ( Interface 'Iiface' ) ]
The d2d1.h in the PSDK has these annotated with "_In_opt_", and presumably it's generated with midl.
These are manually added I believe, it's a part of so called annotation language or SAL (http://msdn.microsoft.com/en-us/library/ms182032.aspx). It's kind of markers for static analysers, this page says it's available starting VS 2005.
On 14 May 2014 10:19, Nikolay Sivov bunglehead@gmail.com wrote:
Yes, I tested that some time ago, and double-checked just now. Method like this:
HRESULT method([in, optional] float arg, [in] float arg2);
produces midl error 2090:
.\test_tlb.idl(44) : error MIDL2090 : optional parameters must come after required parameters : [ Procedure 'method' ( Interface 'Iiface' ) ]
A pointer type would perhaps have been more interesting than float, but I guess I'll remove the "optional" attributes then.
On 5/14/2014 13:09, Henri Verbeet wrote:
On 14 May 2014 10:19, Nikolay Sivov bunglehead@gmail.com wrote:
Yes, I tested that some time ago, and double-checked just now. Method like this:
HRESULT method([in, optional] float arg, [in] float arg2);
produces midl error 2090:
.\test_tlb.idl(44) : error MIDL2090 : optional parameters must come after required parameters : [ Procedure 'method' ( Interface 'Iiface' ) ]
A pointer type would perhaps have been more interesting than float, but I guess I'll remove the "optional" attributes then. .
Same happens with pointer types, I just checked.
On 05/14/14 10:05, Henri Verbeet wrote:
The d2d1.h in the PSDK has these annotated with "_In_opt_", and presumably it's generated with midl.
FWIW, I'm pretty sure it's not. It contains a lot of things that would be tricky or impossible to do with widl, like C++ default argument values or overloaded inline functions wrappers around vtbl-based functions. They even invented a new way of declaring C vtbl structs, which contain parent's struct in the beginning, instead of duplicating all functions.
I guess that it was decided that having a clean IDL is more important than being compatible with MS in this case. Otherwise mingw-w64 version would be available to port to Wine (some related headers may be still useful): http://repo.or.cz/w/mingw-w64/jacek.git/blob/HEAD:/mingw-w64-headers/include...
Cheers, Jacek
On 14 May 2014 11:03, Jacek Caban jacek@codeweavers.com wrote:
FWIW, I'm pretty sure it's not. It contains a lot of things that would be tricky or impossible to do with widl, like C++ default argument values or overloaded inline functions wrappers around vtbl-based functions. They even invented a new way of declaring C vtbl structs, which contain parent's struct in the beginning, instead of duplicating all functions.
I had noticed those, but assumed it was just something newer midl versions could do, since I don't generally follow what happens with midl very closely.