project_files/hwc/rtl/pas2c.h
author sheepluva
Mon, 05 Aug 2019 00:20:45 +0200
changeset 15295 f382ec6dba11
parent 14249 06f2dc4deab2
permissions -rw-r--r--
In hindsight my emscripten-ifdef (70d416a8f63f) is nonsense. As fpcrtl_glShaderSource() would not be defined and lead to compiling issues. So either it's 3 ifdefs (in pas2cRedo, pas2cSystem and misc.c), in order to toggle between fpcrtl_ and the native function, or alternatively have no ifdef for it at all. I'm going with none at all, which means emscripten will compile with the original (const) function prototype, being wrapped by the fpcrtl_ function, same as non-emscripten builds.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7989
7ef4ace6335f add xymeng's pas2c header
koda
parents:
diff changeset
     1
#pragma once
7ef4ace6335f add xymeng's pas2c header
koda
parents:
diff changeset
     2
7ef4ace6335f add xymeng's pas2c header
koda
parents:
diff changeset
     3
#include <stddef.h>
7ef4ace6335f add xymeng's pas2c header
koda
parents:
diff changeset
     4
#include <stdint.h>
7ef4ace6335f add xymeng's pas2c header
koda
parents:
diff changeset
     5
#include <stdbool.h>
7ef4ace6335f add xymeng's pas2c header
koda
parents:
diff changeset
     6
#include <wchar.h>
7ef4ace6335f add xymeng's pas2c header
koda
parents:
diff changeset
     7
#include <math.h>
7ef4ace6335f add xymeng's pas2c header
koda
parents:
diff changeset
     8
8006
7ca007615b88 no globs, sources not yet generated
koda
parents: 7989
diff changeset
     9
#define MAX_PARAMS 64
14249
06f2dc4deab2 Remove erroneous code duplicating FIX_STRING functionality, adjust ansistring array size
unc0rr
parents: 14185
diff changeset
    10
#define MAX_ANSISTRING_LENGTH 16382
7989
7ef4ace6335f add xymeng's pas2c header
koda
parents:
diff changeset
    11
7ef4ace6335f add xymeng's pas2c header
koda
parents:
diff changeset
    12
typedef union string255_
7ef4ace6335f add xymeng's pas2c header
koda
parents:
diff changeset
    13
    {
7ef4ace6335f add xymeng's pas2c header
koda
parents:
diff changeset
    14
        struct {
10121
8b65699beb56 Implement a bit of astring
unc0rr
parents: 9962
diff changeset
    15
            unsigned char s[256];
7989
7ef4ace6335f add xymeng's pas2c header
koda
parents:
diff changeset
    16
        };
7ef4ace6335f add xymeng's pas2c header
koda
parents:
diff changeset
    17
        struct {
7ef4ace6335f add xymeng's pas2c header
koda
parents:
diff changeset
    18
            unsigned char len;
10121
8b65699beb56 Implement a bit of astring
unc0rr
parents: 9962
diff changeset
    19
            unsigned char str[255];
7989
7ef4ace6335f add xymeng's pas2c header
koda
parents:
diff changeset
    20
        };
7ef4ace6335f add xymeng's pas2c header
koda
parents:
diff changeset
    21
    } string255;
10121
8b65699beb56 Implement a bit of astring
unc0rr
parents: 9962
diff changeset
    22
8b65699beb56 Implement a bit of astring
unc0rr
parents: 9962
diff changeset
    23
