]> asedeno.scripts.mit.edu Git - cl-protobufs.git/commitdiff
Allow import by symbol to support pure-lisp protobuf definitions
authorAlejandro R Sedeño <asedeno@google.com>
Tue, 19 Mar 2013 20:28:41 +0000 (16:28 -0400)
committerAlejandro R Sedeño <asedeno@google.com>
Wed, 20 Mar 2013 03:35:40 +0000 (23:35 -0400)
asdf-support.lisp

index 4aa3dcfe4eb101309b41f862097a130ee381e6f3..cb1b158e5a70a5db558bf0ea15573e9a7578e237 100644 (file)
 
 ;; Process 'import' lines
 (defun process-imports (schema imports)
-  "Imports all of the files given by 'imports'.
-   If the file is a .proto file, it first parses it and writes a .lisp file.
-   The .lisp file is the compiled and loaded."
+  "Processes the imports for a schema.
+   If the import is a symbol, see if that resolves to an existing schema.
+   If the import is a file (string, pathname), parse it as a .proto in the usual manner."
   (dolist (import imports)
-    (let* ((proto-file (do-process-import (pathname import)))
-           (imported   (find-schema proto-file)))
-      (when imported
-        (appendf (proto-imported-schemas schema) (list imported))))))
+    (let ((imported-schema (find-schema
+                            (etypecase import
+                              ((or string pathname)
+                               (do-process-import (pathname import)))
+                              (symbol import)))))
+      (if imported-schema
+        (appendf (proto-imported-schemas schema) (list imported-schema))
+        (error "Could not import ~S" import)))))
 
 (defun process-imports-from-file (imports-file)
   (when (probe-file imports-file)