diff options
Diffstat (limited to 'src/components/script/dom/bindings/codegen/CodegenRust.py')
-rw-r--r-- | src/components/script/dom/bindings/codegen/CodegenRust.py | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/src/components/script/dom/bindings/codegen/CodegenRust.py b/src/components/script/dom/bindings/codegen/CodegenRust.py index 5f613f8790e..62cb66d5f1f 100644 --- a/src/components/script/dom/bindings/codegen/CodegenRust.py +++ b/src/components/script/dom/bindings/codegen/CodegenRust.py @@ -555,7 +555,7 @@ def getJSToNativeConversionTemplate(type, descriptorProvider, failureCode=None, raise TypeError("Can't handle unions as members, we have a " "holderType") - declType = CGGeneric(type.name) + declType = CGGeneric(type.name + "::" + type.name) if type.nullable(): declType = CGWrapper(declType, pre="Option<", post=" >") @@ -1657,6 +1657,20 @@ def UnionTypes(descriptors, dictionaries, callbacks, config): Returns a CGList containing CGUnionStructs for every union. """ + imports = [ + 'dom::bindings::utils::unwrap_jsmanaged', + 'dom::bindings::codegen::PrototypeList', + 'dom::bindings::conversions::FromJSValConvertible', + 'dom::bindings::conversions::ToJSValConvertible', + 'dom::bindings::conversions::Default', + 'dom::bindings::error::throw_not_in_union', + 'dom::bindings::js::JS', + 'dom::types::*', + 'js::jsapi::JSContext', + 'js::jsval::JSVal', + 'servo_util::str::DOMString', + ] + # Now find all the things we'll need as arguments and return values because # we need to wrap or unwrap them. unionStructs = dict() @@ -1668,7 +1682,12 @@ def UnionTypes(descriptors, dictionaries, callbacks, config): name = str(t) if not name in unionStructs: provider = descriptor or config.getDescriptorProvider() - unionStructs[name] = CGList([CGUnionStruct(t, provider), CGUnionConversionStruct(t, provider)]) + unionStructs[name] = CGNamespace(name, + CGImports(CGList([ + CGUnionStruct(t, provider), + CGUnionConversionStruct(t, provider) + ]), [], imports), + public=True) return CGList(SortedDictValues(unionStructs), "\n\n") @@ -4531,7 +4550,7 @@ class CGNativeMember(ClassMethod): if type.isUnion(): if type.nullable(): type = type.inner - return str(type), False, True + return str(type) + "::" + str(type), False, True if type.isGeckoInterface() and not type.isCallbackInterface(): iface = type.unroll().inner @@ -5315,20 +5334,6 @@ class GlobalGenRoots(): config.getCallbacks(), config) - curr = CGImports(curr, [], [ - 'dom::bindings::utils::unwrap_jsmanaged', - 'dom::bindings::codegen::PrototypeList', - 'dom::bindings::conversions::FromJSValConvertible', - 'dom::bindings::conversions::ToJSValConvertible', - 'dom::bindings::conversions::Default', - 'dom::bindings::error::throw_not_in_union', - 'dom::bindings::js::JS', - 'dom::types::*', - 'js::jsapi::JSContext', - 'js::jsval::JSVal', - 'servo_util::str::DOMString', - ]) - # Add the auto-generated comment. curr = CGWrapper(curr, pre=AUTOGENERATED_WARNING_COMMENT) |