author | sheepluva |
Sun, 09 Aug 2015 00:25:35 +0200 | |
changeset 11040 | 3ab93d702fb1 |
parent 10131 | 4b4a043111f4 |
child 14159 | 0aeea29ef890 |
permissions | -rw-r--r-- |
10015 | 1 |
#ifndef _FPCRTL_MISC_H_ |
2 |
#define _FPCRTL_MISC_H_ |
|
3 |
||
4 |
#include "pas2c.h" |
|
5 |
#include <assert.h> |
|
6 |
#include <stdbool.h> |
|
7 |
||
8 |
#ifdef EMSCRIPTEN |
|
9 |
#include <GL/gl.h> |
|
10 |
#else |
|
11 |
#include <GL/glew.h> |
|
12 |
#endif |
|
13 |
||
14 |
#define VA_NUM_ARGS(...) VA_NUM_ARGS_IMPL(__VA_ARGS__, 5,4,3,2,1) |
|
15 |
#define VA_NUM_ARGS_IMPL(_1,_2,_3,_4,_5,N,...) N |
|
16 |
||
17 |
#define macro_dispatcher(func, ...) macro_dispatcher_(func, VA_NUM_ARGS(__VA_ARGS__)) |
|
18 |
#define macro_dispatcher_(func, nargs) macro_dispatcher__(func, nargs) |
|
19 |
#define macro_dispatcher__(func, nargs) func ## nargs |
|
20 |
||
10128 | 21 |
//#define FPCRTL_DEBUG |
10015 | 22 |
|
10128 | 23 |
#define FIX_STRING(s) (s.str[s.len == 255 ? 254 : s.len] = 0) |
10015 | 24 |
//#define fpcrtl_check_string(s) do{ if(strlen((s).str) != (s).len){ \ |
25 |
// printf("String %s internal inconsistency error. Length should be %d but actually is %d.\n", (s).str, strlen((s).str), (s).len); \ |
|
26 |
// assert(0);\ |
|
27 |
// }}while(0) |
|
28 |
||
29 |
void fpcrtl_assert(int); |
|
30 |
void fpcrtl_print_trace (void); |
|
31 |
||
32 |
int fpcrtl_round(double number); |
|
33 |
void fpcrtl_printf(const char* format, ...); |
|
34 |
||
35 |
string255 fpcrtl_make_string(const char* s); |
|
36 |
||
37 |
string255 fpcrtl_strconcat(string255 str1, string255 str2); |
|
38 |
string255 fpcrtl_strappend(string255 s, char c); |
|
39 |
string255 fpcrtl_strprepend(char c, string255 s); |
|
40 |
string255 fpcrtl_chrconcat(char a, char b); |
|
41 |
||
10124
aabd1b75d5a3
Even more explicit type conversions and other stuff to help pas2c use ansistrings
unc0rr
parents:
10121
diff
changeset
|
42 |
astring fpcrtl_strconcatA(astring str1, astring str2); |
10128 | 43 |
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
|
44 |
|
10015 | 45 |
// return true if str1 == str2 |
46 |
bool fpcrtl_strcompare(string255 str1, string255 str2); |
|
47 |
bool fpcrtl_strcomparec(string255 a, char b); |
|
48 |
bool fpcrtl_strncompare(string255 a, string255 b); |
|
10127 | 49 |
bool fpcrtl_strncompareA(astring a, astring b); |
10015 | 50 |
|
10128 | 51 |
#define fpcrtl__pchar(s) fpcrtl__pchar__vars(&(s)) |
52 |
#define fpcrtl__pcharA(s) fpcrtl__pcharA__vars(&(s)) |
|
10131
4b4a043111f4
- pas2c recognizes typecasts in initialization expressions
unc0rr
parents:
10129
diff
changeset
|
53 |
char* fpcrtl__pchar__vars(const string255 * s); |
10129
cd2a64a1f4aa
- Pas2C: make use of 'external' function decorator
unc0rr
parents:
10128
diff
changeset
|
54 |
char* fpcrtl__pcharA__vars(astring * s); |
10128 | 55 |
string255 fpcrtl_pchar2str(const char *s); |
56 |
astring fpcrtl_pchar2astr(const char *s); |
|
10131
4b4a043111f4
- pas2c recognizes typecasts in initialization expressions
unc0rr
parents:
10129
diff
changeset
|
57 |
astring fpcrtl_str2astr(const string255 s); |
4b4a043111f4
- pas2c recognizes typecasts in initialization expressions
unc0rr
parents:
10129
diff
changeset
|
58 |
string255 fpcrtl_astr2str(const astring s); |
10015 | 59 |
#define fpcrtl_TypeInfo sizeof // dummy |
60 |
||
61 |
#ifdef EMSCRIPTEN |
|
62 |
#define GLEW_OK 1 |
|
63 |
GLenum glewInit(); |
|
64 |
#endif |
|
65 |
||
66 |
#endif |