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
(ns test | |
(:use [gloss core io])) | |
(defcodec tag (enum :byte :end :byte :int16 :int32 :int64 :float32 :float64 :bytes :string :list :compound)) | |
(defcodec tstring (finite-frame :int16 (string :utf-8))) | |
(defcodec tbytes (repeated :byte)) | |
(declare tcompound) | |
(declare tlist) | |
(defn get-tag [t] | |
(get | |
{:string tstring, :list tlist, :compound tcompound} | |
t t)) | |
(defcodec tlist (header tag | |
(memoize (compile-frame (vector (name %) (repeated (get-tag %))))) | |
(comp symbol first))) | |
(defcodec tcompound (repeated | |
(header tag | |
(memoize (compile-frame (vector (name %) tstring (get-tag %)))) | |
(comp symbol first)) | |
:delimiters ["\0"])) | |
(defcodec nbt [tag tstring tcompound]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment