Wed, 20 May 2020 11:33:10 +0100
Make PurplePluginProtocolInfo definitions consistent
Since we can't use C99 structure initialisers, we have to manually add
new NULL fields to all protocols whenever we extend the structure.
Make it slightly easier to script that, by making the current last
field (get_cb_alias) consistent in all cases. In particular, there's
no reason *not* to have the trailing comma, as most already do.
Now I can add a new field to the PRPL by doing something like this...
PROTOFILES=`grep -rl '[A-Za-z_][A-Za-z0-9_]*,[[:space:]]*/\* get_cb_alias \*/' libpurple/protocols/ `
sed '/\/\* get_cb_alias \*\//{p;s/[A-Za-z_][A-Za-
|
24973
d021d316a53d
Add a script to change casts to GObject macros. We'll run this later.
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
1 | #!/bin/sh |
|
d021d316a53d
Add a script to change casts to GObject macros. We'll run this later.
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
2 | |
|
d021d316a53d
Add a script to change casts to GObject macros. We'll run this later.
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
3 | if [ $# -eq 0 ]; then |
|
d021d316a53d
Add a script to change casts to GObject macros. We'll run this later.
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
4 | echo "Usage: `basename "$0"` PurpleFoo..." |
|
d021d316a53d
Add a script to change casts to GObject macros. We'll run this later.
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
5 | echo |
|
d021d316a53d
Add a script to change casts to GObject macros. We'll run this later.
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
6 | echo "This script searches the *current working directory* and replaces casts" |
|
d021d316a53d
Add a script to change casts to GObject macros. We'll run this later.
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
7 | echo "with GObject-style type checking and casting macros." |
|
d021d316a53d
Add a script to change casts to GObject macros. We'll run this later.
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
8 | echo 'For example, "(PurpleBuddy *)b" becomes "PURPLE_BUDDY(b)".' |
|
d021d316a53d
Add a script to change casts to GObject macros. We'll run this later.
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
9 | exit 0 |
|
d021d316a53d
Add a script to change casts to GObject macros. We'll run this later.
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
10 | fi |
|
d021d316a53d
Add a script to change casts to GObject macros. We'll run this later.
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
11 | |
|
d021d316a53d
Add a script to change casts to GObject macros. We'll run this later.
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
12 | for struct in $* ; do |
|
d021d316a53d
Add a script to change casts to GObject macros. We'll run this later.
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
13 | cast=`echo $struct | sed "s|[A-Z]|_\0|g" | tr "a-z" "A-Z" | sed "s|^_||"` |
|
24975
7abe1341dc45
Minor fixes to the cast changing script.
Richard Laager <rlaager@pidgin.im>
parents:
24973
diff
changeset
|
14 | for file in `grep -rl "([[:space:]]*$struct[[:space:]]*\*[[:space:]]*)" . --include=*.c --exclude=purple-client-bindings.c` ; do |
|
7abe1341dc45
Minor fixes to the cast changing script.
Richard Laager <rlaager@pidgin.im>
parents:
24973
diff
changeset
|
15 | sed -i "s|([[:space:]]*$struct[[:space:]]*\*[[:space:]]*)[[:space:]]*(|$cast(|g" $file |
|
7abe1341dc45
Minor fixes to the cast changing script.
Richard Laager <rlaager@pidgin.im>
parents:
24973
diff
changeset
|
16 | sed -i "s|([[:space:]]*$struct[[:space:]]*\*[[:space:]]*)[[:space:]]*\([^(][^,);]*\)|$cast(\1)|g" $file |
|
24973
d021d316a53d
Add a script to change casts to GObject macros. We'll run this later.
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
17 | done |
|
d021d316a53d
Add a script to change casts to GObject macros. We'll run this later.
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
18 | done |