From 3d39646c8e89c304cbae0c2490f2b82e47ccb7c5 Mon Sep 17 00:00:00 2001 From: Nathan Froyd Date: Tue, 27 Oct 2015 13:48:01 -0400 Subject: [PATCH] reduce indentation in CodegenRust.py We're going to wind up tacking on different pieces of code for the global vs. non-global case once we move the JS_SetReservedSlot call into create_dom_global. We might as well separate the indentation changes into a separate commit. --- .../dom/bindings/codegen/CodegenRust.py | 42 ++++++++++--------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index b251c4cc66a5..fab487215d72 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -2157,27 +2157,29 @@ def CreateBindingJSObject(descriptor, parent=None): assert!(!obj.is_null()); let obj = RootedObject::new(cx, obj);\ """ % (descriptor.name, parent) + elif descriptor.isGlobal(): + create += ("let obj = RootedObject::new(\n" + " cx,\n" + " create_dom_global(\n" + " cx,\n" + " &Class.base as *const js::jsapi::Class as *const JSClass,\n" + " Some(%s))\n" + ");\n" + "assert!(!obj.ptr.is_null());\n" + "\n" + "JS_SetReservedSlot(obj.ptr, DOM_OBJECT_SLOT,\n" + " PrivateValue(raw as *const libc::c_void));" % TRACE_HOOK_NAME) else: - if descriptor.isGlobal(): - create += ("let obj = RootedObject::new(\n" - " cx,\n" - " create_dom_global(\n" - " cx,\n" - " &Class.base as *const js::jsapi::Class as *const JSClass,\n" - " Some(%s))\n" - ");\n" % TRACE_HOOK_NAME) - else: - create += ("let obj = {\n" - " let _ac = JSAutoCompartment::new(cx, proto.ptr);\n" - " JS_NewObjectWithGivenProto(\n" - " cx, &Class.base as *const js::jsapi::Class as *const JSClass, proto.handle())\n" - "};\n" - "let obj = RootedObject::new(cx, obj);\n") - create += """\ -assert!(!obj.ptr.is_null()); - -JS_SetReservedSlot(obj.ptr, DOM_OBJECT_SLOT, - PrivateValue(raw as *const libc::c_void));""" + create += ("let obj = {\n" + " let _ac = JSAutoCompartment::new(cx, proto.ptr);\n" + " JS_NewObjectWithGivenProto(\n" + " cx, &Class.base as *const js::jsapi::Class as *const JSClass, proto.handle())\n" + "};\n" + "let obj = RootedObject::new(cx, obj);\n" + "assert!(!obj.ptr.is_null());\n" + "\n" + "JS_SetReservedSlot(obj.ptr, DOM_OBJECT_SLOT,\n" + " PrivateValue(raw as *const libc::c_void));") return create