kopia lustrzana https://github.com/backface/turtlestitch
added experimental "atribute of list" reporter primitive to dev mode
rodzic
bf9f5599ae
commit
7e0db6f6f3
|
@ -11,7 +11,8 @@
|
|||
|
||||
### 2021-02-05
|
||||
* new manual for v6.6, thanks, Brian!
|
||||
* blocks: don't show internal "compile" reporter in search results
|
||||
* objects: don't show internal "compile" reporter in search results
|
||||
* blocks, objects, threads: added experimental "atribute of list" reporter primitive to dev mode
|
||||
|
||||
### 2021-02-04
|
||||
* lists, threads: changed query semantics for table selectors in ITEM OF to rows, columns, planes, etc.
|
||||
|
|
|
@ -158,7 +158,7 @@ CustomCommandBlockMorph, SymbolMorph, ToggleButtonMorph, DialMorph*/
|
|||
|
||||
// Global stuff ////////////////////////////////////////////////////////
|
||||
|
||||
modules.blocks = '2021-February-01';
|
||||
modules.blocks = '2021-February-05';
|
||||
|
||||
var SyntaxElementMorph;
|
||||
var BlockMorph;
|
||||
|
@ -461,6 +461,21 @@ SyntaxElementMorph.prototype.labelParts = {
|
|||
any : ['any']
|
||||
}
|
||||
},
|
||||
'%la': {
|
||||
type: 'input',
|
||||
tags: 'read-only static',
|
||||
menu: {
|
||||
'length' : ['length'],
|
||||
'size' : ['size'],
|
||||
'rank' : ['rank'],
|
||||
'shape' : ['shape'],
|
||||
'ravel' : ['ravel'],
|
||||
'transpose' : ['transpose'],
|
||||
'~' : null,
|
||||
'csv' : ['csv'],
|
||||
'json' : ['json']
|
||||
}
|
||||
},
|
||||
'%dim': {
|
||||
type: 'input',
|
||||
tags: 'numeric',
|
||||
|
|
|
@ -1329,6 +1329,13 @@ SpriteMorph.prototype.initBlocks = function () {
|
|||
category: 'lists',
|
||||
spec: 'length of %l'
|
||||
},
|
||||
reportListAttribute: { // only in dev mode - experimental
|
||||
dev: true,
|
||||
type: 'reporter',
|
||||
category: 'lists',
|
||||
spec: '%la of %l',
|
||||
defaults: [['length']]
|
||||
},
|
||||
reportListContainsItem: {
|
||||
type: 'predicate',
|
||||
category: 'lists',
|
||||
|
@ -2787,6 +2794,7 @@ SpriteMorph.prototype.blockTemplates = function (category) {
|
|||
blocks.push(txt);
|
||||
blocks.push('-');
|
||||
blocks.push(block('doShowTable'));
|
||||
blocks.push(block('reportListAttribute'));
|
||||
}
|
||||
|
||||
/////////////////////////////////
|
||||
|
@ -8948,6 +8956,7 @@ StageMorph.prototype.blockTemplates = function (category) {
|
|||
blocks.push(txt);
|
||||
blocks.push('-');
|
||||
blocks.push(block('doShowTable'));
|
||||
blocks.push(block('reportListAttribute'));
|
||||
}
|
||||
|
||||
/////////////////////////////////
|
||||
|
|
|
@ -61,7 +61,7 @@ StageMorph, SpriteMorph, StagePrompterMorph, Note, modules, isString, copy, Map,
|
|||
isNil, WatcherMorph, List, ListWatcherMorph, alert, console, TableMorph, BLACK,
|
||||
TableFrameMorph, ColorSlotMorph, isSnapObject, newCanvas, Symbol, SVG_Costume*/
|
||||
|
||||
modules.threads = '2021-February-04';
|
||||
modules.threads = '2021-February-05';
|
||||
|
||||
var ThreadManager;
|
||||
var Process;
|
||||
|
@ -1957,6 +1957,37 @@ Process.prototype.reportTranspose = function (list) {
|
|||
|
||||
// Process - other basic list accessors
|
||||
|
||||
Process.prototype.reportListAttribute = function (choice, list) {
|
||||
var option = this.inputOption(choice);
|
||||
this.assertType(list, 'list');
|
||||
switch (option) {
|
||||
case 'length':
|
||||
return list.length();
|
||||
case 'size':
|
||||
return list.size();
|
||||
case 'rank':
|
||||
return list.rank();
|
||||
case 'shape':
|
||||
return list.shape();
|
||||
case 'ravel':
|
||||
return list.ravel();
|
||||
case 'transpose':
|
||||
return list.transpose();
|
||||
case 'csv':
|
||||
if (list.canBeCSV()) {
|
||||
return list.asCSV();
|
||||
}
|
||||
throw new Error('unable to convert to CSV');
|
||||
case 'json':
|
||||
if (list.canBeJSON()) {
|
||||
return list.asJSON();
|
||||
}
|
||||
throw new Error('unable to convert to JSON');
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
Process.prototype.reportListLength = function (list) {
|
||||
this.assertType(list, 'list');
|
||||
return list.length();
|
||||
|
|
Ładowanie…
Reference in New Issue