Better support in ScriptLanguage for GC based scripts
This commit is contained in:
parent
3b5b893a0e
commit
d57b09e47b
|
@ -27,7 +27,7 @@
|
||||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
#include "reference.h"
|
#include "reference.h"
|
||||||
|
#include "script_language.h"
|
||||||
|
|
||||||
|
|
||||||
bool Reference::init_ref() {
|
bool Reference::init_ref() {
|
||||||
|
@ -66,11 +66,21 @@ int Reference::reference_get_count() const {
|
||||||
void Reference::reference(){
|
void Reference::reference(){
|
||||||
|
|
||||||
refcount.ref();
|
refcount.ref();
|
||||||
|
if (get_script_instance()) {
|
||||||
|
get_script_instance()->refcount_incremented();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
bool Reference::unreference(){
|
bool Reference::unreference(){
|
||||||
|
|
||||||
return refcount.unref();
|
bool die = refcount.unref();
|
||||||
|
|
||||||
|
if (get_script_instance()) {
|
||||||
|
die = die && get_script_instance()->refcount_decremented();
|
||||||
|
}
|
||||||
|
|
||||||
|
return die;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Reference::Reference() {
|
Reference::Reference() {
|
||||||
|
|
|
@ -129,6 +129,9 @@ public:
|
||||||
virtual void notification(int p_notification)=0;
|
virtual void notification(int p_notification)=0;
|
||||||
|
|
||||||
|
|
||||||
|
virtual void refcount_incremented() {}
|
||||||
|
virtual bool refcount_decremented() { return true; } //return true if it can die
|
||||||
|
|
||||||
virtual Ref<Script> get_script() const=0;
|
virtual Ref<Script> get_script() const=0;
|
||||||
|
|
||||||
virtual bool is_placeholder() const { return false; }
|
virtual bool is_placeholder() const { return false; }
|
||||||
|
|
Loading…
Reference in New Issue