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

Merging buffer work #2361

Open
wants to merge 94 commits into
base: master
Choose a base branch
from
Open

Merging buffer work #2361

wants to merge 94 commits into from

Conversation

k0T0z
Copy link
Contributor

@k0T0z k0T0z commented Sep 5, 2023

This is the original PR #2309, the purpose here is to split the buffer work from compiler work.

This PR #2350 will depend on the code in this PR.

@dc03 @JoshDreamland @RobertBColton

JoshDreamland and others added 30 commits August 14, 2020 22:34
This gives ENIGMA a custom representation of JDI macros. This functionality is untested. Actually, the only test for the lexer right now is misnamed, but I need to shelve this and fix something in RGM.

This commit integrates the new lexer into the old parser by re-stringifying the lex after syntax checking. It replaces the syntax checker with a call to AST::ParseAST. However, this method is NOT YET IMPLEMENTED, meaning no syntax checking happens as of this commit.

In all likelihood there are remaining problems tokenizing strings, etc. Also, the INCREMENT and DECREMENT tokens cannot be programmatically removed from the token trie at this time.

Theoretically, though, valid games should still build as of this commit.
It's important that the Lexer associated with a given AST never changes.
…ruct.

Cleans up a couple of pull request comments and removes some in-output debug printing.
Moves shared_object_locals into LanguageFrontend. Removes some unused crap in ParsedCode. Lets AST own all the code. Forces construction of ParsedCode with AST&&. Storms the Bastille. Implements AST::ApplyTo at least somewhat appropriately. Moves declaration crawling (invocation) into AST.

Seems to break how constants are detected, but fixes most codegen problems for events. It's adding an unbalanced brace, somewhere, in very rare circumstances.
There were some tokens missing from the trie, and a couple of cases where the lexer might read past the end of a token, or past the end of a string. There's probably more. We could use more tests.
* Add test for macro expansion

The const_cast is used to insert the macro itself forcefully into the lexer so that it can be expanded without having to invoke the preprocessor

* Fix ending parenthesis of macro being considered as a macro argument

When given a macro like MACRO(a, b), this tokenises to 'MACRO', '(', 'a', ',', 'b', ')'. The ending ')' is not considered as a closing parenthesis i.e. as closing off the macro, thus it is inserted as an argument by the macro expansion system. This commit fixes that by making it so that macro arguments are only inserted before the closing parenthesis is encountered which sets the 'paren' variable to 0

* Fix incorrect macro argument stringification in the lexer

This is caused by 'errc.snippet' being used in place of the actual string synthesized to be used. The reason this is done is because the lexer may need to refer to the stringified form of the macro argument long after this is done however the string storing the stringified form is scoped to the function it is created in, thus it will not live as long as the lexer and can cause issues when being referred to after it is destructed.

To fix this, introduce a set to store stringified forms of macro arguments for as long as the lexer lives by adding it as a member variable of the lexer. This will ensure that stringified forms of macro arguments never cause lifetime issues and will also handle deduplicating stringified forms of arguments which stringify to the same string.
Might not fix `__VA_ARGS__`-based macros converted from JDI, because those may not append an empty parameter name for the `...` param (so the argument vector may need to be one larger than the parameters vector).

Seems to fix the test harness but I cbf to wait on it.
Document behavior of control-expression parsing.

Fix warnings for missing values in token name registry.
Update buffer_fill and buffer_poke
dc03 and others added 19 commits July 6, 2022 23:39
- I had for some reason decided to use `std::min(GetSize(), size) -
  offset` to determine the number of bytes used after truncation.
  This obviously makes no sense, as if `size` is lesser than the buffer
  size, then it'll either underflow or use a smaller amount than
  required instead of going to the buffer end.
- `write_to_buffer` could have a buffer overflow error when writing to a
  `buffer_wrap`, which came up with a test for `buffer_load_ext`
- `buffer_copy` did not calculate the new size properly when truncating,
  fix that
Signed-off-by: Saif Kandil <74428638+k0T0z@users.noreply.github.com>
Signed-off-by: Saif Kandil <74428638+k0T0z@users.noreply.github.com>
Signed-off-by: Saif Kandil <74428638+k0T0z@users.noreply.github.com>
Signed-off-by: Saif Kandil <74428638+k0T0z@users.noreply.github.com>
Signed-off-by: Saif Kandil <74428638+k0T0z@users.noreply.github.com>
Signed-off-by: Saif Kandil <74428638+k0T0z@users.noreply.github.com>
k0T0z added a commit to k0T0z/enigma-dev that referenced this pull request Sep 6, 2023
…nigma-dev#2361 merged

Signed-off-by: Saif Kandil <74428638+k0T0z@users.noreply.github.com>
@RobertBColton
Copy link
Contributor

Is this still needed for #2350?

@k0T0z
Copy link
Contributor Author

k0T0z commented Sep 30, 2023

Is this still needed for #2350?

Without this, there are some functions in the Social API that won't work such as:

  • steam_image_get_size();
  • steam_image_get_rgba();
  • steam_image_get_bgra();
  • steam_image_get_argb();
  • steam_image_create_sprite();

Note that these functions won't crash on master, it just doesn't work.

Also, @dc03 said that the buffer work can be merged into the master.

Dhruv Chawla — 05/09/2023 14:49
Josh I feel like the buffer functions (except for game_save and game_load) can be merged into master

@dc03
Copy link
Contributor

dc03 commented Sep 30, 2023

@k0T0z Yes, they should be merged into master, but I would prefer if it didn't involve any revert commits or merge commits... I think we should discuss this more with @JoshDreamland before moving forward with this.

