This is the mail archive of the kawa@sources.redhat.com mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

patch for call-with-input-url


2003-07-15  Bruce Lewis  <brlewis@users.sourceforge.net>

	* doc/kawa.texi: Document call-with-input-url.
	* kawa/lib/ports.scm: Implement call-with-input-url.
	* kawa/standard/Scheme: Bind call-with-input-url.

Index: doc/kawa.texi
===================================================================
RCS file: /cvs/kawa/kawa/doc/kawa.texi,v
retrieving revision 1.135
diff -u -r1.135 kawa.texi
--- doc/kawa.texi	3 Jul 2003 05:51:09 -0000	1.135
+++ doc/kawa.texi	15 Jul 2003 16:50:44 -0000
@@ -2764,6 +2764,12 @@
 Return a string consisting of the data written to the port.
 @end defun
 
+@defun call-with-input-url string proc
+Create an input port that gets its data from the full URL
+@var{string}, call @var{proc} with that port as its one argument,
+and return the result from the call of @var{proc}
+@end defun
+
 @defun force-output [port]
 Forces any pending output on @var{port} to be delivered to the output
 device and returns an unspecified value.  If the @var{port} argument is
Index: kawa/lib/ports.scm
===================================================================
RCS file: /cvs/kawa/kawa/kawa/lib/ports.scm,v
retrieving revision 1.27
diff -u -r1.27 ports.scm
--- kawa/lib/ports.scm	31 May 2003 01:39:55 -0000	1.27
+++ kawa/lib/ports.scm	15 Jul 2003 16:50:45 -0000
@@ -40,6 +40,16 @@
     (close-input-port port)
     result))
 
+(define (call-with-input-url (str :: <string>) proc)
+  (let* ((port
+	  (make <input-port>
+	    (invoke
+	     (make <java.net.URL> str)
+	     'open-stream)))
+	 (result (proc port)))
+    (close-input-port port)
+    result))
+
 (define (force-output #!optional (port (current-output-port)))
   ((primitive-virtual-method <java.io.Writer> "flush" <void> ())
    port))
Index: kawa/standard/Scheme.java
===================================================================
RCS file: /cvs/kawa/kawa/kawa/standard/Scheme.java,v
retrieving revision 1.137
diff -u -r1.137 Scheme.java
--- kawa/standard/Scheme.java	1 Jun 2003 16:53:30 -0000	1.137
+++ kawa/standard/Scheme.java	15 Jul 2003 16:50:45 -0000
@@ -366,6 +366,7 @@
       define_proc ("transcript-off", "kawa.lib.ports");
       define_proc ("transcript-on", "kawa.lib.ports");
       define_proc ("call-with-input-string", "kawa.lib.ports");  // Extension
+      define_proc ("call-with-input-url", "kawa.lib.ports");  // Extension
       define_proc ("open-input-string", "kawa.lib.ports");  // SRFI-6
       define_proc ("open-output-string", "kawa.lib.ports");  // SRFI-6
       define_proc ("get-output-string", "kawa.lib.ports");  // SRFI-6


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]