[e-cvs] cvs commit: e/src/jsrc/org/erights/e/elib/sealing Unsealer.java

markm@eros.cs.jhu.edu markm@eros.cs.jhu.edu
Sat, 4 Aug 2001 02:56:52 -0400


markm       01/08/04 02:56:52

  Modified:    src/esrc/scripts eBrowser.e
               src/jsrc/net/captp/jcomm ProxyConnection.java ProxyMgr.java
                        ProxyOutputStream.java RemoteHandler.java
               src/jsrc/org/erights/e/elang/interp Interp.java
               src/jsrc/org/erights/e/elib/sealing Unsealer.java
  Log:
  fixed new double syntax error bug

Revision  Changes    Path
1.27      +73 -73    e/src/esrc/scripts/eBrowser.e

Index: eBrowser.e
===================================================================
RCS file: /cvs/e/src/esrc/scripts/eBrowser.e,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- eBrowser.e	2001/07/31 13:09:14	1.26
+++ eBrowser.e	2001/08/04 06:56:52	1.27
@@ -24,12 +24,12 @@
 def eLogoURL := <resource:org/erights/e/icons/green-e-on-white-16.gif>
 def eLogoImage := <swing:ImageIcon> new(eLogoURL) getImage()
 def JFrameMaker {
-	to new(title) :any {
-    	def result := <swing:JFrame> new(title)
-    	result setIconImage(eLogoImage)
-    	result
-	}
-	to new() :any {JFrameMaker new("")}
+        to new(title) :any {
+        def result := <swing:JFrame> new(title)
+        result setIconImage(eLogoImage)
+        result
+        }
+        to new() :any {JFrameMaker new("")}
 }
 
 def promiseAllResolved := <import:com.skyhunter.e.net.promiseAllResolved>
@@ -148,12 +148,12 @@
         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("//") ||
+                        strippedLine startsWith("#")) {
+                        buf append(continuationIndent)
+                        buf append(tab * flowIndentLevel)
+                        buf append(strippedLine)
+                        buf push('\n')
         } else {
             if (strippedLine startsWith("}")) {
                 flowIndentLevel := (flowIndentLevel - 1) max(0)
@@ -658,21 +658,21 @@
         }
     }
 
-	def makeFontLarger() {
-		def oldFont := textPane getFont()
-		def newFont := oldFont deriveFont(0.0 + oldFont getSize() + 2.0)
-		textPane setFont(newFont)
-		funcListPane setFont(newFont)
-		varListPane setFont(newFont)
-	}
-
-	def makeFontSmaller() {
-		def oldFont := textPane getFont()
-		def newFont := oldFont deriveFont(0.0 + oldFont getSize() - 2.0)
-		textPane setFont(newFont)
-		funcListPane setFont(newFont)
-		varListPane setFont(newFont)
-	}
+        def makeFontLarger() {
+                def oldFont := textPane getFont()
+                def newFont := oldFont deriveFont(0.0 + oldFont getSize() + 2.0)
+                textPane setFont(newFont)
+                funcListPane setFont(newFont)
+                varListPane setFont(newFont)
+        }
+
+        def makeFontSmaller() {
+                def oldFont := textPane getFont()
+                def newFont := oldFont deriveFont(0.0 + oldFont getSize() - 2.0)
+                textPane setFont(newFont)
+                funcListPane setFont(newFont)
+                varListPane setFont(newFont)
+        }
 
     # Option menu
     var capScriptsMaySubstitute := false
@@ -729,48 +729,48 @@
         #def confiner(source) :any {confinedRunner(source, outputPane)})
     #E call(menubar, "add(JMenu)", [capScriptMenu])
 
-	def indentGroup := <swing:ButtonGroup> new()
-	var defaultIndentItem := null
+        def indentGroup := <swing:ButtonGroup> new()
+        var defaultIndentItem := null
 
-	def menuReactor {
-		to doNew(){newFileFunc()}
-		to doOpen() {openFunc()}
-		to doSave() {saveFunc()}
-		to doSaveAs() {saveAsFunc()}
-		to doUseTabs() {tabValue := "\t"}
-		to doUseSpaces() {tabValue := "    "}
-		to doSmallerFont() {makeFontSmaller()}
-		to doLargerFont() {makeFontLarger()}
-		to doAbout() {eBrowser about()}
-		match [verb,args] {traceln("menu hit for " + verb)}
-	}
-
-	#make the menus
-	def mm := <import:com.skyhunter.ex.swing.MenuMakerAuthor> (
-		swing__uriGetter,
-		<unsafe:org.erights.e.ui.jed.EAction>,
-		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 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")
-		]),
-		mm menu("&Help", [
-			mm action("&About...")
-		])
-	])
-	defaultIndentItem setSelected(true)
-	mainFrame setJMenuBar(menuBar)
+        def menuReactor {
+                to doNew(){newFileFunc()}
+                to doOpen() {openFunc()}
+                to doSave() {saveFunc()}
+                to doSaveAs() {saveAsFunc()}
+                to doUseTabs() {tabValue := "\t"}
+                to doUseSpaces() {tabValue := "    "}
+                to doSmallerFont() {makeFontSmaller()}
+                to doLargerFont() {makeFontLarger()}
+                to doAbout() {eBrowser about()}
+                match [verb,args] {traceln("menu hit for " + verb)}
+        }
+
+        #make the menus
+        def mm := <import:com.skyhunter.ex.swing.MenuMakerAuthor> (
+                swing__uriGetter,
+                <unsafe:org.erights.e.ui.jed.EAction>,
+                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 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")
+                ]),
+                mm menu("&Help", [
+                        mm action("&About...")
+                ])
+        ])
+        defaultIndentItem setSelected(true)
+        mainFrame setJMenuBar(menuBar)
 
     # configure and show window
     mainPane add(realPane)
