mirror of
https://github.com/servo/servo.git
synced 2025-06-11 18:10:11 +00:00
Implement WebIDL codegen for ByteString.
This commit is contained in:
parent
541d581c32
commit
8c879c8bf8
6 changed files with 100 additions and 2 deletions
|
@ -687,6 +687,24 @@ def getJSToNativeConversionTemplate(type, descriptorProvider, failureCode=None,
|
|||
|
||||
return handleOptional(getConversionCode(), CGGeneric(declType), isOptional)
|
||||
|
||||
if type.isByteString():
|
||||
assert not isEnforceRange and not isClamp
|
||||
|
||||
conversionCode = (
|
||||
"match FromJSValConvertible::from_jsval(cx, ${val}, ()) {\n"
|
||||
" Ok(strval) => strval,\n"
|
||||
" Err(_) => { %s },\n"
|
||||
"}" % exceptionCode)
|
||||
|
||||
declType = CGGeneric("ByteString")
|
||||
if type.nullable():
|
||||
declType = CGWrapper(declType, pre="Option<", post=">")
|
||||
conversionCode = handleDefaultNull(conversionCode, "None")
|
||||
else:
|
||||
assert defaultValue is None
|
||||
|
||||
return handleOptional(conversionCode, declType, isOptional)
|
||||
|
||||
if type.isEnum():
|
||||
assert not isEnforceRange and not isClamp
|
||||
|
||||
|
@ -996,6 +1014,11 @@ def getRetvalDeclarationForType(returnType, descriptorProvider):
|
|||
if returnType.nullable():
|
||||
result = CGWrapper(result, pre="Option<", post=">")
|
||||
return result
|
||||
if returnType.isByteString():
|
||||
result = CGGeneric("ByteString")
|
||||
if returnType.nullable():
|
||||
result = CGWrapper(result, pre="Option<", post=">")
|
||||
return result
|
||||
if returnType.isEnum():
|
||||
result = CGGeneric(returnType.unroll().inner.identifier.name)
|
||||
if returnType.nullable():
|
||||
|
@ -4283,11 +4306,12 @@ class CGBindingRoot(CGThing):
|
|||
'dom::bindings::error::{FailureUnknown, Fallible, Error, ErrorResult}',
|
||||
'dom::bindings::error::{throw_method_failed_with_details}',
|
||||
'dom::bindings::error::throw_type_error',
|
||||
'script_task::JSPageInfo',
|
||||
'dom::bindings::proxyhandler',
|
||||
'dom::bindings::proxyhandler::{_obj_toString, defineProperty}',
|
||||
'dom::bindings::proxyhandler::{FillPropertyDescriptor, GetExpandoObject}',
|
||||
'dom::bindings::proxyhandler::{getPropertyDescriptor}',
|
||||
'dom::bindings::str::ByteString',
|
||||
'script_task::JSPageInfo',
|
||||
'libc',
|
||||
'servo_util::str::DOMString',
|
||||
'servo_util::vec::zip_copies',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue