[Mono-dev] COM Callable Wrapper Patch

Paolo Molaro lupus at ximian.com
Thu Feb 8 11:44:26 EST 2007


On 02/07/07 Jon Chambers wrote:
> >> different. I currently have no way to determine that an object with a
> >> finalizer needs it's CCW destroyed but don't need it's finalizer run.
> >
> >For delegates we just check and return in SuppressFinalize.
> >You could add a similar check there with the usual fast path for when no
> >com support has been used.

It looks like this check has not been implemented.
At least add a FIXME with the explanation.

> +gboolean
> +mono_marshal_free_ccw (MonoObject* object)
> +{
> +	GList *ccw_list, *ccw_list_orig, *ccw_list_item;
> +	/* no ccw's were created */
> +	if (!ccw_hash || g_hash_table_size (ccw_hash) == 0)
> +		return FALSE;
> +
> +	/* need to cache orig list address to remove from hash_table if empty */
> +	ccw_list = ccw_list_orig = g_hash_table_lookup (ccw_hash, GINT_TO_POINTER (mono_object_hash (object)));

The hash table accesses need locking protection. I didn't check for
other lockings issues, but I guess it will be easier once the code is
integrated in svn.

> +void
> +cominterop_mono_string_to_guid (const MonoString* string, guint8 *guid) {
> +	gunichar2 * chars = mono_string_chars (string);
> +	guid [0] = g_unichar_xdigit_value (chars [7]) + (g_unichar_xdigit_value (chars [6]) << 4);
> +	guid [1] = g_unichar_xdigit_value (chars [5]) + (g_unichar_xdigit_value (chars [4]) << 4);
[...]
I would implement this with a loop: put in a small const byte array the
indexes in the proper sequence (in this case: 7, 5, 3, 1, 12, 10, ...)
and loop other it.

Please commit after the above changes.
Thanks!

lupus

-- 
-----------------------------------------------------------------
lupus at debian.org                                     debian/rules
lupus at ximian.com                             Monkeys do it better



More information about the Mono-devel-list mailing list