Support script object pointer downcast #2018
Labels
ags 4
related to the ags4 development
context: script compiler
context: script vm
type: enhancement
a suggestion or necessity to have something improved
Milestone
CC @fernewelten
After RTTI was added in ags4, it is now theoretically possible to find out the managed object's parent(s), knowing its type. This opens a possibility to support downcasting, that is - a conversion from the base type pointer to a child type pointer. As opposed to the upcasting, which may be calculated at compile time, downcasting has to be performed at runtime, as compiler cannot know which type will be stored in the base pointer.
What would be required for this?
Child* child_ptr = (Child*)parent_ptr
;Child* child_ptr = parent_ptr as Child
;cast<T>(parent_ptr)
orcast<T*>(parent_ptr)
, but it looks more complicated.The text was updated successfully, but these errors were encountered: