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

Basic support for "#else" preprocessor in AGS script #2178

Merged

Conversation

ivan-mogilko
Copy link
Contributor

@ivan-mogilko ivan-mogilko commented Oct 13, 2023

I could not find if there was there a ticket for this, maybe I had a false memory about it.

In any case, I got weary of not being able to have #ifdef N #else #endif kind of construct, and tried to implement basic support for "#else".

This is a most trivial and naive implementation, because it assumes only ifdef/else/endif combination. This won't work with "else if", but these are not supported by AGS preprocessor at the moment.

Added to:

  • Editor's preprocessor (C# one);
  • Editor's Autocomplete. Although autocomplete seems to break often when preprocessor definitions are around, but that might be a separate issue. At least it seems to work when the #if/else/endif are on top of the script (outside of function).
  • C++ preprocessor, to sync with the embedded C# one.

If this proves to be working, and merged, then we could also tidy builtin header where declarations depend on SCRIPT_API macros.

PS. I still think we should get a proper complete preprocessor into AGS from somewhere else at some point.

@ivan-mogilko ivan-mogilko added type: enhancement a suggestion or necessity to have something improved what: editor related to the game editor labels Oct 13, 2023
@ivan-mogilko ivan-mogilko force-pushed the 361--trivialpreprocelse branch 2 times, most recently from 83b8bcc to 8dfa8db Compare October 13, 2023 12:18
Also switched vector to stack for conditional statements (seems more logical?).
@ivan-mogilko ivan-mogilko force-pushed the 361--trivialpreprocelse branch from 8dfa8db to a204e17 Compare October 13, 2023 12:19
@ericoporto
Copy link
Member

It would be nice to add a demonstrative test case in https://github.com/adventuregamestudio/ags/blob/master/Compiler/test/preprocessor_test.cpp

@ericoporto
Copy link
Member

Looks good to merge! :)

@ivan-mogilko ivan-mogilko merged commit 1ca7622 into adventuregamestudio:master Oct 15, 2023
20 checks passed
@ivan-mogilko ivan-mogilko deleted the 361--trivialpreprocelse branch October 15, 2023 08:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement a suggestion or necessity to have something improved what: editor related to the game editor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants