boxes-per-row can't do 32?
adb-luna opened this issue · 7 comments
Is your feature request related to a problem? Please describe.
I am trying to describe a structure that has 32-bit words, but boxes-per-row will not accept a value above 16 with an error about vector length.
Describe the solution you'd like
(def boxes-per-row 32) shouldn't give an error of “No item 16 in vector of length 16”.
Describe alternatives you've considered
I modified the core.cljs build-initial-globals to make the default boxes-per-row equal to 64, but I get the same error.
Additional context
None
Can you please supply a stack trace that gives more details about where the problem is happening? I may be able to help, but you might need to write your own entire set of functions to extend it in this direction as well.
Thanks for the help @brunchboy. Here is the stack trace.
/home/account/node_modules/bytefield-svg/lib.js:369
var sj=function sj(a,b,c,d){var f=pj(c),k=a.A-1>>>b&31;5===b?f.l[k]=d:(c=c.l[k],null!=c?(b-=5,a=sj.s?sj.s(a,b,c,d):sj.call(null,a,b,c,d)):a=rj(null,b-5,d),f.l[k]=a);return f};function tj(a,b){throw Error(["No item ",p.La(a)," in vector of length ",p.La(b)].join(""));}function uj(a,b){if(b>=qj(a))return a.fb;var c=a.root;for(a=a.shift;;)if(0<a){var d=a-5;c=c.l[b>>>a&31];a=d}else return c.l}function vj(a,b){return 0<=b&&b<a.A?uj(a,b):tj(b,a.A)}
^
Error: No item 16 in vector of length 16
at tj (/home/account/node_modules/bytefield-svg/lib.js:369:199)
at vj (/home/account/node_modules/bytefield-svg/lib.js:369:437)
at K.g.$ (/home/account/node_modules/bytefield-svg/lib.js:375:282)
at Function.C.Na (/home/account/node_modules/bytefield-svg/lib.js:109:158)
at /home/account/node_modules/bytefield-svg/lib.js:1814:170
at /home/account/node_modules/bytefield-svg/lib.js:1814:182
at /home/account/node_modules/bytefield-svg/lib.js:1814:206
at kh (/home/account/node_modules/bytefield-svg/lib.js:196:54)
at jh.g.U (/home/account/node_modules/bytefield-svg/lib.js:198:376)
at B (/home/account/node_modules/bytefield-svg/lib.js:87:84)
Hmm, I need a Clojure stacktrace, not a Javascript stack trace, I am a Clojure developer. I can’t make sense of that, I’m afraid. I don’t see how to relate it back to my source code. If you can figure out the root cause here I’d appreciate very much hearing it.
(From that I can’t even see the function that is throwing the exception, which is step 1 in figuring out what is causing it.)
If I find myself with a bunch of time to spare, I may try to re-learn how this project builds and whether there is a way to run it that is less heavily compiled, to get better debugging. But I am preparing for a memorial service for both my parents, who passed away rather abruptly recently, and am also busy with my main open source projects, so I can’t predict when I would be able to do that. In the mean time, you might want to try adding some debugging code of your own and see if you can pin this down.
OK, I am getting somewhere. If you run it from the command-line in the top of the project source, like so:
npx bytefield-svg <test.edn >test.svg
Then you get stack traces from the Clojure source, not the minified Javascript build, which tell you far more useful information. I have been able to reproduce the problem, so I will be able to poke at it a bit as I find time.
Ah ha! Your problem is happening here:
And that is because it is trying to ask for the seventeenth column label, and there are only sixteen of them defined as I ship it. You are going to need to decide what you want as column labels for all of your columns, and set those up, before you try to draw your boxes. You can do this by def
ing a new value in the predefined value column-labels
, or calling draw-column-headers
yourself with your own vector of labels before you draw the boxes.
Thanks @brunchboy! You are correct that defining the column labels with more entries solves the problem. Thank you for looking into this, and I offer my condolences for the loss of your parents.
For anyone needing details, this is working:
(def column-labels (str/split "31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0" #","))
(def boxes-per-row 32)
(draw-column-headers )