Skip to content

Commit

Permalink
Use helper is_typed_array function
Browse files Browse the repository at this point in the history
  • Loading branch information
Xanewok committed Mar 14, 2018
1 parent 6beb32e commit c29fcb8
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions components/script/dom/bindings/codegen/CodegenRust.py
Expand Up @@ -870,7 +870,7 @@ def wrapObjectTemplate(templateBody, nullValue, isDefinitelyObject, type,

return handleOptional(templateBody, declType, handleDefaultNull("None"))

if type.isTypedArray() or type.isArrayBuffer() or type.isArrayBufferView() or type.isSharedArrayBuffer():
if is_typed_array(type):
if failureCode is None:
substitutions = {
"sourceDescription": sourceDescription,
Expand Down Expand Up @@ -4182,7 +4182,7 @@ def getUnionTypeTemplateVars(type, descriptorProvider):
elif type.isObject():
name = type.name
typeName = "Heap<*mut JSObject>"
elif type.isTypedArray() or type.isArrayBuffer() or type.isArrayBufferView() or type.isSharedArrayBuffer():
elif is_typed_array(type):
name = type.name
typeName = "typedarray::Heap" + name
else:
Expand Down Expand Up @@ -6468,7 +6468,7 @@ def type_needs_tracing(t):
if t.isUnion():
return any(type_needs_tracing(member) for member in t.flatMemberTypes)

if t.isTypedArray() or t.isArrayBuffer() or t.isArrayBufferView() or t.isSharedArrayBuffer():
if is_typed_array(t):
return True

return False
Expand All @@ -6491,6 +6491,12 @@ def type_needs_tracing(t):
assert False, (t, type(t))


def is_typed_array(t):
assert isinstance(t, IDLObject), (t, type(t))

return t.isTypedArray() or t.isArrayBuffer() or t.isArrayBufferView() or t.isSharedArrayBuffer()


def type_needs_auto_root(t):
"""
Certain IDL types, such as `sequence<any>` or `sequence<object>` need to be
Expand All @@ -6501,8 +6507,8 @@ def type_needs_auto_root(t):
if t.isType():
if t.isSequence() and (t.inner.isAny() or t.inner.isObject()):
return True
# SpiderMonkey interfaces
if t.isTypedArray() or t.isArrayBuffer() or t.isArrayBufferView() or t.isSharedArrayBuffer():
# SpiderMonkey interfaces, we currently don't support any other except typed arrays
if is_typed_array(t):
return True

return False
Expand Down

0 comments on commit c29fcb8

Please sign in to comment.