{"action":"created","issue":{"url":"https://api.github.com/repos/MightyPirates/OpenComputers/issues/1077","labels_url":"https://api.github.com/repos/MightyPirates/OpenComputers/issues/1077/labels{/name}","comments_url":"https://api.github.com/repos/MightyPirates/OpenComputers/issues/1077/comments","events_url":"https://api.github.com/repos/MightyPirates/OpenComputers/issues/1077/events","html_url":"https://github.com/MightyPirates/OpenComputers/issues/1077","id":69149964,"number":1077,"title":"Data processor block/upgrade.","user":{"login":"Kubuxu","id":2259282,"avatar_url":"https://avatars.githubusercontent.com/u/2259282?v=3","gravatar_id":"","url":"https://api.github.com/users/Kubuxu","html_url":"https://github.com/Kubuxu","followers_url":"https://api.github.com/users/Kubuxu/followers","following_url":"https://api.github.com/users/Kubuxu/following{/other_user}","gists_url":"https://api.github.com/users/Kubuxu/gists{/gist_id}","starred_url":"https://api.github.com/users/Kubuxu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kubuxu/subscriptions","organizations_url":"https://api.github.com/users/Kubuxu/orgs","repos_url":"https://api.github.com/users/Kubuxu/repos","events_url":"https://api.github.com/users/Kubuxu/events{/privacy}","received_events_url":"https://api.github.com/users/Kubuxu/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/MightyPirates/OpenComputers/labels/feature-suggested","name":"feature-suggested","color":"bfe5bf"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2015-04-17T14:29:52Z","updated_at":"2015-04-18T03:11:41Z","closed_at":null,"body":"Data processor would allow advanced data processing (pun not intended).\r\nIts main purpose would be to provide functions for bulk data storage or lower level functions on data.\r\n\r\nProposed functions:\r\n\r\n* ```tobytes(data1: Primitive[, data2: Primitive[, ...]]) -> ByteArray, format: String``` - Returns byte encoded primitive, throws error if rhere is more than one argument and it is string with ```null``` byte in it.\r\n* ```tobytesf(format: String, ...) -> ByteArray, format: String``` - Accepts format string and variable number of arguments. Returns ByteArray and the same format string for consistency with \r\n* ```frombytes(format/type: String, bytes: ByteArray) -> Primitive (of type 'type') or ... depending whether type or format was specfied.``` - returns decoded data from bytes.\r\n* **Format String** uses single characets to denote Lua's basic types:\r\n    * `d`: for double\r\n    * `b`: for boolean\r\n    * `s`: for string (String can't contain `0` byte.)\r\n    * `r` (like `raw`): for byte array. `r` is required to be followed by decimal number of bytes.\r\n* ```deflate(bytes: ByteArray) -> ByteArray``` - applies DEFLATE compression.\r\n* ```inflate(bytes: ByteArray) -> ByteArray``` - applies INFLATE decompression.\r\n* ```endianness() -> String``` - returns \"big\" in case of big-endian systems and \"little\" in case of little-endian systems.\r\n* ```encode64(bytes: ByteArray) -> ByteArray``` - returns bytes encoded to base64.\r\n* ```decode64(bytes: ByteArray) -> ByteArray``` - returns bytes decoded from bese64.\r\n\r\nAlmost all of those functions can be implemented from inside of Lua *but* the implementation is never perfect and is usually very slow; [Example](https://gist.github.com/Kubuxu/e5e04c028d8aaeab4be8).\r\n\r\nEDIT2: Edited the main part of post to incorporate changes.\r\n"},"comment":{"url":"https://api.github.com/repos/MightyPirates/OpenComputers/issues/comments/94121452","html_url":"https://github.com/MightyPirates/OpenComputers/issues/1077#issuecomment-94121452","issue_url":"https://api.github.com/repos/MightyPirates/OpenComputers/issues/1077","id":94121452,"user":{"login":"natedogith1","id":1638163,"avatar_url":"https://avatars.githubusercontent.com/u/1638163?v=3","gravatar_id":"","url":"https://api.github.com/users/natedogith1","html_url":"https://github.com/natedogith1","followers_url":"https://api.github.com/users/natedogith1/followers","following_url":"https://api.github.com/users/natedogith1/following{/other_user}","gists_url":"https://api.github.com/users/natedogith1/gists{/gist_id}","starred_url":"https://api.github.com/users/natedogith1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/natedogith1/subscriptions","organizations_url":"https://api.github.com/users/natedogith1/orgs","repos_url":"https://api.github.com/users/natedogith1/repos","events_url":"https://api.github.com/users/natedogith1/events{/privacy}","received_events_url":"https://api.github.com/users/natedogith1/received_events","type":"User","site_admin":false},"created_at":"2015-04-18T03:11:41Z","updated_at":"2015-04-18T03:11:41Z","body":"for tobytes/frombytes are y'all looking for something like Lua 5.3's string.pack and string.unpack (http://www.lua.org/manual/5.3/manual.html#pdf-string.pack) ?"}}