├── .gitattributes ├── .gitignore ├── .gitmodules ├── .travis.yml ├── AUTHORS ├── CHANGELOG ├── CODE_OF_CONDUCT ├── CONTRIBUTING ├── Doxyfile ├── LICENSE ├── NOTES.md ├── README.md ├── STYLE ├── TODO.md ├── VERSION ├── _build ├── build.h ├── build_engine_debug_windows_32.bat ├── build_engine_debug_windows_64.bat ├── build_resource_compiler_debug_windows_32.bat ├── build_resource_compiler_debug_windows_64.bat ├── build_runtime_debug_windows_32.bat ├── build_runtime_debug_windows_64.bat ├── info.bat └── scripts │ ├── 7z.bat │ ├── download.ps1 │ ├── git.bat │ ├── manifest.bat │ ├── revision.bat │ ├── sign.bat │ ├── unity.bat │ ├── vc.bat │ └── version.bat ├── _deps └── .gitignore ├── _rel └── .gitignore ├── appveyor.yml ├── include ├── yeti.h └── yeti │ ├── application.h │ ├── application │ ├── console.h │ ├── settings.h │ └── time_step_policy.h │ ├── audio.h │ ├── color.h │ ├── component.h │ ├── components │ ├── camera.h │ ├── decal.h │ ├── effect.h │ ├── fluid.h │ ├── light.h │ ├── mesh.h │ ├── scatter.h │ ├── tag.h │ ├── terrain.h │ └── transform.h │ ├── config.h │ ├── core.h │ ├── core │ ├── algorithms │ │ ├── digest.h │ │ ├── hash.h │ │ └── random.h │ ├── allocator.h │ ├── allocators │ │ ├── buddy_allocator.h │ │ ├── bump_allocator.h │ │ ├── global_heap_allocator.h │ │ ├── global_page_allocator.h │ │ ├── proxy_allocator.h │ │ └── thread_safe │ │ │ ├── bump_allocator.h │ │ │ └── scratch_allocator.h │ ├── atomics.h │ ├── bits.h │ ├── containers │ │ ├── array.h │ │ ├── dequeue.h │ │ ├── list.h │ │ ├── map.h │ │ ├── queue.h │ │ └── stack.h │ ├── debug │ │ ├── abi.h │ │ ├── assert.h │ │ ├── demangle.h │ │ ├── errors.h │ │ ├── handler.h │ │ ├── registers.h │ │ └── stacktrace.h │ ├── fp.h │ ├── log.h │ ├── log │ │ ├── console.h │ │ ├── file.h │ │ └── network.h │ ├── memory.h │ ├── misc │ │ ├── ini.h │ │ ├── json.h │ │ ├── pattern_file_parser.h │ │ ├── uuid.h │ │ └── xml.h │ ├── network │ │ ├── dns.h │ │ ├── http.h │ │ └── sockets.h │ ├── platform │ │ ├── entropy.h │ │ ├── environment.h │ │ ├── event.h │ │ ├── filesystem.h │ │ ├── info.h │ │ ├── lock.h │ │ ├── path.h │ │ ├── process.h │ │ ├── processor.h │ │ ├── reader_writer_lock.h │ │ ├── thread.h │ │ └── timer.h │ ├── support.h │ ├── support │ │ ├── inlining.h │ │ ├── likeliness.h │ │ ├── macro.h │ │ ├── prefetch.h │ │ ├── reachability.h │ │ ├── rule_of_three.h │ │ ├── stack.h │ │ ├── strings.h │ │ ├── thread_local_storage.h │ │ └── usage.h │ ├── types.h │ └── utilities.h │ ├── entity.h │ ├── input.h │ ├── input │ ├── feeder.h │ ├── gamepad.h │ ├── joystick.h │ ├── keyboard.h │ ├── keys.inl │ ├── mouse.h │ ├── tablet.h │ └── touchscreen.h │ ├── kludge.h │ ├── level.h │ ├── linkage.h │ ├── math.h │ ├── math │ ├── aabb.h │ ├── constants.h │ ├── conversions.h │ ├── frustum.h │ ├── line.h │ ├── mat4.h │ ├── plane.h │ ├── quaternion.h │ ├── ray.h │ ├── sphere.h │ ├── vec2.h │ ├── vec3.h │ └── vec4.h │ ├── optimized_resource_database.h │ ├── physics │ └── raycast.h │ ├── resource.h │ ├── resource_bundle.h │ ├── resource_compiler.h │ ├── resource_database.h │ ├── resource_manager.h │ ├── resource_package.h │ ├── resources │ ├── data_resource.h │ ├── decal_resource.h │ ├── effect_resource.h │ ├── entity_resource.h │ ├── level_resource.h │ ├── material_resource.h │ ├── mesh_resource.h │ ├── prefab_resource.h │ ├── render_config_resource.h │ ├── script_resource.h │ ├── shader_resource.h │ └── texture_resource.h │ ├── script.h │ ├── script │ ├── binding.h │ ├── bindings │ │ ├── application_if.h │ │ ├── camera_if.h │ │ ├── component_if.h │ │ ├── entity_if.h │ │ ├── keyboard_if.h │ │ ├── light_if.h │ │ ├── math_if.h │ │ ├── mouse_if.h │ │ ├── transform_if.h │ │ ├── viewport_if.h │ │ ├── window_if.h │ │ └── world_if.h │ └── environment.h │ ├── sophisticated_resource_database.h │ ├── system.h │ ├── task.h │ ├── task_scheduler.h │ ├── window.h │ └── world.h ├── runtime ├── include │ └── yeti │ │ └── runtime │ │ ├── manifest.h │ │ └── standard_application.h └── src │ ├── runtime.cc │ └── yeti │ └── runtime │ ├── manifest.cc │ └── standard_application.cc ├── src ├── yeti.cc └── yeti │ ├── application.cc │ ├── application │ └── time_step_policy.cc │ ├── color.cc │ ├── component.cc │ ├── components │ ├── camera.cc │ ├── decal.cc │ ├── effect.cc │ ├── fluid.cc │ ├── light.cc │ ├── mesh.cc │ ├── scatter.cc │ ├── tag.cc │ ├── terrain.cc │ └── transform.cc │ ├── core │ ├── algorithms │ │ ├── digest.cc │ │ ├── hash.cc │ │ └── random.cc │ ├── allocator.cc │ ├── allocators │ │ ├── buddy_allocator.cc │ │ ├── bump_allocator.cc │ │ ├── global_heap_allocator.cc │ │ ├── global_page_allocator.cc │ │ ├── proxy_allocator.cc │ │ └── thread_safe │ │ │ ├── bump_allocator.cc │ │ │ └── scratch_allocator.cc │ ├── debug │ │ └── assert.cc │ ├── log.cc │ ├── log │ │ ├── console.cc │ │ ├── file.cc │ │ └── network.cc │ ├── misc │ │ ├── ini.cc │ │ ├── pattern_file_parser.cc │ │ ├── uuid.cc │ │ └── xml.cc │ ├── platform │ │ ├── entropy.cc │ │ ├── event.cc │ │ ├── filesystem.cc │ │ ├── lock.cc │ │ ├── path.cc │ │ ├── process.cc │ │ ├── reader_writer_lock.cc │ │ ├── thread.cc │ │ └── timer.cc │ └── support │ │ └── strings.cc │ ├── entity.cc │ ├── input │ ├── feeder.cc │ ├── keyboard.cc │ └── mouse.cc │ ├── level.cc │ ├── math.cc │ ├── math │ ├── mat4.cc │ ├── quaternion.cc │ ├── vec2.cc │ ├── vec3.cc │ └── vec4.cc │ ├── optimized_resource_database.cc │ ├── resource.cc │ ├── resource_bundle.cc │ ├── resource_compiler.cc │ ├── resource_database.cc │ ├── resource_manager.cc │ ├── resource_package.cc │ ├── resources │ ├── entity_cache.cc │ ├── entity_cache.h │ ├── entity_compiler.cc │ ├── entity_compiler.h │ ├── entity_resource.cc │ ├── entity_resource_format.h │ ├── geometry_compiler.cc │ ├── geometry_compiler.h │ ├── level_compiler.cc │ ├── level_compiler.h │ ├── level_format.h │ ├── level_resource.cc │ ├── mesh_resource.cc │ ├── prefab_resource.cc │ ├── render_config_compiler.cc │ ├── render_config_compiler.h │ ├── render_config_compiler_helpers.cc │ ├── render_config_compiler_helpers.h │ ├── render_config_format.h │ ├── render_config_resource.cc │ ├── script_compiler.cc │ ├── script_compiler.h │ ├── script_resource.cc │ ├── texture_compiler.cc │ ├── texture_compiler.h │ ├── texture_format.h │ └── texture_resource.cc │ ├── script.cc │ ├── script │ ├── bindings │ │ ├── application_if.cc │ │ ├── camera_if.cc │ │ ├── component_if.cc │ │ ├── decal_if.cc │ │ ├── dlc_if.cc │ │ ├── entity_if.cc │ │ ├── fluid_if.cc │ │ ├── gamepad_if.cc │ │ ├── http_if.cc │ │ ├── joystick_if.cc │ │ ├── keyboard_if.cc │ │ ├── level_if.cc │ │ ├── light_if.cc │ │ ├── material_if.cc │ │ ├── math_if.cc │ │ ├── mesh_if.cc │ │ ├── mouse_if.cc │ │ ├── prefab_if.cc │ │ ├── profiler_if.cc │ │ ├── resource_if.cc │ │ ├── resource_package_if.cc │ │ ├── save_if.cc │ │ ├── scatter_if.cc │ │ ├── settings_if.cc │ │ ├── spline_if.cc │ │ ├── tablet_if.cc │ │ ├── tag_if.cc │ │ ├── terrain_if.cc │ │ ├── touchscreen_if.cc │ │ ├── transform_if.cc │ │ ├── viewport_if.cc │ │ ├── window_if.cc │ │ └── world_if.cc │ └── environment.cc │ ├── sophisticated_resource_database.cc │ ├── system.cc │ ├── task.cc │ ├── task_scheduler.cc │ ├── window.cc │ ├── window.m │ └── world.cc ├── tools └── resource_compiler │ ├── include │ └── yeti │ │ └── resource_compiler │ │ └── runner.h │ └── src │ └── yeti │ ├── resource_compiler.cc │ └── resource_compiler │ └── runner.cc └── yeti.sublime-project /.gitattributes: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/.gitattributes -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore Sublime Text 2/3 junk. 2 | *.sublime-workspace 3 | 4 | # Ignore automatically fetched tools. 5 | _build/tools/cache 6 | 7 | # Ingore build intermediates. 8 | _build/*.cc 9 | 10 | # Ingore build artifacts. 11 | _build/**/*.exe 12 | _build/**/*.pdb 13 | _build/**/*.obj 14 | _build/**/*.ilk 15 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "_deps/luajit"] 2 | path = _deps/luajit 3 | url = git@github.com:origamicomet/luajit.git 4 | [submodule "_deps/sqlite3"] 5 | path = _deps/sqlite3 6 | url = git@github.com:origamicomet/sqlite3.git 7 | [submodule "_deps/gala"] 8 | path = _deps/gala 9 | url = git@github.com:origamicomet/gala.git 10 | [submodule "_deps/loom"] 11 | path = _deps/loom 12 | url = git@github.com:origamicomet/loom.git 13 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/.travis.yml -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Michael Williams 2 | Jason Kozak 3 | -------------------------------------------------------------------------------- /CHANGELOG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/CHANGELOG -------------------------------------------------------------------------------- /CODE_OF_CONDUCT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/CODE_OF_CONDUCT -------------------------------------------------------------------------------- /CONTRIBUTING: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/CONTRIBUTING -------------------------------------------------------------------------------- /Doxyfile: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/Doxyfile -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/LICENSE -------------------------------------------------------------------------------- /NOTES.md: -------------------------------------------------------------------------------- 1 | # Building 2 | 3 | ## Windows 4 | 5 | ryb generate ninja --toolchain=vs@latest 6 | 7 | ## Mac 8 | 9 | Until `ryb` is extended to support Mac. 10 | 11 | # We'll reuse the preprocessor to do depedency resolution... 12 | rm -r _build 13 | mkdir -p _build/unity 14 | find ./src -type f -name "*.cc" | sed 's/\(.*\)/#include "\1"/g' > _build/unity/yeti 15 | find ./runtime -type f -name "*.cc" | sed 's/\(.*\)/#include "\1"/g' > _build/unity/runtime 16 | find ./tools -type f -name "*.cc" | sed 's/\(.*\)/#include "\1"/g' > _build/unity/tools 17 | 18 | # Running 19 | 20 | ## Mac 21 | 22 | Unfortunately `DYLD_LIBRARY_PATH` is not respected when System Integrety Protection is enabled, as of El Capitan. So you'll need to copy dynamically linked dependencies into `_build/bin` prior to running Yeti et al. 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 |

4 | 5 |

6 | :snowman: A general-purpose data-driven game engine with tools. 7 |

8 | 9 |

10 | 11 | Build Status for Windows 12 | 13 | 14 | 15 | Build Status for Mac & Linux 16 | 17 | 18 | 19 | Downloads 20 | 21 | 22 |
23 | 24 | 25 | Latest Release 26 | 27 | 28 | 29 | License 30 | 31 |

