diff options
author | Nathan Froyd <froydnj@gmail.com> | 2015-10-27 13:48:01 -0400 |
---|---|---|
committer | Nathan Froyd <froydnj@gmail.com> | 2015-10-27 16:46:01 -0400 |
commit | 3d39646c8e89c304cbae0c2490f2b82e47ccb7c5 (patch) | |
tree | 091bc43ed0b0208c79e48c149eb3750ee665a6fe /components/script/dom/bindings/codegen | |
parent | 484c0e45461fa2beb5fc186f51e76671076149db (diff) | |
download | servo-3d39646c8e89c304cbae0c2490f2b82e47ccb7c5.tar.gz servo-3d39646c8e89c304cbae0c2490f2b82e47ccb7c5.zip |
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.
Diffstat (limited to 'components/script/dom/bindings/codegen')
-rw-r--r-- | components/script/dom/bindings/codegen/CodegenRust.py | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index b251c4cc66a..fab487215d7 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -2157,27 +2157,29 @@ let obj = { 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 |