diff options
Diffstat (limited to 'src/components/script/dom/bindings')
-rw-r--r-- | src/components/script/dom/bindings/codegen/CodegenRust.py | 34 | ||||
-rw-r--r-- | src/components/script/dom/bindings/element.rs | 16 | ||||
-rw-r--r-- | src/components/script/dom/bindings/text.rs | 7 | ||||
-rw-r--r-- | src/components/script/dom/bindings/utils.rs | 15 |
4 files changed, 34 insertions, 38 deletions
diff --git a/src/components/script/dom/bindings/codegen/CodegenRust.py b/src/components/script/dom/bindings/codegen/CodegenRust.py index 140a712b950..8a1c647b6e5 100644 --- a/src/components/script/dom/bindings/codegen/CodegenRust.py +++ b/src/components/script/dom/bindings/codegen/CodegenRust.py @@ -1044,7 +1044,7 @@ for (uint32_t i = 0; i < length; ++i) { # "if (!ConvertJSValueToString(cx, ${val}, ${valPtr}, %s, %s, %s)) {\n" # " return false;\n" # "}" % (nullBehavior, undefinedBehavior, varName)) - strval = "str(strval.get())" + strval = "str(strval.unwrap())" if isOptional: strval = "Some(%s)" % strval conversionCode = ( @@ -1114,7 +1114,7 @@ for (uint32_t i = 0; i < length; ++i) { " if result.is_err() {\n" "%(handleInvalidEnumValueCode)s" " }\n" - " let index = result.get();\n" + " let index = result.unwrap();\n" " ${declName} = cast::transmute(index); //XXXjdm need some range checks up in here\n" "}" % { "enumtype" : enum, "values" : enum + "Values::strings", @@ -1511,7 +1511,7 @@ for (uint32_t i = 0; i < length; ++i) { wrappingCode = ("if %s.is_none() {\n" % (result) + CGIndenter(CGGeneric(setValue("JSVAL_NULL"))).define() + "\n" + "}\n" + - "let mut %s = %s.get();\n" % (result, result)) + "let mut %s = %s.unwrap();\n" % (result, result)) else: wrappingCode = "" if (not descriptor.interface.isExternal() and @@ -2746,10 +2746,10 @@ class CGGetPerInterfaceObject(CGAbstractMethod): }*/ /* Check to see whether the interface objects are already installed */ let protoOrIfaceArray: *mut *JSObject = cast::transmute(GetProtoOrIfaceArray(aGlobal)); - let cachedObject: *JSObject = *protoOrIfaceArray.offset(%s as uint); + let cachedObject: *JSObject = *protoOrIfaceArray.offset(%s as int); if cachedObject.is_null() { let tmp: *JSObject = CreateInterfaceObjects(aCx, aGlobal, aReceiver); - *protoOrIfaceArray.offset(%s as uint) = tmp; + *protoOrIfaceArray.offset(%s as int) = tmp; tmp } else { cachedObject @@ -3623,7 +3623,7 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod): templateValues = {'jsvalRef': '(*desc).value', 'jsvalPtr': 'ptr::to_mut_unsafe_ptr(&mut (*desc).value)', 'obj': 'proxy', 'successCode': fillDescriptor} get = ("if index.is_some() {\n" + - " let index = index.get();\n" + + " let index = index.unwrap();\n" + " let this: *%s = UnwrapProxy(proxy);\n" + CGIndenter(CGProxyIndexedGetter(self.descriptor, templateValues)).define() + "\n" + "}\n") % (self.descriptor.concreteType) @@ -3632,7 +3632,7 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod): setOrIndexedGet += "if set != 0 {\n" if indexedSetter: setOrIndexedGet += (" if index.is_some() {\n" + - " let index = index.get();\n") + " let index = index.unwrap();\n") if not 'IndexedCreator' in self.descriptor.operations: # FIXME need to check that this is a 'supported property index' assert False @@ -3677,7 +3677,7 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod): " if strval.is_err() {\n" + " return 0;\n" + " }\n" + - " let name = str(strval.get());\n" + + " let name = str(strval.unwrap());\n" + "\n" + " let this: *%s = UnwrapProxy(proxy);\n" + CGIndenter(CGProxyNamedGetter(self.descriptor, templateValues)).define() + "\n" + @@ -3721,7 +3721,7 @@ class CGDOMJSProxyHandler_defineProperty(CGAbstractExternMethod): raise TypeError("Can't handle creator that's different from the setter") set += ("let index = GetArrayIndexFromId(cx, id);\n" + "if index.is_some() {\n" + - " let index = index.get();\n" + + " let index = index.unwrap();\n" + " let this: *%s = UnwrapProxy(proxy);\n" + CGIndenter(CGProxyIndexedSetter(self.descriptor)).define() + " return 1;\n" + @@ -3746,7 +3746,7 @@ class CGDOMJSProxyHandler_defineProperty(CGAbstractExternMethod): " if strval.is_err() {\n" + " return 0;\n" + " }\n" + - " let name = str(strval.get());\n" + + " let name = str(strval.unwrap());\n" + "\n" + " let this: *%s = UnwrapProxy(proxy);\n" + CGIndenter(CGProxyNamedSetter(self.descriptor)).define() + "\n" + @@ -3762,7 +3762,7 @@ class CGDOMJSProxyHandler_defineProperty(CGAbstractExternMethod): " if strval.is_err() {\n" + " return 0;\n" + " }\n" + - " let name = str(strval.get());\n" + + " let name = str(strval.unwrap());\n" + " let this: %%s = UnwrapProxy(proxy);\n" + CGIndenter(CGProxyNamedGetter(self.descriptor)).define() + " if (found) {\n" @@ -3787,7 +3787,7 @@ class CGDOMJSProxyHandler_hasOwn(CGAbstractExternMethod): if indexedGetter: indexed = ("let index = GetArrayIndexFromId(cx, id);\n" + "if index.is_some() {\n" + - " let index = index.get();\n" + + " let index = index.unwrap();\n" + " let this: *%s = UnwrapProxy(proxy);\n" + CGIndenter(CGProxyIndexedGetter(self.descriptor)).define() + "\n" + " *bp = found as JSBool;\n" + @@ -3808,7 +3808,7 @@ class CGDOMJSProxyHandler_hasOwn(CGAbstractExternMethod): " if strval.is_err() {\n" + " return 0;\n" + " }\n" + - " let name = str(strval.get());\n" + + " let name = str(strval.unwrap());\n" + "\n" + " let this: *%s = UnwrapProxy(proxy);\n" + CGIndenter(CGProxyNamedGetter(self.descriptor)).define() + "\n" + @@ -3861,7 +3861,7 @@ if expando.is_not_null() { if indexedGetter: getIndexedOrExpando = ("let index = GetArrayIndexFromId(cx, id);\n" + "if index.is_some() {\n" + - " let index = index.get();\n" + + " let index = index.unwrap();\n" + " let this = UnwrapProxy(proxy);\n" + CGIndenter(CGProxyIndexedGetter(self.descriptor, templateValues)).define()) getIndexedOrExpando += """ @@ -3935,7 +3935,7 @@ class CGDOMJSProxyHandler_obj_toString(CGAbstractExternMethod): JSString* jsresult; return xpc_qsStringToJsstring(cx, result, &jsresult) ? jsresult : NULL;""" - return """ do str::as_c_str("%s") |s| { + return """ do "%s".as_c_str |s| { _obj_toString(cx, s) }""" % self.descriptor.name @@ -4461,9 +4461,9 @@ class CGDictionary(CGThing): # NOTE: jsids are per-runtime, so don't use them in workers if True or self.workers: #XXXjdm hack until 'static mut' exists for global jsids propName = member.identifier.name - propCheck = ('str::as_c_str("%s", |s| { JS_HasProperty(cx, RUST_JSVAL_TO_OBJECT(val), s, ptr::to_unsafe_ptr(&found)) })' % + propCheck = ('"%s".as_c_str(|s| { JS_HasProperty(cx, RUST_JSVAL_TO_OBJECT(val), s, ptr::to_unsafe_ptr(&found)) })' % propName) - propGet = ('str::as_c_str("%s", |s| { JS_GetProperty(cx, RUST_JSVAL_TO_OBJECT(val), s, ptr::to_unsafe_ptr(&temp)) })' % + propGet = ('"%s".as_c_str(|s| { JS_GetProperty(cx, RUST_JSVAL_TO_OBJECT(val), s, ptr::to_unsafe_ptr(&temp)) })' % propName) else: propId = self.makeIdName(member.identifier.name); diff --git a/src/components/script/dom/bindings/element.rs b/src/components/script/dom/bindings/element.rs index e9336e3da2a..5a3075efacc 100644 --- a/src/components/script/dom/bindings/element.rs +++ b/src/components/script/dom/bindings/element.rs @@ -21,8 +21,6 @@ use std::libc::c_uint; use std::comm; use std::ptr; use std::ptr::null; -use std::result; -use std::str; use js::glue::*; use js::jsapi::*; use js::jsapi::{JSContext, JSVal, JSObject, JSBool, JSFreeOp, JSPropertySpec}; @@ -49,14 +47,14 @@ pub extern fn trace(tracer: *mut JSTracer, obj: *JSObject) { return; } error!("tracing %s", name); - let mut node = node.get(); + let mut node = node.unwrap(); let cache = node.get_wrappercache(); let wrapper = cache.get_wrapper(); assert!(wrapper.is_not_null()); unsafe { (*tracer).debugPrinter = ptr::null(); (*tracer).debugPrintIndex = -1; - do str::as_c_str(name) |name| { + do name.as_c_str |name| { (*tracer).debugPrintArg = name as *libc::c_void; JS_CallTracer(cast::transmute(tracer), wrapper, JSTRACE_OBJECT as u32); } @@ -194,14 +192,14 @@ extern fn setAttribute(cx: *JSContext, argc: c_uint, vp: *JSVal) -> JSBool { if strval.is_err() { return 0; } - arg0 = str(strval.get()); + arg0 = str(strval.unwrap()); let arg1: DOMString; let strval = jsval_to_str(cx, (*argv.offset(1))); if strval.is_err() { return 0; } - arg1 = str(strval.get()); + arg1 = str(strval.unwrap()); do node.as_mut_element |elem| { elem.set_attr(&arg0, &arg1); @@ -293,9 +291,9 @@ pub fn create(cx: *JSContext, node: &mut AbstractNode<ScriptView>) -> jsobj { //XXXjdm the parent should probably be the node parent instead of the global //TODO error checking let compartment = utils::get_compartment(cx); - let obj = result::unwrap(compartment.new_object_with_proto(~"GenericElementInstance", - proto, - compartment.global_obj.ptr)); + let obj = compartment.new_object_with_proto(~"GenericElementInstance", + proto, + compartment.global_obj.ptr).unwrap(); let cache = node.get_wrappercache(); assert!(cache.get_wrapper().is_null()); diff --git a/src/components/script/dom/bindings/text.rs b/src/components/script/dom/bindings/text.rs index 2ec4a6a69df..efa8cc90206 100644 --- a/src/components/script/dom/bindings/text.rs +++ b/src/components/script/dom/bindings/text.rs @@ -16,7 +16,6 @@ use js::rust::{Compartment, jsobj}; use std::cast; use std::libc; -use std::result; extern fn finalize_text(_fop: *JSFreeOp, obj: *JSObject) { debug!("text finalize: %?!", obj as uint); @@ -79,9 +78,9 @@ pub fn create(cx: *JSContext, node: &mut AbstractNode<ScriptView>) -> jsobj { //XXXjdm the parent should probably be the node parent instead of the global //TODO error checking let compartment = utils::get_compartment(cx); - let obj = result::unwrap(compartment.new_object_with_proto(instance, - proto, - compartment.global_obj.ptr)); + let obj = compartment.new_object_with_proto(instance, + proto, + compartment.global_obj.ptr).unwrap(); let cache = node.get_wrappercache(); assert!(cache.get_wrapper().is_null()); diff --git a/src/components/script/dom/bindings/utils.rs b/src/components/script/dom/bindings/utils.rs index c30eea5f1db..7db5a27a988 100644 --- a/src/components/script/dom/bindings/utils.rs +++ b/src/components/script/dom/bindings/utils.rs @@ -13,7 +13,6 @@ use std::hashmap::HashMap; use std::libc; use std::ptr; use std::ptr::{null, to_unsafe_ptr}; -use std::result; use std::str; use std::uint; use std::unstable::intrinsics; @@ -85,7 +84,7 @@ extern fn InterfaceObjectToString(cx: *JSContext, _argc: uint, vp: *mut JSVal) - return 0; } - let name = jsval_to_str(cx, *v).get(); + let name = jsval_to_str(cx, *v).unwrap(); let retval = str(~"function " + name + "() {\n [native code]\n}"); *vp = domstring_to_jsval(cx, &retval); return 1; @@ -216,10 +215,10 @@ pub unsafe fn domstring_to_jsval(cx: *JSContext, string: &DOMString) -> JSVal { JSVAL_NULL } &str(ref s) => { - str::as_buf(*s, |buf, len| { + do s.as_imm_buf |buf, len| { let cbuf = cast::transmute(buf); RUST_STRING_TO_JSVAL(JS_NewStringCopyN(cx, cbuf, len as libc::size_t)) - }) + } } } } @@ -322,13 +321,13 @@ pub fn define_empty_prototype(name: ~str, proto: Option<~str>, compartment: @mut compartment.register_class(prototype_jsclass(name.to_owned())); //TODO error checking - let obj = result::unwrap( + let obj = ( match proto { Some(s) => compartment.new_object_with_proto(name.to_owned(), s, compartment.global_obj.ptr), None => compartment.new_object(name.to_owned(), null(), compartment.global_obj.ptr) - }); + }).unwrap(); unsafe { compartment.define_property(name.to_owned(), RUST_OBJECT_TO_JSVAL(obj.ptr), @@ -456,7 +455,7 @@ pub fn CreateInterfaceObjects2(cx: *JSContext, global: *JSObject, receiver: *JSO let mut interface = ptr::null(); if constructorClass.is_not_null() || constructor.is_not_null() { - interface = do str::as_c_str(name) |s| { + interface = do name.as_c_str |s| { CreateInterfaceObject(cx, global, receiver, constructorClass, constructor, ctorNargs, proto, staticMethods, constants, s) @@ -508,7 +507,7 @@ fn CreateInterfaceObject(cx: *JSContext, global: *JSObject, receiver: *JSObject, } if constructorClass.is_not_null() { - let toString = do str::as_c_str("toString") |s| { + let toString = do "toString".as_c_str |s| { DefineFunctionWithReserved(cx, constructor, s, InterfaceObjectToString, 0, 0) |