Skip to content

Wildcard import support - #35

Merged
Jamextreme140 merged 3 commits into
CodenameCrew:codename-devfrom
hackx2:wildcard-import-impl
Nov 22, 2026
Merged

Jamextreme140 merged 3 commits into
CodenameCrew:codename-devfrom
hackx2:wildcard-import-impl

Conversation

@hackx2

@hackx2 hackx2 commented Nov 21, 2026

Copy link
Copy Markdown

This PR (as the name suggests) adds wildcard import support. :3

I've added a public variable called allowWildcardImports to the Interp class (omitted when compiled with -D hscriptNoWildcardImports). When this variable is false, wildcard import support is disabled for that interp instance, and when used, results in the following error:
image

Important

This was tested using both hscript-improved built-in unit tests & nightly cne.

Wildcard import:

import haxe.ds.*;

var str = new StringMap<String>();
str.set('fish', "><((()>");
trace(str.get('fish'));

Result:
image

Wildcard import on a package that doesn't exist:

import not.real.cls.*;

new Yes();

Result:
image

as on wildcard import:

import haxe.ds.* as Yes;

var str = new StringMap<String>();
str.set('fish', "><((()>");
trace(str.get('fish'));

Result:
image


With -D hscriptNoWildcardImports, interpreter-based support for wildcard imports is omitted from the build entirely.

Attempting to use wildcard imports on a build created with -D hscriptNoWildcardImports will result in this error:
image


@hackx2
hackx2 force-pushed the wildcard-import-impl branch from ff999af to bca3637 Compare November 21, 2026 17:42

@Jamextreme140 Jamextreme140 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Man, I was thinking about making this possible. Thanks for the contribution :3

@Jamextreme140
Jamextreme140 merged commit 34a7ced into CodenameCrew:codename-dev Nov 22, 2026
1 check passed
@hackx2

hackx2 commented Nov 22, 2026

Copy link
Copy Markdown
Author

Man, I was thinking about making this possible. Thanks for the contribution :3

np :3

Comment thread hscript/Interp.hx
function exprImportWildcard(pkg):Void {
final types = TypeListRegistry.get(pkg);

if(types == null) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This pull request has already been merged, but I have noticed that importFailedCallback is not used here (or anywhere in the pull request), the variable does use only 2 parameters being Array<String>, Null<String>, so it could be changed to include an isWildCard:Bool parameter so that it could fit here (or just make another callback though that's a bit much).
Adding the resolver here would allow for wildcard scripted packages, and making it more consistent with what you'd expect importFailedCallback to do.

This is all really just my thoughts and opinions, as someone who has been messing around with hscript for the last 2 years, so take what I say with a grain of salt.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Will do

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

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.

3 participants