Permalink
Browse files

Move the code in base to a new repository. It now lives in a system

and package called com.google.base.
  • Loading branch information...
brown committed Sep 12, 2011
1 parent 11da801 commit 761c554b677c49b0558cc5a28f85aebbd2a779bb
Showing with 99 additions and 415 deletions.
  1. +22 −7 README
  2. +0 −46 base/base.asd
  3. +0 −49 base/defconst.lisp
  4. +0 −88 base/octet.lisp
  5. +0 −48 base/optimize.lisp
  6. +0 −54 base/package.lisp
  7. +0 −45 base/type.lisp
  8. +12 −12 message-test.lisp
  9. +4 −4 package.lisp
  10. +12 −15 proto-lisp-test.lisp
  11. +3 −1 protobuf.asd
  12. +5 −5 protoc/lisp/message.cc
  13. +3 −3 protoc/lisp/string_field.cc
  14. +1 −1 varint/package.lisp
  15. +1 −1 varint/varint.asd
  16. +36 −36 varint/varint_test.lisp
View
29 README
@@ -29,7 +29,7 @@ documentation are available here:
http://code.google.com/p/protobuf/
-2. Clone the protobuf git repository to get a local copy.
+2. Clone the protobuf git repository to get a local copy:
git clone git://github.com/brown/protobuf.git
@@ -53,9 +53,14 @@ become:
make install
-4. Download and install the Common Lisp packages that protobuf depends on.
-You'll need ASDF, but it comes pre-installed in most Common Lisp
-distributions. If you're not using Allegro, CLisp, or SBCL, you may need
+4. Download and install other Common Lisp packages that protobuf
+depends on. You'll need ASDF, but it comes pre-installed in most
+Common Lisp distributions. You'll also need com.google.base, which
+you can download by cloning its git repository:
+
+ git clone git://github.com/brown/base.git
+
+If you're not using Allegro, CLisp, or SBCL, you may need
trivial-utf8, which is available here:
http://common-lisp.net/project/trivial-utf-8/
@@ -68,12 +73,22 @@ dependencies:
alexandria
-5. Make protobuf.asd available to ASDF. There are several ways to do this
-and you should consult the ASDF documentation to determine what will work
-best for you. ASDF and its manual are available here:
+5. Make com.google.base.asd and protobuf.asd available to ASDF. There
+are several ways to do this and you should consult the ASDF
+documentation to determine what will work best for you. ASDF and its
+manual are available here:
http://common-lisp.net/project/asdf/
+On my system, I tell ASDF the locations of the com.google.base and
+protobuf systems by creating a file called source-registry.conf in
+directory /home/brown/.config/common-lisp/ with the following contents:
+
+ (:source-registry
+ (:tree "/home/brown/src/base/")
+ (:tree "/home/brown/src/protobuf/")
+ :inherit-configuration)
+
6. Tell ASDF where to find Google's protocol buffer compiler and the Common
Lisp plugin. The file paths to use depend on where you have installed each.
View
@@ -1,46 +0,0 @@
-;;;; Copyright 2011 Google Inc. All Rights Reserved
-
-;;;; Redistribution and use in source and binary forms, with or without
-;;;; modification, are permitted provided that the following conditions are
-;;;; met:
-
-;;;; * Redistributions of source code must retain the above copyright
-;;;; notice, this list of conditions and the following disclaimer.
-;;;; * Redistributions in binary form must reproduce the above
-;;;; copyright notice, this list of conditions and the following disclaimer
-;;;; in the documentation and/or other materials provided with the
-;;;; distribution.
-;;;; * Neither the name of Google Inc. nor the names of its
-;;;; contributors may be used to endorse or promote products derived from
-;;;; this software without specific prior written permission.
-
-;;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-;;;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-;;;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-;;;; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-;;;; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-;;;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-;;;; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-;;;; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-;;;; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-;;;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-;;;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-;;;; Author: brown@google.com (Robert Brown)
-
-(in-package #:common-lisp-user)
-
-(defpackage #:base-system
- (:documentation "ASDF system definition for package BASE.")
- (:use #:common-lisp #:asdf))
-
-(in-package #:base-system)
-
-(defsystem #:base
- :depends-on (#-(or allegro ccl clisp sbcl) :trivial-utf-8)
- :components
- ((:file "package")
- (:file "optimize" :depends-on ("package"))
- (:file "defconst" :depends-on ("package" "optimize"))
- (:file "type" :depends-on ("package" "optimize"))
- (:file "octet" :depends-on ("package" "optimize" "type"))))
View
@@ -1,49 +0,0 @@
-;;;; Copyright 2011 Google Inc. All Rights Reserved
-
-;;;; Redistribution and use in source and binary forms, with or without
-;;;; modification, are permitted provided that the following conditions are
-;;;; met:
-
-;;;; * Redistributions of source code must retain the above copyright
-;;;; notice, this list of conditions and the following disclaimer.
-;;;; * Redistributions in binary form must reproduce the above
-;;;; copyright notice, this list of conditions and the following disclaimer
-;;;; in the documentation and/or other materials provided with the
-;;;; distribution.
-;;;; * Neither the name of Google Inc. nor the names of its
-;;;; contributors may be used to endorse or promote products derived from
-;;;; this software without specific prior written permission.
-
-;;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-;;;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-;;;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-;;;; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-;;;; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-;;;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-;;;; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-;;;; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-;;;; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-;;;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-;;;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-;;;; Author: brown@google.com (Robert Brown)
-
-;;;; Define DEFCONST, a more convenient version of DEFCONSTANT.
-
-(in-package #:base)
-(declaim #.*optimize-default*)
-
-(defmacro defconst (name value &optional (documentation nil documentation-present-p))
- "Identical to CL:DEFCONSTANT except that the global constant variable NAME
-is bound to VALUE at compile time so it can be used in #. reader forms.
-Additionally, if the DEFCONST form is evaluated a second time, the constant
-is not rebound if the new value is EQUALP to the old. CL:DEFCONSTANT
-requires that the two values be EQL to avoid undefined behavior."
- (let ((temp (gensym))
- (documentation (when documentation-present-p (list documentation))))
- `(eval-when (:compile-toplevel :load-toplevel :execute)
- (let ((,temp ,value))
- (if (and (boundp ',name) (equalp (symbol-value ',name) ,temp))
- ;; Return the same result as DEFCONSTANT.
- ',name
- (defconstant ,name ,temp ,@documentation))))))
View
@@ -1,88 +0,0 @@
-;;;; Copyright 2011 Google Inc. All Rights Reserved
-
-;;;; Redistribution and use in source and binary forms, with or without
-;;;; modification, are permitted provided that the following conditions are
-;;;; met:
-
-;;;; * Redistributions of source code must retain the above copyright
-;;;; notice, this list of conditions and the following disclaimer.
-;;;; * Redistributions in binary form must reproduce the above
-;;;; copyright notice, this list of conditions and the following disclaimer
-;;;; in the documentation and/or other materials provided with the
-;;;; distribution.
-;;;; * Neither the name of Google Inc. nor the names of its
-;;;; contributors may be used to endorse or promote products derived from
-;;;; this software without specific prior written permission.
-
-;;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-;;;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-;;;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-;;;; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-;;;; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-;;;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-;;;; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-;;;; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-;;;; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-;;;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-;;;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-;;;; Author: brown@google.com (Robert Brown)
-
-;;;; Vectors of octets, 8-bit bytes, used to store UTF-8 encoded strings.
-
-(in-package #:base)
-(declaim #.*optimize-fast-unsafe*)
-
-(deftype octet () '(unsigned-byte 8))
-(deftype octet-vector () '(simple-array octet (*)))
-
-(declaim (ftype (function (fixnum &key (:initial-contents list)) (values octet-vector &optional))
- make-octet-vector))
-
-(defun make-octet-vector (octet-count &key initial-contents)
- "Create an OCTET-VECTOR containing OCTET-COUNT octets. If INITIAL-CONTENTS
-is not supplied, each element of the vector is initialized to zero. Otherwise,
-the vector is initialized to the contents of list INITIAL-CONTENTS."
- (declare (type vector-index octet-count)
- (type list initial-contents))
- (if initial-contents
- (make-array octet-count :element-type 'octet :initial-contents initial-contents)
- (make-array octet-count :element-type 'octet :initial-element 0)))
-
-(declaim (ftype (function (string &key (:start vector-index) (:end vector-index))
- (values octet-vector &optional))
- string-to-utf8-octets))
-
-(defun string-to-utf8-octets (string &key (start 0) (end (length string)))
- "Convert STRING into an OCTET-VECTOR by UTF-8 encoding each character."
- (declare (type string string)
- (type vector-index start end))
- #+allegro
- (excl:string-to-octets string :start start :end end :null-terminate nil :external-format :utf8)
- #+ccl
- (ccl:encode-string-to-octets string :start start :end end :external-format :utf-8)
- #+clisp
- (ext:convert-string-to-bytes string charset:utf-8 :start start :end end)
- #+sbcl
- (sb-ext:string-to-octets string :start start :end end)
- #-(or allegro ccl clisp sbcl)
- (trivial-utf-8:string-to-utf-8-bytes (subseq string start end)))
-
-(declaim (ftype (function (octet-vector &key (:start vector-index) (:end vector-index))
- (values string &optional))
- utf8-octets-to-string))
-
-(defun utf8-octets-to-string (octets &key (start 0) (end (length octets)))
- "Convert OCTETS, a vector of UTF-8 encoded octets, into a string."
- (declare (type octet-vector octets)
- (type vector-index start end))
- #+allegro
- (excl:octets-to-string octets :start start :end end :external-format :utf8)
- #+ccl
- (ccl:decode-string-from-octets octets :start start :end end :external-format :utf-8)
- #+clisp
- (ext:convert-string-from-bytes octets charset:utf-8 :start start :end end)
- #+sbcl
- (sb-ext:octets-to-string octets :start start :end end :external-format :utf8)
- #-(or allegro ccl clisp sbcl)
- (trivial-utf-8:utf-8-bytes-to-string (subseq octets start end)))
View
@@ -1,48 +0,0 @@
-;;;; Copyright 2011 Google Inc. All Rights Reserved
-
-;;;; Redistribution and use in source and binary forms, with or without
-;;;; modification, are permitted provided that the following conditions are
-;;;; met:
-
-;;;; * Redistributions of source code must retain the above copyright
-;;;; notice, this list of conditions and the following disclaimer.
-;;;; * Redistributions in binary form must reproduce the above
-;;;; copyright notice, this list of conditions and the following disclaimer
-;;;; in the documentation and/or other materials provided with the
-;;;; distribution.
-;;;; * Neither the name of Google Inc. nor the names of its
-;;;; contributors may be used to endorse or promote products derived from
-;;;; this software without specific prior written permission.
-
-;;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-;;;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-;;;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-;;;; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-;;;; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-;;;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-;;;; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-;;;; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-;;;; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-;;;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-;;;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-;;;; Author: brown@google.com (Robert Brown)
-
-;;;; Compiler optimization settings.
-
-(in-package #:base)
-
-;;; To recompile code with different compiler optimization settings, rebind
-;;; these special variables.
-
-(defparameter *optimize-default*
- '(optimize (compilation-speed 0) (debug 3) (safety 3) (speed 1))
- "Compiler optimization settings that emphasize debugging over speed. Most
-code should use these settings.")
-
-(defparameter *optimize-fast-unsafe*
- ;; Use the default debugging level.
- '(optimize (compilation-speed 0) (safety 0) (speed 3))
- "Compiler optimization settings that emphasize speed at the expense of
-debugging and run-time safety. Only low-level performance sensitive code
-that has been extensively tested should use these settings.")
View
@@ -1,54 +0,0 @@
-;;;; Copyright 2011 Google Inc. All Rights Reserved
-
-;;;; Redistribution and use in source and binary forms, with or without
-;;;; modification, are permitted provided that the following conditions are
-;;;; met:
-
-;;;; * Redistributions of source code must retain the above copyright
-;;;; notice, this list of conditions and the following disclaimer.
-;;;; * Redistributions in binary form must reproduce the above
-;;;; copyright notice, this list of conditions and the following disclaimer
-;;;; in the documentation and/or other materials provided with the
-;;;; distribution.
-;;;; * Neither the name of Google Inc. nor the names of its
-;;;; contributors may be used to endorse or promote products derived from
-;;;; this software without specific prior written permission.
-
-;;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-;;;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-;;;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-;;;; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-;;;; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-;;;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-;;;; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-;;;; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-;;;; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-;;;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-;;;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-;;;; Author: brown@google.com (Robert Brown)
-
-(in-package #:common-lisp-user)
-
-(defpackage #:base
- (:documentation "Basic code used by all applications. The code in BASE
-should be universally useful, since most packages import BASE symbols by
-including (:USE #:BASE) in their DEFPACKAGE form.")
- (:use #:common-lisp)
- ;; optimize.lisp
- (:export #:*optimize-default*
- #:*optimize-fast-unsafe*)
- ;; defconst.lisp
- (:export #:defconst)
- ;; type.lisp
- (:export #:int32
- #:int64
- #:uint32
- #:uint64
- #:vector-index)
- ;; octet.lisp
- (:export #:octet
- #:octet-vector
- #:make-octet-vector
- #:string-to-utf8-octets
- #:utf8-octets-to-string))
View
@@ -1,45 +0,0 @@
-;;;; Copyright 2011 Google Inc. All Rights Reserved
-
-;;;; Redistribution and use in source and binary forms, with or without
-;;;; modification, are permitted provided that the following conditions are
-;;;; met:
-
-;;;; * Redistributions of source code must retain the above copyright
-;;;; notice, this list of conditions and the following disclaimer.
-;;;; * Redistributions in binary form must reproduce the above
-;;;; copyright notice, this list of conditions and the following disclaimer
-;;;; in the documentation and/or other materials provided with the
-;;;; distribution.
-;;;; * Neither the name of Google Inc. nor the names of its
-;;;; contributors may be used to endorse or promote products derived from
-;;;; this software without specific prior written permission.
-
-;;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-;;;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-;;;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-;;;; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-;;;; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-;;;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-;;;; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-;;;; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-;;;; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-;;;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-;;;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-;;;; Author: brown@google.com (Robert Brown)
-
-;;;; Basic constants and types that are very commonly used.
-
-(in-package #:base)
-(declaim #.*optimize-default*)
-
-;;; Lisp integer types with the same numeric range as C++ ints.
-
-(deftype int32 () '(signed-byte 32))
-(deftype int64 () '(signed-byte 64))
-(deftype uint32 () '(unsigned-byte 32))
-(deftype uint64 () '(unsigned-byte 64))
-
-;;; Integers used as indexes into vectors.
-
-(deftype vector-index () '(integer 0 #.array-dimension-limit))
Oops, something went wrong.

0 comments on commit 761c554

Please sign in to comment.