forked from shaka-project/shaka-player
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Add utility to keep unused parameters (shaka-project#4233)
Many times in our default configuration, we need to create an empty default implementation of a callback. The compiler wants to strip out unused parameters from these functions, but this breaks our runtime-type-checking for functions in configure(). We need a way to keep the full function signature in default config callbacks in compiled mode. This adds a new utility: ConfigUtils.referenceParametersAndReturn(). It references the input parameters so the compiler doesn't remove them from the calling function, and returns whatever value is specified. The utility function is marked with `@noinline`, so the compiler won't tamper with it. Default config callbacks that use this utility will still bear the complete function signature even in compiled mode. The caller should look something like this: ```js const callback = (a, b, c, d) => { return referenceParametersAndReturn( [a, b, c, d], a); // Can be anything, doesn't need to be one of the parameters }; ``` See also shaka-project#4231 (comment)
- Loading branch information
1 parent
87e9187
commit 4ae3a08
Showing
2 changed files
with
34 additions
and
14 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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