summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjmoenig <jens@moenig.org>2013-07-15 15:45:11 +0200
committerjmoenig <jens@moenig.org>2013-07-15 15:45:11 +0200
commit4c9150d7e76a83bff903c079b3595cb44a255b30 (patch)
treed2a4918229f0512f4392c4ea353c9f7aae766b6a
parent6dbfe66420571a945688278cba70451083b43ccd (diff)
downloadsnap-byow-4c9150d7e76a83bff903c079b3595cb44a255b30.tar.gz
snap-byow-4c9150d7e76a83bff903c079b3595cb44a255b30.zip
experimental text-function primitive
(hidden, shown only in dev mode in the operators category)
-rw-r--r--blocks.js19
-rwxr-xr-xhistory.txt1
-rw-r--r--objects.js9
-rw-r--r--threads.js35
4 files changed, 61 insertions, 3 deletions
diff --git a/blocks.js b/blocks.js
index 9077548..1b1bc0f 100644
--- a/blocks.js
+++ b/blocks.js
@@ -155,7 +155,7 @@ DialogBoxMorph, BlockInputFragmentMorph, PrototypeHatBlockMorph*/
// Global stuff ////////////////////////////////////////////////////////
-modules.blocks = '2013-July-12';
+modules.blocks = '2013-July-15';
var SyntaxElementMorph;
var BlockMorph;
@@ -989,6 +989,23 @@ SyntaxElementMorph.prototype.labelPart = function (spec) {
);
part.setContents(['sqrt']);
break;
+ case '%txtfun':
+ part = new InputSlotMorph(
+ null,
+ false,
+ {
+ 'encode URI' : ['encode URI'],
+ 'decode URI' : ['decode URI'],
+ 'encode URI component' : ['encode URI component'],
+ 'decode URI component' : ['decode URI component'],
+ 'XML escape' : ['XML escape'],
+ 'XML unescape' : ['XML unescape'],
+ 'hex sha512 hash' : ['hex sha512 hash']
+ },
+ true
+ );
+ part.setContents(['encode URI']);
+ break;
case '%typ':
part = new InputSlotMorph(
null,
diff --git a/history.txt b/history.txt
index 5b7c2f1..27f98ac 100755
--- a/history.txt
+++ b/history.txt
@@ -1818,3 +1818,4 @@ ______
130715
------
* Objects: increased palette's vertical growth by scrollBarSize
+* Objects, Blocks, Threads: experimental text-function primitive (hidden, shown only in dev mode)
diff --git a/objects.js b/objects.js
index efe93e8..421b207 100644
--- a/objects.js
+++ b/objects.js
@@ -918,6 +918,13 @@ SpriteMorph.prototype.initBlocks = function () {
spec: 'type of %s',
defaults: [5]
},
+ reportTextFunction: { // only in dev mode - experimental
+ type: 'reporter',
+ category: 'operators',
+ spec: '%txtfun of %s',
+ defaults: [null, "Abelson & Sussman"]
+ },
+
/*
reportScript: {
type: 'reporter',
@@ -1703,6 +1710,7 @@ SpriteMorph.prototype.blockTemplates = function (category) {
blocks.push(txt);
blocks.push('-');
blocks.push(block('reportTypeOf'));
+ blocks.push(block('reportTextFunction'));
}
/////////////////////////////////
@@ -3963,6 +3971,7 @@ StageMorph.prototype.blockTemplates = function (category) {
blocks.push(txt);
blocks.push('-');
blocks.push(block('reportTypeOf'));
+ blocks.push(block('reportTextFunction'));
}
//////////////////////////////////
diff --git a/threads.js b/threads.js
index c67360a..5368b18 100644
--- a/threads.js
+++ b/threads.js
@@ -61,7 +61,7 @@ ReporterBlockMorph, ScriptsMorph, ShadowMorph, StringMorph,
SyntaxElementMorph, TextMorph, WorldMorph, blocksVersion, contains,
degrees, detect, getDocumentPositionOf, newCanvas, nop, radians,
useBlurredShadows, ReporterSlotMorph, CSlotMorph, RingMorph, IDE_Morph,
-ArgLabelMorph, localize*/
+ArgLabelMorph, localize, XML_Element, hex_sha512*/
// globals from objects.js:
@@ -83,7 +83,7 @@ ArgLabelMorph, localize*/
// Global stuff ////////////////////////////////////////////////////////
-modules.threads = '2013-July-11';
+modules.threads = '2013-July-15';
var ThreadManager;
var Process;
@@ -1917,6 +1917,37 @@ Process.prototype.reportMonadic = function (fname, n) {
return result;
};
+Process.prototype.reportTextFunction = function (fname, string) {
+ var x = (isNil(string) ? '' : string).toString(),
+ result = '';
+
+ switch (this.inputOption(fname)) {
+ case 'encode URI':
+ result = encodeURI(x);
+ break;
+ case 'decode URI':
+ result = decodeURI(x);
+ break;
+ case 'encode URI component':
+ result = encodeURIComponent(x);
+ break;
+ case 'decode URI component':
+ result = decodeURIComponent(x);
+ break;
+ case 'XML escape':
+ result = new XML_Element().escape(x);
+ break;
+ case 'XML unescape':
+ result = new XML_Element().unescape(x);
+ break;
+ case 'hex sha512 hash':
+ result = hex_sha512(x);
+ break;
+ default:
+ }
+ return result;
+};
+
Process.prototype.reportJoin = function (a, b) {
var x = (isNil(a) ? '' : a).toString(),
y = (isNil(b) ? '' : b).toString();