sharpdx / SharpDX

SharpDX GitHub Repository
http://sharpdx.org
MIT License
1.69k stars 638 forks source link

[Animation] Problem with KeyFrame #928

Open spellizzari opened 7 years ago

spellizzari commented 7 years ago

Description of the problem There is a problem with how UI_ANIMATION_KEYFRAME is mapped in SharpDX.Animation.

In UIAnimation.h, UI_ANIMATION_KEYFRAME is defined as a pointer to an opaque structure (__MIDL___MIDL_itf_UIAnimation_0000_0002_0003), and UI_ANIMATION_KEYFRAME_STORYBOARD_STARTis defined as a pointer of value -1.

In SharpDX.Animation, UI_ANIMATION_KEYFRAME is not mapped directly. Instead, the type __MIDL___MIDL_itf_UIAnimation_0000_0002_0003 is mapped to a structure KeyFrame which contains a single field of type IntPtr.

The problem is that COM methods with parameters of type UI_ANIMATION_KEYFRAME are recognized by the mapper as pointers to __MIDL___MIDL_itf_UIAnimation_0000_0002_0003 structures, and therefore the generated code for these methods don't pass the value of the IntPtr field of the mapped KeyFrame parameter, but pass instead a pointer to the KeyFrame structure, which is invalid.

Solution

The solution, but I'm not sure how it must be implemented via the mapping system, would be to keep the KeyFrame type as it is now, but force the mapper to generate code for methods with UI_ANIMATION_KEYFRAME parameters that pass the inner IntPtr by copy instead of passing a pointer to the KeyFrame value.