Changes between Version 10 and Version 11 of ForeignData
- Timestamp:
- 02/05/06 23:44:12 (7 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
ForeignData
v10 v11 17 17 18 18 {{{ 19 foreign space [const] <n> :: Ptr <type>19 foreign space [const] <n> "name" :: Ptr <type> 20 20 }}} 21 21 … … 33 33 34 34 {{{ 35 foreign space [bigendian|littleendian] [const] <n> :: Ptr <type> = constant35 foreign space [bigendian|littleendian] [const] <n> "name" :: Ptr <type> = constant 36 36 }}} 37 37 … … 43 43 44 44 45 * a "string" to be output as utf8, utf16 or ucs4 unicode code points depending on what type of pointer it is assigned to. 46 45 * a "string" to be output as utf8, utf16 or ucs4 unicode code points depending on the size of the type of pointer it is assigned to. 47 46 48 47 49 48 if the data is initialized as a string, <n> will always refer to a number of characters regardless of encoding and the string will be null terminated (unless an explicit <n> chops off the trailing space) 50 49 51 big endian or little endian may be explicitly specified in which case the data is written out with the specified endianess, else it will be output in the default format of the givensystem.50 big endian or little endian may be explicitly specified in which case the data is written out with the specified endianess, else it will be output in the default format of the target system. 52 51 53 52 == implementation == … … 59 58 60 59 It is anoying that <n> must be a constant and <type> must be a builtin, but there is not really any other recourse without defining a preprocessor in haskell and the restrictions are no more onerous than those placed on the arguments to foreign function calls. Something like template haskell would mitigate this problem when available. 60 61 == sample translation == 62 63 when compiling to C, here is an example of what the code will translate too. 64 65 {{{ 66 foreign space const "myints" :: Ptr CInt = [1,2,3,4] 67 }}} 68 69 becomes 70 71 the haskell import: 72 {{{ 73 forign import "&c_myints" myints :: Ptr CInt 74 }}} 75 and the c code: 76 {{{ 77 int c_myints[] = {1,2,3,4}; 78 }}} 79 80 81
