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