Skip to content
Myr

test_cpp_compilation.cpp

This file

Path

tests/test_cpp_compilation.cpp

232 lines · 9.4 KiB · C++

Last changed by

stb_c_lexer: fix NUL eof test so it compilesSean Barrettbefore adoption84e7a4a

History of this file

Take it

The walk stopped after 200 commits: lines older than 59e9702 point at it.

stb_hexwave added, stretchy_buffer.h deprecatedSean Barrettbefore adoption559d759

lines 1–14why, one step back
1#define STB_IMAGE_WRITE_STATIC
2#define STBIWDEF static inline34#include "stb_image.h"5#include "stb_rect_pack.h"6#include "stb_truetype.h"7#include "stb_image_write.h"8#include "stb_perlin.h"9#include "stb_dxt.h"10#include "stb_divide.h"11#include "stb_herringbone_wang_tile.h"12#include "stb_ds.h"13#include "stb_hexwave.h"14

update readmeSean Barrettbefore adoption59e9702

lines 15–30why, one step back
15#include "stb_sprintf.h"
16#define STB_SPRINTF_IMPLEMENTATION17#include "stb_sprintf.h"181920#define STB_IMAGE_WRITE_IMPLEMENTATION21#define STB_TRUETYPE_IMPLEMENTATION22#define STB_PERLIN_IMPLEMENTATION23#define STB_DXT_IMPLEMENATION24#define STB_C_LEXER_IMPLEMENTATIOn25#define STB_DIVIDE_IMPLEMENTATION26#define STB_IMAGE_IMPLEMENTATION27#define STB_HERRINGBONE_WANG_TILE_IMPLEMENTATION28#define STB_RECT_PACK_IMPLEMENTATION29#define STB_VOXEL_RENDER_IMPLEMENTATION30#define STB_CONNECTED_COMPONENTS_IMPLEMENTATION

stb_hexwave added, stretchy_buffer.h deprecatedSean Barrettbefore adoption559d759

line 31why, one step back
31#define STB_HEXWAVE_IMPLEMENTATION

update tests and project files for stb_dsSean Barrettbefore adoptione704ed0

line 32why, one step back
32#define STB_DS_IMPLEMENTATION

test updates for test_ds unit testingSean Barrettbefore adoption72990ef

line 33why, one step back
33#define STBDS_UNIT_TESTS

update readmeSean Barrettbefore adoption59e9702

lines 34–51why, one step back
34
35#define STBI_MALLOC my_malloc36#define STBI_FREE my_free37#define STBI_REALLOC my_realloc3839void *my_malloc(size_t) { return 0; }40void *my_realloc(void *, size_t) { return 0; }41void my_free(void *) { }4243#include "stb_image.h"44#include "stb_rect_pack.h"45#include "stb_truetype.h"46#include "stb_image_write.h"47#include "stb_perlin.h"48#include "stb_dxt.h"49#include "stb_c_lexer.h"50#include "stb_divide.h"51#include "stb_herringbone_wang_tile.h"

update tests and project files for stb_dsSean Barrettbefore adoptione704ed0

line 52why, one step back
52#include "stb_ds.h"

stb_hexwave added, stretchy_buffer.h deprecatedSean Barrettbefore adoption559d759

line 53why, one step back
53#include "stb_hexwave.h"

update readmeSean Barrettbefore adoption59e9702

lines 54–74why, one step back
54
55#define STBCC_GRID_COUNT_X_LOG2 1056#define STBCC_GRID_COUNT_Y_LOG2 1057#include "stb_connected_components.h"5859#define STBVOX_CONFIG_MODE 160#include "stb_voxel_render.h"6162#define STBTE_DRAW_RECT(x0,y0,x1,y1,color) do ; while(0)63#define STBTE_DRAW_TILE(x,y,id,highlight,data) do ; while(0)64#define STB_TILEMAP_EDITOR_IMPLEMENTATION65#include "stb_tilemap_editor.h"6667#include "stb_easy_font.h"6869#define STB_LEAKCHECK_IMPLEMENTATION70#include "stb_leakcheck.h"7172#define STB_IMAGE_RESIZE_IMPLEMENTATION73#include "stb_image_resize.h"74