@k0T0z
Copy link
Contributor Author

k0T0z commented Sep 30, 2023

Oooh, forgot to mention that the work in this PR gives build failure, I had to test the Social API inside the AST-Generation branch itself.

I think this PR will be closed, and the buffer work will be merged with AST-Generation branch.

@dc03
Copy link
Contributor

dc03 commented Sep 30, 2023

AST-Generation is quite a ways out from being merged, I think merging the buffer work into master is a good idea.

@RobertBColton
Copy link
Contributor

I'll await until that discussion has happened, just ding me on this when it's ready to merge.

@k0T0z
Copy link
Contributor Author

k0T0z commented Oct 1, 2023

very good then

RobertBColton added a commit that referenced this pull request Oct 11, 2023
)

Closes #1881. This is the second part of my first PR #2343.

This PR is part of the ``Google Summer of Code 2023`` program.

I will be updating my Logs inside my [domain](https://k0t0z.github.io).

#### Note: ✔️ means that SOG/unit tests for the
corresponding function are provided.


---------------------------------------------------------------------------------------------------

✅ [Leaderboards
API](https://github.com/YoYoGames/GMEXT-Steamworks/wiki/Leaderboards)
 - ✅ steam_create_leaderboard();
 - ✅ steam_upload_score();
 - ✅ steam_upload_score_ext();
 - ⬜ steam_upload_score_buffer();
 - ⬜ steam_upload_score_buffer_ext();
 - ✅ steam_download_scores();
 - ✅ steam_download_scores_around_user();
 - ✅ steam_download_friends_scores();
 - ⬜ ``LeaderboardEntry`` data type
 - ✅ ``LeaderboardDisplayType`` constant
 - ✅ ``LeaderboardSortOrder`` constant


---------------------------------------------------------------------------------------------------

✅ [Social
API](https://github.com/YoYoGames/GMEXT-Steamworks/wiki/Social)
 - ✅ steam_set_rich_presence();
 - ✅ steam_set_clear_presence();
 - ✅ steam_user_set_played_with();
 - ⬜ steam_get_friends_game_info();
 - ✅ steam_get_user_avatar();
 - ✅ steam_image_get_size();
 - ✅ steam_image_get_rgba();
 - ✅ steam_image_get_bgra();
 - ✅ steam_image_get_argb();
 - ✅ steam_image_create_sprite();


---------------------------------------------------------------------------------------------------

⬜ [Cloud
API](https://github.com/YoYoGames/GMEXT-Steamworks/wiki/Cloud)
 - ⬜ steam_is_cloud_enabled_for_app();
 - ⬜ steam_is_cloud_enabled_for_account();
 - ⬜ steam_get_quota_total();
 - ⬜ steam_get_quota_free();
 - ⬜ steam_file_exists();
 - ⬜ steam_file_size();
 - ⬜ steam_file_persisted();
 - ⬜ steam_file_write();
 - ⬜ steam_file_write_file();
 - ⬜ steam_file_read();
 - ⬜ steam_file_share();
 - ⬜ steam_file_delete();


---------------------------------------------------------------------------------------------------

## Must Be Done Before Merging:

✅ Adding support for other platforms in the Makefile
file.
✅ Switching the ``Default`` property in the Steamworks
& Json extensions YAML file to ``false``.
✅ Switching the ``cxxflags`` property in
``Compilers/Linux/gcc.ey`` to ``-fdiagnostics-color=always``.
⬜ Reviewing all error messages and documentation in
newly added files.
✅ Adding the license to all newly added files.
✅ Providing installation instructions for all
platforms.
✅ Modifying the extension to call ``steam_init();``
automatically when enabled.
✅ Match all naming conventions with GMS's Steamworks
extension.
⬜ Testing the APIs with the latest version of
Steamworks SDK, Steam, OS version, etc.
⬜ Must test all EDL scripts in the example game
provided.
⬜ Providing SOG/unit tests for all functions written
(this need to be studied carefully as in order to test the C++ wrapper
tester must have steam installed and running or I may use mocks).
✅ Clearing garbage files.
✅ ``DEBUG_MESSAGE()`` must exist only in APIs files.
Try to remove it from wrapper files. Try to make the wrapper independent
on ENIGMA.
✅ Fix example game background design.
⬜ Update the example game to match the latest version
of [GMS Steamworks
extension](https://marketplace.yoyogames.com/assets/10709/steamworks-ext).

:white_check_mark: The compiler must write a file next to the exe.
:white_large_square: Review includes.

:white_check_mark: Commit the example game again and remove it from
``.gitignore`` file.
:white_large_square: The extension and the example must be compatible
with GameMaker.
:white_large_square: Set the title for Steamworks demo to ``Created with
ENIGMA``.
:white_large_square: Monitor GMS's terminal behavior.


---------------------------------------------------------------------------------------------------

## Dependencies:

- [Social
API](https://github.com/YoYoGames/GMEXT-Steamworks/wiki/Social) depends
on this #2309 (#2361).


---------------------------------------------------------------------------------------------------

## Good to have:

:white_large_square: Test the changes with
[RGM](https://github.com/enigma-dev/RadialGM).
:white_large_square: Solve all build warnings.

---------

Signed-off-by: Saif Kandil <74428638+k0T0z@users.noreply.github.com>
Co-authored-by: saifkandil <saifsaalaheldeen2002@gmail.com>
Co-authored-by: = <=>
Co-authored-by: --replace-all <--replace-all>
Co-authored-by: Robert Colton <robertbcolton@gmail.com>
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.

None yet

4 participants