X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Futils%2Fhsc2hs%2Ftemplate-hsc.h;h=a77c2533a88bf135ec9c1160b89be2473167e1dc;hb=922805b23964e54f9aa5e7408747617d32ea0e1d;hp=9b68c98d393b29e89da109f1ea11bf9db7e33652;hpb=0b1f00339cf83e1817e021f88c1168f52e31c331;p=ghc-hetmet.git diff --git a/ghc/utils/hsc2hs/template-hsc.h b/ghc/utils/hsc2hs/template-hsc.h index 9b68c98..a77c253 100644 --- a/ghc/utils/hsc2hs/template-hsc.h +++ b/ghc/utils/hsc2hs/template-hsc.h @@ -6,11 +6,21 @@ #include #include #include +#include +#include #ifndef offsetof #define offsetof(t, f) ((size_t) &((t *)0)->f) #endif +#if __NHC__ +#define hsc_line(line, file) \ + printf ("# %d \"%s\"\n", line, file); +#else +#define hsc_line(line, file) \ + printf ("{-# LINE %d \"%s\" #-}\n", line, file); +#endif + #define hsc_const(x) \ if ((x) < 0) \ printf ("%ld", (long)(x)); \ @@ -31,7 +41,7 @@ printf ("\\%d%s", \ (unsigned char) *s, \ s[1] >= '0' && s[1] <= '9' ? "\\&" : ""); \ - s++; \ + ++s; \ } \ printf ("\""); \ } @@ -56,3 +66,34 @@ #define hsc_ptr(t, f) \ printf ("(\\hsc_ptr -> hsc_ptr `plusPtr` %ld)", (long) offsetof (t, f)); +#define hsc_enum(t, f, print_name, x) \ + print_name; \ + printf (" :: %s\n", #t); \ + print_name; \ + printf (" = %s ", #f); \ + if ((x) < 0) \ + printf ("(%ld)\n", (long)(x)); \ + else \ + printf ("%lu\n", (unsigned long)(x)); + +#define hsc_haskellize(x) \ + { \ + const char *s = (x); \ + int upper = 0; \ + if (*s != '\0') \ + { \ + putchar (tolower (*s)); \ + ++s; \ + while (*s != '\0') \ + { \ + if (*s == '_') \ + upper = 1; \ + else \ + { \ + putchar (upper ? toupper (*s) : tolower (*s)); \ + upper = 0; \ + } \ + ++s; \ + } \ + } \ + }