Merge branch 'master' into workingSean Barrettbefore adoptiond940053

line 75why, one step back
75//#include "stretchy_buffer.h" // deprecating

update readmeSean Barrettbefore adoption59e9702

lines 76–77why, one step back
76
77

Merge branch 'master' into workingSean Barrettbefore adoptiond940053

lines 78–85why, one step back
78// avoid unused-function complaints
79void dummy2(void)80{81 stb_easy_font_spacing(1.0);82 stb_easy_font_print(0,0,NULL,NULL,NULL,0);83 stb_easy_font_width(NULL);84 stb_easy_font_height(NULL);85}

update readmeSean Barrettbefore adoption59e9702

line 86why, one step back
86

Merge branch 'master' into workingSean Barrettbefore adoptiond940053

line 87why, one step back
87

update readmeSean Barrettbefore adoption59e9702

lines 88–139why, one step back
88////////////////////////////////////////////////////////////
89//90// text edit9192#include <stdlib.h>93#include <string.h> // memmove94#include <ctype.h> // isspace9596#define STB_TEXTEDIT_CHARTYPE char97#define STB_TEXTEDIT_STRING text_control9899// get the base type100#include "stb_textedit.h"101102// define our editor structure103typedef struct104{105 char *string;106 int stringlen;107 STB_TexteditState state;108} text_control;109110// define the functions we need111void layout_func(StbTexteditRow *row, STB_TEXTEDIT_STRING *str, int start_i)112{113 int remaining_chars = str->stringlen - start_i;114 row->num_chars = remaining_chars > 20 ? 20 : remaining_chars; // should do real word wrap here115 row->x0 = 0;116 row->x1 = 20; // need to account for actual size of characters117 row->baseline_y_delta = 1.25;118 row->ymin = -1;119 row->ymax = 0;120}121122int delete_chars(STB_TEXTEDIT_STRING *str, int pos, int num)123{124 memmove(&str->string[pos], &str->string[pos+num], str->stringlen - (pos+num));125 str->stringlen -= num;126 return 1; // always succeeds127}128129int insert_chars(STB_TEXTEDIT_STRING *str, int pos, STB_TEXTEDIT_CHARTYPE *newtext, int num)130{131 str->string = (char *) realloc(str->string, str->stringlen + num);132 memmove(&str->string[pos+num], &str->string[pos], str->stringlen - pos);133 memcpy(&str->string[pos], newtext, num);134 str->stringlen += num;135 return 1; // always succeeds136}137138// define all the #defines needed 139

Merge branch 'master' into workingSean Barrettbefore adoptiond940053

line 140why, one step back
140#define KEYDOWN_BIT 0x40000000

update readmeSean Barrettbefore adoption59e9702

lines 141–151why, one step back
141
142#define STB_TEXTEDIT_STRINGLEN(tc) ((tc)->stringlen)143#define STB_TEXTEDIT_LAYOUTROW layout_func144#define STB_TEXTEDIT_GETWIDTH(tc,n,i) (1) // quick hack for monospaced145#define STB_TEXTEDIT_KEYTOTEXT(key) (((key) & KEYDOWN_BIT) ? 0 : (key))146#define STB_TEXTEDIT_GETCHAR(tc,i) ((tc)->string[i])147#define STB_TEXTEDIT_NEWLINE '\n'148#define STB_TEXTEDIT_IS_SPACE(ch) isspace(ch)149#define STB_TEXTEDIT_DELETECHARS delete_chars150#define STB_TEXTEDIT_INSERTCHARS insert_chars151

Merge branch 'master' into workingSean Barrettbefore adoptiond940053

