// output (outputCube dcInstance);
String outputFunctionName =
"output" + typeConstructor.getName().getUnqualifiedName();
// Do the function type declaration.
TypeExprDefn outputFunctionType =
TypeExprDefn.Function.make(
TypeExprDefn.TypeCons.make(Name.TypeCons.makeUnqualified(typeConstructorInfo.typeConstructor.getName().getUnqualifiedName())),
TypeExprDefn.TypeCons.make(Name.TypeCons.makeUnqualified(typeConstructorInfo.calForeignTypeName)));
SourceModel.CALDoc.Comment.Function outputFunctionComment;
{
SourceModel.CALDoc.TextSegment.Plain textSegment =
SourceModel.CALDoc.TextSegment.Plain.make(
"\nOutput an instance of " + typeConstructor.getName().getUnqualifiedName() + ".\n" +
"Translates an instance of " + typeConstructor.getName().getUnqualifiedName() + " to\n" +
"an instance of "+ typeConstructorInfo.calForeignTypeName + ".");
SourceModel.CALDoc.TextBlock textBlock =
SourceModel.CALDoc.TextBlock.make(new SourceModel.CALDoc.TextSegment.TopLevel[]{textSegment});
outputFunctionComment =
SourceModel.CALDoc.Comment.Function.make(
textBlock,
null);
}
SourceModel.FunctionTypeDeclaration outputFunctionTypeDecl =
FunctionTypeDeclaration.make(
outputFunctionComment,
outputFunctionName,
TypeSignature.make(outputFunctionType));
topLevelDefnsList.add(outputFunctionTypeDecl);
SourceModel.FunctionDefn.Algebraic outputFunction =
FunctionDefn.Algebraic.make(
outputFunctionName,
Scope.PUBLIC,
new SourceModel.Parameter[]{Parameter.make("dcInstance", true)},
outputFunctionBody);
topLevelDefnsList.add(outputFunction);
// Now create the conversion function. i.e. a private function that outputs to a JObject.
String conversionFunctionName = outputFunctionName + "ToJObject";
// Do the function type declaration.
TypeExprDefn conversionFunctionType =
TypeExprDefn.Function.make(
TypeExprDefn.TypeCons.make(Name.TypeCons.makeUnqualified(typeConstructorInfo.typeConstructor.getName().getUnqualifiedName())),
JOBJECT_TYPE_EXPR_DEFN);
SourceModel.CALDoc.Comment.Function conversionFunctionComment;