Sometimes, it'll be necessary to decide which class to unmarshal a C pointer into on-the-fly. For example FROGGS' use case at http://irclog.perlgeek.de/perl6/2012-09-04#i_5961160
Basically, the exact nature of void *pixels is determined by the data in the format. I think the solution will be something along the lines of a new NQP op nqp::dyncall_cast_pointer($obj, Class) where Class is CStruct/CArray/CPointer REPRd, and the op basically hooks into the existing make_*_result logic in ops/nqp_dyncall.ops.
Can be done by:
These PR's were merged, and the sub nativecast provides this functionality now.