lines 152–153why, one step back
152#define STB_TEXTEDIT_K_SHIFT 0x20000000
153#define STB_TEXTEDIT_K_CONTROL 0x10000000

update readmeSean Barrettbefore adoption59e9702

lines 154–175why, one step back
154#define STB_TEXTEDIT_K_LEFT (KEYDOWN_BIT | 1) // actually use VK_LEFT, SDLK_LEFT, etc
155#define STB_TEXTEDIT_K_RIGHT (KEYDOWN_BIT | 2) // VK_RIGHT156#define STB_TEXTEDIT_K_UP (KEYDOWN_BIT | 3) // VK_UP157#define STB_TEXTEDIT_K_DOWN (KEYDOWN_BIT | 4) // VK_DOWN158#define STB_TEXTEDIT_K_LINESTART (KEYDOWN_BIT | 5) // VK_HOME159#define STB_TEXTEDIT_K_LINEEND (KEYDOWN_BIT | 6) // VK_END160#define STB_TEXTEDIT_K_TEXTSTART (STB_TEXTEDIT_K_LINESTART | STB_TEXTEDIT_K_CONTROL)161#define STB_TEXTEDIT_K_TEXTEND (STB_TEXTEDIT_K_LINEEND | STB_TEXTEDIT_K_CONTROL)162#define STB_TEXTEDIT_K_DELETE (KEYDOWN_BIT | 7) // VK_DELETE163#define STB_TEXTEDIT_K_BACKSPACE (KEYDOWN_BIT | 8) // VK_BACKSPACE164#define STB_TEXTEDIT_K_UNDO (KEYDOWN_BIT | STB_TEXTEDIT_K_CONTROL | 'z')165#define STB_TEXTEDIT_K_REDO (KEYDOWN_BIT | STB_TEXTEDIT_K_CONTROL | 'y')166#define STB_TEXTEDIT_K_INSERT (KEYDOWN_BIT | 9) // VK_INSERT167#define STB_TEXTEDIT_K_WORDLEFT (STB_TEXTEDIT_K_LEFT | STB_TEXTEDIT_K_CONTROL)168#define STB_TEXTEDIT_K_WORDRIGHT (STB_TEXTEDIT_K_RIGHT | STB_TEXTEDIT_K_CONTROL)169#define STB_TEXTEDIT_K_PGUP (KEYDOWN_BIT | 10) // VK_PGUP -- not implemented170#define STB_TEXTEDIT_K_PGDOWN (KEYDOWN_BIT | 11) // VK_PGDOWN -- not implemented171172#define STB_TEXTEDIT_IMPLEMENTATION173#include "stb_textedit.h"174175

Merge branch 'master' into workingSean Barrettbefore adoptiond940053

lines 176–184why, one step back
176void dummy3(void)
177{178 stb_textedit_click(0,0,0,0);179 stb_textedit_drag(0,0,0,0);180 stb_textedit_cut(0,0);181 stb_textedit_key(0,0,0);182 stb_textedit_initialize_state(0,0);183 stb_textedit_paste(0,0,0,0);184}

stb_c_lexer: fix NUL eof test so it compilesSean Barrettbefore adoption84e7a4a

lines 185–232why, one step back
185
186#define STB_C_LEX_C_DECIMAL_INTS Y // "0|[1-9][0-9]*" CLEX_intlit187#define STB_C_LEX_C_HEX_INTS Y // "0x[0-9a-fA-F]+" CLEX_intlit188#define STB_C_LEX_C_OCTAL_INTS Y // "[0-7]+" CLEX_intlit189#define STB_C_LEX_C_DECIMAL_FLOATS Y // "[0-9]*(.[0-9]*([eE][-+]?[0-9]+)?) CLEX_floatlit190#define STB_C_LEX_C99_HEX_FLOATS N // "0x{hex}+(.{hex}*)?[pP][-+]?{hex}+ CLEX_floatlit191#define STB_C_LEX_C_IDENTIFIERS Y // "[_a-zA-Z][_a-zA-Z0-9]*" CLEX_id192#define STB_C_LEX_C_DQ_STRINGS Y // double-quote-delimited strings with escapes CLEX_dqstring193#define STB_C_LEX_C_SQ_STRINGS N // single-quote-delimited strings with escapes CLEX_ssstring194#define STB_C_LEX_C_CHARS Y // single-quote-delimited character with escape CLEX_charlits195#define STB_C_LEX_C_COMMENTS Y // "/* comment */"196#define STB_C_LEX_CPP_COMMENTS Y // "// comment to end of line\n"197#define STB_C_LEX_C_COMPARISONS Y // "==" CLEX_eq "!=" CLEX_noteq "<=" CLEX_lesseq ">=" CLEX_greatereq198#define STB_C_LEX_C_LOGICAL Y // "&&" CLEX_andand "||" CLEX_oror199#define STB_C_LEX_C_SHIFTS Y // "<<" CLEX_shl ">>" CLEX_shr200#define STB_C_LEX_C_INCREMENTS Y // "++" CLEX_plusplus "--" CLEX_minusminus201#define STB_C_LEX_C_ARROW Y // "->" CLEX_arrow202#define STB_C_LEX_EQUAL_ARROW N // "=>" CLEX_eqarrow203#define STB_C_LEX_C_BITWISEEQ Y // "&=" CLEX_andeq "|=" CLEX_oreq "^=" CLEX_xoreq204#define STB_C_LEX_C_ARITHEQ Y // "+=" CLEX_pluseq "-=" CLEX_minuseq205 // "*=" CLEX_muleq "/=" CLEX_diveq "%=" CLEX_modeq206 // if both STB_C_LEX_SHIFTS & STB_C_LEX_ARITHEQ:207 // "<<=" CLEX_shleq ">>=" CLEX_shreq208209#define STB_C_LEX_PARSE_SUFFIXES N // letters after numbers are parsed as part of those numbers, and must be in suffix list below210#define STB_C_LEX_DECIMAL_SUFFIXES "" // decimal integer suffixes e.g. "uUlL" -- these are returned as-is in string storage211#define STB_C_LEX_HEX_SUFFIXES "" // e.g. "uUlL"212#define STB_C_LEX_OCTAL_SUFFIXES "" // e.g. "uUlL"213#define STB_C_LEX_FLOAT_SUFFIXES "" //214215#define STB_C_LEX_0_IS_EOF Y // if Y, ends parsing at '\0'; if N, returns '\0' as token216#define STB_C_LEX_INTEGERS_AS_DOUBLES N // parses integers as doubles so they can be larger than 'int', but only if STB_C_LEX_STDLIB==N217#define STB_C_LEX_MULTILINE_DSTRINGS N // allow newlines in double-quoted strings218#define STB_C_LEX_MULTILINE_SSTRINGS N // allow newlines in single-quoted strings219#define STB_C_LEX_USE_STDLIB Y // use strtod,strtol for parsing #s; otherwise inaccurate hack220#define STB_C_LEX_DOLLAR_IDENTIFIER Y // allow $ as an identifier character221#define STB_C_LEX_FLOAT_NO_DECIMAL Y // allow floats that have no decimal point if they have an exponent222223#define STB_C_LEX_DEFINE_ALL_TOKEN_NAMES N // if Y, all CLEX_ token names are defined, even if never returned224 // leaving it as N should help you catch config bugs225226#define STB_C_LEX_DISCARD_PREPROCESSOR Y // discard C-preprocessor directives (e.g. after prepocess227 // still have #line, #pragma, etc)228229//#define STB_C_LEX_ISWHITE(str) ... // return length in bytes of whitespace characters if first char is whitespace230231#define STB_C_LEXER_DEFINITIONS // This line prevents the header file from replacing your definitions232#include "stb_c_lexer.h"