author | nemo |
Wed, 27 Feb 2013 21:30:33 -0500 | |
changeset 8598 | 9d21bab30893 |
parent 7151 | ec15d9e1a7e3 |
permissions | -rw-r--r-- |
6875
6528171ce36d
First try to compile with clang: improve renderer a bit. The result of pas2c is still far from normal C source.
unc0rr
parents:
diff
changeset
|
1 |
#pragma once |
6528171ce36d
First try to compile with clang: improve renderer a bit. The result of pas2c is still far from normal C source.
unc0rr
parents:
diff
changeset
|
2 |
|
7134 | 3 |
#include <stddef.h> |
6971
b7b38e051b5f
add NULL definition and align types to their correct bitwidth
koda
parents:
6967
diff
changeset
|
4 |
#include <stdint.h> |
6878
0af34406b83d
Improve rendering of function types, arrays, and more
unc0rr
parents:
6875
diff
changeset
|
5 |
#include <stdbool.h> |
7073 | 6 |
#include <wchar.h> |
6878
0af34406b83d
Improve rendering of function types, arrays, and more
unc0rr
parents:
6875
diff
changeset
|
7 |
|
6896
23b38e530967
Move all strings into constants to make them of string255 type
unc0rr
parents:
6895
diff
changeset
|
8 |
typedef union string255_ |
6883 | 9 |
{ |
6896
23b38e530967
Move all strings into constants to make them of string255 type
unc0rr
parents:
6895
diff
changeset
|
10 |
struct { |
23b38e530967
Move all strings into constants to make them of string255 type
unc0rr
parents:
6895
diff
changeset
|
11 |
char s[256]; |
23b38e530967
Move all strings into constants to make them of string255 type
unc0rr
parents:
6895
diff
changeset
|
12 |
}; |
23b38e530967
Move all strings into constants to make them of string255 type
unc0rr
parents:
6895
diff
changeset
|
13 |
struct { |
23b38e530967
Move all strings into constants to make them of string255 type
unc0rr
parents:
6895
diff
changeset
|
14 |
char len; |
23b38e530967
Move all strings into constants to make them of string255 type
unc0rr
parents:
6895
diff
changeset
|
15 |
char str[255]; |
23b38e530967
Move all strings into constants to make them of string255 type
unc0rr
parents:
6895
diff
changeset
|
16 |
}; |
6883 | 17 |
} string255; |
6889 | 18 |
typedef struct string192_ |
19 |
{ |
|
20 |
char s[193]; |
|
21 |
} string192; |
|
22 |
typedef struct string31_ |
|
23 |
{ |
|
24 |
char s[32]; |
|
25 |
} string31; |
|
6891
ab9843957664
Improve rendering of function types, ranges, and more
unc0rr
parents:
6889
diff
changeset
|
26 |
typedef struct string15_ |
ab9843957664
Improve rendering of function types, ranges, and more
unc0rr
parents:
6889
diff
changeset
|
27 |
{ |
ab9843957664
Improve rendering of function types, ranges, and more
unc0rr
parents:
6889
diff
changeset
|
28 |
char s[16]; |
ab9843957664
Improve rendering of function types, ranges, and more
unc0rr
parents:
6889
diff
changeset
|
29 |
} string15; |
6875
6528171ce36d
First try to compile with clang: improve renderer a bit. The result of pas2c is still far from normal C source.
unc0rr
parents:
diff
changeset
|
30 |
|
7072 | 31 |
typedef string255 shortstring; |
7151 | 32 |
typedef string255 ansistring; |
7072 | 33 |
|
6971
b7b38e051b5f
add NULL definition and align types to their correct bitwidth
koda
parents:
6967
diff
changeset
|
34 |
typedef uint8_t Byte; |
b7b38e051b5f
add NULL definition and align types to their correct bitwidth
koda
parents:
6967
diff
changeset
|
35 |
typedef int8_t ShortInt; |
b7b38e051b5f
add NULL definition and align types to their correct bitwidth
koda
parents:
6967
diff
changeset
|
36 |
typedef uint16_t Word; |
b7b38e051b5f
add NULL definition and align types to their correct bitwidth
koda
parents:
6967
diff
changeset
|
37 |
typedef int16_t SmallInt; |
b7b38e051b5f
add NULL definition and align types to their correct bitwidth
koda
parents:
6967
diff
changeset
|
38 |
typedef uint32_t LongWord; |
b7b38e051b5f
add NULL definition and align types to their correct bitwidth
koda
parents:
6967
diff
changeset
|
39 |
typedef int32_t LongInt; |
b7b38e051b5f
add NULL definition and align types to their correct bitwidth
koda
parents:
6967
diff
changeset
|
40 |
typedef uint64_t QWord; |
b7b38e051b5f
add NULL definition and align types to their correct bitwidth
koda
parents:
6967
diff
changeset
|
41 |
typedef int64_t Int64; |
7073 | 42 |
typedef LongWord Cardinal; |
6878
0af34406b83d
Improve rendering of function types, arrays, and more
unc0rr
parents:
6875
diff
changeset
|
43 |
|
6971
b7b38e051b5f
add NULL definition and align types to their correct bitwidth
koda
parents:
6967
diff
changeset
|
44 |
typedef LongInt Integer; |
6878
0af34406b83d
Improve rendering of function types, arrays, and more
unc0rr
parents:
6875
diff
changeset
|
45 |
typedef float extended; |
0af34406b83d
Improve rendering of function types, arrays, and more
unc0rr
parents:
6875
diff
changeset
|
46 |
typedef float real; |
7043
7c080e5ac8d0
Some work to make more units compile after conversion to c
unc0rr
parents:
7041
diff
changeset
|
47 |
typedef float single; |
6878
0af34406b83d
Improve rendering of function types, arrays, and more
unc0rr
parents:
6875
diff
changeset
|
48 |
|
0af34406b83d
Improve rendering of function types, arrays, and more
unc0rr
parents:
6875
diff
changeset
|
49 |
typedef bool boolean; |
7043
7c080e5ac8d0
Some work to make more units compile after conversion to c
unc0rr
parents:
7041
diff
changeset
|
50 |
typedef int LongBool; |
6875
6528171ce36d
First try to compile with clang: improve renderer a bit. The result of pas2c is still far from normal C source.
unc0rr
parents:
diff
changeset
|
51 |
|
6528171ce36d
First try to compile with clang: improve renderer a bit. The result of pas2c is still far from normal C source.
unc0rr
parents:
diff
changeset
|
52 |
typedef void * pointer; |
6878
0af34406b83d
Improve rendering of function types, arrays, and more
unc0rr
parents:
6875
diff
changeset
|
53 |
typedef Byte * PByte; |
0af34406b83d
Improve rendering of function types, arrays, and more
unc0rr
parents:
6875
diff
changeset
|
54 |
typedef char * PChar; |
0af34406b83d
Improve rendering of function types, arrays, and more
unc0rr
parents:
6875
diff
changeset
|
55 |
typedef LongInt * PLongInt; |
7060
861d6897917f
Properly track type in ref2CF, this fixes issues with functions returning strings used in expression (like "a" + line())
unc0rr
parents:
7054
diff
changeset
|
56 |
typedef LongWord * PLongWord; |
6878
0af34406b83d
Improve rendering of function types, arrays, and more
unc0rr
parents:
6875
diff
changeset
|
57 |
typedef Integer * PInteger; |
7070 | 58 |
typedef int PtrInt; |
7073 | 59 |
typedef wchar_t widechar; |
6875
6528171ce36d
First try to compile with clang: improve renderer a bit. The result of pas2c is still far from normal C source.
unc0rr
parents:
diff
changeset
|
60 |
|
6922 | 61 |
#define new(a) __new((void **)&a, sizeof(*(a))) |
62 |
void __new(void ** p, int size); |
|
6895 | 63 |
#define dispose(a) __dispose(a, sizeof(*(a))) |
64 |
void __dispose(pointer p, int size); |
|
6894 | 65 |
|
7053 | 66 |
void * GetMem(int size); |
67 |
void FreeMem(void * p, int size); |
|
68 |
||
6894 | 69 |
#define FillChar(a, b, c) __FillChar(&(a), b, c) |
70 |
||
71 |
void __FillChar(pointer p, int size, char fill); |
|
72 |
string255 _strconcat(string255 a, string255 b); |
|
6898 | 73 |
string255 _strappend(string255 s, char c); |
74 |
string255 _strprepend(char c, string255 s); |
|
7151 | 75 |
string255 _chrconcat(char a, char b); |
6923 | 76 |
bool _strcompare(string255 a, string255 b); |
7054 | 77 |
bool _strcomparec(string255 a, char b); |
7043
7c080e5ac8d0
Some work to make more units compile after conversion to c
unc0rr
parents:
7041
diff
changeset
|
78 |
bool _strncompare(string255 a, string255 b); |
6898 | 79 |
char * _pchar(string255 s); |
7134 | 80 |
string255 pchar2str(char * s); |
6894 | 81 |
|
6895 | 82 |
int Length(string255 a); |
83 |
string255 copy(string255 a, int s, int l); |
|
84 |
string255 delete(string255 a, int s, int l); |
|
7069 | 85 |
string255 trim(string255 a); |
6895 | 86 |
|
6967
1224c6fb36c3
Support recurrent function calls. The code is kinda hackish and ugly, but I really spent a few hours thinking on a good solution.
unc0rr
parents:
6965
diff
changeset
|
87 |
#define STRINIT(a) {.len = sizeof(a) - 1, .str = a} |
6898 | 88 |
|
7062 | 89 |
|
90 |
int length_ar(void * a); |
|
91 |
||
6898 | 92 |
typedef int file; |
7043
7c080e5ac8d0
Some work to make more units compile after conversion to c
unc0rr
parents:
7041
diff
changeset
|
93 |
typedef int TextFile; |
6898 | 94 |
extern int FileMode; |
95 |
extern int IOResult; |
|
7151 | 96 |
extern int stdout; |
7074 | 97 |
extern int stderr; |
6898 | 98 |
|
6902
7d4e5ce73b98
Make pas2c even smarter. Now uIO.c compiles fine, and only 1 warning when compiled with -Wall (clang).
unc0rr
parents:
6898
diff
changeset
|
99 |
#define assign(a, b) assign_(&(a), b) |
7d4e5ce73b98
Make pas2c even smarter. Now uIO.c compiles fine, and only 1 warning when compiled with -Wall (clang).
unc0rr
parents:
6898
diff
changeset
|
100 |
void assign_(int * f, string255 fileName); |
7069 | 101 |
void reset_1(int f, int size); |
102 |
void reset_2(int f, int size); |
|
6898 | 103 |
#define BlockRead(a, b, c, d) BlockRead_(a, &(b), c, &(d)) |
104 |
void BlockRead_(int f, void * p, int size, int * sizeRead); |
|
7053 | 105 |
#define BlockWrite(a, b, c) BlockWrite_(a, &(b), c) |
106 |
void BlockWrite_(int f, void * p, int size); |
|
6898 | 107 |
void close(int f); |
7002 | 108 |
|
7151 | 109 |
void write(int f, string255 s); |
110 |
void writeLn(int f, string255 s); |
|
7054 | 111 |
|
7053 | 112 |
bool DirectoryExists(string255 dir); |
113 |
bool FileExists(string255 filename); |
|
114 |
||
7002 | 115 |
bool odd(int i); |
7038 | 116 |
|
117 |
||
118 |
typedef int TThreadId; |
|
119 |
void ThreadSwitch(); |
|
120 |
#define InterlockedIncrement(a) __InterlockedIncrement(&(a)) |
|
121 |
#define InterlockedDecrement(a) __InterlockedDecrement(&(a)) |
|
122 |
void __InterlockedIncrement(int * a); |
|
123 |
void __InterlockedDecrement(int * a); |
|
124 |
||
125 |
bool Assigned(void * a); |
|
126 |
||
7054 | 127 |
void randomize(); |
7038 | 128 |
int random(int max); |
129 |
int abs(int i); |
|
7041 | 130 |
double sqr(double n); |
131 |
double sqrt(double n); |
|
132 |
int trunc(double n); |
|
7043
7c080e5ac8d0
Some work to make more units compile after conversion to c
unc0rr
parents:
7041
diff
changeset
|
133 |
int round(double n); |
7045 | 134 |
|
135 |
string255 ParamStr(int n); |
|
136 |
int ParamCount(); |
|
7054 | 137 |
|
7151 | 138 |
#define val(a, b, c) _val(a, (LongInt*)&(b), (LongInt*)&(c)) |
139 |
void _val(string255 str, LongInt * a, LongInt * c); |
|
7062 | 140 |
|
141 |
extern double pi; |
|
7069 | 142 |
|
143 |
string255 EnumToStr(int a); |
|
144 |
string255 ExtractFileName(string255 f); |