-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ByteString implementation #148
Merged
Merged
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
d6c533f
Implement basic ByteString API
fzhinkin 41b1962
Support ByteString in kotlinx-io
fzhinkin 40f59ed
Cleanup
fzhinkin 2d81743
Update API dump
fzhinkin d99ff1c
Added tests on ByteStringBuilder
fzhinkin 6d3bd05
Improve test coverage
fzhinkin e09f188
Removed debugging code
fzhinkin 09e8676
Change ByteString::toString to always return full string representation
fzhinkin 9c8d009
Restructure unsafe API, move utf-8 conversion to base module
fzhinkin 4f31909
Hide ByteString.EMPTY
fzhinkin 5a1b06f
Cleanup
fzhinkin 9eff7c8
Added module description
fzhinkin 7d16db1
Move Unsafe Api annotation to unsafe package
fzhinkin 9519b83
Implement contentEquals
fzhinkin c05ac7a
Cleanup
fzhinkin 18620a3
Ended the sentence
fzhinkin 045cbe1
Bump up dependencies version
fzhinkin f2d820a
Add isNotEmpty extension
fzhinkin 09af0ac
Add buildByteString functions
fzhinkin fc853c7
Add append(vararg Byte) extension to the builder
fzhinkin 74fcebe
Update API dump
fzhinkin e2f6d76
Restructure project layout
fzhinkin d83827c
Minor API changes
fzhinkin 1ffce7a
Enable JS target in bytestring module
fzhinkin a21ec1f
Fixed formatting for byte-string related tests
fzhinkin 5e0fb14
Updated tests, docs and made the code BCE-friendly
fzhinkin 7207c08
Rename string conversion routines
fzhinkin b3612bd
Increase timeout of JS tests
fzhinkin 9006255
Cleaned up the code, updated docs
fzhinkin 2c1a785
Updated API dump
fzhinkin 61332f6
Updated exception messages
fzhinkin 457692a
Renamed readUtf8/writeUtf8 to readString/writeString (#156)
fzhinkin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Module kotlinx-io-bytestring | ||
|
||
The module provides the [ByteString] - an immutable sequence of bytes, and extensions facilitating work with it. |
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,84 @@ | ||
public final class kotlinx/io/bytestring/ByteString : java/lang/Comparable { | ||
public static final field Companion Lkotlinx/io/bytestring/ByteString$Companion; | ||
public fun <init> ([BII)V | ||
public synthetic fun <init> ([BIIILkotlin/jvm/internal/DefaultConstructorMarker;)V | ||
public synthetic fun <init> ([BLjava/lang/Object;Lkotlin/jvm/internal/DefaultConstructorMarker;)V | ||
public synthetic fun compareTo (Ljava/lang/Object;)I | ||
public fun compareTo (Lkotlinx/io/bytestring/ByteString;)I | ||
public final fun copyInto ([BIII)V | ||
public static synthetic fun copyInto$default (Lkotlinx/io/bytestring/ByteString;[BIIIILjava/lang/Object;)V | ||
public fun equals (Ljava/lang/Object;)Z | ||
public final fun get (I)B | ||
public final fun getBackingArrayReference ()[B | ||
public final fun getSize ()I | ||
public fun hashCode ()I | ||
public final fun substring (II)Lkotlinx/io/bytestring/ByteString; | ||
public static synthetic fun substring$default (Lkotlinx/io/bytestring/ByteString;IIILjava/lang/Object;)Lkotlinx/io/bytestring/ByteString; | ||
public final fun toByteArray (II)[B | ||
public static synthetic fun toByteArray$default (Lkotlinx/io/bytestring/ByteString;IIILjava/lang/Object;)[B | ||
public fun toString ()Ljava/lang/String; | ||
} | ||
|
||
public final class kotlinx/io/bytestring/ByteString$Companion { | ||
} | ||
|
||
public final class kotlinx/io/bytestring/ByteStringBuilder { | ||
public fun <init> ()V | ||
public fun <init> (I)V | ||
public synthetic fun <init> (IILkotlin/jvm/internal/DefaultConstructorMarker;)V | ||
public final fun append (B)V | ||
public final fun append ([BII)V | ||
public static synthetic fun append$default (Lkotlinx/io/bytestring/ByteStringBuilder;[BIIILjava/lang/Object;)V | ||
public final fun getCapacity ()I | ||
public final fun getSize ()I | ||
public final fun toByteString ()Lkotlinx/io/bytestring/ByteString; | ||
} | ||
|
||
public final class kotlinx/io/bytestring/ByteStringBuilderKt { | ||
public static final fun append (Lkotlinx/io/bytestring/ByteStringBuilder;Lkotlinx/io/bytestring/ByteString;)V | ||
public static final fun append (Lkotlinx/io/bytestring/ByteStringBuilder;[B)V | ||
public static final fun append-EK-6454 (Lkotlinx/io/bytestring/ByteStringBuilder;B)V | ||
public static final fun buildByteString (ILkotlin/jvm/functions/Function1;)Lkotlinx/io/bytestring/ByteString; | ||
public static synthetic fun buildByteString$default (ILkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lkotlinx/io/bytestring/ByteString; | ||
} | ||
|
||
public final class kotlinx/io/bytestring/ByteStringJvmExtKt { | ||
public static final fun decodeToString (Lkotlinx/io/bytestring/ByteString;Ljava/nio/charset/Charset;)Ljava/lang/String; | ||
public static final fun encodeToByteString (Ljava/lang/String;Ljava/nio/charset/Charset;)Lkotlinx/io/bytestring/ByteString; | ||
} | ||
|
||
public final class kotlinx/io/bytestring/ByteStringKt { | ||
public static final fun ByteString ([B)Lkotlinx/io/bytestring/ByteString; | ||
public static final fun contentEquals (Lkotlinx/io/bytestring/ByteString;[B)Z | ||
public static final fun decodeToString (Lkotlinx/io/bytestring/ByteString;)Ljava/lang/String; | ||
public static final fun encodeToByteString (Ljava/lang/String;)Lkotlinx/io/bytestring/ByteString; | ||
public static final fun endsWith (Lkotlinx/io/bytestring/ByteString;Lkotlinx/io/bytestring/ByteString;)Z | ||
public static final fun endsWith (Lkotlinx/io/bytestring/ByteString;[B)Z | ||
public static final fun getIndices (Lkotlinx/io/bytestring/ByteString;)Lkotlin/ranges/IntRange; | ||
public static final fun indexOf (Lkotlinx/io/bytestring/ByteString;BI)I | ||
public static final fun indexOf (Lkotlinx/io/bytestring/ByteString;Lkotlinx/io/bytestring/ByteString;I)I | ||
public static final fun indexOf (Lkotlinx/io/bytestring/ByteString;[BI)I | ||
public static synthetic fun indexOf$default (Lkotlinx/io/bytestring/ByteString;BIILjava/lang/Object;)I | ||
public static synthetic fun indexOf$default (Lkotlinx/io/bytestring/ByteString;Lkotlinx/io/bytestring/ByteString;IILjava/lang/Object;)I | ||
public static synthetic fun indexOf$default (Lkotlinx/io/bytestring/ByteString;[BIILjava/lang/Object;)I | ||
public static final fun isEmpty (Lkotlinx/io/bytestring/ByteString;)Z | ||
public static final fun isNotEmpty (Lkotlinx/io/bytestring/ByteString;)Z | ||
public static final fun lastIndexOf (Lkotlinx/io/bytestring/ByteString;BI)I | ||
public static final fun lastIndexOf (Lkotlinx/io/bytestring/ByteString;Lkotlinx/io/bytestring/ByteString;I)I | ||
public static final fun lastIndexOf (Lkotlinx/io/bytestring/ByteString;[BI)I | ||
public static synthetic fun lastIndexOf$default (Lkotlinx/io/bytestring/ByteString;BIILjava/lang/Object;)I | ||
public static synthetic fun lastIndexOf$default (Lkotlinx/io/bytestring/ByteString;Lkotlinx/io/bytestring/ByteString;IILjava/lang/Object;)I | ||
public static synthetic fun lastIndexOf$default (Lkotlinx/io/bytestring/ByteString;[BIILjava/lang/Object;)I | ||
public static final fun startsWith (Lkotlinx/io/bytestring/ByteString;Lkotlinx/io/bytestring/ByteString;)Z | ||
public static final fun startsWith (Lkotlinx/io/bytestring/ByteString;[B)Z | ||
} | ||
|
||
public abstract interface annotation class kotlinx/io/bytestring/unsafe/UnsafeByteStringApi : java/lang/annotation/Annotation { | ||
} | ||
|
||
public final class kotlinx/io/bytestring/unsafe/UnsafeByteStringOperations { | ||
public static final field INSTANCE Lkotlinx/io/bytestring/unsafe/UnsafeByteStringOperations; | ||
public final fun withByteArrayUnsafe (Lkotlinx/io/bytestring/ByteString;Lkotlin/jvm/functions/Function1;)V | ||
public final fun wrapUnsafe ([B)Lkotlinx/io/bytestring/ByteString; | ||
} | ||
|
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,80 @@ | ||
import org.jetbrains.dokka.gradle.DokkaTaskPartial | ||
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet | ||
|
||
plugins { | ||
kotlin("multiplatform") | ||
id("org.jetbrains.kotlinx.kover") version "0.7.1" | ||
id("org.jetbrains.dokka") version "1.8.20" | ||
} | ||
|
||
kotlin { | ||
jvm { | ||
withJava() | ||
testRuns["test"].executionTask.configure { | ||
useJUnitPlatform() | ||
} | ||
} | ||
|
||
js(IR) { | ||
nodejs { | ||
testTask { | ||
useMocha { | ||
timeout = "30s" | ||
} | ||
} | ||
} | ||
browser { | ||
testTask { | ||
filter.setExcludePatterns("*SmokeFileTest*") | ||
useMocha { | ||
timeout = "30s" | ||
} | ||
} | ||
} | ||
} | ||
|
||
configureNativePlatforms() | ||
sourceSets { | ||
val commonMain by getting | ||
val commonTest by getting { | ||
dependencies { | ||
implementation(kotlin("test")) | ||
} | ||
} | ||
val jvmMain by getting | ||
val jvmTest by getting | ||
|
||
createSourceSet("nativeMain", parent = commonMain, children = nativeTargets) | ||
createSourceSet("nativeTest", parent = commonTest, children = nativeTargets) | ||
} | ||
|
||
explicitApi() | ||
sourceSets.configureEach { | ||
configureSourceSet() | ||
} | ||
} | ||
|
||
fun KotlinSourceSet.configureSourceSet() { | ||
val srcDir = if (name.endsWith("Main")) "src" else "test" | ||
val platform = name.dropLast(4) | ||
kotlin.srcDir("$platform/$srcDir") | ||
if (name == "jvmMain") { | ||
resources.srcDir("$platform/resources") | ||
} else if (name == "jvmTest") { | ||
resources.srcDir("$platform/test-resources") | ||
} | ||
languageSettings { | ||
progressiveMode = true | ||
} | ||
} | ||
|
||
tasks.withType<DokkaTaskPartial>().configureEach { | ||
dokkaSourceSets.configureEach { | ||
includes.from("Module.md") | ||
|
||
perPackageOption { | ||
suppress.set(true) | ||
matchingRegex.set(".*unsafe.*") | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think it's worth excluding it from the official documentation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise, it looks like a Forbidden fruit - we're asking not to use it by any means and then making it visible to everyone.