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.
This commit is contained in:
Nathan Froyd 2015-10-27 13:48:01 -04:00
parent 484c0e4546
commit 3d39646c8e

View file

@ -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