Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


#ActualWracky

Posted 15 September 2013 - 08:43 AM

I've been trying some things, but I noticed I still have one ownership problem:
That of the asIscriptFunction object.

If I only weak-ref the OBJECT, the "binding" of a script function bound for this object will still exist in the application even when the delegate goes out of scope in script.

With the delegate out of scope, the scripter might assume that this binding is now broken.

 

The same problem occurs when the user passes a simpel global function callback. In this case, I have no object to ref, and only the function to hold.
Again, reffing the function object would move control over the callback from scripter to application, adding the necessity for some other application interface to break the callback binding.  Not reffing the object would cause me to call it when the function object is already gone, which I assume, is a bad thing.

 

This can ofcourse be prevented if I can weak-ref the asIScriptFunction as well (but this is currently not possible is it?, The CScriptWeakRef needs an object type?). As a matter of fact, if I could just weak-ref the asIScriptFunction,  I don't need to destinguish between an object delegate or a normal callback, since if the delegate object is destroyed, the object ref will be freed as expected, and the func ref will be as well, and the object will not be destroyed as long as the delegate exists, since it refs it.

 

Couldn't the script delegate weak-ref the object and fallback to a no-op if the object is destroyed before the delegate is called?

In that case, the control of both the lifetime of the object, and the lifetime of the delegate remain in the hands of the scripter, that is, if the application can weakref the asIScriptFunction* 

 

I've read different posts about the subject and understand this is a difficult problem smile.png However I can explain a scripter that the delegate will ref the object for as long as it exists, but it is kind of strange that a script callback or delegate stops existing when the object funcdef object goes out of scope, but not when a global function callback is passed to the application (only when it's a delegate).

 

Any thoughts on this?

Regards,

Wracky.

 


#6Wracky

Posted 15 September 2013 - 08:39 AM

I've been trying some things, but I noticed I still have one ownership problem:
That of the asIscriptFunction object.

If I only weak-ref the OBJECT, the "binding" of a script function bound for this object will still exist in the application even when the delegate goes out of scope in script.

With the delegate out of scope, the scripter might assume that this binding is now broken.

 

The same problem occurs when the user passes a simpel global function callback. In this case, I have no object to ref, and only the function to hold.
Again, reffing the function object would move control over the callback from scripter to application, adding the necessity for some other application interface to break the callback binding. 

 

This can ofcourse be prevented if I can weak-ref the asIScriptFunction as well (but this is currently not possible is it?, The CScriptWeakRef needs an object type?). As a matter of fact, if I could just weak-ref the asIScriptFunction,  I don't need to destinguish between an object delegate or a normal callback, since if the delegate object is destroyed, the object ref will be freed as expected, and the func ref will be as well, and the object will not be destroyed as long as the delegate exists, since it refs it.

 

Couldn't the script delegate weak-ref the object and fallback to a no-op if the object is destroyed before the delegate is called?

In that case, the control of both the lifetime of the object, and the lifetime of the delegate remain in the hands of the scripter, that is, if the application can weakref the asIScriptFunction* 

 

I've read different posts about the subject and understand this is a difficult problem smile.png However I can explain a scripter that the delegate will ref the object for as long as it exists, but it is kind of strange that a script callback or delegate stops existing when the object funcdef object goes out of scope, but not when a global function callback is passed to the application (only when it's a delegate).

 

Any thoughts on this?

Regards,

Wracky.

 


#5Wracky

Posted 15 September 2013 - 08:38 AM

I've been trying some things, but I noticed I still have one ownership problem:
That of the asIscriptFunction object.

If I only weak-ref the OBJECT, the "binding" of a script function bound for this object will still exist in the application even when the delegate goes out of scope in script.

With the delegate out of scope, the scripter might assume that this binding is now broken.

 

The same problem occurs when the user passes a simpel global function callback. In this case, I have no object to ref, and only the function to hold.
Again, reffing the function object would move control over the callback from scripter to application, adding the necessity for some other application interface to break the callback binding. 

 

This can ofcourse be prevented if I can weak-ref the asIScriptFunction as well (but this is currently not possible is it?, The CScriptWeakRef needs an object type?). As a matter of fact, if I could just weak-ref the asIScriptFunction,  I don't need to destinguish between an object delegate or a normal callback, since if the delegate object is destroyed, the object ref will be freed as expected, and the func ref will be as well, and the object will not be destroyed as long as the delegate exists, since it refs it.

 

Couldn't the script delegate weak-ref the object and fallback to a no-op if the object is destroyed before the delegate is called?

In that case, the control of both the lifetime of the object, and the lifetime of the delegate remain in the hands of the scripter, that is, if the application can weakref the asIScriptFunction* 

 

I've read different posts about the subject and understand this is a difficult problem smile.png However I can explain a scripter that the delegate will ref the object for as long as it exists, but it is kind of strange that a script callback or delegate stops existing when the object funcdef object goes out of scope, while this would also be the case with a delegate passed to the application, but not with a callback passed to the application.

 

Any thoughts on this?

Regards,

