| 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 |
#include "GL.h" |
| 9 |
|
| 10 |
#define VA_NUM_ARGS(...) VA_NUM_ARGS_IMPL(__VA_ARGS__, 5,4,3,2,1) |
| 11 |
#define VA_NUM_ARGS_IMPL(_1,_2,_3,_4,_5,N,...) N |
| 12 |
|
| 13 |
#define macro_dispatcher(func, ...) macro_dispatcher_(func, VA_NUM_ARGS(__VA_ARGS__)) |
| 14 |
#define macro_dispatcher_(func, nargs) macro_dispatcher__(func, nargs) |
| 15 |
#define macro_dispatcher__(func, nargs) func ## nargs |
| 16 |
|
| 17 |
//#define FPCRTL_DEBUG |
| 18 |
|
| 19 |
#define FIX_STRING(s) do { s.str[s.len == 255 ? 254 : s.len] = 0; } while (0) |
| 20 |
#define FIX_STRINGA(s) do { s.str[s.len == MAX_ANSISTRING_LENGTH ? MAX_ANSISTRING_LENGTH - 1 : s.len] = 0; } while (0) |
| 21 |
//#define fpcrtl_check_string(s) do{ if(strlen((s).str) != (s).len){ \ |
| 22 |
// printf("String %s internal inconsistency error. Length should be %d but actually is %d.\n", (s).str, strlen((s).str), (s).len); \ |
| 23 |
// assert(0);\ |
| 24 |
// }}while(0) |
| 25 |
|
| 26 |
void fpcrtl_assert(int); |
| 27 |
void fpcrtl_print_trace (void); |
| 28 |
|
| 29 |
int fpcrtl_round(double number); |
| 30 |
void fpcrtl_printf(const char* format, ...); |
| 31 |
|
| 32 |
string255 fpcrtl_make_string(const char* s); |
| 33 |
|
| 34 |
string255 fpcrtl_strconcat(string255 str1, string255 str2); |
| 35 |
string255 fpcrtl_strappend(string255 s, char c); |
| 36 |
string255 fpcrtl_strprepend(char c, string255 s); |
| 37 |
string255 fpcrtl_chrconcat(char a, char b); |
| 38 |
|
| 39 |
astring fpcrtl_strconcatA(astring str1, astring str2); |
| 40 |
astring fpcrtl_strappendA(astring s, char c); |
| 41 |
|
| 42 |
// return true if str1 == str2 |
| 43 |
bool fpcrtl_strcompare(string255 str1, string255 str2); |
| 44 |
bool fpcrtl_strcomparec(string255 a, char b); |
| 45 |
bool fpcrtl_strncompare(string255 a, string255 b); |
| 46 |
bool fpcrtl_strncompareA(astring a, astring b); |
| 47 |
|
| 48 |
#define fpcrtl__pchar(s) fpcrtl__pchar__vars(&(s)) |
| 49 |
#define fpcrtl__pcharA(s) fpcrtl__pcharA__vars(&(s)) |
| 50 |
char* fpcrtl__pchar__vars(const string255 * s); |
| 51 |
char* fpcrtl__pcharA__vars(astring * s); |
| 52 |
string255 fpcrtl_pchar2str(const char *s); |
| 53 |
astring fpcrtl_pchar2astr(const char *s); |
| 54 |
astring fpcrtl_str2astr(const string255 s); |
| 55 |
string255 fpcrtl_astr2str(const astring s); |
| 56 |
#define fpcrtl_TypeInfo sizeof // dummy |
| 57 |
|
| 58 |
#endif |