Repository navigation
Conversation
Contributor
Member
|
Can you please add a snippet showing it? |
Contributor
Author
Showing what specifically? e.g. we have Snippet307 showing Browser Function usage. |
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
Backend-dependent public API behavior needs human compatibility review and regression validation.
Review effort: Balanced
Findings: 1
Open (2)
What changed in this PR
Prototypes object/Map support in SWT’s shared browser JSON codec, without changing native conversion paths.
Changes:
- Decode JSON objects into insertion-ordered maps.
- Encode String-keyed maps, rejecting other key types.
- Document backend limitations internally.
| File | Description |
|---|---|
| bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/JSON.java | Adds object/Map conversion and documents its scope. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+278
to
+279
| } else if (object instanceof Map) { | ||
| writeMap((Map<?, ?>)object); |
Comment on lines
+23
to
+24
| // javascript objects are decoded as java.util.LinkedHashMap<String, Object> (insertion order preserved). | ||
| // Any java.util.Map with String keys can be encoded back into a javascript object. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Currently BrowserFunction/Evaluate only supports primitives and arrays but not objects.
This is a prototype to add support for having a
Map<String, Object>support, but is not complete because Object/Map support is inconsistent across the 4 native backends because they use two different marshalling strategies:So JSON.java is only the actual conversion path for Edge (fully) and for WebKitGTK's BrowserFunction call marshalling (function args come in via a swt:// URL query string that's JSON-encoded, and the return value is JSON-stringified back to JS). The other native paths inspect JS values directly (JSC API, WebScriptObject, IDispatch) and only ever check for arrays via a length property/index — no key enumeration exists for plain objects.
I still wanted to share this here for gathering feedback of others, if such partial support would be helpful (windows+linux) and possibly ideas how we can streamline this across different OS. My main workaround currently is to start a local webserver and using rest calls, but this is a bit brittle and not always possible due to restricted environments.