javagen.service.ssp Maven / Gradle / Ivy
The newest version!
<%
// Copyright 2014 Foursquare Labs Inc. All Rights Reserved.
import com.foursquare.spindle.codegen.runtime.{RenderType, ScalaClass, ScalaFunction, ScalaService,
TypeReferenceResolver}
import com.twitter.thrift.descriptors.{Annotation, Field, Requiredness, Struct}
%>
<%@ val service: ScalaService %>
<%@ val resolver: TypeReferenceResolver %>
<%-- Output the NAME_args and NAME_result structures. --%>
#for (function <- service.functions)
<%
// Dynamically generate a ScalaStruct for NAME_args, then emit Java code for it.
val rawArgsStruct = Struct.newBuilder.name("%s_%s_args".format(service.name, function.name)).__fields(function.argz).result()
val argsStruct = new ScalaClass(rawArgsStruct, resolver)
render("class.ssp", Map("cls" -> argsStruct)) // TODO(tdyas): Capture and indent properly.
// Dynamically generate a ScalaStruct for NAME_result, then emit Java code for it. For one-way functions,
// this is purely so functionDescriptors has a class to reference.
val rawResultStruct = Struct.newBuilder.name("%s_%s_result".format(service.name, function.name)).__fields(function.fields).result()
val resultStruct = new ScalaClass(rawResultStruct, resolver)
render("class.ssp", Map("cls" -> resultStruct)) // TODO(tdyas): Capture and indent properly.
%>
#end
© 2015 - 2025 Weber Informatics LLC | Privacy Policy