Wracky.

 


#4Wracky

Posted 15 September 2013 - 08:36 AM

I've been trying some things, but I noticed I still have one ownership problem:
That of the asIscriptFunction object.

If I only weak-ref the OBJECT, the "binding" of a script function bound for this object will still exist in the application even when the delegate goes out of scope in script.

With the delegate out of scope, the scripter might assume that this binding is now broken.

 

The same problem occurs when the user passes a simpel global function callback. In this case, I have no object to ref, and only the function to hold.
Again, reffing the function object would move control over the callback from scripter to application, adding the necessity for some other application interface to break the callback binding. 

 

This can ofcourse be prevented if I can weak-ref the asIScriptFunction as well (but this is currently not possible is it?, The CScriptWeakRef needs an object type?). As a matter of fact, if I could just weak-ref the asIScriptFunction,  I don't need to destinguish between an object delegate or a normal callback, since if the delegate object is destroyed, the object ref will be freed as expected, and the func ref will be as well, and the object will not be destroyed as long as the delegate exists, since it refs it.

 

Couldn't the script delegate weak-ref the object and fallback to a no-op if the object is destroyed before the delegate is called?

In that case, the control of both the lifetime of the object, and the lifetime of the delegate remain in the hands of the scripter, that is, if the application can weakref the asIScriptFunction* 

 

I've read different posts about the subject and understand this is a difficult problem smile.png I can explain a scripter that the delegate will ref the object for as long as it exists, but it is kind of strange that a script callback or delegate stops existing when the object funcdef object goes out of scope, while this would also be the case with a delegate passed to the application, but not with a callback passed to the application.

 

Any thoughts on this?

Regards,

Wracky.

 


#3Wracky

Posted 15 September 2013 - 08:35 AM

I've been trying some things, but I noticed I still have one ownership problem:
That of the asIscriptFunction object.

If I only weak-ref the OBJECT, the "binding" of a script function object (funcdef object?) with the application will still exist even when the delegate goes out of scope in script.

With the delegate out of scope, the scripter might assume that this binding is now broken.

 

The same problem occurs when the user passes a simpel global function callback. In this case, I have no object to ref, and only the function to hold.
Again, reffing the function object would move control over the callback from scripter to application, adding the necessity for some other application interface to break the callback binding. 

 

This can ofcourse be prevented if I can weak-ref the asIScriptFunction as well (but this is currently not possible is it?, The CScriptWeakRef needs an object type?). As a matter of fact, if I could just weak-ref the asIScriptFunction,  I don't need to destinguish between an object delegate or a normal callback, since if the delegate object is destroyed, the object ref will be freed as expected, and the func ref will be as well, and the object will not be destroyed as long as the delegate exists, since it refs it.

 

Couldn't the script delegate weak-ref the object and fallback to a no-op if the object is destroyed before the delegate is called?

In that case, the control of both the lifetime of the object, and the lifetime of the delegate remain in the hands of the scripter, that is, if the application can weakref the asIScriptFunction* 

 

I've read different posts about the subject and understand this is a difficult problem smile.png I can explain a scripter that the delegate will ref the object for as long as it exists, but it is kind of strange that a script callback or delegate stops existing when the object funcdef object goes out of scope, while this would also be the case with a delegate passed to the application, but not with a callback passed to the application.

 

Any thoughts on this?

Regards,

Wracky.

 


#2Wracky

Posted 15 September 2013 - 08:34 AM

I've been trying some things, but I noticed I still have one ownership problem:
That of the asIscriptFunction object.

If I only weak-ref the OBJECT, the "binding" of a script callback (global function) with the application will still exist even when the delegate goes out of scope in script.

With the delegate out of scope, the scripter might assume that this binding is now broken.

 

The same problem occurs when the user passes a simpel global function callback. In this case, I have no object to ref, and only the function to hold.
Again, reffing the function object would move control over the callback from scripter to application, adding the necessity for some other application interface to break the callback binding. 

 

This can ofcourse be prevented if I can weak-ref the asIScriptFunction as well (but this is currently not possible is it?, The CScriptWeakRef needs an object type?). As a matter of fact, if I could just weak-ref the asIScriptFunction,  I don't need to destinguish between an object delegate or a normal callback, since if the delegate object is destroyed, the object ref will be freed as expected, and the func ref will be as well, and the object will not be destroyed as long as the delegate exists, since it refs it.

 

Couldn't the script delegate weak-ref the object and fallback to a no-op if the object is destroyed before the delegate is called?

In that case, the control of both the lifetime of the object, and the lifetime of the delegate remain in the hands of the scripter, that is, if the application can weakref the asIScriptFunction* 

 

I've read different posts about the subject and understand this is a difficult problem smile.png I can explain a scripter that the delegate will ref the object for as long as it exists, but it is kind of strange that a script callback or delegate stops existing when the object funcdef object goes out of scope, while this would also be the case with a delegate passed to the application, but not with a callback passed to the application.

 

Any thoughts on this?

Regards,

Wracky.

 


PARTNERS