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

Implementing automatic includes #561

Merged
merged 12 commits into from
Oct 31, 2024
Merged

Implementing automatic includes #561

merged 12 commits into from
Oct 31, 2024

Conversation

RhoSigma-QB64
Copy link
Member

@RhoSigma-QB64 RhoSigma-QB64 commented Oct 29, 2024

Long discussed, finally here :)

  • Adapted the forced include mechanism (originally implemented by Fellippe to include the $DEBUG/vWatch stuff) to allow any number of auto-includes before and after the regular program content.
  • The system is now also smart enough to see when such a file is loaded directly and then not including it, so it avoids all the duplicate definitions caused by that.
  • Added beforefirstline.bi and afterlastline.bm files in internal/support/include, which implement some CONST and helper functions and be helpful in the future for other things. Read the file header, some rules must be followed to avoid conflicts or errors with user code.
  • Best way to ensure the rules is to always edit the files in the IDE, which detects these files when loaded and switches into a special mode to enforce the rules.

Also in this PR:

  • Implemented human readable syntax entries (idstruct) for user defined SUBs and FUNCTIONs for better reference.
  • Used the new auto-includes to implement the _MIN and _MAX functions as new internal keywords to QB64PE, more or less as example how to make it.
  • Also implemented EncodeURL$ and DecodeURL$ functions here, which may be used in conjunction with the _OPENCLIENT(HTTP:url) syntax
  • We can consider taking the HTTP stuff out of $UNSTABLE now, as this closes _OpenClient() with an HTTP URL should automatically do the necessary URL encoding. #259 in the respective Milestone and it would also make sense for the v4.0.0 release.

You may probably ignore reviewing the internal/source related commits, too many changes to the internals, so I just thought to provide the whole thing for bootstrapping.

- making the bootstrap compiler aware of auto-includes and changed helper routines
- internal handling logic adapted from already available vwatch auto-including
- vwatch as well as the new auto-include files now run through the same logic
- added beforefirstline.bi with CONST definitions
- added afterlastline.bm with new _MIN and _MAX functions and helper routines
- removed old WhatIsMyIP routine (myip.cpp)
- implemented new helper routines from auto-includes
- added _MIN and _MAX to highlighter
- a special edit mode will be automatically enabled when loading one of the auto-includes
- it is changing options and checks to enforce the rules set for these files
- implements id.hr_syntax entries for user defined SUBs and FUNCTIONs for better reference
@RhoSigma-QB64 RhoSigma-QB64 added the enhancement New feature or request label Oct 29, 2024
@RhoSigma-QB64 RhoSigma-QB64 self-assigned this Oct 29, 2024
- need to remember to use the 64bit version for those changes
@FellippeHeitor
Copy link
Contributor

Just some trivia: The force include mechanism was already there when I adapted it for $debug; Galleon had put it in place for the old Virtual Keyboard subsystem (remember the Android dream?).

@RhoSigma-QB64
Copy link
Member Author

Just some trivia: The force include mechanism was already there when I adapted it for $debug; Galleon had put it in place for the old Virtual Keyboard subsystem (remember the Android dream?).

Aha, didn't know that.

@mkilgore
Copy link
Contributor

Some thoughts on the Http changes:

After seeing this I'm thinking I was wrong about having us encode the URL for the user, I think it would be better to expose your _EncodeUrl$ and _DecodeUrl$ functions as part of the language and leave it up to the user to correctly encode the URL passed to _OpenClient (we would also remove the URL state logic from _EncodeUrl$, it would just encode whatever it is given). The problem is that there's ambiguous cases where only the user would know the correct way to encode the URL (Ex. ?foo=bar&baz). Presumably this same issue is why libcurl doesn't do the encoding automatically either, not sure why that didn't occur to me 🤦

The separate thing is libcurl inclusion. You mentioned in the comments keeping _WhatIsMyIp$ TCP/IP-based to avoid pulling in libcurl, but that won't work if $Unsafe:Http is removed - all networking programs will get libcurl because we don't know how they will use _OpenClient. It's definitely an issue worth considering, I think the only real way to avoid it is to add a new flag to replace the $Unsafe:Http flag (which admittedly is a bit ugly).

- all changes related to the PR comments and discussions at Discord
- further adjustments to the special edit mode for auto-includes and its internal keyword registration
- recognize F/f as exponent introduction for _FLOAT numbers given to  VAL()
- reset IDE path when "New" is selected, avoids quick inattentive saves to disappear to wherever you were before
- _EXPLICITARRAY was missed from reserved words list
- once more update the bootstrap compiler for latest changes of the internals
- oh look, it knows F now :)
- however, range still limited to DOUBLE yet
@RhoSigma-QB64 RhoSigma-QB64 merged commit 390723f into main Oct 31, 2024
4 checks passed
@RhoSigma-QB64 RhoSigma-QB64 deleted the auto-includes branch October 31, 2024 16:27
@RhoSigma-QB64 RhoSigma-QB64 mentioned this pull request Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Development

Successfully merging this pull request may close these issues.

_OpenClient() with an HTTP URL should automatically do the necessary URL encoding.
4 participants