aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/bindings/codegen/CodegenRust.py
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2018-03-23 15:15:38 -0400
committerGitHub <noreply@github.com>2018-03-23 15:15:38 -0400
commite8fdc677f440919507209ed42d0ea042c700042c (patch)
treefab6934483c93cf67273458bd193c75e3f3a7d64 /components/script/dom/bindings/codegen/CodegenRust.py
parent18ef5874dd3e11551e2f9503746540847eeb974c (diff)
parent80c6891f339c52778ee7133b3b3f8ae9c8c350e5 (diff)
downloadservo-e8fdc677f440919507209ed42d0ea042c700042c.tar.gz
servo-e8fdc677f440919507209ed42d0ea042c700042c.zip
Auto merge of #20396 - Xanewok:webgl-typed-arrays, r=jdm
Replace `object` function arguments in WebGL with typed arrays <!-- Please describe your changes on the following line: --> Could use a https://github.com/servo/rust-mozjs/pull/402 in some places, as this should simplify a little bit and remove unnecessary `#[allow(unsafe_code)]` attributes. I sort of hacked my way through for https://github.com/servo/servo/issues/20394 since I encountered this issue as well. I agree that the comment above makes me feel uneasy about this and feels like I'm missing something and this shouldn't be the way we eventually resolve the overloads with auto rootable types (talking about this: https://github.com/servo/servo/pull/20396/files#diff-60d01595cff328c165842fea9e4ccbc2R428). r? @jdm --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #20342 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [X] These changes do not require tests because if the bindings compile now, it works! <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/20396) <!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom/bindings/codegen/CodegenRust.py')
-rw-r--r--components/script/dom/bindings/codegen/CodegenRust.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py
index 24054de8e95..de991f35ed9 100644
--- a/components/script/dom/bindings/codegen/CodegenRust.py
+++ b/components/script/dom/bindings/codegen/CodegenRust.py
@@ -422,7 +422,8 @@ class CGMethodCall(CGThing):
template,
{"val": distinguishingArg},
declType,
- "arg%d" % distinguishingIndex)
+ "arg%d" % distinguishingIndex,
+ needsAutoRoot=type_needs_auto_root(type))
# Indent by 4, since we need to indent further than our "do" statement
caseBody.append(CGIndenter(testCode, 4))
@@ -1211,7 +1212,8 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
def instantiateJSToNativeConversionTemplate(templateBody, replacements,
- declType, declName):
+ declType, declName,
+ needsAutoRoot=False):
"""
Take the templateBody and declType as returned by
getJSToNativeConversionInfo, a set of replacements as required by the
@@ -1236,6 +1238,8 @@ def instantiateJSToNativeConversionTemplate(templateBody, replacements,
else:
result.append(conversion)
+ if needsAutoRoot:
+ result.append(CGGeneric("auto_root!(in(cx) let %s = %s);" % (declName, declName)))
# Add an empty CGGeneric to get an extra newline after the argument
# conversion.
result.append(CGGeneric(""))
@@ -1318,11 +1322,8 @@ class CGArgumentConverter(CGThing):
arg = "arg%d" % index
self.converter = instantiateJSToNativeConversionTemplate(
- template, replacementVariables, declType, arg)
-
- # The auto rooting is done only after the conversion is performed
- if type_needs_auto_root(argument.type):
- self.converter.append(CGGeneric("auto_root!(in(cx) let %s = %s);" % (arg, arg)))
+ template, replacementVariables, declType, arg,
+ needsAutoRoot=type_needs_auto_root(argument.type))
else:
assert argument.optional