-
Notifications
You must be signed in to change notification settings - Fork 63
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
Add ability to inject custom JS code for processors #148
Comments
You can paste your custom type to the JS code (debug) tab before all generated code there and then hit Ctrl+Enter while your cursor is still in that tab. However, when you touch your source Therefore, Web IDE has a feature for accepting custom code (intended exactly for opaque type and custom processor definitions) that will be injected at the beginning of JS code (debug) tab after every
I guess that's the idea in the long run, but to me, the current situation is already good enough - there's an easy workaround for this fairly niche feature, which is documented. So quite low priority for me - nice to have, but at least a few dozens of things come before this. |
I can try to look at this myself if
My concrete use-case was solved by this method: open browser console and execute this code: localStorage.setItem("userTypes", `class Hex {
decode(bytes) {
let result = Array(bytes.length / 2);
for (let i = 0; i < bytes.length; i += 2) {
let hi = bytes[i ] - 0x30;
let lo = bytes[i + 1] - 0x30;
if (hi > 9) hi -= 7;
if (lo > 9) lo -= 7;
let byte = hi * 16 + lo;
result[i/2] = byte;
}
return Int8Array.from(result);
}
}
this.Hex = Hex;`) Note: if you have a type named this.HexDecoder = Hex; (use as
|
I have a KSY that needs to decode some field from HEX before parsing it, something like this:
Unfortunately, there is strange obstacles of making that very common algorithm would be available in the core, and WebIDE produces an error:
The corresponding code from "JS code" tab does the follow:
so I tried to implement necessary class in browser console by monkey-patching. I've open a https://ide.kaitai.io/# in Firefox, open console and put the following code to it:
but webide still does not see it.
Is it possible to add a new window to the IDE with the ability to enter JS code that would be injected to parser? And until this would be implemented provide a workaround, how I can inject code right now.
The text was updated successfully, but these errors were encountered: