mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Avoid a type error with a non-null default value for an optional nullable string argument.
This commit is contained in:
parent
716e1ce144
commit
54a59b9d38
3 changed files with 15 additions and 9 deletions
|
@ -1063,13 +1063,19 @@ for (uint32_t i = 0; i < length; ++i) {
|
|||
assert(type.nullable())
|
||||
return handleDefault(conversionCode,
|
||||
"%s.SetNull()" % varName)
|
||||
return handleDefault(
|
||||
conversionCode,
|
||||
("static data: [u8, ..%s] = [ %s ];\n"
|
||||
"%s = str::from_utf8(data).to_owned()" %
|
||||
|
||||
value = "str::from_utf8(data).to_owned()"
|
||||
if type.nullable():
|
||||
value = "Some(%s)" % value
|
||||
|
||||
default = (
|
||||
"static data: [u8, ..%s] = [ %s ];\n"
|
||||
"%s = %s" %
|
||||
(len(defaultValue.value) + 1,
|
||||
", ".join(["'" + char + "' as u8" for char in defaultValue.value] + ["0"]),
|
||||
varName)))
|
||||
varName, value))
|
||||
|
||||
return handleDefault(conversionCode, default)
|
||||
|
||||
if isMember:
|
||||
# We have to make a copy, because our jsval may well not
|
||||
|
|
|
@ -134,7 +134,7 @@ impl TestBinding {
|
|||
pub fn PassOptionalNullableUnsignedLongLongWithNonNullDefault(&self, _: Option<u64>) {}
|
||||
// pub fn PassOptionalNullableFloatWithNonNullDefault(&self, _: Option<f32>) {}
|
||||
// pub fn PassOptionalNullableDoubleWithNonNullDefault(&self, _: Option<f64>) {}
|
||||
// pub fn PassOptionalNullableStringWithNonNullDefault(&self, _: Option<DOMString>) {}
|
||||
pub fn PassOptionalNullableStringWithNonNullDefault(&self, _: Option<DOMString>) {}
|
||||
}
|
||||
|
||||
impl Reflectable for TestBinding {
|
||||
|
|
|
@ -94,5 +94,5 @@ interface TestBinding {
|
|||
void passOptionalNullableUnsignedLongLongWithNonNullDefault(optional unsigned long long? arg = 7);
|
||||
// void passOptionalNullableFloatWithNonNullDefault(optional float? arg = 0.0);
|
||||
// void passOptionalNullableDoubleWithNonNullDefault(optional double? arg = 0.0);
|
||||
// void passOptionalNullableStringWithNonNullDefault(optional DOMString? arg = "");
|
||||
void passOptionalNullableStringWithNonNullDefault(optional DOMString? arg = "");
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue