Changes between Version 10 and Version 11 of ForeignData


Ignore:
Timestamp:
Feb 6, 2006 7:44:12 AM (9 years ago)
Author:
john@…
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ForeignData

    v10 v11  
    1717
    1818{{{
    19 foreign space [const] <n> :: Ptr <type>
     19foreign space [const] <n> "name" :: Ptr <type>
    2020}}}
    2121
     
    3333
    3434{{{
    35 foreign space [bigendian|littleendian] [const] <n> :: Ptr <type> = constant
     35foreign space [bigendian|littleendian] [const] <n> "name" :: Ptr <type> = constant
    3636}}}
    3737
     
    4343
    4444
    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.
    4746
    4847
    4948if 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)
    5049
    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 given system.
     50big 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.
    5251
    5352== implementation ==
     
    5958
    6059It 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
     63when compiling to C, here is an example of what the code will translate too.
     64
     65{{{
     66foreign space const "myints" :: Ptr CInt = [1,2,3,4]
     67}}}
     68
     69becomes
     70
     71the haskell import:
     72{{{
     73forign import "&c_myints" myints :: Ptr CInt
     74}}}
     75and the c code:
     76{{{
     77int c_myints[] = {1,2,3,4};
     78}}}
     79
     80
     81