Skip to content

Ios compatibility codex#5

Merged
OlKir merged 2 commits intoios_compatibilityfrom
ios_compatibility_codex
Oct 3, 2025
Merged

Ios compatibility codex#5
OlKir merged 2 commits intoios_compatibilityfrom
ios_compatibility_codex

Conversation

@OlKir
Copy link
Copy Markdown

@OlKir OlKir commented Oct 2, 2025

AI (codex) refactored static CustomWeighting.Parameters createWeightingParameters to avoid instantiation of customModel Java class in runtime. Instead class is parsed and parameters are built based on restored logic.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The parser looks very nice maybe we can even use this on android as well 👍

Just one comment as i don't get why it was added

return true;
}
}
} else if (n.identifiers.length == 1 && mi.arguments.length == 0 && variableValidator.isValid(n.identifiers[0])) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Why was this added it seems like this tries to support a method invocation pattern?

Copy link
Copy Markdown
Author

@OlKir OlKir Oct 2, 2025

Choose a reason for hiding this comment

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

Codex:

I added that branch in core/src/main/java/com/graphhopper/routing/weighting/custom/ConditionalExpressionVisitor.java:108 because, while testing the refactored custom-model caching, Janino sometimes reports the target of an ordinal() call as a single identifier. For expressions like track_type.ordinal() in the built-in models (e.g. motorcycle.json), mi.target.toRvalue() now yields an AmbiguousName with length 1, so our earlier logic never recorded track_type as a used variable and the parser rejected the condition (“… not available”). The new else if just mirrors the existing road_class.ordinal() case for that AST shape so we still accept the expression and we add the variable to guessedVariables, ensuring the enum accessor is created when the model is re-used from the cache.

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.

For me it's a quick fix for .ordinal() operation. I'm not sure if we use it. But might be useful in future:

change is not specific to track_type; it kicks in whenever Janino gives us a zero-argument method call whose target reduces to a single identifier that the validator accepts. So any bike-oriented custom model that ever does something like bike_network.ordinal() (or a similar accessor on a bike-specific encoded value) now stays valid and keeps the variable in guessedVariables, ensuring the lookup/accessor is built correctly. Even though the shipped bike models don’t currently rely on .ordinal(), they’re covered automatically if we add such expressions later.

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.

The fact that core tests are passing without this addition kind of confirms the statement.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hmm alright sounds good to me

@OlKir OlKir merged commit 2d46d73 into ios_compatibility Oct 3, 2025
2 of 4 checks passed
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