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

Some refactors to main.c #15

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

Some refactors to main.c #15

wants to merge 2 commits into from

Conversation

Slayer95
Copy link
Contributor

@Slayer95 Slayer95 commented Mar 16, 2025

I'm currently working on several features(*) I intend to PR. These refactors are meant to simplify their diffs.

(*) Features:

  1. Eagerly exit / fail fast on first error found (flag +ff?)
  2. Flag to disable dynamic toggling of flags from parsed code (flag +???)
  3. Static build including the following APIs, supporting
    3.1. Parse in-memory buffer(s).
    3.2. Output to a buffer instead of stdout.
// Parse an in-memory buffer
int _cdecl parse_jass(char *output, const int n_max_out_size, int *n_out_size, const char* target, const int target_size);

// Parse in-memory buffers for common.j, Blizzard.j, war3map.j
int _cdecl parse_jass_triad(char *output, const int n_max_out_size, int *n_out_size, const char* buf_common, const int size_common, const char* buf_blizz, const int size_blizz, const char* buf_script, const int size_script);

// Versatile function to parse inputs as if they were passed to latest ``pjass`` binary. (``doparse`` can be refactored to use it.)
int _cdecl parse_jass_custom_r(char *output, const int n_max_out_size, int *n_out_size, const int targets_or_opts_count, const char **targets_or_opts);

// Versatile function to parse inputs with fine-grained control over each file/buffer's flags. (This is my main use case.)
int _cdecl parse_jass_custom(char *output, const int n_max_out_size, int *n_out_size, const int targets_count, const int *targets_sizes, const char **targets, const char **flags);

Do let me know if you find some of these features/APIs useless or w.e.

(cherry picked from commit 13cf484b86d533e0bdaec9ba3cc484baebc3ffe9)
(cherry picked from commit 007d6b6d4462eb1def16ed1de5494d1c2afbd7d1)
@lep
Copy link
Owner

lep commented Apr 2, 2025

Do let me know if you find some of these features/APIs useless or w.e.

If you are writing them because you need them or want to use them they are probably not useless. I guess you'd want them for more of a library-like usage of pjass. So maybe having one general function could be mergeable. Personally i don't have any uses for these atm.

Maybe refactor this PR to use the general API and i can see if i like it.

For the current state of this PR, i do like putting stuff in a tryfile function. The main refactoring i don't seem neccessary but it's also not like a big deal.

@Slayer95
Copy link
Contributor Author

Slayer95 commented Apr 2, 2025

If you are writing them because you need them or want to use them they are probably not useless. I guess you'd want them for more of a library-like usage of pjass.

Exactly so. I'm using it as a dependency of Ghost++. In my branch, there seem to be some preexisting memory leaks due to the original authors' focus on a standalone executable.

Maybe refactor this PR to use the general API and i can see if i like it.

Sure. I messed up while rebasing those features, so that's why I decided to PR this small refactor before investing more time in a PR I was not confident you'd find appealing.

The main refactoring i don't seem neccessary but it's also not like a big deal.

Yeah, I only added that to please git.

Will circle back to this.

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.

2 participants