Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export FScanner parser to ZScript as ScriptScanner #2290

Closed
wants to merge 2 commits into from

Conversation

Cacodemon345
Copy link
Contributor

This PR exposes the internal FScanner parser to ZScript as ScriptScanner.

ScriptScanners are created with Create functions, and destroyed by calling Destroy (after which it must not be used). SetPrependMessage is used to set the message that will be prepended to the displayed error messages in case of failure. The rest of the exported functions work unchanged from their native counterparts.

src/common/engine/sc_man.cpp Outdated Show resolved Hide resolved
Copy link
Member

@coelckers coelckers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rewrite this to not use multiple inheritance. A lot of ZScripts inner workings circumvent standard C++ logic that ensure type safety and this may easily end up trashing the pointer to such an object because it may not point to where you expect it anymore.

@Cacodemon345
Copy link
Contributor Author

Done as requested.

@nashmuhandes
Copy link
Contributor

Please also provide a working example mod that showcases the usage of this feature.

@Cacodemon345
Copy link
Contributor Author

Cacodemon345 commented Dec 11, 2023

scriptparserexample.zip
demoscpt.txt

Here's one. Compile and run this PR with the ZIP file and the uploaded demoscpt.txt lump and open any kind of map. It will print 1337 to console.

demoscpt.txt

Since this example uses MustGetStringName function, it will abort to the console with the second one.

@coelckers
Copy link
Member

I merged this manually and changed it to use direct native calls for most functions

@coelckers coelckers closed this Dec 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants