Permalink
Browse files

Add code to read a CodeGeneratorRequest.

  • Loading branch information...
brown committed Feb 6, 2012
1 parent fbeb728 commit 24bbd5568558f6647879a8ff112f09f83c71a295
Showing with 46 additions and 5 deletions.
  1. +27 −0 protoc/package.lisp
  2. +7 −3 protoc/protoc.asd
  3. +12 −2 protoc/protoc.lisp
View
@@ -34,6 +34,33 @@
(:documentation "Protocol buffer Common Lisp plugin.")
(:use #:common-lisp
#:com.google.base)
+ (:import-from #:google.protobuf.compiler
+ ;; Classes
+ #:code-generator-request
+ #:code-generator-response
+ #:code-generator-response-file
+ ;; Functions
+ #:clear-content
+ #:clear-error
+ ;;#:clear-file
+ #:clear-file-to-generate
+ #:clear-insertion-point
+ ;;#:clear-name
+ #:clear-parameter
+ #:clear-proto-file
+ #:content
+ ;;#:error
+ ;;#:file
+ #:file-to-generate
+ #:has-content
+ #:has-error
+ #:has-insertion-point
+ ;;#:has-name
+ #:has-parameter
+ #:insertion-point
+ ;;#:name
+ #:parameter
+ #:proto-file)
(:import-from #:com.google.protobuf
;; Constants
#:+field-descriptor-proto-label-label-optional+
View
@@ -44,8 +44,12 @@
:license "See file COPYING and the copyright messages in individual files."
:defsystem-depends-on (protobuf)
:depends-on (com.google.base)
- ;; :in-order-to ((test-op (test-op protoc-test)))
+ :in-order-to ((test-op (test-op protoc-test)))
:components
((:protobuf-source-file "descriptor" :proto-pathname "../google/protobuf/descriptor")
- (:file "package" :depends-on ("descriptor"))
- (:file "protoc" :depends-on ("package" "descriptor"))))
+ (:protobuf-source-file "plugin"
+ :proto-pathname "../google/protobuf/compiler/plugin"
+ :depends-on ("descriptor")
+ :proto-search-path ("../"))
+ (:file "package" :depends-on ("descriptor" "plugin"))
+ (:file "protoc" :depends-on ("package" "descriptor" "plugin"))))
View
@@ -33,6 +33,17 @@
(in-package #:protoc)
(declaim #.*optimize-default*)
+(defparameter *plugin-input* "unittest-plugin-input")
+
+(defun read-plugin-input ()
+ (with-open-file (input *plugin-input* :direction :input :element-type 'octet)
+ (let* ((size (file-length input))
+ (buffer (make-octet-vector size))
+ (code-generator-request (make-instance 'code-generator-request)))
+ (read-sequence buffer input)
+ (pb:merge-from-array code-generator-request buffer 0 size)
+ code-generator-request)))
+
(defparameter *parsed-proto* "unittest_import.pb")
(defun read-file-descriptor-set ()
@@ -44,7 +55,6 @@
(pb:merge-from-array file-descriptor-set buffer 0 size)
file-descriptor-set)))
-
(defun hyphenate-studly-caps (string)
(let ((state 'unknown)
(result '()))
@@ -96,7 +106,7 @@
(slot-definitions (loop for field across (field descriptor)
collect (slot-definition field))))
`((defclass ,class-symbol (pb:protocol-buffer)
- (,slot-definitions
+ (,@slot-definitions
(%has-bits% :accessor %has-bits% :initform 0 :type (unsigned-byte ,field-count))
(pb::%cached-size% :initform 0 :type vector-index)))
(export ',class-symbol))))

0 comments on commit 24bbd55

Please sign in to comment.