Add support for return values when calling C++ functions from scripts