Following your idea, we added a new function %retrieve_void_func() in last beta http://beta.plantuml.net/plantuml.jar
This function is a return function, which means that it returns a String. %retrieve_void_func() takes as first argument the name of a void function to be called. Strings generated by this called void function are not output to the diagram but are returned in the returned string. Ok, this sounds difficult to understand.
Here is a first simple example :
@startuml
!function $OBJ()
class Object {
name : token
name : flag
}
!endfunction
$OBJ()
note left : foo %retrieve_void_func("$OBJ") dummy
@enduml
Knowing that, you can now have :
@startuml
!function msg($source, $destination)
$source --> $destination
!endfunction
!function init_class($name)
class $name {
$addCommonMethod()
}
!endfunction
!function $addCommonMethod()
toString()
hashCode()
!endfunction
!function $OBJ()
class Object {
name : token
name : flag
}
!endfunction
!unquoted function addNote($note, $as)
note "$note" as $as
!endfunction
component "C1" as C1 {
note "{{\nparticipant MyA as A\nA->>B: prepare\n}}\n" as detailsNote1
}
note "{{\nclass Object {\n name : token\n name : flag\n}\n}}\n" as detailsNote2
$OBJ()
addNote(%retrieve_void_func("$OBJ"), note1)
init_class("foo1")
init_class("foo2")
msg("foo1", "foo2")
@enduml
Is this what you were looking for ?