1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3 ;;; Confidential and proprietary information of ITA Software, Inc. ;;;
5 ;;; Copyright (c) 2012 ITA Software, Inc. All rights reserved. ;;;
7 ;;; Original author: Francois-Rene Rideau, Scott McKay ;;;
9 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
11 (in-package "PROTO-IMPL")
14 (eval-when (:compile-toplevel :load-toplevel :execute)
16 (defclass proto-file (asdf:cl-source-file)
17 ((asdf::type :initform "proto"))
19 "This ASDF component defines COMPILE-OP and LOAD-OP operations
20 that compiles the .proto file into a .lisp file, and the compiles
21 the resulting .lisp file into a fasl."))
25 (defmethod asdf:output-files ((op asdf:compile-op) (c proto-file))
26 (append (call-next-method)
27 (make-pathname :type "lisp" :defaults (asdf:component-pathname c))))
29 (defmethod asdf:perform ((op asdf:compile-op) (c proto-file))
30 (destructuring-bind (fasl-file lisp-file)
31 (asdf:output-files op c)
32 (funcall asdf::*compile-op-compile-file-function*
33 (parse-protobuf-file (asdf:component-pathname c) lisp-file)
34 :output-file fasl-file)))
36 (defmethod asdf:perform ((op asdf:load-source-op) (c proto-file))
37 (destructuring-bind (fasl-file lisp-file)
38 (asdf:output-files op c)
39 (declare (ignore fasl-file))
40 (load (parse-protobuf-file (asdf:component-pathname c) lisp-file))))
42 (defun parse-protobuf-file (proto-file lisp-file)
43 (let ((protobuf (parse-protobuf-from-file proto-file)))
44 (with-open-file (stream lisp-file
47 (write-protobuf protobuf :stream stream :type :lisp)))