Add safer bindings for refcounted types across ffi

This commit is contained in:
Manish Goregaokar 2016-08-14 00:06:58 +05:30
parent 8fd74e026c
commit 0d4d1b539e
10 changed files with 248 additions and 180 deletions

View file

@ -116,6 +116,9 @@ COMPILATION_TARGETS = {
"raw_lines": [
"use heapsize::HeapSizeOf;",
],
"flags": [
"-ignore-methods",
],
"match_headers": [
"ServoBindings.h",
"nsStyleStructList.h",
@ -145,6 +148,7 @@ COMPILATION_TARGETS = {
"void_types": [
"nsINode", "nsIDocument", "nsIPrincipal", "nsIURI",
],
"servo_arc_types": ["ServoComputedValues", "RawServoStyleSheet"]
},
"atoms": {
@ -300,7 +304,16 @@ def build(objdir, target_name, 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"]:
flags.append("-blacklist-type")
flags.append("{}Strong".format(ty))
flags.append("-raw-line")
flags.append("pub type {0}Strong = ::sugar::refptr::Strong<{0}>;".format(ty))
flags.append("-blacklist-type")
flags.append("{}Borrowed".format(ty))
flags.append("-raw-line")
flags.append("pub type {0}Borrowed<'a> = ::sugar::refptr::Borrowed<'a, {0}>;".format(ty))
if "structs_types" in current_target:
for ty in current_target["structs_types"]:
ty_fragments = ty.split("::")