]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - Ada95/gen/gen.c
ncurses 5.9 - patch 20140125
[ncurses.git] / Ada95 / gen / gen.c
index 3c63cf5aa5fdb6c219a597cb5d1d4257081ee9aa..7595672e57b46ee18abfbd2b8025ca861c900763 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998,2010,2011 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2013,2014 Free Software Foundation, Inc.              *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -32,7 +32,7 @@
 
 /*
     Version Control
-    $Id: gen.c,v 1.58 2011/03/25 23:55:30 tom Exp $
+    $Id: gen.c,v 1.62 2014/01/26 00:21:52 Nicolas.Boulenguez Exp $
   --------------------------------------------------------------------------*/
 /*
   This program generates various record structures and constants from the
@@ -116,6 +116,7 @@ find_pos(char *s, unsigned len, int *low, int *high)
  * record type defined in the binding.
  * We are only dealing with record types which are of 32 or 16
  * bit size, i.e. they fit into an (u)int or a (u)short.
+ * Any pair with a 0 attr field will be ignored.
  */
 static void
 gen_reps(
@@ -124,55 +125,29 @@ gen_reps(
          int len,              /* size of the record in bytes          */
          int bias)
 {
-  const char *unused_name = "Unused";
-  int long_bits = (8 * (int)sizeof(unsigned long));
-  int len_bits = (8 * len);
-  int i, j, n, l, cnt = 0, low, high;
+  const int len_bits = (8 * len);
+  int i, l, low, high;
   int width = strlen(RES_NAME) + 3;
   unsigned long a;
-  unsigned long mask = 0;
 
   assert(nap != NULL);
 
   for (i = 0; nap[i].name != (char *)0; i++)
-    {
-      cnt++;
-      l = (int)strlen(nap[i].name);
-      if (l > width)
-       width = l;
-    }
+    if (nap[i].attr)
+      {
+       l = (int)strlen(nap[i].name);
+       if (l > width)
+         width = l;
+      }
   assert(width > 0);
 
   printf("   type %s is\n", name);
   printf("      record\n");
   for (i = 0; nap[i].name != (char *)0; i++)
-    {
-      mask |= nap[i].attr;
-      printf("         %-*s : Boolean;\n", width, nap[i].name);
-    }
-
-  /*
-   * Compute a mask for the unused bits in this target.
-   */
-  mask = ~mask;
-  /*
-   * Bits in the biased area are unused by the target.
-   */
-  for (j = 0; j < bias; ++j)
-    {
-      mask &= (unsigned long)(~(1L << j));
-    }
-  /*
-   * Bits past the target's size are really unused.
-   */
-  for (j = len_bits + bias; j < long_bits; ++j)
-    {
-      mask &= (unsigned long)(~(1L << j));
-    }
-  if (mask != 0)
-    {
-      printf("         %-*s : Boolean;\n", width, unused_name);
-    }
+    if (nap[i].attr)
+      {
+       printf("         %-*s : Boolean;\n", width, nap[i].name);
+      }
   printf("      end record;\n");
   printf("   pragma Convention (C, %s);\n\n", name);
 
@@ -180,24 +155,18 @@ gen_reps(
   printf("      record\n");
 
   for (i = 0; nap[i].name != (char *)0; i++)
-    {
-      a = nap[i].attr;
-      l = find_pos((char *)&a, sizeof(a), &low, &high);
-      if (l >= 0)
-       printf("         %-*s at 0 range %2d .. %2d;\n", width, nap[i].name,
-              low - bias, high - bias);
-    }
-  if (mask != 0)
-    {
-      l = find_pos((char *)&mask, sizeof(mask), &low, &high);
-      if (l >= 0)
-       printf("         %-*s at 0 range %2d .. %2d;\n", width, unused_name,
-              low - bias, high - bias);
-    }
-  i = 1;
-  n = cnt;
+    if (nap[i].attr)
+      {
+       a = nap[i].attr;
+       l = find_pos((char *)&a, sizeof(a), &low, &high);
+       if (l >= 0)
+         printf("         %-*s at 0 range %2d .. %2d;\n", width, nap[i].name,
+                low - bias, high - bias);
+      }
   printf("      end record;\n");
+  printf("   pragma Warnings (Off);");
   printf("   for %s'Size use %d;\n", name, len_bits);
+  printf("   pragma Warnings (On);\n");
   printf("   --  Please note: this rep. clause is generated and may be\n");
   printf("   --               different on your system.");
 }
@@ -278,54 +247,26 @@ gen_attr_set(const char *name)
    * 1999-2000), the ifdef's also were needed since the proposed bit-layout
    * for wide characters allocated 16-bits for A_CHARTEXT, leaving too few
    * bits for a few of the A_xxx symbols.
+   * Some preprocessors are not able to test the values because they
+   * now (2014) contain an explicit cast to chtype, so we avoid ifdef.
    */
   static const name_attribute_pair nap[] =
   {
-#if A_STANDOUT
     {"Stand_Out", A_STANDOUT},
-#endif
-#if A_UNDERLINE
     {"Under_Line", A_UNDERLINE},
-#endif
-#if A_REVERSE
     {"Reverse_Video", A_REVERSE},
-#endif
-#if A_BLINK
     {"Blink", A_BLINK},
-#endif
-#if A_DIM
     {"Dim_Character", A_DIM},
-#endif
-#if A_BOLD
     {"Bold_Character", A_BOLD},
-#endif
-#if A_ALTCHARSET
     {"Alternate_Character_Set", A_ALTCHARSET},
-#endif
-#if A_INVIS
     {"Invisible_Character", A_INVIS},
-#endif
-#if A_PROTECT
     {"Protected_Character", A_PROTECT},
-#endif
-#if A_HORIZONTAL
     {"Horizontal", A_HORIZONTAL},
-#endif
-#if A_LEFT
     {"Left", A_LEFT},
-#endif
-#if A_LOW
     {"Low", A_LOW},
-#endif
-#if A_RIGHT
     {"Right", A_RIGHT},
-#endif
-#if A_TOP
     {"Top", A_TOP},
-#endif
-#if A_VERTICAL
     {"Vertical", A_VERTICAL},
-#endif
     {(char *)0, 0}
   };
   chtype attr = A_ATTRIBUTES & ~A_COLOR;
@@ -807,7 +748,7 @@ gen_keydefs(int mode)
 static void
 acs_def(const char *name, chtype *a)
 {
-  int c = a - &acs_map[0];
+  int c = (int)(a - &acs_map[0]);
 
   printf("   %-24s : constant Character := ", name);
   if (isprint(UChar(c)) && (c != '`'))