Add MaybeOwned, and use for ServoNodeData. More docs.

This commit is contained in:
Manish Goregaokar 2016-08-24 17:52:15 +05:30
parent 36c63db5d4
commit de90f5fce8
No known key found for this signature in database
GPG key ID: 3BBF4D3E2EF79F98
5 changed files with 216 additions and 32 deletions

View file

@ -150,12 +150,16 @@ COMPILATION_TARGETS = {
"void_types": [
"nsINode", "nsIDocument", "nsIPrincipal", "nsIURI",
],
"servo_arc_types": [
"servo_maybe_arc_types": [
"ServoComputedValues", "RawServoStyleSheet",
"ServoDeclarationBlock"
],
"servo_owned_types": [
"RawServoStyleSet",
"RawGeckoNode",
],
"servo_maybe_owned_types": [
"ServoNodeData",
],
},
@ -318,8 +322,8 @@ def build(objdir, target_name, debug, debugger, kind_name=None,
for ty in current_target["void_types"]:
flags.append("--raw-line")
flags.append("pub enum {} {{}}".format(ty))
if "servo_arc_types" in current_target:
for ty in current_target["servo_arc_types"]:
if "servo_maybe_arc_types" in current_target:
for ty in current_target["servo_maybe_arc_types"]:
flags.append("--blacklist-type")
flags.append("{}Strong".format(ty))
flags.append("--raw-line")
@ -342,6 +346,22 @@ def build(objdir, target_name, debug, debugger, kind_name=None,
flags.append("{}Owned".format(ty))
flags.append("--raw-line")
flags.append("pub type {0}Owned = ::sugar::ownership::Owned<{0}>;".format(ty))
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("--raw-line")
flags.append("pub type {0}Borrowed<'a> = ::sugar::ownership::Borrowed<'a, {0}>;"
.format(ty))
flags.append("--blacklist-type")
flags.append("{}BorrowedMut".format(ty))
flags.append("--raw-line")
flags.append("pub type {0}BorrowedMut<'a> = ::sugar::ownership::BorrowedMut<'a, {0}>;"
.format(ty))
flags.append("--blacklist-type")
flags.append("{}Owned".format(ty))
flags.append("--raw-line")
flags.append("pub type {0}Owned = ::sugar::ownership::MaybeOwned<{0}>;".format(ty))
if "structs_types" in current_target:
for ty in current_target["structs_types"]:
ty_fragments = ty.split("::")