Skip to content

Commit

Permalink
Add binding function for cloning DeclarationBlock
Browse files Browse the repository at this point in the history
  • Loading branch information
upsuper committed Nov 3, 2016
1 parent e8a3d93 commit f6d5dc7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions components/style/gecko_bindings/bindings.rs
Expand Up @@ -927,6 +927,11 @@ extern "C" {
pub fn Servo_DeclarationBlock_CreateEmpty()
-> RawServoDeclarationBlockStrong;
}
extern "C" {
pub fn Servo_DeclarationBlock_Clone(declarations:
RawServoDeclarationBlockBorrowed)
-> RawServoDeclarationBlockStrong;
}
extern "C" {
pub fn Servo_DeclarationBlock_Equals(a: RawServoDeclarationBlockBorrowed,
b: RawServoDeclarationBlockBorrowed)
Expand Down
7 changes: 7 additions & 0 deletions ports/geckolib/glue.rs
Expand Up @@ -426,6 +426,13 @@ pub extern "C" fn Servo_DeclarationBlock_CreateEmpty() -> RawServoDeclarationBlo
Arc::new(RwLock::new(PropertyDeclarationBlock { declarations: vec![], important_count: 0 })).into_strong()
}

#[no_mangle]
pub extern "C" fn Servo_DeclarationBlock_Clone(declarations: RawServoDeclarationBlockBorrowed)
-> RawServoDeclarationBlockStrong {
let declarations = RwLock::<PropertyDeclarationBlock>::as_arc(&declarations);
Arc::new(RwLock::new(declarations.read().clone())).into_strong()
}

#[no_mangle]
pub extern "C" fn Servo_DeclarationBlock_AddRef(declarations: RawServoDeclarationBlockBorrowed) {
unsafe { RwLock::<PropertyDeclarationBlock>::addref(declarations) };
Expand Down

0 comments on commit f6d5dc7

Please sign in to comment.