48 lines
2.2 KiB
Awk
48 lines
2.2 KiB
Awk
|
|
# generates constants from header
|
||
|
|
BEGIN {
|
||
|
|
printf "package com.sequencelogic;\n"
|
||
|
|
printf "/* ** AUTO-GENERATED FILE - DO NOT EDIT ** */\n"
|
||
|
|
printf "/** Provide K2Client constants; extracted from C header file(s) automatically by generate-K2ClientConstants_java.awk. */\n"
|
||
|
|
printf "public interface K2ClientConstants {\n"
|
||
|
|
}
|
||
|
|
/#define K2CLI_EVENTS_EXTRACT/ { events_extract=1; next; }
|
||
|
|
/#undef K2CLI_EVENTS_EXTRACT/ { events_extract=0; next; }
|
||
|
|
/#define K2CLI_STRING_CONSTANTS_EXTRACT/ { string_extract=1; next; }
|
||
|
|
/#undef K2CLI_STRING_CONSTANTS_EXTRACT/ { string_extract=0; next; }
|
||
|
|
/#define K2CLI_CHAR_CONSTANTS_EXTRACT/ { char_extract=1; next; }
|
||
|
|
/#undef K2CLI_CHAR_CONSTANTS_EXTRACT/ { char_extract=0; next; }
|
||
|
|
/#define K2CLI_INT_CONSTANTS_EXTRACT/ { int_extract=1; next; }
|
||
|
|
/#undef K2CLI_INT_CONSTANTS_EXTRACT/ { int_extract=0; next; }
|
||
|
|
{
|
||
|
|
if (events_extract && ("#define" != $1)) {
|
||
|
|
q = "\""
|
||
|
|
split($0, a, q)
|
||
|
|
string = a[2]
|
||
|
|
name = $1
|
||
|
|
sub(/X\(/, "", name)
|
||
|
|
sub(/,/, "", name)
|
||
|
|
sub(/K2CLI_/, "EVENT_", name)
|
||
|
|
printf " public static final String %s = %s;\n", name, q string q
|
||
|
|
} else if (string_extract && ("#define" == $1)) {
|
||
|
|
q = "\""
|
||
|
|
split($0, a, q)
|
||
|
|
string = a[2]
|
||
|
|
name = $2
|
||
|
|
sub(/K2_/, "", name)
|
||
|
|
sub(/K2IPC_/, "", name)
|
||
|
|
printf " public static final String %s = %s;\n", name, q string q
|
||
|
|
} else if (char_extract && ("#define" == $1)) {
|
||
|
|
name = $2
|
||
|
|
sub(/K2_/, "", name)
|
||
|
|
sub(/K2IPC_/, "", name)
|
||
|
|
printf " public static final char %s = %s;\n", name, $3
|
||
|
|
} else if (int_extract && ("#define" == $1)) {
|
||
|
|
name = $2
|
||
|
|
sub(/K2_/, "", name)
|
||
|
|
sub(/K2IPC_/, "", name)
|
||
|
|
printf " public static final int %s = %s;\n", name, $3
|
||
|
|
}
|
||
|
|
}
|
||
|
|
END { printf "}\n" }
|
||
|
|
|