Open hekota opened 2 days ago
We've also defined inout parameters as initializing in with the copy constructor and assigning back with the assignment operator, so having those both defined for resources will make everything work as expected. They can both be = default
.
Resource handle initialization should be done via resource class constructors. If a resource is declared in a global variable, the compiler should make sure to call a constructor that takes binding information, which will later be translated to
dx.handle.fromBinding
.Resources declared as local variables would use a default constructor that will initialize the handle to 'empty' or 'null', or simply leave it undefined. Another resource can be assigned to these local variables and a copy constructor and/or assignment operator will take care of copying the resource handle.
This should greatly simplify handling of resources, including when they are dynamically bound, used as function in/out parameters, declared in unbounded arrays or used defined types.
Resource classes should look like this:
Follow-up from #105076.