Add configurable assertions - #288
Merged
Merged
Conversation
entity.set previously wrote the store silently for a trait the entity had not been given. Every trait now throws instead, so a write can never land in a column the entity does not own. The check reads the membership bit from the trait instance that set already looks up, so it costs one mask read.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Builds an assertion layer that can be compiled in or out that validates design contracts are held at runtime. This assertion layer is composable and adds a small overhead of around 10% for the specific calls. This covers entity operations to enforce entities are alive, traits exist being written to or relation targets exist.
entity.add(...)entity.remove(...)entity.destroy()entity.get(...)entity.has(...)entity.set(...)— including callback writebackentity.changed(...)entity.targetFor(...)entity.targetsFor(...)World
spawn/add/remove/get/setreach the same checked core paths.They are compiled in dev builds and out of prod builds by default. Define
__KOOTA_ASSERTS__astrueto retain them in production, orfalseto remove them completely from the application bundle.