use crate::bindings::{zend_refcounted_h, zend_string};
use super::object::ZendObject;
pub type ZendRefcount = zend_refcounted_h;
pub trait PhpRc {
fn get_rc(&self) -> &ZendRefcount;
fn get_rc_mut(&mut self) -> &mut ZendRefcount;
fn get_count(&self) -> u32 {
self.get_rc().refcount
}
fn inc_count(&mut self) {
self.get_rc_mut().refcount += 1
}
fn dec_count(&mut self) {
self.get_rc_mut().refcount -= 1;
}
}
macro_rules! rc {
($($t: ty),*) => {
$(
impl PhpRc for $t {
fn get_rc(&self) -> &ZendRefcount {
&self.gc
}
fn get_rc_mut(&mut self) -> &mut ZendRefcount {
&mut self.gc
}
}
)*
};
}
rc!(ZendObject, zend_string);