zeroc-ice / ice

All-in-one solution for creating networked applications with RPC, pub/sub, server deployment, and more.
https://zeroc.com
GNU General Public License v2.0
2k stars 592 forks source link

Simplify Generation of Checked and Unchecked Casts #2322

Closed InsertCreativityHere closed 1 week ago

InsertCreativityHere commented 1 week ago

This PR adds a constructor to all proxies, which allows them to be created from other proxies. Previously, we would create an empty proxy, then call copyFrom(other) on it.

It also simplifies and changes some logic with respect to checkedCast and uncheckedCast.

bernardnormier commented 1 week ago

Not a big difference, up to you.

This PR is only a first step in the refactoring. If you look at the C# code, the generated code for checkedCast/uncheckedCast creates directly the desired proxy object from a Reference without an intermediary ObjectPrx. We should get there in the next PR!

InsertCreativityHere commented 1 week ago

I was wondering if it would be a bit simpler to have a common implementation in ObjectPrx

I've kept a note about trying this for later, but opted not to do it for this PR. I think it is indeed simpler, but only very slightly like you say. So I want to wait until my next refactoring to see if it's still useful to do.

It especially depends on #2323. If we get rid of this try/catch block, then the methods will already be so simple, that it's probably not worth it.