[Mono-dev] Problem with Marshing c arrays as UnmanagedType.LPArray using SizeParamIndex when doing Native -> Managed COM method calls.

Tom Hindle tom_hindle at sil.org
Fri Jun 12 14:27:40 EDT 2009


Robert,

You patch alone (without changing cominterop_get_native_wrapper_adjusted
as well) fixes my test cases.

(as my test cases are doing native->managed with respect to array
marshaling)


Thanks
Tom

On Fri, 2009-06-12 at 20:08 +0200, Robert Jordan wrote:
> Tom Hindle wrote:
> > When checking param index type (which is 1 as SizeParamIndex == 1)
> > (about line 6778) the Array itself is being checked (byte[] pv) as
> > m->sig has had and extra parameter inserted at the beginning of its
> > parameter list. (which I assume is for communicating the HRESULT return
> > value back to the C++ as this is a COM method call.)
> 
> It's the converted "this" arg of the managed sig at the front
> of the unmanaged sig.
> 
> > Could someone tell me if this is the correct place to adjust the
> > param_num or should 
> > spec->data.array_data.param_num be expected to contain the adjusted
> > value?
> 
> There are apparently 2 places in cominterop.c where
> spec->data.array_data.param_num has to be increased by one.
> 
> The attached patch is fixing one place, but there seems
> to be another one in cominterop_get_native_wrapper_adjusted.
> 
> Please try it out as I don't have a test case.
> 
> Robert
> 
> plain text document attachment (cominterop.diff)
> Index: cominterop.c
> ===================================================================
> --- cominterop.c	(revision 135665)
> +++ cominterop.c	(working copy)
> @@ -1917,6 +1917,12 @@
>  						mspecs[mspec_index] = g_new0 (MonoMarshalSpec, 1);
>  						mspecs[mspec_index]->native = MONO_NATIVE_VARIANTBOOL;
>  					}
> +				} else {
> +					/* increase SizeParamIndex because we've added a param */
> +					if (sig_adjusted->params[param_index]->type == MONO_TYPE_ARRAY ||
> +					    sig_adjusted->params[param_index]->type == MONO_TYPE_SZARRAY)
> +						if (mspecs[mspec_index]->data.array_data.param_num != -1)
> +							mspecs[mspec_index]->data.array_data.param_num++;
>  				}
>  			}
>  
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list



More information about the Mono-devel-list mailing list