project_files/hwc/headers/pas2c.h
branchwebgl
changeset 7987 d8122000a79f
parent 7985 259231ebf099
child 7989 7ef4ace6335f
equal deleted inserted replaced
7985:259231ebf099 7987:d8122000a79f
     1 #pragma once
       
     2 
       
     3 #include <stddef.h>
       
     4 #include <stdint.h>
       
     5 #include <stdbool.h>
       
     6 #include <wchar.h>
       
     7 
       
     8 typedef union string255_
       
     9     {
       
    10         struct {
       
    11             char s[256];
       
    12         };
       
    13         struct {
       
    14             char len;
       
    15             char str[255];
       
    16         };
       
    17     } string255;
       
    18 typedef struct string192_
       
    19     {
       
    20         char s[193];
       
    21     } string192;
       
    22 typedef struct string31_
       
    23     {
       
    24         char s[32];
       
    25     } string31;
       
    26 typedef struct string15_
       
    27     {
       
    28         char s[16];
       
    29     } string15;
       
    30 
       
    31 typedef string255 shortstring;
       
    32 typedef string255 ansistring;
       
    33     
       
    34 typedef uint8_t Byte;
       
    35 typedef int8_t ShortInt;
       
    36 typedef uint16_t Word;
       
    37 typedef int16_t SmallInt;
       
    38 typedef uint32_t LongWord;
       
    39 typedef int32_t LongInt;
       
    40 typedef uint64_t QWord;
       
    41 typedef int64_t Int64;
       
    42 typedef LongWord Cardinal;
       
    43 
       
    44 typedef LongInt Integer;
       
    45 typedef float extended;
       
    46 typedef float real;
       
    47 typedef float single;
       
    48 
       
    49 typedef bool boolean;
       
    50 typedef int LongBool;
       
    51 
       
    52 typedef void * pointer;
       
    53 typedef Byte * PByte;
       
    54 typedef char * PChar;
       
    55 typedef LongInt * PLongInt;
       
    56 typedef LongWord * PLongWord;
       
    57 typedef Integer * PInteger;
       
    58 typedef int PtrInt;
       
    59 typedef wchar_t widechar;
       
    60 
       
    61 #define new(a) __new((void **)&a, sizeof(*(a)))
       
    62 void __new(void ** p, int size);
       
    63 #define dispose(a) __dispose(a, sizeof(*(a)))
       
    64 void __dispose(pointer p, int size);
       
    65 
       
    66 void * GetMem(int size);
       
    67 void FreeMem(void * p, int size);
       
    68 
       
    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);
       
    73 string255 _strappend(string255 s, char c);
       
    74 string255 _strprepend(char c, string255 s);
       
    75 string255 _chrconcat(char a, char b);
       
    76 bool _strcompare(string255 a, string255 b);
       
    77 bool _strcomparec(string255 a, char b);
       
    78 bool _strncompare(string255 a, string255 b);
       
    79 char * _pchar(string255 s);
       
    80 string255 pchar2str(char * s);
       
    81 
       
    82 int Length(string255 a);
       
    83 string255 copy(string255 a, int s, int l);
       
    84 string255 delete(string255 a, int s, int l);
       
    85 string255 trim(string255 a);
       
    86 
       
    87 #define STRINIT(a) {.len = sizeof(a) - 1, .str = a}
       
    88 
       
    89 
       
    90 int length_ar(void * a);
       
    91 
       
    92 typedef int file;
       
    93 typedef int TextFile;
       
    94 extern int FileMode;
       
    95 extern int IOResult;
       
    96 extern int stdout;
       
    97 extern int stderr;
       
    98 
       
    99 #define assign(a, b) assign_(&(a), b)
       
   100 void assign_(int * f, string255 fileName);
       
   101 void reset_1(int f, int size);
       
   102 void reset_2(int f, int size);
       
   103 #define BlockRead(a, b, c, d) BlockRead_(a, &(b), c, &(d))
       
   104 void BlockRead_(int f, void * p, int size, int * sizeRead);
       
   105 #define BlockWrite(a, b, c) BlockWrite_(a, &(b), c)
       
   106 void BlockWrite_(int f, void * p, int size);
       
   107 void close(int f);
       
   108 
       
   109 void write(int f, string255 s);
       
   110 void writeLn(int f, string255 s);
       
   111 
       
   112 bool DirectoryExists(string255 dir);
       
   113 bool FileExists(string255 filename);
       
   114 
       
   115 bool odd(int i);
       
   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 
       
   127 void randomize();
       
   128 int random(int max);
       
   129 int abs(int i);
       
   130 double sqr(double n);
       
   131 double sqrt(double n);
       
   132 int trunc(double n);
       
   133 int round(double n);
       
   134 
       
   135 string255 ParamStr(int n);
       
   136 int ParamCount();
       
   137 
       
   138 #define val(a, b, c) _val(a, (LongInt*)&(b), (LongInt*)&(c))
       
   139 void _val(string255 str, LongInt * a, LongInt * c);
       
   140 
       
   141 extern double pi;
       
   142 
       
   143 string255 EnumToStr(int a);
       
   144 string255 ExtractFileName(string255 f);