hedgewars/pas2c.h
changeset 7186 013deb83086b
parent 7151 ec15d9e1a7e3
equal deleted inserted replaced
7138:f8248bcba8f1 7186:013deb83086b
     1 #pragma once
     1 #pragma once
     2 
     2 
       
     3 #include <stddef.h>
     3 #include <stdint.h>
     4 #include <stdint.h>
     4 #include <stdbool.h>
     5 #include <stdbool.h>
     5 #include <wchar.h>
     6 #include <wchar.h>
     6 
     7 
     7 typedef union string255_
     8 typedef union string255_
    26     {
    27     {
    27         char s[16];
    28         char s[16];
    28     } string15;
    29     } string15;
    29 
    30 
    30 typedef string255 shortstring;
    31 typedef string255 shortstring;
       
    32 typedef string255 ansistring;
    31     
    33     
    32 typedef uint8_t Byte;
    34 typedef uint8_t Byte;
    33 typedef int8_t ShortInt;
    35 typedef int8_t ShortInt;
    34 typedef uint16_t Word;
    36 typedef uint16_t Word;
    35 typedef int16_t SmallInt;
    37 typedef int16_t SmallInt;
    54 typedef LongWord * PLongWord;
    56 typedef LongWord * PLongWord;
    55 typedef Integer * PInteger;
    57 typedef Integer * PInteger;
    56 typedef int PtrInt;
    58 typedef int PtrInt;
    57 typedef wchar_t widechar;
    59 typedef wchar_t widechar;
    58 
    60 
    59 #ifdef __GNUG__
       
    60 #define NULL __null
       
    61 #else   /* G++ */
       
    62 /* shield NULL definition for non-gnu parsers */
       
    63 #ifndef __cplusplus
       
    64 #define NULL ((void *)0)
       
    65 #else
       
    66 #define NULL 0
       
    67 #endif  /* __cplusplus */
       
    68 #endif  /* G++ */
       
    69 
       
    70 #define new(a) __new((void **)&a, sizeof(*(a)))
    61 #define new(a) __new((void **)&a, sizeof(*(a)))
    71 void __new(void ** p, int size);
    62 void __new(void ** p, int size);
    72 #define dispose(a) __dispose(a, sizeof(*(a)))
    63 #define dispose(a) __dispose(a, sizeof(*(a)))
    73 void __dispose(pointer p, int size);
    64 void __dispose(pointer p, int size);
    74 
    65 
    79 
    70 
    80 void __FillChar(pointer p, int size, char fill);
    71 void __FillChar(pointer p, int size, char fill);
    81 string255 _strconcat(string255 a, string255 b);
    72 string255 _strconcat(string255 a, string255 b);
    82 string255 _strappend(string255 s, char c);
    73 string255 _strappend(string255 s, char c);
    83 string255 _strprepend(char c, string255 s);
    74 string255 _strprepend(char c, string255 s);
       
    75 string255 _chrconcat(char a, char b);
    84 bool _strcompare(string255 a, string255 b);
    76 bool _strcompare(string255 a, string255 b);
    85 bool _strcomparec(string255 a, char b);
    77 bool _strcomparec(string255 a, char b);
    86 bool _strncompare(string255 a, string255 b);
    78 bool _strncompare(string255 a, string255 b);
    87 char * _pchar(string255 s);
    79 char * _pchar(string255 s);
       
    80 string255 pchar2str(char * s);
    88 
    81 
    89 int Length(string255 a);
    82 int Length(string255 a);
    90 string255 copy(string255 a, int s, int l);
    83 string255 copy(string255 a, int s, int l);
    91 string255 delete(string255 a, int s, int l);
    84 string255 delete(string255 a, int s, int l);
    92 string255 trim(string255 a);
    85 string255 trim(string255 a);
    98 
    91 
    99 typedef int file;
    92 typedef int file;
   100 typedef int TextFile;
    93 typedef int TextFile;
   101 extern int FileMode;
    94 extern int FileMode;
   102 extern int IOResult;
    95 extern int IOResult;
       
    96 extern int stdout;
   103 extern int stderr;
    97 extern int stderr;
   104 
    98 
   105 #define assign(a, b) assign_(&(a), b)
    99 #define assign(a, b) assign_(&(a), b)
   106 void assign_(int * f, string255 fileName);
   100 void assign_(int * f, string255 fileName);
   107 void reset_1(int f, int size);
   101 void reset_1(int f, int size);
   110 void BlockRead_(int f, void * p, int size, int * sizeRead);
   104 void BlockRead_(int f, void * p, int size, int * sizeRead);
   111 #define BlockWrite(a, b, c) BlockWrite_(a, &(b), c)
   105 #define BlockWrite(a, b, c) BlockWrite_(a, &(b), c)
   112 void BlockWrite_(int f, void * p, int size);
   106 void BlockWrite_(int f, void * p, int size);
   113 void close(int f);
   107 void close(int f);
   114 
   108 
   115 void write(string255 s);
   109 void write(int f, string255 s);
       
   110 void writeLn(int f, string255 s);
   116 
   111 
   117 bool DirectoryExists(string255 dir);
   112 bool DirectoryExists(string255 dir);
   118 bool FileExists(string255 filename);
   113 bool FileExists(string255 filename);
   119 
   114 
   120 bool odd(int i);
   115 bool odd(int i);
   138 int round(double n);
   133 int round(double n);
   139 
   134 
   140 string255 ParamStr(int n);
   135 string255 ParamStr(int n);
   141 int ParamCount();
   136 int ParamCount();
   142 
   137 
   143 #define val(a, b) _val(a, (LongInt*)&(b))
   138 #define val(a, b, c) _val(a, (LongInt*)&(b), (LongInt*)&(c))
   144 void _val(string255 str, LongInt * a);
   139 void _val(string255 str, LongInt * a, LongInt * c);
   145 
   140 
   146 extern double pi;
   141 extern double pi;
   147 
   142 
   148 string255 EnumToStr(int a);
   143 string255 EnumToStr(int a);
   149 string255 ExtractFileName(string255 f);
   144 string255 ExtractFileName(string255 f);