Remove nullfunc_t and make INVALID_FUNCTION the same as null. #912
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.
INVALID_FUNCTION was proving to be a major pain; setting it to -1 might be one of the dumbest things I've done. It had a few problems all boiling down to "there is no support in the compiler for non-zero false values". Eg,
f1 == f2
is false below:We could have gone through and fixed all the edge cases like this throughout the compiler, but it seems counter-productive.
The other oddity is that because
null
is 0,INVALID_FUNCTION
needed a separate unit type, which we callednullfunc_t
.Rather than keep propping up all this weirdness, this patch normalizes
INVALID_FUNCTION
by making it equivalent tonull
. Its value is 0, and its type isnull_t
.This will break compatibility with cross-plugin interactions, so plugins sharing a scripted API will need to be recompiled.
It will also break C++ code relying on a -1 value. To help assist with this breakage, three functions have been added to
IPluginContext
:GetNullFunctionValue()
IsNullFunctionId()
GetFunctionByIdOrNull()
.