3 type_name = ""; # GtkEnumType
4 type_macro = ""; # GTK_TYPE_ENUM_TYPE
5 type_ident = ""; # _gtk_enum_type
8 delete value_names; # GTK_ENUM_VALUE
9 delete value_nicks; # enum-value
15 for (i = 1; i < ARGC; i++)
17 if (ARGV[i] == "arrays")
19 else if (ARGV[i] == "defs")
25 printf ("/* generated by makeenums.awk */\n\n");
27 printf (";; generated by makeenums.awk ; -*- scheme -*-\n\n");
30 printf ("hm? what do you want me to do?\n") > "/dev/stderr";
35 function set_type (set_type_1)
37 type_name = set_type_1;
38 type_macro = "GTK_TYPE";
40 for (i = 0; i < length (type_name); i++)
42 ch = substr (type_name, i + 1, 1);
46 type_macro = type_macro "_" Ch;
47 type_ident = type_ident "_" tolower (ch);
51 type_macro = type_macro Ch;
52 type_ident = type_ident ch;
57 function set_value (set_value_1, set_value_2)
59 value_names[VI] = set_value_1;
60 value_nicks[VI] = tolower (set_value_2);
61 while (match (value_nicks[VI], "_"))
62 sub ("_", "-", value_nicks[VI]);
65 function generate_arrays ()
69 printf ("static GtkEnumValue %s_values[] = {\n", type_ident);
70 for (i = 0; i < VI; i++)
72 printf (" { %s, \"%s\", \"%s\" },\n",
73 value_names[i], value_names[i], value_nicks[i]);
75 printf (" { 0, NULL, NULL }\n");
80 function generate_defs ()
84 if (comment_file != "")
86 printf ("\n; enumerations from \"%s\"\n", comment_file);
90 printf ("\n(define-%s %s",
91 type_flags ? "flags" : "enum",
93 for (i = 0; i < VI; i++)
96 value_nicks[i], value_names[i]);
102 function basename (basename_1)
104 sub ("\"", "", basename_1);
105 while (match (basename_1, "/"))
106 sub (".*/", "", basename_1);
107 sub ("\"", "", basename_1);
114 if ($3 != "+" || $5 != "+")
115 printf ("huh? G_ENUM_E keyword without arg?\n") > "/dev/stderr";
126 if ($3 != "+" || $5 != "+")
127 printf ("huh? G_ENUM_F keyword without arg?\n") > "/dev/stderr";
138 if ($2 != "+" || $4 != "+" || $6 != "+")
139 printf ("huh? G_ENUM_V keyword without arg?\n") > "/dev/stderr";
145 # feature per file comments
147 comment_file = basename($3);