Giter VIP home page Giter VIP logo

buffer's People

Contributors

litclimbing avatar simwagner avatar thebehera avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

buffer's Issues

Arm

Please add linux arm64 support

[BUG] In a kotlin/js project, using PlatformBuffer.wrap and then parsing the data, the results are not as expected

Here is my test code

import com.d10ng.common.base.toByteArrayFromHex
import com.d10ng.common.base.toHexString
import com.d10ng.common.base.toUnsignedInt
import com.d10ng.common.base.toUnsignedLong
import com.ditchoom.buffer.PlatformBuffer
import com.ditchoom.buffer.wrap
import kotlin.test.Test

class Test {

    @Test
    fun test1() {
        val str = "0001A960DBD8A500006500006400010A003132333435363738"
        val hex = str.toByteArrayFromHex()
        val buf = PlatformBuffer.wrap(hex)
        val messageId = buf.readByteArray(2).toUnsignedInt()
        val cmd = buf.readByte()
        println("messageId: $messageId, cmd: $cmd")
        val data = buf.readByteArray(buf.remaining())
        println("data=${data.toHexString()}")
        val buf1 = PlatformBuffer.wrap(data)
        println("buf1.readByteArray(4)=${buf1.readByteArray(4).toHexString()}")
        //val timestamp = buf1.readByteArray(4).toUnsignedLong() * 1000L
        //println("timestamp: $timestamp")
    }
}

The output log is as follows:

messageId: 1, cmd: -87
data=60DBD8A500006500006400010A003132333435363738
buf1.readByteArray(4)=0001A960

But the expected buf1.readByteArray(4) output is 60DBD8A5

VERSIONS

  • kotlin 1.9.23
  • com.ditchoom:buffer 1.3.38

Need absolute access functions

The ByteBuffer functions that allow fetching a data item from a specific position without moving the pointers are needed to make this a useful replacement for ByteBuffer, e.g. ByteBuffer.get(index) returns the byte at index without moving the position.

Inconsistent behaviour ios/jvm, write() doesn't update position on iOS

Using version 1.3.9

Having following test

@Test
fun test() {
    val text = "Hello world!"
    val input = PlatformBuffer.wrap(text.encodeToByteArray())
    val output = PlatformBuffer.allocate(text.length)
    output.write(input)
    assertThat(input.position()).isEqualTo(text.length) //<- ios fails
    assertThat(output.position()).isEqualTo(text.length)
    output.position(0)
    assertThat(output.readString(text.length)).isEqualTo(text)
}

JVM: OK
iOS: fails

com.willowtreeapps.opentest4k.AssertionFailedError: expected:<[12]> but was:<[0]>
Expected :[12]
Actual   :[0]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.