-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #91 from xflin/issue85
fixed issue#85 when a fullname is used in a proto, ScalaBuff generates incorrect Scala code
- Loading branch information
Showing
11 changed files
with
196 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
scalabuff-compiler/src/test/resources/generated/ImportUseFullname.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
// Generated by ScalaBuff, the Scala Protocol Buffers compiler. DO NOT EDIT! | ||
// source: import_use_fullname.proto | ||
|
||
package resources.generated | ||
|
||
//import "package_name.proto" | ||
|
||
final case class UseFullImportedName ( | ||
`fullnameTest`: resources.generated.nested.PackageTest = resources.generated.nested.PackageTest.defaultInstance | ||
) extends com.google.protobuf.GeneratedMessageLite | ||
with com.google.protobuf.MessageLite.Builder | ||
with net.sandrogrzicic.scalabuff.Message[UseFullImportedName] | ||
with net.sandrogrzicic.scalabuff.Parser[UseFullImportedName] { | ||
|
||
|
||
|
||
def writeTo(output: com.google.protobuf.CodedOutputStream) { | ||
output.writeMessage(1, `fullnameTest`) | ||
} | ||
|
||
def getSerializedSize = { | ||
import com.google.protobuf.CodedOutputStream._ | ||
var __size = 0 | ||
__size += computeMessageSize(1, `fullnameTest`) | ||
|
||
__size | ||
} | ||
|
||
def mergeFrom(in: com.google.protobuf.CodedInputStream, extensionRegistry: com.google.protobuf.ExtensionRegistryLite): UseFullImportedName = { | ||
import com.google.protobuf.ExtensionRegistryLite.{getEmptyRegistry => _emptyRegistry} | ||
var __fullnameTest: resources.generated.nested.PackageTest = resources.generated.nested.PackageTest.defaultInstance | ||
|
||
def __newMerged = UseFullImportedName( | ||
__fullnameTest | ||
) | ||
while (true) in.readTag match { | ||
case 0 => return __newMerged | ||
case 10 => __fullnameTest = readMessage[resources.generated.nested.PackageTest](in, __fullnameTest, _emptyRegistry) | ||
case default => if (!in.skipField(default)) return __newMerged | ||
} | ||
null | ||
} | ||
|
||
def mergeFrom(m: UseFullImportedName) = { | ||
UseFullImportedName( | ||
m.`fullnameTest` | ||
) | ||
} | ||
|
||
def getDefaultInstanceForType = UseFullImportedName.defaultInstance | ||
def clear = getDefaultInstanceForType | ||
def isInitialized = true | ||
def build = this | ||
def buildPartial = this | ||
def parsePartialFrom(cis: com.google.protobuf.CodedInputStream, er: com.google.protobuf.ExtensionRegistryLite) = mergeFrom(cis, er) | ||
override def getParserForType = this | ||
def newBuilderForType = getDefaultInstanceForType | ||
def toBuilder = this | ||
def toJson(indent: Int = 0): String = "ScalaBuff JSON generation not enabled. Use --generate_json_method to enable." | ||
} | ||
|
||
object UseFullImportedName { | ||
@reflect.BeanProperty val defaultInstance = new UseFullImportedName() | ||
|
||
def parseFrom(data: Array[Byte]): UseFullImportedName = defaultInstance.mergeFrom(data) | ||
def parseFrom(data: Array[Byte], offset: Int, length: Int): UseFullImportedName = defaultInstance.mergeFrom(data, offset, length) | ||
def parseFrom(byteString: com.google.protobuf.ByteString): UseFullImportedName = defaultInstance.mergeFrom(byteString) | ||
def parseFrom(stream: java.io.InputStream): UseFullImportedName = defaultInstance.mergeFrom(stream) | ||
def parseDelimitedFrom(stream: java.io.InputStream): Option[UseFullImportedName] = defaultInstance.mergeDelimitedFromStream(stream) | ||
|
||
val FULLNAME_TEST_FIELD_NUMBER = 1 | ||
|
||
def newBuilder = defaultInstance.newBuilderForType | ||
def newBuilder(prototype: UseFullImportedName) = defaultInstance.mergeFrom(prototype) | ||
|
||
} | ||
|
||
object ImportUseFullname { | ||
def registerAllExtensions(registry: com.google.protobuf.ExtensionRegistryLite) { | ||
} | ||
|
||
private val fromBinaryHintMap = collection.immutable.HashMap[String, Array[Byte] ⇒ com.google.protobuf.GeneratedMessageLite]( | ||
"UseFullImportedName" -> (bytes ⇒ UseFullImportedName.parseFrom(bytes)) | ||
) | ||
|
||
def deserializePayload(payload: Array[Byte], payloadType: String): com.google.protobuf.GeneratedMessageLite = { | ||
fromBinaryHintMap.get(payloadType) match { | ||
case Some(f) ⇒ f(payload) | ||
case None ⇒ throw new IllegalArgumentException(s"unimplemented deserialization of message payload of type [${payloadType}]") | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
scalabuff-compiler/src/test/resources/parsed/ImportUseFullname.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
List(PackageStatement(resources.generated), ImportStatement("package_name.proto"), OptionValue(optimize_for,LITE_RUNTIME), Message(UseFullImportedName,MessageBody(List(Field(required,resources.generated.nested.PackageTest,fullname_test,1,List(),)),List(),List(),List(),List(),List(),List()))) |
9 changes: 9 additions & 0 deletions
9
scalabuff-compiler/src/test/resources/proto/import_use_fullname.proto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package resources.generated; | ||
|
||
import "package_name.proto"; | ||
|
||
option optimize_for = LITE_RUNTIME; | ||
|
||
message UseFullImportedName { | ||
required resources.generated.nested.PackageTest fullname_test = 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters