Double handle

Started by
4 comments, last by iraxef 9 years, 9 months ago

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.

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?

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Fixed in revision 1952

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

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!

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.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

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. :)

This topic is closed to new replies.

Advertisement