@@ -804,7 +804,7 @@
         }
         match _ {}
     }
-	mainFrame addWindowListener(windowActiveListener)
+        mainFrame addWindowListener(windowActiveListener)
 
     startOutlineSyncer(farBrowseServerMaker <- new(), textModel, textPane)
 
@@ -988,10 +988,10 @@
                     postDeclaration := postTo trim()
                     declarationType := "to"
                 } else if (each =~ `@{varLeader}var @postVar`) {
-					leader := varLeader
-					postDeclaration := postVar trim()
-					declarationType := "var"
-				}
+                                        leader := varLeader
+                                        postDeclaration := postVar trim()
+                                        declarationType := "var"
+                                }
                 # if it looks like a class or def, using an open
                 # brace, process it as such
                 if (postDeclaration size() != 0 && leader trim() size() == 0) {



1.20      +33 -0     e/src/jsrc/net/captp/jcomm/ProxyConnection.java

Index: ProxyConnection.java
===================================================================
RCS file: /cvs/e/src/jsrc/net/captp/jcomm/ProxyConnection.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- ProxyConnection.java	2001/08/04 00:45:38	1.19
+++ ProxyConnection.java	2001/08/04 06:56:52	1.20
@@ -43,6 +43,10 @@
 import org.erights.e.elib.ref.Ref;
 import org.erights.e.elib.ref.Resolver;
 import org.erights.e.elib.ref.ProxyResolver;
+import org.erights.e.elib.sealing.Brand;
+import org.erights.e.elib.sealing.SealedBox;
+import org.erights.e.elib.sealing.Sealer;
+import org.erights.e.elib.sealing.Unsealer;
 import org.erights.e.elib.tables.ConstList;
 import org.erights.e.meta.java.math.BigIntegerSugar;
 
@@ -291,6 +295,11 @@
     /*package*/ Object getRemoteNonceLocator() {
         return myRemoteNonceLocator;
     }
+    
+    /**
+     *
+     */
+    /*package*/ Sealer getSealer() { return myProxyMgr.mySealer; }
 
     /**
      * Return our identity.
@@ -387,6 +396,30 @@
             throw new RuntimeException("internal: Not exportable");
         }
     }
+    
+    /**
+     * Figure out what kind of eventual reference 'ref' is, and return an 
+     * appropriate descriptor for encoding it over the wire.
+     */
+    /*package*/ ObjectRefDesc makeEventualDesc(Ref ref) {
+        Unsealer unsealer = myProxyMgr.myUnsealer;
+        Brand brand = unsealer.brand();
+        SealedBox optBox = ref.optMeta(brand);
+        RemoteHandler optHandler = 
+            (RemoteHandler)unsealer.unseal(optBox, RemoteHandler.class);
+        if (null == optHandler) {
+            //a local promise
+            return newRemoteVowDesc(ref);
+        } else {
+            if (this == optHandler.myConn) {
+                int pos = optHandler.getPos();
+                return new IncomingDesc(pos);
+            } else {
+                throw new RuntimeException("XXX 3vats not yet implemented");
+            }
+        }
+    }
+        
 
     /************************ Desc Messages *********************/
 



1.10      +11 -0     e/src/jsrc/net/captp/jcomm/ProxyMgr.java

Index: ProxyMgr.java
===================================================================
RCS file: /cvs/e/src/jsrc/net/captp/jcomm/ProxyMgr.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- ProxyMgr.java	2001/07/26 15:28:07	1.9
+++ ProxyMgr.java	2001/08/04 06:56:52	1.10
@@ -32,6 +32,9 @@
 import org.erights.e.develop.exception.ExceptionMgr;
 import org.erights.e.develop.trace.Trace;
 import org.erights.e.elib.ref.Resolver;
+import org.erights.e.elib.sealing.Brand;
+import org.erights.e.elib.sealing.Sealer;
+import org.erights.e.elib.sealing.Unsealer;
 import org.erights.e.elib.tables.ConstList;
 import org.erights.e.elib.tables.FlexMap;
 
@@ -58,6 +61,10 @@
     
     /** makes new unguessable numbers */
     private ESecureRandom myEntropy;
+    
+    /** for self recognition */
+    /*package*/ Sealer mySealer;
+    /*package*/ Unsealer myUnsealer;
 
     /**
      * Constructor
@@ -84,6 +91,10 @@
         myProxyConnections = FlexMap.fromTypes(DataConnection.class,
                                                ProxyConnection.class);
         myEntropy = entropy;
+        
+        Object[] pair = Brand.pair("captp");
+        mySealer = (Sealer)pair[0];
+        myUnsealer = (Unsealer)pair[1];
         
         if (Trace.captp.debug && Trace.ON) {
             Trace.captp.debugm("Create ProxyMgr " + this +



1.11      +1 -9      e/src/jsrc/net/captp/jcomm/ProxyOutputStream.java

Index: ProxyOutputStream.java
===================================================================
RCS file: /cvs/e/src/jsrc/net/captp/jcomm/ProxyOutputStream.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- ProxyOutputStream.java	2001/07/29 02:16:49	1.10
+++ ProxyOutputStream.java	2001/08/04 06:56:52	1.11
@@ -97,16 +97,8 @@
         }
         //end PCB testing
         
-        if (false /*XXX ref is a remote reference */) {
-            /* Send a remote references as an ObjectRefDesc (object reference 
-             * descriptor) which gets dereferenced when deserialized.
-             */
-            //return Proxy.makeDesc((Proxy)ref, myConn);
-            throw new RuntimeException
-                ("XXX remote ref serialization not yet implemented");
-        }
         if (Ref.isEventual(ref)) {
-            return myConn.newRemoteVowDesc(ref);
+            return myConn.makeEventualDesc(Ref.toRef(ref));
         } 
         if (Ref.isNear(ref)) {
             if (Ref.isPassByProxy(ref)) {



1.10      +6 -1      e/src/jsrc/net/captp/jcomm/RemoteHandler.java

Index: RemoteHandler.java
===================================================================
RCS file: /cvs/e/src/jsrc/net/captp/jcomm/RemoteHandler.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- RemoteHandler.java	2001/07/31 13:09:14	1.9
+++ RemoteHandler.java	2001/08/04 06:56:52	1.10
@@ -25,6 +25,7 @@
 import org.erights.e.elib.ref.ProxyHandler;
 import org.erights.e.elib.sealing.Brand;
 import org.erights.e.elib.sealing.SealedBox;
+import org.erights.e.elib.sealing.Sealer;
 import org.erights.e.elib.tables.FlexList;
 
 /**
@@ -127,7 +128,11 @@
      * How should my ref respond to an optMeta request?
      */
     public SealedBox handleOptMeta(Brand brand) {
-        throw new RuntimeException("XXX handleOptMeta not yet implemented");
+        Sealer sealer = myConn.getSealer();
+        if (brand != sealer.brand()) {
+            return null;
+        }
+        return sealer.seal(this);
     }
     
     /**



1.58      +3 -2      e/src/jsrc/org/erights/e/elang/interp/Interp.java

Index: Interp.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elang/interp/Interp.java,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -r1.57 -r1.58
--- Interp.java	2001/07/29 20:57:19	1.57
+++ Interp.java	2001/08/04 06:56:52	1.58
@@ -375,7 +375,7 @@
     }
 
     /**
-     * Not yet tested, because Elmer doesn't currently interacting correctly 
+     * Not yet tested, because Elmer doesn't currently interact correctly 
      * with interpreter exiting.
      */
     public void exitAtTop(Throwable optProblem) {
@@ -559,7 +559,8 @@
                 if (stopOnProblem) {
                     myShouldExit = true;
                     myOptProblem = th;
-                    reportProblem(th);
+                    //reportProblem(th); XXX would be redundant, but which 
+                    //                   one to keep? 
                     return th;
                 }
             }



1.8       +19 -0     e/src/jsrc/org/erights/e/elib/sealing/Unsealer.java

Index: Unsealer.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elib/sealing/Unsealer.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- Unsealer.java	2001/04/13 08:08:34	1.7
+++ Unsealer.java	2001/08/04 06:56:52	1.8
@@ -59,6 +59,25 @@
     }
     
     /**
+     * If 'optBox' isn't null, it unseals with this sealer, and it's contents 
+     * is of type 'type', then return those contents; otherwise return null.
+     */
+    public Object unseal(SealedBox optBox, Class type) {
+        if (null == optBox) {
+            return null;
+        }
+        if (myBrand != optBox.brand()) {
+            return null;
+        }
+        Object result = optBox.myContents;
+        if (type.isInstance(result)) {
+            return result;
+        } else {
+            return null;
+        }
+    }
+    
+    /**
      * Prints using the Brand's name
      */
     public void printOn(TextWriter out) throws IOException {