mirror of
https://github.com/servo/servo.git
synced 2025-06-15 20:04:28 +00: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()" %
|
||||
(len(defaultValue.value) + 1,
|
||||
", ".join(["'" + char + "' as u8" for char in defaultValue.value] + ["0"]),
|
||||
varName)))
|
||||
|
||||
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, value))
|
||||
|
||||
return handleDefault(conversionCode, default)
|
||||
|
||||
if isMember:
|
||||
# We have to make a copy, because our jsval may well not
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue