-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7bfa566
commit 6af8477
Showing
7 changed files
with
99 additions
and
62 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
protokt-runtime/src/main/kotlin/com/toasttab/protokt/rt/BoxedTypes.kt
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,40 @@ | ||
/* | ||
* Copyright (c) 2020 Toast Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.toasttab.protokt.rt | ||
|
||
interface Boxed { | ||
val value: Number | ||
} | ||
|
||
inline class Int32(override val value: Int) : Boxed | ||
|
||
inline class Fixed32(override val value: Int) : Boxed | ||
|
||
inline class SFixed32(override val value: Int) : Boxed | ||
|
||
inline class UInt32(override val value: Int) : Boxed | ||
|
||
inline class SInt32(override val value: Int) : Boxed | ||
|
||
inline class Int64(override val value: Long) : Boxed | ||
|
||
inline class Fixed64(override val value: Long) : Boxed | ||
|
||
inline class SFixed64(override val value: Long) : Boxed | ||
|
||
inline class UInt64(override val value: Long) : Boxed | ||
|
||
inline class SInt64(override val value: Long) : Boxed |
40 changes: 40 additions & 0 deletions
40
protokt-runtime/src/main/kotlin/com/toasttab/protokt/rt/Bytes.kt
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,40 @@ | ||
/* | ||
* Copyright (c) 2020 Toast Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.toasttab.protokt.rt | ||
|
||
class Bytes(internal val value: ByteArray) { | ||
val bytes | ||
get() = value.clone() | ||
|
||
fun isNotEmpty() = | ||
value.isNotEmpty() | ||
|
||
fun isEmpty() = | ||
value.isEmpty() | ||
|
||
override fun equals(other: Any?) = | ||
other is Bytes && value.contentEquals(other.value) | ||
|
||
override fun hashCode() = | ||
value.contentHashCode() | ||
|
||
override fun toString() = | ||
value.contentToString() | ||
|
||
companion object { | ||
val empty = Bytes(ByteArray(0)) | ||
} | ||
} |
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
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