diff options
author | paltherr <paltherr@epfl.ch> | 2003-02-17 13:37:50 +0000 |
---|---|---|
committer | paltherr <paltherr@epfl.ch> | 2003-02-17 13:37:50 +0000 |
commit | 20f7e75afe7cde2bea396d666c9144cd49c18063 (patch) | |
tree | c6783b179fa5ce7b06610af38b115ffa619a67a4 | |
parent | 1af5e675692f1cec2daf4f6de8e6d0686420078d (diff) | |
download | scala-20f7e75afe7cde2bea396d666c9144cd49c18063.tar.gz scala-20f7e75afe7cde2bea396d666c9144cd49c18063.tar.bz2 scala-20f7e75afe7cde2bea396d666c9144cd49c18063.zip |
- Added Function.scm and Function.tmpl
-rw-r--r-- | sources/scala/Function.scm | 47 | ||||
-rw-r--r-- | sources/scala/Function.tmpl | 33 |
2 files changed, 80 insertions, 0 deletions
diff --git a/sources/scala/Function.scm b/sources/scala/Function.scm new file mode 100644 index 0000000000..34abaf5524 --- /dev/null +++ b/sources/scala/Function.scm @@ -0,0 +1,47 @@ +;; This rule file defines the environment for the expansion of +;; Function.tmpl template. +;; +;; It defines the following variables: +;; +;; Name Meaning Value for Function1 +;; -------------------------------------------------------- +;; n Arity of the function 1 +;; type-params Type parameters [?A1, ?R] +;; java-params Java parameters java.lang.Object a1 +;; scala-params Scala parameters (?A1) ?R + +;; $Id$ + +(define (gen-variables stem n) + (let loop ((i 1) (res '())) + (if (> i n) + (reverse! res) + (loop (+ i 1) (cons (string-append stem (number->string i)) res))))) + +(define (make-type-params n) + (string-append "[" + (string-join (append (gen-variables "?A" n) + '("?R")) + ", ") + "]")) + +(define (make-java-params n) + (string-join (gen-variables "java.lang.Object a" n) ", ")) + +(define (make-scala-params n) + (string-append "(" + (string-join (gen-variables "?A" n) ", ") + ") ?R")) + +(define file-name-rx (rx (* any) "Function" (submatch (+ digit)) ".java")) + +(define (make-env target-file) + (let ((match (regexp-search file-name-rx target-file))) + (if match + (let ((n (string->number (match:substring match 1)))) + (list (cons 'n (number->string n)) + (cons 'type-params (make-type-params n)) + (cons 'java-params (make-java-params n)) + (cons 'scala-params (make-scala-params n)))) + (error "invalid file name" target-file)))) + diff --git a/sources/scala/Function.tmpl b/sources/scala/Function.tmpl new file mode 100644 index 0000000000..69c438dcda --- /dev/null +++ b/sources/scala/Function.tmpl @@ -0,0 +1,33 @@ +// [#do-not-edit#] + +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id$ + +package scala; + +/** @meta class [#type-params#] extends scala.Object; + */ +public interface Function[#n#] extends Object { + /** @meta method [#scala-params#]; + */ + public java.lang.Object apply([#java-params#]); +} + +/** @meta class [#type-params#] extends scala.Object$class with scala.Function[#n#][#type-params#]; + */ +public abstract class Function[#n#]$class extends Object$class implements Function[#n#] { + /** @meta constr(); + */ + public Function[#n#]$class() {} + + /** @meta method [#scala-params#]; + */ + public abstract java.lang.Object apply([#java-params#]); +} |