typedef union astring_
7989
7ef4ace6335f add xymeng's pas2c header
koda
parents:
diff changeset
    24
    {
10121
8b65699beb56 Implement a bit of astring
unc0rr
parents: 9962
diff changeset
    25
        struct {
10131
4b4a043111f4 - pas2c recognizes typecasts in initialization expressions
unc0rr
parents: 10128
diff changeset
    26
            uint16_t len;
13880
5f819b90d479 - Fix insert() for strings in pas2c
unc0rr
parents: 12103
diff changeset
    27
            unsigned char str[MAX_ANSISTRING_LENGTH];
10121
8b65699beb56 Implement a bit of astring
unc0rr
parents: 9962
diff changeset
    28
        };
8b65699beb56 Implement a bit of astring
unc0rr
parents: 9962
diff changeset
    29
        struct {
8b65699beb56 Implement a bit of astring
unc0rr
parents: 9962
diff changeset
    30
            unsigned char _dummy2;
10128
0f6878b5395a Implement needed rtl functions
unc0rr
parents: 10127
diff changeset
    31
            unsigned char s[MAX_ANSISTRING_LENGTH + 1];
10121
8b65699beb56 Implement a bit of astring
unc0rr
parents: 9962
diff changeset
    32
        };
8b65699beb56 Implement a bit of astring
unc0rr
parents: 9962
diff changeset
    33
        struct {
10131
4b4a043111f4 - pas2c recognizes typecasts in initialization expressions
unc0rr
parents: 10128
diff changeset
    34
            unsigned char _dummy1;
4b4a043111f4 - pas2c recognizes typecasts in initialization expressions
unc0rr
parents: 10128
diff changeset
    35
            string255 str255;
10121
8b65699beb56 Implement a bit of astring
unc0rr
parents: 9962
diff changeset
    36
        };
8b65699beb56 Implement a bit of astring
unc0rr
parents: 9962
diff changeset
    37
    } astring;
7989
7ef4ace6335f add xymeng's pas2c header
koda
parents:
diff changeset
    38
7ef4ace6335f add xymeng's pas2c header
koda
parents:
diff changeset
    39
typedef string255 shortstring;
7ef4ace6335f add xymeng's pas2c header
koda
parents:
diff changeset
    40
7ef4ace6335f add xymeng's pas2c header
koda
parents:
diff changeset
    41
typedef uint8_t Byte;
7ef4ace6335f add xymeng's pas2c header
koda
parents:
diff changeset
    42
typedef int8_t ShortInt;
7ef4ace6335f add xymeng's pas2c header
koda
parents:
diff changeset
    43
typedef uint16_t Word;
7ef4ace6335f add xymeng's pas2c header
koda
parents:
diff changeset
    44
typedef int16_t SmallInt;
7ef4ace6335f add xymeng's pas2c header
koda
parents:
diff changeset
    45
typedef uint32_t LongWord;
7ef4ace6335f add xymeng's pas2c header
koda
parents:
diff changeset
    46
typedef int32_t LongInt;
7ef4ace6335f add xymeng's pas2c header
koda
parents:
diff changeset
    47
typedef uint64_t QWord;
7ef4ace6335f add xymeng's pas2c header
koda
parents:
diff changeset
    48
typedef int64_t Int64;
7ef4ace6335f add xymeng's pas2c header
koda
parents:
diff changeset
    49
typedef LongWord Cardinal;
7ef4ace6335f add xymeng's pas2c header
koda
parents:
diff changeset
    50
7ef4ace6335f add xymeng's pas2c header
koda
parents:
diff changeset
    51
typedef LongInt Integer;
14185
801dc57371c3 Pas2C: Fix bad C typedefs for Pascal data types Extended and Real
Wuzzy <Wuzzy2@mail.ru>
parents: 13880
diff changeset
    52
typedef long double extended;
801dc57371c3 Pas2C: Fix bad C typedefs for Pascal data types Extended and Real
Wuzzy <Wuzzy2@mail.ru>
parents: 13880
diff changeset
    53
typedef double real;
7989
7ef4ace6335f add xymeng's pas2c header
koda
parents:
diff changeset
    54
typedef float single;
7ef4ace6335f add xymeng's pas2c header
koda
parents:
diff changeset
    55
7ef4ace6335f add xymeng's pas2c header
koda
parents:
diff changeset
    56
