Handle RawGeckoElement and friends, add support for types which are used in both maybe-null and non-null forms

This commit is contained in:
Manish Goregaokar 2016-08-24 22:29:46 +05:30
parent de90f5fce8
commit 0d4c5674ec
No known key found for this signature in database
GPG key ID: 3BBF4D3E2EF79F98
6 changed files with 260 additions and 256 deletions

View file

@ -156,11 +156,15 @@ COMPILATION_TARGETS = {
],
"servo_owned_types": [
"RawServoStyleSet",
"RawGeckoNode",
],
"servo_maybe_owned_types": [
"ServoNodeData",
],
"servo_immutable_borrow_types": [
"RawGeckoNode",
"RawGeckoElement",
"RawGeckoDocument",
],
},
"atoms": {
@ -329,9 +333,19 @@ def build(objdir, target_name, debug, debugger, kind_name=None,
flags.append("--raw-line")
flags.append("pub type {0}Strong = ::sugar::ownership::Strong<{0}>;".format(ty))
flags.append("--blacklist-type")
flags.append("{}MaybeBorrowed".format(ty))
flags.append("-raw-line")
flags.append("pub type {0}MaybeBorrowed<'a> = ::sugar::ownership::Borrowed<'a, {0}>;".format(ty))
if "servo_immutable_borrow_types" in current_target:
for ty in current_target["servo_immutable_borrow_types"]:
flags.append("-blacklist-type")
flags.append("{}Borrowed".format(ty))
flags.append("--raw-line")
flags.append("pub type {0}Borrowed<'a> = ::sugar::ownership::Borrowed<'a, {0}>;".format(ty))
flags.append("pub type {0}Borrowed<'a> = &'a {0};".format(ty))
flags.append("--blacklist-type")
flags.append("{}MaybeBorrowed".format(ty))
flags.append("--raw-line")
flags.append("pub type {0}MaybeBorrowed<'a> = ::sugar::ownership::Borrowed<'a, {0}>;".format(ty))
if "servo_owned_types" in current_target:
for ty in current_target["servo_owned_types"]:
flags.append("--blacklist-type")
@ -349,19 +363,19 @@ def build(objdir, target_name, debug, debugger, kind_name=None,
if "servo_maybe_owned_types" in current_target:
for ty in current_target["servo_maybe_owned_types"]:
flags.append("--blacklist-type")
flags.append("{}Borrowed".format(ty))
flags.append("{}MaybeBorrowed".format(ty))
flags.append("--raw-line")
flags.append("pub type {0}Borrowed<'a> = ::sugar::ownership::Borrowed<'a, {0}>;"
flags.append("pub type {0}MaybeBorrowed<'a> = ::sugar::ownership::Borrowed<'a, {0}>;"
.format(ty))
flags.append("--blacklist-type")
flags.append("{}BorrowedMut".format(ty))
flags.append("{}MaybeBorrowedMut".format(ty))
flags.append("--raw-line")
flags.append("pub type {0}BorrowedMut<'a> = ::sugar::ownership::BorrowedMut<'a, {0}>;"
flags.append("pub type {0}MaybeBorrowedMut<'a> = ::sugar::ownership::BorrowedMut<'a, {0}>;"
.format(ty))
flags.append("--blacklist-type")
flags.append("{}Owned".format(ty))
flags.append("{}MaybeOwned".format(ty))
flags.append("--raw-line")
flags.append("pub type {0}Owned = ::sugar::ownership::MaybeOwned<{0}>;".format(ty))
flags.append("pub type {0}MaybeOwned = ::sugar::ownership::MaybeOwned<{0}>;".format(ty))
if "structs_types" in current_target:
for ty in current_target["structs_types"]:
ty_fragments = ty.split("::")