32 | 33 | ## Intro 34 | 35 | Yeti is a completely open-source game engine (with tools) that's not too dissimilar from [Autodesk Stingray](http://www.autodesk.com/products/stingray/overview) (née Bitsquid). It's part of a larger vision of having high-quality, open-source software made available for making games. It's far from complete... but with some luck and a lot of work, it will be ready for production use in the near future. 36 | 37 | ## Questions 38 | 39 | For questions, please [email me](mailto:mike@origamicomet.com). The issue tracker of this repository is exclusively for bugs, feature requests, and very occasional meta discussions. 40 | 41 | ## Contributing 42 | 43 | Thoroughly read our [contributing guide](https://github.com/origamicomet/yeti/blob/master/CONTRIBUTING) before opening a pull request. 44 | 45 | ## Changelog 46 | 47 | A detailed changelog for every release will be maintained, but just gets in the way for now. 48 | 49 | ## License 50 | 51 | Essentially a zlib license with stipulations made for attribution (i.e. a splash screen). 52 | -------------------------------------------------------------------------------- /STYLE: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/STYLE -------------------------------------------------------------------------------- /VERSION: -------------------------------------------------------------------------------- 1 | 0.0.0 2 | -------------------------------------------------------------------------------- /_build/build.h: -------------------------------------------------------------------------------- 1 | // This is automatically included by unity build files. 2 | 3 | #if defined(_WIN32) || defined(_WIN64) 4 | // We target Windows 7 and later. 5 | #define WINVER 0x0601 6 | #endif 7 | 8 | #if defined(_WIN32) || defined(_WIN64) 9 | #define WIN32_LEAN_AND_MEAN 10 | 11 | // There's so much crap included by default. This should prune a lot. 12 | #define NOGDICAPMASKS 13 | #define NORASTEROPS 14 | #define NOCOLOR 15 | #define NODRAWTEXT 16 | #define NOMB 17 | #define NOMEMMGR 18 | #define NOMETAFILE 19 | #define NOMINMAX 20 | #define NOOPENFILE 21 | #define NOSCROLL 22 | #define NOSOUND 23 | #define NOCOMM 24 | #define NOKANJI 25 | #define NOHELP 26 | #define NODEFERWINDOWPOS 27 | #define NOMCX 28 | 29 | // Preemptively include `windows.h` and `windowsx.h` and unfuck afterwords, 30 | // because Microsoft litters the global namespace with so much crap that is 31 | // a nightmare to clean up as we go along. 32 | #include 33 | #include 34 | 35 | #undef ABSOLUTE 36 | #undef RELATIVE 37 | 38 | #undef NEAR 39 | #undef FAR 40 | 41 | #undef absolute 42 | #undef relative 43 | 44 | #undef near 45 | #undef far 46 | 47 | #undef ERROR 48 | 49 | #undef DELETE 50 | #endif 51 | -------------------------------------------------------------------------------- /_build/build_engine_debug_windows_32.bat: -------------------------------------------------------------------------------- 1 | @echo OFF 2 | @setlocal EnableDelayedExpansion 3 | 4 | if defined VisualStudioVersion ( 5 | set IDE=1 6 | ) else ( 7 | set IDE=0 8 | ) 9 | 10 | @rem TODO(mtwilliams): Cache environment. 11 | 12 | if not defined YETI_COPYRIGHT (call %~dp0\info.bat) 13 | if not defined YETI_VERSION (call %~dp0\info.bat) 14 | if not defined YETI_REVISION (call %~dp0\info.bat) 15 | 16 | if not defined TOOLCHAIN ( 17 | if defined VisualStudioVersion ( 18 | set TOOLCHAIN=%VisualStudioVersion% 19 | ) else ( 20 | echo Using latest Visual Studio install... 1>&2 21 | set TOOLCHAIN=latest 22 | ) 23 | ) 24 | 25 | call %~dp0\scripts\vc.bat %TOOLCHAIN% windows x86 26 | 27 | if not %ERRORLEVEL% EQU 0 ( 28 | echo Could not setup environment for x86! 29 | exit /B 1 30 | ) 31 | 32 | pushd %~dp0\.. 33 | 34 | mkdir _build\obj 2>NUL 35 | mkdir _build\bin 2>NUL 36 | mkdir _build\lib 2>NUL 37 | 38 | echo #include "%~dp0\build.h" > _build\engine_debug_windows_32.cc 39 | call _build\scripts\unity.bat src >> _build\engine_debug_windows_32.cc 40 | 41 | cl.exe /nologo /c /W4 /arch:IA32 /fp:except /favor:blend /Od /Oi ^ 42 | /Gm- /GR- /EHa- /GS /MDd ^ 43 | /Fo_build\obj\yeti_debug_windows_32.obj ^ 44 | /Zi /Fd_build\obj\yeti_debug_windows_32.pdb ^ 45 | /D__YETI_COPYRIGHT__="\"%YETI_COPYRIGHT%\"" ^ 46 | /D__YETI_VERSION__="\"%YETI_VERSION%\"" ^ 47 | /D__YETI_REVISION__="%YETI_REVISION%" ^ 48 | /DYETI_CONFIGURATION=YETI_CONFIGURATION_DEBUG ^ 49 | /DYETI_LINKAGE=YETI_LINKAGE_STATIC ^ 50 | /DLOOM_CONFIGURATION=LOOM_CONFIGURATION_DEBUG ^ 51 | /DLOOM_LINKAGE=LOOM_LINKAGE_STATIC ^ 52 | /I_deps\luajit\include ^ 53 | /I_deps\sqlite3\include ^ 54 | /I_deps\loom\include ^ 55 | /I_deps\gala ^ 56 | /Iinclude /Isrc ^ 57 | _build\engine_debug_windows_32.cc 58 | 59 | if not %ERRORLEVEL% equ 0 ( 60 | popd 61 | echo Compilation failed. 62 | exit /B 1 63 | ) 64 | 65 | lib.exe /nologo /machine:X86 ^ 66 | /out:_build\lib\yeti_debug_windows_32.lib ^ 67 | _build\obj\yeti_debug_windows_32.obj 68 | 69 | if not %ERRORLEVEL% equ 0 ( 70 | popd 71 | echo Linking failed. 72 | exit /B 1 73 | ) 74 | 75 | echo Built `yeti_debug_windows_32.lib`. 76 | 77 | popd 78 | -------------------------------------------------------------------------------- /_build/build_engine_debug_windows_64.bat: -------------------------------------------------------------------------------- 1 | @echo OFF 2 | @setlocal EnableDelayedExpansion 3 | 4 | if defined VisualStudioVersion ( 5 | set IDE=1 6 | ) else ( 7 | set IDE=0 8 | ) 9 | 10 | @rem TODO(mtwilliams): Cache environment. 11 | 12 | if not defined YETI_COPYRIGHT (call %~dp0\info.bat) 13 | if not defined YETI_VERSION (call %~dp0\info.bat) 14 | if not defined YETI_REVISION (call %~dp0\info.bat) 15 | 16 | if not defined TOOLCHAIN ( 17 | if defined VisualStudioVersion ( 18 | set TOOLCHAIN=%VisualStudioVersion% 19 | ) else ( 20 | echo Using latest Visual Studio install... 1>&2 21 | set TOOLCHAIN=latest 22 | ) 23 | ) 24 | 25 | call %~dp0\scripts\vc.bat %TOOLCHAIN% windows x86_64 26 | 27 | if not %ERRORLEVEL% EQU 0 ( 28 | echo Could not setup environment for x86_64! 29 | exit /B 1 30 | ) 31 | 32 | pushd %~dp0\.. 33 | 34 | mkdir _build\obj 2>NUL 35 | mkdir _build\bin 2>NUL 36 | mkdir _build\lib 2>NUL 37 | 38 | echo #include "%~dp0\build.h" > _build\engine_debug_windows_64.cc 39 | call _build\scripts\unity.bat src >> _build\engine_debug_windows_64.cc 40 | 41 | cl.exe /nologo /c /W4 /fp:except /favor:blend /Od /Oi ^ 42 | /Gm- /GR- /EHa- /GS /MDd ^ 43 | /Fo_build\obj\yeti_debug_windows_64.obj ^ 44 | /Zi /Fd_build\obj\yeti_debug_windows_64.pdb ^ 45 | /D__YETI_COPYRIGHT__="\"%YETI_COPYRIGHT%\"" ^ 46 | /D__YETI_VERSION__="\"%YETI_VERSION%\"" ^ 47 | /D__YETI_REVISION__="%YETI_REVISION%" ^ 48 | /DYETI_CONFIGURATION=YETI_CONFIGURATION_DEBUG ^ 49 | /DYETI_LINKAGE=YETI_LINKAGE_STATIC ^ 50 | /DLOOM_CONFIGURATION=LOOM_CONFIGURATION_DEBUG ^ 51 | /DLOOM_LINKAGE=LOOM_LINKAGE_STATIC ^ 52 | /I_deps\luajit\include ^ 53 | /I_deps\sqlite3\include ^ 54 | /I_deps\loom\include ^ 55 | /I_deps\gala ^ 56 | /Iinclude /Isrc ^ 57 | _build\engine_debug_windows_64.cc 58 | 59 | if not %ERRORLEVEL% equ 0 ( 60 | popd 61 | echo Compilation failed. 62 | exit /B 1 63 | ) 64 | 65 | lib.exe /nologo /machine:X64 ^ 66 | /out:_build\lib\yeti_debug_windows_64.lib ^ 67 | _build\obj\yeti_debug_windows_64.obj 68 | 69 | if not %ERRORLEVEL% equ 0 ( 70 | popd 71 | echo Linking failed. 72 | exit /B 1 73 | ) 74 | 75 | echo Built `yeti_debug_windows_64.lib`. 76 | 77 | popd 78 | -------------------------------------------------------------------------------- /_build/build_resource_compiler_debug_windows_32.bat: -------------------------------------------------------------------------------- 1 | @echo OFF 2 | @setlocal EnableDelayedExpansion 3 | 4 | if defined VisualStudioVersion ( 5 | set IDE=1 6 | ) else ( 7 | set IDE=0 8 | ) 9 | 10 | @rem TODO(mtwilliams): Cache environment. 11 | 12 | if not defined TOOLCHAIN ( 13 | if defined VisualStudioVersion ( 14 | set TOOLCHAIN=%VisualStudioVersion% 15 | ) else ( 16 | echo Using latest Visual Studio install... 1>&2 17 | set TOOLCHAIN=latest 18 | ) 19 | ) 20 | 21 | call %~dp0\scripts\vc.bat %TOOLCHAIN% windows x86 22 | 23 | if not %ERRORLEVEL% EQU 0 ( 24 | echo Could not setup environment for x86! 25 | exit /B 1 26 | ) 27 | 28 | pushd %~dp0\.. 29 | 30 | mkdir _build\obj 2>NUL 31 | mkdir _build\bin 2>NUL 32 | mkdir _build\lib 2>NUL 33 | 34 | call _build\scripts\unity.bat tools\resource_compiler ^ 35 | > _build\resource_compiler_debug_windows_32.cc 36 | 37 | cl.exe /nologo /c /W4 /arch:IA32 /fp:except /favor:blend /Od /Oi ^ 38 | /Gm- /GR- /EHa- /GS /MDd ^ 39 | /Fo_build\obj\resource_compiler_debug_windows_32.obj ^ 40 | /Zi /Fd_build\obj\resource_compiler_debug_windows_32.pdb ^ 41 | /DYETI_CONFIGURATION=YETI_CONFIGURATION_DEBUG ^ 42 | /DYETI_LINKAGE=YETI_LINKAGE_STATIC ^ 43 | /DLOOM_CONFIGURATION=LOOM_CONFIGURATION_DEBUG ^ 44 | /DLOOM_LINKAGE=LOOM_LINKAGE_STATIC ^ 45 | /I_deps\luajit\include ^ 46 | /I_deps\sqlite3\include ^ 47 | /I_deps\loom\include ^ 48 | /I_deps\gala ^ 49 | /Iinclude /Isrc ^ 50 | /Itools\resource_compiler\include /Itools\resource_compiler\src ^ 51 | _build\resource_compiler_debug_windows_32.cc 52 | 53 | if not %ERRORLEVEL% equ 0 ( 54 | popd 55 | echo Compilation failed. 56 | exit /B 1 57 | ) 58 | 59 | link.exe /nologo /machine:X86 /DEBUG /stack:0x400000,0x400000 ^ 60 | /out:_build\bin\resource_compiler_debug_windows_32.exe ^ 61 | _build\obj\resource_compiler_debug_windows_32.obj ^ 62 | _build\lib\yeti_debug_windows_32.lib ^ 63 | _deps\luajit\_build\lib\luajit_debug_windows_32.lib ^ 64 | _deps\sqlite3\_build\lib\sqlite3_debug_windows_32.lib ^ 65 | _deps\loom\_build\lib\loom_debug_windows_32.lib ^ 66 | _deps\gala\_build\lib\gala_debug_windows_32.lib ^ 67 | kernel32.lib user32.lib gdi32.lib ole32.lib advapi32.lib 68 | 69 | if not %ERRORLEVEL% equ 0 ( 70 | popd 71 | echo Linking failed. 72 | exit /B 1 73 | ) 74 | 75 | echo Built `resource_compiler_debug_windows_32.exe`. 76 | 77 | popd 78 | -------------------------------------------------------------------------------- /_build/build_resource_compiler_debug_windows_64.bat: -------------------------------------------------------------------------------- 1 | @echo OFF 2 | @setlocal EnableDelayedExpansion 3 | 4 | if defined VisualStudioVersion ( 5 | set IDE=1 6 | ) else ( 7 | set IDE=0 8 | ) 9 | 10 | @rem TODO(mtwilliams): Cache environment. 11 | 12 | if not defined TOOLCHAIN ( 13 | if defined VisualStudioVersion ( 14 | set TOOLCHAIN=%VisualStudioVersion% 15 | ) else ( 16 | echo Using latest Visual Studio install... 1>&2 17 | set TOOLCHAIN=latest 18 | ) 19 | ) 20 | 21 | call %~dp0\scripts\vc.bat %TOOLCHAIN% windows x86_64 22 | 23 | if not %ERRORLEVEL% EQU 0 ( 24 | echo Could not setup environment for x86_64! 25 | exit /B 1 26 | ) 27 | 28 | pushd %~dp0\.. 29 | 30 | mkdir _build\obj 2>NUL 31 | mkdir _build\bin 2>NUL 32 | mkdir _build\lib 2>NUL 33 | 34 | call _build\scripts\unity.bat tools\resource_compiler ^ 35 | > _build\resource_compiler_debug_windows_64.cc 36 | 37 | cl.exe /nologo /c /W4 /fp:except /favor:blend /Od /Oi ^ 38 | /Gm- /GR- /EHa- /GS /MDd ^ 39 | /Fo_build\obj\resource_compiler_debug_windows_64.obj ^ 40 | /Zi /Fd_build\obj\resource_compiler_debug_windows_64.pdb ^ 41 | /DYETI_CONFIGURATION=YETI_CONFIGURATION_DEBUG ^ 42 | /DYETI_LINKAGE=YETI_LINKAGE_STATIC ^ 43 | /DLOOM_CONFIGURATION=LOOM_CONFIGURATION_DEBUG ^ 44 | /DLOOM_LINKAGE=LOOM_LINKAGE_STATIC ^ 45 | /I_deps\luajit\include ^ 46 | /I_deps\sqlite3\include ^ 47 | /I_deps\loom\include ^ 48 | /I_deps\gala ^ 49 | /Iinclude /Isrc ^ 50 | /Itools\resource_compiler\include /Itools\resource_compiler\src ^ 51 | _build\resource_compiler_debug_windows_64.cc 52 | 53 | if not %ERRORLEVEL% equ 0 ( 54 | popd 55 | echo Compilation failed. 56 | exit /B 1 57 | ) 58 | 59 | link.exe /nologo /machine:X64 /DEBUG /stack:0x400000,0x400000 ^ 60 | /out:_build\bin\resource_compiler_debug_windows_64.exe ^ 61 | _build\obj\resource_compiler_debug_windows_64.obj ^ 62 | _build\lib\yeti_debug_windows_64.lib ^ 63 | _deps\luajit\_build\lib\luajit_debug_windows_64.lib ^ 64 | _deps\sqlite3\_build\lib\sqlite3_debug_windows_64.lib ^ 65 | _deps\loom\_build\lib\loom_debug_windows_64.lib ^ 66 | _deps\gala\_build\lib\gala_debug_windows_64.lib ^ 67 | kernel32.lib user32.lib gdi32.lib ole32.lib advapi32.lib 68 | 69 | if not %ERRORLEVEL% equ 0 ( 70 | popd 71 | echo Linking failed. 72 | exit /B 1 73 | ) 74 | 75 | echo Built `resource_compiler_debug_windows_64.exe`. 76 | 77 | popd 78 | -------------------------------------------------------------------------------- /_build/build_runtime_debug_windows_32.bat: -------------------------------------------------------------------------------- 1 | @echo OFF 2 | @setlocal EnableDelayedExpansion 3 | 4 | if defined VisualStudioVersion ( 5 | set IDE=1 6 | ) else ( 7 | set IDE=0 8 | ) 9 | 10 | @rem TODO(mtwilliams): Cache environment. 11 | 12 | if not defined TOOLCHAIN ( 13 | if defined VisualStudioVersion ( 14 | set TOOLCHAIN=%VisualStudioVersion% 15 | ) else ( 16 | echo Using latest Visual Studio install... 1>&2 17 | set TOOLCHAIN=latest 18 | ) 19 | ) 20 | 21 | call %~dp0\scripts\vc.bat %TOOLCHAIN% windows x86 22 | 23 | if not %ERRORLEVEL% EQU 0 ( 24 | echo Could not setup environment for x86! 25 | exit /B 1 26 | ) 27 | 28 | pushd %~dp0\.. 29 | 30 | mkdir _build\obj 2>NUL 31 | mkdir _build\bin 2>NUL 32 | mkdir _build\lib 2>NUL 33 | 34 | call _build\scripts\unity.bat runtime > _build\runtime_debug_windows_32.cc 35 | 36 | cl.exe /nologo /c /W4 /arch:IA32 /fp:except /favor:blend /Od /Oi ^ 37 | /Gm- /GR- /EHa- /GS /MDd ^ 38 | /Fo_build\obj\runtime_debug_windows_32.obj ^ 39 | /Zi /Fd_build\obj\runtime_debug_windows_32.pdb ^ 40 | /DYETI_CONFIGURATION=YETI_CONFIGURATION_DEBUG ^ 41 | /DYETI_LINKAGE=YETI_LINKAGE_STATIC ^ 42 | /DLOOM_CONFIGURATION=LOOM_CONFIGURATION_DEBUG ^ 43 | /DLOOM_LINKAGE=LOOM_LINKAGE_STATIC ^ 44 | /I_deps\luajit\include ^ 45 | /I_deps\sqlite3\include ^ 46 | /I_deps\loom\include ^ 47 | /I_deps\gala ^ 48 | /Iinclude /Isrc ^ 49 | /Iruntime\include /Iruntime\src ^ 50 | _build\runtime_debug_windows_32.cc 51 | 52 | if not %ERRORLEVEL% equ 0 ( 53 | popd 54 | echo Compilation failed. 55 | exit /B 1 56 | ) 57 | 58 | link.exe /nologo /machine:X86 /DEBUG /stack:0x400000,0x400000 ^ 59 | /out:_build\bin\runtime_debug_windows_32.exe ^ 60 | _build\obj\runtime_debug_windows_32.obj ^ 61 | _build\lib\yeti_debug_windows_32.lib ^ 62 | _deps\luajit\_build\lib\luajit_debug_windows_32.lib ^ 63 | _deps\sqlite3\_build\lib\sqlite3_debug_windows_32.lib ^ 64 | _deps\loom\_build\lib\loom_debug_windows_32.lib ^ 65 | _deps\gala\_build\lib\gala_debug_windows_32.lib ^ 66 | kernel32.lib user32.lib gdi32.lib ole32.lib advapi32.lib 67 | 68 | if not %ERRORLEVEL% equ 0 ( 69 | popd 70 | echo Linking failed. 71 | exit /B 1 72 | ) 73 | 74 | echo Built `runtime_debug_windows_32.exe`. 75 | 76 | popd 77 | -------------------------------------------------------------------------------- /_build/build_runtime_debug_windows_64.bat: -------------------------------------------------------------------------------- 1 | @echo OFF 2 | @setlocal EnableDelayedExpansion 3 | 4 | if defined VisualStudioVersion ( 5 | set IDE=1 6 | ) else ( 7 | set IDE=0 8 | ) 9 | 10 | @rem TODO(mtwilliams): Cache environment. 11 | 12 | if not defined TOOLCHAIN ( 13 | if defined VisualStudioVersion ( 14 | set TOOLCHAIN=%VisualStudioVersion% 15 | ) else ( 16 | echo Using latest Visual Studio install... 1>&2 17 | set TOOLCHAIN=latest 18 | ) 19 | ) 20 | 21 | call %~dp0\scripts\vc.bat %TOOLCHAIN% windows x86_64 22 | 23 | if not %ERRORLEVEL% EQU 0 ( 24 | echo Could not setup environment for x86_64! 25 | exit /B 1 26 | ) 27 | 28 | pushd %~dp0\.. 29 | 30 | mkdir _build\obj 2>NUL 31 | mkdir _build\bin 2>NUL 32 | mkdir _build\lib 2>NUL 33 | 34 | call _build\scripts\unity.bat runtime > _build\runtime_debug_windows_64.cc 35 | 36 | cl.exe /nologo /c /W4 /fp:except /favor:blend /Od /Oi ^ 37 | /Gm- /GR- /EHa- /GS /MDd ^ 38 | /Fo_build\obj\runtime_debug_windows_64.obj ^ 39 | /Zi /Fd_build\obj\runtime_debug_windows_64.pdb ^ 40 | /DYETI_CONFIGURATION=YETI_CONFIGURATION_DEBUG ^ 41 | /DYETI_LINKAGE=YETI_LINKAGE_STATIC ^ 42 | /DLOOM_CONFIGURATION=LOOM_CONFIGURATION_DEBUG ^ 43 | /DLOOM_LINKAGE=LOOM_LINKAGE_STATIC ^ 44 | /I_deps\luajit\include ^ 45 | /I_deps\sqlite3\include ^ 46 | /I_deps\loom\include ^ 47 | /I_deps\gala ^ 48 | /Iinclude /Isrc ^ 49 | /Iruntime\include /Iruntime\src ^ 50 | _build\runtime_debug_windows_64.cc 51 | 52 | if not %ERRORLEVEL% equ 0 ( 53 | popd 54 | echo Compilation failed. 55 | exit /B 1 56 | ) 57 | 58 | link.exe /nologo /machine:X64 /DEBUG /stack:0x400000,0x400000 ^ 59 | /out:_build\bin\runtime_debug_windows_64.exe ^ 60 | _build\obj\runtime_debug_windows_64.obj ^ 61 | _build\lib\yeti_debug_windows_64.lib ^ 62 | _deps\luajit\_build\lib\luajit_debug_windows_64.lib ^ 63 | _deps\sqlite3\_build\lib\sqlite3_debug_windows_64.lib ^ 64 | _deps\loom\_build\lib\loom_debug_windows_64.lib ^ 65 | _deps\gala\_build\lib\gala_debug_windows_64.lib ^ 66 | kernel32.lib user32.lib gdi32.lib ole32.lib advapi32.lib 67 | 68 | if not %ERRORLEVEL% equ 0 ( 69 | popd 70 | echo Linking failed. 71 | exit /B 1 72 | ) 73 | 74 | echo Built `runtime_debug_windows_64.exe`. 75 | 76 | popd 77 | -------------------------------------------------------------------------------- /_build/info.bat: -------------------------------------------------------------------------------- 1 | @rem Collects various information about Yeti. 2 | 3 | @echo OFF 4 | 5 | for /f "tokens=2 delims==" %%r in ('wmic OS Get localdatetime /value') do ( 6 | set T=%%r 7 | 8 | set YYYY=!T:~0,4! 9 | set MM=!T:~4,2! 10 | set DD=!T:~6,2! 11 | set HH=!T:~8,2! 12 | set MM=!T:~10,2! 13 | set SS=!T:~12,2! 14 | 15 | set TIMESTAMP=!YYYY!-!MM!-!DD! !HH!:!MM!:!SS! 16 | ) 17 | 18 | set YETI_COPYRIGHT=Copyright 2012-%YYYY% Origami Comet Games, Inc. 19 | 20 | for /f %%v in ('call %~dp0\scripts\version.bat') do ( 21 | set YETI_VERSION=%%v 22 | ) 23 | 24 | for /f %%v in ('call %~dp0\scripts\revision.bat') do ( 25 | set YETI_REVISION=%%v 26 | ) 27 | -------------------------------------------------------------------------------- /_build/scripts/7z.bat: -------------------------------------------------------------------------------- 1 | @rem Forwards to `7z` if in PATH, or to a local copy of 7-Zip if not found. 2 | 3 | @echo OFF 4 | @setlocal EnableDelayedExpansion 5 | 6 | where /Q 7z 7 | 8 | if %ERRORLEVEL% equ 0 ( 9 | @rem 7-Zip is already in PATH! 10 | 7z %* 11 | exit /B !ERRORLEVEL! 12 | ) 13 | 14 | @rem Not found. 15 | 16 | set _7zip=%~dp0\..\tools\cache\7za.exe 17 | set _7zipVer=16.04 18 | set _7zipSource=https://github.com/origamicomet/barebones/releases/download/v0.1.0/7za.exe 19 | 20 | if exist %_7zip% ( 21 | @rem Already installed. 22 | goto forward_to_cached 23 | ) 24 | 25 | if defined DO_NOT_FETCH_TOOLS ( 26 | echo Could not find 7-Zip! 27 | exit /B 1 28 | ) 29 | 30 | PowerShell.exe -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -File %~dp0\download.ps1 %_7zipSource% %_7zip% 31 | 32 | if not %ERRORLEVEL% equ 0 ( 33 | echo Failed to fetch 7-Zip for Windows! 34 | exit /B 1 35 | ) 36 | 37 | :forward_to_cached 38 | 39 | %_7zip% %* 40 | -------------------------------------------------------------------------------- /_build/scripts/download.ps1: -------------------------------------------------------------------------------- 1 | # Force errors to bubble correctly. 2 | trap { exit 1 } 3 | 4 | # Download the file (using WebClient to support Windows 7.) 5 | $WebClient = New-Object System.Net.WebClient 6 | $WebClient.DownloadFile($args[0], $args[1]) 7 | -------------------------------------------------------------------------------- /_build/scripts/git.bat: -------------------------------------------------------------------------------- 1 | @rem Forwards to `git` if in PATH, or to a local copy of Git for Windows if 2 | @rem not found. 3 | 4 | @echo OFF 5 | @setlocal EnableDelayedExpansion 6 | 7 | where /Q git 8 | 9 | if %ERRORLEVEL% equ 0 ( 10 | @rem Git is already in PATH! 11 | git %* 12 | exit /B !ERRORLEVEL! 13 | ) 14 | 15 | @rem Not found. 16 | 17 | set _GitForWindows=%~dp0\..\tools\cache\git-for-windows 18 | set _GitForWindowsVer=2.14.2 19 | set _GitForWindowsSource=https://github.com/git-for-windows/git/releases/download/v%_GitForWindowsVer%.windows.1/PortableGit-%_GitForWindowsVer%-32-bit.7z.exe 20 | 21 | if exist %_GitForWindows%\cmd\git.exe ( 22 | @rem Already installed. 23 | goto forward_to_cached 24 | ) 25 | 26 | if defined DO_NOT_FETCH_TOOLS ( 27 | echo Could not find Git! 28 | exit /B 1 29 | ) 30 | 31 | @rem Download. 32 | 33 | PowerShell.exe -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -File %~dp0\download.ps1 %_GitForWindowsSource% %_GitForWindows%.7z.exe 34 | 35 | if not %ERRORLEVEL% equ 0 ( 36 | echo Failed to fetch Git for Windows from Github! 37 | exit /B 1 38 | ) 39 | 40 | @rem Extract. 41 | 42 | %~dp0\7z.bat e -o%_GitForWindows% %_GitForWindows%.7z.exe 43 | 44 | @rem Run post install script, otherwise Git for Windows won't work. 45 | 46 | start "git-bash.exe --no-needs-console --hide --no-cd --command=%_GitForWindows%\post-install.cmd" 47 | 48 | @rem Give it some time, then proceed. 49 | 50 | timeout /t 5 /nobreak > NUL 51 | 52 | :forward_to_cached 53 | 54 | set gitdir=%_GitForWindows% 55 | 56 | "%_GitForWindows%\cmd\git.exe" %* 57 | -------------------------------------------------------------------------------- /_build/scripts/manifest.bat: -------------------------------------------------------------------------------- 1 | @rem TODO(mtwilliams): Manifest compilation and injection. 2 | -------------------------------------------------------------------------------- /_build/scripts/revision.bat: -------------------------------------------------------------------------------- 1 | @echo OFF 2 | 3 | for /F "usebackq tokens=1" %%r in (`call %~dp0\git.bat rev-list --count HEAD`) do ( 4 | 31 | extern YETI_PUBLIC T random(); 32 | 33 | /// Returns a pseudo-random number between @min and @max, inclusive. 34 | template 35 | extern YETI_PUBLIC T random(const T min, const T max); 36 | 37 | /// Fills @buffer with @n random bytes. 38 | extern YETI_PUBLIC void random_n(u8 *buffer, size_t n); 39 | 40 | } // core 41 | } // yeti 42 | 43 | #endif // _YETI_CORE_ALGORITHMS_RANDOM_H_ 44 | -------------------------------------------------------------------------------- /include/yeti/core/allocator.h: -------------------------------------------------------------------------------- 1 | //===-- yeti/core/allocator.h ---------------------------*- mode: C++11 -*-===// 2 | // 3 | // _____ _ _ _ 4 | // | __|___ _ _ ___ _| |___| |_|_|___ ___ 5 | // | __| . | | | | . | .'| _| | . | | 6 | // |__| |___|___|_|_|___|__,|_| |_|___|_|_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | // 12 | // TODO(mtwilliams): Document the purpose of this file. 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | #ifndef _YETI_CORE_ALLOCATOR_H_ 17 | #define _YETI_CORE_ALLOCATOR_H_ 18 | 19 | #include "yeti/config.h" 20 | #include "yeti/linkage.h" 21 | 22 | #include "yeti/core/types.h" 23 | #include "yeti/core/support.h" 24 | 25 | #include "yeti/core/memory.h" 26 | 27 | namespace yeti { 28 | namespace core { 29 | 30 | /// \brief Common interface that encapsulates strategies for allocation, 31 | /// deallocation, and tracking of memory. 32 | class YETI_PUBLIC Allocator { 33 | YETI_DISALLOW_COPYING(Allocator) 34 | 35 | protected: 36 | Allocator(); 37 | virtual ~Allocator(); 38 | 39 | public: 40 | virtual void *allocate(size_t size, size_t alignment = 16) = 0; 41 | virtual void *reallocate(void *ptr, size_t size, size_t alignment = 16) = 0; 42 | virtual void deallocate(void *ptr) = 0; 43 | }; 44 | 45 | } // core 46 | } // yeti 47 | 48 | // Need to include to pickup placement new. 49 | #include 50 | 51 | /// \def YETI_NEW 52 | /// 53 | /// \brief Allocates memory from @Allocator for the given type @T, then calls 54 | /// its constructor. 55 | /// 56 | #define YETI_NEW(T, Allocator) \ 57 | new (Allocator.allocate(sizeof(T), alignof(T))) T 58 | 59 | /// \def YETI_DELETE 60 | /// 61 | /// \brief Destructs @Instance and deallocates memory from @Allocator. 62 | /// 63 | #define YETI_DELETE(T, Allocator, Instance) \ 64 | { (Instance)->~T(); Allocator.deallocate((void *)Instance); } 65 | 66 | #endif // _YETI_CORE_ALLOCATOR_H_ 67 | -------------------------------------------------------------------------------- /include/yeti/core/allocators/buddy_allocator.h: -------------------------------------------------------------------------------- 1 | //===-- yeti/core/allocators/buddy_allocator.h ----------*- mode: C++11 -*-===// 2 | // 3 | // _____ _ _ _ 4 | // | __|___ _ _ ___ _| |___| |_|_|___ ___ 5 | // | __| . | | | | . | .'| _| | . | | 6 | // |__| |___|___|_|_|___|__,|_| |_|___|_|_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | // 12 | // TODO(mtwilliams): Document the purpose of this file. 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | #ifndef _YETI_CORE_ALLOCATORS_BUDDY_ALLOCATOR_H_ 17 | #define _YETI_CORE_ALLOCATORS_BUDDY_ALLOCATOR_H_ 18 | 19 | #include "yeti/core/allocator.h" 20 | 21 | namespace yeti { 22 | namespace core { 23 | 24 | // TODO(mtwilliams): Implement a buddy allocator with minimal overhead. 25 | class YETI_PUBLIC BuddyAllocator : public Allocator {}; 26 | 27 | } // core 28 | } // yeti 29 | 30 | #endif // _YETI_CORE_ALLOCATORS_BUDDY_ALLOCATOR_H_ 31 | -------------------------------------------------------------------------------- /include/yeti/core/allocators/bump_allocator.h: -------------------------------------------------------------------------------- 1 | //===-- yeti/core/allocators/bump_allocator.h -----------*- mode: C++11 -*-===// 2 | // 3 | // _____ _ _ _ 4 | // | __|___ _ _ ___ _| |___| |_|_|___ ___ 5 | // | __| . | | | | . | .'| _| | . | | 6 | // |__| |___|___|_|_|___|__,|_| |_|___|_|_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | // 12 | // TODO(mtwilliams): Document the purpose of this file. 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | #ifndef _YETI_CORE_ALLOCATORS_BUMP_ALLOCATOR_H_ 17 | #define _YETI_CORE_ALLOCATORS_BUMP_ALLOCATOR_H_ 18 | 19 | #include "yeti/core/allocator.h" 20 | 21 | namespace yeti { 22 | namespace core { 23 | 24 | // TODO(mtwilliams): Implement a bump allocator. 25 | // TODO(mtwilliams): Allow bookmarking. 26 | 27 | class YETI_PUBLIC BumpAllocator : public Allocator {}; 28 | 29 | } // core 30 | } // yeti 31 | 32 | #endif // _YETI_CORE_ALLOCATORS_BUMP_ALLOCATOR_H_ 33 | -------------------------------------------------------------------------------- /include/yeti/core/allocators/global_heap_allocator.h: -------------------------------------------------------------------------------- 1 | //===-- yeti/core/allocators/global_heap_allocator.h ----*- mode: C++11 -*-===// 2 | // 3 | // _____ _ _ _ 4 | // | __|___ _ _ ___ _| |___| |_|_|___ ___ 5 | // | __| . | | | | . | .'| _| | . | | 6 | // |__| |___|___|_|_|___|__,|_| |_|___|_|_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | // 12 | // TODO(mtwilliams): Document the purpose of this file. 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | #ifndef _YETI_CORE_ALLOCATORS_GLOBAL_HEAP_ALLOCATOR_H_ 17 | #define _YETI_CORE_ALLOCATORS_GLOBAL_HEAP_ALLOCATOR_H_ 18 | 19 | #include "yeti/core/allocator.h" 20 | 21 | namespace yeti { 22 | namespace core { 23 | 24 | /// \brief Returns global heap allocator. 25 | /// \deprecated Use the global page allocator instead. 26 | extern YETI_PUBLIC Allocator &global_heap_allocator(); 27 | 28 | } // core 29 | } // yeti 30 | 31 | #endif // _YETI_CORE_ALLOCATORS_GLOBAL_HEAP_ALLOCATOR_H_ 32 | -------------------------------------------------------------------------------- /include/yeti/core/allocators/global_page_allocator.h: -------------------------------------------------------------------------------- 1 | //===-- yeti/core/allocators/global_page_allocator.h ----*- mode: C++11 -*-===// 2 | // 3 | // _____ _ _ _ 4 | // | __|___ _ _ ___ _| |___| |_|_|___ ___ 5 | // | __| . | | | | . | .'| _| | . | | 6 | // |__| |___|___|_|_|___|__,|_| |_|___|_|_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | // 12 | // TODO(mtwilliams): Document the purpose of this file. 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | #ifndef _YETI_CORE_ALLOCATORS_GLOBAL_PAGE_ALLOCATOR_H_ 17 | #define _YETI_CORE_ALLOCATORS_GLOBAL_PAGE_ALLOCATOR_H_ 18 | 19 | #include "yeti/core/allocator.h" 20 | 21 | namespace yeti { 22 | namespace core { 23 | 24 | /// Allocates whole pages from system. 25 | class YETI_PUBLIC PageAllocator : public Allocator { 26 | YETI_DISALLOW_COPYING(PageAllocator) 27 | 28 | protected: 29 | PageAllocator(size_t granularity) : granularity_(granularity) {} 30 | ~PageAllocator() {} 31 | 32 | public: 33 | virtual void *allocate(size_t size, size_t alignment = 16) = 0; 34 | virtual void *reallocate(void *ptr, size_t size, size_t alignment = 16) = 0; 35 | virtual void deallocate(void *ptr) = 0; 36 | 37 | public: 38 | size_t granularity() const { return granularity_; } 39 | 40 | protected: 41 | const size_t granularity_; 42 | }; 43 | 44 | /// brief Returns the global page allocator. 45 | extern YETI_PUBLIC PageAllocator &global_page_allocator(); 46 | 47 | } // core 48 | } // yeti 49 | 50 | #endif // _YETI_CORE_ALLOCATORS_GLOBAL_PAGE_ALLOCATOR_H_ 51 | -------------------------------------------------------------------------------- /include/yeti/core/allocators/proxy_allocator.h: -------------------------------------------------------------------------------- 1 | //===-- yeti/core/allocators/proxy_allocator.h ----------*- mode: C++11 -*-===// 2 | // 3 | // _____ _ _ _ 4 | // | __|___ _ _ ___ _| |___| |_|_|___ ___ 5 | // | __| . | | | | . | .'| _| | . | | 6 | // |__| |___|___|_|_|___|__,|_| |_|___|_|_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | // 12 | // TODO(mtwilliams): Document the purpose of this file. 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | #ifndef _YETI_CORE_PROXY_ALLOCATOR_H_ 17 | #define _YETI_CORE_PROXY_ALLOCATOR_H_ 18 | 19 | #include "yeti/core/allocator.h" 20 | 21 | namespace yeti { 22 | namespace core { 23 | 24 | /// Proxies allocations to another allocator. 25 | class YETI_PUBLIC ProxyAllocator : public Allocator { 26 | YETI_DISALLOW_COPYING(ProxyAllocator) 27 | 28 | public: 29 | explicit ProxyAllocator(Allocator *allocator, const char *name); 30 | explicit ProxyAllocator(Allocator &allocator, const char *name); 31 | 32 | ~ProxyAllocator(); 33 | 34 | public: 35 | void *allocate(size_t size, size_t alignment = 16); 36 | void *reallocate(void *ptr, size_t size, size_t alignment = 16); 37 | void deallocate(void *ptr); 38 | 39 | private: 40 | Allocator *forwardee_; 41 | }; 42 | 43 | } // core 44 | } // yeti 45 | 46 | #endif // _YETI_CORE_PROXY_ALLOCATOR_H_ 47 | -------------------------------------------------------------------------------- /include/yeti/core/allocators/thread_safe/bump_allocator.h: -------------------------------------------------------------------------------- 1 | //===-- yeti/core/allocators/thread_safe/bump_allocator.h -----------------===// 2 | // 3 | // _____ _ _ _ 4 | // | __|___ _ _ ___ _| |___| |_|_|___ ___ 5 | // | __| . | | | | . | .'| _| | . | | 6 | // |__| |___|___|_|_|___|__,|_| |_|___|_|_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | // 12 | // TODO(mtwilliams): Document the purpose of this file. 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | #ifndef _YETI_CORE_ALLOCATORS_THREAD_SAFE_BUMP_ALLOCATOR_H_ 17 | #define _YETI_CORE_ALLOCATORS_THREAD_SAFE_BUMP_ALLOCATOR_H_ 18 | 19 | #include "yeti/core/allocator.h" 20 | 21 | namespace yeti { 22 | namespace core { 23 | namespace thread_safe { 24 | 25 | class YETI_PUBLIC BumpAllocator : public Allocator { 26 | YETI_DISALLOW_COPYING(BumpAllocator) 27 | 28 | public: 29 | BumpAllocator(Allocator *allocator, size_t size); 30 | BumpAllocator(Allocator &allocator, size_t size); 31 | BumpAllocator(void *memory, size_t size); 32 | 33 | ~BumpAllocator(); 34 | 35 | public: 36 | void *allocate(size_t size, size_t alignment = 16); 37 | void *reallocate(void *ptr, size_t size, size_t alignment = 16); 38 | void deallocate(void *ptr); 39 | 40 | public: 41 | void reset(); 42 | 43 | private: 44 | Allocator *backing_; 45 | const uintptr_t lower_; 46 | const uintptr_t upper_; 47 | volatile uintptr_t unallocated_; 48 | }; 49 | 50 | } // thread_safe 51 | } // core 52 | } // yeti 53 | 54 | #endif // _YETI_CORE_ALLOCATORS_THREAD_SAFE_BUMP_ALLOCATOR_H_ 55 | -------------------------------------------------------------------------------- /include/yeti/core/containers/dequeue.h: -------------------------------------------------------------------------------- 1 | // TODO(mtwilliams): Implement a doubly-ended queue. 2 | -------------------------------------------------------------------------------- /include/yeti/core/containers/list.h: -------------------------------------------------------------------------------- 1 | // TODO(mtwilliams): Implement a linked-list container. 2 | -------------------------------------------------------------------------------- /include/yeti/core/containers/stack.h: -------------------------------------------------------------------------------- 1 | // TODO(mtwilliams): Implement a stack. 2 | -------------------------------------------------------------------------------- /include/yeti/core/debug/abi.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/include/yeti/core/debug/abi.h -------------------------------------------------------------------------------- /include/yeti/core/debug/demangle.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/include/yeti/core/debug/demangle.h -------------------------------------------------------------------------------- /include/yeti/core/debug/errors.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/include/yeti/core/debug/errors.h -------------------------------------------------------------------------------- /include/yeti/core/debug/handler.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/include/yeti/core/debug/handler.h -------------------------------------------------------------------------------- /include/yeti/core/debug/registers.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/include/yeti/core/debug/registers.h -------------------------------------------------------------------------------- /include/yeti/core/debug/stacktrace.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/include/yeti/core/debug/stacktrace.h -------------------------------------------------------------------------------- /include/yeti/core/log/console.h: -------------------------------------------------------------------------------- 1 | //===-- yeti/core/log/console.h -------------------------*- mode: C++11 -*-===// 2 | // 3 | // _____ _ _ _ 4 | // | __|___ _ _ ___ _| |___| |_|_|___ ___ 5 | // | __| . | | | | . | .'| _| | . | | 6 | // |__| |___|___|_|_|___|__,|_| |_|___|_|_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | // 12 | /// \file 13 | /// \brief Console backend for logs. 14 | // 15 | //===----------------------------------------------------------------------===// 16 | 17 | #ifndef _YETI_CORE_LOG_CONSOLE_H_ 18 | #define _YETI_CORE_LOG_CONSOLE_H_ 19 | 20 | #include "yeti/core/log.h" 21 | 22 | namespace yeti { 23 | namespace core { 24 | 25 | namespace log { 26 | 27 | class YETI_PUBLIC ConsoleBackend : public Backend { 28 | YETI_DISALLOW_COPYING(ConsoleBackend) 29 | 30 | public: 31 | ConsoleBackend(); 32 | ~ConsoleBackend(); 33 | 34 | private: 35 | enum Color { 36 | BLACK = 0, 37 | GRAY = 1, 38 | WHITE = 2, 39 | RED = 3, 40 | GREEN = 4, 41 | BLUE = 5, 42 | YELLOW = 6, 43 | CYAN = 7, 44 | MAGENTA = 8 45 | }; 46 | 47 | void set_foreground_color(Color color); 48 | void set_background_color(Color color); 49 | 50 | void reset_foreground_color(); 51 | void reset_background_color(); 52 | 53 | public: 54 | void log(const Message &message); 55 | 56 | private: 57 | struct Storage; 58 | Storage *storage_; 59 | }; 60 | 61 | } // log 62 | 63 | } // core 64 | } // yeti 65 | 66 | #endif // _YETI_CORE_LOG_CONSOLE_H_ 67 | -------------------------------------------------------------------------------- /include/yeti/core/log/file.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/include/yeti/core/log/file.h -------------------------------------------------------------------------------- /include/yeti/core/log/network.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/include/yeti/core/log/network.h -------------------------------------------------------------------------------- /include/yeti/core/memory.h: -------------------------------------------------------------------------------- 1 | //===-- yeti/core/memory.h ------------------------------*- mode: C++11 -*-===// 2 | // 3 | // _____ _ _ _ 4 | // | __|___ _ _ ___ _| |___| |_|_|___ ___ 5 | // | __| . | | | | . | .'| _| | . | | 6 | // |__| |___|___|_|_|___|__,|_| |_|___|_|_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | // 12 | // TODO(mtwilliams): Document the purpose of this file. 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | #ifndef _YETI_CORE_MEMORY_H_ 17 | #define _YETI_CORE_MEMORY_H_ 18 | 19 | #include "yeti/config.h" 20 | #include "yeti/linkage.h" 21 | 22 | #include "yeti/core/types.h" 23 | #include "yeti/core/support.h" 24 | 25 | #include 26 | 27 | namespace yeti { 28 | namespace core { 29 | 30 | // TODO(mtwilliam): Document `memory` utilities. 31 | // TODO(mtwilliams): Assert `memory::copy` buffers don't overlap. 32 | // PERF(mtwilliams): Restrict `memory::copy` pointers. 33 | 34 | /// \namespace ::yeti::core::memory 35 | /// \brief 36 | namespace memory { 37 | /// Forward aligns @base pointer to the closest @alignment byte boundry. 38 | static YETI_INLINE uintptr_t align(uintptr_t base, size_t alignment) { 39 | return (alignment - (base % alignment)) % alignment; 40 | } 41 | 42 | /// Forward aligns @base pointer to the closest @alignment byte boundry. 43 | static YETI_INLINE void *align(void *base, size_t alignment) { 44 | return (void *)memory::align((uintptr_t)base, alignment); 45 | } 46 | 47 | /// Zeros @count bytes starting from @ptr. 48 | static YETI_INLINE void zero(void *ptr, size_t count) { 49 | ::memset(ptr, 0, count); 50 | } 51 | 52 | /// Fills @count bytes with @byte starting from @ptr. 53 | static YETI_INLINE void fill(void *ptr, size_t count, unsigned char byte) { 54 | ::memset(ptr, byte, count); 55 | } 56 | 57 | /// Copies @count bytes from @source to @destination. 58 | static YETI_INLINE void copy(const void *source, void *destination, size_t count) { 59 | ::memcpy(destination, source, count); 60 | } 61 | } 62 | 63 | } // core 64 | } // yeti 65 | 66 | #endif // _YETI_CORE_MEMORY_H_ 67 | -------------------------------------------------------------------------------- /include/yeti/core/misc/ini.h: -------------------------------------------------------------------------------- 1 | //===-- yeti/core/misc/ini.h ----------------------------*- mode: C++11 -*-===// 2 | // 3 | // _____ _ _ _ 4 | // | __|___ _ _ ___ _| |___| |_|_|___ ___ 5 | // | __| . | | | | . | .'| _| | . | | 6 | // |__| |___|___|_|_|___|__,|_| |_|___|_|_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | // 12 | // TODO(mtwilliams): Document the purpose of this file. 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | #ifndef _YETI_CORE_MISC_INI_H_ 17 | #define _YETI_CORE_MISC_INI_H_ 18 | 19 | #include "yeti/config.h" 20 | #include "yeti/linkage.h" 21 | 22 | #include "yeti/core/types.h" 23 | #include "yeti/core/support.h" 24 | 25 | namespace yeti { 26 | namespace core { 27 | 28 | // See `yeti/core/platform/filesystem.h`. 29 | struct File; 30 | 31 | namespace ini { 32 | typedef bool (*Callback)(const char *section, 33 | const char *key, 34 | const char *value, 35 | void *context); 36 | 37 | enum Options { 38 | // Skip malformed entries and continue rather than stopping parsing. 39 | CONTINUE_ON_ERROR = (1 << 0) 40 | }; 41 | 42 | /// \brief Parses a @buffer, calling @callback for each entry. 43 | extern YETI_PUBLIC bool parse(const char *buffer, 44 | unsigned length, 45 | Callback callback, 46 | void *context = NULL, 47 | u32 options = 0x00000000); 48 | 49 | /// \brief Parses a @file, calling @callback for each entry. 50 | extern YETI_PUBLIC bool parse(File *file, 51 | Callback callback, 52 | void *context = NULL, 53 | u32 options = 0x00000000); 54 | } 55 | 56 | } // core 57 | } // yeti 58 | 59 | #endif // _YETI_CORE_MISC_INI_H_ 60 | -------------------------------------------------------------------------------- /include/yeti/core/misc/json.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/include/yeti/core/misc/json.h -------------------------------------------------------------------------------- /include/yeti/core/misc/pattern_file_parser.h: -------------------------------------------------------------------------------- 1 | //===-- yeti/core/misc/pattern_file_parser.h ------------*- mode: C++11 -*-===// 2 | // 3 | // _____ _ _ _ 4 | // | __|___ _ _ ___ _| |___| |_|_|___ ___ 5 | // | __| . | | | | . | .'| _| | . | | 6 | // |__| |___|___|_|_|___|__,|_| |_|___|_|_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | // 12 | // TODO(mtwilliams): Document the purpose of this file. 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | #ifndef _YETI_CORE_MISC_PATTERN_FILE_PARSER_H_ 17 | #define _YETI_CORE_MISC_PATTERN_FILE_PARSER_H_ 18 | 19 | #include "yeti/config.h" 20 | #include "yeti/linkage.h" 21 | 22 | #include "yeti/core/types.h" 23 | #include "yeti/core/support.h" 24 | 25 | #include "yeti/core/containers/array.h" 26 | 27 | namespace yeti { 28 | namespace core { 29 | 30 | // See `yeti/core/platform/filesystem.h`. 31 | struct File; 32 | 33 | /// \brief A pattern file parser. 34 | /// 35 | /// \details Parses a file of patterns akin to a `.gitignore`. 36 | /// 37 | class YETI_PUBLIC PatternFileParser { 38 | YETI_DISALLOW_COPYING(PatternFileParser) 39 | 40 | public: 41 | PatternFileParser(File *file); 42 | 43 | public: 44 | /// Extracts patterns from file. 45 | void parse(Array &patterns); 46 | 47 | private: 48 | /// \internal Extracts pattern on current line, unless empty. 49 | const char *extract(); 50 | 51 | /// \internal Skips to new line. 52 | void skip_to_next_line(); 53 | 54 | /// \internal Get next character. 55 | char advance(); 56 | 57 | /// \internal Get next character without advancing. 58 | char peek(); 59 | 60 | /// \internal End of file? 61 | bool eof() const; 62 | 63 | private: 64 | Array buffer_; 65 | unsigned cursor_; 66 | char character_; 67 | }; 68 | 69 | } // core 70 | } // yeti 71 | 72 | #endif // _YETI_CORE_MISC_PATTERN_FILE_PARSER_H_ 73 | -------------------------------------------------------------------------------- /include/yeti/core/misc/uuid.h: -------------------------------------------------------------------------------- 1 | //===-- yeti/core/misc/uuid.h ---------------------------*- mode: C++11 -*-===// 2 | // 3 | // _____ _ _ _ 4 | // | __|___ _ _ ___ _| |___| |_|_|___ ___ 5 | // | __| . | | | | . | .'| _| | . | | 6 | // |__| |___|___|_|_|___|__,|_| |_|___|_|_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | /// 12 | /// \file 13 | /// \brief Universally unique identifiers. 14 | /// 15 | //===----------------------------------------------------------------------===// 16 | 17 | #ifndef _YETI_CORE_MISC_UUID_H_ 18 | #define _YETI_CORE_MISC_UUID_H_ 19 | 20 | #include "yeti/config.h" 21 | #include "yeti/linkage.h" 22 | 23 | #include "yeti/core/types.h" 24 | 25 | namespace yeti { 26 | namespace core { 27 | 28 | namespace uuid { 29 | /// Generates a UUID v4. 30 | extern YETI_PUBLIC void generate(u8 uuid[16]); 31 | 32 | /// Parses @string into a @uuid. 33 | extern YETI_PUBLIC bool parse(const char *string, u8 uuid[16]); 34 | 35 | /// Converts @uuid to a human-readable representation in @pretty. 36 | extern YETI_PUBLIC void present(const u8 uuid[20], char pretty[36+1]); 37 | 38 | /// Determines if @string contains a UUID. 39 | extern YETI_PUBLIC bool validate(const char *string); 40 | } 41 | 42 | } // core 43 | } // yeti 44 | 45 | #endif // _YETI_CORE_MISC_UUID_H_ 46 | 47 | 48 | -------------------------------------------------------------------------------- /include/yeti/core/network/dns.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/include/yeti/core/network/dns.h -------------------------------------------------------------------------------- /include/yeti/core/network/http.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/include/yeti/core/network/http.h -------------------------------------------------------------------------------- /include/yeti/core/network/sockets.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/include/yeti/core/network/sockets.h -------------------------------------------------------------------------------- /include/yeti/core/platform/entropy.h: -------------------------------------------------------------------------------- 1 | //===-- yeti/core/platform/entropy.h --------------------*- mode: C++11 -*-===// 2 | // 3 | // _____ _ _ _ 4 | // | __|___ _ _ ___ _| |___| |_|_|___ ___ 5 | // | __| . | | | | . | .'| _| | . | | 6 | // |__| |___|___|_|_|___|__,|_| |_|___|_|_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | /// 12 | /// \file 13 | /// \brief Heat death of the universe accelerator. 14 | /// 15 | //===----------------------------------------------------------------------===// 16 | 17 | #ifndef _YETI_CORE_PLATFORM_ENTROPY_H_ 18 | #define _YETI_CORE_PLATFORM_ENTROPY_H_ 19 | 20 | #include "yeti/config.h" 21 | #include "yeti/linkage.h" 22 | 23 | #include "yeti/core/types.h" 24 | #include "yeti/core/support.h" 25 | 26 | namespace yeti { 27 | namespace core { 28 | 29 | /// Returns @amount bytes of entropy. 30 | /// 31 | /// \warning Will block until enough entropy is available. 32 | /// 33 | extern YETI_PUBLIC void entropy(void *buffer, size_t amount); 34 | 35 | } // core 36 | } // yeti 37 | 38 | #endif // _YETI_CORE_PLATFORM_ENTROPY_H_ 39 | -------------------------------------------------------------------------------- /include/yeti/core/platform/environment.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/include/yeti/core/platform/environment.h -------------------------------------------------------------------------------- /include/yeti/core/platform/event.h: -------------------------------------------------------------------------------- 1 | //===-- yeti/core/platform/event.h ----------------------*- mode: C++11 -*-===// 2 | // 3 | // _____ _ _ _ 4 | // | __|___ _ _ ___ _| |___| |_|_|___ ___ 5 | // | __| . | | | | . | .'| _| | . | | 6 | // |__| |___|___|_|_|___|__,|_| |_|___|_|_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | /// 12 | /// \file 13 | /// \brief Lightweight signaling primitive. 14 | /// 15 | //===----------------------------------------------------------------------===// 16 | 17 | #ifndef _YETI_CORE_PLATFORM_EVENT_H_ 18 | #define _YETI_CORE_PLATFORM_EVENT_H_ 19 | 20 | #include "yeti/config.h" 21 | #include "yeti/linkage.h" 22 | 23 | #include "yeti/core/types.h" 24 | #include "yeti/core/support.h" 25 | 26 | namespace yeti { 27 | namespace core { 28 | 29 | /// A lightweight signaling primitive. 30 | class YETI_PUBLIC Event { 31 | YETI_DISALLOW_COPYING(Event) 32 | 33 | public: 34 | /// \param @manual Requires manual reset after being signaled. 35 | Event(bool manual = false); 36 | 37 | ~Event(); 38 | 39 | public: 40 | /// \brief Signals the event. 41 | void signal(); 42 | 43 | /// \brief Unsignals the event. 44 | void unsignal(); 45 | 46 | /// \brief Determines if the event was signaled. 47 | /// \warning Will unsignal the event if *not* a manually unsignaled event. 48 | bool signaled(); 49 | 50 | /// \brief Waits for the eventt to be signaled. 51 | /// \note Will unsignal the event if *not* a manually unsignaled event. 52 | void wait(); 53 | 54 | private: 55 | struct Storage; 56 | Storage *storage_; 57 | }; 58 | 59 | } // core 60 | } // yeti 61 | 62 | #endif // _YETI_CORE_PLATFORM_EVENT_H_ 63 | -------------------------------------------------------------------------------- /include/yeti/core/platform/info.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/include/yeti/core/platform/info.h -------------------------------------------------------------------------------- /include/yeti/core/platform/lock.h: -------------------------------------------------------------------------------- 1 | //===-- yeti/core/platform/lock.h -----------------------*- mode: C++11 -*-===// 2 | // 3 | // _____ _ _ _ 4 | // | __|___ _ _ ___ _| |___| |_|_|___ ___ 5 | // | __| . | | | | . | .'| _| | . | | 6 | // |__| |___|___|_|_|___|__,|_| |_|___|_|_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | /// 12 | /// \file 13 | /// \brief Lightweight mutual exclusion primitive. 14 | /// 15 | //===----------------------------------------------------------------------===// 16 | 17 | #ifndef _YETI_CORE_PLATFORM_LOCK_H_ 18 | #define _YETI_CORE_PLATFORM_LOCK_H_ 19 | 20 | #include "yeti/config.h" 21 | #include "yeti/linkage.h" 22 | 23 | #include "yeti/core/types.h" 24 | #include "yeti/core/support.h" 25 | 26 | namespace yeti { 27 | namespace core { 28 | 29 | /// A lightweight mutual exclusion primitive. 30 | class YETI_PUBLIC Lock { 31 | YETI_DISALLOW_COPYING(Lock) 32 | 33 | public: 34 | Lock(); 35 | ~Lock(); 36 | 37 | public: 38 | /// \brief Acquire the lock, waiting on other threads indefinitely until it 39 | /// can be acquired. 40 | void acquire(); 41 | 42 | /// \brief Releases the lock, allowing other threads to acquire it. 43 | void release(); 44 | 45 | private: 46 | struct Storage; 47 | Storage *storage_; 48 | }; 49 | 50 | /// \def YETI_SCOPED_LOCK 51 | /// \brief Holds a lock for the duration of the current scope. 52 | #define YETI_SCOPED_LOCK(Lock) \ 53 | const ::yeti::core::ScopedLock YETI_PASTE(__scoped_lock__, __LINE__)(Lock); 54 | 55 | /// Holds a lock for the duration of its scope. 56 | class ScopedLock { 57 | YETI_DISALLOW_COPYING(ScopedLock) 58 | 59 | public: 60 | ScopedLock(Lock *lock) : lock_(lock) { lock_->acquire(); } 61 | ScopedLock(Lock &lock) : lock_(&lock) { lock_->acquire(); } 62 | ~ScopedLock() { lock_->release(); } 63 | 64 | private: 65 | Lock *lock_; 66 | }; 67 | 68 | } // core 69 | } // yeti 70 | 71 | #endif // _YETI_CORE_PLATFORM_LOCK_H_ 72 | -------------------------------------------------------------------------------- /include/yeti/core/platform/path.h: -------------------------------------------------------------------------------- 1 | //===-- yeti/core/platform/path.h -----------------------*- mode: C++11 -*-===// 2 | // 3 | // _____ _ _ _ 4 | // | __|___ _ _ ___ _| |___| |_|_|___ ___ 5 | // | __| . | | | | . | .'| _| | . | | 6 | // |__| |___|___|_|_|___|__,|_| |_|___|_|_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | // 12 | /// \file 13 | /// \brief Path manipulation utilities. 14 | // 15 | //===----------------------------------------------------------------------===// 16 | 17 | #ifndef _YETI_CORE_PLATFORM_PATH_H_ 18 | #define _YETI_CORE_PLATFORM_PATH_H_ 19 | 20 | #include "yeti/config.h" 21 | #include "yeti/linkage.h" 22 | 23 | #include "yeti/core/types.h" 24 | #include "yeti/core/support.h" 25 | 26 | namespace yeti { 27 | namespace core { 28 | 29 | namespace path { 30 | 31 | /// Preferred path seperator for the current platform. 32 | extern YETI_PUBLIC char seperator(); 33 | 34 | /// Modifies @path to use the current platforms preferred seperators, among 35 | /// other things. 36 | extern YETI_PUBLIC void canonicalize(char *path); 37 | 38 | /// Modifies @path to use forward slashes as path seperators. 39 | extern YETI_PUBLIC void unixify(char *path); 40 | 41 | /// Returns the file component of @path. 42 | extern YETI_PUBLIC const char *file(const char *path); 43 | 44 | /// Returns the extension of @path. 45 | extern YETI_PUBLIC const char *extension(const char *path); 46 | 47 | /// Copies the current working directory to @cwd. 48 | extern YETI_PUBLIC void cwd(char *cwd, size_t size); 49 | 50 | /// Performs a wildcard match of @path against @pattern. 51 | extern YETI_PUBLIC bool match(const char *pattern, const char *path); 52 | 53 | /// \copydoc yeti::core::path::match 54 | extern YETI_PUBLIC bool glob(const char *pattern, const char *path); 55 | 56 | } // path 57 | 58 | } // core 59 | } // yeti 60 | 61 | #endif // _YETI_CORE_PLATFORM_PATH_H_ 62 | -------------------------------------------------------------------------------- /include/yeti/core/platform/process.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/include/yeti/core/platform/process.h -------------------------------------------------------------------------------- /include/yeti/core/platform/processor.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/include/yeti/core/platform/processor.h -------------------------------------------------------------------------------- /include/yeti/core/platform/timer.h: -------------------------------------------------------------------------------- 1 | //===-- yeti/core/platform/timer.h ----------------------*- mode: C++11 -*-===// 2 | // 3 | // _____ _ _ _ 4 | // | __|___ _ _ ___ _| |___| |_|_|___ ___ 5 | // | __| . | | | | . | .'| _| | . | | 6 | // |__| |___|___|_|_|___|__,|_| |_|___|_|_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | /// 12 | /// \file 13 | /// \brief High resolution timing. 14 | /// 15 | //===----------------------------------------------------------------------===// 16 | 17 | #ifndef _YETI_CORE_PLATFORM_TIMER_H_ 18 | #define _YETI_CORE_PLATFORM_TIMER_H_ 19 | 20 | #include "yeti/config.h" 21 | #include "yeti/linkage.h" 22 | 23 | #include "yeti/core/types.h" 24 | #include "yeti/core/support.h" 25 | 26 | namespace yeti { 27 | namespace core { 28 | 29 | /// A high-resolution monotonically increasing timer. 30 | class YETI_PUBLIC Timer { 31 | YETI_DISALLOW_COPYING(Timer) 32 | 33 | public: 34 | Timer(); 35 | ~Timer(); 36 | 37 | public: 38 | /// \brief Resets the timer. 39 | void reset(); 40 | 41 | public: 42 | /// \brief Returns the number of seconds elapsed since the last reset. 43 | u64 secs() const; 44 | 45 | /// \brief Returns the number of milliseconds elapsed since the last reset. 46 | u64 msecs() const; 47 | 48 | /// \brief Returns the number of microseconds elapsed since the last reset. 49 | u64 usecs() const; 50 | 51 | /// \brief Returns the number of nanoseconds elapsed since the last reset. 52 | /// \warning Nanosecond resolution is not guaranteed on some platforms. 53 | u64 nsecs() const; 54 | 55 | private: 56 | /// \internal Ticks since last reset. 57 | u64 elapsed() const; 58 | 59 | private: 60 | u64 frequency_; 61 | u64 epoch_; 62 | }; 63 | 64 | } // core 65 | } // yeti 66 | 67 | #endif // _YETI_CORE_PLATFORM_TIMER_H_ 68 | -------------------------------------------------------------------------------- /include/yeti/core/support.h: -------------------------------------------------------------------------------- 1 | //===-- yeti/core/support.h -----------------------------*- mode: C++11 -*-===// 2 | // 3 | // _____ _ _ _ 4 | // | __|___ _ _ ___ _| |___| |_|_|___ ___ 5 | // | __| . | | | | . | .'| _| | . | | 6 | // |__| |___|___|_|_|___|__,|_| |_|___|_|_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | // 12 | /// \file 13 | /// \brief Plasters over compiler incompatibilities and idiosyncrasies. 14 | // 15 | //===----------------------------------------------------------------------===// 16 | 17 | #ifndef _YETI_CORE_SUPPORT_H_ 18 | #define _YETI_CORE_SUPPORT_H_ 19 | 20 | #include "yeti/config.h" 21 | #include "yeti/linkage.h" 22 | 23 | #include "yeti/core/support/macro.h" 24 | #include "yeti/core/support/usage.h" 25 | #include "yeti/core/support/inlining.h" 26 | #include "yeti/core/support/likeliness.h" 27 | #include "yeti/core/support/reachability.h" 28 | #include "yeti/core/support/rule_of_three.h" 29 | #include "yeti/core/support/thread_local_storage.h" 30 | #include "yeti/core/support/stack.h" 31 | #include "yeti/core/support/prefetch.h" 32 | #include "yeti/core/support/strings.h" 33 | 34 | #endif // _YETI_CORE_SUPPORT_H_ 35 | -------------------------------------------------------------------------------- /include/yeti/core/support/inlining.h: -------------------------------------------------------------------------------- 1 | //===-- yeti/core/support/inlining.h --------------------*- mode: C++11 -*-===// 2 | // 3 | // _____ _ _ _ 4 | // | __|___ _ _ ___ _| |___| |_|_|___ ___ 5 | // | __| . | | | | . | .'| _| | . | | 6 | // |__| |___|___|_|_|___|__,|_| |_|___|_|_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | /// 12 | /// \file 13 | /// \brief Defines pre-processor macros that assist in conveying to the 14 | /// compiler when code should be inlined. 15 | /// 16 | //===----------------------------------------------------------------------===// 17 | 18 | #ifndef _YETI_CORE_SUPPORT_INLINING_H_ 19 | #define _YETI_CORE_SUPPORT_INLINING_H_ 20 | 21 | /// \def YETI_INLINE 22 | /// \brief Code should be inlined. 23 | #if defined(DOXYGEN) 24 | #define YETI_INLINE 25 | #else 26 | #if defined(_MSC_VER) 27 | #define YETI_INLINE __forceinline 28 | #elif defined(__clang__) || defined(__GNUC__) 29 | #define YETI_INLINE __inline __attribute__ ((always_inline)) 30 | #endif 31 | #endif 32 | 33 | #endif // _YETI_CORE_SUPPORT_INLINING_H_ 34 | -------------------------------------------------------------------------------- /include/yeti/core/support/likeliness.h: -------------------------------------------------------------------------------- 1 | //===-- yeti/core/support/likeliness.h ------------------*- mode: C++11 -*-===// 2 | // 3 | // _____ _ _ _ 4 | // | __|___ _ _ ___ _| |___| |_|_|___ ___ 5 | // | __| . | | | | . | .'| _| | . | | 6 | // |__| |___|___|_|_|___|__,|_| |_|___|_|_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | /// 12 | /// \file 13 | /// \brief Defines pre-processor macros that assist in conveying to the 14 | /// compiler the probability of a branch occuring. 15 | /// 16 | //===----------------------------------------------------------------------===// 17 | 18 | #ifndef _YETI_CORE_SUPPORT_LIKELINESS_H_ 19 | #define _YETI_CORE_SUPPORT_LIKELINESS_H_ 20 | 21 | /// \def YETI_LIKELY 22 | /// \brief @Condition is likely to evaluate to be true. 23 | #if defined(DOXYGEN) 24 | #define YETI_LIKELY(Condition) (!!(Condition)) 25 | #else 26 | #if defined(__GNUC__) 27 | #define YETI_LIKELY(Condition) __builtin_expect(!!(Condition), 1) 28 | #else 29 | #define YETI_LIKELY(Condition) (!!(Condition)) 30 | #endif 31 | #endif 32 | 33 | /// \def YETI_UNLIKELY 34 | /// \brief @Condition is likely to evaluate to be false. 35 | #if defined(DOXYGEN) 36 | #define YETI_UNLIKELY(Condition) (!!(Condition)) 37 | #else 38 | #if defined(__GNUC__) 39 | #define YETI_UNLIKELY(Condition) __builtin_expect(!!(Condition), 0) 40 | #else 41 | #define YETI_UNLIKELY(Condition) (!!(Condition)) 42 | #endif 43 | #endif 44 | 45 | #endif // _YETI_CORE_SUPPORT_LIKELINESS_H_ 46 | -------------------------------------------------------------------------------- /include/yeti/core/support/prefetch.h: -------------------------------------------------------------------------------- 1 | //===-- yeti/core/support/prefetch.h --------------------*- mode: C++11 -*-===// 2 | // 3 | // _____ _ _ _ 4 | // | __|___ _ _ ___ _| |___| |_|_|___ ___ 5 | // | __| . | | | | . | .'| _| | . | | 6 | // |__| |___|___|_|_|___|__,|_| |_|___|_|_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | /// 12 | /// \file 13 | /// \brief Defines pre-processor macros that assist in conveying to the 14 | /// compiler to insert prefetch instructions. 15 | /// 16 | //===----------------------------------------------------------------------===// 17 | 18 | #ifndef _YETI_CORE_SUPPORT_PREFETCH_H_ 19 | #define _YETI_CORE_SUPPORT_PREFETCH_H_ 20 | 21 | #if YETI_ARCHITECTURE == YETI_ARCHITECTURE_X86 || \ 22 | YETI_ARCHITECTURE == YETI_ARCHITECTURE_X86_64 23 | #include 24 | #endif 25 | 26 | /// \def YETI_PREFETCH_L1 27 | /// \brief Fetch into lowest cache level for inclusive access. 28 | #if defined(DOXYGEN) 29 | #define YETI_PREFETCH_L1 30 | #endif 31 | 32 | /// \def YETI_PREFETCH_L2 33 | /// \brief Fetch into second lowest cache level for inclusive access. 34 | #if defined(DOXYGEN) 35 | #define YETI_PREFETCH_L2 36 | #endif 37 | 38 | /// \def YETI_PREFETCH_L3 39 | /// \brief Fetch into third lowest cache level for inclusive access. 40 | #if defined(DOXYGEN) 41 | #define YETI_PREFETCH_L3 42 | #endif 43 | 44 | /// \def YETI_PREFETCH_NTA 45 | /// \brief Fetch into lowest cache level and spill to memory on eviction. 46 | #if defined(DOXYGEN) 47 | #define YETI_PREFETCH_NTA 48 | #endif 49 | 50 | /// \def YETI_PREFETCH 51 | /// \brief Hint to prefetch @Address with @Hint. 52 | #if defined(DOXYGEN) 53 | #define YETI_PREFETCH(Address, Hint) 54 | #else 55 | #if YETI_ARCHITECTURE == YETI_ARCHITECTURE_X86 || \ 56 | YETI_ARCHITECTURE == YETI_ARCHITECTURE_X86_64 57 | #define YETI_PREFETCH_L1 _MM_HINT_T0 58 | #define YETI_PREFETCH_L2 _MM_HINT_T1 59 | #define YETI_PREFETCH_L3 _MM_HINT_T2 60 | #define YETI_PREFETCH_NTA _MM_HINT_NTA 61 | 62 | #define YETI_PREFETCH(Address, Hint) \ 63 | _mm_prefetch(((void *)Address), Hint) 64 | #else 65 | #define YETI_PREFETCH(Address, Hint) 66 | #endif 67 | #endif 68 | 69 | #endif // _YETI_CORE_SUPPORT_PREFETCH_H_ 70 | -------------------------------------------------------------------------------- /include/yeti/core/support/reachability.h: -------------------------------------------------------------------------------- 1 | //===-- yeti/core/support/reachability.h ----------------*- mode: C++11 -*-===// 2 | // 3 | // _____ _ _ _ 4 | // | __|___ _ _ ___ _| |___| |_|_|___ ___ 5 | // | __| . | | | | . | .'| _| | . | | 6 | // |__| |___|___|_|_|___|__,|_| |_|___|_|_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | /// 12 | /// \file 13 | /// \brief Defines pre-processor macros that assist in conveying to the 14 | /// compiler the reachability of code. 15 | /// 16 | //===----------------------------------------------------------------------===// 17 | 18 | #ifndef _YETI_CORE_SUPPORT_REACHABILITY_H_ 19 | #define _YETI_CORE_SUPPORT_REACHABILITY_H_ 20 | 21 | /// \def YETI_TRAP 22 | /// \brief Errant, but reachable, code path. 23 | #if defined(DOXYGEN) 24 | #define YETI_TRAP() 25 | #else 26 | #if defined(_MSC_VER) 27 | #define YETI_TRAP() __debugbreak() 28 | #elif defined(__GNUC__) 29 | #define YETI_TRAP() __builtin_trap() 30 | #endif 31 | #endif 32 | 33 | /// \def YETI_UNREACHABLE 34 | /// \brief Code is unreachable. 35 | #if defined(DOXYGEN) 36 | #define YETI_UNREACHABLE() 37 | #else 38 | #if defined(_MSC_VER) 39 | #define YETI_UNREACHABLE() __assume(0) 40 | #elif defined(__clang__) 41 | #define YETI_UNREACHABLE() __builtin_unreachable() 42 | #elif defined(__GNUC__) 43 | #if __GNUC_VERSION__ >= 40500 44 | #define YETI_UNREACHABLE() __builtin_unreachable() 45 | #else 46 | #include 47 | #define YETI_UNREACHABLE() \ 48 | do { ::signal(SIGTRAP); } while(0, 0) 49 | #endif 50 | #endif 51 | #endif 52 | 53 | #endif // _YETI_CORE_SUPPORT_REACHABILITY_H_ 54 | -------------------------------------------------------------------------------- /include/yeti/core/support/rule_of_three.h: -------------------------------------------------------------------------------- 1 | //===-- yeti/core/support/rule_of_three.h ---------------*- mode: C++11 -*-===// 2 | // 3 | // _____ _ _ _ 4 | // | __|___ _ _ ___ _| |___| |_|_|___ ___ 5 | // | __| . | | | | . | .'| _| | . | | 6 | // |__| |___|___|_|_|___|__,|_| |_|___|_|_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | /// 12 | /// \file 13 | /// \brief Defines pre-processor macros that assist in conveying the intented 14 | /// usage of classes' constructors, assignment operators, and destructors. 15 | /// 16 | //===----------------------------------------------------------------------===// 17 | 18 | #ifndef _YETI_CORE_SUPPORT_RULE_OF_THREE_H_ 19 | #define _YETI_CORE_SUPPORT_RULE_OF_THREE_H_ 20 | 21 | /// \def YETI_DISALLOW_CONSTRUCTION 22 | /// \brief Prevent construction of @_Class_name. 23 | #define YETI_DISALLOW_CONSTRUCTION(_Class_name) \ 24 | private: \ 25 | _Class_name(); \ 26 | ~_Class_name(); 27 | 28 | /// \def YETI_DISALLOW_COPYING 29 | /// \brief Prevent copying of @_Class_name. 30 | #define YETI_DISALLOW_COPYING(_Class_name) \ 31 | private: \ 32 | _Class_name (const _Class_name &); \ 33 | _Class_name &operator= (const _Class_name &); 34 | 35 | #endif // _YETI_CORE_SUPPORT_RULE_OF_THREE_H_ 36 | -------------------------------------------------------------------------------- /include/yeti/core/support/stack.h: -------------------------------------------------------------------------------- 1 | //===-- yeti/core/support/stack.h -----------------------*- mode: C++11 -*-===// 2 | // 3 | // _____ _ _ _ 4 | // | __|___ _ _ ___ _| |___| |_|_|___ ___ 5 | // | __| . | | | | . | .'| _| | . | | 6 | // |__| |___|___|_|_|___|__,|_| |_|___|_|_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | /// 12 | /// \file 13 | /// \brief Normalizes dynamic stack allocation. 14 | /// 15 | //===----------------------------------------------------------------------===// 16 | 17 | #ifndef _YETI_CORE_SUPPORT_STACK_H_ 18 | #define _YETI_CORE_SUPPORT_STACK_H_ 19 | 20 | #if YETI_COMPILER == YETI_COMPILER_MSVC 21 | #include 22 | 23 | #ifndef alloca 24 | #define alloca _alloca 25 | #endif 26 | #elif YETI_COMPILER == YETI_COMPILER_CLANG || \ 27 | YETI_COMPILER == YETI_COMPILER_GCC 28 | // Dynamic stack allocation is only inlined if `alloca.h` is included when 29 | // non-extended standards are specified on the command line. 30 | #include 31 | #endif 32 | 33 | #endif // _YETI_CORE_SUPPORT_STACK_H_ 34 | -------------------------------------------------------------------------------- /include/yeti/core/support/strings.h: -------------------------------------------------------------------------------- 1 | //===-- yeti/core/support/strings.h ---------------------*- mode: C++11 -*-===// 2 | // 3 | // _____ _ _ _ 4 | // | __|___ _ _ ___ _| |___| |_|_|___ ___ 5 | // | __| . | | | | . | .'| _| | . | | 6 | // |__| |___|___|_|_|___|__,|_| |_|___|_|_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | /// 12 | /// \file 13 | /// \brief Normalizes support for strings. 14 | /// 15 | //===----------------------------------------------------------------------===// 16 | 17 | #ifndef _YETI_CORE_SUPPORT_STRINGS_H_ 18 | #define _YETI_CORE_SUPPORT_STRINGS_H_ 19 | 20 | #include "yeti/linkage.h" 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace yeti { 27 | namespace core { 28 | 29 | namespace kludge { 30 | /// \internal 31 | /// @{ 32 | extern YETI_PUBLIC int vsnprintf(char *buffer, size_t size, const char *format, va_list ap); 33 | extern YETI_PUBLIC int snprintf(char *buffer, size_t size, const char *format, ...); 34 | /// @} 35 | } 36 | 37 | namespace string { 38 | /// \brief Compares @a to @b. 39 | /// \return True if @a and @b match. 40 | extern YETI_PUBLIC bool compare(const char *a, const char *b); 41 | 42 | /// \brief Compares up to @length characters of @a to @b. 43 | /// \return True if @a and @b match. 44 | extern YETI_PUBLIC bool compare(const char *a, const char *b, size_t length); 45 | } 46 | 47 | } // core 48 | } // yeti 49 | 50 | #if YETI_COMPILER == YETI_COMPILER_MSVC 51 | // Include prior to redefining otherwise we break things. 52 | #include 53 | 54 | // All because Microsoft has to do things their own stupid way... 55 | #define vsnprintf ::yeti::core::kludge::vsnprintf 56 | #define snprintf ::yeti::core::kludge::snprintf 57 | #endif 58 | 59 | #endif // _YETI_CORE_SUPPORT_STRINGS_H_ 60 | -------------------------------------------------------------------------------- /include/yeti/core/support/thread_local_storage.h: -------------------------------------------------------------------------------- 1 | //===-- yeti/core/support/thread_local_storage.h --------*- mode: C++11 -*-===// 2 | // 3 | // _____ _ _ _ 4 | // | __|___ _ _ ___ _| |___| |_|_|___ ___ 5 | // | __| . | | | | . | .'| _| | . | | 6 | // |__| |___|___|_|_|___|__,|_| |_|___|_|_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | /// 12 | /// \file 13 | /// \brief Defines a pre-processor macro that assist in conveying to the 14 | /// compiler that global variables should use thread-local storage. 15 | /// 16 | //===----------------------------------------------------------------------===// 17 | 18 | #ifndef _YETI_CORE_SUPPORT_THREAD_LOCAL_STORAGE_H_ 19 | #define _YETI_CORE_SUPPORT_THREAD_LOCAL_STORAGE_H_ 20 | 21 | /// \def YETI_THREAD_LOCAL 22 | /// \brief Marks a static variable as "thread local" meaning each thread 23 | /// has its own unique copy. 24 | #if defined(DOXYGEN) 25 | #define YETI_THREAD_LOCAL 26 | #else 27 | #if (__STDC_VERSION__ >= 201112L) && !defined(__STDC_NO_THREADS__) 28 | #define YETI_THREAD_LOCAL _Thread_local 29 | #else 30 | #if defined(_MSC_VER) 31 | #define YETI_THREAD_LOCAL __declspec(thread) 32 | #elif defined(__clang__) || defined(__GNUC__) 33 | #define YETI_THREAD_LOCAL __thread 34 | #endif 35 | #endif 36 | #endif 37 | 38 | #endif // _YETI_CORE_SUPPORT_THREAD_LOCAL_STORAGE_H_ 39 | -------------------------------------------------------------------------------- /include/yeti/core/support/usage.h: -------------------------------------------------------------------------------- 1 | //===-- yeti/core/support/usage.h -----------------------*- mode: C++11 -*-===// 2 | // 3 | // _____ _ _ _ 4 | // | __|___ _ _ ___ _| |___| |_|_|___ ___ 5 | // | __| . | | | | . | .'| _| | . | | 6 | // |__| |___|___|_|_|___|__,|_| |_|___|_|_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | /// 12 | /// \file 13 | /// \brief Defines pre-processor macros that assist in conveying to the 14 | /// compiler the usage of variables. 15 | /// 16 | //===----------------------------------------------------------------------===// 17 | 18 | #ifndef _YETI_CORE_SUPPORT_USAGE_H_ 19 | #define _YETI_CORE_SUPPORT_USAGE_H_ 20 | 21 | /// \def YETI_UNUSED 22 | /// \brief Unused argument. 23 | #if defined(DOXYGEN) 24 | #define YETI_UNUSED(_Argument) 25 | #else // !defined(DOXYGEN) 26 | #define YETI_UNUSED(_Argument) \ 27 | (void)(_Argument); 28 | #endif 29 | 30 | #endif // _YETI_CORE_SUPPORT_USAGE_H_ 31 | -------------------------------------------------------------------------------- /include/yeti/core/types.h: -------------------------------------------------------------------------------- 1 | //===-- yeti/core/types.h -------------------------------*- mode: C++11 -*-===// 2 | // 3 | // _____ _ _ _ 4 | // | __|___ _ _ ___ _| |___| |_|_|___ ___ 5 | // | __| . | | | | . | .'| _| | . | | 6 | // |__| |___|___|_|_|___|__,|_| |_|___|_|_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | // 12 | // TODO(mtwilliams): Document the purpose of this file. 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | #ifndef _YETI_CORE_TYPES_H_ 17 | #define _YETI_CORE_TYPES_H_ 18 | 19 | #include "yeti/config.h" 20 | #include "yeti/linkage.h" 21 | 22 | // TODO(mtwilliams): Provide fallbacks for shitty compilers. 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | YETI_BEGIN_EXTERN_C // { 30 | 31 | typedef uintptr_t yeti_uintptr_t; 32 | typedef ptrdiff_t yeti_ptrdiff_t; 33 | 34 | typedef size_t yeti_size_t; 35 | 36 | typedef int8_t yeti_int8_t; 37 | typedef uint8_t yeti_uint8_t; 38 | typedef int16_t yeti_int16_t; 39 | typedef uint16_t yeti_uint16_t; 40 | typedef int32_t yeti_int32_t; 41 | typedef uint32_t yeti_uint32_t; 42 | typedef int64_t yeti_int64_t; 43 | typedef uint64_t yeti_uint64_t; 44 | 45 | typedef float yeti_float32_t; 46 | typedef double yeti_float64_t; 47 | 48 | typedef bool yeti_bool_t; 49 | 50 | YETI_END_EXTERN_C // } 51 | 52 | namespace yeti { 53 | 54 | typedef ::yeti_int8_t i8; 55 | typedef ::yeti_uint8_t u8; 56 | typedef ::yeti_int16_t i16; 57 | typedef ::yeti_uint16_t u16; 58 | typedef ::yeti_int32_t i32; 59 | typedef ::yeti_uint32_t u32; 60 | typedef ::yeti_int64_t i64; 61 | typedef ::yeti_uint64_t u64; 62 | 63 | typedef ::yeti_float32_t f32; 64 | typedef ::yeti_float64_t f64; 65 | 66 | } // yeti 67 | 68 | #endif // _YETI_CORE_TYPES_H_ 69 | -------------------------------------------------------------------------------- /include/yeti/input.h: -------------------------------------------------------------------------------- 1 | //===-- yeti/input.h ------------------------------------*- mode: C++11 -*-===// 2 | // 3 | // __ __ _ _ 4 | // | | |___| |_|_| 5 | // |_ _| -_| _| | 6 | // |_| |___|_| |_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | /// 12 | /// \file 13 | /// \brief Because you're out of control... 14 | /// 15 | //===----------------------------------------------------------------------===// 16 | 17 | #ifndef _YETI_INPUT_H_ 18 | #define _YETI_INPUT_H_ 19 | 20 | #include "yeti/input/keyboard.h" 21 | #include "yeti/input/mouse.h" 22 | 23 | #include "yeti/input/feeder.h" 24 | 25 | #endif // _YETI_INPUT_H_ 26 | -------------------------------------------------------------------------------- /include/yeti/input/feeder.h: -------------------------------------------------------------------------------- 1 | //===-- yeti/input/feeder.h -----------------------------*- mode: C++11 -*-===// 2 | // 3 | // __ __ _ _ 4 | // | | |___| |_|_| 5 | // |_ _| -_| _| | 6 | // |_| |___|_| |_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | // 12 | // TODO(mtwilliams): Document the purpose of this file. 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | #ifndef _YETI_INPUT_FEEDER_H_ 17 | #define _YETI_INPUT_FEEDER_H_ 18 | 19 | #include "yeti/core.h" 20 | 21 | namespace yeti { 22 | 23 | // See `yeti/window.h`. 24 | class Window; 25 | 26 | namespace input { 27 | 28 | /// \internal Watches @window for input and feeds into the pertinent singletons. 29 | extern YETI_PUBLIC void from(const Window *window); 30 | 31 | } // input 32 | 33 | } // yeti 34 | 35 | #endif // _YETI_INPUT_FEEDER_H_ 36 | -------------------------------------------------------------------------------- /include/yeti/input/gamepad.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/include/yeti/input/gamepad.h -------------------------------------------------------------------------------- /include/yeti/input/joystick.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/include/yeti/input/joystick.h -------------------------------------------------------------------------------- /include/yeti/input/keyboard.h: -------------------------------------------------------------------------------- 1 | //===-- yeti/input/keyboard.h ---------------------------*- mode: C++11 -*-===// 2 | // 3 | // __ __ _ _ 4 | // | | |___| |_|_| 5 | // |_ _| -_| _| | 6 | // |_| |___|_| |_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | // 12 | // TODO(mtwilliams): Document the purpose of this file. 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | #ifndef _YETI_INPUT_KEYBOARD_H_ 17 | #define _YETI_INPUT_KEYBOARD_H_ 18 | 19 | #include "yeti/core.h" 20 | 21 | namespace yeti { 22 | 23 | namespace Keys { 24 | enum _ { 25 | #define _(Id, Mnemonic, _) Mnemonic = Id, 26 | #include "yeti/input/keys.inl" 27 | #undef _ 28 | 29 | _COUNT 30 | }; 31 | } typedef Keys::_ Key; 32 | 33 | namespace Keyboard { 34 | 35 | /// Returns whether a keyboard is connected and functioning. 36 | extern YETI_PUBLIC bool connected(); 37 | extern YETI_PUBLIC bool disconnected(); 38 | 39 | /// Returns whether the @key is up. 40 | extern YETI_PUBLIC bool up(const Key key); 41 | 42 | /// Returns whether the @key is down. 43 | extern YETI_PUBLIC bool down(const Key key); 44 | 45 | /// Returns whether the @key was pressed this frame. 46 | extern YETI_PUBLIC bool pressed(const Key key); 47 | 48 | /// Returns whether the @key has been held down for more than one frame. 49 | extern YETI_PUBLIC bool held(const Key key); 50 | 51 | /// Returns whether the @key was released this frame. 52 | extern YETI_PUBLIC bool released(const Key key); 53 | 54 | /// \internal Keyboard event from platform. 55 | struct YETI_PRIVATE Event { 56 | enum Type { 57 | // Key was pressed. 58 | PRESSED = 1, 59 | // Key was released. 60 | RELEASED = 2, 61 | }; 62 | 63 | Type type; 64 | 65 | union { 66 | struct { Key key; } pressed; 67 | struct { Key key; } released; 68 | }; 69 | 70 | Event() { 71 | core::memory::zero((void *)this, sizeof(Event)); 72 | } 73 | 74 | Event(const Event &event) { 75 | core::memory::copy((const void *)&event, (void *)this, sizeof(Event)); 76 | } 77 | 78 | Event operator=(const Event &event) { 79 | core::memory::copy((const void *)&event, (void *)this, sizeof(Event)); 80 | return *this; 81 | } 82 | }; 83 | 84 | /// \internal Handles @event. 85 | extern YETI_PRIVATE void handle(const Event event); 86 | 87 | /// \internal 88 | extern YETI_PRIVATE void update(); 89 | 90 | } // Keyboard 91 | 92 | } // yeti 93 | 94 | #endif // _YETI_INPUT_KEYBOARD_H_ 95 | -------------------------------------------------------------------------------- /include/yeti/input/tablet.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/include/yeti/input/tablet.h -------------------------------------------------------------------------------- /include/yeti/input/touchscreen.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/include/yeti/input/touchscreen.h -------------------------------------------------------------------------------- /include/yeti/kludge.h: -------------------------------------------------------------------------------- 1 | //===-- yeti/kludge.h -----------------------------------*- mode: C++11 -*-===// 2 | // 3 | // __ __ _ _ 4 | // | | |___| |_|_| 5 | // |_ _| -_| _| | 6 | // |_| |___|_| |_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | 12 | #ifdef _MSC_VER 13 | // Shut up about non-standard extensions. 14 | #pragma warning(disable: 4200 4201) 15 | 16 | // Disable warnings about types marked public when dynamically linking. 17 | #pragma warning(disable: 4251) 18 | 19 | // Disable warnings about synchronous exception handling. 20 | #pragma warning(disable: 4577) 21 | #endif 22 | 23 | #ifdef _MSC_VER 24 | // We don't care about buffer overflows, at least for the majority of our inputs. 25 | #define _CRT_SECURE_NO_WARNINGS 1 26 | #endif 27 | -------------------------------------------------------------------------------- /include/yeti/level.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/include/yeti/level.h -------------------------------------------------------------------------------- /include/yeti/math.h: -------------------------------------------------------------------------------- 1 | //===-- yeti/math.h -------------------------------------*- mode: C++11 -*-===// 2 | // 3 | // __ __ _ _ 4 | // | | |___| |_|_| 5 | // |_ _| -_| _| | 6 | // |_| |___|_| |_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | /// 12 | /// \file 13 | /// \brief For all of your math and magic needs. 14 | /// 15 | //===----------------------------------------------------------------------===// 16 | 17 | #ifndef _YETI_MATH_H_ 18 | #define _YETI_MATH_H_ 19 | 20 | #include 21 | 22 | #include "yeti/math/constants.h" 23 | #include "yeti/math/conversions.h" 24 | 25 | #include "yeti/math/vec2.h" 26 | #include "yeti/math/vec3.h" 27 | #include "yeti/math/vec4.h" 28 | 29 | #include "yeti/math/quaternion.h" 30 | 31 | #include "yeti/math/mat4.h" 32 | 33 | #endif // _YETI_MATH_H_ 34 | -------------------------------------------------------------------------------- /include/yeti/math/aabb.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/include/yeti/math/aabb.h -------------------------------------------------------------------------------- /include/yeti/math/constants.h: -------------------------------------------------------------------------------- 1 | //===-- yeti/math/constants.h ---------------------------*- mode: C++11 -*-===// 2 | // 3 | // __ __ _ _ 4 | // | | |___| |_|_| 5 | // |_ _| -_| _| | 6 | // |_| |___|_| |_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | /// 12 | /// \file 13 | /// \brief Mathematical constants. 14 | /// 15 | //===----------------------------------------------------------------------===// 16 | 17 | #ifndef _YETI_MATH_CONSTANTS_H_ 18 | #define _YETI_MATH_CONSTANTS_H_ 19 | 20 | #include "yeti/core.h" 21 | 22 | namespace yeti { 23 | 24 | /// \brief Euler's constant. 25 | /// \detail The limit of `(1 + 1/n) * n` as `n` approaches infinity. 26 | static const f32 EULER = 2.71828182845904523536f; 27 | 28 | /// \brief Ratio of a circle's circumference to its diameter. 29 | static const f32 PI = 3.14159265358979323846264338327950288f; 30 | 31 | /// \brief Twice as good as Pi. 32 | /// \see yeti::PI 33 | static const f32 TAU = 2.f * PI; 34 | 35 | } // yeti 36 | 37 | #endif // _YETI_MATH_CONSTANTS_H_ 38 | -------------------------------------------------------------------------------- /include/yeti/math/conversions.h: -------------------------------------------------------------------------------- 1 | //===-- yeti/math/conversions.h -------------------------*- mode: C++11 -*-===// 2 | // 3 | // __ __ _ _ 4 | // | | |___| |_|_| 5 | // |_ _| -_| _| | 6 | // |_| |___|_| |_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | /// 12 | /// \file 13 | /// \brief Various unit conversion helpers. 14 | /// 15 | //===----------------------------------------------------------------------===// 16 | 17 | #ifndef _YETI_MATH_CONVERSIONS_H_ 18 | #define _YETI_MATH_CONVERSIONS_H_ 19 | 20 | #include "yeti/core.h" 21 | 22 | #include "yeti/math/constants.h" 23 | 24 | #include 25 | 26 | namespace yeti { 27 | 28 | // PERF(mtwillianms): Mark as `constexpr` when possible. 29 | 30 | /// \brief Converts degrees to radians. 31 | YETI_INLINE f32 degrees_to_radians(const f32 degrees) { 32 | return degrees * (180.f / PI); 33 | } 34 | 35 | /// \brief Converts radians to degrees. 36 | YETI_INLINE f32 radians_to_degrees(const f32 radians) { 37 | return radians * (PI / 180.f); 38 | } 39 | 40 | } // yeti 41 | 42 | #endif // _YETI_MATH_CONVERSIONS_H_ 43 | -------------------------------------------------------------------------------- /include/yeti/math/frustum.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/include/yeti/math/frustum.h -------------------------------------------------------------------------------- /include/yeti/math/line.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/include/yeti/math/line.h -------------------------------------------------------------------------------- /include/yeti/math/plane.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/include/yeti/math/plane.h -------------------------------------------------------------------------------- /include/yeti/math/ray.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/include/yeti/math/ray.h -------------------------------------------------------------------------------- /include/yeti/math/sphere.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/include/yeti/math/sphere.h -------------------------------------------------------------------------------- /include/yeti/optimized_resource_database.h: -------------------------------------------------------------------------------- 1 | //===-- yeti/optimized_resource_database.h --------------*- mode: C++11 -*-===// 2 | // 3 | // __ __ _ _ 4 | // | | |___| |_|_| 5 | // |_ _| -_| _| | 6 | // |_| |___|_| |_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | // 12 | // TODO(mtwilliams): Document the purpose of this file. 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | #ifndef _YETI_OPTIMIZED_RESOURCE_DATABASE_H_ 17 | #define _YETI_OPTIMIZED_RESOURCE_DATABASE_H_ 18 | 19 | #include "yeti/resource_database.h" 20 | 21 | namespace yeti { 22 | 23 | /// ... 24 | class YETI_PUBLIC OptimizedResourceDatabase : public ResourceDatabase { 25 | YETI_DISALLOW_COPYING(OptimizedResourceDatabase) 26 | 27 | private: 28 | OptimizedResourceDatabase(); 29 | ~OptimizedResourceDatabase(); 30 | 31 | public: 32 | static OptimizedResourceDatabase *open_or_create(const char *path); 33 | void close(); 34 | }; 35 | 36 | } // yeti 37 | 38 | #endif // _YETI_OPTIMIZED_RESOURCE_DATABASE_H_ 39 | -------------------------------------------------------------------------------- /include/yeti/physics/raycast.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/include/yeti/physics/raycast.h -------------------------------------------------------------------------------- /include/yeti/resource_bundle.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/include/yeti/resource_bundle.h -------------------------------------------------------------------------------- /include/yeti/resource_manager.h: -------------------------------------------------------------------------------- 1 | //===-- yeti/resource_manager.h -------------------------*- mode: C++11 -*-===// 2 | // 3 | // __ __ _ _ 4 | // | | |___| |_|_| 5 | // |_ _| -_| _| | 6 | // |_| |___|_| |_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | // 12 | // TODO(mtwilliams): Document the purpose of this file. 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | #ifndef _YETI_RESOURCE_MANAGER_H_ 17 | #define _YETI_RESOURCE_MANAGER_H_ 18 | 19 | #include "yeti/core.h" 20 | 21 | #include "yeti/resource.h" 22 | 23 | namespace yeti { 24 | 25 | class ResourceDatabase; 26 | 27 | namespace resource_manager { 28 | 29 | struct Config { 30 | /// Path to resource database. 31 | /// \note Resources cannot be loaded or unloaded if `NULL`. 32 | const char *database; 33 | 34 | /// Toggles automatic loading of resources as required rather than loading 35 | /// through packages. 36 | bool autoload; 37 | }; 38 | 39 | extern YETI_PUBLIC void initialize(const Config &config); 40 | 41 | extern YETI_PUBLIC void shutdown(); 42 | 43 | /// Returns resource database. 44 | extern YETI_PUBLIC ResourceDatabase *database(); 45 | 46 | extern YETI_PUBLIC bool autoloads(); 47 | 48 | extern YETI_PUBLIC bool available(Resource::Id id); 49 | 50 | extern YETI_PUBLIC Resource *lookup(Resource::Id id); 51 | 52 | extern YETI_PUBLIC Resource *load(Resource::Id id); 53 | 54 | extern YETI_PUBLIC void reload(Resource::Id id); 55 | 56 | extern YETI_PUBLIC void unload(Resource *resource); 57 | 58 | extern YETI_PUBLIC Resource::State state(Resource::Id id); 59 | 60 | extern YETI_PUBLIC Resource::State state(Resource *resource); 61 | 62 | } // resource_manager 63 | 64 | } // yeti 65 | 66 | #endif // _YETI_RESOURCE_MANAGER_H_ 67 | 68 | -------------------------------------------------------------------------------- /include/yeti/resource_package.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/include/yeti/resource_package.h -------------------------------------------------------------------------------- /include/yeti/resources/data_resource.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/include/yeti/resources/data_resource.h -------------------------------------------------------------------------------- /include/yeti/resources/decal_resource.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/include/yeti/resources/decal_resource.h -------------------------------------------------------------------------------- /include/yeti/resources/effect_resource.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/include/yeti/resources/effect_resource.h -------------------------------------------------------------------------------- /include/yeti/resources/entity_resource.h: -------------------------------------------------------------------------------- 1 | //===-- yeti/resources/entity_resource.h ----------------*- mode: C++11 -*-===// 2 | // 3 | // __ __ _ _ 4 | // | | |___| |_|_| 5 | // |_ _| -_| _| | 6 | // |_| |___|_| |_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | // 12 | // TODO(mtwilliams): Document the purpose of this file. 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | #ifndef _YETI_ENTITY_RESOURCE_H_ 17 | #define _YETI_ENTITY_RESOURCE_H_ 18 | 19 | #include "yeti/core.h" 20 | 21 | #include "yeti/resource.h" 22 | 23 | namespace yeti { 24 | 25 | class YETI_PUBLIC EntityResource : public Resource { 26 | YETI_DISALLOW_COPYING(EntityResource) 27 | 28 | private: 29 | EntityResource(Resource::Id id); 30 | ~EntityResource(); 31 | 32 | public: 33 | /// \internal 34 | static const Resource::Type *type(); 35 | 36 | private: 37 | static Resource *prepare(Resource::Id id); 38 | 39 | static void load(Resource *resource, const Resource::Data &data); 40 | static void unload(Resource *resource); 41 | 42 | static bool compile(const resource_compiler::Environment *env, 43 | const resource_compiler::Input *input, 44 | const resource_compiler::Output *output); 45 | 46 | static bool compatible(u32 version); 47 | 48 | private: 49 | // TODO(mtwilliams): Components. 50 | }; 51 | 52 | } // yeti 53 | 54 | #endif // _YETI_ENTITY_RESOURCE_H_ 55 | -------------------------------------------------------------------------------- /include/yeti/resources/level_resource.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/include/yeti/resources/level_resource.h -------------------------------------------------------------------------------- /include/yeti/resources/material_resource.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/include/yeti/resources/material_resource.h -------------------------------------------------------------------------------- /include/yeti/resources/mesh_resource.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/include/yeti/resources/mesh_resource.h -------------------------------------------------------------------------------- /include/yeti/resources/prefab_resource.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/include/yeti/resources/prefab_resource.h -------------------------------------------------------------------------------- /include/yeti/resources/render_config_resource.h: -------------------------------------------------------------------------------- 1 | //===-- yeti/resources/render_config_resource.h ---------*- mode: C++11 -*-===// 2 | // 3 | // __ __ _ _ 4 | // | | |___| |_|_| 5 | // |_ _| -_| _| | 6 | // |_| |___|_| |_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | // 12 | // TODO(mtwilliams): Document the purpose of this file. 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | #ifndef _YETI_RENDER_CONFIG_RESOURCE_H_ 17 | #define _YETI_RENDER_CONFIG_RESOURCE_H_ 18 | 19 | #include "yeti/core.h" 20 | 21 | #include "yeti/resource.h" 22 | 23 | namespace yeti { 24 | 25 | class YETI_PUBLIC RenderConfigResource : public Resource { 26 | YETI_DISALLOW_COPYING(RenderConfigResource) 27 | 28 | private: 29 | RenderConfigResource(Resource::Id id); 30 | ~RenderConfigResource(); 31 | 32 | public: 33 | /// \internal 34 | static const Resource::Type *type(); 35 | 36 | private: 37 | static Resource *prepare(Resource::Id id); 38 | 39 | static void load(Resource *resource, const Resource::Data &data); 40 | static void unload(Resource *resource); 41 | 42 | static bool compile(const resource_compiler::Environment *env, 43 | const resource_compiler::Input *input, 44 | const resource_compiler::Output *output); 45 | 46 | static bool compatible(u32 version); 47 | 48 | private: 49 | void *memory_resident_data_; 50 | }; 51 | 52 | } // yeti 53 | 54 | #endif // _YETI_RENDER_CONFIG_RESOURCE_H_ 55 | -------------------------------------------------------------------------------- /include/yeti/resources/script_resource.h: -------------------------------------------------------------------------------- 1 | //===-- yeti/resources/script_resource.h ----------------*- mode: C++11 -*-===// 2 | // 3 | // __ __ _ _ 4 | // | | |___| |_|_| 5 | // |_ _| -_| _| | 6 | // |_| |___|_| |_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | // 12 | // TODO(mtwilliams): Document the purpose of this file. 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | #ifndef _YETI_SCRIPT_RESOURCE_H_ 17 | #define _YETI_SCRIPT_RESOURCE_H_ 18 | 19 | #include "yeti/core.h" 20 | 21 | #include "yeti/resource.h" 22 | 23 | namespace yeti { 24 | 25 | class Script; 26 | 27 | class YETI_PUBLIC ScriptResource : public Resource { 28 | YETI_DISALLOW_COPYING(ScriptResource) 29 | 30 | private: 31 | friend class Script; 32 | 33 | private: 34 | ScriptResource(Resource::Id id); 35 | ~ScriptResource(); 36 | 37 | public: 38 | /// \internal 39 | static const Resource::Type *type(); 40 | 41 | private: 42 | static Resource *prepare(Resource::Id id); 43 | 44 | static void load(Resource *resource, const Resource::Data &data); 45 | static void unload(Resource *resource); 46 | 47 | static bool compile(const resource_compiler::Environment *env, 48 | const resource_compiler::Input *input, 49 | const resource_compiler::Output *output); 50 | 51 | static bool compatible(u32 version); 52 | 53 | private: 54 | char path_[256]; 55 | const char *bytecode_; 56 | size_t bytecode_len_; 57 | }; 58 | 59 | } // yeti 60 | 61 | #endif // _YETI_SCRIPT_RESOURCE_H_ 62 | -------------------------------------------------------------------------------- /include/yeti/resources/shader_resource.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/include/yeti/resources/shader_resource.h -------------------------------------------------------------------------------- /include/yeti/resources/texture_resource.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/include/yeti/resources/texture_resource.h -------------------------------------------------------------------------------- /include/yeti/script/binding.h: -------------------------------------------------------------------------------- 1 | //===-- yeti/script/binding.h ---------------------------*- mode: C++11 -*-===// 2 | // 3 | // __ __ _ _ 4 | // | | |___| |_|_| 5 | // |_ _| -_| _| | 6 | // |_| |___|_| |_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | // 12 | // TODO(mtwilliams): Document the purpose of this file. 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | #ifndef _YETI_SCRIPT_BINDING_H_ 17 | #define _YETI_SCRIPT_BINDING_H_ 18 | 19 | #include "yeti/core.h" 20 | 21 | extern "C" { 22 | #include 23 | #include 24 | #include 25 | #include 26 | } 27 | 28 | #include "yeti/script.h" 29 | #include "yeti/script/environment.h" 30 | 31 | #endif // _YETI_SCRIPT_BINDING_H_ 32 | -------------------------------------------------------------------------------- /include/yeti/script/bindings/application_if.h: -------------------------------------------------------------------------------- 1 | //===-- yeti/script/bindings/application_if.h -----------*- mode: C++11 -*-===// 2 | // 3 | // __ __ _ _ 4 | // | | |___| |_|_| 5 | // |_ _| -_| _| | 6 | // |_| |___|_| |_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | // 12 | // TODO(mtwilliams): Document the purpose of this file. 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | #ifndef _YETI_SCRIPT_BINDINGS_APPLICATION_IF_H_ 17 | #define _YETI_SCRIPT_BINDINGS_APPLICATION_IF_H_ 18 | 19 | #include "yeti/script/binding.h" 20 | 21 | namespace yeti { 22 | 23 | // See `yeti/application.h`. 24 | class Application; 25 | 26 | namespace application_if { 27 | 28 | /// \internal 29 | extern YETI_PRIVATE Application *instance(lua_State *L); 30 | 31 | /// ... 32 | extern YETI_PUBLIC void expose(Script *script, Application *app); 33 | 34 | } // application_if 35 | 36 | } // yeti 37 | 38 | #endif // _YETI_SCRIPT_BINDINGS_APPLICATION_IF_H_ 39 | -------------------------------------------------------------------------------- /include/yeti/script/bindings/camera_if.h: -------------------------------------------------------------------------------- 1 | //===-- yeti/script/bindings/camera_if.h ----------------*- mode: C++11 -*-===// 2 | // 3 | // __ __ _ _ 4 | // | | |___| |_|_| 5 | // |_ _| -_| _| | 6 | // |_| |___|_| |_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | // 12 | // TODO(mtwilliams): Document the purpose of this file. 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | #ifndef _YETI_SCRIPT_BINDINGS_CAMERA_IF_H_ 17 | #define _YETI_SCRIPT_BINDINGS_CAMERA_IF_H_ 18 | 19 | #include "yeti/script/binding.h" 20 | 21 | namespace yeti { 22 | namespace camera_if { 23 | 24 | /// ... 25 | extern YETI_PUBLIC void expose(Script *script); 26 | 27 | } // camera_if 28 | } // yeti 29 | 30 | #endif // _YETI_SCRIPT_BINDINGS_CAMERA_IF_H_ 31 | -------------------------------------------------------------------------------- /include/yeti/script/bindings/component_if.h: -------------------------------------------------------------------------------- 1 | //===-- yeti/script/bindings/component_if.h -------------*- mode: C++11 -*-===// 2 | // 3 | // __ __ _ _ 4 | // | | |___| |_|_| 5 | // |_ _| -_| _| | 6 | // |_| |___|_| |_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | // 12 | // TODO(mtwilliams): Document the purpose of this file. 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | #ifndef _YETI_SCRIPT_BINDINGS_COMPONENT_IF_H_ 17 | #define _YETI_SCRIPT_BINDINGS_COMPONENT_IF_H_ 18 | 19 | #include "yeti/script/binding.h" 20 | 21 | #include "yeti/component.h" 22 | 23 | namespace yeti { 24 | 25 | namespace component_if { 26 | 27 | // TODO(mtwilliams): Expose handle and instances dichotomy to Lua. 28 | 29 | struct Handle { 30 | Component::Id type; 31 | Component::Handle handle; 32 | }; 33 | 34 | /// \brief Checks if the value on @L's stack at @index is a handle to a 35 | /// component of @type. 36 | extern YETI_PUBLIC bool check(lua_State *L, int index, Component::Id type); 37 | 38 | /// \brief Checks if the value on @L's stack at @index is a handle to the right 39 | /// @type of component then returns it. 40 | extern YETI_PUBLIC const Handle &cast(lua_State *L, int index, Component::Id type); 41 | 42 | /// \brief Pushes @handle onto @L's stack. 43 | extern YETI_PUBLIC void push(lua_State *L, Component::Id type, Component::Handle handle); 44 | 45 | /// ... 46 | extern YETI_PUBLIC void expose(Script *script); 47 | 48 | } // component_if 49 | 50 | } // yeti 51 | 52 | #endif // _YETI_SCRIPT_BINDINGS_COMPONENT_IF_H_ 53 | -------------------------------------------------------------------------------- /include/yeti/script/bindings/entity_if.h: -------------------------------------------------------------------------------- 1 | //===-- yeti/script/bindingsentity_if.h -------------------------*- mode: C++11 -*-===// 2 | // 3 | // __ __ _ _ 4 | // | | |___| |_|_| 5 | // |_ _| -_| _| | 6 | // |_| |___|_| |_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | // 12 | // TODO(mtwilliams): Document the purpose of this file. 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | #ifndef _YETI_SCRIPT_BINDINGS_ENTITY_IF_H_ 17 | #define _YETI_SCRIPT_BINDINGS_ENTITY_IF_H_ 18 | 19 | #include "yeti/script/binding.h" 20 | 21 | #include "yeti/entity.h" 22 | 23 | namespace yeti { 24 | 25 | // Forward declared for `entity_if::Handle`. 26 | class World; 27 | 28 | namespace entity_if { 29 | 30 | struct Handle { 31 | World *world; 32 | Entity entity; 33 | }; 34 | 35 | /// \brief Checks if the value on @L's stack at @idx is a handle to an entity. 36 | extern YETI_PUBLIC bool check(lua_State *L, int idx); 37 | 38 | /// \brief Checks if the value on @L's stack at @idx is a handle to an entity 39 | /// then returns it. 40 | extern YETI_PUBLIC const Handle &cast(lua_State *L, int idx); 41 | 42 | /// \brief Pushes @handle onto @L's stack. 43 | extern YETI_PUBLIC void push(lua_State *L, const Handle &handle); 44 | 45 | /// ... 46 | extern YETI_PUBLIC void expose(Script *script); 47 | 48 | } // entity_if 49 | 50 | } // yeti 51 | 52 | #endif // _YETI_SCRIPT_BINDINGS_ENTITY_IF_H_ 53 | -------------------------------------------------------------------------------- /include/yeti/script/bindings/keyboard_if.h: -------------------------------------------------------------------------------- 1 | //===-- yeti/script/bindings/keyboard_if.h --------------*- mode: C++11 -*-===// 2 | // 3 | // __ __ _ _ 4 | // | | |___| |_|_| 5 | // |_ _| -_| _| | 6 | // |_| |___|_| |_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | // 12 | // TODO(mtwilliams): Document the purpose of this file. 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | #ifndef _YETI_SCRIPT_BINDINGS_KEYBOARD_IF_H_ 17 | #define _YETI_SCRIPT_BINDINGS_KEYBOARD_IF_H_ 18 | 19 | #include "yeti/script/binding.h" 20 | 21 | namespace yeti { 22 | namespace keyboard_if { 23 | 24 | /// ... 25 | extern YETI_PUBLIC void expose(Script *script); 26 | 27 | } // keyboard_if 28 | } // yeti 29 | 30 | #endif // _YETI_SCRIPT_BINDINGS_KEYBOARD_IF_H_ 31 | -------------------------------------------------------------------------------- /include/yeti/script/bindings/light_if.h: -------------------------------------------------------------------------------- 1 | //===-- yeti/script/bindings/light_if.h -----------------*- mode: C++11 -*-===// 2 | // 3 | // __ __ _ _ 4 | // | | |___| |_|_| 5 | // |_ _| -_| _| | 6 | // |_| |___|_| |_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | // 12 | // TODO(mtwilliams): Document the purpose of this file. 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | #ifndef _YETI_SCRIPT_BINDINGS_LIGHT_IF_H_ 17 | #define _YETI_SCRIPT_BINDINGS_LIGHT_IF_H_ 18 | 19 | #include "yeti/script/binding.h" 20 | 21 | namespace yeti { 22 | namespace light_if { 23 | 24 | /// ... 25 | extern YETI_PUBLIC void expose(Script *script); 26 | 27 | } // light_if 28 | } // yeti 29 | 30 | #endif // _YETI_SCRIPT_BINDINGS_LIGHT_IF_H_ 31 | -------------------------------------------------------------------------------- /include/yeti/script/bindings/math_if.h: -------------------------------------------------------------------------------- 1 | //===-- yeti/script/bindings/math_if.h ------------------*- mode: C++11 -*-===// 2 | // 3 | // __ __ _ _ 4 | // | | |___| |_|_| 5 | // |_ _| -_| _| | 6 | // |_| |___|_| |_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | // 12 | // TODO(mtwilliams): Document the purpose of this file. 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | #ifndef _YETI_SCRIPT_BINDINGS_MATH_IF_H_ 17 | #define _YETI_SCRIPT_BINDINGS_MATH_IF_H_ 18 | 19 | #include "yeti/script/binding.h" 20 | 21 | namespace yeti { 22 | 23 | namespace math_if { 24 | 25 | /// ... 26 | extern YETI_PUBLIC void expose(Script *script); 27 | 28 | } // math_if 29 | 30 | } // yeti 31 | 32 | #endif // _YETI_SCRIPT_BINDINGS_MATH_IF_H_ 33 | -------------------------------------------------------------------------------- /include/yeti/script/bindings/mouse_if.h: -------------------------------------------------------------------------------- 1 | //===-- yeti/script/bindings/mouse_if.h -----------------*- mode: C++11 -*-===// 2 | // 3 | // __ __ _ _ 4 | // | | |___| |_|_| 5 | // |_ _| -_| _| | 6 | // |_| |___|_| |_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | // 12 | // TODO(mtwilliams): Document the purpose of this file. 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | #ifndef _YETI_SCRIPT_BINDINGS_MOUSE_IF_H_ 17 | #define _YETI_SCRIPT_BINDINGS_MOUSE_IF_H_ 18 | 19 | #include "yeti/script/binding.h" 20 | 21 | namespace yeti { 22 | namespace mouse_if { 23 | 24 | /// ... 25 | extern YETI_PUBLIC void expose(Script *script); 26 | 27 | } // mouse_if 28 | } // yeti 29 | 30 | #endif // _YETI_SCRIPT_BINDINGS_MOUSE_IF_H_ 31 | -------------------------------------------------------------------------------- /include/yeti/script/bindings/transform_if.h: -------------------------------------------------------------------------------- 1 | //===-- yeti/script/bindingstransform_if.h --------------*- mode: C++11 -*-===// 2 | // 3 | // __ __ _ _ 4 | // | | |___| |_|_| 5 | // |_ _| -_| _| | 6 | // |_| |___|_| |_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | // 12 | // TODO(mtwilliams): Document the purpose of this file. 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | #ifndef _YETI_SCRIPT_BINDINGS_TRANSFORM_IF_H_ 17 | #define _YETI_SCRIPT_BINDINGS_TRANSFORM_IF_H_ 18 | 19 | #include "yeti/script/binding.h" 20 | 21 | namespace yeti { 22 | namespace transform_if { 23 | 24 | /// ... 25 | extern YETI_PUBLIC void expose(Script *script); 26 | 27 | } // transform_if 28 | } // yeti 29 | 30 | #endif // _YETI_SCRIPT_BINDINGS_TRANSFORM_IF_H_ 31 | -------------------------------------------------------------------------------- /include/yeti/script/bindings/viewport_if.h: -------------------------------------------------------------------------------- 1 | //===-- yeti/script/bindingsviewport_if.h -----------------------*- mode: C++11 -*-===// 2 | // 3 | // __ __ _ _ 4 | // | | |___| |_|_| 5 | // |_ _| -_| _| | 6 | // |_| |___|_| |_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | // 12 | // TODO(mtwilliams): Document the purpose of this file. 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | #ifndef _YETI_SCRIPT_BINDINGS_VIEWPORT_IF_H_ 17 | #define _YETI_SCRIPT_BINDINGS_VIEWPORT_IF_H_ 18 | 19 | #include "yeti/script/binding.h" 20 | 21 | namespace yeti { 22 | namespace viewport_if { 23 | 24 | /// ... 25 | extern YETI_PUBLIC void expose(Script *script); 26 | 27 | } // viewport_if 28 | } // yeti 29 | 30 | #endif // _YETI_SCRIPT_BINDINGS_VIEWPORT_IF_H_ 31 | -------------------------------------------------------------------------------- /include/yeti/script/bindings/window_if.h: -------------------------------------------------------------------------------- 1 | //===-- yeti/script/bindings/window_if.h ----------------*- mode: C++11 -*-===// 2 | // 3 | // __ __ _ _ 4 | // | | |___| |_|_| 5 | // |_ _| -_| _| | 6 | // |_| |___|_| |_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | // 12 | // TODO(mtwilliams): Document the purpose of this file. 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | #ifndef _YETI_SCRIPT_BINDINGS_WINDOW_IF_H_ 17 | #define _YETI_SCRIPT_BINDINGS_WINDOW_IF_H_ 18 | 19 | #include "yeti/script/binding.h" 20 | 21 | namespace yeti { 22 | 23 | // See `yeti/world.h`. 24 | class Window; 25 | 26 | namespace window_if { 27 | 28 | /// \brief Checks if the value on @L's stack at @idx is window. 29 | extern YETI_PUBLIC bool check(lua_State *L, int idx); 30 | 31 | /// \brief Checks if the value on @L's stack at @idx is window then returns it. 32 | extern YETI_PUBLIC Window *cast(lua_State *L, int idx); 33 | 34 | /// \brief Pushes @window onto @L's stack. 35 | extern YETI_PUBLIC void push(lua_State *L, Window *window); 36 | 37 | /// ... 38 | extern YETI_PUBLIC void expose(Script *script); 39 | 40 | } // window_if 41 | } // yeti 42 | 43 | #endif // _YETI_SCRIPT_BINDINGS_WINDOW_IF_H_ 44 | -------------------------------------------------------------------------------- /include/yeti/script/bindings/world_if.h: -------------------------------------------------------------------------------- 1 | //===-- yeti/script/bindings/world_if.h -----------------*- mode: C++11 -*-===// 2 | // 3 | // __ __ _ _ 4 | // | | |___| |_|_| 5 | // |_ _| -_| _| | 6 | // |_| |___|_| |_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | // 12 | // TODO(mtwilliams): Document the purpose of this file. 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | #ifndef _YETI_SCRIPT_BINDINGS_WORLD_IF_H_ 17 | #define _YETI_SCRIPT_BINDINGS_WORLD_IF_H_ 18 | 19 | #include "yeti/script/binding.h" 20 | 21 | namespace yeti { 22 | 23 | // See `yeti/world.h`. 24 | class World; 25 | 26 | namespace world_if { 27 | 28 | /// \brief Checks if the value on @L's stack at @idx is world. 29 | extern YETI_PUBLIC bool check(lua_State *L, int idx); 30 | 31 | /// \brief Checks if the value on @L's stack at @idx is world then returns it. 32 | extern YETI_PUBLIC World *cast(lua_State *L, int idx); 33 | 34 | /// \brief Pushes @world onto @L's stack. 35 | extern YETI_PUBLIC void push(lua_State *L, World *world); 36 | 37 | /// ... 38 | extern YETI_PUBLIC void expose(Script *script); 39 | 40 | } // world_if 41 | } // yeti 42 | 43 | #endif // _YETI_SCRIPT_BINDINGS_WORLD_IF_H_ 44 | -------------------------------------------------------------------------------- /include/yeti/task.h: -------------------------------------------------------------------------------- 1 | //===-- yeti/task.h -------------------------------------*- mode: C++11 -*-===// 2 | // 3 | // __ __ _ _ 4 | // | | |___| |_|_| 5 | // |_ _| -_| _| | 6 | // |_| |___|_| |_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | // 12 | // TODO(mtwilliams): Document the purpose of this file. 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | #ifndef _YETI_TASK_H_ 17 | #define _YETI_TASK_H_ 18 | 19 | #include "yeti/core.h" 20 | 21 | #include "loom.h" 22 | 23 | namespace yeti { 24 | 25 | /// \brief Describes a schedulable unit of work and its dependencies. 26 | struct Task : public ::loom_task_t { 27 | /// \brief Code comprising a task. 28 | typedef ::loom_kernel_fn Kernel; 29 | 30 | /// \brief Opaque reference to a task. 31 | typedef ::loom_handle_t Handle; 32 | }; 33 | 34 | namespace task { 35 | 36 | /// \brief Creates a task with given work. 37 | extern YETI_PUBLIC Task::Handle describe(Task::Kernel kernel, 38 | void *data = NULL); 39 | 40 | /// \brief Prevents @permittee from being scheduled until @task has completed. 41 | extern YETI_PUBLIC void permits(Task::Handle task, 42 | Task::Handle permittee); 43 | 44 | } // task 45 | 46 | } // yeti 47 | 48 | #endif // _YETI_TASK_H_ 49 | -------------------------------------------------------------------------------- /include/yeti/world.h: -------------------------------------------------------------------------------- 1 | //===-- yeti/world.h ------------------------------------*- mode: C++11 -*-===// 2 | // 3 | // __ __ _ _ 4 | // | | |___| |_|_| 5 | // |_ _| -_| _| | 6 | // |_| |___|_| |_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | // 12 | // TODO(mtwilliams): Document the purpose of this file. 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | #ifndef _YETI_WORLD_H_ 17 | #define _YETI_WORLD_H_ 18 | 19 | #include "yeti/core.h" 20 | 21 | #include "yeti/resource.h" 22 | 23 | #include "yeti/math.h" 24 | 25 | #include "yeti/entity.h" 26 | #include "yeti/component.h" 27 | #include "yeti/system.h" 28 | 29 | // Pointers to commonly accessed components are provided. Reduces overhead, and 30 | // improves readability. 31 | #include "yeti/components/transform.h" 32 | #include "yeti/components/camera.h" 33 | #include "yeti/components/light.h" 34 | #include "yeti/components/mesh.h" 35 | #include "yeti/components/terrain.h" 36 | #include "yeti/components/data.h" 37 | #include "yeti/components/tag.h" 38 | 39 | namespace yeti { 40 | 41 | class YETI_PUBLIC World { 42 | YETI_DISALLOW_COPYING(World) 43 | 44 | private: 45 | World(); 46 | ~World(); 47 | 48 | public: 49 | static World *create(); 50 | 51 | void update(const f32 delta_time); 52 | 53 | void destroy(); 54 | 55 | public: 56 | /// \brief Spawns an entity from a resource given by @id at @position with a 57 | /// rotation of @rotation and scaled by @scale. 58 | /// 59 | /// \return Handle to spawned entity. 60 | /// 61 | Entity spawn(Resource::Id id, 62 | const Vec3 &position = Vec3(0.f, 0.f, 0.f), 63 | const Quaternion &rotation = Quaternion(0.f, 0.f, 0.f, 1.f), 64 | const Vec3 &scale = Vec3(1.f, 1.f, 1.f)); 65 | 66 | /// \brief Kills @entity. 67 | void kill(Entity entity); 68 | 69 | public: 70 | YETI_INLINE EntityManager *entities() { 71 | return &entities_; 72 | } 73 | 74 | YETI_INLINE TransformSystem *transforms() { 75 | return transforms_; 76 | } 77 | 78 | YETI_INLINE CameraSystem *cameras() { 79 | return cameras_; 80 | } 81 | 82 | YETI_INLINE LightSystem *lights() { 83 | return lights_; 84 | } 85 | 86 | private: 87 | EntityManager entities_; 88 | 89 | SystemManager systems_; 90 | 91 | TransformSystem *transforms_; 92 | CameraSystem *cameras_; 93 | LightSystem *lights_; 94 | }; 95 | 96 | } // yeti 97 | 98 | #endif // _YETI_WORLD_H_ 99 | -------------------------------------------------------------------------------- /runtime/include/yeti/runtime/standard_application.h: -------------------------------------------------------------------------------- 1 | //===-- yeti/runtime/standard_application.h -------------*- mode: C++11 -*-===// 2 | // 3 | // __ __ _ _ 4 | // | | |___| |_|_| 5 | // |_ _| -_| _| | 6 | // |_| |___|_| |_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | // 12 | // TODO(mtwilliams): Document the purpose of this file. 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | #ifndef _YETI_RUNTIME_STANDARD_APPLICATION_H_ 17 | #define _YETI_RUNTIME_STANDARD_APPLICATION_H_ 18 | 19 | #include "yeti.h" 20 | 21 | namespace yeti { 22 | namespace runtime { 23 | 24 | // See `yeti/runtime/manifest.h`. 25 | struct Manifest; 26 | 27 | class StandardApplication : public yeti::Application { 28 | YETI_DISALLOW_COPYING(StandardApplication) 29 | 30 | public: 31 | StandardApplication(const Manifest *manifest); 32 | ~StandardApplication(); 33 | 34 | protected: 35 | bool startup(); 36 | void update(const f32 delta_time); 37 | void render(); 38 | void shutdown(); 39 | 40 | private: 41 | // Starts logging to console. 42 | void start_logging_to_console() const; 43 | 44 | // Starts logging to a file. 45 | void start_logging_to_file() const; 46 | 47 | // Sets the accepted logging levels based on build configuration. 48 | void set_appropriate_logging_level() const; 49 | 50 | // Logs game and engine copyright information. 51 | void log_copyright_notices() const; 52 | 53 | // Logs engine, game, and content revisions. 54 | void log_pertinent_information_about_build() const; 55 | 56 | // Logs software and hardware information. 57 | void log_pertinent_information_about_system() const; 58 | 59 | private: 60 | // Creates main window and default viewport. 61 | void create_main_window_and_default_viewport(); 62 | 63 | // Exposes interfaces to Lua. 64 | void expose_to_lua(); 65 | 66 | // Loads boot package and script. 67 | void load_boot_package_and_script(); 68 | 69 | private: 70 | const Manifest *manifest_; 71 | Script script_; 72 | }; 73 | 74 | } // runtime 75 | } // yeti 76 | 77 | #endif // _YETI_RUNTIME_STANDARD_APPLICATION_H_ 78 | -------------------------------------------------------------------------------- /src/yeti/application/time_step_policy.cc: -------------------------------------------------------------------------------- 1 | //===-- yeti/application/time_step_policy.cc ------------*- mode: C++11 -*-===// 2 | // 3 | // __ __ _ _ 4 | // | | |___| |_|_| 5 | // |_ _| -_| _| | 6 | // |_| |___|_| |_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | 12 | #include "yeti/application/time_step_policy.h" 13 | 14 | // For rounding. 15 | #include 16 | 17 | namespace yeti { 18 | 19 | TimeStepPolicy::TimeStepPolicy() { 20 | desc_.type = TimeStepPolicy::UNKNOWN; 21 | steps_ = 0; 22 | delta_time_per_step_ = 0.f; 23 | } 24 | 25 | TimeStepPolicy::~TimeStepPolicy() { 26 | } 27 | 28 | TimeStepPolicy *TimeStepPolicy::create(const TimeStepPolicy::Description &desc) { 29 | // TODO(mtwilliams): Perform more thorough validation. 30 | yeti_assert_development(desc.type != TimeStepPolicy::UNKNOWN); 31 | 32 | TimeStepPolicy *time_step_policy = 33 | YETI_NEW(TimeStepPolicy, core::global_heap_allocator()); 34 | 35 | time_step_policy->desc_ = desc; 36 | 37 | core::memory::zero((void *)&time_step_policy->state_, sizeof(TimeStepPolicy::State)); 38 | 39 | // TODO(mtwilliams): Implement the smoothed time-step-policy. 40 | yeti_assert_release(desc.type != TimeStepPolicy::SMOOTHED); 41 | 42 | return time_step_policy; 43 | } 44 | 45 | void TimeStepPolicy::destroy() { 46 | YETI_DELETE(TimeStepPolicy, core::global_heap_allocator(), this); 47 | } 48 | 49 | void TimeStepPolicy::update(const core::Timer &frame, 50 | const core::Timer &wall) { 51 | switch (desc_.type) { 52 | case TimeStepPolicy::VARIABLE: { 53 | steps_ = 1; 54 | delta_time_per_step_ = (f32)frame.usecs() / 1000000.f; 55 | } break; 56 | 57 | case TimeStepPolicy::FIXED: { 58 | state_.fixed.accumulated += (f32)frame.usecs() / 1000000.f; 59 | steps_ = lroundf(state_.fixed.accumulated / desc_.config.fixed.delta_time_per_step); 60 | state_.fixed.accumulated -= steps_ * desc_.config.fixed.delta_time_per_step; 61 | delta_time_per_step_ = desc_.config.fixed.delta_time_per_step; 62 | } break; 63 | 64 | case TimeStepPolicy::SMOOTHED: { 65 | YETI_TRAP(); 66 | } break; 67 | } 68 | } 69 | 70 | } // yeti 71 | -------------------------------------------------------------------------------- /src/yeti/color.cc: -------------------------------------------------------------------------------- 1 | //===-- yeti/color.cc -----------------------------------*- mode: C++11 -*-===// 2 | // 3 | // __ __ _ _ 4 | // | | |___| |_|_| 5 | // |_ _| -_| _| | 6 | // |_| |___|_| |_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | 12 | #include "yeti/color.h" 13 | 14 | namespace yeti { 15 | 16 | const Color Color::BLACK = Color(0.f, 0.f, 0.f, 1.f); 17 | const Color Color::WHITE = Color(1.f, 1.f, 1.f, 1.f); 18 | const Color Color::RED = Color(1.f, 0.f, 0.f, 1.f); 19 | const Color Color::GREEN = Color(0.f, 1.f, 0.f, 1.f); 20 | const Color Color::BLUE = Color(0.f, 0.f, 1.f, 1.f); 21 | 22 | } // yeti 23 | -------------------------------------------------------------------------------- /src/yeti/components/decal.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/src/yeti/components/decal.cc -------------------------------------------------------------------------------- /src/yeti/components/effect.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/src/yeti/components/effect.cc -------------------------------------------------------------------------------- /src/yeti/components/fluid.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/src/yeti/components/fluid.cc -------------------------------------------------------------------------------- /src/yeti/components/mesh.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/src/yeti/components/mesh.cc -------------------------------------------------------------------------------- /src/yeti/components/scatter.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/src/yeti/components/scatter.cc -------------------------------------------------------------------------------- /src/yeti/components/tag.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/src/yeti/components/tag.cc -------------------------------------------------------------------------------- /src/yeti/components/terrain.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/src/yeti/components/terrain.cc -------------------------------------------------------------------------------- /src/yeti/core/allocator.cc: -------------------------------------------------------------------------------- 1 | //===-- yeti/core/allocator.cc --------------------------*- mode: C++11 -*-===// 2 | // 3 | // _____ _ _ _ 4 | // | __|___ _ _ ___ _| |___| |_|_|___ ___ 5 | // | __| . | | | | . | .'| _| | . | | 6 | // |__| |___|___|_|_|___|__,|_| |_|___|_|_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | 12 | #include "yeti/core/allocator.h" 13 | 14 | namespace yeti { 15 | namespace core { 16 | 17 | Allocator::Allocator() {} 18 | Allocator::~Allocator() {} 19 | 20 | } // core 21 | } // yeti 22 | -------------------------------------------------------------------------------- /src/yeti/core/allocators/buddy_allocator.cc: -------------------------------------------------------------------------------- 1 | //===-- yeti/core/allocators/buddy_allocator.cc ---------*- mode: C++11 -*-===// 2 | // 3 | // _____ _ _ _ 4 | // | __|___ _ _ ___ _| |___| |_|_|___ ___ 5 | // | __| . | | | | . | .'| _| | . | | 6 | // |__| |___|___|_|_|___|__,|_| |_|___|_|_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | 12 | #include "yeti/core/allocators/buddy_allocator.h" 13 | -------------------------------------------------------------------------------- /src/yeti/core/allocators/bump_allocator.cc: -------------------------------------------------------------------------------- 1 | //===-- yeti/core/allocators/bump_allocator.cc ----------*- mode: C++11 -*-===// 2 | // 3 | // _____ _ _ _ 4 | // | __|___ _ _ ___ _| |___| |_|_|___ ___ 5 | // | __| . | | | | . | .'| _| | . | | 6 | // |__| |___|___|_|_|___|__,|_| |_|___|_|_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | 12 | #include "yeti/core/allocators/bump_allocator.h" 13 | -------------------------------------------------------------------------------- /src/yeti/core/allocators/global_heap_allocator.cc: -------------------------------------------------------------------------------- 1 | //===-- yeti/core/allocators/global_heap_allocator.cc ---*- mode: C++11 -*-===// 2 | // 3 | // _____ _ _ _ 4 | // | __|___ _ _ ___ _| |___| |_|_|___ ___ 5 | // | __| . | | | | . | .'| _| | . | | 6 | // |__| |___|___|_|_|___|__,|_| |_|___|_|_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | 12 | #include "yeti/core/allocators/global_heap_allocator.h" 13 | 14 | // For sanity checks. 15 | #include "yeti/core/debug/assert.h" 16 | 17 | #if YETI_PLATFORM == YETI_PLATFORM_WINDOWS 18 | #include 19 | #include 20 | #elif YETI_PLATFORM == YETI_PLATFORM_MAC || \ 21 | YETI_PLATFORM == YETI_PLATFORM_LINUX 22 | #include 23 | #endif 24 | 25 | namespace yeti { 26 | namespace core { 27 | 28 | class GlobalHeapAllocator : public Allocator { 29 | YETI_DISALLOW_COPYING(GlobalHeapAllocator) 30 | 31 | public: 32 | GlobalHeapAllocator(); 33 | ~GlobalHeapAllocator(); 34 | 35 | public: 36 | void *allocate(size_t size, size_t alignment = 16); 37 | void *reallocate(void *ptr, size_t size, size_t alignment = 16); 38 | void deallocate(void *ptr); 39 | }; 40 | 41 | GlobalHeapAllocator::GlobalHeapAllocator() 42 | : Allocator() 43 | { 44 | } 45 | 46 | GlobalHeapAllocator::~GlobalHeapAllocator() { 47 | } 48 | 49 | void *GlobalHeapAllocator::allocate(size_t size, size_t alignment) { 50 | #if YETI_PLATFORM == YETI_PLATFORM_WINDOWS 51 | return _aligned_malloc(size, alignment); 52 | #elif YETI_PLATFORM == YETI_PLATFORM_MAC || \ 53 | YETI_PLATFORM == YETI_PLATFORM_LINUX 54 | #endif 55 | } 56 | 57 | void *GlobalHeapAllocator::reallocate(void *ptr, size_t size, size_t alignment) { 58 | #if YETI_PLATFORM == YETI_PLATFORM_WINDOWS 59 | return _aligned_realloc(ptr, size, alignment); 60 | #elif YETI_PLATFORM == YETI_PLATFORM_MAC || \ 61 | YETI_PLATFORM == YETI_PLATFORM_LINUX 62 | #endif 63 | } 64 | 65 | void GlobalHeapAllocator::deallocate(void *ptr) { 66 | #if YETI_PLATFORM == YETI_PLATFORM_WINDOWS 67 | _aligned_free(ptr); 68 | #elif YETI_PLATFORM == YETI_PLATFORM_MAC || \ 69 | YETI_PLATFORM == YETI_PLATFORM_LINUX 70 | #endif 71 | } 72 | 73 | Allocator &global_heap_allocator() { 74 | // HACK(mtwilliams): Force initialization on first call in case static 75 | // constructors need to allocate from the global heap allocator. 76 | 77 | // BUG(mtwilliams): May initialize more than once. 78 | static GlobalHeapAllocator global_heap_allocator_; 79 | 80 | return global_heap_allocator_; 81 | } 82 | 83 | } // core 84 | } // yeti 85 | -------------------------------------------------------------------------------- /src/yeti/core/allocators/proxy_allocator.cc: -------------------------------------------------------------------------------- 1 | //===-- yeti/core/allocators/proxy_allocator.cc ---------*- mode: C++11 -*-===// 2 | // 3 | // _____ _ _ _ 4 | // | __|___ _ _ ___ _| |___| |_|_|___ ___ 5 | // | __| . | | | | . | .'| _| | . | | 6 | // |__| |___|___|_|_|___|__,|_| |_|___|_|_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | 12 | #include "yeti/core/allocators/proxy_allocator.h" 13 | 14 | namespace yeti { 15 | namespace core { 16 | 17 | ProxyAllocator::ProxyAllocator(Allocator *allocator, 18 | const char *name) 19 | : forwardee_(allocator) 20 | { 21 | } 22 | 23 | ProxyAllocator::ProxyAllocator(Allocator &allocator, 24 | const char *name) 25 | : forwardee_(&allocator) 26 | { 27 | } 28 | 29 | ProxyAllocator::~ProxyAllocator() { 30 | } 31 | 32 | void *ProxyAllocator::allocate(size_t size, size_t alignment) { 33 | return forwardee_->allocate(size, alignment); 34 | } 35 | 36 | void *ProxyAllocator::reallocate(void *ptr, size_t size, size_t alignment) { 37 | return forwardee_->reallocate(ptr, size, alignment); 38 | } 39 | 40 | void ProxyAllocator::deallocate(void *ptr) { 41 | forwardee_->deallocate(ptr); 42 | } 43 | 44 | } // core 45 | } // yeti 46 | -------------------------------------------------------------------------------- /src/yeti/core/allocators/thread_safe/bump_allocator.cc: -------------------------------------------------------------------------------- 1 | //===-- yeti/core/allocators/thread_safe/bump_allocator.cc ----------------===// 2 | // 3 | // _____ _ _ _ 4 | // | __|___ _ _ ___ _| |___| |_|_|___ ___ 5 | // | __| . | | | | . | .'| _| | . | | 6 | // |__| |___|___|_|_|___|__,|_| |_|___|_|_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | 12 | #include "yeti/core/allocators/thread_safe/bump_allocator.h" 13 | 14 | #include "yeti/core/atomics.h" 15 | 16 | // For sanity checks. 17 | #include "yeti/core/debug/assert.h" 18 | 19 | namespace yeti { 20 | namespace core { 21 | namespace thread_safe { 22 | 23 | BumpAllocator::BumpAllocator(Allocator *allocator, size_t size) 24 | : Allocator() 25 | , backing_(allocator) 26 | , lower_((uintptr_t)allocator->allocate(size)) 27 | , upper_(lower_ + size) 28 | , unallocated_(lower_) 29 | { 30 | } 31 | 32 | BumpAllocator::BumpAllocator(Allocator &allocator, size_t size) 33 | : Allocator() 34 | , backing_(&allocator) 35 | , lower_((uintptr_t)allocator.allocate(size)) 36 | , upper_(lower_ + size) 37 | , unallocated_(lower_) 38 | { 39 | } 40 | 41 | BumpAllocator::BumpAllocator(void *memory, size_t size) 42 | : Allocator() 43 | , backing_(NULL) 44 | , lower_((uintptr_t)memory) 45 | , upper_(lower_ + size) 46 | , unallocated_(lower_) 47 | { 48 | } 49 | 50 | BumpAllocator::~BumpAllocator() { 51 | if (backing_) 52 | backing_->deallocate((void *)lower_); 53 | } 54 | 55 | void *BumpAllocator::allocate(size_t size, size_t alignment) { 56 | while (true) { 57 | const uintptr_t unallocated = atomic::load(&unallocated_); 58 | 59 | const size_t padding = unallocated % alignment; 60 | const size_t length = size + padding; 61 | 62 | if (length >= upper_) 63 | // We don't have enough memory left to fufill the requested allocation. 64 | return NULL; 65 | 66 | if (atomic::cmp_and_xchg(&unallocated_, unallocated, unallocated + length) != unallocated) 67 | // Lost to another thread. 68 | continue; 69 | 70 | return (void *)(unallocated + padding); 71 | } 72 | } 73 | 74 | void *BumpAllocator::reallocate(void *ptr, size_t size, size_t alignment) { 75 | // Not supported. 76 | YETI_TRAP(); 77 | 78 | return NULL; 79 | } 80 | 81 | void BumpAllocator::deallocate(void *ptr) { 82 | yeti_assert_debug(((uintptr_t)ptr) > lower_); 83 | yeti_assert_debug(((uintptr_t)ptr) < upper_); 84 | } 85 | 86 | void BumpAllocator::reset() { 87 | while (atomic::cmp_and_xchg(&unallocated_, unallocated_, lower_) != unallocated_); 88 | } 89 | 90 | } // thread_safe 91 | } // core 92 | } // yeti 93 | -------------------------------------------------------------------------------- /src/yeti/core/debug/assert.cc: -------------------------------------------------------------------------------- 1 | //===-- yeti/core/debug/assert.cc -----------------------*- mode: C++11 -*-===// 2 | // 3 | // _____ _ _ _ 4 | // | __|___ _ _ ___ _| |___| |_|_|___ ___ 5 | // | __| . | | | | . | .'| _| | . | | 6 | // |__| |___|___|_|_|___|__,|_| |_|___|_|_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | 12 | #include "yeti/core/debug/assert.h" 13 | 14 | namespace yeti { 15 | namespace core { 16 | 17 | namespace { 18 | static AssertionHandler assertion_handler_ = NULL; 19 | static void *assertion_handler_context_ = NULL; 20 | } 21 | 22 | void assertion_handler(AssertionHandler *assertion_handler, 23 | void **context) { 24 | *assertion_handler = assertion_handler_; 25 | *context = assertion_handler_context_; 26 | } 27 | 28 | void set_assertion_handler(AssertionHandler assertion_handler, 29 | void *context) { 30 | assertion_handler_ = assertion_handler; 31 | assertion_handler_context_ = context; 32 | } 33 | 34 | void raise_an_assertion(const Assertion &assertion) { 35 | if (assertion_handler_) 36 | assertion_handler_(assertion, assertion_handler_context_); 37 | } 38 | 39 | } // core 40 | } // yeti 41 | -------------------------------------------------------------------------------- /src/yeti/core/log/file.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/src/yeti/core/log/file.cc -------------------------------------------------------------------------------- /src/yeti/core/log/network.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/src/yeti/core/log/network.cc -------------------------------------------------------------------------------- /src/yeti/core/misc/pattern_file_parser.cc: -------------------------------------------------------------------------------- 1 | //===-- yeti/core/misc/pattern_file_parser.cc -----------*- mode: C++11 -*-===// 2 | // 3 | // _____ _ _ _ 4 | // | __|___ _ _ ___ _| |___| |_|_|___ ___ 5 | // | __| . | | | | . | .'| _| | . | | 6 | // |__| |___|___|_|_|___|__,|_| |_|___|_|_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | 12 | #include "yeti/core/misc/pattern_file_parser.h" 13 | 14 | // Forward declared by header. 15 | #include "yeti/core/platform/filesystem.h" 16 | 17 | // For buffer, and (temporarily) strings. 18 | #include "yeti/core/allocators/global_heap_allocator.h" 19 | 20 | #include 21 | #include 22 | 23 | namespace yeti { 24 | namespace core { 25 | 26 | PatternFileParser::PatternFileParser(File *file) 27 | : buffer_(core::global_heap_allocator()) 28 | { 29 | fs::read_into_buffer(file, buffer_); 30 | 31 | cursor_ = 0; 32 | character_ = eof() ? '\0' : buffer_[cursor_]; 33 | } 34 | 35 | void PatternFileParser::parse(Array &patterns) { 36 | while (!eof()) { 37 | if (character_ == '#') { 38 | // Comment; skip. 39 | skip_to_next_line(); 40 | } else { 41 | if (const char *line = extract()) 42 | // Pattern. 43 | patterns.push(line); 44 | } 45 | } 46 | } 47 | 48 | const char *PatternFileParser::extract() { 49 | unsigned begin = cursor_; 50 | 51 | skip_to_next_line(); 52 | 53 | unsigned end = cursor_; 54 | 55 | // Trim trailing whitespace, if any. 56 | while ((end > begin) && ::isspace(buffer_[--end - 1])); 57 | 58 | if (begin == end) 59 | // Empty line. 60 | return NULL; 61 | 62 | const size_t length = (end - begin); 63 | 64 | char *line = (char *)core::global_heap_allocator().allocate(length + 1); 65 | strncpy(line, (const char *)&buffer_[begin], length); 66 | line[length] = '\0'; 67 | 68 | return line; 69 | } 70 | 71 | void PatternFileParser::skip_to_next_line() { 72 | while (!eof()) { 73 | if (advance() == '\n') { 74 | advance(); 75 | break; 76 | } 77 | } 78 | } 79 | 80 | char PatternFileParser::advance() { 81 | return eof() ? '\0' : (character_ = buffer_[++cursor_]); 82 | } 83 | 84 | char PatternFileParser::peek() { 85 | return eof() ? '\0' : buffer_[cursor_ + 1]; 86 | } 87 | 88 | bool PatternFileParser::eof() const { 89 | return (cursor_ == (buffer_.size() - 1)); 90 | } 91 | 92 | } // core 93 | } // yeti 94 | -------------------------------------------------------------------------------- /src/yeti/core/misc/uuid.cc: -------------------------------------------------------------------------------- 1 | //===-- yeti/core/misc/uuid.cc --------------------------*- mode: C++11 -*-===// 2 | // 3 | // _____ _ _ _ 4 | // | __|___ _ _ ___ _| |___| |_|_|___ ___ 5 | // | __| . | | | | . | .'| _| | . | | 6 | // |__| |___|___|_|_|___|__,|_| |_|___|_|_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | 12 | #include "yeti/core/misc/uuid.h" 13 | 14 | // Used to generate UUID v4. 15 | #include "yeti/core/algorithms/random.h" 16 | 17 | namespace yeti { 18 | namespace core { 19 | 20 | // TODO(mtwilliams): Improve validation. 21 | // TODO(mtwilliams): Improve randomness. 22 | 23 | void uuid::generate(u8 uuid[16]) { 24 | // Fill with random bytes. 25 | random_n(uuid, sizeof(uuid)); 26 | 27 | // Mark as version four variant one as it is. 28 | uuid[6] = (uuid[6] & 0x0F) | 0x40; 29 | uuid[8] = (uuid[8] & 0x3F) | 0x80; 30 | } 31 | 32 | bool uuid::parse(const char *string, u8 uuid[16]) { 33 | unsigned n = 0; 34 | 35 | sscanf(string, "%2hhx%2hhx%2hhx%2hhx-" 36 | "%2hhx%2hhx-" 37 | "%2hhx%2hhx-" 38 | "%2hhx%2hhx-" 39 | "%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx%n", 40 | &uuid[0], &uuid[1], &uuid[2], &uuid[3], 41 | &uuid[4], &uuid[5], 42 | &uuid[6], &uuid[7], 43 | &uuid[8], &uuid[9], 44 | &uuid[10], &uuid[11], &uuid[12], &uuid[13], &uuid[14], &uuid[15], 45 | &n); 46 | 47 | return (n == 36); 48 | } 49 | 50 | bool uuid::validate(const char *string) { 51 | u8 dummy[16]; 52 | return uuid::parse(string, dummy); 53 | } 54 | 55 | void uuid::present(const u8 uuid[20], char pretty[36+1]) { 56 | sprintf(pretty, "%2hhx%2hhx%2hhx%2hhx-" 57 | "%2hhx%2hhx-" 58 | "%2hhx%2hhx-" 59 | "%2hhx%2hhx-" 60 | "%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx", 61 | uuid[0], uuid[1], uuid[2], uuid[3], 62 | uuid[4], uuid[5], 63 | uuid[6], uuid[7], 64 | uuid[8], uuid[9], 65 | uuid[10], uuid[11], uuid[12], uuid[13], uuid[14], uuid[15]); 66 | } 67 | 68 | } // core 69 | } // yeti 70 | -------------------------------------------------------------------------------- /src/yeti/core/misc/xml.cc: -------------------------------------------------------------------------------- 1 | /* All we're doing is providing a compilation unit for the single file 2 | library. */ 3 | #define XML_IMPLEMENTATION 4 | 5 | /* Include implementation. */ 6 | #include "yeti/core/misc/xml.h" 7 | 8 | /* Undefine to prevent duplication implementation when using unity builds. */ 9 | #undef XML_IMPLEMENTATION 10 | -------------------------------------------------------------------------------- /src/yeti/core/platform/entropy.cc: -------------------------------------------------------------------------------- 1 | //===-- yeti/core/platform/entropy.cc -------------------*- mode: C++11 -*-===// 2 | // 3 | // _____ _ _ _ 4 | // | __|___ _ _ ___ _| |___| |_|_|___ ___ 5 | // | __| . | | | | . | .'| _| | . | | 6 | // |__| |___|___|_|_|___|__,|_| |_|___|_|_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | 12 | #include "yeti/core/platform/entropy.h" 13 | 14 | #if YETI_PLATFORM == YETI_PLATFORM_WINDOWS 15 | #include 16 | #include 17 | #elif YETI_PLATFORM == YETI_PLATFORM_MAC 18 | #elif YETI_PLATFORM == YETI_PLATFORM_LINUX 19 | #elif YETI_PLATFORM == YETI_PLATFORM_IOS 20 | #elif YETI_PLATFORM == YETI_PLATFORM_ANDROID 21 | #endif 22 | 23 | namespace yeti { 24 | namespace core { 25 | 26 | namespace { 27 | #if YETI_PLATFORM == YETI_PLATFORM_WINDOWS 28 | class StrongCryptoServiceProvider { 29 | public: 30 | StrongCryptoServiceProvider() { 31 | ::CryptAcquireContext(&csp, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT); 32 | } 33 | 34 | ~StrongCryptoServiceProvider() { 35 | ::CryptReleaseContext(csp, 0); 36 | } 37 | 38 | public: 39 | HCRYPTPROV csp; 40 | }; 41 | 42 | static StrongCryptoServiceProvider strong_crypto_service_provider_; 43 | #endif 44 | } 45 | 46 | void entropy(void *buffer, size_t amount) { 47 | #if YETI_PLATFORM == YETI_PLATFORM_WINDOWS 48 | ::CryptGenRandom(strong_crypto_service_provider_.csp, amount, (BYTE *)buffer); 49 | #elif YETI_PLATFORM == YETI_PLATFORM_MAC || \ 50 | YETI_PLATFORM == YETI_PLATFORM_LINUX 51 | // TODO(mtwilliams): Read from `/dev/urandom`. 52 | YETI_TRAP(); 53 | #endif 54 | } 55 | 56 | } // core 57 | } // yeti 58 | -------------------------------------------------------------------------------- /src/yeti/core/platform/event.cc: -------------------------------------------------------------------------------- 1 | //===-- yeti/core/platform/event.cc ---------------------*- mode: C++11 -*-===// 2 | // 3 | // _____ _ _ _ 4 | // | __|___ _ _ ___ _| |___| |_|_|___ ___ 5 | // | __| . | | | | . | .'| _| | . | | 6 | // |__| |___|___|_|_|___|__,|_| |_|___|_|_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | 12 | #include "yeti/core/platform/event.h" 13 | 14 | // TODO(mtwilliams): Allocate from a pool. 15 | #include "yeti/core/allocators/global_heap_allocator.h" 16 | 17 | #if YETI_PLATFORM == YETI_PLATFORM_WINDOWS 18 | #include 19 | #elif YETI_PLATFORM == YETI_PLATFORM_MAC 20 | #elif YETI_PLATFORM == YETI_PLATFORM_LINUX 21 | #endif 22 | 23 | namespace yeti { 24 | namespace core { 25 | 26 | struct Event::Storage { 27 | #if YETI_PLATFORM == YETI_PLATFORM_WINDOWS 28 | HANDLE handle; 29 | #elif YETI_PLATFORM == YETI_PLATFORM_MAC 30 | #elif YETI_PLATFORM == YETI_PLATFORM_LINUX 31 | #endif 32 | }; 33 | 34 | Event::Event(bool manual) { 35 | storage_ = 36 | (Event::Storage *)global_heap_allocator().allocate(sizeof(Event::Storage), 37 | alignof(Event::Storage)); 38 | 39 | #if YETI_PLATFORM == YETI_PLATFORM_WINDOWS 40 | storage_->handle = ::CreateEvent(NULL, manual, FALSE, NULL); 41 | #elif YETI_PLATFORM == YETI_PLATFORM_MAC 42 | #elif YETI_PLATFORM == YETI_PLATFORM_LINUX 43 | #endif 44 | } 45 | 46 | Event::~Event() { 47 | #if YETI_PLATFORM == YETI_PLATFORM_WINDOWS 48 | ::CloseHandle(storage_->handle); 49 | #elif YETI_PLATFORM == YETI_PLATFORM_MAC 50 | #elif YETI_PLATFORM == YETI_PLATFORM_LINUX 51 | #endif 52 | 53 | core::global_heap_allocator().deallocate((void *)storage_); 54 | } 55 | 56 | void Event::signal() { 57 | #if YETI_PLATFORM == YETI_PLATFORM_WINDOWS 58 | ::SetEvent(storage_->handle); 59 | #elif YETI_PLATFORM == YETI_PLATFORM_MAC 60 | #elif YETI_PLATFORM == YETI_PLATFORM_LINUX 61 | #endif 62 | } 63 | 64 | void Event::unsignal() { 65 | #if YETI_PLATFORM == YETI_PLATFORM_WINDOWS 66 | ::ResetEvent(storage_->handle); 67 | #elif YETI_PLATFORM == YETI_PLATFORM_MAC 68 | #elif YETI_PLATFORM == YETI_PLATFORM_LINUX 69 | #endif 70 | } 71 | 72 | bool Event::signaled() { 73 | #if YETI_PLATFORM == YETI_PLATFORM_WINDOWS 74 | return (::WaitForSingleObject(storage_->handle, 0) == WAIT_OBJECT_0); 75 | #elif YETI_PLATFORM == YETI_PLATFORM_MAC 76 | #elif YETI_PLATFORM == YETI_PLATFORM_LINUX 77 | #endif 78 | } 79 | 80 | void Event::wait() { 81 | #if YETI_PLATFORM == YETI_PLATFORM_WINDOWS 82 | ::WaitForSingleObject(storage_->handle, INFINITE); 83 | #elif YETI_PLATFORM == YETI_PLATFORM_MAC 84 | #elif YETI_PLATFORM == YETI_PLATFORM_LINUX 85 | #endif 86 | } 87 | 88 | } // core 89 | } // yeti 90 | -------------------------------------------------------------------------------- /src/yeti/core/platform/lock.cc: -------------------------------------------------------------------------------- 1 | //===-- yeti/core/platform/lock.cc ----------------------*- mode: C++11 -*-===// 2 | // 3 | // _____ _ _ _ 4 | // | __|___ _ _ ___ _| |___| |_|_|___ ___ 5 | // | __| . | | | | . | .'| _| | . | | 6 | // |__| |___|___|_|_|___|__,|_| |_|___|_|_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | 12 | #include "yeti/core/platform/lock.h" 13 | 14 | // TODO(mtwilliams): Allocate from a pool. 15 | #include "yeti/core/allocators/global_heap_allocator.h" 16 | 17 | #if YETI_PLATFORM == YETI_PLATFORM_WINDOWS 18 | #include 19 | #elif YETI_PLATFORM == YETI_PLATFORM_MAC 20 | #elif YETI_PLATFORM == YETI_PLATFORM_LINUX 21 | #endif 22 | 23 | namespace yeti { 24 | namespace core { 25 | 26 | struct Lock::Storage { 27 | #if YETI_PLATFORM == YETI_PLATFORM_WINDOWS 28 | CRITICAL_SECTION cs; 29 | #elif YETI_PLATFORM == YETI_PLATFORM_MAC 30 | #elif YETI_PLATFORM == YETI_PLATFORM_LINUX 31 | #endif 32 | }; 33 | 34 | Lock::Lock() { 35 | storage_ = 36 | (Lock::Storage *)global_heap_allocator().allocate(sizeof(Lock::Storage), 37 | alignof(Lock::Storage)); 38 | 39 | #if YETI_PLATFORM == YETI_PLATFORM_WINDOWS 40 | ::InitializeCriticalSection(&storage_->cs); 41 | #elif YETI_PLATFORM == YETI_PLATFORM_MAC 42 | #elif YETI_PLATFORM == YETI_PLATFORM_LINUX 43 | #endif 44 | } 45 | 46 | Lock::~Lock() { 47 | #if YETI_PLATFORM == YETI_PLATFORM_WINDOWS 48 | ::DeleteCriticalSection(&storage_->cs); 49 | #elif YETI_PLATFORM == YETI_PLATFORM_MAC 50 | #elif YETI_PLATFORM == YETI_PLATFORM_LINUX 51 | #endif 52 | 53 | core::global_heap_allocator().deallocate((void *)storage_); 54 | } 55 | 56 | void Lock::acquire() { 57 | #if YETI_PLATFORM == YETI_PLATFORM_WINDOWS 58 | ::EnterCriticalSection(&storage_->cs); 59 | #elif YETI_PLATFORM == YETI_PLATFORM_MAC 60 | #elif YETI_PLATFORM == YETI_PLATFORM_LINUX 61 | #endif 62 | } 63 | 64 | void Lock::release() { 65 | #if YETI_PLATFORM == YETI_PLATFORM_WINDOWS 66 | ::LeaveCriticalSection(&storage_->cs); 67 | #elif YETI_PLATFORM == YETI_PLATFORM_MAC 68 | #elif YETI_PLATFORM == YETI_PLATFORM_LINUX 69 | #endif 70 | } 71 | 72 | } // core 73 | } // yeti 74 | -------------------------------------------------------------------------------- /src/yeti/core/platform/process.cc: -------------------------------------------------------------------------------- 1 | //===-- yeti/core/platform/process.cc -------------------*- mode: C++11 -*-===// 2 | // 3 | // _____ _ _ _ 4 | // | __|___ _ _ ___ _| |___| |_|_|___ ___ 5 | // | __| . | | | | . | .'| _| | . | | 6 | // |__| |___|___|_|_|___|__,|_| |_|___|_|_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | 12 | #include "yeti/core/platform/process.h" 13 | -------------------------------------------------------------------------------- /src/yeti/core/platform/reader_writer_lock.cc: -------------------------------------------------------------------------------- 1 | //===-- yeti/core/platform/reader_writer_lock.cc --------*- mode: C++11 -*-===// 2 | // 3 | // _____ _ _ _ 4 | // | __|___ _ _ ___ _| |___| |_|_|___ ___ 5 | // | __| . | | | | . | .'| _| | . | | 6 | // |__| |___|___|_|_|___|__,|_| |_|___|_|_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | 12 | #include "yeti/core/platform/reader_writer_lock.h" 13 | 14 | // TODO(mtwilliams): Allocate from a pool. 15 | #include "yeti/core/allocators/global_heap_allocator.h" 16 | 17 | #if YETI_PLATFORM == YETI_PLATFORM_WINDOWS 18 | #include 19 | #elif YETI_PLATFORM == YETI_PLATFORM_MAC 20 | #elif YETI_PLATFORM == YETI_PLATFORM_LINUX 21 | #endif 22 | 23 | namespace yeti { 24 | namespace core { 25 | 26 | struct ReaderWriterLock::Storage { 27 | #if YETI_PLATFORM == YETI_PLATFORM_WINDOWS 28 | SRWLOCK srwl; 29 | #elif YETI_PLATFORM == YETI_PLATFORM_MAC 30 | #elif YETI_PLATFORM == YETI_PLATFORM_LINUX 31 | #endif 32 | }; 33 | 34 | ReaderWriterLock::ReaderWriterLock() { 35 | storage_ = 36 | (ReaderWriterLock::Storage *)global_heap_allocator().allocate(sizeof(ReaderWriterLock::Storage), 37 | alignof(ReaderWriterLock::Storage)); 38 | 39 | #if YETI_PLATFORM == YETI_PLATFORM_WINDOWS 40 | ::InitializeSRWLock(&storage_->srwl); 41 | #elif YETI_PLATFORM == YETI_PLATFORM_MAC 42 | #elif YETI_PLATFORM == YETI_PLATFORM_LINUX 43 | #endif 44 | } 45 | 46 | ReaderWriterLock::~ReaderWriterLock() { 47 | #if YETI_PLATFORM == YETI_PLATFORM_WINDOWS 48 | #elif YETI_PLATFORM == YETI_PLATFORM_MAC 49 | #elif YETI_PLATFORM == YETI_PLATFORM_LINUX 50 | #endif 51 | 52 | core::global_heap_allocator().deallocate((void *)storage_); 53 | } 54 | 55 | void ReaderWriterLock::acquire(bool exclusive) { 56 | #if YETI_PLATFORM == YETI_PLATFORM_WINDOWS 57 | if (YETI_LIKELY(!exclusive)) 58 | ::AcquireSRWLockShared(&storage_->srwl); 59 | else 60 | ::AcquireSRWLockExclusive(&storage_->srwl); 61 | #elif YETI_PLATFORM == YETI_PLATFORM_MAC 62 | #elif YETI_PLATFORM == YETI_PLATFORM_LINUX 63 | #endif 64 | } 65 | 66 | void ReaderWriterLock::release(bool exclusive) { 67 | #if YETI_PLATFORM == YETI_PLATFORM_WINDOWS 68 | if (YETI_LIKELY(!exclusive)) 69 | ::ReleaseSRWLockShared(&storage_->srwl); 70 | else 71 | ::ReleaseSRWLockExclusive(&storage_->srwl); 72 | #elif YETI_PLATFORM == YETI_PLATFORM_MAC 73 | #elif YETI_PLATFORM == YETI_PLATFORM_LINUX 74 | #endif 75 | } 76 | 77 | } // core 78 | } // yeti 79 | -------------------------------------------------------------------------------- /src/yeti/core/support/strings.cc: -------------------------------------------------------------------------------- 1 | //===-- yeti/core/support/strings.h ---------------------*- mode: C++11 -*-===// 2 | // 3 | // _____ _ _ _ 4 | // | __|___ _ _ ___ _| |___| |_|_|___ ___ 5 | // | __| . | | | | . | .'| _| | . | | 6 | // |__| |___|___|_|_|___|__,|_| |_|___|_|_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | 12 | #include "yeti/core/support/strings.h" 13 | 14 | #undef vsnprintf 15 | #undef snprintf 16 | 17 | namespace yeti { 18 | namespace core { 19 | 20 | int kludge::vsnprintf(char *buffer, size_t size, const char *format, va_list ap) { 21 | #if YETI_COMPILER == YETI_COMPILER_MSVC 22 | int count = -1; 23 | if (size != 0) 24 | count = _vsnprintf_s(buffer, size, _TRUNCATE, format, ap); 25 | if (count == -1) 26 | count = _vscprintf(format, ap); 27 | return count; 28 | #else 29 | return ::vsnprintf(buffer, size, format, ap); 30 | #endif 31 | } 32 | 33 | int kludge::snprintf(char *buffer, size_t size, const char *format, ...) { 34 | va_list ap; 35 | va_start(ap, format); 36 | const int count = vsnprintf(buffer, size, format, ap); 37 | va_end(ap); 38 | return count; 39 | } 40 | 41 | bool string::compare(const char *a, const char *b) { 42 | return (strcmp(a, b) == 0); 43 | } 44 | 45 | bool string::compare(const char *a, const char *b, size_t length) { 46 | return (strncmp(a, b, length) == 0); 47 | } 48 | 49 | } // core 50 | } // yeti 51 | -------------------------------------------------------------------------------- /src/yeti/level.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/src/yeti/level.cc -------------------------------------------------------------------------------- /src/yeti/math.cc: -------------------------------------------------------------------------------- 1 | //===-- yeti/math.cc ------------------------------------*- mode: C++11 -*-===// 2 | // 3 | // __ __ _ _ 4 | // | | |___| |_|_| 5 | // |_ _| -_| _| | 6 | // |_| |___|_| |_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | 12 | #include "yeti/math.h" 13 | 14 | -------------------------------------------------------------------------------- /src/yeti/math/quaternion.cc: -------------------------------------------------------------------------------- 1 | //===-- yeti/math/quaternion.cc -------------------------*- mode: C++11 -*-===// 2 | // 3 | // __ __ _ _ 4 | // | | |___| |_|_| 5 | // |_ _| -_| _| | 6 | // |_| |___|_| |_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | 12 | #include "yeti/math/quaternion.h" 13 | 14 | namespace yeti { 15 | 16 | const Quaternion Quaternion::IDENTITY = Quaternion(0.f, 0.f, 0.f, 1.f); 17 | 18 | } // yeti 19 | -------------------------------------------------------------------------------- /src/yeti/math/vec2.cc: -------------------------------------------------------------------------------- 1 | //===-- yeti/math/vec2.cc -------------------------------*- mode: C++11 -*-===// 2 | // 3 | // __ __ _ _ 4 | // | | |___| |_|_| 5 | // |_ _| -_| _| | 6 | // |_| |___|_| |_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | 12 | #include "yeti/math/vec2.h" 13 | 14 | namespace yeti { 15 | 16 | const Vec2 Vec2::ZERO = Vec2(0.f, 0.f); 17 | const Vec2 Vec2::ONE = Vec2(1.f, 1.f); 18 | 19 | const Vec2 Vec2::X_AXIS = Vec2(1.f, 0.f); 20 | const Vec2 Vec2::Y_AXIS = Vec2(0.f, 1.f); 21 | 22 | } // yeti 23 | -------------------------------------------------------------------------------- /src/yeti/math/vec3.cc: -------------------------------------------------------------------------------- 1 | //===-- yeti/math/vec3.cc -------------------------------*- mode: C++11 -*-===// 2 | // 3 | // __ __ _ _ 4 | // | | |___| |_|_| 5 | // |_ _| -_| _| | 6 | // |_| |___|_| |_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | 12 | #include "yeti/math/vec3.h" 13 | 14 | namespace yeti { 15 | 16 | const Vec3 Vec3::ZERO = Vec3(0.f, 0.f, 0.f); 17 | const Vec3 Vec3::ONE = Vec3(1.f, 1.f, 1.f); 18 | 19 | const Vec3 Vec3::X_AXIS = Vec3(1.f, 0.f, 0.f); 20 | const Vec3 Vec3::Y_AXIS = Vec3(0.f, 1.f, 0.f); 21 | const Vec3 Vec3::Z_AXIS = Vec3(0.f, 0.f, 1.f); 22 | 23 | } // yeti 24 | -------------------------------------------------------------------------------- /src/yeti/math/vec4.cc: -------------------------------------------------------------------------------- 1 | //===-- yeti/math/vec4.cc -------------------------------*- mode: C++11 -*-===// 2 | // 3 | // __ __ _ _ 4 | // | | |___| |_|_| 5 | // |_ _| -_| _| | 6 | // |_| |___|_| |_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | 12 | #include "yeti/math/vec4.h" 13 | 14 | namespace yeti { 15 | 16 | const Vec4 Vec4::ZERO = Vec4(0.f, 0.f, 0.f, 0.f); 17 | const Vec4 Vec4::ONE = Vec4(1.f, 1.f, 1.f, 1.f); 18 | 19 | const Vec4 Vec4::X_AXIS = Vec4(1.f, 0.f, 0.f, 0.f); 20 | const Vec4 Vec4::Y_AXIS = Vec4(0.f, 1.f, 0.f, 0.f); 21 | const Vec4 Vec4::Z_AXIS = Vec4(0.f, 0.f, 1.f, 0.f); 22 | const Vec4 Vec4::W_AXIS = Vec4(0.f, 0.f, 0.f, 1.f); 23 | 24 | } // yeti 25 | -------------------------------------------------------------------------------- /src/yeti/optimized_resource_database.cc: -------------------------------------------------------------------------------- 1 | //===-- yeti/optimized_resource_database.cc -------------*- mode: C++11 -*-===// 2 | // 3 | // __ __ _ _ 4 | // | | |___| |_|_| 5 | // |_ _| -_| _| | 6 | // |_| |___|_| |_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | 12 | #include "yeti/optimized_resource_database.h" 13 | -------------------------------------------------------------------------------- /src/yeti/resource_bundle.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/src/yeti/resource_bundle.cc -------------------------------------------------------------------------------- /src/yeti/resource_database.cc: -------------------------------------------------------------------------------- 1 | //===-- yeti/resource_database.cc -----------------------*- mode: C++11 -*-===// 2 | // 3 | // __ __ _ _ 4 | // | | |___| |_|_| 5 | // |_ _| -_| _| | 6 | // |_| |___|_| |_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | 12 | #include "yeti/resource_database.h" 13 | 14 | #include "yeti/sophisticated_resource_database.h" 15 | #include "yeti/optimized_resource_database.h" 16 | 17 | namespace yeti { 18 | 19 | namespace core { 20 | namespace log { 21 | 22 | extern const core::log::Category::Id RESOURCE_DATABASE = 23 | Category::add("resource_database", GENERAL); 24 | 25 | } // log 26 | } // core 27 | 28 | ResourceDatabase::ResourceDatabase() { 29 | } 30 | 31 | ResourceDatabase::~ResourceDatabase() { 32 | } 33 | 34 | ResourceDatabase *ResourceDatabase::open(const char *path) { 35 | yeti_assert_debug(path != NULL); 36 | 37 | // TODO(mtwilliams): Guess type. 38 | return SophisticatedResourceDatabase::open(path); 39 | } 40 | 41 | void ResourceDatabase::close() { 42 | YETI_DELETE(ResourceDatabase, core::global_heap_allocator(), this); 43 | } 44 | 45 | } // yeti 46 | -------------------------------------------------------------------------------- /src/yeti/resource_package.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/src/yeti/resource_package.cc -------------------------------------------------------------------------------- /src/yeti/resources/entity_cache.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/src/yeti/resources/entity_cache.cc -------------------------------------------------------------------------------- /src/yeti/resources/entity_cache.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/src/yeti/resources/entity_cache.h -------------------------------------------------------------------------------- /src/yeti/resources/entity_resource.cc: -------------------------------------------------------------------------------- 1 | //===-- yeti/resources/entity_resource.cc ---------------*- mode: C++11 -*-===// 2 | // 3 | // __ __ _ _ 4 | // | | |___| |_|_| 5 | // |_ _| -_| _| | 6 | // |_| |___|_| |_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | 12 | #include "yeti/resources/entity_resource.h" 13 | 14 | #include "yeti/resource.h" 15 | #include "yeti/resource_compiler.h" 16 | 17 | // Compilation logic is factored into a seperate class. 18 | #include "entity_compiler.h" 19 | 20 | namespace yeti { 21 | 22 | EntityResource::EntityResource(Resource::Id id) 23 | : Resource(id) { 24 | } 25 | 26 | EntityResource::~EntityResource() { 27 | } 28 | 29 | const Resource::Type *EntityResource::type() { 30 | static const char *extensions[] = {"entity", NULL}; 31 | 32 | static const Resource::Type type = { 33 | /* .name = */ "entity", 34 | /* .extensions = */ extensions, 35 | /* .version = */ 0, 36 | /* .prepare = */ &EntityResource::prepare, 37 | /* .load = */ &EntityResource::load, 38 | /* .unload = */ &EntityResource::unload, 39 | /* .online = */ NULL, 40 | /* .offline = */ NULL, 41 | /* .compile = */ &EntityResource::compile, 42 | /* .compatible = */ &EntityResource::compatible, 43 | /* .lifecycle_preference = */ resource::LifecyclePreferences::INDIFFERENT 44 | }; 45 | 46 | return &type; 47 | } 48 | 49 | Resource *EntityResource::prepare(Resource::Id id) { 50 | // TODO(mtwilliams): Use an arena allocator. 51 | return (Resource *)YETI_NEW(EntityResource, core::global_heap_allocator())(id); 52 | } 53 | 54 | void EntityResource::load(Resource *resource, const Resource::Data &data) { 55 | } 56 | 57 | void EntityResource::unload(Resource *resource) { 58 | EntityResource *entity_resource = (EntityResource *)resource; 59 | 60 | YETI_DELETE(EntityResource, core::global_heap_allocator(), entity_resource); 61 | } 62 | 63 | bool EntityResource::compile(const resource_compiler::Environment *env, 64 | const resource_compiler::Input *input, 65 | const resource_compiler::Output *output) { 66 | return EntityCompiler(env, input, output).run(); 67 | } 68 | 69 | bool EntityResource::compatible(u32 version) { 70 | return false; 71 | } 72 | 73 | } // yeti 74 | -------------------------------------------------------------------------------- /src/yeti/resources/entity_resource_format.h: -------------------------------------------------------------------------------- 1 | //===-- yeti/resources/entity_resource_format.h ---------*- mode: C++11 -*-===// 2 | // 3 | // __ __ _ _ 4 | // | | |___| |_|_| 5 | // |_ _| -_| _| | 6 | // |_| |___|_| |_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | // 12 | // TODO(mtwilliams): Document the purpose of this file. 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | #ifndef _YETI_ENTITY_RESOURCE_FORMAT_H_ 17 | #define _YETI_ENTITY_RESOURCE_FORMAT_H_ 18 | 19 | namespace yeti { 20 | 21 | namespace entity_resource_format { 22 | // We pack our structures and manually align and pad since we're using these 23 | // structures with memory-mapped files across architectures and compilers. 24 | #pragma pack(push, 1) 25 | 26 | struct Header { 27 | // Number of entities in total. 28 | u32 num_of_entities; 29 | // Number of components in total. 30 | u32 num_of_components; 31 | // Offset to relevant data. 32 | u32 offset_to_entities; 33 | u32 offset_to_components; 34 | u32 offset_to_hierarchy; 35 | // Pad to 16-byte alignment. 36 | u8 padding[12]; 37 | }; 38 | 39 | struct Entity { 40 | // Universally unique identifier assigned to instance. 41 | u8 identifier[16]; 42 | }; 43 | 44 | struct Component { 45 | // Type of component, i.e. `Component::Id`. 46 | u32 type; 47 | // Version of component, i.e. `Component::version`. 48 | u32 version; 49 | // Number of instances. 50 | u32 count; 51 | // Offsets to relevant data. 52 | u32 offset_to_mapping; 53 | u32 offset_to_instances; 54 | u32 offset_to_data; 55 | }; 56 | 57 | // Maps from component to entity. 58 | struct Mappings { 59 | u32 indef_of_entity[0]; 60 | }; 61 | 62 | struct Instance { 63 | // Universally unique identifier assigned to instance. 64 | u8 identifier[16]; 65 | }; 66 | 67 | struct Hierarchy { 68 | // Index of parent for each entity. Must be mapped to runtime handles. 69 | u32 index_of_parent[0]; 70 | }; 71 | 72 | #pragma pack(pop) 73 | } 74 | 75 | } // yeti 76 | 77 | #endif // _YETI_ENTITY_RESOURCE_FORMAT_H_ 78 | -------------------------------------------------------------------------------- /src/yeti/resources/geometry_compiler.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/src/yeti/resources/geometry_compiler.cc -------------------------------------------------------------------------------- /src/yeti/resources/geometry_compiler.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/src/yeti/resources/geometry_compiler.h -------------------------------------------------------------------------------- /src/yeti/resources/level_compiler.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/src/yeti/resources/level_compiler.cc -------------------------------------------------------------------------------- /src/yeti/resources/level_compiler.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/src/yeti/resources/level_compiler.h -------------------------------------------------------------------------------- /src/yeti/resources/level_format.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/src/yeti/resources/level_format.h -------------------------------------------------------------------------------- /src/yeti/resources/level_resource.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/src/yeti/resources/level_resource.cc -------------------------------------------------------------------------------- /src/yeti/resources/mesh_resource.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/src/yeti/resources/mesh_resource.cc -------------------------------------------------------------------------------- /src/yeti/resources/prefab_resource.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/src/yeti/resources/prefab_resource.cc -------------------------------------------------------------------------------- /src/yeti/resources/render_config_compiler.cc: -------------------------------------------------------------------------------- 1 | //===-- yeti/resources/render_config_compiler.cc --------*- mode: C++11 -*-===// 2 | // 3 | // __ __ _ _ 4 | // | | |___| |_|_| 5 | // |_ _| -_| _| | 6 | // |_| |___|_| |_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | 12 | #include "render_config_compiler.h" 13 | 14 | namespace yeti { 15 | 16 | RenderConfigCompiler::RenderConfigCompiler(const resource_compiler::Environment *env, 17 | const resource_compiler::Input *input, 18 | const resource_compiler::Output *output) 19 | : env_(env) 20 | , input_(input) 21 | , output_(output) 22 | , variables_(core::global_heap_allocator()) 23 | , global_resources_(core::global_heap_allocator()) 24 | , local_resources_(core::global_heap_allocator()) 25 | , generators_(core::global_heap_allocator()) 26 | , modifiers_(core::global_heap_allocator()) 27 | , layers_(core::global_heap_allocator()) 28 | { 29 | yeti_assert_debug(env_ != NULL); 30 | yeti_assert_debug(input_ != NULL); 31 | yeti_assert_debug(output_ != NULL); 32 | } 33 | 34 | RenderConfigCompiler::~RenderConfigCompiler() { 35 | } 36 | 37 | bool RenderConfigCompiler::run() { 38 | return this->parse() 39 | && this->compile(); 40 | } 41 | 42 | // Plan 43 | // (1) Manually build the typed, in-memory representation of `render_config` 44 | // (2) Implement `RenderConfigCompiler::compile` 45 | // (3) Build runtime components and get things choochin' 46 | // (4) Write (and rewrite until nice) `origamicomet/jolly` 47 | // (5) Implement `RenderConfigCompiler::parse` 48 | 49 | bool RenderConfigCompiler::parse() { 50 | // variables_.push(...); 51 | 52 | return false; 53 | } 54 | 55 | bool RenderConfigCompiler::compile() { 56 | // Header 57 | // Variables 58 | // Global Resources 59 | // Local Resources 60 | // Generators 61 | // Modifiers 62 | // Layers 63 | 64 | return false; 65 | } 66 | 67 | } // yeti 68 | -------------------------------------------------------------------------------- /src/yeti/resources/render_config_compiler.h: -------------------------------------------------------------------------------- 1 | //===-- yeti/resources/render_config_compiler.h ---------*- mode: C++11 -*-===// 2 | // 3 | // __ __ _ _ 4 | // | | |___| |_|_| 5 | // |_ _| -_| _| | 6 | // |_| |___|_| |_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | // 12 | // TODO(mtwilliams): Document the purpose of this file. 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | #ifndef _YETI_RENDER_CONFIG_COMPILER_H_ 17 | #define _YETI_RENDER_CONFIG_COMPILER_H_ 18 | 19 | #include "yeti/resource.h" 20 | #include "yeti/resource_compiler.h" 21 | 22 | #include "render_config_format.h" 23 | 24 | namespace yeti { 25 | 26 | class YETI_PRIVATE RenderConfigCompiler { 27 | YETI_DISALLOW_COPYING(RenderConfigCompiler); 28 | 29 | private: 30 | // Size, in bytes, dedicated to tokenization and parsing. 31 | static const size_t SIZE_OF_BUFFER = 1048575 /* 1 MiB */; 32 | 33 | private: 34 | typedef render_config_format::Variable Variable; 35 | typedef render_config_format::Resource Resource; 36 | typedef render_config_format::Generator Generator; 37 | typedef render_config_format::Modifier Modifier; 38 | typedef render_config_format::Layer Layer; 39 | 40 | public: 41 | RenderConfigCompiler(const resource_compiler::Environment *env, 42 | const resource_compiler::Input *input, 43 | const resource_compiler::Output *output); 44 | 45 | ~RenderConfigCompiler(); 46 | 47 | public: 48 | bool run(); 49 | 50 | private: 51 | bool parse(); 52 | bool compile(); 53 | 54 | private: 55 | const resource_compiler::Environment *env_; 56 | const resource_compiler::Input *input_; 57 | const resource_compiler::Output *output_; 58 | 59 | core::Array variables_; 60 | core::Array global_resources_; 61 | core::Array local_resources_; 62 | core::Array generators_; 63 | core::Array modifiers_; 64 | core::Array layers_; 65 | }; 66 | 67 | } // yeti 68 | 69 | #endif // _YETI_RENDER_CONFIG_COMPILER_H_ 70 | -------------------------------------------------------------------------------- /src/yeti/resources/render_config_compiler_helpers.cc: -------------------------------------------------------------------------------- 1 | //===-- yeti/resources/render_config_compiler_helpers.cc --*- mode: C++ -*-===// 2 | // 3 | // __ __ _ _ 4 | // | | |___| |_|_| 5 | // |_ _| -_| _| | 6 | // |_| |___|_| |_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | 12 | #include "render_config_compiler_helpers.h" 13 | 14 | #include "yeti/core.h" 15 | 16 | #include 17 | #include 18 | 19 | namespace yeti { 20 | 21 | namespace render_config_compiler { 22 | // We only allow names composed of `a-z`, `0-9`, and `_` characters. 23 | bool NameParser::is_acceptable_name(const char *name) { 24 | // TODO(mtwilliams): Always check length? 25 | yeti_assert_debug(strlen(name) <= 255); 26 | 27 | while (const char ch = *name++) { 28 | if ((ch >= 'a' && ch <= 'z') || 29 | (ch >= '0' && ch <= '9') || 30 | (ch == '_')) 31 | continue; 32 | return false; 33 | } 34 | 35 | return true; 36 | } 37 | } 38 | 39 | } // yeti 40 | -------------------------------------------------------------------------------- /src/yeti/resources/render_config_compiler_helpers.h: -------------------------------------------------------------------------------- 1 | //===-- yeti/resources/render_config_compiler_helpers.h ---*- mode: C++ -*-===// 2 | // 3 | // __ __ _ _ 4 | // | | |___| |_|_| 5 | // |_ _| -_| _| | 6 | // |_| |___|_| |_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | // 12 | // TODO(mtwilliams): Document the purpose of this file. 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | #ifndef _YETI_RENDER_CONFIG_COMPILER_HELPERS_H_ 17 | #define _YETI_RENDER_CONFIG_COMPILER_HELPERS_H_ 18 | 19 | namespace yeti { 20 | 21 | namespace render_config_compiler { 22 | class NameParser { 23 | private: 24 | static bool is_acceptable_name(const char *name); 25 | }; 26 | 27 | /// Parses constant or variable binding. 28 | template 29 | class BindingParser {}; 30 | } 31 | 32 | } // yeti 33 | 34 | #endif // _YETI_RENDER_CONFIG_COMPILER_HELPERS_H_ 35 | -------------------------------------------------------------------------------- /src/yeti/resources/script_compiler.h: -------------------------------------------------------------------------------- 1 | //===-- yeti/resources/script_compiler.h ----------------*- mode: C++11 -*-===// 2 | // 3 | // __ __ _ _ 4 | // | | |___| |_|_| 5 | // |_ _| -_| _| | 6 | // |_| |___|_| |_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | // 12 | // TODO(mtwilliams): Document the purpose of this file. 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | #ifndef _YETI_SCRIPT_COMPILER_H_ 17 | #define _YETI_SCRIPT_COMPILER_H_ 18 | 19 | #include "yeti/resource.h" 20 | #include "yeti/resource_compiler.h" 21 | 22 | extern "C" { 23 | #include 24 | #include 25 | #include 26 | } 27 | 28 | namespace yeti { 29 | 30 | class YETI_PRIVATE ScriptCompiler { 31 | YETI_DISALLOW_COPYING(ScriptCompiler); 32 | 33 | public: 34 | ScriptCompiler(const resource_compiler::Environment *env, 35 | const resource_compiler::Input *input, 36 | const resource_compiler::Output *output); 37 | 38 | ~ScriptCompiler(); 39 | 40 | public: 41 | bool run(); 42 | 43 | private: 44 | bool compile(); 45 | bool dump(); 46 | 47 | private: 48 | bool empty() const; 49 | 50 | private: 51 | const resource_compiler::Environment *env_; 52 | const resource_compiler::Input *input_; 53 | const resource_compiler::Output *output_; 54 | 55 | lua_State *lua_; 56 | 57 | core::Array source_; 58 | core::Array bytecode_; 59 | }; 60 | 61 | } // yeti 62 | 63 | #endif // _YETI_SCRIPT_COMPILER_H_ 64 | -------------------------------------------------------------------------------- /src/yeti/resources/texture_compiler.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/src/yeti/resources/texture_compiler.cc -------------------------------------------------------------------------------- /src/yeti/resources/texture_compiler.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/src/yeti/resources/texture_compiler.h -------------------------------------------------------------------------------- /src/yeti/resources/texture_format.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/src/yeti/resources/texture_format.h -------------------------------------------------------------------------------- /src/yeti/resources/texture_resource.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/src/yeti/resources/texture_resource.cc -------------------------------------------------------------------------------- /src/yeti/script/bindings/component_if.cc: -------------------------------------------------------------------------------- 1 | //===-- yeti/script/bindings/component_if.cc ------------*- mode: C++11 -*-===// 2 | // 3 | // __ __ _ _ 4 | // | | |___| |_|_| 5 | // |_ _| -_| _| | 6 | // |_| |___|_| |_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | 12 | #include "yeti/script/bindings/component_if.h" 13 | 14 | #include "yeti/script.h" 15 | 16 | namespace yeti { 17 | 18 | namespace component_if { 19 | // TODO(mtwilliams): Associate with metatable to aid type checking. 20 | 21 | bool check(lua_State *L, int idx, Component::Id type) { 22 | if (!lua_isuserdata(L, idx)) 23 | return false; 24 | return true; 25 | } 26 | 27 | const Handle &cast(lua_State *L, int idx, Component::Id type) { 28 | void *ud = lua_touserdata(L, idx); 29 | 30 | #if YETI_CONFIGURATION == YETI_CONFIGURATION_DEBUG || \ 31 | YETI_CONFIGURATION == YETI_CONFIGURATION_DEVELOPMENT 32 | if (!ud) 33 | luaL_typerror(L, idx, component_registry::component_by_id(type)->name); 34 | #endif 35 | 36 | return *((const Handle *)ud); 37 | } 38 | 39 | void push(lua_State *L, Component::Id type, Component::Handle handle) { 40 | void *ud = lua_newuserdata(L, sizeof(Handle)); 41 | Handle *h = (Handle *)ud; 42 | h->type = type; 43 | h->handle = handle; 44 | } 45 | } // component_if 46 | 47 | void component_if::expose(Script *script) { 48 | } 49 | 50 | } // yeti 51 | -------------------------------------------------------------------------------- /src/yeti/script/bindings/decal_if.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/src/yeti/script/bindings/decal_if.cc -------------------------------------------------------------------------------- /src/yeti/script/bindings/dlc_if.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/src/yeti/script/bindings/dlc_if.cc -------------------------------------------------------------------------------- /src/yeti/script/bindings/entity_if.cc: -------------------------------------------------------------------------------- 1 | //===-- yeti/script/bindings/entity_if.cc ---------------*- mode: C++11 -*-===// 2 | // 3 | // __ __ _ _ 4 | // | | |___| |_|_| 5 | // |_ _| -_| _| | 6 | // |_| |___|_| |_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | 12 | #include "yeti/script/bindings/entity_if.h" 13 | 14 | #include "yeti/script.h" 15 | 16 | namespace yeti { 17 | 18 | namespace entity_if { 19 | // TODO(mtwilliams): Associate with metatable to aid type checking. 20 | 21 | bool check(lua_State *L, int idx) { 22 | if (!lua_isuserdata(L, idx)) 23 | return false; 24 | return true; 25 | } 26 | 27 | const Handle &cast(lua_State *L, int idx) { 28 | void *ud = lua_touserdata(L, idx); 29 | 30 | #if YETI_CONFIGURATION == YETI_CONFIGURATION_DEBUG || \ 31 | YETI_CONFIGURATION == YETI_CONFIGURATION_DEVELOPMENT 32 | if (!ud) 33 | luaL_typerror(L, idx, "Entity"); 34 | #endif 35 | 36 | return *((const Handle *)ud); 37 | } 38 | 39 | void push(lua_State *L, const Handle &handle) { 40 | void *ud = lua_newuserdata(L, sizeof(Handle)); 41 | *((Handle *)ud) = handle; 42 | } 43 | } // entity_if 44 | 45 | void entity_if::expose(Script *script) { 46 | } 47 | 48 | } // yeti 49 | -------------------------------------------------------------------------------- /src/yeti/script/bindings/fluid_if.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/src/yeti/script/bindings/fluid_if.cc -------------------------------------------------------------------------------- /src/yeti/script/bindings/gamepad_if.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/src/yeti/script/bindings/gamepad_if.cc -------------------------------------------------------------------------------- /src/yeti/script/bindings/http_if.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/src/yeti/script/bindings/http_if.cc -------------------------------------------------------------------------------- /src/yeti/script/bindings/joystick_if.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/src/yeti/script/bindings/joystick_if.cc -------------------------------------------------------------------------------- /src/yeti/script/bindings/level_if.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/src/yeti/script/bindings/level_if.cc -------------------------------------------------------------------------------- /src/yeti/script/bindings/material_if.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/src/yeti/script/bindings/material_if.cc -------------------------------------------------------------------------------- /src/yeti/script/bindings/mesh_if.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/src/yeti/script/bindings/mesh_if.cc -------------------------------------------------------------------------------- /src/yeti/script/bindings/prefab_if.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/src/yeti/script/bindings/prefab_if.cc -------------------------------------------------------------------------------- /src/yeti/script/bindings/profiler_if.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/src/yeti/script/bindings/profiler_if.cc -------------------------------------------------------------------------------- /src/yeti/script/bindings/resource_if.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/src/yeti/script/bindings/resource_if.cc -------------------------------------------------------------------------------- /src/yeti/script/bindings/resource_package_if.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/src/yeti/script/bindings/resource_package_if.cc -------------------------------------------------------------------------------- /src/yeti/script/bindings/save_if.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/src/yeti/script/bindings/save_if.cc -------------------------------------------------------------------------------- /src/yeti/script/bindings/scatter_if.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/src/yeti/script/bindings/scatter_if.cc -------------------------------------------------------------------------------- /src/yeti/script/bindings/settings_if.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/src/yeti/script/bindings/settings_if.cc -------------------------------------------------------------------------------- /src/yeti/script/bindings/spline_if.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/src/yeti/script/bindings/spline_if.cc -------------------------------------------------------------------------------- /src/yeti/script/bindings/tablet_if.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/src/yeti/script/bindings/tablet_if.cc -------------------------------------------------------------------------------- /src/yeti/script/bindings/tag_if.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/src/yeti/script/bindings/tag_if.cc -------------------------------------------------------------------------------- /src/yeti/script/bindings/terrain_if.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/src/yeti/script/bindings/terrain_if.cc -------------------------------------------------------------------------------- /src/yeti/script/bindings/touchscreen_if.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/origamicomet/yeti/273e8f5a3a2c9c5a9d3a9a8de2629c660f225bb1/src/yeti/script/bindings/touchscreen_if.cc -------------------------------------------------------------------------------- /src/yeti/script/bindings/viewport_if.cc: -------------------------------------------------------------------------------- 1 | //===-- yeti/script/bindings/viewport_if.cc -------------*- mode: C++11 -*-===// 2 | // 3 | // __ __ _ _ 4 | // | | |___| |_|_| 5 | // |_ _| -_| _| | 6 | // |_| |___|_| |_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | 12 | #include "yeti/script/bindings/viewport_if.h" 13 | 14 | #include "yeti/script.h" 15 | 16 | // To recover `Application *` from `lua_State *`. 17 | #include "yeti/application.h" 18 | #include "yeti/script/bindings/application_if.h" 19 | 20 | namespace yeti { 21 | 22 | namespace viewport_if { 23 | namespace { 24 | static int create(lua_State *L) { 25 | luaL_error(L, "Not implemented yet."); 26 | return 0; 27 | } 28 | 29 | static int destroy(lua_State *L) { 30 | luaL_error(L, "Not implemented yet."); 31 | return 0; 32 | } 33 | } 34 | } // viewport_if 35 | 36 | void viewport_if::expose(Script *script) { 37 | script->add_module("Viewport"); 38 | 39 | script->add_module_function("Viewport", "create", &create); 40 | script->add_module_function("Viewport", "destroy", &destroy); 41 | } 42 | 43 | } // yeti 44 | -------------------------------------------------------------------------------- /src/yeti/script/environment.cc: -------------------------------------------------------------------------------- 1 | //===-- yeti/script/environment.cc ----------------------*- mode: C++11 -*-===// 2 | // 3 | // __ __ _ _ 4 | // | | |___| |_|_| 5 | // |_ _| -_| _| | 6 | // |_| |___|_| |_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | 12 | #include "yeti/script.h" 13 | #include "yeti/script/environment.h" 14 | 15 | namespace yeti { 16 | 17 | ScriptEnvironment::ScriptEnvironment() { 18 | // Pointers below are not temporary. 19 | lower_bounds_of_pointers_ = (void *)&this->storage; 20 | 21 | // Pointers above are not temporary. 22 | upper_bounds_of_pointers_ = (void *)(uintptr_t(&this->storage) + sizeof(this->storage)); 23 | 24 | // Descended to determine type of a temporary. 25 | lower_bounds_of_pointers_by_type_[0] = (void *)&this->storage.mat4[0]; 26 | lower_bounds_of_pointers_by_type_[1] = (void *)&this->storage.quaternion[0]; 27 | lower_bounds_of_pointers_by_type_[2] = (void *)&this->storage.vec4[0]; 28 | lower_bounds_of_pointers_by_type_[3] = (void *)&this->storage.vec3[0]; 29 | lower_bounds_of_pointers_by_type_[4] = (void *)&this->storage.vec2[0]; 30 | 31 | this->reset(); 32 | } 33 | 34 | ScriptEnvironment::~ScriptEnvironment() { 35 | } 36 | 37 | void ScriptEnvironment::reset() { 38 | this->counts.vec2 = 0; 39 | this->counts.vec3 = 0; 40 | this->counts.vec4 = 0; 41 | this->counts.quaternion = 0; 42 | this->counts.mat4 = 0; 43 | } 44 | 45 | } // yeti 46 | -------------------------------------------------------------------------------- /src/yeti/task.cc: -------------------------------------------------------------------------------- 1 | //===-- yeti/task.cc ------------------------------------*- mode: C++11 -*-===// 2 | // 3 | // __ __ _ _ 4 | // | | |___| |_|_| 5 | // |_ _| -_| _| | 6 | // |_| |___|_| |_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | 12 | #include "yeti/task.h" 13 | 14 | namespace yeti { 15 | 16 | Task::Handle task::describe(Task::Kernel kernel, void *data) { 17 | return ::loom_describe(kernel, data, 0); 18 | } 19 | 20 | void task::permits(Task::Handle task, Task::Handle permittee) { 21 | ::loom_permits(task, permittee); 22 | } 23 | 24 | } // yeti 25 | -------------------------------------------------------------------------------- /src/yeti/task_scheduler.cc: -------------------------------------------------------------------------------- 1 | //===-- yeti/task_scheduler.cc --------------------------*- mode: C++11 -*-===// 2 | // 3 | // __ __ _ _ 4 | // | | |___| |_|_| 5 | // |_ _| -_| _| | 6 | // |_| |___|_| |_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | 12 | #include "yeti/task_scheduler.h" 13 | 14 | namespace yeti { 15 | 16 | namespace task_scheduler { 17 | namespace { 18 | // TODO(mtwilliams): Statistics. 19 | static void prologue(Task *task, void *) {} 20 | static void epilogue(Task *task, void *) {} 21 | } 22 | } 23 | 24 | void task_scheduler::initialize(const task_scheduler::Config &config) { 25 | ::loom_options_t options; 26 | 27 | options.workers = config.workers; 28 | 29 | // Only true of our runtime. 30 | options.main_thread_does_work = false; 31 | 32 | options.prologue.fn = (::loom_prologue_fn)&prologue; 33 | options.prologue.context = NULL; 34 | 35 | options.epilogue.fn = (::loom_epilogue_fn)&epilogue; 36 | options.epilogue.context = NULL; 37 | 38 | // TODO(mtwilliams): Determine reasonable defaults. 39 | options.tasks = 4096; 40 | options.permits = 4096; 41 | options.queue = 4096; 42 | 43 | ::loom_initialize(&options); 44 | } 45 | 46 | void task_scheduler::shutdown() { 47 | ::loom_shutdown(); 48 | } 49 | 50 | void task_scheduler::kick(Task::Handle task) { 51 | ::loom_kick(task); 52 | } 53 | 54 | void task_scheduler::kick_n(unsigned n, const Task::Handle *tasks) { 55 | ::loom_kick_n(n, tasks); 56 | } 57 | 58 | void task_scheduler::kick_and_wait(Task::Handle task) { 59 | ::loom_kick_and_wait(task); 60 | } 61 | 62 | void task_scheduler::kick_and_wait_n(unsigned n, const Task::Handle *tasks) { 63 | ::loom_kick_and_wait_n(n, tasks); 64 | } 65 | 66 | void task_scheduler::kick_and_do_work_while_waiting(Task::Handle task) { 67 | ::loom_kick_and_do_work_while_waiting(task); 68 | } 69 | 70 | void task_scheduler::kick_and_do_work_while_waiting_n(unsigned n, const Task::Handle *tasks) { 71 | ::loom_kick_and_do_work_while_waiting_n(n, tasks); 72 | } 73 | 74 | static bool is_desired_yet(volatile u32 *v, const u32 desired) { 75 | return (atomic::load(v) == desired) 76 | && (atomic::cmp_and_xchg(v, desired, desired) == desired); 77 | } 78 | 79 | bool task_scheduler::do_some_work() { 80 | return ::loom_do_some_work(); 81 | } 82 | 83 | void task_scheduler::do_some_work_until_zero(volatile u32 *v) { 84 | while (!is_desired_yet(v, 0)) 85 | if (!do_some_work()) 86 | core::Thread::yield(); 87 | } 88 | 89 | void task_scheduler::do_some_work_until_equal(volatile u32 *v, u32 desired) { 90 | while (!is_desired_yet(v, desired)) 91 | if (!do_some_work()) 92 | core::Thread::yield(); 93 | } 94 | 95 | } // yeti 96 | -------------------------------------------------------------------------------- /src/yeti/world.cc: -------------------------------------------------------------------------------- 1 | //===-- yeti/world.cc -----------------------------------*- mode: C++11 -*-===// 2 | // 3 | // __ __ _ _ 4 | // | | |___| |_|_| 5 | // |_ _| -_| _| | 6 | // |_| |___|_| |_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | 12 | #include "yeti/world.h" 13 | 14 | #include "yeti/resource_manager.h" 15 | 16 | #include "yeti/resources/level_resource.h" 17 | #include "yeti/resources/entity_resource.h" 18 | #include "yeti/resources/prefab_resource.h" 19 | 20 | #include "yeti/task.h" 21 | #include "yeti/task_scheduler.h" 22 | 23 | namespace yeti { 24 | 25 | World::World() 26 | : entities_() 27 | , systems_(&entities_) 28 | , transforms_((TransformSystem *)systems_.lookup("transform")) 29 | , cameras_((CameraSystem *)systems_.lookup("camera")) 30 | , lights_((LightSystem *)systems_.lookup("light")) 31 | { 32 | } 33 | 34 | World::~World() { 35 | } 36 | 37 | World *World::create() { 38 | World *world = YETI_NEW(World, core::global_heap_allocator()); 39 | return world; 40 | } 41 | 42 | void World::update(const f32 delta_time) { 43 | yeti_assert_debug(delta_time >= 0.f); 44 | 45 | // Build task graph. 46 | // Kick and wait. 47 | } 48 | 49 | void World::destroy() { 50 | YETI_DELETE(World, core::global_heap_allocator(), this); 51 | } 52 | 53 | Entity World::spawn(Resource::Id id, 54 | const Vec3 &position, 55 | const Quaternion &rotation, 56 | const Vec3 &scale) { 57 | const EntityResource *resource = 58 | (const EntityResource *)resource_manager::lookup(id); 59 | 60 | if (resource_manager::autoloads()) { 61 | // Wait until resource is loaded. 62 | while (resource_manager::state(id) != Resource::LOADED) 63 | core::Thread::yield(); 64 | } else { 65 | yeti_assert_development(resource != NULL); 66 | yeti_assert_development(resource_manager::state(id) == Resource::LOADED); 67 | } 68 | 69 | const Entity entity = entities_.create(); 70 | 71 | // TODO(mtwilliams): Create components. 72 | // TODO(mtwilliams): Lifecycle events. 73 | 74 | resource->deref(); 75 | 76 | return entity; 77 | } 78 | 79 | void World::kill(Entity entity) { 80 | // TODO(mtwilliams): Lifecycle events. 81 | 82 | entities_.destroy(entity); 83 | } 84 | 85 | } // yeti 86 | -------------------------------------------------------------------------------- /tools/resource_compiler/include/yeti/resource_compiler/runner.h: -------------------------------------------------------------------------------- 1 | //===-- yeti/resource_compiler/runner.h -----------------*- mode: C++11 -*-===// 2 | // 3 | // __ __ _ _ 4 | // | | |___| |_|_| 5 | // |_ _| -_| _| | 6 | // |_| |___|_| |_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | // 12 | // TODO(mtwilliams): Document the purpose of this file. 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | #ifndef _YETI_RESOURCE_COMPILER_RUNNER_H_ 17 | #define _YETI_RESOURCE_COMPILER_RUNNER_H_ 18 | 19 | #include "yeti.h" 20 | 21 | namespace yeti { 22 | namespace resource_compiler { 23 | 24 | class Runner { 25 | YETI_DISALLOW_COPYING(Runner) 26 | 27 | public: 28 | Runner(); 29 | ~Runner(); 30 | 31 | public: 32 | void setup(const char *args[], const u32 num_args); 33 | void run(); 34 | 35 | private: 36 | // Starts logging to console. 37 | void start_logging_to_console() const; 38 | 39 | private: 40 | ResourceDatabase *resource_database_; 41 | 42 | ResourceCompiler::Options resource_compiler_options_; 43 | ResourceCompiler *resource_compiler_; 44 | 45 | bool force_; 46 | bool watch_; 47 | }; 48 | 49 | } // resource_compiler 50 | } // yeti 51 | 52 | #endif // _YETI_RESOURCE_COMPILER_RUNNER_H_ 53 | -------------------------------------------------------------------------------- /tools/resource_compiler/src/yeti/resource_compiler.cc: -------------------------------------------------------------------------------- 1 | //===-- yeti/runtime.cc ---------------------------------*- mode: C++11 -*-===// 2 | // 3 | // __ __ _ _ 4 | // | | |___| |_|_| 5 | // |_ _| -_| _| | 6 | // |_| |___|_| |_| 7 | // 8 | // This file is distributed under the terms described in LICENSE. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | 12 | #include "yeti.h" 13 | 14 | #include "yeti/resource_compiler/runner.h" 15 | 16 | #include 17 | #include 18 | #include 19 | 20 | int main(int argc, const char *argv[]) { 21 | ::setlocale(LC_ALL, "en_US.UTF-8"); 22 | 23 | yeti::Config config; 24 | 25 | config.app.id = NULL; 26 | config.app.publisher = NULL; 27 | 28 | config.user.settings = NULL; 29 | config.user.saves = NULL; 30 | 31 | config.resources.database = NULL; 32 | config.resources.autoload = false; 33 | 34 | config.keyboard.raw = true; 35 | config.mouse.raw = true; 36 | 37 | config.debug.floating_point_exceptions = true; 38 | config.debug.memory = false; 39 | 40 | // Spawn a worker thread for each logical core, minus one for the main thread. 41 | config.workers = -1; 42 | 43 | yeti::boot(config); 44 | 45 | yeti::resource_compiler::Runner resource_compiler_runner; 46 | resource_compiler_runner.setup(&argv[1], argc - 1); 47 | resource_compiler_runner.run(); 48 | 49 | yeti::shutdown(); 50 | 51 | return EXIT_SUCCESS; 52 | } 53 | -------------------------------------------------------------------------------- /yeti.sublime-project: -------------------------------------------------------------------------------- 1 | { 2 | "folders": 3 | [ 4 | { 5 | "path": ".", 6 | 7 | "follow_symlinks": true, 8 | 9 | "file_exclude_patterns": [ 10 | "*.sublime-workspace", 11 | 12 | "_build/*.cc" 13 | ], 14 | 15 | "folder_exclude_patterns": [ 16 | "_build/tools", 17 | 18 | "_build/obj", 19 | "_build/lib", 20 | "_build/bin", 21 | 22 | "_deps", 23 | "_rel", 24 | ] 25 | } 26 | ] 27 | } 28 | --------------------------------------------------------------------------------