From b31fdf12efa8797240d04c83861105a859f44c3e Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Wed, 16 Apr 2014 18:27:36 +0200 Subject: [PATCH 1/2] Add a few tests for dictionary codegen. --- .../script/dom/webidls/TestBinding.webidl | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/components/script/dom/webidls/TestBinding.webidl b/src/components/script/dom/webidls/TestBinding.webidl index 4cc2fac87f9..23504dd2c44 100644 --- a/src/components/script/dom/webidls/TestBinding.webidl +++ b/src/components/script/dom/webidls/TestBinding.webidl @@ -4,6 +4,40 @@ enum TestEnum { "", "foo", "bar" }; +/* dictionary TestDictionary { + // boolean booleanValue; + // byte byteValue; + // octet octetValue; + // short shortValue; + // unsigned short unsignedShortValue; + // long longValue; + // unsigned long unsignedLongValue; + // long long longLongValue; + // unsigned long long unsignedLongLongValue; + // float floatValue; + // double doubleValue; + // DOMString stringValue; + // TestEnum enumValue; + // Blob interfaceValue; + // any anyValue; +}; */ + +dictionary TestDictionaryDefaults { + // boolean booleanValue = false; + // byte byteValue = 7; + // octet octetValue = 7; + short shortValue = 7; + unsigned short unsignedShortValue = 7; + long longValue = 7; + unsigned long unsignedLongValue = 7; + // long long longLongValue = 7; + // unsigned long long unsignedLongLongValue = 7; + // float floatValue = 7.0; + // double doubleValue = 7.0; + DOMString stringValue = ""; + // TestEnum enumValue = "bar"; +}; + interface TestBinding { attribute boolean booleanAttribute; attribute byte byteAttribute; From 5ac5ba246896778ebeaba396687135efc72aead9 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Fri, 18 Apr 2014 11:37:56 +0200 Subject: [PATCH 2/2] Support nullable strings in dictionaries. We copy the string in all cases, so there's no need to handle the isMember case differently. --- .../script/dom/bindings/codegen/CodegenRust.py | 7 ------- .../script/dom/webidls/TestBinding.webidl | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/components/script/dom/bindings/codegen/CodegenRust.py b/src/components/script/dom/bindings/codegen/CodegenRust.py index 8d89fe1b879..0746613d80c 100644 --- a/src/components/script/dom/bindings/codegen/CodegenRust.py +++ b/src/components/script/dom/bindings/codegen/CodegenRust.py @@ -702,13 +702,6 @@ def getJSToNativeConversionTemplate(type, descriptorProvider, failureCode=None, return handleDefault(conversionCode, default) - if isMember: - # We have to make a copy, because our jsval may well not - # live as long as our string needs to. - declType = CGGeneric("DOMString") - return ("%s\n" % getConversionCode(), - declType, None, isOptional, None) - declType = "DOMString" initialValue = None if type.nullable(): diff --git a/src/components/script/dom/webidls/TestBinding.webidl b/src/components/script/dom/webidls/TestBinding.webidl index 23504dd2c44..1e7a36cb253 100644 --- a/src/components/script/dom/webidls/TestBinding.webidl +++ b/src/components/script/dom/webidls/TestBinding.webidl @@ -36,6 +36,20 @@ dictionary TestDictionaryDefaults { // double doubleValue = 7.0; DOMString stringValue = ""; // TestEnum enumValue = "bar"; + + // boolean? nullableBooleanValue = false; + // byte? nullableByteValue = 7; + // octet? nullableOctetValue = 7; + short? nullableShortValue = 7; + unsigned short? nullableUnsignedShortValue = 7; + long? nullableLongValue = 7; + unsigned long? nullableUnsignedLongValue = 7; + // long long? nullableLongLongValue = 7; + // unsigned long long? nullableUnsignedLongLongValue = 7; + // float? nullableFloatValue = 7.0; + // double? nullableDoubleValue = 7.0; + DOMString? nullableStringValue = ""; + // TestEnum? nullableEnumValue = "bar"; }; interface TestBinding {