summaryrefslogtreecommitdiff
path: root/src/gen_message_list.sed
blob: 17b2c161a70ed7205a5f37ee1006abd3c6e84ac9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
1 {
i\
#ifndef _MESSAGE_LIST_H_ \
#define _MESSAGE_LIST_H_ \
\
#define MUMBLE_MSGS \\
}

$ {
a\
\
#endif /* _MESSAGES_H_ */
}

# Isolate message name from .proto file
/^message/!d
s/message[ 	]*\([^ 	]*\).*$/\1/

# This code attempts to generate "MUMBLE_MSG(FooBar, foo_bar)" from "FooBar"

# Backup original message name
h
# Prefix uppercase characters that follow a lowercase one
s/\([a-z]\)\([A-Z]\)/\1_\2/g
# Lowercase uppercase characters
y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
# Append backup to lowercase underscored message
G
# Put template macro around (delete newline between both msgs, swap order)
s/^\(.*\)\n\(.*\)$/	MUMBLE_MSG(\2, \1) \\/