lundump.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. ** $Id: lundump.h,v 1.7 1998/06/25 15:50:09 lhf Exp $
  3. ** load pre-compiled Lua chunks
  4. ** See Copyright Notice in lua.h
  5. */
  6. #ifndef lundump_h
  7. #define lundump_h
  8. #include "lobject.h"
  9. #include "lzio.h"
  10. TProtoFunc* luaU_undump1(ZIO* Z); /* load one chunk */
  11. #define SIGNATURE "Lua"
  12. #define VERSION 0x31 /* last format change was in 3.1 */
  13. #define VERSION0 0x31 /* last major change was in 3.1 */
  14. #define IsMain(f) (f->lineDefined==0)
  15. #define ID_CHUNK 27 /* ESC */
  16. #define ID_NUM 'N'
  17. #define ID_STR 'S'
  18. #define ID_FUN 'F'
  19. /* number representation */
  20. #define ID_INT4 'l' /* 4-byte integers */
  21. #define ID_REAL4 'f' /* 4-byte reals */
  22. #define ID_REAL8 'd' /* 8-byte reals */
  23. #define ID_NATIVE '?' /* whatever your machine uses */
  24. /*
  25. * use a multiple of PI for testing number representation.
  26. * multiplying by 1E8 gives notrivial integer values.
  27. */
  28. #define TEST_NUMBER 3.14159265358979323846E8
  29. /* LUA_NUMBER
  30. * choose one below for the number representation in precompiled chunks.
  31. * the default is ID_REAL8 because the default for LUA_NUM_TYPE is double.
  32. * if your machine does not use IEEE 754, use ID_NATIVE.
  33. * the next version will support conversion to/from IEEE 754.
  34. *
  35. * if you change LUA_NUM_TYPE, make sure you set ID_NUMBER accordingly,
  36. * specially if sizeof(long)!=4.
  37. * for types other than the ones listed below, you'll have to write your own
  38. * dump and undump routines.
  39. */
  40. #ifndef ID_NUMBER
  41. #define ID_NUMBER ID_NATIVE
  42. #endif
  43. #if 0
  44. #define ID_NUMBER ID_INT4
  45. #define ID_NUMBER ID_REAL4
  46. #define ID_NUMBER ID_REAL8
  47. #define ID_NUMBER ID_NATIVE
  48. #endif
  49. #endif
  50. #if ID_NUMBER==ID_REAL4
  51. #define DumpNumber DumpFloat
  52. #define LoadNumber LoadFloat
  53. #define SIZEOF_NUMBER 4
  54. #elif ID_NUMBER==ID_REAL8
  55. #define DumpNumber DumpDouble
  56. #define LoadNumber LoadDouble
  57. #define SIZEOF_NUMBER 8
  58. #elif ID_NUMBER==ID_INT4
  59. #define DumpNumber DumpLong
  60. #define LoadNumber LoadLong
  61. #define SIZEOF_NUMBER 4
  62. #elif ID_NUMBER==ID_NATIVE
  63. #define DumpNumber DumpNative
  64. #define LoadNumber LoadNative
  65. #define SIZEOF_NUMBER sizeof(real)
  66. #else
  67. #error bad ID_NUMBER
  68. #endif