Tim Abraldes:
> > So my question is this; is it preferable to keep the As*Event
> > functions, or to use regular C++ casts to accomplish the same
> > behavior? We could use static_cast unconditionally for upcasts,
> > static_cast with a check of |eventStructType| for downcasts to
> > most-derived event types, and dynamic_cast for downcasts to
> > non-most-derived event types.

Masayuki Nakano:
> Please use As*Event() in case #1 and #2. As you said, we can use
> static_cast since there is eventStructType. However, it's NOT safe
> because we *might* take mistakes. Actually, there was such bug. If
> somebody takes mistake, it may cause breaking memory if it sets
> value to the member.
> 
> # Anyway, we don't need to do anything in case #3.
> 
> Additionally, the user code becomes simple since we can avoid
> checking eventStructType member ;-)

Would it make sense to make eventStructType exist only in debug builds,
and to assert its value inside the As*Event() functions?

-- 
Cameron McCormack ≝ http://mcc.id.au/
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to