Auto merge of #6223 - nox:merge-generic-functions, r=Ms2ger

Merge generic funs to share them across all bindings (fixes #2684)



<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6223)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2015-06-24 03:54:56 -06:00
commit 6247a96761
5 changed files with 185 additions and 200 deletions

View file

@ -4,6 +4,7 @@
//! Utilities to throw exceptions from Rust bindings.
use dom::bindings::codegen::PrototypeList::proto_id_to_name;
use dom::bindings::conversions::ToJSValConvertible;
use dom::bindings::global::GlobalRef;
use dom::domexception::{DOMException, DOMErrorName};
@ -149,6 +150,15 @@ pub fn throw_not_in_union(cx: *mut JSContext, names: &'static str) {
throw_type_error(cx, &error);
}
/// Throw an exception to signal that a `JSObject` can not be converted to a
/// given DOM type.
pub fn throw_invalid_this(cx: *mut JSContext, proto_id: u16) {
debug_assert!(unsafe { JS_IsExceptionPending(cx) } == 0);
let error = format!("\"this\" object does not implement interface {}.",
proto_id_to_name(proto_id));
throw_type_error(cx, &error);
}
/// Format string used to throw javascript errors.
static ERROR_FORMAT_STRING_STRING: [libc::c_char; 4] = [
'{' as libc::c_char,