summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-03-27 17:18:00 -0500
committerJeff Carr <[email protected]>2025-03-27 17:18:00 -0500
commitbdc2e4fadf75f08f6d44fa984ea4d3d78f9dede2 (patch)
treee934c120150563cfe2573ebbe9648e903ab1504f
parentfb881df443918a6c5d271af691759adb7c0afa9e (diff)
general updates
-rw-r--r--Makefile5
-rw-r--r--example/Makefile1
-rw-r--r--example/Signal-Desktop-Backups.proto.orig16
-rw-r--r--protoReformat.go25
4 files changed, 34 insertions, 13 deletions
diff --git a/Makefile b/Makefile
index 351bcae..f2efd87 100644
--- a/Makefile
+++ b/Makefile
@@ -92,5 +92,6 @@ clean-more:
ls -l autogenpb autogenpb.last
-rm -f autogenpb.2*
-Signal-Desktop:
- autogenpb --proto SignalService.proto --format
+reformat-signal.proto:
+ make -C example proto-reformat-restore
+ make -C example proto-reformat-comments
diff --git a/example/Makefile b/example/Makefile
index 4c98ac9..4f8171d 100644
--- a/example/Makefile
+++ b/example/Makefile
@@ -108,3 +108,4 @@ proto-reformat-restore:
proto-reformat-comments:
../autogenpb --proto signal.proto --format-comments
+ # autogenpb --proto SignalService.proto --format
diff --git a/example/Signal-Desktop-Backups.proto.orig b/example/Signal-Desktop-Backups.proto.orig
index c939e53..faed8ee 100644
--- a/example/Signal-Desktop-Backups.proto.orig
+++ b/example/Signal-Desktop-Backups.proto.orig
@@ -115,7 +115,7 @@ message AccountData {
string familyName = 5;
string avatarUrlPath = 6;
SubscriberData donationSubscriberData = 7;
- reserved 8; // A deprecated format // backupsSubscriberData
+ reserved /*backupsSubscriberData*/ 8; // A deprecated format
AccountSettings accountSettings = 9;
IAPSubscriberData backupsSubscriberData = 10;
string svrPin = 11;
@@ -230,7 +230,7 @@ message Group {
// We would use Groups.proto if we could, but we want a plaintext version to improve export readability.
// For documentation, defer to Groups.proto. The only name change is Group -> GroupSnapshot to avoid the naming conflict.
message GroupSnapshot {
- reserved 1; // The field is deprecated in the context of static group state // publicKey
+ reserved /*publicKey*/ 1; // The field is deprecated in the context of static group state
GroupAttributeBlob title = 2;
GroupAttributeBlob description = 11;
string avatarUrl = 3;
@@ -264,8 +264,8 @@ message Group {
bytes userId = 1;
Role role = 2;
- reserved 3; // This field is ignored in Backups, in favor of Contact frames for members // profileKey
- reserved 4; // This field is deprecated in the context of static group state // presentation
+ reserved /*profileKey*/ 3; // This field is ignored in Backups, in favor of Contact frames for members
+ reserved /*presentation*/ 4; // This field is deprecated in the context of static group state
uint32 joinedAtVersion = 5;
}
@@ -277,8 +277,8 @@ message Group {
message MemberPendingAdminApproval {
bytes userId = 1;
- reserved 2; // This field is ignored in Backups, in favor of Contact frames for members // profileKey
- reserved 3; // This field is deprecated in the context of static group state // presentation
+ reserved /*profileKey*/ 2; // This field is ignored in Backups, in favor of Contact frames for members
+ reserved /*presentation*/ 3; // This field is deprecated in the context of static group state
uint64 timestamp = 4;
}
@@ -505,7 +505,7 @@ message DirectStoryReplyMessage {
}
repeated Reaction reactions = 3;
- reserved 4; // storySentTimestamp
+ reserved /*storySentTimestamp*/ 4;
}
message PaymentNotification {
@@ -1312,4 +1312,4 @@ message ChatFolder {
FolderType folderType = 6;
repeated uint64 includedRecipientIds = 7; // generated recipient id of groups, contacts, and/or note to self
repeated uint64 excludedRecipientIds = 8; // generated recipient id of groups, contacts, and/or note to self
-}
+} \ No newline at end of file
diff --git a/protoReformat.go b/protoReformat.go
index 5cd685d..962e7b2 100644
--- a/protoReformat.go
+++ b/protoReformat.go
@@ -54,6 +54,8 @@ func protoReformatComments(filename string) error {
}
var newfile string
+ newfile = commentPreprocessorFull(string(data))
+ saveFile(filename, newfile)
log.Info("filename", filename)
alltest := makeLineIter(data)
@@ -61,7 +63,8 @@ func protoReformatComments(filename string) error {
for line := range alltest {
newfile += fmt.Sprintln(commentPreprocessor(line))
}
- saveFile(filename, newfile)
+ newfile = commentPreprocessorFull(newfile)
+ // saveFile(filename, newfile)
return nil
}
@@ -488,9 +491,8 @@ func (it *LinesScanner) Next() string {
// END DEFINE THE ITERATOR
// turns: "/* test */ reserved /* linkPreviews */ 4;"
-// into:
+// into: reserved 1; // test // linkPreviews
func commentPreprocessor(line string) string {
-
// Match all /* comment */ blocks
re := regexp.MustCompile(`/\*([^*]+)\*/`)
matches := re.FindAllStringSubmatch(line, -1)
@@ -514,3 +516,20 @@ func commentPreprocessor(line string) string {
return line
}
+
+// /* this
+// - thing
+// */
+//
+// becomes
+//
+// this
+// thing
+func commentPreprocessorFull(full string) string {
+ // Match all /* comment */ blocks
+ re := regexp.MustCompile(`/\*([^*]+)\*/`)
+
+ return re.ReplaceAllStringFunc(full, func(s string) string {
+ return strings.ToUpper(s)
+ })
+}