aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/bindings/codegen
diff options
context:
space:
mode:
authorMs2ger <Ms2ger@gmail.com>2015-11-09 12:11:18 +0100
committerMs2ger <Ms2ger@gmail.com>2015-11-12 10:20:19 +0100
commitacb24e80b87d043173e2e8b2a31ef3fdb610767b (patch)
tree10572ffac61e5ce64ee2495a8cee779795fa30d8 /components/script/dom/bindings/codegen
parentddaa1a1960a6abd49ea268fa4edb00f31b26e8db (diff)
downloadservo-acb24e80b87d043173e2e8b2a31ef3fdb610767b.tar.gz
servo-acb24e80b87d043173e2e8b2a31ef3fdb610767b.zip
Use throw_type_error and throw_range_error from js.
Diffstat (limited to 'components/script/dom/bindings/codegen')
-rw-r--r--components/script/dom/bindings/codegen/CodegenRust.py15
1 files changed, 5 insertions, 10 deletions
diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py
index 260ef1e9006..fbe2c46e9de 100644
--- a/components/script/dom/bindings/codegen/CodegenRust.py
+++ b/components/script/dom/bindings/codegen/CodegenRust.py
@@ -888,21 +888,16 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
else:
handleInvalidEnumValueCode = "return true;"
- transmute = "mem::transmute(index)"
- if isMember == 'Dictionary':
- transmute = 'unsafe { ' + transmute + ' }'
-
template = (
"match find_enum_string_index(cx, ${val}, %(values)s) {\n"
" Err(_) => { %(exceptionCode)s },\n"
" Ok(None) => { %(handleInvalidEnumValueCode)s },\n"
" Ok(Some(index)) => {\n"
" //XXXjdm need some range checks up in here.\n"
- " %(transmute)s\n"
+ " mem::transmute(index)\n"
" },\n"
"}" % {"values": enum + "Values::strings",
"exceptionCode": exceptionCode,
- "transmute": transmute,
"handleInvalidEnumValueCode": handleInvalidEnumValueCode})
if defaultValue is not None:
@@ -3649,7 +3644,7 @@ class CGUnionConversionStruct(CGThing):
names.append(name)
conversions.append(CGGeneric(
- "throw_not_in_union(cx, \"%s\");\n"
+ "unsafe { throw_not_in_union(cx, \"%s\"); }\n"
"Err(())" % ", ".join(names)))
method = CGWrapper(
CGIndenter(CGList(conversions, "\n\n")),
@@ -4952,10 +4947,10 @@ class CGDictionary(CGThing):
return string.Template(
"impl ${selfName} {\n"
- " pub fn empty(cx: *mut JSContext) -> ${selfName} {\n"
+ " pub unsafe fn empty(cx: *mut JSContext) -> ${selfName} {\n"
" ${selfName}::new(cx, HandleValue::null()).unwrap()\n"
" }\n"
- " pub fn new(cx: *mut JSContext, val: HandleValue) -> Result<${selfName}, ()> {\n"
+ " pub unsafe fn new(cx: *mut JSContext, val: HandleValue) -> Result<${selfName}, ()> {\n"
" let object = if val.get().is_null_or_undefined() {\n"
" RootedObject::new(cx, ptr::null_mut())\n"
" } else if val.get().is_object() {\n"
@@ -5159,6 +5154,7 @@ class CGBindingRoot(CGThing):
'js::{JSCLASS_RESERVED_SLOTS_MASK}',
'js::{JSPROP_ENUMERATE, JSPROP_SHARED}',
'js::{JSITER_OWNONLY, JSITER_HIDDEN, JSITER_SYMBOLS}',
+ 'js::error::throw_type_error',
'js::jsapi::{JS_CallFunctionValue, JS_GetClass, JS_GetGlobalForObject}',
'js::jsapi::{JS_GetObjectPrototype, JS_GetProperty, JS_GetPropertyById}',
'js::jsapi::{JS_GetPropertyDescriptorById, JS_GetReservedSlot}',
@@ -5222,7 +5218,6 @@ class CGBindingRoot(CGThing):
'dom::bindings::error::{Fallible, Error, ErrorResult}',
'dom::bindings::error::Error::JSFailed',
'dom::bindings::error::throw_dom_exception',
- 'dom::bindings::error::throw_type_error',
'dom::bindings::proxyhandler',
'dom::bindings::proxyhandler::{fill_property_descriptor, get_expando_object}',
'dom::bindings::proxyhandler::{get_property_descriptor}',