+static void
+wrap_one_var(const char *c_var,
+ const char *c_type,
+ const char *ada_func,
+ const char *ada_type)
+{
+#if USE_REENTRANT
+ /* must wrap variables */
+ printf("\n");
+ printf(" function %s return %s\n", ada_func, ada_type);
+ printf(" is\n");
+ printf(" function Result return %s;\n", c_type);
+ printf(" pragma Import (C, Result, \"" NCURSES_WRAP_PREFIX "%s\");\n", c_var);
+ printf(" begin\n");
+ if (strcmp(c_type, ada_type))
+ printf(" return %s (Result);\n", ada_type);
+ else
+ printf(" return Result;\n");
+ printf(" end %s;\n", ada_func);
+#else
+ /* global variables are really global */
+ printf("\n");
+ printf(" function %s return %s\n", ada_func, ada_type);
+ printf(" is\n");
+ printf(" Result : %s;\n", c_type);
+ printf(" pragma Import (C, Result, \"%s\");\n", c_var);
+ printf(" begin\n");
+ if (strcmp(c_type, ada_type))
+ printf(" return %s (Result);\n", ada_type);
+ else
+ printf(" return Result;\n");
+ printf(" end %s;\n", ada_func);
+#endif
+}
+
+#define GEN_PUBLIC_VAR(c_var, c_type, ada_func, ada_type) \
+ wrap_one_var(#c_var, #c_type, #ada_func, #ada_type)
+
+static void
+gen_public_vars(void)
+{
+ GEN_PUBLIC_VAR(stdscr, Window, Standard_Window, Window);
+ GEN_PUBLIC_VAR(curscr, Window, Current_Window, Window);
+ GEN_PUBLIC_VAR(LINES, C_Int, Lines, Line_Count);
+ GEN_PUBLIC_VAR(COLS, C_Int, Columns, Column_Count);
+ GEN_PUBLIC_VAR(TABSIZE, C_Int, Tab_Size, Natural);
+ GEN_PUBLIC_VAR(COLORS, C_Int, Number_Of_Colors, Natural);
+ GEN_PUBLIC_VAR(COLOR_PAIRS, C_Int, Number_Of_Color_Pairs, Natural);
+}
+