Created
May 30, 2014 19:55
-
-
Save Ms2ger/ad8078dced745b9be651 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern fn setRequestHeader(cx: *mut JSContext, _obj: JSHandleObject, this: *XMLHttpRequest, argc: libc::c_uint, vp: *mut JSVal) -> JSBool { | |
unsafe { | |
let this = JS::from_raw(this); | |
let mut this = this.root(); | |
if argc < 2 { | |
throw_type_error(cx, "Not enough arguments to \"XMLHttpRequest.setRequestHeader\"."); | |
return 0; | |
} | |
let argv = JS_ARGV(cx, vp); | |
let mut arg0: ByteString = match FromJSValConvertible::from_jsval(cx, (*argv.offset(0)), ()) { | |
Ok(strval) => strval, | |
Err(_) => { return 0; }, | |
}; | |
let mut arg1: ByteString = match FromJSValConvertible::from_jsval(cx, (*argv.offset(1)), ()) { | |
Ok(strval) => strval, | |
Err(_) => { return 0; }, | |
}; | |
let result: Result<(), Error> = (*this).SetRequestHeader(arg0, arg1); | |
let result = match result { | |
Ok(result) => result, | |
Err(e) => { | |
let global = global_object_for_js_object(this.reflector().get_jsobject()).root(); | |
throw_dom_exception(cx, &*global, e); | |
return false as JSBool; | |
}, | |
}; | |
*vp = (result).to_jsval(cx); | |
return 1; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment