mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Make DOMString represent a non-nullable string.
This commit is contained in:
parent
2975cb69e3
commit
803cd4b7cf
75 changed files with 632 additions and 632 deletions
|
@ -116,9 +116,9 @@ extern fn InterfaceObjectToString(cx: *JSContext, _argc: c_uint, vp: *mut JSVal)
|
|||
}
|
||||
}
|
||||
|
||||
pub type DOMString = Option<~str>;
|
||||
pub type DOMString = ~str;
|
||||
|
||||
pub fn null_str_as_empty(s: &DOMString) -> ~str {
|
||||
pub fn null_str_as_empty(s: &Option<DOMString>) -> ~str {
|
||||
// We don't use map_default because it would allocate ~"" even for Some.
|
||||
match *s {
|
||||
Some(ref s) => s.clone(),
|
||||
|
@ -126,14 +126,14 @@ pub fn null_str_as_empty(s: &DOMString) -> ~str {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn null_str_as_empty_ref<'a>(s: &'a DOMString) -> &'a str {
|
||||
pub fn null_str_as_empty_ref<'a>(s: &'a Option<DOMString>) -> &'a str {
|
||||
match *s {
|
||||
Some(ref s) => s.as_slice(),
|
||||
None => &'a ""
|
||||
}
|
||||
}
|
||||
|
||||
pub fn null_str_as_word_null(s: &DOMString) -> ~str {
|
||||
pub fn null_str_as_word_null(s: &Option<DOMString>) -> ~str {
|
||||
// We don't use map_default because it would allocate ~"null" even for Some.
|
||||
match *s {
|
||||
Some(ref s) => s.clone(),
|
||||
|
@ -259,7 +259,7 @@ pub fn jsval_to_str(cx: *JSContext, v: JSVal,
|
|||
}
|
||||
|
||||
#[fixed_stack_segment]
|
||||
pub fn jsval_to_domstring(cx: *JSContext, v: JSVal) -> Result<DOMString, ()> {
|
||||
pub fn jsval_to_domstring(cx: *JSContext, v: JSVal) -> Result<Option<DOMString>, ()> {
|
||||
if jsval::is_null(v) || jsval::is_undefined(v) {
|
||||
Ok(None)
|
||||
} else {
|
||||
|
@ -273,7 +273,7 @@ pub fn jsval_to_domstring(cx: *JSContext, v: JSVal) -> Result<DOMString, ()> {
|
|||
}
|
||||
|
||||
#[fixed_stack_segment]
|
||||
pub unsafe fn domstring_to_jsval(cx: *JSContext, string: &DOMString) -> JSVal {
|
||||
pub unsafe fn domstring_to_jsval(cx: *JSContext, string: &Option<DOMString>) -> JSVal {
|
||||
match string {
|
||||
&None => JSVAL_NULL,
|
||||
&Some(ref s) => do s.to_utf16().as_imm_buf |buf, len| {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue