[examples] tweaks to overrides example and commentary

This commit is contained in:
Allen Webster
2021-10-09 22:34:41 -07:00
parent 126fab22df
commit b67dc566c6
5 changed files with 35 additions and 21 deletions
+3 -5
View File
@@ -11,11 +11,6 @@ bin/bld_core.sh show_ctx
examps="examples"
bin/bld_core.sh unit expr_intro $examps/expr/expr_intro.c
bin/bld_core.sh unit expr_c_like $examps/expr/expr_c_like.c
exit
bin/bld_core.sh unit hello_world $examps/intro/hello_world.c
bin/bld_core.sh unit parse_check $examps/intro/parse_check.c
bin/bld_core.sh unit data_desk_like $examps/intro/data_desk_like_template.c
@@ -26,6 +21,9 @@ if [ -d $examps/type_metadata/generated/type_info_meta.h ]; then
bin/bld_core.sh unit type_info $examps/type_metadata/type_info_final_program.c
fi
bin/bld_core.sh unit expr_intro $examps/expr/expr_intro.c
bin/bld_core.sh unit expr_c_like $examps/expr/expr_c_like.c
bin/bld_core.sh unit overrides $examps/integration/overrides.c
echo
+8 -10
View File
@@ -8,16 +8,6 @@ root_path=$PWD
build_path=$root_path/build
examps=$root_path/examples
echo ~~~ Running Expression Intro ~~~
$build_path/expr_intro.exe $examps/expr/expr_intro.mdesk
echo
echo ~~~ Running C Like Expression ~~~
$build_path/expr_c_like.exe $examps/expr/expr_c_like.mdesk
echo
exit
echo ~~~ Running Type Metadata Generator Example ~~~
cd $examps/type_metadata/generated
$build_path/type_metadata.exe $examps/type_metadata/types.mdesk
@@ -26,5 +16,13 @@ echo
echo ~~~ Running Error Generation Example ~~~
$build_path/user_errors.exe $examps/user_errors/user_errors.mdesk
echo ~~~ Running Expression Intro ~~~
$build_path/expr_intro.exe $examps/expr/expr_intro.mdesk
echo
echo ~~~ Running C Like Expression ~~~
$build_path/expr_c_like.exe $examps/expr/expr_c_like.mdesk
echo
###### Restore Path ###########################################################
cd $og_path
+1 -1
View File
@@ -11,4 +11,4 @@ c: 3;
w: 100;
x: a;
y: b + w*a;
z: (c + w*(b + w*a));
z: c + w*b + w*w*a;
+22 -4
View File
@@ -40,11 +40,24 @@ void examp_free(ExampleAllocator *a, void *ptr);
//~ include metadesk header ///////////////////////////////////////////////////
// @notes Disabling print helpers removes any APIs from the library that depend
// on FILE from stdio.h.
#define MD_DISABLE_PRINT_HELPERS 1
// @notes Here is also a good place to disable the default implementations of
// anything that is overriden to avoid extra includes.
#define MD_DEFAULT_MEMORY 0
#define MD_DEFAULT_FILE_LOAD 0
// @notes We can also disable default implementations for "optional" parts,
// here we disable the default file iterator without replacing it, which gets
// this example off of direct OS header dependencies.
#define MD_DEFAULT_FILE_ITER 0
// @notes We include the metadesk header before we define the overrides because
// some overrides require that metadesk base types be visible. There are
// exceptions to this pattern, in particular overrides for types need to be
// defined before including md.h, we aren't going that far here.
#include "md.h"
@@ -126,6 +139,8 @@ md_release_by_example_allocator(void *ptr, unsigned long long ignore)
// override file loading
#include <stdio.h>
MD_String8
md_load_entire_file_by_stdio(MD_Arena *arena, MD_String8 filename)
{
@@ -151,16 +166,19 @@ md_load_entire_file_by_stdio(MD_Arena *arena, MD_String8 filename)
int main(int argc, char **argv)
{
// ... where ever program init stuff is happening ...
// initialize the example allocator
ExampleAllocator allocator = {0};
// configure the allocator context
// metadesk allocator context gets setup before a call to MD_ArenaAlloc
md_example_allocator = &allocator;
// setup the global arena
arena = MD_ArenaAlloc();
// ... any normal metadesk usage may go here ...
// ... any normal metadesk usage may now happen ...
return 0;
+1 -1
View File
@@ -127,7 +127,7 @@ MD_CRT_LoadEntireFile(MD_Arena *arena, MD_String8 filename)
////////////////////////////////////////////////////////////////////////////////
//- win32 header
#if (MD_DEFAULT_FILE_ITER || MD_DEFAULT_MEMORY) && MD_OS_WINDOWS
#if (MD_DEFAULT_FILE_ITER || MD_2DEFAULT_MEMORY) && MD_OS_WINDOWS
# include <Windows.h>
# pragma comment(lib, "User32.lib")
#endif