[Mono-dev] [PATCH] Marshaling bools native->managed

Bill Holmes billholmes54 at gmail.com
Thu Feb 12 11:13:30 EST 2009


Hi,

After discussing this patch with Zoltan last night on IRC we decided
to make two variations of this patch.  One for the trunk and one for
the 2.4 branch.  The reasoning being that we should not change the
default behavior of marshaling bools from native to managed this close
to the branch release.  For the trunk patch we will now marshal bools
as 32-bit integers by default and for the branch we will continue to
marshal bools as bytes as it has been done in the past.  In both
patches if a MarshalAs attribute is specified it will now be
processed.

This patch does affect all calls from native to managed that include
bool arguments and is not exclusive to COM.

-bill

trunk:
2009-02-13  Bill Holmes  <billholmes54 at gmail.com>

	* object-internals.h : Fixing a typo in the
	  MonoReflectionComVisibleAttribute struct.

	* marshal.c (cominterop_com_visible): Check the implemented
	  interfaces for ComImport.

	* marshal.c (cominterop_get_native_wrapper_adjusted): For COM calls
	  assume that bools should be treated as VARIANTBOOLs.

	* marshal.c (emit_marshal_boolean): Adding cases for
	  MARSHAL_ACTION_MANAGED_CONV_IN and MARSHAL_ACTION_MANAGED_CONV_OUT.

	* marshal.c (mono_marshal_emit_managed_wrapper): Adding calls to
	  emit_marshal MARSHAL_ACTION_MANAGED_CONV_IN and OUT for bools.

	* marshal.c (cominterop_get_ccw): For COM calls assume that bools
	  should be treated as VARIANTBOOLs.	

	Code is contributed under MIT/X11 license.

branch:
2009-02-13  Bill Holmes  <billholmes54 at gmail.com>

	Backport of r(fill in later).  This is a safer variant of the
	  trunk for the 2.4 branch. The default in emit_marshal_boolean
	  for this version is I1.

	* object-internals.h : Fixing a typo in the
	  MonoReflectionComVisibleAttribute struct.

	* marshal.c (cominterop_com_visible): Check the implemented
	  interfaces for ComImport.

	* marshal.c (cominterop_get_native_wrapper_adjusted): For COM calls
	  assume that bools should be treated as VARIANTBOOLs.

	* marshal.c (emit_marshal_boolean): Adding cases for
	  MARSHAL_ACTION_MANAGED_CONV_IN and MARSHAL_ACTION_MANAGED_CONV_OUT.

	* marshal.c (mono_marshal_emit_managed_wrapper): Adding calls to
	  emit_marshal MARSHAL_ACTION_MANAGED_CONV_IN and OUT for bools.

	* marshal.c (cominterop_get_ccw): For COM calls assume that bools
	  should be treated as VARIANTBOOLs.	

	Code is contributed under MIT/X11 license.

On Wed, Feb 11, 2009 at 7:29 PM, Zoltan Varga <vargaz at gmail.com> wrote:
> Hi,
>
>  This looks ok, I'm just concerned that the new code will be run even
> in non-com situations,
> and it might cause problems, like it uses CEE_LDIND_I4 to load a bool value.
>
>                   Zoltan
>
> 2009/2/12 Bill Holmes <billholmes54 at gmail.com>:
>> Hi,
>>
>> The attached patch fixes some problems we are seeing with marshaling
>> bools and IDspatch types in Native code.
>>
>> I can split the patch separating the bool changes form the dispatch
>> changes if needed.  I would like to apply this to the 2.4 branch as
>> well.
>>
>> -bill
>>
>> 2009-02-12  Bill Holmes  <billholmes54 at gmail.com>
>>
>>        * object-internals.h : Fixing a typo in the
>>          MonoReflectionComVisibleAttribute struct.
>>
>>        * marshal.c (cominterop_com_visible): Check the implemented
>>          interfaces for ComImport.
>>
>>        * marshal.c (cominterop_get_native_wrapper_adjusted): For COM calls
>>          assume that bools should be treated as VARIANTBOOLs.
>>
>>        * marshal.c (emit_marshal_boolean): Adding cases for
>>          MARSHAL_ACTION_MANAGED_CONV_IN and MARSHAL_ACTION_MANAGED_CONV_OUT.
>>
>>        * marshal.c (mono_marshal_emit_managed_wrapper): Adding calls to
>>          emit_marshal MARSHAL_ACTION_MANAGED_CONV_IN and OUT for bools.
>>
>>        * marshal.c (cominterop_get_ccw): For COM calls assume that bools
>>          should be treated as VARIANTBOOLs.
>>
>>        Code is contributed under MIT/X11 license.
>>
>> _______________________________________________
>> Mono-devel-list mailing list
>> Mono-devel-list at lists.ximian.com
>> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>>
>>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Native_To_Managed_Bools.patch
Type: text/x-patch
Size: 6548 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20090212/359a15b5/attachment-0002.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Native_To_Managed_Bools_For_2-4.patch
Type: text/x-patch
Size: 6667 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20090212/359a15b5/attachment-0003.bin 


More information about the Mono-devel-list mailing list