[e-cvs] cvs commit: e/src/jsrc/org/erights/e/elib/tables FlexList.updoc
markm@eros.cs.jhu.edu
markm@eros.cs.jhu.edu
Fri, 24 Aug 2001 13:14:03 -0400
markm 01/08/24 13:14:03
Modified: src/bin/resources/org/erights/e/elang/syntax
ParserTables.data
src/esrc/com/skyhunter/e/lang vatMakerAuthor.emaker
vatTester.e
src/esrc/org/erights/e/elang/cmd cmdMakerMaker.emaker
cmdMakerMaker.updoc
src/esrc/scripts eBrowser.e evalServer.updoc updoc.e
src/jsrc/org/erights/e/elang/interp ScopeSetup.java
Added: src/esrc/org/erights/e/elang/cmd
evalServerMakerAuthor.emaker
src/jsrc/org/erights/e/elang/interp ResourceUriGetter.java
src/jsrc/org/erights/e/elib/prim SynchQueue.java
src/jsrc/org/erights/e/elib/serial RemoteCall.java
src/jsrc/org/erights/e/elib/tables FlexList.updoc
Log:
missing files, updoc improvements
Revision Changes Path
1.14 +12 -12 e/src/bin/resources/org/erights/e/elang/syntax/ParserTables.data
Index: ParserTables.data
===================================================================
RCS file: /cvs/e/src/bin/resources/org/erights/e/elang/syntax/ParserTables.data,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
Binary files /tmp/cvsoLtEOv and /tmp/cvsWErHXQ differ
1.2 +9 -9 e/src/esrc/com/skyhunter/e/lang/vatMakerAuthor.emaker
Index: vatMakerAuthor.emaker
===================================================================
RCS file: /cvs/e/src/esrc/com/skyhunter/e/lang/vatMakerAuthor.emaker,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- vatMakerAuthor.emaker 2001/08/08 06:00:20 1.1
+++ vatMakerAuthor.emaker 2001/08/24 17:14:02 1.2
@@ -15,14 +15,14 @@
# <p>
# This is a very early draft of the concept, and is expected to change
# radically in non-upwards compatible ways.
-#
+#
# @author Marc Stiegler
# @author Mark S. Miller
# @author Terry Stanley
def vatMakerAuthor(unsafe__uriGetter, introducer, traceln) :near {
- # XXX Kludge: The sourceCode expression must not print to stdout or
- # stderr when it's evaluated, although the objects it spawns may do
+ # XXX Kludge: The sourceCode expression must not print to stdout or
+ # stderr when it's evaluated, although the objects it spawns may do
# so later
class vatMaker(sourceCode, args, props, vatName) :near {
def io__uriGetter := <unsafe:java.io.*>
@@ -66,13 +66,13 @@
def uri := readBuffer(altoutBuffer) trim()
def sr := introducer sturdyFromURI(uri)
- def primorialObjPromise := sr promiseRef()
+ def primordialObjPromise := sr promiseRef()
def vat {
- to promisePrimorialObj() :any {primorialObjPromise}
- to getInterp() :near {altInterp}
- to getRunner() :near {runner}
- to readStdout() :String {readBuffer(altoutBuffer)}
- to readStderr() :String {readBuffer(alterrBuffer)}
+ to promisePrimordialObj() :any {primordialObjPromise}
+ to getInterp() :near {altInterp}
+ to getRunner() :near {runner}
+ to readStdout() :String {readBuffer(altoutBuffer)}
+ to readStderr() :String {readBuffer(alterrBuffer)}
}
}
}
1.2 +1 -1 e/src/esrc/com/skyhunter/e/lang/vatTester.e
Index: vatTester.e
===================================================================
RCS file: /cvs/e/src/esrc/com/skyhunter/e/lang/vatTester.e,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- vatTester.e 2001/08/08 06:00:20 1.1
+++ vatTester.e 2001/08/24 17:14:02 1.2
@@ -10,7 +10,7 @@
def vat := vatMaker new(source, [], interp getProps(), "Bogus Sync Server")
println("made far vat")
-def farSyncServer := vat promisePrimorialObj()
+def farSyncServer := vat promisePrimordialObj()
println("far sync server: " + farSyncServer)
def outs := vat readStdout()
def errs := vat readStderr()
1.3 +9 -0 e/src/esrc/org/erights/e/elang/cmd/cmdMakerMaker.emaker
Index: cmdMakerMaker.emaker
===================================================================
RCS file: /cvs/e/src/esrc/org/erights/e/elang/cmd/cmdMakerMaker.emaker,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- cmdMakerMaker.emaker 2001/08/19 06:35:55 1.2
+++ cmdMakerMaker.emaker 2001/08/24 17:14:02 1.3
@@ -70,6 +70,15 @@
reportRes resolve(sb toString())
sb setLength(0)
}
+ when (cmdLoop getExitPairVow()) -> done([exitCode, optProblem]) {
+ if (null == optProblem) {
+ reportRes smash(`after normal exit: $exitCode`)
+ } else {
+ reportRes smash(optProblem)
+ }
+ } catch problem {
+ reportRes smash(problem)
+ }
[reportVow, cmd]
}
}
1.5 +1 -49 e/src/esrc/org/erights/e/elang/cmd/cmdMakerMaker.updoc
Index: cmdMakerMaker.updoc
===================================================================
RCS file: /cvs/e/src/esrc/org/erights/e/elang/cmd/cmdMakerMaker.updoc,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- cmdMakerMaker.updoc 2001/08/20 05:07:43 1.4
+++ cmdMakerMaker.updoc 2001/08/24 17:14:02 1.5
@@ -36,60 +36,12 @@
> alterr,
> props,
> cmdLoop)
- # value: org.erights.e.elang.scope.MutableScope@3aa7d4
+ # value: org.erights.e.elang.scope.MutableScope@366999
? def bind cmdLoop := cmdLoopMaker new(["a", "b"], props, privileged)
# value: <cmdLoop>
? def cmdMaker := cmdMakerMaker new(cmdLoop, altoutBuf, alterrBuf)
# value: <cmdMaker>
-
- ? def execVow(sourceCode) :any {
- > def [reportVow, cmd] := cmdMaker new(sourceCode)
- > cmdLoop enqueue(cmd)
- > reportVow
- > }
- # value: <execVow>
-
- ? def r1 := execVow("2 + 3")
- # value: <Eventual ref>
-
- ? r1
- # value: "# valuex: 5\n\
- # \n\
- # "
-
- ? def epVow := cmdLoop getExitPairVow()
- # value: <Eventual ref>
-
- ? def r2 := execVow("3 _/ 0")
- # value: <Eventual ref>
-
- ? r2
- # value: "# problem: <ArithmeticException: BigInteger divide by zero>\n\
- # \n\
- # "
-
- ? cmdLoop setShowsEStack(true)
- ? def r3 := execVow("3 _/ 0")
- # value: <Eventual ref>
-
- ? r3
- # value: "# problem: <ArithmeticException: BigInteger divide by zero>\n\
- # #\n\
- # # 3 floorDivide(0)\n\
- # # e`3 floorDivide(0)` eval([org.erights.e.elang.scope.MutableScope@3aa7d4])\n\
- # \n\
- # "
-
- ? def r4 := execVow("2 +")
- # value: <Eventual ref>
-
- ? r4
- # value: "# syntax error: Unexpected EOF\n\
- # #\n\
- # # <import:org.erights.e.elang.syntax.EParser>(\"2 +\")\n\
- # \n\
- # "
?
1.1 e/src/esrc/org/erights/e/elang/cmd/evalServerMakerAuthor.emaker
Index: evalServerMakerAuthor.emaker
===================================================================
# Reads the current contents of the buffer, and resets the buffer.
# <p>
# Repeated calls act like successive reads from a stream
#
# @author Mark S. Miller
# @author Terry Stanley
def readBuffer(stringBuffer) :String {
def result := stringBuffer toString()
stringBuffer setLength(0)
result
}
def evalServerSrc := <resource:scripts/evalServer.e> getText()
# For making evalServers in their own vats.
# <p>
# This is based on com/skyhunter/e/lang/vatMakerAuthor.emaker
#
# @author Marc Stiegler
# @author Mark S. Miller
# @author Terry Stanley
def evalServerMakerAuthor(unsafe__uriGetter, introducer, traceln) :near {
class evalServerMaker(args, props, vatName) :near {
def io__uriGetter := <unsafe:java.io.*>
def elib__uriGetter := <unsafe:org.erights.e.elib.*>
def elang__uriGetter := <unsafe:org.erights.e.elang.*>
def RunnerMaker := <elib:prim.Runner>
def InterpMaker := <elang:interp.Interp>
def StringWriterMaker := <io:StringWriter>
def TextWriterMaker := <elib:base.TextWriter>
def TwineFeederMaker := <elang:syntax.TwineFeeder>
def altoutWriter := StringWriterMaker new()
def altoutBuffer := altoutWriter getBuffer()
def altout := TextWriterMaker new(altoutWriter)
def alterrWriter := StringWriterMaker new()
def alterrBuffer := alterrWriter getBuffer()
def alterr := TextWriterMaker new(alterrWriter)
def runner := RunnerMaker new(vatName)
def sacrificial := TwineFeederMaker new("")
def altInterp := InterpMaker make(
args,
props,
altout,
alterr,
runner,
sacrificial,
null) # optTopScope, null implies privilegedScope
traceln("made interp")
altInterp setSource(evalServerSrc)
def optProblem := altInterp interpret() # beware: 2 vat blocking op
require(optProblem == null, thunk{`while spawning: $optProblem`})
def errString := alterrBuffer toString() trim()
require(errString == "", thunk{`errors while spawning: $errString`})
def uri := readBuffer(altoutBuffer) trim()
def sr := introducer sturdyFromURI(uri)
def evalServerQ := sr getGrip()
def vat {
to getEvalServerQ() :any {evalServerQ}
to getInterp() :near {altInterp}
to getRunner() :near {runner}
to readStdout() :String {readBuffer(altoutBuffer)}
to readStderr() :String {readBuffer(alterrBuffer)}
}
}
}
1.34 +902 -903 e/src/esrc/scripts/eBrowser.e
Index: eBrowser.e
===================================================================
RCS file: /cvs/e/src/esrc/scripts/eBrowser.e,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- eBrowser.e 2001/08/20 16:04:45 1.33
+++ eBrowser.e 2001/08/24 17:14:02 1.34
@@ -7,7 +7,7 @@
# compliance with the License. You may obtain a copy of the License
# at http://www.skyhunter.com/marcs/eBrowser-license.html Software
# distributed under the License is distributed on an "AS IS" basis,
- # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
# License for the specific language governing rights and limitations
# under the License.
# The Original Code is The eBrowser Program. The Initial Developer of
@@ -23,23 +23,23 @@
def eLogoImage := <swing:ImageIcon> new(eLogoURL) getImage()
def JFrameMaker {
to new(title) :any {
- def result := <swing:JFrame> new(title)
- result setIconImage(eLogoImage)
- result
+ def result := <swing:JFrame> new(title)
+ result setIconImage(eLogoImage)
+ result
}
to new() :any {JFrameMaker new("")}
}
def promiseAllResolved := <import:com.skyhunter.e.net.promiseAllResolved>
def uriTools := <import:com.skyhunter.e.net.uriToolsAuthor>(introducer,
- sturdyRef)
+ sturdyRef)
def uiTools := <import:com.skyhunter.ex.swing.uiToolsAuthor>(awt__uriGetter,
- swing__uriGetter)
+ swing__uriGetter)
def dialogPromiser := <import:com.skyhunter.ex.swing.dialogPromiserAuthor>(
- awt__uriGetter,
- swing__uriGetter,
- JPanel__quasiParser,
- JFrameMaker)
+ awt__uriGetter,
+ swing__uriGetter,
+ JPanel__quasiParser,
+ JFrameMaker)
# set up tracing; stub out all the printing for operational version
def traceln(str) { println(str) }
traceln("started")
@@ -52,134 +52,134 @@
# close whole app when windowSet returns to zero size
def windowSet := [] asKeys() diverge()
def standardWindow(title, windowClosingHandler) :any {
- def mainFrame := JFrameMaker new(title)
- def mainPane := mainFrame getContentPane()
- def border := <swing:BoxLayout> new(mainPane,1)
- mainPane setLayout(border)
- windowSet[mainFrame] := mainFrame
- def windowListener {
- to windowClosing(event) {
- windowClosingHandler windowClosing()
- }
- to windowClosed(event) {
- windowSet removeKey(mainFrame)
- if (windowSet size() == 0) {
- interp continueAtTop()
- }
- }
- match _ {}
- }
- mainFrame addWindowListener(windowListener)
- mainFrame
+ def mainFrame := JFrameMaker new(title)
+ def mainPane := mainFrame getContentPane()
+ def border := <swing:BoxLayout> new(mainPane,1)
+ mainPane setLayout(border)
+ windowSet[mainFrame] := mainFrame
+ def windowListener {
+ to windowClosing(event) {
+ windowClosingHandler windowClosing()
+ }
+ to windowClosed(event) {
+ windowSet removeKey(mainFrame)
+ if (windowSet size() == 0) {
+ interp continueAtTop()
+ }
+ }
+ match _ {}
+ }
+ mainFrame addWindowListener(windowListener)
+ mainFrame
}
def popAboutBox() {
- def props := interp getProps()
- def text := `<html>For Help with eBrowser, see<br>
- http://www.skyhunter.com/marcs/eBrowserIndex.html<p><p>
-
- Copyright 1999 Marc Stiegler. All rights reserved.<br>
- This software covered by the Mozilla license. For details see<p><p>
-
- http://www.skyhunter.com/marcs/eBrowser-license.html<p><p>
-
- OS version: ${props["os.name"]} ${props["os.version"]} on ${props["os.arch"]}<br>
- Java version: ${props["java.version"]} at ${props["java.home"] replaceAll("\\", "/")}<br>
- E version: ${props["e.version"]} at ${props["e.home"]}<br>
- for ${props["user.name"]} in ${props["user.region"]}</html>`
- dialogPromiser new("About eBrowser", text, null, ["OK"])
+ def props := interp getProps()
+ def text := `<html>For Help with eBrowser, see<br>
+ http://www.skyhunter.com/marcs/eBrowserIndex.html<p><p>
+
+ Copyright 1999 Marc Stiegler. All rights reserved.<br>
+ This software covered by the Mozilla license. For details see<p><p>
+
+ http://www.skyhunter.com/marcs/eBrowser-license.html<p><p>
+
+ OS version: ${props["os.name"]} ${props["os.version"]} on ${props["os.arch"]}<br>
+ Java version: ${props["java.version"]} at ${props["java.home"] replaceAll("\\", "/")}<br>
+ E version: ${props["e.version"]} at ${props["e.home"]}<br>
+ for ${props["user.name"]} in ${props["user.region"]}</html>`
+ dialogPromiser new("About eBrowser", text, null, ["OK"])
}
def buildScriptList(folder, suffix) :any {
- def runnables := [] diverge()
- if (folder exists()) {
- for each in folder {
- if (each getName() =~ `@menuLabel.$suffix`) {
- runnables push(`$menuLabel.$suffix`)
- }
- }
- }
- runnables snapshot()
+ def runnables := [] diverge()
+ if (folder exists()) {
+ for each in folder {
+ if (each getName() =~ `@menuLabel.$suffix`) {
+ runnables push(`$menuLabel.$suffix`)
+ }
+ }
+ }
+ runnables snapshot()
}
var syncerCounter := 1
def startOutlineSyncer(farBrowseServer, textModel, textPane) {
- var changeMadeSinceLastAnalysisStart := true
- var analysisNowInProgress := false
- def myNumber := syncerCounter
- syncerCounter += 1
- def syncer() {
- #traceln("syncer started for: " + myNumber)
- def vowFuncs := farBrowseServer <- refreshFuncs(textPane getText())
- analysisNowInProgress := true
- when (vowFuncs) -> done(funcs) {
- if (funcs != null) {
- #traceln("syncer got change" + myNumber)
- textModel setLines(funcs[0], funcs[1], funcs[2], funcs[3])
- } else {
+ var changeMadeSinceLastAnalysisStart := true
+ var analysisNowInProgress := false
+ def myNumber := syncerCounter
+ syncerCounter += 1
+ def syncer() {
+ #traceln("syncer started for: " + myNumber)
+ def vowFuncs := farBrowseServer <- refreshFuncs(textPane getText())
+ analysisNowInProgress := true
+ when (vowFuncs) -> done(funcs) {
+ if (funcs != null) {
+ #traceln("syncer got change" + myNumber)
+ textModel setLines(funcs[0], funcs[1], funcs[2], funcs[3])
+ } else {
#traceln("syncer got NO change" + myNumber)
}
- if (changeMadeSinceLastAnalysisStart) {
- changeMadeSinceLastAnalysisStart := false
- syncer()
- } else {analysisNowInProgress := false}
- } catch e {
- println("dead sync: " + e)
- dialogPromiser new("Browse Server Lost",
- `<html><b>Error:</b><br> $e</html>`,
- null,
- ["OK"])
- }
- }
- syncer()
- def keyListener {
- to keyTyped(theChar) {
- changeMadeSinceLastAnalysisStart := true
- if (!analysisNowInProgress) {syncer()}
- }
- match [verb,args] {}
- }
- textPane addKeyListener(keyListener)
+ if (changeMadeSinceLastAnalysisStart) {
+ changeMadeSinceLastAnalysisStart := false
+ syncer()
+ } else {analysisNowInProgress := false}
+ } catch e {
+ println("dead sync: " + e)
+ dialogPromiser new("Browse Server Lost",
+ `<html><b>Error:</b><br> $e</html>`,
+ null,
+ ["OK"])
+ }
+ }
+ syncer()
+ def keyListener {
+ to keyTyped(theChar) {
+ changeMadeSinceLastAnalysisStart := true
+ if (!analysisNowInProgress) {syncer()}
+ }
+ match [verb,args] {}
+ }
+ textPane addKeyListener(keyListener)
}
# Indentation formatter
def prettyE(eText,tab) :pbc {
- def continuationCharMap := "\\[(+-'|&/<,=*" asKeys()
- def buf := <ee:elib.tables.FlexList> fromType(char, eText size() + 10)
- var flowIndentLevel := 0
- var continuationIndent := ""
- for line in eText split("\n") {
-
- def strippedLine := line trim()
- if (strippedLine size() == 0) {
- buf push('\n')
- continuationIndent := ""
+ def continuationCharMap := "\\[(+-'|&/<,=*" asKeys()
+ def buf := <ee:elib.tables.FlexList> fromType(char, eText size() + 10)
+ var flowIndentLevel := 0
+ var continuationIndent := ""
+ for line in eText split("\n") {
+
+ def strippedLine := line trim()
+ if (strippedLine size() == 0) {
+ buf push('\n')
+ continuationIndent := ""
} else if (strippedLine startsWith("//") ||
strippedLine startsWith("#")) {
buf append(continuationIndent)
buf append(tab * flowIndentLevel)
buf append(strippedLine)
buf push('\n')
- } else {
- if (strippedLine startsWith("}")) {
- flowIndentLevel := (flowIndentLevel - 1) max(0)
- }
- buf append(continuationIndent)
- buf append(tab * flowIndentLevel)
- buf append(strippedLine)
- buf push('\n')
- continuationIndent := ""
- def lastc := strippedLine[strippedLine size() - 1]
- if (continuationCharMap maps(lastc)) {
- continuationIndent := tab
- } else if (strippedLine endsWith(" >")) {
- continuationIndent := tab
- } else if (strippedLine endsWith("{")) {
- flowIndentLevel += 1
- }
- }
- }
- buf snapshot()
+ } else {
+ if (strippedLine startsWith("}")) {
+ flowIndentLevel := (flowIndentLevel - 1) max(0)
+ }
+ buf append(continuationIndent)
+ buf append(tab * flowIndentLevel)
+ buf append(strippedLine)
+ buf push('\n')
+ continuationIndent := ""
+ def lastc := strippedLine[strippedLine size() - 1]
+ if (continuationCharMap maps(lastc)) {
+ continuationIndent := tab
+ } else if (strippedLine endsWith(" >")) {
+ continuationIndent := tab
+ } else if (strippedLine endsWith("{")) {
+ flowIndentLevel += 1
+ }
+ }
+ }
+ buf snapshot()
}
def openFiles := [] asMap() diverge()
@@ -189,504 +189,502 @@
# TextModel
class textModelMaker(optBrowseFile) :any {
- def dummyFile {
- to getName() :any {"Untitled"}
- to getCanonicalPath() :any {"Untitled"}
- to lastModified() :any {0}
- to getText() :any {""}
- to setText() :any {throw ("Dummy File Set Text")}
- }
- var browseFile := dummyFile
- if (optBrowseFile != null) {browseFile := optBrowseFile}
- def funcsChangedAlertList := [] asMap() diverge()
- def current() :any {<unsafe:java.lang.System> currentTimeMillis()}
- var myText := browseFile getText()
- var myTimeLastTextMod := current()
- var myTimeLastSaved := browseFile lastModified()
- var myOutline := []
- var myOutlineIndices := []
- var myVarLines := []
- var myVarLineIndices := []
- var myTimeLastSync := 0
- def textModel {
- to getFileName() :any {
- browseFile getName()
- }
- to getFilePath() :near {
- browseFile getCanonicalPath()
- }
- to getText() :any {myText}
- to getTextDate() :any {myTimeLastTextMod}
- to addFuncsChangedAlertRecipient(vowRecipient) {
- when (vowRecipient) -> done(recipient) {
- funcsChangedAlertList[recipient] := recipient
- } catch e {println("broken recipient in textmodel!")}
- }
- to removeFuncsChangedAlertRecipient(recipient) {
- funcsChangedAlertList removeKey(recipient)
- }
- to setText(newText) {
- myText := newText
- myTimeLastTextMod := current()
- }
- to setLines(outlineList,outlineIndices,varLineList,varLineIndices) {
- myOutline := outlineList
- myOutlineIndices := outlineIndices
- myVarLines := varLineList
- myVarLineIndices := varLineIndices
- for each in funcsChangedAlertList {each linesChanged()}
- }
- to getVarLineList() :any {myVarLines}
- to getVarLineIndices() :any {myVarLineIndices}
- to getOutlineList() :any {myOutline}
- to getOutlineIndices() :any {myOutlineIndices}
- to saveFileIsSet() :boolean {browseFile != dummyFile}
- #save assumes there is a file!
- to save() {
- browseFile setText(myText)
- myTimeLastSaved := browseFile lastModified()
- }
- to saveAs(filePath) {
- if (browseFile != dummyFile) {
- openFiles removeKey(browseFile getCanonicalPath())
- }
- browseFile := <file: filePath>
- textModel save()
- }
- to storedVersionIsNewer() :any {
- myTimeLastSaved < browseFile lastModified()
- }
- to reload() :any {
- myText := browseFile getText()
- myTimeLastSaved := browseFile lastModified()
- myTimeLastTextMod := myTimeLastSaved
- myText
- }
- to resetSaveTimeNoReload() {
- myTimeLastSaved := browseFile lastModified()
- }
- to close() {
- if (browseFile != dummyFile) {openFiles removeKey(browseFile getCanonicalPath())}
- }
- }
+ def dummyFile {
+ to getName() :any {"Untitled"}
+ to getCanonicalPath() :any {"Untitled"}
+ to lastModified() :any {0}
+ to getText() :any {""}
+ to setText() :any {throw ("Dummy File Set Text")}
+ }
+ var browseFile := dummyFile
+ if (optBrowseFile != null) {browseFile := optBrowseFile}
+ def funcsChangedAlertList := [] asMap() diverge()
+ def current() :any {<unsafe:java.lang.System> currentTimeMillis()}
+ var myText := browseFile getText()
+ var myTimeLastTextMod := current()
+ var myTimeLastSaved := browseFile lastModified()
+ var myOutline := []
+ var myOutlineIndices := []
+ var myVarLines := []
+ var myVarLineIndices := []
+ var myTimeLastSync := 0
+ def textModel {
+ to getFileName() :any {
+ browseFile getName()
+ }
+ to getFilePath() :near {
+ browseFile getCanonicalPath()
+ }
+ to getText() :any {myText}
+ to getTextDate() :any {myTimeLastTextMod}
+ to addFuncsChangedAlertRecipient(vowRecipient) {
+ when (vowRecipient) -> done(recipient) {
+ funcsChangedAlertList[recipient] := recipient
+ } catch e {println("broken recipient in textmodel!")}
+ }
+ to removeFuncsChangedAlertRecipient(recipient) {
+ funcsChangedAlertList removeKey(recipient)
+ }
+ to setText(newText) {
+ myText := newText
+ myTimeLastTextMod := current()
+ }
+ to setLines(outlineList,outlineIndices,varLineList,varLineIndices) {
+ myOutline := outlineList
+ myOutlineIndices := outlineIndices
+ myVarLines := varLineList
+ myVarLineIndices := varLineIndices
+ for each in funcsChangedAlertList {each linesChanged()}
+ }
+ to getVarLineList() :any {myVarLines}
+ to getVarLineIndices() :any {myVarLineIndices}
+ to getOutlineList() :any {myOutline}
+ to getOutlineIndices() :any {myOutlineIndices}
+ to saveFileIsSet() :boolean {browseFile != dummyFile}
+ #save assumes there is a file!
+ to save() {
+ browseFile setText(myText)
+ myTimeLastSaved := browseFile lastModified()
+ }
+ to saveAs(filePath) {
+ if (browseFile != dummyFile) {
+ openFiles removeKey(browseFile getCanonicalPath())
+ }
+ browseFile := <file: filePath>
+ textModel save()
+ }
+ to storedVersionIsNewer() :any {
+ myTimeLastSaved < browseFile lastModified()
+ }
+ to reload() :any {
+ myText := browseFile getText()
+ myTimeLastSaved := browseFile lastModified()
+ myTimeLastTextMod := myTimeLastSaved
+ myText
+ }
+ to resetSaveTimeNoReload() {
+ myTimeLastSaved := browseFile lastModified()
+ }
+ to close() {
+ if (browseFile != dummyFile) {openFiles removeKey(browseFile getCanonicalPath())}
+ }
+ }
}
-
# elmer scratchpad
def eui__uriGetter := <unsafe:org.erights.e.ui.*>
def EditGroupMaker := <eui:jed.EditGroup>
def ElmerMainMaker := <eui:elmer.ElmerMain>
def EInterpAdapterMaker := <eui:elmer.EInterpAdapter>
-
def group := EditGroupMaker new(false)
-
def elmer() {
- def first := ElmerMainMaker new(group, EInterpAdapterMaker)
- first setVisible(true)
+ def first := ElmerMainMaker new(group, EInterpAdapterMaker)
+ first setVisible(true)
}
def confinedRunner(sourceTwine, resultPane) :any {
- resultPane setText("Executing...")
- traceln("in confined runner, about to interpret")
- def interpret() :any {
- var result := null
- traceln("ready")
- def ScopeSetupMaker := <unsafe:org.erights.e.elang.interp.ScopeSetup>
- traceln("made scoper")
- def scope1 := ScopeSetupMaker universal()
- traceln("made scope1")
- try {
- def tree := e__quasiParser(sourceTwine)
- traceln("made tree")
- result := tree eval(scope1 newPov())
- traceln("confined Interpretation done")
- resultPane append("\n# value: " + result)
- traceln("confined shown")
- } catch problem {
- resultPane append(`Error: ${"\n"}$problem`)
- }
- result
- }
- interpret()
+ resultPane setText("Executing...")
+ traceln("in confined runner, about to interpret")
+ def interpret() :any {
+ var result := null
+ traceln("ready")
+ def ScopeSetupMaker := <unsafe:org.erights.e.elang.interp.ScopeSetup>
+ traceln("made scoper")
+ def scope1 := ScopeSetupMaker universal()
+ traceln("made scope1")
+ try {
+ def tree := e__quasiParser(sourceTwine)
+ traceln("made tree")
+ result := tree eval(scope1 newPov())
+ traceln("confined Interpretation done")
+ resultPane append("\n# value: " + result)
+ traceln("confined shown")
+ } catch problem {
+ resultPane append(`Error: ${"\n"}$problem`)
+ }
+ result
+ }
+ interpret()
}
# Assumes without checking that the span is into the same "file" shown
# in this textPane
def selectSpan(textPane, span) {
- # "-1" because getLineStartOffset is 0 index origin
- def line1pos := textPane getLineStartOffset(span getStartLine() -1)
- textPane setCaretPosition(line1pos + span getStartCol())
- def line2pos := textPane getLineStartOffset(span getEndLine() -1)
- textPane moveCaretPosition(line2pos + span getEndCol())
+ # "-1" because getLineStartOffset is 0 index origin
+ def line1pos := textPane getLineStartOffset(span getStartLine() -1)
+ textPane setCaretPosition(line1pos + span getStartCol())
+ def line2pos := textPane getLineStartOffset(span getEndLine() -1)
+ textPane moveCaretPosition(line2pos + span getEndCol())
}
def SyntaxException :=
- <unsafe:org.erights.e.elang.syntax.SyntaxException> asType()
+ <unsafe:org.erights.e.elang.syntax.SyntaxException> asType()
def programRunner(sourceTwine, textPane, textModel, resultPane) {
- resultPane setText("Executing...")
- traceln("in runner, about to interpret")
- def interpret() {
- traceln("ready")
- def ScopeSetupMaker := <unsafe:org.erights.e.elang.interp.ScopeSetup>
- traceln("made scoper")
- def scope1 := ScopeSetupMaker privileged(false,
- stdout,
- stderr,
- interp)
- traceln("made scope1")
- def subInterp {
- to blockAtTop() {
- # ignored
- }
- to continueAtTop() {
- # ignored
- }
- delegate { interp }
- }
- traceln("made subInterp")
- var scope2 := scope1 sprout() bindFinal("interp", subInterp)
- traceln("made scope2")
- try {
- def tree := e__quasiParser(sourceTwine)
- traceln("made tree")
- def result := tree eval(scope2 newPov())
- traceln("Interpretation done")
- resultPane append("\n# value: " + result)
- traceln("shown")
- } catch problem {
- if (problem leaf() =~ sex :SyntaxException) {
- resultPane append(sex report())
- def optDamage := sex optDamage()
- if (optDamage != null) {
- def optSpan := optDamage optSourceSpan()
- if (optSpan != null) {
- def url := optSpan getUrl()
- def path := textModel getFilePath()
- if (url =~ `file:$path`) {
- traceln(`position to $optSpan in "$optDamage"`)
- selectSpan(textPane, optSpan)
- textPane requestFocus()
- textPane getTopLevelAncestor() toFront()
- } else {
- traceln(`$url !~ ``file:$path```)
- }
- } else {
- traceln("string is bare")
- }
- } else {
- traceln("floating syntax exception")
- }
- } else {
- resultPane append("\n# " + problem + "\n\n" +
- problem eStack() + "\n\n" +
- problem javaStack())
- }
- traceln("problem shown")
- }
- }
- interpret()
+ resultPane setText("Executing...")
+ traceln("in runner, about to interpret")
+ def interpret() {
+ traceln("ready")
+ def ScopeSetupMaker := <unsafe:org.erights.e.elang.interp.ScopeSetup>
+ traceln("made scoper")
+ def scope1 := ScopeSetupMaker privileged(false,
+ stdout,
+ stderr,
+ interp)
+ traceln("made scope1")
+ def subInterp {
+ to blockAtTop() {
+ # ignored
+ }
+ to continueAtTop() {
+ # ignored
+ }
+ delegate { interp }
+ }
+ traceln("made subInterp")
+ var scope2 := scope1 sprout() bindFinal("interp", subInterp)
+ traceln("made scope2")
+ try {
+ def tree := e__quasiParser(sourceTwine)
+ traceln("made tree")
+ def result := tree eval(scope2 newPov())
+ traceln("Interpretation done")
+ resultPane append("\n# value: " + result)
+ traceln("shown")
+
+ } catch problem {
+ resultPane append(("\n" + problem) replaceAll("\n", "\n# "))
+ if (problem leaf() =~ sex :SyntaxException) {
+ def optDamage := sex optDamage()
+ if (optDamage != null) {
+ def optSpan := optDamage optSourceSpan()
+ if (optSpan != null) {
+ def url := optSpan getUrl()
+ def path := textModel getFilePath()
+ if (url =~ `file:$path`) {
+ traceln(`position to $optSpan in "$optDamage"`)
+ selectSpan(textPane, optSpan)
+ textPane requestFocus()
+ textPane getTopLevelAncestor() toFront()
+ } else {
+ traceln(`$url !~ ``file:$path```)
+ }
+ } else {
+ traceln("string is bare")
+ }
+ } else {
+ traceln("floating syntax exception")
+ }
+ } else {
+ resultPane append(("\n\n" + problem eStack() + "\n\n" +
+ problem javaStack()) replaceAll("\n", "\n# "))
+ }
+ traceln("problem shown")
+ }
+
+ }
+ interpret()
}
# Compare the selection in a listpane to the items in a list
# see if there is a sensible match, return -1 if no match found,
- # return index of the match in the list to the listpane selection
+# return index of the match in the list to the listpane selection
# if there is a sensible match
def determineBestMatch(listPane,list) :any {
- def extractElement(line) :any {
- if (line =~ `* @{body}`) {
- body trim()
- } else {
- null
- }
- }
- var answer := -1
- def currentIndex := listPane getSelectedIndex()
- if (currentIndex >= 0) {
- def newIndex := null
- def currentFunc := extractElement(listPane getSelectedValue())
- def isMatch(listIndex) :pbc {
- if (listIndex > 0 && listIndex < list size()) {
- extractElement(list[listIndex]) == currentFunc
- } else {false}
- }
- for i in 0..10 {
- if (answer == -1) {
- if (isMatch(currentIndex + i)) {
- answer := currentIndex + i
- } else if (isMatch(currentIndex - i)) {
- answer := currentIndex - i
- }
- }
- }
- }
- answer
+ def extractElement(line) :any {
+ if (line =~ `* @{body}`) {
+ body trim()
+ } else {
+ null
+ }
+ }
+ var answer := -1
+ def currentIndex := listPane getSelectedIndex()
+ if (currentIndex >= 0) {
+ def newIndex := null
+ def currentFunc := extractElement(listPane getSelectedValue())
+ def isMatch(listIndex) :pbc {
+ if (listIndex > 0 && listIndex < list size()) {
+ extractElement(list[listIndex]) == currentFunc
+ } else {false}
+ }
+ for i in 0..10 {
+ if (answer == -1) {
+ if (isMatch(currentIndex + i)) {
+ answer := currentIndex + i
+ } else if (isMatch(currentIndex - i)) {
+ answer := currentIndex - i
+ }
+ }
+ }
+ }
+ answer
}
def configureUpdatedListPane(listPane,list) {
- def selectedIndex := determineBestMatch(listPane,list)
- E call(listPane,"setListData(Object[])",[list snapshot()])
- if (selectedIndex >= 0) {listPane setSelectedIndex(selectedIndex)}
+ def selectedIndex := determineBestMatch(listPane,list)
+ E call(listPane,"setListData(Object[])",[list snapshot()])
+ if (selectedIndex >= 0) {listPane setSelectedIndex(selectedIndex)}
}
# eBrowser
class eBrowserMaker(textModel) :any {
- # def tabValue := " "
- var tabValue := " "
- def newButton(name, operation, target) :any {
- def runner() {
- E call(target, operation, [])
- }
- uiTools newButton(name,runner)
- }
- def newToolButton(uri, tipText, operation, target) :any {
- def runner() {
- E call(target, operation, [])
- }
- uiTools newToolButton(uri, tipText ,runner)
- }
- def addMenuItem(menu, name, operation, target) :any {
- def runner() {
- E call(target, operation, [])
- }
- uiTools addMenuItem(menu, name,runner)
- }
- def icons__uriGetter {
- to get(name) :any {
- <resource: `com/skyhunter/e/icons/$name`>
- }
- }
-
- def eBrowser
- textModel addFuncsChangedAlertRecipient(eBrowser)
- var closingInProcess := false
- def mainFrame := standardWindow("",eBrowser)
- def setTitle {
- to (isDirty) {
- # XXX true case is not yet used
- def marker := if (isDirty) { "*" } else { "" }
- mainFrame setTitle(textModel getFilePath() + marker + " - eBrowser")
- }
- to () {setTitle(false)}
- }
- def mainPane := mainFrame getContentPane()
- mainFrame setDefaultCloseOperation(
- <swing:WindowConstants> DO_NOTHING_ON_CLOSE())
- def saveButton := newToolButton(
- <icons:save.gif>,
- "Save File","save",eBrowser)
- def findButton := newToolButton(
- <icons:find.gif>,
- "Find","find",eBrowser)
- def searchField := <swing:JTextField> new()
- def pasteUpdocButton := newToolButton(
- <icons:paste.gif>,
- "Paste from Scratchpad","pasteUpdoc",eBrowser)
- # def aboutButton := newButton("About","about",eBrowser)
- def gotoButton := newToolButton(
- <icons:goto.gif>,
- "Goto Line", "goto",eBrowser)
- def reformatButton := newToolButton(
- <icons:reformat.gif>,
- "Reformat","reformat",eBrowser)
- #def refreshFuncsButton := newToolButton(
- # <icons:sync.gif>,
- # "Sync Outline","refreshFuncs",eBrowser)
- def elmerButton := newToolButton(
- <icons:elmer.gif>,
- "Elmer scratchpad","scratchpad",eBrowser)
- def runHiLiteButton := newToolButton(
- <icons:runhilite.gif>,
- "Run HiLite","executeHiLite",eBrowser)
- def runButton := newToolButton(
- <icons:run.gif>,
- "Run","executeProgram",eBrowser)
-
- # build text pane
- def textPane := <swing:JTextArea> new()
- textPane setMargin(<awt:Insets> new(0,5,0,10))
- textPane setLineWrap(false)
- textPane setTabSize(4)
- textPane setFont(<awt:Font> new("Monospaced",<awt:Font> PLAIN(),12))
- def scrollingTextPane := <swing:JScrollPane> new(
- <swing:ScrollPaneConstants> VERTICAL_SCROLLBAR_ALWAYS(),
- <swing:ScrollPaneConstants> HORIZONTAL_SCROLLBAR_ALWAYS())
- scrollingTextPane getViewport() add(textPane)
- scrollingTextPane setMinimumSize(<awt:Dimension> new(200, 100))
- scrollingTextPane setPreferredSize(<awt:Dimension> new(800, 700))
-
- # build variable list pane
- def varListPopup := <swing:JPopupMenu> new("Var Ops")
- addMenuItem(varListPopup,"Insert","insertVar", eBrowser)
- addMenuItem(varListPopup,"Align", "alignVars", eBrowser)
- def varListPane := <swing:JList> new(<unsafe:java.util.Vector> new())
- varListPane setMinimumSize(<unsafe:java.awt.Dimension> new(20,20))
- varListPane setFont(<awt:Font> new("Monospaced",<awt:Font> PLAIN(),12))
- def scrollingVarPane := <swing:JScrollPane> new(
- <swing:ScrollPaneConstants> VERTICAL_SCROLLBAR_ALWAYS(),
- <swing:ScrollPaneConstants> HORIZONTAL_SCROLLBAR_ALWAYS())
- scrollingVarPane setMinimumSize(<unsafe:java.awt.Dimension> new(20,20))
- scrollingVarPane getViewport() add(varListPane)
- def varListPaneListener {
- to mouseClicked(theEvent) {
- if (theEvent getClickCount() > 1) {
- def varLineIndices := textModel getVarLineIndices()
- def selectedLineNum :=
- varLineIndices[varListPane getSelectedIndex()]
- def newPosition := textPane getLineStartOffset(selectedLineNum)
- textPane setCaretPosition(
- textPane getLineStartOffset(selectedLineNum + 1) - 1)
- textPane moveCaretPosition(newPosition)
- textPane requestFocus()
- } else if (theEvent isPopupTrigger() ||
- <unsafe:javax.swing.SwingUtilities> isRightMouseButton(theEvent)) {
- def clickLocation := <unsafe:java.awt.Point> new(theEvent getX(), theEvent getY())
- def selectionIndex := varListPane locationToIndex(clickLocation)
- varListPane setSelectedIndex(selectionIndex)
- varListPopup show(varListPane,
- theEvent getX(),
- theEvent getY())
- }
- }
- match _ {}
- }
- varListPane addMouseListener(varListPaneListener)
- # scrollingVarPane setMinimumSize(<awt:Dimension> new(150, 100))
-
- # build function list pane
- def funcListPane := <swing:JList> new(<unsafe:java.util.Vector> new())
- funcListPane setFont(<awt:Font> new("Monospaced",<awt:Font> PLAIN(),12))
- def scrollingFuncPane := <swing:JScrollPane> new(
- <swing:ScrollPaneConstants> VERTICAL_SCROLLBAR_ALWAYS(),
- <swing:ScrollPaneConstants> HORIZONTAL_SCROLLBAR_ALWAYS())
- scrollingFuncPane getViewport() add(funcListPane)
- def funcListPopup := <swing:JPopupMenu> new("Var Ops")
- addMenuItem(funcListPopup,"Insert","insertFunc", eBrowser)
- addMenuItem(funcListPopup,"Align", "alignFuncs", eBrowser)
- def funcListPaneListener {
- to mouseClicked(theEvent) {
- if (theEvent getClickCount() > 1) {
- def outlineIndices := textModel getOutlineIndices()
- def selectedLineNum :=
- outlineIndices[funcListPane getSelectedIndex()]
- def newPosition := textPane getLineStartOffset(selectedLineNum)
- textPane setCaretPosition(
- textPane getLineStartOffset(selectedLineNum + 1) - 1)
- textPane moveCaretPosition(newPosition)
- textPane requestFocus()
- } else if (theEvent isPopupTrigger() ||
- <unsafe:javax.swing.SwingUtilities> isRightMouseButton(theEvent)) {
- def clickLocation := <unsafe:java.awt.Point> new(theEvent getX(), theEvent getY())
- def selectionIndex := funcListPane locationToIndex(clickLocation)
- funcListPane setSelectedIndex(selectionIndex)
- funcListPopup show(funcListPane,
- theEvent getX(),
- theEvent getY())
- }
- }
- match _ {}
- }
- funcListPane addMouseListener(funcListPaneListener)
- funcListPane setMinimumSize(<awt:Dimension> new(100, 100))
- funcListPane setPreferredSize(<awt:Dimension> new(200, 100)) # why no effect?
- scrollingFuncPane setMinimumSize(<awt:Dimension> new(100, 100))
- scrollingFuncPane setPreferredSize(<awt:Dimension> new(200, 100)) # why no effect?
-
- # build output viewpane
- def outputPane := <swing:JTextArea> new()
- outputPane setMinimumSize(<awt:Dimension> new(20, 20))
- outputPane setText("Execution Output")
- def scrollingOutputPane := <swing:JScrollPane> new(
- <swing:ScrollPaneConstants> VERTICAL_SCROLLBAR_AS_NEEDED(),
- <swing:ScrollPaneConstants> HORIZONTAL_SCROLLBAR_AS_NEEDED())
- scrollingOutputPane getViewport() add(outputPane)
-
- # build splitter panes
- def varLineSplitter := <swing:JSplitPane> new()
- varLineSplitter setLeftComponent(scrollingTextPane)
- varLineSplitter setRightComponent(scrollingVarPane)
- def outputSplitter := <swing:JSplitPane> new(0)
- outputSplitter setTopComponent(varLineSplitter)
- outputSplitter setBottomComponent(scrollingOutputPane)
- def outLineSplitter := <swing:JSplitPane> new()
- outLineSplitter setLeftComponent(scrollingFuncPane)
- outLineSplitter setRightComponent(outputSplitter)
-
- # build status pane
- def statusPane := E call(<swing:JLabel>, "new(String)",[" "])
- statusPane setFont(<awt:Font> new("Monospaced",<awt:Font> PLAIN(),11))
-
- def s1 := uiTools labelIcon(<icons:separator.gif>)
- def s2 := uiTools labelIcon(<icons:separator.gif>)
- def s3 := uiTools labelIcon(<icons:separator.gif>)
-
- # real pane
- def buttonPane :=
- JPanel`$saveButton $reformatButton $s1 $pasteUpdocButton $elmerButton $s2 $runHiLiteButton $runButton $s3 $gotoButton $findButton $searchField.X`
- def realPane :=
- JPanel`$buttonPane
- $outLineSplitter.X.Y
- $statusPane `
-
- # def text replacer function
- def replaceSelectionHilite(replacement) {
- def location := textPane getSelectionStart()
- textPane replaceSelection(replacement)
- textPane setCaretPosition(location)
- textPane moveCaretPosition(location + replacement size())
- textPane requestFocus()
- }
-
- # menubar
- def newFileFunc() {
- eBrowserMaker new(textModelMaker new(null))
- }
- def openFunc() {
- fileDialog setMode(<awt:FileDialog> LOAD())
- fileDialog setTitle("Pick File To Open")
- fileDialog show()
- def fileName := fileDialog getFile()
- if (fileName != null && fileName size() > 0) {
- def localPath := `${fileDialog getDirectory()}$fileName`
- traceln(`path to new file: $localPath`)
- def openFile := <file: localPath>
- def path := openFile getCanonicalPath()
- #traceln(`current openFiles: $openFiles`)
- if (openFiles maps(path)) {
- openFiles[path] bringToTop()
- } else {
- def browser := eBrowserMaker new(textModelMaker new(openFile))
- openFiles[path] := browser
- }
- }
- }
- def saveFunc() {eBrowser save()}
- def saveAsFunc() {
- fileDialog setMode(<awt:FileDialog> SAVE())
- fileDialog setTitle("Save File As")
- fileDialog show()
- def fileName := fileDialog getFile()
- if (fileName != null && fileName size() > 0) {
- def localPath := `${fileDialog getDirectory()}$fileName`
- traceln(`path to save file: $localPath`)
- def openFile := <file: localPath>
- def path := openFile getCanonicalPath()
- #traceln(`current openFiles: $openFiles`)
- if (openFiles maps(path)) {
- dialogPromiser new("File Already Open", "Cannot save as open file", null, ["OK"])
- } else {
- textModel saveAs(path)
- openFiles[path] := eBrowser
- setTitle()
- }
- }
- }
+ # def tabValue := " "
+ var tabValue := " "
+ def newButton(name, operation, target) :any {
+ def runner() {
+ E call(target, operation, [])
+ }
+ uiTools newButton(name,runner)
+ }
+ def newToolButton(uri, tipText, operation, target) :any {
+ def runner() {
+ E call(target, operation, [])
+ }
+ uiTools newToolButton(uri, tipText ,runner)
+ }
+ def addMenuItem(menu, name, operation, target) :any {
+ def runner() {
+ E call(target, operation, [])
+ }
+ uiTools addMenuItem(menu, name,runner)
+ }
+ def icons__uriGetter {
+ to get(name) :any {
+ <resource: `com/skyhunter/e/icons/$name`>
+ }
+ }
+
+ def eBrowser
+ textModel addFuncsChangedAlertRecipient(eBrowser)
+ var closingInProcess := false
+ def mainFrame := standardWindow("",eBrowser)
+ def setTitle {
+ to (isDirty) {
+ # XXX true case is not yet used
+ def marker := if (isDirty) { "*" } else { "" }
+ mainFrame setTitle("eBrowser - " + textModel getFilePath())
+ }
+ to () {setTitle(false)}
+ }
+ def mainPane := mainFrame getContentPane()
+ mainFrame setDefaultCloseOperation(
+ <swing:WindowConstants> DO_NOTHING_ON_CLOSE())
+ def saveButton := newToolButton(
+ <icons:save.gif>,
+ "Save File","save",eBrowser)
+ def findButton := newToolButton(
+ <icons:find.gif>,
+ "Find","find",eBrowser)
+ def searchField := <swing:JTextField> new()
+ def pasteUpdocButton := newToolButton(
+ <icons:paste.gif>,
+ "Paste from Scratchpad","pasteUpdoc",eBrowser)
+ # def aboutButton := newButton("About","about",eBrowser)
+ def gotoButton := newToolButton(
+ <icons:goto.gif>,
+ "Goto Line", "goto",eBrowser)
+ def reformatButton := newToolButton(
+ <icons:reformat.gif>,
+ "Reformat","reformat",eBrowser)
+ #def refreshFuncsButton := newToolButton(
+ # <icons:sync.gif>,
+ # "Sync Outline","refreshFuncs",eBrowser)
+ def elmerButton := newToolButton(
+ <icons:elmer.gif>,
+ "Scratchpad","scratchpad",eBrowser)
+ def runHiLiteButton := newToolButton(
+ <icons:runhilite.gif>,
+ "Run HiLite","executeHiLite",eBrowser)
+ def runButton := newToolButton(
+ <icons:run.gif>,
+ "Run","executeProgram",eBrowser)
+
+ # build text pane
+ def textPane := <swing:JTextArea> new()
+ textPane setMargin(<awt:Insets> new(0,5,0,10))
+ textPane setLineWrap(false)
+ textPane setTabSize(4)
+ textPane setFont(<awt:Font> new("Monospaced",<awt:Font> PLAIN(),12))
+ def scrollingTextPane := <swing:JScrollPane> new(
+ <swing:ScrollPaneConstants> VERTICAL_SCROLLBAR_ALWAYS(),
+ <swing:ScrollPaneConstants> HORIZONTAL_SCROLLBAR_ALWAYS())
+ scrollingTextPane getViewport() add(textPane)
+ scrollingTextPane setMinimumSize(<awt:Dimension> new(200, 100))
+ scrollingTextPane setPreferredSize(<awt:Dimension> new(800, 600))
+
+ # build variable list pane
+ def varListPopup := <swing:JPopupMenu> new("Var Ops")
+ addMenuItem(varListPopup,"Insert","insertVar", eBrowser)
+ addMenuItem(varListPopup,"Align", "alignVars", eBrowser)
+ def varListPane := <swing:JList> new(<unsafe:java.util.Vector> new())
+ varListPane setMinimumSize(<unsafe:java.awt.Dimension> new(20,20))
+ varListPane setFont(<awt:Font> new("Monospaced",<awt:Font> PLAIN(),12))
+ def scrollingVarPane := <swing:JScrollPane> new(
+ <swing:ScrollPaneConstants> VERTICAL_SCROLLBAR_ALWAYS(),
+ <swing:ScrollPaneConstants> HORIZONTAL_SCROLLBAR_ALWAYS())
+ scrollingVarPane setMinimumSize(<unsafe:java.awt.Dimension> new(20,20))
+ scrollingVarPane getViewport() add(varListPane)
+ def varListPaneListener {
+ to mouseClicked(theEvent) {
+ if (theEvent getClickCount() > 1) {
+ def varLineIndices := textModel getVarLineIndices()
+ def selectedLineNum :=
+ varLineIndices[varListPane getSelectedIndex()]
+ def newPosition := textPane getLineStartOffset(selectedLineNum)
+ textPane setCaretPosition(
+ textPane getLineStartOffset(selectedLineNum + 1) - 1)
+ textPane moveCaretPosition(newPosition)
+ textPane requestFocus()
+ } else if (theEvent isPopupTrigger() ||
+ <unsafe:javax.swing.SwingUtilities> isRightMouseButton(theEvent)) {
+ def clickLocation := <unsafe:java.awt.Point> new(theEvent getX(), theEvent getY())
+ def selectionIndex := varListPane locationToIndex(clickLocation)
+ varListPane setSelectedIndex(selectionIndex)
+ varListPopup show(varListPane,
+ theEvent getX(),
+ theEvent getY())
+ }
+ }
+ match _ {}
+ }
+ varListPane addMouseListener(varListPaneListener)
+ scrollingVarPane setMinimumSize(<awt:Dimension> new(50, 100))
+
+ # build function list pane
+ def funcListPane := <swing:JList> new(<unsafe:java.util.Vector> new())
+ funcListPane setFont(<awt:Font> new("Monospaced",<awt:Font> PLAIN(),12))
+ def scrollingFuncPane := <swing:JScrollPane> new(
+ <swing:ScrollPaneConstants> VERTICAL_SCROLLBAR_ALWAYS(),
+ <swing:ScrollPaneConstants> HORIZONTAL_SCROLLBAR_ALWAYS())
+ scrollingFuncPane getViewport() add(funcListPane)
+ def funcListPopup := <swing:JPopupMenu> new("Var Ops")
+ addMenuItem(funcListPopup,"Insert","insertFunc", eBrowser)
+ addMenuItem(funcListPopup,"Align", "alignFuncs", eBrowser)
+ def funcListPaneListener {
+ to mouseClicked(theEvent) {
+ if (theEvent getClickCount() > 1) {
+ def outlineIndices := textModel getOutlineIndices()
+ def selectedLineNum :=
+ outlineIndices[funcListPane getSelectedIndex()]
+ def newPosition := textPane getLineStartOffset(selectedLineNum)
+ textPane setCaretPosition(
+ textPane getLineStartOffset(selectedLineNum + 1) - 1)
+ textPane moveCaretPosition(newPosition)
+ textPane requestFocus()
+ } else if (theEvent isPopupTrigger() ||
+ <unsafe:javax.swing.SwingUtilities> isRightMouseButton(theEvent)) {
+ def clickLocation := <unsafe:java.awt.Point> new(theEvent getX(), theEvent getY())
+ def selectionIndex := funcListPane locationToIndex(clickLocation)
+ funcListPane setSelectedIndex(selectionIndex)
+ funcListPopup show(funcListPane,
+ theEvent getX(),
+ theEvent getY())
+ }
+ }
+ match _ {}
+ }
+ funcListPane addMouseListener(funcListPaneListener)
+ #funcListPane setMinimumSize(<awt:Dimension> new(100, 100))
+ #funcListPane setPreferredSize(<awt:Dimension> new(200, 100)) # why no effect?
+ #scrollingFuncPane setMinimumSize(<awt:Dimension> new(100, 100))
+ #scrollingFuncPane setPreferredSize(<awt:Dimension> new(200, 100)) # why no effect?
+
+ # build output viewpane
+ def outputPane := <swing:JTextArea> new()
+ outputPane setMinimumSize(<awt:Dimension> new(20, 20))
+ outputPane setText("Execution Output")
+ def scrollingOutputPane := <swing:JScrollPane> new(
+ <swing:ScrollPaneConstants> VERTICAL_SCROLLBAR_AS_NEEDED(),
+ <swing:ScrollPaneConstants> HORIZONTAL_SCROLLBAR_AS_NEEDED())
+ scrollingOutputPane getViewport() add(outputPane)
+
+ # build splitter panes
+ def varLineSplitter := <swing:JSplitPane> new()
+ varLineSplitter setLeftComponent(scrollingTextPane)
+ varLineSplitter setRightComponent(scrollingVarPane)
+ def outputSplitter := <swing:JSplitPane> new(0)
+ outputSplitter setTopComponent(varLineSplitter)
+ outputSplitter setBottomComponent(scrollingOutputPane)
+ def outLineSplitter := <swing:JSplitPane> new()
+ outLineSplitter setLeftComponent(scrollingFuncPane)
+ outLineSplitter setRightComponent(outputSplitter)
+
+ # build status pane
+ def statusPane := E call(<swing:JLabel>, "new(String)",[" "])
+ statusPane setFont(<awt:Font> new("Monospaced",<awt:Font> PLAIN(),11))
+
+ def s1 := uiTools labelIcon(<icons:separator.gif>)
+ def s2 := uiTools labelIcon(<icons:separator.gif>)
+ def s3 := uiTools labelIcon(<icons:separator.gif>)
+
+ # real pane
+ def buttonPane :=
+ JPanel`$saveButton $reformatButton $s1 $pasteUpdocButton $elmerButton $s2 $runHiLiteButton $runButton $s3 $gotoButton $findButton $searchField.X`
+ def realPane :=
+ JPanel`$buttonPane
+ $outLineSplitter.X.Y
+ $statusPane `
+
+ # def text replacer function
+ def replaceSelectionHilite(replacement) {
+ def location := textPane getSelectionStart()
+ textPane replaceSelection(replacement)
+ textPane setCaretPosition(location)
+ textPane moveCaretPosition(location + replacement size())
+ textPane requestFocus()
+ }
+ # menubar
+ def newFileFunc() {
+ eBrowserMaker new(textModelMaker new(null))
+ }
+ def openFunc() {
+ fileDialog setMode(<awt:FileDialog> LOAD())
+ fileDialog setTitle("Pick File To Open")
+ fileDialog show()
+ def fileName := fileDialog getFile()
+ if (fileName != null && fileName size() > 0) {
+ def localPath := `${fileDialog getDirectory()}$fileName`
+ traceln(`path to new file: $localPath`)
+ def openFile := <file: localPath>
+ def path := openFile getCanonicalPath()
+ #traceln(`current openFiles: $openFiles`)
+ if (openFiles maps(path)) {
+ openFiles[path] bringToTop()
+ } else {
+ def browser := eBrowserMaker new(textModelMaker new(openFile))
+ openFiles[path] := browser
+ }
+ }
+ }
+ def saveFunc() {eBrowser save()}
+ def saveAsFunc() {
+ fileDialog setMode(<awt:FileDialog> SAVE())
+ fileDialog setTitle("Save File As")
+ fileDialog show()
+ def fileName := fileDialog getFile()
+ if (fileName != null && fileName size() > 0) {
+ def localPath := `${fileDialog getDirectory()}$fileName`
+ traceln(`path to save file: $localPath`)
+ def openFile := <file: localPath>
+ def path := openFile getCanonicalPath()
+ #traceln(`current openFiles: $openFiles`)
+ if (openFiles maps(path)) {
+ dialogPromiser new("File Already Open", "Cannot save as open file", null, ["OK"])
+ } else {
+ textModel saveAs(path)
+ openFiles[path] := eBrowser
+ setTitle()
+ }
+ }
+ }
+
def makeFontLarger() {
def oldFont := textPane getFont()
- def newFont := oldFont deriveFont(0.0 + oldFont getSize() + 2.0)
+ def newFont := oldFont deriveFont(0.0 + oldFont getSize() + 2.0)
textPane setFont(newFont)
funcListPane setFont(newFont)
varListPane setFont(newFont)
@@ -694,66 +692,66 @@
def makeFontSmaller() {
def oldFont := textPane getFont()
- def newFont := oldFont deriveFont(0.0 + oldFont getSize() - 2.0)
+ def newFont := oldFont deriveFont(0.0 + oldFont getSize() - 2.0)
textPane setFont(newFont)
funcListPane setFont(newFont)
varListPane setFont(newFont)
}
- # Option menu
- var capScriptsMaySubstitute := false
- #def substitutionAllowedMenuItem :=
- #<swing:JCheckBoxMenuItem> new("capScripts May Substitute")
- #E call(optionMenu, "add(JMenuItem)", [substitutionAllowedMenuItem])
- #def toggleSubstitution() {#
- #capScriptsMaySubstitute := substitutionAllowedMenuItem getState()
- #}
- #uiTools attachAction(substitutionAllowedMenuItem,toggleSubstitution)
-
-
- # capScript menu
- # scriptEvaluator must be a single-argument receiver, receiving a
- # source text
- def buildScriptMenu(title, runnablesList, folder, scriptEvaluator) :any {
- class actionListenerMaker(runnableName) :any {
- # def selectionStart := textPane getSelectionStart()
- # def selectionEnd := textPane getSelectionEnd()
- # def textSize := textPane getText() size()
- def action() {
- eBrowser setStatus(`Running script: $runnableName ...`)
- try {
- def source := folder[runnableName] getText()
- def script := scriptEvaluator(source)
- def result := script(textPane getSelectedText())
- if (capScriptsMaySubstitute &&
- script requestsSubstitution()
- ) {
- replaceSelectionHilite(result)
- outputPane append(
- `$runnableName results placed in source.`)
- } else {
- outputPane append(
- `$runnableName results: ${"\n"}$result`)
- }
- } catch err {outputPane append("\n" + `Script error: $err`)}
- eBrowser setStatus(`Script $runnableName completed.`)
- }
- }
- def scriptMenu := <swing:JMenu> new(title)
- for each in runnablesList {
- uiTools addMenuItem(scriptMenu,
- each,
- actionListenerMaker new(each))
- }
- scriptMenu
- }
- #def scriptFolder := <file:ebScripts>
- #def capScriptMenu := buildScriptMenu(
- #"capScripts",
- #buildScriptList(scriptFolder, "emaker"),
- #scriptFolder,
- #def confiner(source) :any {confinedRunner(source, outputPane)})
- #E call(menubar, "add(JMenu)", [capScriptMenu])
+ # Option menu
+ var capScriptsMaySubstitute := false
+ #def substitutionAllowedMenuItem :=
+ #<swing:JCheckBoxMenuItem> new("capScripts May Substitute")
+ #E call(optionMenu, "add(JMenuItem)", [substitutionAllowedMenuItem])
+ #def toggleSubstitution() {#
+ #capScriptsMaySubstitute := substitutionAllowedMenuItem getState()
+ #}
+ #uiTools attachAction(substitutionAllowedMenuItem,toggleSubstitution)
+
+
+ # capScript menu
+ # scriptEvaluator must be a single-argument receiver, receiving a
+ # source text
+ def buildScriptMenu(title, runnablesList, folder, scriptEvaluator) :any {
+ class actionListenerMaker(runnableName) :any {
+ # def selectionStart := textPane getSelectionStart()
+ # def selectionEnd := textPane getSelectionEnd()
+ # def textSize := textPane getText() size()
+ def action() {
+ eBrowser setStatus(`Running script: $runnableName ...`)
+ try {
+ def source := folder[runnableName] getText()
+ def script := scriptEvaluator(source)
+ def result := script(textPane getSelectedText())
+ if (capScriptsMaySubstitute &&
+ script requestsSubstitution()
+ ) {
+ replaceSelectionHilite(result)
+ outputPane append(
+ `$runnableName results placed in source.`)
+ } else {
+ outputPane append(
+ `$runnableName results: ${"\n"}$result`)
+ }
+ } catch err {outputPane append("\n" + `Script error: $err`)}
+ eBrowser setStatus(`Script $runnableName completed.`)
+ }
+ }
+ def scriptMenu := <swing:JMenu> new(title)
+ for each in runnablesList {
+ uiTools addMenuItem(scriptMenu,
+ each,
+ actionListenerMaker new(each))
+ }
+ scriptMenu
+ }
+ #def scriptFolder := <file:ebScripts>
+ #def capScriptMenu := buildScriptMenu(
+ #"capScripts",
+ #buildScriptList(scriptFolder, "emaker"),
+ #scriptFolder,
+ #def confiner(source) :any {confinedRunner(source, outputPane)})
+ #E call(menubar, "add(JMenu)", [capScriptMenu])
def indentGroup := <swing:ButtonGroup> new()
var defaultIndentItem := null
@@ -778,292 +776,292 @@
menuReactor)
def menuBar := mm menuBar([
mm menu("&File", [
- mm action("&New", "Ctrl+N"),
- mm action("&Open...", "Ctrl+O"),
- mm action("&Save", "Ctrl+S"),
- mm action("Save &As...")
- ]),
+ mm action("&New", "Ctrl+N"),
+ mm action("&Open...", "Ctrl+O"),
+ mm action("&Save", "Ctrl+S"),
+ mm action("Save &As...")
+ ]),
mm menu("For&mat", [
- defaultIndentItem :=
- mm radio(indentGroup, mm action("Use Spaces")),
- mm radio(indentGroup, mm action("Use Tabs")),
- "--",
- mm action("Smaller Font", "Ctrl+OPEN_BRACKET"),
- mm action("Larger Font", "Ctrl+CLOSE_BRACKET")
- ]),
+ defaultIndentItem :=
+ mm radio(indentGroup, mm action("Use Spaces")),
+ mm radio(indentGroup, mm action("Use Tabs")),
+ "--",
+ mm action("Smaller Font", "Ctrl+OPEN_BRACKET"),
+ mm action("Larger Font", "Ctrl+CLOSE_BRACKET")
+ ]),
mm menu("&Help", [
- mm action("&About...")
- ])
+ mm action("&About...")
])
+ ])
defaultIndentItem setSelected(true)
mainFrame setJMenuBar(menuBar)
+
+ # configure and show window
+ mainPane add(realPane)
+ setTitle()
+ textPane setText(textModel getText())
+ textPane setCaretPosition(0)
+ mainFrame pack()
+ mainFrame setSize(1000,700)
+ mainFrame setLocation(50 + entropy nextInt() % 30, 50 + entropy nextInt() % 30)
+ E call(outLineSplitter, "setDividerLocation(int)",[200])
+ E call(outputSplitter, "setDividerLocation(double)",[0.9])
+ # def width := varLineSplitter getBounds() width()
+ E call(varLineSplitter, "setDividerLocation(int)",[600])
+ mainFrame show()
+
+ def windowActiveListener {
+ to windowActivated(e) {
+ if (textModel storedVersionIsNewer()) {
+ var message := "The file has been updated outside eBrowser. Would you like to reload the file?"
+ if (textPane getText() != textModel getText()) {
+ message := message +
+ " Note, eBrowser has edited since last save too."
+ }
+ def shouldUpdate := <swing:JOptionPane> showConfirmDialog(
+ mainFrame,
+ message, "File updated outside eBrowser",
+ <swing:JOptionPane> YES_NO_OPTION())
+ if (shouldUpdate == <swing:JOptionPane> YES_OPTION()) {
+ textPane setText(textModel reload())
+ } else {textModel resetSaveTimeNoReload()}
- # configure and show window
- mainPane add(realPane)
- setTitle()
- textPane setText(textModel getText())
- textPane setCaretPosition(0)
- mainFrame pack()
- mainFrame setSize(1100,900)
- mainFrame setLocation(50 + entropy nextInt() % 30, 50 + entropy nextInt() % 30)
- E call(outLineSplitter, "setDividerLocation(int)",[200])
- E call(outputSplitter, "setDividerLocation(int)",[-1])
- # def width := varLineSplitter getBounds() width()
- E call(varLineSplitter, "setDividerLocation(int)",[800])
- mainFrame show()
-
- def windowActiveListener {
- to windowActivated(e) {
- if (textModel storedVersionIsNewer()) {
- var message := "The file has been updated outside eBrowser. Would you like to reload the file?"
- if (textPane getText() != textModel getText()) {
- message := message +
- " Note, eBrowser has edited since last save too."
- }
- def shouldUpdate := <swing:JOptionPane> showConfirmDialog(
- mainFrame,
- message, "File updated outside eBrowser",
- <swing:JOptionPane> YES_NO_OPTION())
- if (shouldUpdate == <swing:JOptionPane> YES_OPTION()) {
- textPane setText(textModel reload())
- } else {textModel resetSaveTimeNoReload()}
-
- }
- }
- match _ {}
- }
+ }
+ }
+ match _ {}
+ }
mainFrame addWindowListener(windowActiveListener)
- startOutlineSyncer(farBrowseServerMaker <- new(), textModel, textPane)
+ startOutlineSyncer(farBrowseServerMaker <- new(), textModel, textPane)
- def bind eBrowser {
- to save() {
- if (textModel saveFileIsSet()) {
- textModel setText(textPane getText())
- textModel save()
- textPane requestFocus()
- } else {saveAsFunc()}
- }
- to bringToTop() {mainFrame toFront()}
- to setStatus(statusText) {
- statusPane setText(statusText)
- statusPane repaint()
- }
- to find() {
- eBrowser setStatus("Finding...")
- def textSize := textPane getText() size()
- def startSearchIndex := textPane getCaretPosition()
- def searchArea := textPane getText(startSearchIndex,
- textSize - startSearchIndex)
- if (searchArea =~ `@{front}${searchField getText()}@{tail}`) {
- def startFoundIndex := front size() + startSearchIndex
- textPane setCaretPosition(startFoundIndex )
- textPane moveCaretPosition(
- startFoundIndex + searchField getText() size())
- eBrowser setStatus("Found")
- textPane requestFocus()
-
- } else {eBrowser setStatus("Not Found")}
- }
- to goto() {
- # println("into goto")
- # def intMaker := <unsafe:java.lang.Integer>
- # println(`got intMaker $intMaker`)
- # def lineNumText := searchField getText()
- # println(`got lineNumText $lineNumText`)
- # def intClassObj := intMaker new(lineNumText)
- # println(`got intClassObj $intClassObj`)
- # def lineNum := intClassObj intValue()
- def lineNum :=
- <unsafe:java.lang.Integer> parseInt(searchField getText())
- println(`got line num $lineNum`)
- def newPosition := textPane getLineStartOffset(lineNum)
- println(`got position $newPosition`)
- textPane setCaretPosition(
- textPane getLineStartOffset(lineNum + 1) - 1)
- println(`set caret position $lineNum`)
- textPane moveCaretPosition(newPosition)
- println(`moved caret position $newPosition`)
- textPane requestFocus()
- }
- to about() {popAboutBox()}
- to scratchpad() {elmer()}
- to executeHiLite() {
- outputPane setText("")
- def str := textPane getText()
- def reader := <unsafe:java.io.StringReader> new(str)
- def path := textModel getFilePath()
- def twine := reader getTwine(`file:$path`)
- def selection := twine(textPane getSelectionStart(),
- textPane getSelectionEnd())
- traceln(`Selection: "$selection"`)
- programRunner(selection, textPane, textModel, outputPane)
- # programRunner(textPane getSelectedText(),"",outputPane)
- }
- to executeProgram() {
- outputPane setText("")
- def str := textPane getText()
- def reader := <unsafe:java.io.StringReader> new(str)
- def path := textModel getFilePath()
- def twine := reader getTwine(`file:$path`)
- programRunner(twine, textPane, textModel, outputPane)
- }
- to insertVar() {
- def insert := "" + varListPane getSelectedValue()
- if (insert != null && insert size() > 0) {
- def insertVarTrimmed := insert trim()
- replaceSelectionHilite(insertVarTrimmed + " ")
- }
- }
- to insertFunc() {
- def insert := "" + funcListPane getSelectedValue()
- if (insert != null && insert size() > 0) {
- var insertSection := ""
- # get the chunk of func following the "to" or "def"
- if (insert =~ `@{leader} to @{tail}`) {
- insertSection := tail
- } else if (insert =~ `@{leader} class @{tail}`) {
- if (tail =~ `@name(@rest`) {
- insertSection := `$name new($rest`
- } else {insertSection := tail}
- } else if (insert =~ `@{leader} def bind @{tail}`) {
- insertSection := tail
- } else if (insert =~ `@{leader} def @{tail}`) {
- insertSection := tail
- } else {println(`non insertable func: $insert`)}
- # strip the :any type if present
- if (insertSection =~ `@{leader}:@{trailer}`) {
- insertSection := leader
- }
- insertSection := insertSection trim()
- replaceSelectionHilite("" + `$insertSection `)
- }
- }
- to alignVars() {
- def currentLine :=
- textPane getLineOfOffset(textPane getCaretPosition())
- var i := 0
- def indices := textModel getVarLineIndices()
- if (indices != null && indices size() > 0) {
- while (i < indices size() && indices[i] < currentLine) {
- i += 1
- }
- if (i > 0) {i := i - 1}
- varListPane setSelectedIndex(i)
- varListPane ensureIndexIsVisible(i)
- }
- textPane requestFocus()
- }
- to alignFuncs() {
- def currentLine :=
- textPane getLineOfOffset(textPane getCaretPosition())
- var i := 0
- def indices := textModel getOutlineIndices()
- if (indices != null && indices size() > 0) {
- while (i < indices size() && indices[i] < currentLine) {
- i += 1
- }
- if (i > 0) {i := i - 1}
- funcListPane setSelectedIndex(i)
- funcListPane ensureIndexIsVisible(i)
- }
- textPane requestFocus()
- }
- to reformat() {
- textPane setEditable(false)
- eBrowser setStatus("Reformatting...")
- textPane setText(prettyE(textPane getText(), tabValue))
- println(`did textPane setText`)
- textPane setEditable(true)
- eBrowser setStatus("Reformat Done.")
- }
- to linesChanged() {
- configureUpdatedListPane(funcListPane, textModel getOutlineList())
- configureUpdatedListPane(varListPane, textModel getVarLineList())
- }
- to pasteUpdoc() {
- def getPasteString() : any {
- var pastedString := ""
- # get access to the system clipboard
- def SysClip :=
- <awt:Toolkit> getDefaultToolkit() getSystemClipboard()
- # get the transfer object containing the text
- def transferObject := SysClip getContents(null)
- if (transferObject != null) {
- # def the flavor needed for extraction
- def stringFlavor :=
- <awt:datatransfer.DataFlavor> stringFlavor()
- # at last, get the string
- pastedString :=
- transferObject getTransferData(stringFlavor)
- }
- pastedString
- }
- def rawcode := getPasteString()
- var cleancode := ""
- for each in rawcode split("\n") {
- if (each =~ `? @{cleanline}`) {
- cleancode := cleancode + cleanline
- } else if (each =~ `> @{cleanline}`) {
- cleancode := cleancode + cleanline
- } else {cleancode := cleancode + each}
- }
- replaceSelectionHilite(cleancode)
- }
- to windowClosing() {
- def closeCleanly() {
- textModel close()
- mainFrame dispose()
- }
- if (!closingInProcess) {
- closingInProcess := true
- # def finalText:= textPane getText()
- if (textPane getText() == textModel getText()) {
- closeCleanly()
- } else {
- def saveDecision := dialogPromiser new(
- "Modified File " + textModel getFileName(),
- "Save Before Exiting?",
- null,
- ["Save", "Exit", "Cancel"])
- when (saveDecision <- getClickedButton()) -> done(answer) {
- closingInProcess := false
- if (answer == null) {
- # answer := "Cancel"
- }
- if (answer =="Save") {
- traceln("into save")
- eBrowser save()
- closeCleanly()
- } else if (answer == "Exit") {
- closeCleanly()
- }
- } catch err {println(`save dialog broken promise: $err`)}
- }
- }
- }
- }
+ def bind eBrowser {
+ to save() {
+ if (textModel saveFileIsSet()) {
+ textModel setText(textPane getText())
+ textModel save()
+ textPane requestFocus()
+ } else {saveAsFunc()}
+ }
+ to bringToTop() {mainFrame toFront()}
+ to setStatus(statusText) {
+ statusPane setText(statusText)
+ statusPane repaint()
+ }
+ to find() {
+ eBrowser setStatus("Finding...")
+ def textSize := textPane getText() size()
+ def startSearchIndex := textPane getCaretPosition()
+ def searchArea := textPane getText(startSearchIndex,
+ textSize - startSearchIndex)
+ if (searchArea =~ `@{front}${searchField getText()}@{tail}`) {
+ def startFoundIndex := front size() + startSearchIndex
+ textPane setCaretPosition(startFoundIndex )
+ textPane moveCaretPosition(
+ startFoundIndex + searchField getText() size())
+ eBrowser setStatus("Found")
+ textPane requestFocus()
+
+ } else {eBrowser setStatus("Not Found")}
+ }
+ to goto() {
+ # println("into goto")
+ # def intMaker := <unsafe:java.lang.Integer>
+ # println(`got intMaker $intMaker`)
+ # def lineNumText := searchField getText()
+ # println(`got lineNumText $lineNumText`)
+ # def intClassObj := intMaker new(lineNumText)
+ # println(`got intClassObj $intClassObj`)
+ # def lineNum := intClassObj intValue()
+ def lineNum :=
+ <unsafe:java.lang.Integer> parseInt(searchField getText())
+ println(`got line num $lineNum`)
+ def newPosition := textPane getLineStartOffset(lineNum)
+ println(`got position $newPosition`)
+ textPane setCaretPosition(
+ textPane getLineStartOffset(lineNum + 1) - 1)
+ println(`set caret position $lineNum`)
+ textPane moveCaretPosition(newPosition)
+ println(`moved caret position $newPosition`)
+ textPane requestFocus()
+ }
+ to about() {popAboutBox()}
+ to scratchpad() {elmer()}
+ to executeHiLite() {
+ outputPane setText("")
+ def str := textPane getText()
+ def reader := <unsafe:java.io.StringReader> new(str)
+ def path := textModel getFilePath()
+ def twine := reader getTwine(`file:$path`)
+ def selection := twine(textPane getSelectionStart(),
+ textPane getSelectionEnd())
+ traceln(`Selection: "$selection"`)
+ programRunner(selection, textPane, textModel, outputPane)
+ # programRunner(textPane getSelectedText(),"",outputPane)
+ }
+ to executeProgram() {
+ outputPane setText("")
+ def str := textPane getText()
+ def reader := <unsafe:java.io.StringReader> new(str)
+ def path := textModel getFilePath()
+ def twine := reader getTwine(`file:$path`)
+ programRunner(twine, textPane, textModel, outputPane)
+ }
+ to insertVar() {
+ def insert := "" + varListPane getSelectedValue()
+ if (insert != null && insert size() > 0) {
+ def insertVarTrimmed := insert trim()
+ replaceSelectionHilite(insertVarTrimmed + " ")
+ }
+ }
+ to insertFunc() {
+ def insert := "" + funcListPane getSelectedValue()
+ if (insert != null && insert size() > 0) {
+ var insertSection := ""
+ # get the chunk of func following the "to" or "def"
+ if (insert =~ `@{leader} to @{tail}`) {
+ insertSection := tail
+ } else if (insert =~ `@{leader} class @{tail}`) {
+ if (tail =~ `@name(@rest`) {
+ insertSection := `$name new($rest`
+ } else {insertSection := tail}
+ } else if (insert =~ `@{leader} def bind @{tail}`) {
+ insertSection := tail
+ } else if (insert =~ `@{leader} def @{tail}`) {
+ insertSection := tail
+ } else {println(`non insertable func: $insert`)}
+ # strip the :any type if present
+ if (insertSection =~ `@{leader}:@{trailer}`) {
+ insertSection := leader
+ }
+ insertSection := insertSection trim()
+ replaceSelectionHilite("" + `$insertSection `)
+ }
+ }
+ to alignVars() {
+ def currentLine :=
+ textPane getLineOfOffset(textPane getCaretPosition())
+ var i := 0
+ def indices := textModel getVarLineIndices()
+ if (indices != null && indices size() > 0) {
+ while (i < indices size() && indices[i] < currentLine) {
+ i += 1
+ }
+ if (i > 0) {i := i - 1}
+ varListPane setSelectedIndex(i)
+ varListPane ensureIndexIsVisible(i)
+ }
+ textPane requestFocus()
+ }
+ to alignFuncs() {
+ def currentLine :=
+ textPane getLineOfOffset(textPane getCaretPosition())
+ var i := 0
+ def indices := textModel getOutlineIndices()
+ if (indices != null && indices size() > 0) {
+ while (i < indices size() && indices[i] < currentLine) {
+ i += 1
+ }
+ if (i > 0) {i := i - 1}
+ funcListPane setSelectedIndex(i)
+ funcListPane ensureIndexIsVisible(i)
+ }
+ textPane requestFocus()
+ }
+ to reformat() {
+ textPane setEditable(false)
+ eBrowser setStatus("Reformatting...")
+ textPane setText(prettyE(textPane getText(), tabValue))
+ println(`did textPane setText`)
+ textPane setEditable(true)
+ eBrowser setStatus("Reformat Done.")
+ }
+ to linesChanged() {
+ configureUpdatedListPane(funcListPane, textModel getOutlineList())
+ configureUpdatedListPane(varListPane, textModel getVarLineList())
+ }
+ to pasteUpdoc() {
+ def getPasteString() : any {
+ var pastedString := ""
+ # get access to the system clipboard
+ def SysClip :=
+ <awt:Toolkit> getDefaultToolkit() getSystemClipboard()
+ # get the transfer object containing the text
+ def transferObject := SysClip getContents(null)
+ if (transferObject != null) {
+ # def the flavor needed for extraction
+ def stringFlavor :=
+ <awt:datatransfer.DataFlavor> stringFlavor()
+ # at last, get the string
+ pastedString :=
+ transferObject getTransferData(stringFlavor)
+ }
+ pastedString
+ }
+ def rawcode := getPasteString()
+ var cleancode := ""
+ for each in rawcode split("\n") {
+ if (each =~ `? @{cleanline}`) {
+ cleancode := cleancode + cleanline
+ } else if (each =~ `> @{cleanline}`) {
+ cleancode := cleancode + cleanline
+ } else {cleancode := cleancode + each}
+ }
+ replaceSelectionHilite(cleancode)
+ }
+ to windowClosing() {
+ def closeCleanly() {
+ textModel close()
+ mainFrame dispose()
+ }
+ if (!closingInProcess) {
+ closingInProcess := true
+ # def finalText:= textPane getText()
+ if (textPane getText() == textModel getText()) {
+ closeCleanly()
+ } else {
+ def saveDecision := dialogPromiser new(
+ "Modified File " + textModel getFileName(),
+ "Save Before Exiting?",
+ null,
+ ["Save", "Exit", "Cancel"])
+ when (saveDecision <- getClickedButton()) -> done(answer) {
+ closingInProcess := false
+ if (answer == null) {
+ # answer := "Cancel"
+ }
+ if (answer =="Save") {
+ traceln("into save")
+ eBrowser save()
+ closeCleanly()
+ } else if (answer == "Exit") {
+ closeCleanly()
+ }
+ } catch err {println(`save dialog broken promise: $err`)}
+ }
+ }
+ }
+ }
}
def acquireBrowseServerMaker() {
- introducer onTheAir()
- def tryAgain(e) {
- traceln("trying to acquire server")
- #<unsafe:org.erights.e.extern.timer.Timer> theTimer() after(10000,
- # acquireBrowseServerMaker)
+ introducer onTheAir()
+ def tryAgain(e) {
+ traceln("trying to acquire server")
+ #<unsafe:org.erights.e.extern.timer.Timer> theTimer() after(10000,
+ # acquireBrowseServerMaker)
timer whenAlarm(10_000 + timer now(), acquireBrowseServerMaker)
- }
- try {
- def serverPromise :=
- uriTools promiseObject(<file:browseServer.cap> getText())
- when (serverPromise) -> done(server) {
- farBrowseServerResolver resolve(server)
- traceln("GOT server")
- } catch e {tryAgain(e)}
- } catch serverErr {tryAgain(serverErr)}
+ }
+ try {
+ def serverPromise :=
+ uriTools promiseObject(<file:browseServer.cap> getText())
+ when (serverPromise) -> done(server) {
+ farBrowseServerResolver resolve(server)
+ traceln("GOT server")
+ } catch e {tryAgain(e)}
+ } catch serverErr {tryAgain(serverErr)}
}
# stub browse server for nonComm version
# acquireBrowseServerMaker()
@@ -1075,7 +1073,7 @@
unsafe__uriGetter, introducer, println)
def source := "<import:com.skyhunter.eBrowser.syncServerMakerAuthor> run(unsafe__uriGetter, stdout)"
def vat := vatMaker new(source, [], interp getProps(), "Sync Server Maker")
- def farSyncServerMaker := vat promisePrimorialObj()
+ def farSyncServerMaker := vat promisePrimordialObj()
farBrowseServerResolver resolve(farSyncServerMaker)
}
makeFarSyncServer()
@@ -1083,12 +1081,13 @@
var optBrowseFile := null
def commandArgs := interp getArgs()
if (commandArgs size() > 0) {
- def name := commandArgs[0]
- optBrowseFile := <file: name>
+ def name := commandArgs[0]
+ optBrowseFile := <file: name>
}
def browser := eBrowserMaker new(textModelMaker new(optBrowseFile))
if (optBrowseFile != null) {
- openFiles[optBrowseFile getCanonicalPath()] := browser
+ openFiles[optBrowseFile getCanonicalPath()] := browser
}
interp blockAtTop()
+
1.3 +1 -1 e/src/esrc/scripts/evalServer.updoc
Index: evalServer.updoc
===================================================================
RCS file: /cvs/e/src/esrc/scripts/evalServer.updoc,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- evalServer.updoc 2001/08/21 14:28:14 1.2
+++ evalServer.updoc 2001/08/24 17:14:02 1.3
@@ -1,7 +1,7 @@
? introducer onTheAir()
# value: ["3DES_SDH_M"]
-? def sr := <cap://192.168.0.21:2093;63.178.231.159:2093/VmNr75EJgkClc4GYgHFcTkAJo=u/0DPAx5Y2bOfTURHDToQoiXE1f6ED>
+? def sr := <cap://192.168.0.21:1385;63.178.231.220:1385/6BoBqEMMnqCNwHEQNclG5O5a8Nq/Cg_dzihfAveXfXwEIjJNhjLucSC>
# value: <SturdyRef>
? def evalServerPass := sr liveRef()
1.11 +87 -55 e/src/esrc/scripts/updoc.e
Index: updoc.e
===================================================================
RCS file: /cvs/e/src/esrc/scripts/updoc.e,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- updoc.e 2001/08/13 20:38:10 1.10
+++ updoc.e 2001/08/24 17:14:02 1.11
@@ -1,5 +1,10 @@
#!/usr/bin/env e
+def traceln(str) { println(`updoc $str`) }
+# def traceln(str) {}
+
+traceln("cp1")
+
def EParser := <import:org.erights.e.elang.syntax.EParser>
def ScopeSetup := <unsafe:org.erights.e.elang.interp.ScopeSetup>
def trimLines := <import:org.erights.e.tools.text.trimLines>
@@ -11,6 +16,10 @@
def html2txt := <import:org.erights.e.tools.html.html2txt>
def integerMaker := <import:java.math.BigInteger>
+def updocParserMaker
+
+traceln("cp2")
+
def foldLines(lines) :any { trimLines(lines) replaceAll("\\\n", "") }
# Prints an output record
@@ -122,29 +131,14 @@
# <tt>runTest</tt> evaluates an expression and remembers the
# new answers.
- to runTest(pov) {
- def exprTree := try {
- EParser(expr)
- } catch problem {
- # XXX should use TextWriter parameter
- stdout println()
- printBlock("**can't parse", expr, stdout)
- throw(problem)
- }
- var value := null
- var succeeded := false
- def answers := [] asMap() diverge()
- try {
- value := exprTree eval(pov)
- succeeded := true
- } catch problem {
- answers["problem"] := foldLines(""+problem+"\n")
- }
- if (succeeded && value != null) {
- answers["value"] := foldLines(E toQuote(value)+"\n")
- }
- # XXX Doesn't capture stdout or stderr
- newAnswers := answers snapshot()
+ to newReportVow(scriptEvaluatorQ) :any {
+ scriptEvaluatorQ <- evalCmdVow(expr)
+ }
+
+ to report(newReport, out) {
+ def parser := updocParserMaker new(newReport)
+ newAnswers := parser readAnswers()
+ testCase printDiffsOn(out)
}
}
}
@@ -174,21 +168,32 @@
# run in sequence in the same scope, so that each test case
# sees the scope as affected by previous cases.
- to runTest() {
- def scope := ScopeSetup privileged(true,
- stdout,
- stderr,
- interp)
- def pov := scope newPov()
+ to runTest(scriptEvaluatorQ, out) {
+ def newReportVows := [] diverge()
for testCase in cases {
- testCase runTest(pov)
+ newReportVows push(testCase newReportVow(scriptEvaluatorQ))
+ }
+ newReportVows := newReportVows snapshot()
+ def doWhen(i) {
+ if (i < newReportVows size()) {
+ when (newReportVows[i]) -> done(newReport) {
+ cases[i] report(newReport, out)
+ } catch problem {
+ out lnPrint(`no eval report: $problem`)
+ } finally {
+ doWhen(i+1)
+ }
+ }
}
+ doWhen(0)
}
to size() :integer { cases size() }
}
}
+traceln("cp3")
+
# <tt>updocParser</tt> parses <tt>updoc</tt> files into test cases
# that constitute a test script to run.
# <p>
@@ -224,7 +229,7 @@
# @author <a href="mailto:tstanley@cocoon.com">Terry Stanley</a>
# @author <a href="mailto:markm@caplet.com">Mark Miller</a>
-class updocParserMaker(testSrc) :any {
+class bind updocParserMaker(testSrc) :any {
def lines := testSrc split("\n")
var index := 0
@@ -246,7 +251,7 @@
var result := ""
var current := lines[index] trim()
while (true) {
- # skip ? (or >) and (optional) space
+ # skip "?" (or ">") and (optional) space
current := current run(1, current size())
if (current =~ ` @rest`) {
current := rest
@@ -267,7 +272,7 @@
result
}
- # <tt>readAnswer</tt> reads a single or multi-line answer.
+ # <tt>readOptAnswer</tt> reads a single or multi-line answer.
# <p>
# It expects the formats shown below,
# <pre>
@@ -280,7 +285,7 @@
# </pre>
# For answers with the keyword "problem" the stack trace is skipped.
- def readAnswer() :any {
+ def readOptAnswer() :any {
escape return {
var keyword := null
var answer := ""
@@ -293,14 +298,14 @@
answer += text trim() + "\n"
index += 1
while (index < lines size() &&
- lines[index] trim() =~ `#@rest`) {
+ lines[index] trim() =~ `#@rest`) {
# multi-line answer block
def nextLine := rest trim()
# skip over the stack trace which can vary from run to run
if (nextLine =~ `` && keyword =~ `problem`) {
index += 1
while (index < lines size() &&
- lines[index] trim() =~ `#@_`) {
+ lines[index] trim() =~ `#@_`) {
index += 1
}
break()
@@ -329,20 +334,25 @@
# Each test case is an expression and a set of answers.
def updocParser {
+
+ to readAnswers() :any {
+ def answers := [] asMap() diverge()
+ while (readOptAnswer() =~ [keyword, answer]) {
+ answers[keyword] := answer
+ # blank line follows answer block
+ readBlankLine()
+ }
+ answers snapshot()
+ }
- to parse() :any {
+ to readScript() :any {
def cases := [] diverge()
while (index < lines size()) {
def current := lines[index] trim()
if (current startsWith("?")) {
def expr := readExpr()
- def answers := [] asMap() diverge()
- while (readAnswer() =~ [keyword, answer]) {
- answers[keyword] := answer
- # blank line follows answer block
- readBlankLine()
- }
- cases push(testCaseMaker new(expr, answers snapshot()))
+ def answers := updocParser readAnswers()
+ cases push(testCaseMaker new(expr, answers))
} else {
index += 1
}
@@ -352,15 +362,16 @@
}
}
+traceln("cp4")
+
# Given the source text string (or twine) of an updoc file, parse, run,
# and report the test outcomes.
-def updocTestSrc(testSrc, out) :boolean {
+def updocTestSrc(testSrc, scriptEvaluatorQ, out) :boolean {
try {
def parser := updocParserMaker new(testSrc)
def script := parser parse()
- script runTest()
- script printOn(out)
+ script runTest(scriptEvaluatorQ, out)
script size() >= 1
} catch problem {
if (problem leaf() =~ sex :SyntaxException) {
@@ -405,14 +416,18 @@
}
}
+traceln("cp5")
+
def eHome := <file: interp getProps()["e.home"]>
def hashCache := hashCacheMaker new(eHome["updoc-hash-cache.txt"])
+traceln("cp6")
+
# Run updoc either on a ".updoc" file, on the text extracted from a
# ".html" file.
-def updocOne(file, path, out) {
+def updocOne(file, path, evalServerQ, out) {
def hash := file getCryptoHash()
if (hashCache has(hash)) {
out lnPrint(`skipping $path`)
@@ -422,7 +437,8 @@
# to pass source info through (preserving twine-ness), then
# switch from getText() to getTwine()
def testSrc := file getText()
- if (! (updocTestSrc(testSrc, out))) {
+ def scriptEvaluatorQ := evalServerQ <- newScriptEvaluator([])
+ if (! (updocTestSrc(testSrc, scriptEvaluatorQ, out))) {
hashCache put(hash)
}
} else if (endsWithAny(path, [".html", ".htm"])) {
@@ -432,10 +448,13 @@
html2txt(htmlSrc)
} catch problem {
out lnPrint(`can't parse $path: `)
- out indent("# ") print(problem)
+ out indent("# ") print(problem)
null
}
- if (testSrc != null && ! (updocTestSrc(testSrc, out))) {
+ def scriptEvaluatorQ := evalServerQ <- newScriptEvaluator([])
+ if (testSrc != null &&
+ ! (updocTestSrc(testSrc, scriptEvaluatorQ, out))) {
+
hashCache put(hash)
}
} else {
@@ -443,17 +462,30 @@
}
}
+traceln("cp7")
+
+def cmd__uriGetter := <import:org.erights.e.elang.cmd.*>
+traceln("cp8")
+def evalServerMaker :=
+ <cmd:evalServerMakerAuthor>(unsafe__uriGetter, introducer, println)
+traceln("cp9")
+def vat := evalServerMaker new([], interp getProps(), "updocer")
+traceln("cp10")
+def evalServerQ := vat getEvalServerQ()
+traceln("cp11")
+
# Run updoc either on a ".updoc" file, on the text extracted from a
# ".html" file, or on all such files in a directory tree, or on a URL.
def updoc(filedir, out) {
if (filedir =~ url :URL) {
- updocOne(url, url toExternalForm(), out)
+ updocOne(url, url toExternalForm(), evalServerQ, out)
} else if (filedir isDirectory()) {
- for each in filedir { updoc(each, out) }
- hashCache checkpoint()
+ throw("XXX not yet implemented")
+ # for each in filedir { updoc(each, out) }
+ # hashCache checkpoint()
} else {
- updocOne(filedir, filedir getPath(), out)
+ updocOne(filedir, filedir getPath(), evalServerQ, out)
}
}
1.63 +2 -7 e/src/jsrc/org/erights/e/elang/interp/ScopeSetup.java
Index: ScopeSetup.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elang/interp/ScopeSetup.java,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -r1.62 -r1.63
--- ScopeSetup.java 2001/08/19 06:35:55 1.62
+++ ScopeSetup.java 2001/08/24 17:14:02 1.63
@@ -204,6 +204,8 @@
{ "TextWriter", ClassDesc.make(TextWriter.class) },
{ "import__uriGetter", importer },
+ { "resource__uriGetter",
+ StaticMaker.make(ResourceUriGetter.class) },
{ "simple__quasiParser", SimpleQuasiParser.THE_ONE },
{ "rx__quasiParser", univ,
"<import:org.erights.e.elang.interp.PerlMatchMakerMaker>" },
@@ -303,13 +305,6 @@
{ "JPanel__quasiParser", privScope,
"<import:org.erights.ex.swing.JPanelQParserMaker> " +
"new(awt__uriGetter, swing__uriGetter)" },
- { "resource__uriGetter", privScope,
- "def resource__uriGetter {\n" +
- " to get(relpath) :any {\n" +
- " def ClassLoader := <unsafe:java.lang.ClassLoader>\n" +
- " ClassLoader getSystemResource(relpath)\n" +
- " }\n" +
- "}" },
{ "CommandMaker", privScope,
"<import:org.erights.e.elib.extern.CommandMakerAuthor>(" +
1.1 e/src/jsrc/org/erights/e/elang/interp/ResourceUriGetter.java
Index: ResourceUriGetter.java
===================================================================
package org.erights.e.elang.interp;
/*
The contents of this file are subject to the Improvements to the
Distributed E Language Implementation License Version 1.0 (the
"License"); you may not use this file except in compliance with the
License. You may obtain a copy of the License at
http://www.erights.org/mmlicense.html
Software distributed under the License is distributed on an "AS IS"
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
the License for the specific language governing rights and limitations
under the License.
The Original Code is the Improvements to the Distributed E Language
Implementation, released May 27, 1999.
The Initial Developer of the Original Code is Mark S. Miller.
Copyright (C) 1999 Mark S. Miller. All Rights Reserved.
Contributor(s): ______________________________________.
*/
import java.net.URL;
/**
* Bound to resource__uriGetter in the universal scope
*/
public class ResourceUriGetter {
/** prevent instantiation */
private ResourceUriGetter() {}
/**
* <resource:...> expands to resource__uriGetter get(...)
*/
static public URL get(String relpath) {
return ClassLoader.getSystemResource(relpath);
}
}
1.1 e/src/jsrc/org/erights/e/elib/prim/SynchQueue.java
Index: SynchQueue.java
===================================================================
package org.erights.e.elib.prim;
/*
The contents of this file are subject to the Electric Communities E Open
Source Code License Version 1.0 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of the License
at http://www.communities.com/EL/.
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
the specific language governing rights and limitations under the License.
The Original Code is the Distributed E Language Implementation, released
July 20, 1998.
The Initial Developer of the Original Code is Electric Communities.
Copyright (C) 1998 Electric Communities. All Rights Reserved.
Contributor(s): ______________________________________.
*/
import java.lang.reflect.Array;
import java.util.Enumeration;
import java.util.NoSuchElementException;
/**
* A SynchQueue is a thread-safe Queue, providing its own lock, and a
* blocking dequeue() operation. <p>
*
* Since it provides a blocking operation, it is not E-safe. For an E-safe
* variant suitable for use inside one vat, see the superclass {@link Queue}.
*
* @see org.erights.e.elib.prim.Runner
* @author <a href="mailto:markm@erights.org">Mark S. Miller</a>
*/
public class SynchQueue extends Queue {
private Object myQLock;
/**
* Makes a SynchQueue that can hold any object (except null).
*/
public SynchQueue() {
this(Object.class);
}
/**
* Makes a SynchQueue that can hold objects of the specified elementType.
*
* @param elementType may not be a primitive (ie, scalar) type.
*/
public SynchQueue(Class elementType) {
super(elementType);
myQLock = new Object();
}
/**
* Get the least-recently-added element off of the queue. If the queue
* is currently empty, block until there is an element that can be
* dequeued.
*/
public Object dequeue() {
synchronized(myQLock) {
while(true) {
Object result = optDequeue();
if (result != null) {
return result;
}
try {
myQLock.wait();
} catch (InterruptedException ie) {
//ignored on purpose, but we do recheck the queue rather
//than just waiting again
}
}
}
}
/**
*
*/
public void enqueue(Object newElement) {
synchronized(myQLock) {
super.enqueue(newElement);
myQLock.notifyAll();
}
}
/**
*
*/
public Object optDequeue() {
synchronized(myQLock) {
return super.optDequeue();
}
}
}
1.1 e/src/jsrc/org/erights/e/elib/serial/RemoteCall.java
Index: RemoteCall.java
===================================================================
package org.erights.e.elib.serial;
/*
The contents of this file are subject to the Improvements to the
Distributed E Language Implementation License Version 1.0 (the
"License"); you may not use this file except in compliance with the
License. You may obtain a copy of the License at
http://www.erights.org/mmlicense.html
Software distributed under the License is distributed on an "AS IS"
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
the License for the specific language governing rights and limitations
under the License.
The Original Code is the Improvements to the Distributed E Language
Implementation, released May 27, 1999.
The Initial Developer of the Original Code is Mark S. Miller.
Copyright (C) 1999 Mark S. Miller. All Rights Reserved.
Contributor(s): ______________________________________.
*/
import java.io.IOException;
import java.io.Serializable;
import org.erights.e.elib.base.TextWriter;
import org.erights.e.elib.prim.E;
import org.erights.e.elib.ref.Ref;
import org.erights.e.elib.ref.StemCell;
import org.erights.e.elib.tables.ConstList;
/**
* A RemoteCall unserializes into the result of <pre>
*
* recipient verb(args...)
* </pre>
* allowing arbitrary execution *during* deserialization, but only within
* capability constraints. All pointers serialized as pointers to the
* RemoteCall will be deserialized as pointing to the result of the call, or,
* if the unserializtion of the RemoteCall is in progress, to a promise for
* this result. This may violate static types or other constraints, and
* cause deserialization to fail.
* <p>
* If the call throws a problem, then the resolution is a reference broken by
* that problem.
*
* @author <a href="mailto:markm@erights.org">Mark S. Miller</a>
*/
public class RemoteCall extends StemCell {
static final long serialVersionUID = 3703520454697636174L;
/** @serial receives the message */
private Object myRecipient;
/** @serial the message name (selector, method name) */
private String myVerb;
/** @serial the message arguments */
private Object[] myArgs;
/**
* Descibe an invocation to be run on the other side of a serialization
* barrier of some sort.
*
* @param recipient receives the message
* @param verb the message name (selector, method name)
* @param args the message arguments
*/
public RemoteCall(Object recipient,
String verb,
Object[] args)
{
myRecipient = recipient;
myVerb = verb;
myArgs = args;
}
/**
* Invoked directly by the ObjectInputStream following desrialization of
* the entire RemoteCall to get the object to use instead.
*/
private Object readResolve() {
Object result;
try {
result = E.callAll(myRecipient, myVerb, myArgs);
} catch (Throwable problem) {
result = Ref.broken(problem);
}
myOptResolver.resolve(result);
return result;
}
/**
*
*/
public void printOn(TextWriter out) throws IOException {
out.print("RemoteCall(", myRecipient, " <- ", myVerb);
ConstList.fromArray(myArgs).printOn("(", ", ", "))", out);
}
}
1.1 e/src/jsrc/org/erights/e/elib/tables/FlexList.updoc
Index: FlexList.updoc
===================================================================
? def x := ["x", "y"] diverge()
# value: ["x", "y"] diverge
? x(0,0) := ["a", "b"]
# value: ["a", "b"]
? x
# value: ["a", "b", "x", "y"] diverge
? x(1,3) := ["m", "n", "o"]
# value: ["m", "n", "o"]
? x
# value: ["a", "m", "n", "o", "y"] diverge
?