Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
support Scala.js
- Loading branch information
Showing
8 changed files
with
170 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package msgpack4z | ||
|
||
/** | ||
* @see [[https://github.com/msgpack/msgpack/blob/master/spec.md#ext-format-family ext format family]] | ||
* @see [[https://github.com/msgpack4z/msgpack4z-api/blob/v0.2.0/src/main/java/msgpack4z/ExtTypeHeader.java]] | ||
*/ | ||
final case class ExtTypeHeader(getType: Byte, getLength: Int) |
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,27 @@ | ||
package msgpack4z | ||
|
||
import java.math.BigInteger | ||
|
||
/** | ||
* @see [[https://github.com/msgpack4z/msgpack4z-api/blob/v0.2.0/src/main/java/msgpack4z/MsgPacker.java]] | ||
*/ | ||
trait MsgPacker { | ||
def packByte(a: Byte): Unit | ||
def packShort(a: Short): Unit | ||
def packInt(a: Int): Unit | ||
def packLong(a: Long): Unit | ||
def packDouble(a: Double): Unit | ||
def packFloat(a: Float): Unit | ||
def packBigInteger(a: BigInteger): Unit | ||
def packArrayHeader(a: Int): Unit | ||
def arrayEnd(): Unit | ||
def packMapHeader(a: Int): Unit | ||
def mapEnd(): Unit | ||
def packBoolean(a: Boolean): Unit | ||
def packNil(): Unit | ||
def packString(a: String): Unit | ||
def packBinary(a: Array[Byte]): Unit | ||
def packExtTypeHeader(extType: Byte, payloadLen: Int): Unit | ||
def writePayload(a: Array[Byte]): Unit | ||
def result(): Array[Byte] | ||
} |
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,45 @@ | ||
package msgpack4z | ||
|
||
/** | ||
* @see [[https://github.com/msgpack4z/msgpack4z-api/blob/v0.2.0/src/main/java/msgpack4z/MsgType.java]] | ||
*/ | ||
sealed abstract class MsgType extends Product with Serializable | ||
|
||
object MsgType { | ||
/** | ||
* [[https://github.com/msgpack/msgpack/blob/master/spec.md#formats-nil nil type]] | ||
*/ | ||
case object NIL extends MsgType | ||
/** | ||
* [[https://github.com/msgpack/msgpack/blob/master/spec.md#bool-format-family boolean type]] | ||
*/ | ||
case object BOOLEAN extends MsgType | ||
/** | ||
* [[https://github.com/msgpack/msgpack/blob/master/spec.md#int-format-family integer type]] | ||
*/ | ||
case object INTEGER extends MsgType | ||
/** | ||
* [[https://github.com/msgpack/msgpack/blob/master/spec.md#float-format-family float type]] | ||
*/ | ||
case object FLOAT extends MsgType | ||
/** | ||
* [[https://github.com/msgpack/msgpack/blob/master/spec.md#str-format-family string type]] | ||
*/ | ||
case object STRING extends MsgType | ||
/** | ||
* [[https://github.com/msgpack/msgpack/blob/master/spec.md#array-format-family array type]] | ||
*/ | ||
case object ARRAY extends MsgType | ||
/** | ||
* [[https://github.com/msgpack/msgpack/blob/master/spec.md#map-format-family map type]] | ||
*/ | ||
case object MAP extends MsgType | ||
/** | ||
* [[https://github.com/msgpack/msgpack/blob/master/spec.md#bin-format-family binary type]] | ||
*/ | ||
case object BINARY extends MsgType | ||
/** | ||
* [[https://github.com/msgpack/msgpack/blob/master/spec.md#ext-format-family extension type]] | ||
*/ | ||
case object EXTENSION extends MsgType | ||
} |
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,29 @@ | ||
package msgpack4z | ||
|
||
import java.math.BigInteger | ||
|
||
/** | ||
* @see [[https://github.com/msgpack4z/msgpack4z-api/blob/v0.2.0/src/main/java/msgpack4z/MsgUnpacker.java]] | ||
*/ | ||
trait MsgUnpacker { | ||
def nextType(): MsgType | ||
def unpackByte(): Byte | ||
def unpackShort(): Short | ||
def unpackInt(): Int | ||
def unpackLong(): Long | ||
def unpackBigInteger(): BigInteger | ||
def unpackDouble(): Double | ||
def unpackFloat(): Float | ||
def unpackArrayHeader(): Int | ||
def arrayEnd(): Unit | ||
def mapEnd(): Unit | ||
def unpackMapHeader(): Int | ||
def unpackBoolean(): Boolean | ||
def unpackNil(): Unit | ||
def unpackString(): String | ||
def unpackBinary(): Array[Byte] | ||
def unpackExtTypeHeader(): ExtTypeHeader | ||
def readPayload(a: Array[Byte]): Unit | ||
def readPayload(length: Int): Array[Byte] | ||
def close(): Unit | ||
} |
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,17 @@ | ||
import sbt._ | ||
import org.scalajs.sbtplugin.cross.CrossType | ||
|
||
/** | ||
* avoid move files | ||
* @see [[https://github.com/scala-js/scala-js/blob/v0.6.8/sbt-plugin/src/main/scala/scala/scalajs/sbtplugin/cross/CrossProject.scala#L193-L206]] | ||
*/ | ||
object CustomCrossType extends CrossType { | ||
override def projectDir(crossBase: File, projectType: String) = | ||
crossBase / projectType | ||
|
||
def shared(projectBase: File, conf: String) = | ||
projectBase.getParentFile / "src" / conf / "scala" | ||
|
||
override def sharedSrcDir(projectBase: File, conf: String) = | ||
Some(shared(projectBase, conf)) | ||
} |
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