casting - How to cast a compact type in Vala? -


i using gobject-introspection-1.0 library vala dynamically load gir modules. need call initialization function having fixed name, retrieve baseinfo object repository.find_by_name.

now, want invoke function gi.callableinfo.invoke, needs gi.callableinfo object.

luckily, gi.callableinfo inherits gi.baseinfo, , instance retrieve gi.callableinfo. therefore try dynamically or statically cast :

gi.callableinfo mycallableinfo = mybaseinfo gi.callableinfo;  gi.callableinfo mycallableinfo = (gi.callableinfo) mybaseinfo;  gi.callableinfo mycallableinfo = (mybaseinfo gi.callableinfo)     ? (gi.callableinfo) mybaseinfo : null; 

the first 1 results in compilation error:

error: operation not supported type

the second 1 in runtime assertion fail, , mycallableinfo being null:

g_boxed_copy: assertion 'g_type_is_boxed (boxed_type)' failed

the last 1 gives compilation error lead me compact type trail:

type check expressions not supported compact classes, structs, , enums

how can cast gi.baseinfo gi.callableinfo?

when assign owned variable vala has copy value (in case types aren't reference counted, copying way). problem here copying, not casting. assign unowned variable:

unowned gi.callableinfo mycallableinfo = (gi.callableinfo) mybaseinfo; 

Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -