From 561bb2bd6f69e7b34d87b16e0a9f948b128456ca Mon Sep 17 00:00:00 2001 From: jidibinlin <2694273649@qq.com> Date: Fri, 5 Aug 2022 23:22:07 +0800 Subject: [PATCH 1/3] use enum name as constant prefix --- define-proto.lisp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/define-proto.lisp b/define-proto.lisp index 1d7107cc..92e5f590 100644 --- a/define-proto.lisp +++ b/define-proto.lisp @@ -287,11 +287,13 @@ message, and of ++ when the enum is defined at top-level." (let* ((enum-name (symbol-name type)) (dot (position #\. enum-name :test #'char= :from-end t)) ;; Use C/C++ enum scope. - (scope (and dot (subseq enum-name 0 dot))) + (scope enum-name + ;; (and dot (subseq enum-name 0 dot)) + ) (constants - (loop for v in enum-values - for c = (fintern "+~@[~A.~]~A+" scope (enum-value-descriptor-name v)) - collect `(defconstant ,c ,(enum-value-descriptor-value v))))) + (loop for v in enum-values + for c = (fintern "+~@[~A.~]~A+" scope (enum-value-descriptor-name v)) + collect `(defconstant ,c ,(enum-value-descriptor-value v))))) `(progn ,@constants (export ',(mapcar #'second constants))))) From 474b26c3c076abe64ecad58428439dfab23abc02 Mon Sep 17 00:00:00 2001 From: jidibinlin <2694273649@qq.com> Date: Wed, 10 Aug 2022 22:27:30 +0800 Subject: [PATCH 2/3] fix enum-mapping-test for use enum name as constant prefix --- tests/enum-mapping-test.lisp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/enum-mapping-test.lisp b/tests/enum-mapping-test.lisp index f042805b..dd5f039a 100644 --- a/tests/enum-mapping-test.lisp +++ b/tests/enum-mapping-test.lisp @@ -43,10 +43,10 @@ Parameters (assert-true (eq :zaphod (pb:my-message.my-enum-int-to-keyword 42))) ;; constants - (assert-eql 1 pb:+my-message.foo+) - (assert-eql 2 pb:+my-message.bar+) - (assert-eql 2 pb:+my-message.baz+) - (assert-eql 42 pb:+my-message.zaphod+) + (assert-eql 1 pb:+my-message.my-enum.foo+) + (assert-eql 2 pb:+my-message.my-enum.bar+) + (assert-eql 2 pb:+my-message.my-enum.baz+) + (assert-eql 42 pb:+my-message.my-enum.zaphod+) ;; Error cases. (assert-false (pb:my-message.my-enum-keyword-to-int :some-unknown-keyword)) @@ -69,10 +69,10 @@ Parameters (assert-eq :zaphod (pb:outer-enum-int-to-keyword 142)) ;; constants - (assert-eql 11 pb:+foo+) - (assert-eql 12 pb:+bar+) - (assert-eql 12 pb:+baz+) - (assert-eql 142 pb:+zaphod+) + (assert-eql 11 pb:+outer-enum.foo+) + (assert-eql 12 pb:+outer-enum.bar+) + (assert-eql 12 pb:+outer-enum.baz+) + (assert-eql 142 pb:+outer-enum.zaphod+) ;; Error cases. (assert-false (pb:outer-enum-keyword-to-int :some-unknown-keyword)) From cdf821ab6174824c61d587d63499048223d55149 Mon Sep 17 00:00:00 2001 From: jidibinlin <2694273649@qq.com> Date: Thu, 1 Sep 2022 09:59:09 +0800 Subject: [PATCH 3/3] add descriptor.proto --- cl-protobufs.asd | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cl-protobufs.asd b/cl-protobufs.asd index d44a5382..bdc88ec1 100644 --- a/cl-protobufs.asd +++ b/cl-protobufs.asd @@ -79,6 +79,8 @@ and functionality for working with them." :proto-pathname "google/protobuf/any.proto") (:protobuf-source-file "source_context" :proto-pathname "google/protobuf/source_context.proto") + (:protobuf-source-file "descriptor" + :proto-pathname "google/protobuf/descriptor.proto") #-ccl (:protobuf-source-file "type" :proto-pathname "google/protobuf/type.proto"