mirror of
https://github.com/servo/servo.git
synced 2025-10-18 09:19:16 +01:00
Stop passing DOMStrings via borrowed pointer. (#1201)
This commit is contained in:
parent
b1762655e6
commit
f5ef4365f4
74 changed files with 364 additions and 366 deletions
|
@ -1584,9 +1584,9 @@ for (uint32_t i = 0; i < length; ++i) {
|
|||
|
||||
if type.isString():
|
||||
if type.nullable():
|
||||
return (wrapAndSetPtr("*${jsvalPtr} = domstring_to_jsval(cx, &%s)" % result), False)
|
||||
return (wrapAndSetPtr("*${jsvalPtr} = domstring_to_jsval(cx, %s)" % result), False)
|
||||
else:
|
||||
return (wrapAndSetPtr("*${jsvalPtr} = str_to_jsval(cx, &%s)" % result), False)
|
||||
return (wrapAndSetPtr("*${jsvalPtr} = str_to_jsval(cx, %s)" % result), False)
|
||||
|
||||
if type.isEnum():
|
||||
if type.nullable():
|
||||
|
@ -2961,9 +2961,7 @@ class CGCallGenerator(CGThing):
|
|||
if a.type.isObject() and not a.type.nullable() and not a.optional:
|
||||
name = "(JSObject&)" + name
|
||||
#XXXjdm Perhaps we should pass all nontrivial types by borrowed pointer
|
||||
# Aoid passing Option<Option<DOMString>> by reference. If only one of optional or
|
||||
# defaultValue are truthy we pass an Option, otherwise it's a concrete Option<DOMString>.
|
||||
if a.type.isDictionary() or (a.type.isString() and not (bool(a.defaultValue) ^ a.optional)):
|
||||
if a.type.isDictionary():
|
||||
name = "&" + name
|
||||
args.append(CGGeneric(name))
|
||||
|
||||
|
|
|
@ -111,7 +111,7 @@ extern fn InterfaceObjectToString(cx: *JSContext, _argc: c_uint, vp: *mut JSVal)
|
|||
assert!(jsval::is_string(v));
|
||||
let name = jsstring_to_str(cx, jsval::to_string(v));
|
||||
let retval = Some(~"function " + name + "() {\n [native code]\n}");
|
||||
*vp = domstring_to_jsval(cx, &retval);
|
||||
*vp = domstring_to_jsval(cx, retval);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
@ -273,7 +273,7 @@ pub fn jsval_to_domstring(cx: *JSContext, v: JSVal) -> Result<Option<DOMString>,
|
|||
}
|
||||
|
||||
#[fixed_stack_segment]
|
||||
pub unsafe fn str_to_jsval(cx: *JSContext, string: &DOMString) -> JSVal {
|
||||
pub unsafe fn str_to_jsval(cx: *JSContext, string: DOMString) -> JSVal {
|
||||
do string.to_utf16().as_imm_buf |buf, len| {
|
||||
let jsstr = JS_NewUCStringCopyN(cx, buf, len as libc::size_t);
|
||||
if jsstr.is_null() {
|
||||
|
@ -286,10 +286,10 @@ pub unsafe fn str_to_jsval(cx: *JSContext, string: &DOMString) -> JSVal {
|
|||
}
|
||||
|
||||
#[fixed_stack_segment]
|
||||
pub unsafe fn domstring_to_jsval(cx: *JSContext, string: &Option<DOMString>) -> JSVal {
|
||||
pub unsafe fn domstring_to_jsval(cx: *JSContext, string: Option<DOMString>) -> JSVal {
|
||||
match string {
|
||||
&None => JSVAL_NULL,
|
||||
&Some(ref s) => str_to_jsval(cx, s),
|
||||
None => JSVAL_NULL,
|
||||
Some(s) => str_to_jsval(cx, s),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue