-// Serializable
-
-importJava "org.simantics.databoard.serialization.Serializer" where
- data Serializer a
-
- @private
- @JavaName "serialize"
- serialize_ :: Serializer a -> a -> ByteArray
-
- @private
- @JavaName "deserialize"
- deserialize_ :: Serializer a -> ByteArray -> a
-
-importJava "org.simantics.databoard.Bindings" where
- @private
- @JavaName "getSerializer"
- serializerOf :: Binding a -> Serializer a
-
- @private
- @JavaName toString
- bindingToString :: Binding a -> String
-
- @JavaName adapt
- adapt_ :: a -> Binding a -> Binding b -> b
-
-adapt :: Serializable a => Serializable b => a -> b
-adapt x = adapt_ x binding binding
-
-instance Show (Binding a) where
- show = bindingToString
-
-"Serializes a value to a byte array."
-serialize :: Serializable a => a -> ByteArray
-serialize v = serialize_ (serializerOf binding) v
-
-"Deserializes a value from a byte array."
-deserialize :: Serializable a => ByteArray -> a
-deserialize ba = deserialize_ (serializerOf binding) ba
-
-// ByteArray
-
-importJava "java.util.Arrays" where
- @private
- @JavaName toString
- byteArrayToString :: ByteArray -> String
-
-instance Show ByteArray where
- show = byteArrayToString
-
-importJava "org.simantics.databoard.binding.mutable.Variant" where
- // data Variant (in Builtins)
- @JavaName getValue
- rawVariantValue :: Variant -> a
- @JavaName ofInstance
- variantOf :: a -> Variant\r
- @JavaName "<init>"
- variantOfWithBinding :: Binding a -> a -> Variant\r
- @JavaName getValue
- variantValue_ :: Variant -> Binding a -> a
- @JavaName toString
- showVariant :: Variant -> String
-
- @JavaName getComponent
- variantComponent :: Variant -> ChildReference -> Variant
-
-variantValue :: Serializable a => Variant -> a
-variantValue v = variantValue_ v binding
-
-instance Show Variant where
- show = showVariant
-
-variantElement :: Serializable a => Variant -> Integer -> a
-variantElement v i = variantValue (variantComponent v (indexReference i))