aboutsummaryrefslogtreecommitdiff
path: root/lundump.h
diff options
context:
space:
mode:
Diffstat (limited to 'lundump.h')
-rw-r--r--lundump.h91
1 files changed, 18 insertions, 73 deletions
diff --git a/lundump.h b/lundump.h
index 399a72db..0446ccdf 100644
--- a/lundump.h
+++ b/lundump.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lundump.h,v 1.6 1999/03/30 20:29:34 roberto Exp roberto $ 2** $Id: lundump.h,v 1.13 1999/03/29 16:16:18 lhf Exp lhf $
3** load pre-compiled Lua chunks 3** load pre-compiled Lua chunks
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -10,39 +10,7 @@
10#include "lobject.h" 10#include "lobject.h"
11#include "lzio.h" 11#include "lzio.h"
12 12
13/* -- start of user configuration ------------------------------------------ */
14
15/* LUA_NUMBER
16* choose below the number representation in precompiled chunks by choosing an
17* an adequate definition for ID_NUMBER.
18* if you change LUA_NUM_TYPE, you must set ID_NUMBER accordingly.
19* the default is ID_REAL8 because the default for LUA_NUM_TYPE is double.
20* if you want to use this default, do nothing.
21* if your machine does not use the IEEE 754 floating-point standard, use
22* ID_NATIVE, but precompiled chunks may not be portable to all architectures.
23*
24* for types other than the ones listed below, you'll have to write your own
25* dump and undump routines, specially if sizeof(long)!=4.
26*/
27
28/* choose one definition for ID_NUMBER and move it to after #endif */
29#if 0
30#define ID_NUMBER ID_INT4 /* 4-byte integers */
31#define ID_NUMBER ID_REAL4 /* 4-byte reals */
32#define ID_NUMBER ID_REAL8 /* 8-byte reals */
33#define ID_NUMBER ID_NATIVE /* whatever your machine uses */
34#endif
35
36/* format for numbers in listings and error messages */
37#ifndef NUMBER_FMT
38#define NUMBER_FMT "%.16g" /* LUA_NUMBER */
39#endif
40
41/* -- end of user configuration -- DO NOT CHANGE ANYTHING BELOW THIS LINE -- */
42
43
44TProtoFunc* luaU_undump1 (ZIO* Z); /* load one chunk */ 13TProtoFunc* luaU_undump1 (ZIO* Z); /* load one chunk */
45void luaU_testnumber (void); /* test number representation */
46void luaU_badconstant (char* s, int i, TObject* o, TProtoFunc* tf); 14void luaU_badconstant (char* s, int i, TObject* o, TProtoFunc* tf);
47 /* handle cases that cannot happen */ 15 /* handle cases that cannot happen */
48 16
@@ -52,52 +20,29 @@ void luaU_badconstant (char* s, int i, TObject* o, TProtoFunc* tf);
52#define ID_CHUNK 27 /* binary files start with ESC... */ 20#define ID_CHUNK 27 /* binary files start with ESC... */
53#define SIGNATURE "Lua" /* ...followed by this signature */ 21#define SIGNATURE "Lua" /* ...followed by this signature */
54 22
55/* number representation */ 23/* formats for error messages */
56#define ID_INT4 'l' /* 4-byte integers */ 24#define SOURCE "<%s:%d>"
57#define ID_REAL4 'f' /* 4-byte reals */ 25#define IN " in %p " SOURCE
58#define ID_REAL8 'd' /* 8-byte reals */ 26#define INLOC tf,tf->source->str,tf->lineDefined
59#define ID_NATIVE '?' /* whatever your machine uses */
60 27
61/* the default is ID_REAL8 because the default for LUA_NUM_TYPE is double */ 28/* format for numbers in listings and error messages */
62#ifndef ID_NUMBER 29#ifndef NUMBER_FMT
63#define ID_NUMBER ID_REAL8 /* 8-byte reals */ 30#define NUMBER_FMT "%.16g" /* LUA_NUMBER */
64#endif 31#endif
65 32
33/* LUA_NUMBER
34* by default, numbers are stored in precompiled chunks as decimal strings.
35* this is completely portable and fast enough for most applications.
36* if you want to use this default, do nothing.
37* if you want additional speed at the expense of portability, move the line
38* below out of this comment.
39#define LUAC_NATIVE
40*/
41
42#ifdef LUAC_NATIVE
66/* a multiple of PI for testing number representation */ 43/* a multiple of PI for testing number representation */
67/* multiplying by 1E8 gives non-trivial integer values */ 44/* multiplying by 1E8 gives non-trivial integer values */
68#define TEST_NUMBER 3.14159265358979323846E8 45#define TEST_NUMBER 3.14159265358979323846E8
69
70#if ID_NUMBER==ID_REAL4
71 #define DumpNumber DumpFloat
72 #define LoadNumber LoadFloat
73 #define SIZEOF_NUMBER 4
74 #define TYPEOF_NUMBER float
75 #define NAMEOF_NUMBER "float"
76#elif ID_NUMBER==ID_REAL8
77 #define DumpNumber DumpDouble
78 #define LoadNumber LoadDouble
79 #define SIZEOF_NUMBER 8
80 #define TYPEOF_NUMBER double
81 #define NAMEOF_NUMBER "double"
82#elif ID_NUMBER==ID_INT4
83 #define DumpNumber DumpLong
84 #define LoadNumber LoadLong
85 #define SIZEOF_NUMBER 4
86 #define TYPEOF_NUMBER long
87 #define NAMEOF_NUMBER "long"
88#elif ID_NUMBER==ID_NATIVE
89 #define DumpNumber DumpNative
90 #define LoadNumber LoadNative
91 #define SIZEOF_NUMBER sizeof(real)
92 #define TYPEOF_NUMBER real
93 #define NAMEOF_NUMBER "native"
94#else
95 #error bad ID_NUMBER
96#endif 46#endif
97 47
98/* formats for error messages */
99#define SOURCE "<%s:%d>"
100#define IN " in %p " SOURCE
101#define INLOC tf,tf->source->str,tf->lineDefined
102
103#endif 48#endif