project_files/hwc/rtl/misc.h
author unc0rr
Fri, 07 Feb 2014 22:42:57 +0400
changeset 10121 8b65699beb56
parent 10015 4feced261c68
child 10124 aabd1b75d5a3
permissions -rw-r--r--
Implement a bit of astring
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
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
     8
#ifdef EMSCRIPTEN
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
     9
#include <GL/gl.h>
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    10
#else
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    11
#include <GL/glew.h>
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    12
#endif
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    13
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    14
#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
    15
#define     VA_NUM_ARGS_IMPL(_1,_2,_3,_4,_5,N,...)  N
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    16
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    17
#define     macro_dispatcher(func, ...)             macro_dispatcher_(func, VA_NUM_ARGS(__VA_ARGS__))
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    18
#define     macro_dispatcher_(func, nargs)          macro_dispatcher__(func, nargs)
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    19
#define     macro_dispatcher__(func, nargs)         func ## nargs
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    20
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    21
#define     FPCRTL_DEBUG
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    22
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    23
#define     FIX_STRING(s)                           (s.str[s.len] = 0)
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    24
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    25
//#define fpcrtl_check_string(s)     do{ if(strlen((s).str) != (s).len){ \
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    26
//                                        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
    27
//                                        assert(0);\
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    28
//                                    }}while(0)
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    29
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    30
void        fpcrtl_assert(int);
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    31
void        fpcrtl_print_trace (void);
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    32
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    33
int         fpcrtl_round(double number);
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    34
void        fpcrtl_printf(const char* format, ...);
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    35
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    36
string255   fpcrtl_make_string(const char* s);
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    37
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    38
string255   fpcrtl_strconcat(string255 str1, string255 str2);
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    39
string255   fpcrtl_strappend(string255 s, char c);
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    40
string255   fpcrtl_strprepend(char c, string255 s);
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    41
string255   fpcrtl_chrconcat(char a, char b);
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    42
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    43
// return true if str1 == str2
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    44
bool        fpcrtl_strcompare(string255 str1, string255 str2);
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    45
bool        fpcrtl_strcomparec(string255 a, char b);
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    46
bool        fpcrtl_strncompare(string255 a, string255 b);
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    47
10121
8b65699beb56 Implement a bit of astring
unc0rr
parents: 10015
diff changeset
    48
char*       fpcrtl__pchar(string255 s);
10015
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    49
string255   fpcrtl_pchar2str(char *s);
10121
8b65699beb56 Implement a bit of astring
unc0rr
parents: 10015
diff changeset
    50
astring     fpcrtl_str2astr(string255 s);
10015
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    51
#define     fpcrtl_TypeInfo                         sizeof // dummy
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    52
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    53
#ifdef EMSCRIPTEN
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    54
#define     GLEW_OK                                 1
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    55
GLenum      glewInit();
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    56
#endif
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