project_files/hwc/rtl/misc.h
author alfadur
Tue, 19 May 2020 02:25:24 +0300
changeset 15575 a2e78f5907cc
parent 15361 5c0479d0ed5b
permissions -rw-r--r--
improve escapes handling
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10015
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
     1
#ifndef _FPCRTL_MISC_H_
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
     2
#define _FPCRTL_MISC_H_
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
     3
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
     4
#include "pas2c.h"
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
     5
#include <assert.h>
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
     6
#include <stdbool.h>
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
     7
15361
5c0479d0ed5b Remove last vestiges of GLEW
raptor <buckyballreaction@gmail.com>
parents: 14159
diff changeset
     8
#include "GL.h"
10015
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
     9
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    10
#define     VA_NUM_ARGS(...)                        VA_NUM_ARGS_IMPL(__VA_ARGS__, 5,4,3,2,1)
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    11
#define     VA_NUM_ARGS_IMPL(_1,_2,_3,_4,_5,N,...)  N
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    12
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    13
#define     macro_dispatcher(func, ...)             macro_dispatcher_(func, VA_NUM_ARGS(__VA_ARGS__))
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    14
#define     macro_dispatcher_(func, nargs)          macro_dispatcher__(func, nargs)
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    15
#define     macro_dispatcher__(func, nargs)         func ## nargs
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    16
10128
0f6878b5395a Implement needed rtl functions
unc0rr
parents: 10127
diff changeset
    17
//#define     FPCRTL_DEBUG
10015
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    18
14159
0aeea29ef890 Introduce FIX_STRINGA, use it fpcrtl_pos
unc0rr
parents: 10131
diff changeset
    19
#define     FIX_STRING(s)                           do { s.str[s.len == 255 ? 254 : s.len] = 0; } while (0)
0aeea29ef890 Introduce FIX_STRINGA, use it fpcrtl_pos
unc0rr
parents: 10131
diff changeset
    20
#define     FIX_STRINGA(s)                          do { s.str[s.len == MAX_ANSISTRING_LENGTH ? MAX_ANSISTRING_LENGTH - 1 : s.len] = 0; } while (0)
10015
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    21
//#define fpcrtl_check_string(s)     do{ if(strlen((s).str) != (s).len){ \
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    22
//                                        printf("String %s internal inconsistency error. Length should be %d but actually is %d.\n", (s).str, strlen((s).str), (s).len); \
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    23
//                                        assert(0);\
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    24
//                                    }}while(0)
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    25
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    26
void        fpcrtl_assert(int);
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    27
void        fpcrtl_print_trace (void);
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    28
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    29
int         fpcrtl_round(double number);
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    30
void        fpcrtl_printf(const char* format, ...);
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    31
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    32
string255   fpcrtl_make_string(const char* s);
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    33
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    34
string255   fpcrtl_strconcat(string255 str1, string255 str2);
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    35
string255   fpcrtl_strappend(string255 s, char c);
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    36
string255   fpcrtl_strprepend(char c, string255 s);
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    37
string255   fpcrtl_chrconcat(char a, char b);
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    38
10124
aabd1b75d5a3 Even more explicit type conversions and other stuff to help pas2c use ansistrings
unc0rr
parents: 10121
diff changeset
    39
astring     fpcrtl_strconcatA(astring str1, astring str2);
10128
0f6878b5395a Implement needed rtl functions
unc0rr
parents: 10127
diff changeset
    40
astring     fpcrtl_strappendA(astring s, char c);
10124
aabd1b75d5a3 Even more explicit type conversions and other stuff to help pas2c use ansistrings
unc0rr
parents: 10121
diff changeset
    41
10015
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    42
// return true if str1 == str2
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    43
bool        fpcrtl_strcompare(string255 str1, string255 str2);
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    44
bool        fpcrtl_strcomparec(string255 a, char b);
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    45
bool        fpcrtl_strncompare(string255 a, string255 b);
10127
7f29a65aa1e4 It compiles \o/
unc0rr
parents: 10124
diff changeset
    46
bool        fpcrtl_strncompareA(astring a, astring b);
10015
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    47
10128
0f6878b5395a Implement needed rtl functions
unc0rr
parents: 10127
diff changeset
    48
#define     fpcrtl__pchar(s)                    fpcrtl__pchar__vars(&(s))
0f6878b5395a Implement needed rtl functions
unc0rr
parents: 10127
diff changeset
    49
#define     fpcrtl__pcharA(s)                   fpcrtl__pcharA__vars(&(s))
10131
4b4a043111f4 - pas2c recognizes typecasts in initialization expressions
unc0rr
parents: 10129
diff changeset
    50
char*       fpcrtl__pchar__vars(const string255 * s);
10129
cd2a64a1f4aa - Pas2C: make use of 'external' function decorator
unc0rr
parents: 10128
diff changeset
    51
char*       fpcrtl__pcharA__vars(astring * s);
10128
0f6878b5395a Implement needed rtl functions
unc0rr
parents: 10127
diff changeset
    52
string255   fpcrtl_pchar2str(const char *s);
0f6878b5395a Implement needed rtl functions
unc0rr
parents: 10127
diff changeset
    53
astring     fpcrtl_pchar2astr(const char *s);
10131
4b4a043111f4 - pas2c recognizes typecasts in initialization expressions
unc0rr
parents: 10129
diff changeset
    54
astring     fpcrtl_str2astr(const string255 s);
4b4a043111f4 - pas2c recognizes typecasts in initialization expressions
unc0rr
parents: 10129
diff changeset
    55
string255   fpcrtl_astr2str(const astring s);
10015
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    56
#define     fpcrtl_TypeInfo                         sizeof // dummy
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    57
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    58
#endif