• Advertisement
Sign in to follow this  

Double handle

This topic is 1281 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

If I have code like the below:

AppRegisteredType @ @ foo = ...;

What should the behavior be as far as the double handle? Should it be a compiler error? Or is it OK that it works as-is?

 

Thank you.

Share this post


Link to post
Share on other sites
Advertisement

It should be a compilation error. Handles of handles is not possible, since that would mean that the actual handle itself was also reference counted, which isn't the case.

 

Are you saying that it compiles without error? 

Share this post


Link to post
Share on other sites

It turns out I need to maintain support for handle of a handle for backwards compatibility purposes. If you can spare the time, please let me know what you think of the attached diff (whether you'd do anything differently in order to support this locally).

 

Thank you very much!

Share this post


Link to post
Share on other sites

I'm sorry, but it does not make sense to keep this kind of backwards compatibility in the library. It was never a valid syntax to begin with. It was just a bug in the compiler that it ignored the extra handle.

 

 

If you want to allow compiling scripts with this kind of invalid syntax I suggest you do a preprocessor pass to look for the existance of double handles and exchange one of them for a space character before giving the code to the script compiler. It can be done with a quick linear pass over the code. The engine's ParseToken method can ideally be used to identify the separate tokens so that you do not need to worry about falsely identifying @ tokens in strings.

 

If you're already using the CScriptBuilder add-on you should preferrably add this check in the CScriptBuilder::ProcessScriptSection method, this way you'll avoid an extra pass over the code and thus get next to zero impact on build times.

Share this post


Link to post
Share on other sites

I'm sorry, but it does not make sense to keep this kind of backwards compatibility in the library. It was never a valid syntax to begin with. It was just a bug in the compiler that it ignored the extra handle.

 

Agreed - I'll have to keep a local patch for as long as I need to maintain the backwards compatibility. I was just hoping you could double-check the patch for me.

 

However, I think I got it all working, so no worries. :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement