-
Notifications
You must be signed in to change notification settings - Fork 123
Add vs-constr-render to ValueSkeleton for Custom Rendering #1805
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
base: horizon
Are you sure you want to change the base?
Changes from 7 commits
6f42673
cfef5d9
cf2b9e0
124ea09
f0e37b9
ec86502
484d5d6
0c1f593
6a6c872
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -202,9 +202,24 @@ function (Namespace, jsnums, codePoint, util, exnStackParser, loader, seedrandom | |
| */ | ||
| function isBase(obj) { return obj instanceof PBase; } | ||
|
|
||
| const thisContext = "cli"; | ||
| function isInRendererContext(val) { | ||
| var renderers = thisRuntime.getField(val, "renderers"); | ||
| return thisRuntime.hasField(renderers, thisContext); | ||
| } | ||
|
|
||
| function renderValueSkeleton(val, values) { | ||
| if (thisRuntime.ffi.isVSValue(val)) { return values.pop(); } // double-check order! | ||
| else if (thisRuntime.ffi.isVSStr(val)) { return thisRuntime.unwrap(thisRuntime.getField(val, "s")); } | ||
| else if (thisRuntime.ffi.isVSConstrRender(val) && isInRendererContext(val)) { | ||
| var items = thisRuntime.ffi.toArray(thisRuntime.getField(val, "args")); | ||
| var strs = []; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These aren't actually guaranteed to be strings, though, right? (It could be arbitrary HTML or something?) |
||
| for (var i = 0; i < items.length; i++) { | ||
| strs.push(renderValueSkeleton(items[i], values)); | ||
| } | ||
| const renderers = thisRuntime.getField(val, "renderers"); | ||
| return thisRuntime.getField(renderers, thisContext).app(strs); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What happens when this In general, I'm concerned about allowing arbitrary Pyret code to run during rendering, such that if the Pyret code is buggy/unexpected, the overall rendering algorithm will choke and produce no output at all, or the dreaded "error while rendering; details logged to console" message... Do you have a fallback here for what to do if that |
||
| } | ||
| else if (thisRuntime.ffi.isVSCollection(val)) { | ||
| var name = thisRuntime.unwrap(thisRuntime.getField(val, "name")); | ||
| var items = thisRuntime.ffi.toArray(thisRuntime.getField(val, "items")); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels very brittle to me. I also don't see where this gets changed for other contexts -- you have it marked as a
const, so line 221 will never look for anything other thanclicontext, right? (In the PR you linked to, it's aconstofcpo, which again is rigid.Also -- how does this interact with
to-reprandto-string?