lua/lundump.h

82 lines
2.0 KiB
C
Raw Normal View History

1998-01-14 18:49:01 +03:00
/*
1998-12-15 17:59:43 +03:00
** $Id: lundump.h,v 1.4 1998/06/25 16:48:44 roberto Exp roberto $
1998-01-14 18:49:01 +03:00
** load pre-compiled Lua chunks
** See Copyright Notice in lua.h
*/
#ifndef lundump_h
#define lundump_h
#include "lobject.h"
#include "lzio.h"
1998-12-15 17:59:43 +03:00
TProtoFunc *luaU_undump1 (ZIO* Z); /* load one chunk */
1998-03-26 17:50:19 +03:00
#define SIGNATURE "Lua"
#define VERSION 0x31 /* last format change was in 3.1 */
1998-06-25 20:48:44 +04:00
#define VERSION0 0x31 /* last major change was in 3.1 */
1998-03-26 17:50:19 +03:00
#define IsMain(f) (f->lineDefined==0)
1998-01-14 18:49:01 +03:00
#define ID_CHUNK 27 /* ESC */
#define ID_NUM 'N'
#define ID_STR 'S'
#define ID_FUN 'F'
1998-06-18 20:52:04 +04:00
/* number representation */
#define ID_INT4 'l' /* 4-byte integers */
#define ID_REAL4 'f' /* 4-byte reals */
#define ID_REAL8 'd' /* 8-byte reals */
#define ID_NATIVE '?' /* whatever your machine uses */
1998-01-14 18:49:01 +03:00
1998-03-26 17:50:19 +03:00
/*
* use a multiple of PI for testing number representation.
1998-06-18 20:52:04 +04:00
* multiplying by 1E8 gives notrivial integer values.
1998-03-26 17:50:19 +03:00
*/
#define TEST_NUMBER 3.14159265358979323846E8
1998-06-18 20:52:04 +04:00
/* LUA_NUMBER
* choose one below for the number representation in precompiled chunks.
* the default is ID_REAL8 because the default for LUA_NUM_TYPE is double.
* if your machine does not use IEEE 754, use ID_NATIVE.
* the next version will support conversion to/from IEEE 754.
*
* if you change LUA_NUM_TYPE, make sure you set ID_NUMBER accordingly,
* specially if sizeof(long)!=4.
1998-03-26 17:50:19 +03:00
* for types other than the ones listed below, you'll have to write your own
* dump and undump routines.
*/
1998-06-25 20:48:44 +04:00
#ifndef ID_NUMBER
#define ID_NUMBER ID_NATIVE
#endif
1998-06-18 20:52:04 +04:00
#if 0
#define ID_NUMBER ID_INT4
1998-06-25 20:48:44 +04:00
#define ID_NUMBER ID_REAL4
#define ID_NUMBER ID_REAL8
1998-06-18 20:52:04 +04:00
#define ID_NUMBER ID_NATIVE
1998-03-26 17:50:19 +03:00
#endif
1998-01-14 18:49:01 +03:00
#endif
1998-06-25 20:48:44 +04:00
#if ID_NUMBER==ID_REAL4
#define DumpNumber DumpFloat
#define LoadNumber LoadFloat
#define SIZEOF_NUMBER 4
#elif ID_NUMBER==ID_REAL8
#define DumpNumber DumpDouble
#define LoadNumber LoadDouble
#define SIZEOF_NUMBER 8
#elif ID_NUMBER==ID_INT4
#define DumpNumber DumpLong
#define LoadNumber LoadLong
#define SIZEOF_NUMBER 4
#elif ID_NUMBER==ID_NATIVE
#define DumpNumber DumpNative
#define LoadNumber LoadNative
#define SIZEOF_NUMBER sizeof(real)
#else
#error bad ID_NUMBER
#endif