I've spent about two days recently before I figured out these two
lines that allow to want the value of the semantic property.
$params = array ("[[Pagename]]", "?ExampleProperty=", "mainlabel=-");
$result = SMWQueryProcessor::getResultFromFunctionParams( $params, SMW_OUTPUT_WIKI );
I'm pretty sure that making custom datatypes is pretty common task and not only I will find your docs useful.