Skip to content

Commit

Permalink
Extract common functionality into GeneratorUtil.getProtobufFunctionName
Browse files Browse the repository at this point in the history
  • Loading branch information
sigiesec committed Aug 24, 2018
1 parent 547ecce commit 1f602b1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import com.btc.serviceidl.idl.AbstractTypeReference
import com.btc.serviceidl.idl.AliasDeclaration
import com.btc.serviceidl.idl.EnumDeclaration
import com.btc.serviceidl.idl.ExceptionDeclaration
import com.btc.serviceidl.idl.FunctionDeclaration
import com.btc.serviceidl.idl.IDLSpecification
import com.btc.serviceidl.idl.InterfaceDeclaration
import com.btc.serviceidl.idl.ModuleDeclaration
Expand Down Expand Up @@ -255,4 +256,11 @@ class GeneratorUtil
// (in the generator settings?)
idl.eResource.URI.lastSegment.replace(".idl", "") + if (artifactNature == ArtifactNature.DOTNET) ".NET" else ""
}

static def String getProtobufFunctionName(FunctionDeclaration object, ProtobufType protobufType)
{
val scopeDeterminant = object.scopeDeterminant
#[Names.plain(scopeDeterminant), protobufType.getName, Names.plain(object) + protobufType.getName].join("_")
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,11 @@ class ProtobufUtil

val paramBundle = ParameterBundle.createBuilder(scopeDeterminant.moduleStack).with(ProjectType.PROTOBUF).build

// TODO this is cloned by java.ProtobufUtil(.getLocalName?)
val result = GeneratorUtil.getTransformedModuleName(paramBundle, ArtifactNature.CPP, TransformType.NAMESPACE) +
Constants.SEPARATOR_NAMESPACE + if (object instanceof InterfaceDeclaration)
Names.plain(object) + protobufType.getName
else if (object instanceof FunctionDeclaration)
Names.plain(scopeDeterminant) + "_" + protobufType.getName + "_" + Names.plain(object) +
protobufType.getName
getProtobufFunctionName(object, protobufType)
else
Names.plain(object)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ class ProtobufUtil
val scopeDeterminant = object.scopeDeterminant

if (object instanceof FunctionDeclaration && Util.ensurePresentOrThrow(optProtobufType))
Names.plain(scopeDeterminant) + "_" + optProtobufType.get.getName + "_" + Names.plain(object) +
optProtobufType.get.getName
getProtobufFunctionName(object as FunctionDeclaration, optProtobufType.get)
else
(if (scopeDeterminant instanceof ModuleDeclaration)
Constants.FILE_NAME_TYPES
Expand Down

0 comments on commit 1f602b1

Please sign in to comment.