Advertisement

Metadata not working in shared class

Started by March 26, 2024 09:31 AM
4 comments, last by WitchLord 7 months, 3 weeks ago

Hi

I have an issue when building my script. This piece here:

shared class iEdScriptDialog : iEdScriptObject
{    
	[nosave] iGuiDialogBase @mpDialogWidget;
	...
}

gets me an “expecting method or property” error when the compiler finds the ‘[’ char.
Did some investigation and found that when the parser gets to the “shared” keyword it reaches the “I'm gonna skip this whole statement” branch of the CScriptBuilder::ProcessScriptSection function, due to “shared” being treated as an identifier, just as stated at the end of the as_tokendef.h file, so no metadata removal happens and compiler gets fed this block as is.
I was about to add some hackish solution but that feels like a rabbit hole waiting to happen. I'm using 2.36.1 wip and can't exactly update to latest version at the moment so unsure if this has been addressed already (although I can't see anything that relates in the changelog).
What's the simplest approach to get the builder to properly process this?

And while we're at it, the issue blocking me from updating the lib is due to some parts in our codebase invalidated by the “value types not being able to be LValues” restriction introduced recently. We have a data container that resorts to some value type object as helper proxy for using the index operator, which works on the C++ side and has worked in the script side until that latest update. I already managed to get it to work by changing the declaration to reference and all the affected methods to take references as well, but unsure if there's some other workaround that involves less changes as I am a bit paranoid this might inadvertedly break some other stuff (made tests and it seemed to work but paranoid is paranoid).

That would be it. Thanks for the awesome lib btw and thanks for the help in advance.

I'll check this out when I come back from vacation, but I believe it is working in the latest version.

You can give the version from the WIP a try. It will most likely work without upgrading the full library.

http://svn.code.sf.net/p/angelscript/code/trunk/sdk/add_on/scriptbuilder/scriptbuilder.cpp

Can you show me with a code sample the “value types not being able to be LValues” issue with the latest 2.37.0 WIP version? I can see if it is possible to add an engine property to allow backwards compatibility.

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

Advertisement

FYI. The issue with metadata on properties in shared classes was fixed back in March, 2021, in revision 2707. Please check out the diff for that commit and compare with the version you are currently using. If you don't want to upgrade to the latest version, then at least apply this patch.

https://sourceforge.net/p/angelscript/code/2707/

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

Thanks a lot for the replies, and now for the embarrassing part: I checked our commit logs and the lib in our project has been updated maybe a couple times after december 2017, but somehow I never touched the builder file in any of those occasions. I guess it slipped because I cannot remember having to fix any compile issues when the updated version got in. Oh well, I guess I poked you just to let you know that I can't update a lib properly.
I am happy I mentioned the lvalue issue though - I prepared a stripped down version of the container in our engine and added it to the angelscript tutorial project, along with some test script that makes the issue surface. The error triggered is the one at as_compiler.cpp line 8852 (in asCCompiler::DoAssignment).
Here it is: angelscript-test.zip

Again, thanks a lot.

Thanks for providing the code to reproduce the scenario on the lvalue issue. I'll check it out and see what can be done to provide better backwards compatibility.

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

This topic is closed to new replies.

Advertisement