typedef bool boolean;
7ef4ace6335f add xymeng's pas2c header
koda
parents:
diff changeset
    57
typedef int LongBool;
7ef4ace6335f add xymeng's pas2c header
koda
parents:
diff changeset
    58
7ef4ace6335f add xymeng's pas2c header
koda
parents:
diff changeset
    59
typedef void * pointer;
7ef4ace6335f add xymeng's pas2c header
koda
parents:
diff changeset
    60
typedef Byte * PByte;
7ef4ace6335f add xymeng's pas2c header
koda
parents:
diff changeset
    61
typedef char * PChar;
7ef4ace6335f add xymeng's pas2c header
koda
parents:
diff changeset
    62
typedef LongInt * PLongInt;
7ef4ace6335f add xymeng's pas2c header
koda
parents:
diff changeset
    63
typedef LongWord * PLongWord;
7ef4ace6335f add xymeng's pas2c header
koda
parents:
diff changeset
    64
typedef Integer * PInteger;
10660
79fa79c77c38 fix size of PtrInt. enable tests for pas2c (all passing now)
sheepluva
parents: 10142
diff changeset
    65
typedef ptrdiff_t PtrInt;
7989
7ef4ace6335f add xymeng's pas2c header
koda
parents:
diff changeset
    66
typedef wchar_t widechar;
7ef4ace6335f add xymeng's pas2c header
koda
parents:
diff changeset
    67
typedef wchar_t* PWideChar;
7ef4ace6335f add xymeng's pas2c header
koda
parents:
diff changeset
    68
typedef char Char;
12103
22bd1099d51f fix pas2c definition of SizeInt
sheepluva
parents: 10660
diff changeset
    69
typedef PtrInt SizeInt;
7989
7ef4ace6335f add xymeng's pas2c header
koda
parents:
diff changeset
    70
typedef char ** PPChar;
7ef4ace6335f add xymeng's pas2c header
koda
parents:
diff changeset
    71
typedef Word* PWord;
7ef4ace6335f add xymeng's pas2c header
koda
parents:
diff changeset
    72
7ef4ace6335f add xymeng's pas2c header
koda
parents:
diff changeset
    73
string255 _strconcat(string255 a, string255 b);
9962
97ed501accc5 oh those signed chars
unc0rr
parents: 8006
diff changeset
    74
string255 _strappend(string255 s, unsigned char c);
97ed501accc5 oh those signed chars
unc0rr
parents: 8006
diff changeset
    75
string255 _strprepend(unsigned char c, string255 s);
97ed501accc5 oh those signed chars
unc0rr
parents: 8006
diff changeset
    76
string255 _chrconcat(unsigned char a, unsigned char b);
7989
7ef4ace6335f add xymeng's pas2c header
koda
parents:
diff changeset
    77
bool _strcompare(string255 a, string255 b);
9962
97ed501accc5 oh those signed chars
unc0rr
parents: 8006
diff changeset
    78
bool _strcomparec(string255 a, unsigned char b);
7989
7ef4ace6335f add xymeng's pas2c header
koda
parents:
diff changeset
    79
bool _strncompare(string255 a, string255 b);
10127
7f29a65aa1e4 It compiles \o/
unc0rr
parents: 10121
diff changeset
    80
bool _strncompareA(astring a, astring b);
7989
7ef4ace6335f add xymeng's pas2c header
koda
parents:
diff changeset
    81
7ef4ace6335f add xymeng's pas2c header
koda
parents:
diff changeset
    82
7ef4ace6335f add xymeng's pas2c header
koda
parents:
diff changeset
    83
#define STRINIT(a) {.len = sizeof(a) - 1, .str = a}
10142
adb804cb2638 Reduce number of warnings in pas2c-generated code
unc0rr
parents: 10131
diff changeset
    84
#define UNUSED(x) (void)(x)
7989
7ef4ace6335f add xymeng's pas2c header
koda
parents:
diff changeset
    85