Moving to config independent types stage 1 - generate intxx types.

This commit is contained in:
David Brown 2016-09-01 14:14:06 +01:00
parent 159f5a3d80
commit ee8342ef0d
168 changed files with 6673 additions and 6565 deletions

View file

@ -14,7 +14,7 @@ typedef
struct Files_BufDesc {
Files_File f;
BOOLEAN chg;
LONGINT org, size;
int64 org, size;
SYSTEM_BYTE data[4096];
} Files_BufDesc;
@ -29,23 +29,23 @@ typedef
Files_FileName workName, registerName;
BOOLEAN tempFile;
Platform_FileIdentity identity;
LONGINT fd, len, pos;
int64 fd, len, pos;
Files_Buffer bufs[4];
INTEGER swapper, state;
int32 swapper, state;
Files_File next;
} Files_FileDesc;
typedef
struct Files_Rider {
LONGINT res;
int64 res;
BOOLEAN eof;
Files_Buffer buf;
LONGINT org, offset;
int64 org, offset;
} Files_Rider;
static Files_File Files_files;
static INTEGER Files_tempno;
static int32 Files_tempno;
static CHAR Files_HOME[1024];
static struct {
LONGINT len[1];
@ -58,56 +58,56 @@ export LONGINT *Files_Rider__typ;
export Files_File Files_Base (Files_Rider *r, LONGINT *r__typ);
static Files_File Files_CacheEntry (Platform_FileIdentity identity);
export void Files_ChangeDirectory (CHAR *path, LONGINT path__len, INTEGER *res);
export void Files_ChangeDirectory (CHAR *path, LONGINT path__len, int32 *res);
export void Files_Close (Files_File f);
static void Files_CloseOSFile (Files_File f);
static void Files_Create (Files_File f);
export void Files_Delete (CHAR *name, LONGINT name__len, INTEGER *res);
static void Files_Err (CHAR *s, LONGINT s__len, Files_File f, INTEGER errcode);
export void Files_Delete (CHAR *name, LONGINT name__len, int32 *res);
static void Files_Err (CHAR *s, LONGINT s__len, Files_File f, int32 errcode);
static void Files_Finalize (SYSTEM_PTR o);
static void Files_FlipBytes (SYSTEM_BYTE *src, LONGINT src__len, SYSTEM_BYTE *dest, LONGINT dest__len);
static void Files_Flush (Files_Buffer buf);
export void Files_GetDate (Files_File f, LONGINT *t, LONGINT *d);
export void Files_GetDate (Files_File f, int64 *t, int64 *d);
export void Files_GetName (Files_File f, CHAR *name, LONGINT name__len);
static void Files_GetTempName (CHAR *finalName, LONGINT finalName__len, CHAR *name, LONGINT name__len);
static BOOLEAN Files_HasDir (CHAR *name, LONGINT name__len);
export LONGINT Files_Length (Files_File f);
export int64 Files_Length (Files_File f);
static void Files_MakeFileName (CHAR *dir, LONGINT dir__len, CHAR *name, LONGINT name__len, CHAR *dest, LONGINT dest__len);
export Files_File Files_New (CHAR *name, LONGINT name__len);
export Files_File Files_Old (CHAR *name, LONGINT name__len);
export LONGINT Files_Pos (Files_Rider *r, LONGINT *r__typ);
export int64 Files_Pos (Files_Rider *r, LONGINT *r__typ);
export void Files_Purge (Files_File f);
export void Files_Read (Files_Rider *r, LONGINT *r__typ, SYSTEM_BYTE *x);
export void Files_ReadBool (Files_Rider *R, LONGINT *R__typ, BOOLEAN *x);
export void Files_ReadByte (Files_Rider *r, LONGINT *r__typ, SYSTEM_BYTE *x, LONGINT x__len);
export void Files_ReadBytes (Files_Rider *r, LONGINT *r__typ, SYSTEM_BYTE *x, LONGINT x__len, LONGINT n);
export void Files_ReadInt (Files_Rider *R, LONGINT *R__typ, INTEGER *x);
export void Files_ReadLInt (Files_Rider *R, LONGINT *R__typ, LONGINT *x);
export void Files_ReadBytes (Files_Rider *r, LONGINT *r__typ, SYSTEM_BYTE *x, LONGINT x__len, int64 n);
export void Files_ReadInt (Files_Rider *R, LONGINT *R__typ, int32 *x);
export void Files_ReadLInt (Files_Rider *R, LONGINT *R__typ, int64 *x);
export void Files_ReadLReal (Files_Rider *R, LONGINT *R__typ, LONGREAL *x);
export void Files_ReadLine (Files_Rider *R, LONGINT *R__typ, CHAR *x, LONGINT x__len);
export void Files_ReadNum (Files_Rider *R, LONGINT *R__typ, LONGINT *x);
export void Files_ReadNum (Files_Rider *R, LONGINT *R__typ, int64 *x);
export void Files_ReadReal (Files_Rider *R, LONGINT *R__typ, REAL *x);
export void Files_ReadSet (Files_Rider *R, LONGINT *R__typ, SET *x);
export void Files_ReadString (Files_Rider *R, LONGINT *R__typ, CHAR *x, LONGINT x__len);
export void Files_Register (Files_File f);
export void Files_Rename (CHAR *old, LONGINT old__len, CHAR *new, LONGINT new__len, INTEGER *res);
static void Files_ScanPath (INTEGER *pos, CHAR *dir, LONGINT dir__len);
export void Files_Set (Files_Rider *r, LONGINT *r__typ, Files_File f, LONGINT pos);
export void Files_Rename (CHAR *old, LONGINT old__len, CHAR *new, LONGINT new__len, int32 *res);
static void Files_ScanPath (int32 *pos, CHAR *dir, LONGINT dir__len);
export void Files_Set (Files_Rider *r, LONGINT *r__typ, Files_File f, int64 pos);
export void Files_SetSearchPath (CHAR *path, LONGINT path__len);
export void Files_Write (Files_Rider *r, LONGINT *r__typ, SYSTEM_BYTE x);
export void Files_WriteBool (Files_Rider *R, LONGINT *R__typ, BOOLEAN x);
export void Files_WriteBytes (Files_Rider *r, LONGINT *r__typ, SYSTEM_BYTE *x, LONGINT x__len, LONGINT n);
export void Files_WriteInt (Files_Rider *R, LONGINT *R__typ, INTEGER x);
export void Files_WriteLInt (Files_Rider *R, LONGINT *R__typ, LONGINT x);
export void Files_WriteBytes (Files_Rider *r, LONGINT *r__typ, SYSTEM_BYTE *x, LONGINT x__len, int64 n);
export void Files_WriteInt (Files_Rider *R, LONGINT *R__typ, int32 x);
export void Files_WriteLInt (Files_Rider *R, LONGINT *R__typ, int64 x);
export void Files_WriteLReal (Files_Rider *R, LONGINT *R__typ, LONGREAL x);
export void Files_WriteNum (Files_Rider *R, LONGINT *R__typ, LONGINT x);
export void Files_WriteNum (Files_Rider *R, LONGINT *R__typ, int64 x);
export void Files_WriteReal (Files_Rider *R, LONGINT *R__typ, REAL x);
export void Files_WriteSet (Files_Rider *R, LONGINT *R__typ, SET x);
export void Files_WriteString (Files_Rider *R, LONGINT *R__typ, CHAR *x, LONGINT x__len);
#define Files_IdxTrap() __HALT(-1)
static void Files_Err (CHAR *s, LONGINT s__len, Files_File f, INTEGER errcode)
static void Files_Err (CHAR *s, LONGINT s__len, Files_File f, int32 errcode)
{
__DUP(s, s__len, CHAR);
Console_Ln();
@ -136,7 +136,7 @@ static void Files_Err (CHAR *s, LONGINT s__len, Files_File f, INTEGER errcode)
static void Files_MakeFileName (CHAR *dir, LONGINT dir__len, CHAR *name, LONGINT name__len, CHAR *dest, LONGINT dest__len)
{
INTEGER i, j;
int32 i, j;
__DUP(dir, dir__len, CHAR);
__DUP(name, name__len, CHAR);
i = 0;
@ -161,7 +161,7 @@ static void Files_MakeFileName (CHAR *dir, LONGINT dir__len, CHAR *name, LONGINT
static void Files_GetTempName (CHAR *finalName, LONGINT finalName__len, CHAR *name, LONGINT name__len)
{
LONGINT n, i, j;
int64 n, i, j;
__DUP(finalName, finalName__len, CHAR);
Files_tempno += 1;
n = Files_tempno;
@ -213,7 +213,7 @@ static void Files_Create (Files_File f)
{
Platform_FileIdentity identity;
BOOLEAN done;
INTEGER error;
int32 error;
CHAR err[32];
if (f->fd == -1) {
if (f->state == 1) {
@ -250,7 +250,7 @@ static void Files_Create (Files_File f)
static void Files_Flush (Files_Buffer buf)
{
INTEGER error;
int32 error;
Files_File f = NIL;
if (buf->chg) {
f = buf->f;
@ -274,7 +274,7 @@ static void Files_Flush (Files_Buffer buf)
static void Files_CloseOSFile (Files_File f)
{
Files_File prev = NIL;
INTEGER error;
int32 error;
if (Files_files == f) {
Files_files = f->next;
} else {
@ -294,8 +294,8 @@ static void Files_CloseOSFile (Files_File f)
void Files_Close (Files_File f)
{
LONGINT i;
INTEGER error;
int64 i;
int32 error;
if (f->state != 1 || f->registerName[0] != 0x00) {
Files_Create(f);
i = 0;
@ -311,9 +311,9 @@ void Files_Close (Files_File f)
}
}
LONGINT Files_Length (Files_File f)
int64 Files_Length (Files_File f)
{
LONGINT _o_result;
int64 _o_result;
_o_result = f->len;
return _o_result;
}
@ -336,9 +336,9 @@ Files_File Files_New (CHAR *name, LONGINT name__len)
return _o_result;
}
static void Files_ScanPath (INTEGER *pos, CHAR *dir, LONGINT dir__len)
static void Files_ScanPath (int32 *pos, CHAR *dir, LONGINT dir__len)
{
INTEGER i;
int32 i;
CHAR ch;
i = 0;
if (Files_SearchPath == NIL) {
@ -382,7 +382,7 @@ static void Files_ScanPath (INTEGER *pos, CHAR *dir, LONGINT dir__len)
static BOOLEAN Files_HasDir (CHAR *name, LONGINT name__len)
{
BOOLEAN _o_result;
INTEGER i;
int32 i;
CHAR ch;
i = 0;
ch = name[0];
@ -398,7 +398,7 @@ static Files_File Files_CacheEntry (Platform_FileIdentity identity)
{
Files_File _o_result;
Files_File f = NIL;
INTEGER i, error;
int32 i, error;
f = Files_files;
while (f != NIL) {
if (Platform_SameFile(identity, f->identity)) {
@ -428,11 +428,11 @@ Files_File Files_Old (CHAR *name, LONGINT name__len)
{
Files_File _o_result;
Files_File f = NIL;
LONGINT fd;
INTEGER pos;
int64 fd;
int32 pos;
BOOLEAN done;
CHAR dir[256], path[256];
INTEGER error;
int32 error;
Platform_FileIdentity identity;
__DUP(name, name__len, CHAR);
if (name[0] != 0x00) {
@ -507,9 +507,9 @@ Files_File Files_Old (CHAR *name, LONGINT name__len)
void Files_Purge (Files_File f)
{
INTEGER i;
int32 i;
Platform_FileIdentity identity;
INTEGER error;
int32 error;
i = 0;
while (i < 4) {
if (f->bufs[i] != NIL) {
@ -529,27 +529,27 @@ void Files_Purge (Files_File f)
Platform_SetMTime(&f->identity, Platform_FileIdentity__typ, identity);
}
void Files_GetDate (Files_File f, LONGINT *t, LONGINT *d)
void Files_GetDate (Files_File f, int64 *t, int64 *d)
{
Platform_FileIdentity identity;
INTEGER error;
int32 error;
Files_Create(f);
error = Platform_Identify(f->fd, &identity, Platform_FileIdentity__typ);
Platform_MTimeAsClock(identity, &*t, &*d);
}
LONGINT Files_Pos (Files_Rider *r, LONGINT *r__typ)
int64 Files_Pos (Files_Rider *r, LONGINT *r__typ)
{
LONGINT _o_result;
int64 _o_result;
_o_result = (*r).org + (*r).offset;
return _o_result;
}
void Files_Set (Files_Rider *r, LONGINT *r__typ, Files_File f, LONGINT pos)
void Files_Set (Files_Rider *r, LONGINT *r__typ, Files_File f, int64 pos)
{
LONGINT org, offset, i, n;
int64 org, offset, i, n;
Files_Buffer buf = NIL;
INTEGER error;
int32 error;
if (f != NIL) {
if (pos > f->len) {
pos = f->len;
@ -609,7 +609,7 @@ void Files_Set (Files_Rider *r, LONGINT *r__typ, Files_File f, LONGINT pos)
void Files_Read (Files_Rider *r, LONGINT *r__typ, SYSTEM_BYTE *x)
{
LONGINT offset;
int64 offset;
Files_Buffer buf = NIL;
buf = (*r).buf;
offset = (*r).offset;
@ -631,9 +631,9 @@ void Files_Read (Files_Rider *r, LONGINT *r__typ, SYSTEM_BYTE *x)
}
}
void Files_ReadBytes (Files_Rider *r, LONGINT *r__typ, SYSTEM_BYTE *x, LONGINT x__len, LONGINT n)
void Files_ReadBytes (Files_Rider *r, LONGINT *r__typ, SYSTEM_BYTE *x, LONGINT x__len, int64 n)
{
LONGINT xpos, min, restInBuf, offset;
int64 xpos, min, restInBuf, offset;
Files_Buffer buf = NIL;
if (n > x__len) {
Files_IdxTrap();
@ -682,7 +682,7 @@ Files_File Files_Base (Files_Rider *r, LONGINT *r__typ)
void Files_Write (Files_Rider *r, LONGINT *r__typ, SYSTEM_BYTE x)
{
Files_Buffer buf = NIL;
LONGINT offset;
int64 offset;
buf = (*r).buf;
offset = (*r).offset;
if ((*r).org != buf->org || offset >= 4096) {
@ -700,9 +700,9 @@ void Files_Write (Files_Rider *r, LONGINT *r__typ, SYSTEM_BYTE x)
(*r).res = 0;
}
void Files_WriteBytes (Files_Rider *r, LONGINT *r__typ, SYSTEM_BYTE *x, LONGINT x__len, LONGINT n)
void Files_WriteBytes (Files_Rider *r, LONGINT *r__typ, SYSTEM_BYTE *x, LONGINT x__len, int64 n)
{
LONGINT xpos, min, restInBuf, offset;
int64 xpos, min, restInBuf, offset;
Files_Buffer buf = NIL;
if (n > x__len) {
Files_IdxTrap();
@ -736,17 +736,17 @@ void Files_WriteBytes (Files_Rider *r, LONGINT *r__typ, SYSTEM_BYTE *x, LONGINT
(*r).res = 0;
}
void Files_Delete (CHAR *name, LONGINT name__len, INTEGER *res)
void Files_Delete (CHAR *name, LONGINT name__len, int32 *res)
{
__DUP(name, name__len, CHAR);
*res = Platform_Unlink((void*)name, name__len);
__DEL(name);
}
void Files_Rename (CHAR *old, LONGINT old__len, CHAR *new, LONGINT new__len, INTEGER *res)
void Files_Rename (CHAR *old, LONGINT old__len, CHAR *new, LONGINT new__len, int32 *res)
{
LONGINT fdold, fdnew, n;
INTEGER error, ignore;
int64 fdold, fdnew, n;
int32 error, ignore;
Platform_FileIdentity oldidentity, newidentity;
CHAR buf[4096];
__DUP(old, old__len, CHAR);
@ -801,7 +801,7 @@ void Files_Rename (CHAR *old, LONGINT old__len, CHAR *new, LONGINT new__len, INT
void Files_Register (Files_File f)
{
INTEGER idx, errcode;
int32 idx, errcode;
Files_File f1 = NIL;
CHAR file[104];
if ((f->state == 1 && f->registerName[0] != 0x00)) {
@ -820,7 +820,7 @@ void Files_Register (Files_File f)
}
}
void Files_ChangeDirectory (CHAR *path, LONGINT path__len, INTEGER *res)
void Files_ChangeDirectory (CHAR *path, LONGINT path__len, int32 *res)
{
__DUP(path, path__len, CHAR);
*res = Platform_Chdir((void*)path, path__len);
@ -829,7 +829,7 @@ void Files_ChangeDirectory (CHAR *path, LONGINT path__len, INTEGER *res)
static void Files_FlipBytes (SYSTEM_BYTE *src, LONGINT src__len, SYSTEM_BYTE *dest, LONGINT dest__len)
{
LONGINT i, j;
int64 i, j;
if (!Platform_LittleEndian) {
i = src__len;
j = 0;
@ -848,14 +848,14 @@ void Files_ReadBool (Files_Rider *R, LONGINT *R__typ, BOOLEAN *x)
Files_Read(&*R, R__typ, (CHAR*)(void*)&*x);
}
void Files_ReadInt (Files_Rider *R, LONGINT *R__typ, INTEGER *x)
void Files_ReadInt (Files_Rider *R, LONGINT *R__typ, int32 *x)
{
CHAR b[2];
Files_ReadBytes(&*R, R__typ, (void*)b, 2, 2);
*x = b[0] + __ASHL(b[1], 8);
}
void Files_ReadLInt (Files_Rider *R, LONGINT *R__typ, LONGINT *x)
void Files_ReadLInt (Files_Rider *R, LONGINT *R__typ, int64 *x)
{
CHAR b[4];
Files_ReadBytes(&*R, R__typ, (void*)b, 4, 4);
@ -865,7 +865,7 @@ void Files_ReadLInt (Files_Rider *R, LONGINT *R__typ, LONGINT *x)
void Files_ReadSet (Files_Rider *R, LONGINT *R__typ, SET *x)
{
CHAR b[4];
LONGINT l;
int64 l;
Files_ReadBytes(&*R, R__typ, (void*)b, 4, 4);
l = ((b[0] + __ASHL(b[1], 8)) + __ASHL(b[2], 16)) + __ASHL(b[3], 24);
*x = (SET)l;
@ -887,7 +887,7 @@ void Files_ReadLReal (Files_Rider *R, LONGINT *R__typ, LONGREAL *x)
void Files_ReadString (Files_Rider *R, LONGINT *R__typ, CHAR *x, LONGINT x__len)
{
INTEGER i;
int32 i;
CHAR ch;
i = 0;
do {
@ -899,7 +899,7 @@ void Files_ReadString (Files_Rider *R, LONGINT *R__typ, CHAR *x, LONGINT x__len)
void Files_ReadLine (Files_Rider *R, LONGINT *R__typ, CHAR *x, LONGINT x__len)
{
INTEGER i;
int32 i;
CHAR ch;
BOOLEAN b;
i = 0;
@ -915,20 +915,20 @@ void Files_ReadLine (Files_Rider *R, LONGINT *R__typ, CHAR *x, LONGINT x__len)
} while (!b);
}
void Files_ReadNum (Files_Rider *R, LONGINT *R__typ, LONGINT *x)
void Files_ReadNum (Files_Rider *R, LONGINT *R__typ, int64 *x)
{
SHORTINT s;
int8 s;
CHAR ch;
LONGINT n;
int64 n;
s = 0;
n = 0;
Files_Read(&*R, R__typ, (void*)&ch);
while (ch >= 128) {
n += __ASH((SYSTEM_INT64)(ch - 128), s);
n += __ASH((int64)(ch - 128), s);
s += 7;
Files_Read(&*R, R__typ, (void*)&ch);
}
n += __ASH((SYSTEM_INT64)(__MASK(ch, -64) - __ASHL(__ASHR(ch, 6), 6)), s);
n += __ASH((int64)(__MASK(ch, -64) - __ASHL(__ASHR(ch, 6), 6)), s);
*x = n;
}
@ -937,7 +937,7 @@ void Files_WriteBool (Files_Rider *R, LONGINT *R__typ, BOOLEAN x)
Files_Write(&*R, R__typ, __VAL(CHAR, x));
}
void Files_WriteInt (Files_Rider *R, LONGINT *R__typ, INTEGER x)
void Files_WriteInt (Files_Rider *R, LONGINT *R__typ, int32 x)
{
CHAR b[2];
b[0] = (CHAR)x;
@ -945,7 +945,7 @@ void Files_WriteInt (Files_Rider *R, LONGINT *R__typ, INTEGER x)
Files_WriteBytes(&*R, R__typ, (void*)b, 2, 2);
}
void Files_WriteLInt (Files_Rider *R, LONGINT *R__typ, LONGINT x)
void Files_WriteLInt (Files_Rider *R, LONGINT *R__typ, int64 x)
{
CHAR b[4];
b[0] = (CHAR)x;
@ -958,8 +958,8 @@ void Files_WriteLInt (Files_Rider *R, LONGINT *R__typ, LONGINT x)
void Files_WriteSet (Files_Rider *R, LONGINT *R__typ, SET x)
{
CHAR b[4];
LONGINT i;
i = (LONGINT)x;
int64 i;
i = (int64)x;
b[0] = (CHAR)i;
b[1] = (CHAR)__ASHR(i, 8);
b[2] = (CHAR)__ASHR(i, 16);
@ -983,7 +983,7 @@ void Files_WriteLReal (Files_Rider *R, LONGINT *R__typ, LONGREAL x)
void Files_WriteString (Files_Rider *R, LONGINT *R__typ, CHAR *x, LONGINT x__len)
{
INTEGER i;
int32 i;
i = 0;
while (x[i] != 0x00) {
i += 1;
@ -991,7 +991,7 @@ void Files_WriteString (Files_Rider *R, LONGINT *R__typ, CHAR *x, LONGINT x__len
Files_WriteBytes(&*R, R__typ, (void*)x, x__len * 1, i + 1);
}
void Files_WriteNum (Files_Rider *R, LONGINT *R__typ, LONGINT x)
void Files_WriteNum (Files_Rider *R, LONGINT *R__typ, int64 x)
{
while (x < -64 || x > 63) {
Files_Write(&*R, R__typ, (CHAR)(__MASK(x, -128) + 128));
@ -1008,7 +1008,7 @@ void Files_GetName (Files_File f, CHAR *name, LONGINT name__len)
static void Files_Finalize (SYSTEM_PTR o)
{
Files_File f = NIL;
LONGINT res;
int64 res;
f = (Files_File)(SYSTEM_ADRINT)o;
if (f->fd >= 0) {
Files_CloseOSFile(f);