resources as base64

This commit is contained in:
Danny Yoo 2012-02-13 13:34:01 -05:00
parent 14a3604705
commit 2bfc143b45
6 changed files with 20 additions and 9 deletions

View File

@ -45,8 +45,8 @@ cs019-doc:
setup:
raco setup --no-docs -P dyoo whalesong.plt 1 14
raco setup --no-docs -P dyoo whalesong.plt 1 15
planet-link:
raco planet link dyoo whalesong.plt 1 14 .
raco planet link dyoo whalesong.plt 1 15 .

View File

@ -10,7 +10,8 @@
racket/match)
(require/typed net/base64
[base64-encode (Bytes -> Bytes)])
(provide assemble-oparg
assemble-target
@ -143,10 +144,8 @@
;; This needs to be an array, because this may contain
;; a LOT of elements, and certain JS evaluators will break
;; otherewise.
(format "RT.makeBytes([~a])"
(string-join (for/list ([a-byte val])
(number->string a-byte))
","))]
(format "RT.makeBytesFromBase64(~s)"
(bytes->string/utf-8 (base64-encode val)))]
[(path? val)
(format "RT.makePath(~s)"
(path->string val))]

View File

@ -6,6 +6,10 @@
*
* dyoo: modified to work with arrays of bytes rather than assume
* the bytes are strings.
*
* Provides a Base64 object with two methods:
* Base64.encode: string -> string
* Base64.decode: string -> string
**/
var Base64 = (function() {
'use strict';
@ -71,7 +75,7 @@ var Base64 = (function() {
outputBytes.push(chr3);
}
}
return outputBytes;
return outputBytes.join('');
}
};
return Base64;

View File

@ -119,11 +119,17 @@
return new Bytes(chars);
};
var makeBytesFromBase64 = function(byteString) {
return new Bytes(Base64.decode(byteString).split(''));
};
var isBytes = baselib.makeClassPredicate(Bytes);
exports.Bytes = Bytes;
exports.makeBytes = makeBytes;
exports.makeBytesFromBase64 = makeBytesFromBase64;
exports.isBytes = isBytes;

View File

@ -48,6 +48,7 @@
var makeSymbol = baselib.symbols.makeSymbol;
var makePath = baselib.paths.makePath;
var makeBytes = baselib.bytes.makeBytes;
var makeBytesFromBase64 = baselib.bytes.makeBytesFromBase64;
var makeBox = baselib.boxes.makeBox;
var isBox = baselib.boxes.isBox;
@ -885,6 +886,7 @@
exports['makeSymbol'] = makeSymbol;
exports['makePath'] = makePath;
exports['makeBytes'] = makeBytes;
exports['makeBytesFromBase64'] = makeBytesFromBase64;
exports['checkPair'] = baselib.check.checkPair;

View File

@ -7,4 +7,4 @@
(provide version)
(: version String)
(define version "1.116")
(define version "1.118")