abbat / clamato [abbat]
fork of clamato
My working copy of clamato project.
Clone this repository (size: 756.7 KB): HTTPS / SSH
$ hg clone http://bitbucket.org/abbat/clamato-abbat/
| commit 95: | d34b959f9b3f |
| parent 94: | d4f7ff03745f |
| branch: | default |
Wrapp JavaScript object Error and small refctoring of error handling in Workspace.
4 months ago
Changed (Δ2.1 KB):
raw changeset »
js/bootstrap.js (25 lines added, 0 lines removed)
js/clamato.js (2 lines added, 0 lines removed)
js/libs.js (34 lines added, 8 lines removed)
js/libweb.js (25 lines added, 0 lines removed)
lib/lib.st (10 lines added, 0 lines removed)
lib/workspace.st (9 lines added, 9 lines removed)
Up to file-list js/bootstrap.js:
| … | … | @@ -67,6 +67,8 @@ clamato.wrap("Clamato", Clamato); |
67 |
67 |
clamato.wrap("Nil", ClamatoNil); |
68 |
68 |
clamato.wrap("Object", ClamatoObject); |
69 |
69 |
clamato.wrap("Class", ClamatoClass); |
70 |
clamato.wrap("Error", Error); |
|
71 |
||
70 |
72 |
// compiled: lib/lib.st |
71 |
73 |
|
72 |
74 |
clamato.define("Object", ["class"]); |
| … | … | @@ -2054,6 +2056,29 @@ instanceVariableNames: []}, |
2054 |
2056 |
function(){// Boolean class |
2055 |
2057 |
var self = this; |
2056 |
2058 |
return clamato.Boolean}); |
2059 |
clamato.define("Error", []); |
|
2060 |
clamato.install("Error", |
|
2061 |
"class", "_class", false, |
|
2062 |
{source: unescape("-%20class%0A%09Error."), |
|
2063 |
filename: unescape("lib/lib.st"), |
|
2064 |
selectorsSent: [], |
|
2065 |
classesReferenced: ["Error"], |
|
2066 |
instanceVariableNames: []}, |
|
2067 |
function(){// Error class |
|
2068 |
var self = this; |
|
2069 |
return clamato.Error}); |
|
2070 |
clamato.install("Error", |
|
2071 |
"message", "_message", false, |
|
2072 |
{source: unescape("-%20message%0A%7B%0A%09return%20this.message%20%3F%20this.message%20%3A%20clamato.Nil._new%28%29%3B%0A%7D."), |
|
2073 |
filename: unescape("lib/lib.st"), |
|
2074 |
selectorsSent: [], |
|
2075 |
classesReferenced: [], |
|
2076 |
instanceVariableNames: []}, |
|
2077 |
function(){// Error message |
|
2078 |
var self = this; |
|
2079 |
||
2080 |
return this.message ? this.message : clamato.Nil._new(); |
|
2081 |
}); |
|
2057 |
2082 |
|
2058 |
2083 |
// compiled: lib/peg.st |
2059 |
2084 |
Up to file-list js/clamato.js:
| … | … | @@ -67,3 +67,5 @@ clamato.wrap("Clamato", Clamato); |
67 |
67 |
clamato.wrap("Nil", ClamatoNil); |
68 |
68 |
clamato.wrap("Object", ClamatoObject); |
69 |
69 |
clamato.wrap("Class", ClamatoClass); |
70 |
clamato.wrap("Error", Error); |
|
71 |
| … | … | @@ -1985,6 +1985,29 @@ instanceVariableNames: []}, |
1985 |
1985 |
function(){// Boolean class |
1986 |
1986 |
var self = this; |
1987 |
1987 |
return clamato.Boolean}); |
1988 |
clamato.define("Error", []); |
|
1989 |
clamato.install("Error", |
|
1990 |
"class", "_class", false, |
|
1991 |
{source: unescape("-%20class%0A%09Error."), |
|
1992 |
filename: unescape("lib/lib.st"), |
|
1993 |
selectorsSent: [], |
|
1994 |
classesReferenced: ["Error"], |
|
1995 |
instanceVariableNames: []}, |
|
1996 |
function(){// Error class |
|
1997 |
var self = this; |
|
1998 |
return clamato.Error}); |
|
1999 |
clamato.install("Error", |
|
2000 |
"message", "_message", false, |
|
2001 |
{source: unescape("-%20message%0A%7B%0A%09return%20this.message%20%3F%20this.message%20%3A%20clamato.Nil._new%28%29%3B%0A%7D."), |
|
2002 |
filename: unescape("lib/lib.st"), |
|
2003 |
selectorsSent: [], |
|
2004 |
classesReferenced: [], |
|
2005 |
instanceVariableNames: []}, |
|
2006 |
function(){// Error message |
|
2007 |
var self = this; |
|
2008 |
||
2009 |
return this.message ? this.message : clamato.Nil._new(); |
|
2010 |
}); |
|
1988 |
2011 |
|
1989 |
2012 |
// compiled: lib/peg.st |
1990 |
2013 |
|
| … | … | @@ -6838,14 +6861,17 @@ var self = this; |
6838 |
6861 |
return (self["@className"] = "DoIt")}); |
6839 |
6862 |
clamato.install("Workspace", |
6840 |
6863 |
"eval:", "_eval_", false, |
6841 |
{source: unescape("-%20eval%3A%20aString%20% |
|
6864 |
{source: unescape("-%20eval%3A%20aString%20%0A%7B%20%0A%09var%20res%20%3D%20%24.globalEval%28aString%29%20%3B%0A%09return%20res%20%3D%3D%3D%20undefined%20%3F%20true%20%3A%20%20res%3B%20%0A%7D."), |
|
6842 |
6865 |
filename: unescape("lib/workspace.st"), |
6843 |
6866 |
selectorsSent: [], |
6844 |
6867 |
classesReferenced: [], |
6845 |
6868 |
instanceVariableNames: []}, |
6846 |
6869 |
function(aString){// Workspace eval: |
6847 |
6870 |
var self = this; |
6848 |
|
|
6871 |
||
6872 |
var res = $.globalEval(aString) ; |
|
6873 |
return res === undefined ? true : res; |
|
6874 |
}); |
|
6849 |
6875 |
clamato.install("Workspace", |
6850 |
6876 |
"compile:", "_compile_", false, |
6851 |
6877 |
{source: unescape("-%20compile%3A%20aString%20%0A%20%20%20%20%7C%20code%20src%20%7C%0A%20%20%20%20clamato%20filename%3A%20%27doIt.st%27.%0A%20%20%20%20src%20%3A%3D%20%28aString%20matches%3A%20%27%5C.%24%27%29%0A%20%20%20%20%20%20%20%20ifTrue%3A%20%5BaString%5D%0A%20%20%20%20%20%20%20%20ifFalse%3A%20%5BaString%2C%20%27.%27%5D.%0A%20%20%20%20code%20%3A%3D%20%27%3C%27%2C%20self%20className%2C%20%27%3E%20+doIt%20%27%2C%20src.%0A%20%20%20%20self%20eval%3A%20%28clamato%20compile%3A%20code%29."), |
| … | … | @@ -6884,10 +6910,10 @@ var self = this; |
6884 |
6910 |
return (self["@workspace"] = aTextareaElement)}); |
6885 |
6911 |
clamato.install("Workspace", |
6886 |
6912 |
"printIt", "_printIt", false, |
6887 |
{source: unescape("-%20printIt%0A%09%7C%20output%20tempStart%20tempEnd%20res1%7C%0A%09res1%20%3A%3D%20%5Bself%20compile%3A%20self%20selection%5D%20catch%3A%20%5B%3Ae%20%7C%20e%5D.%0A%09%28Clamato%20isJSError%3A%20res1%29%20ifTrueRet%3A%20%0A%09%09%5B%20%7Cmsg%7C%0A%09%09msg%20%3A%3D%20Clamato%20getJSErrorMessageFrom%3A%20res1.%0A%09%09Clamato%20alert%3A%20%27Compile%20error%3A%20%27%2C%20msg%20%5D.%0A%09result%20%3A%3D%20%5B%28clamato%20at%3A%20self%20className%29%20doIt%5D%20catch%3A%20%5B%3Ae%20%7C%20e%5D.%0A%09%28Clamato%20isJSError%3A%20result%29%20ifTrueRet%3A%20%0A%09%09%5B%20%7Cmsg%7C%0A%09%09msg%20%3A%3D%20Clamato%20getJSErrorMessageFrom%3A%20result.%0A%09%09Clamato%20alert%3A%20%27Eval%20error%3A%20%27%2C%20msg%5D.%0A%09tempStart%20%3A%3D%20self%20end.%0A%09tempEnd%20%3A%3D%20self%20end%20+%201%20+%20result%20asString%20size.%0A%09output%20%3A%3D%20%28@workspace%20value%20copyFrom%3A%200%20to%3A%20self%20end%20-%201%29%2C%20%27%20%27%2C%20result%2C%20%28@workspace%20value%20copyFrom%3A%20self%20end%20to%3A%20@workspace%20value%20size%20-%201%29.%0A%09@workspace%20value%3A%20output.%0A%09@workspace%20selectionStart%3A%20tempStart.%0A%09@workspace%20selectionEnd%3A%20tempEnd.%0A%09self%20start%3A%20tempStart.%0A%09self%20end%3A%20tempEnd."), |
|
6888 |
filename: unescape("lib/workspace.st"), |
|
6889 |
selectorsSent: [unescape("+"), unescape("%2C"), unescape("-"), "alert:", "asString", "at:", "catch:", "className", "compile:", "copyFrom:to:", "doIt", "end", "end:", "getJSErrorMessageFrom:", "ifTrueRet:", "isJSError:", "selection", "selectionEnd:", "selectionStart:", "size", "start:", "value", "value:"], |
|
6890 |
classesReferenced: ["Clamato"], |
|
6913 |
{source: unescape("-%20printIt%0A%09%7C%20output%20tempStart%20tempEnd%20res1%7C%0A%09res1%20%3A%3D%20%5Bself%20compile%3A%20self%20selection%5D%20catch%3A%20%5B%3Ae%20%7C%20e%5D.%0A%09res1%20class%20%3D%20Error%20ifTrueRet%3A%20%0A%09%09%5BClamato%20alert%3A%20res1%5D.%0A%09result%20%3A%3D%20%5B%28clamato%20at%3A%20self%20className%29%20doIt%5D%20catch%3A%20%5B%3Ae%20%7C%20e%5D.%0A%09result%20class%20%3D%20Error%20ifTrueRet%3A%20%0A%09%09%5BClamato%20alert%3A%20result%5D.%0A%09tempStart%20%3A%3D%20self%20end.%0A%09tempEnd%20%3A%3D%20self%20end%20+%201%20+%20result%20asString%20size.%0A%09output%20%3A%3D%20%28@workspace%20value%20copyFrom%3A%200%20to%3A%20self%20end%20-%201%29%2C%20%27%20%27%2C%20result%2C%20%28@workspace%20value%20copyFrom%3A%20self%20end%20to%3A%20@workspace%20value%20size%20-%201%29.%0A%09@workspace%20value%3A%20output.%0A%09@workspace%20selectionStart%3A%20tempStart.%0A%09@workspace%20selectionEnd%3A%20tempEnd.%0A%09self%20start%3A%20tempStart.%0A%09self%20end%3A%20tempEnd."), |
|
6914 |
filename: unescape("lib/workspace.st"), |
|
6915 |
selectorsSent: [unescape("+"), unescape("%2C"), unescape("-"), unescape("%3D"), "alert:", "asString", "at:", "catch:", "class", "className", "compile:", "copyFrom:to:", "doIt", "end", "end:", "ifTrueRet:", "selection", "selectionEnd:", "selectionStart:", "size", "start:", "value", "value:"], |
|
6916 |
classesReferenced: ["Clamato", "Error"], |
|
6891 |
6917 |
instanceVariableNames: ["workspace"]}, |
6892 |
6918 |
function(){// Workspace printIt |
6893 |
6919 |
var self = this; |
| … | … | @@ -6896,9 +6922,9 @@ var tempStart = nil; |
6896 |
6922 |
var tempEnd = nil; |
6897 |
6923 |
var res1 = nil; |
6898 |
6924 |
(res1 = (function(){return self._compile_(self._selection())})._catch_((function(e){return e}))); |
6899 |
if ( |
|
6925 |
if (res1._class().$eq(clamato.Error)) return clamato.Clamato._alert_(res1); |
|
6900 |
6926 |
(result = (function(){return clamato._at_(self._className())._doIt()})._catch_((function(e){return e}))); |
6901 |
if ( |
|
6927 |
if (result._class().$eq(clamato.Error)) return clamato.Clamato._alert_(result); |
|
6902 |
6928 |
(tempStart = self._end()); |
6903 |
6929 |
(tempEnd = self._end().$plus((1)).$plus(result._asString()._size())); |
6904 |
6930 |
(output = self["@workspace"]._value()._copyFrom_to_((0), self._end().$minus((1))).$comma(" ").$comma(result).$comma(self["@workspace"]._value()._copyFrom_to_(self._end(), self["@workspace"]._value()._size().$minus((1))))); |
| … | … | @@ -85,6 +85,8 @@ clamato.wrap("Clamato", Clamato); |
85 |
85 |
clamato.wrap("Nil", ClamatoNil); |
86 |
86 |
clamato.wrap("Object", ClamatoObject); |
87 |
87 |
clamato.wrap("Class", ClamatoClass); |
88 |
clamato.wrap("Error", Error); |
|
89 |
||
88 |
90 |
window.print = function(x) {}; |
89 |
91 |
clamato.wrap("Event", jQuery.Event); |
90 |
92 |
// compiled: lib/lib.st |
| … | … | @@ -2074,6 +2076,29 @@ instanceVariableNames: []}, |
2074 |
2076 |
function(){// Boolean class |
2075 |
2077 |
var self = this; |
2076 |
2078 |
return clamato.Boolean}); |
2079 |
clamato.define("Error", []); |
|
2080 |
clamato.install("Error", |
|
2081 |
"class", "_class", false, |
|
2082 |
{source: unescape("-%20class%0A%09Error."), |
|
2083 |
filename: unescape("lib/lib.st"), |
|
2084 |
selectorsSent: [], |
|
2085 |
classesReferenced: ["Error"], |
|
2086 |
instanceVariableNames: []}, |
|
2087 |
function(){// Error class |
|
2088 |
var self = this; |
|
2089 |
return clamato.Error}); |
|
2090 |
clamato.install("Error", |
|
2091 |
"message", "_message", false, |
|
2092 |
{source: unescape("-%20message%0A%7B%0A%09return%20this.message%20%3F%20this.message%20%3A%20clamato.Nil._new%28%29%3B%0A%7D."), |
|
2093 |
filename: unescape("lib/lib.st"), |
|
2094 |
selectorsSent: [], |
|
2095 |
classesReferenced: [], |
|
2096 |
instanceVariableNames: []}, |
|
2097 |
function(){// Error message |
|
2098 |
var self = this; |
|
2099 |
||
2100 |
return this.message ? this.message : clamato.Nil._new(); |
|
2101 |
}); |
|
2077 |
2102 |
|
2078 |
2103 |
// compiled: lib/web.st |
2079 |
2104 |
656 |
656 |
|
657 |
657 |
- class |
658 |
658 |
Boolean. |
659 |
||
660 |
<Error> |
|
661 |
||
662 |
- class |
|
663 |
Error. |
|
664 |
||
665 |
- message |
|
666 |
{ |
|
667 |
return this.message ? this.message : clamato.Nil._new(); |
|
668 |
}. |
Up to file-list lib/workspace.st:
6 |
6 |
@workspace := '#code' q. |
7 |
7 |
@className := 'DoIt'. |
8 |
8 |
|
9 |
- eval: aString |
|
9 |
- eval: aString |
|
10 |
{ |
|
11 |
var res = $.globalEval(aString) ; |
|
12 |
return res === undefined ? true : res; |
|
13 |
}. |
|
10 |
14 |
|
11 |
15 |
- compile: aString |
12 |
16 |
| code src | |
32 |
36 |
- printIt |
33 |
37 |
| output tempStart tempEnd res1| |
34 |
38 |
res1 := [self compile: self selection] catch: [:e | e]. |
35 |
(Clamato isJSError: res1) ifTrueRet: |
|
36 |
[ |msg| |
|
37 |
msg := Clamato getJSErrorMessageFrom: res1. |
|
38 |
Clamato alert: 'Compile error: ', msg ]. |
|
39 |
res1 class = Error ifTrueRet: |
|
40 |
[Clamato alert: res1]. |
|
39 |
41 |
result := [(clamato at: self className) doIt] catch: [:e | e]. |
40 |
(Clamato isJSError: result) ifTrueRet: |
|
41 |
[ |msg| |
|
42 |
msg := Clamato getJSErrorMessageFrom: result. |
|
43 |
Clamato alert: 'Eval error: ', msg]. |
|
42 |
result class = Error ifTrueRet: |
|
43 |
[Clamato alert: result]. |
|
44 |
44 |
tempStart := self end. |
45 |
45 |
tempEnd := self end + 1 + result asString size. |
46 |
46 |
output := (@workspace value copyFrom: 0 to: self end - 1), ' ', result, (@workspace value copyFrom: self end to: @workspace value size - 1). |
