On Sat, Mar 01, 2014 at 02:24:32PM -0500, Karl Dahlke wrote:
> Yeah, this is something I got confused about too,
> until Chris set me straight.
> Duh - I wrote it - and then I got confused about it.
> I can be dumb as a box of rocks sometimes.
I remembered something about this after I replied but couldn't remember the
details.
At some stage I really need to familiarise myself with the html code.
> The linked list or array or vector or whatever holds pointers
> to struct htmlTag, not the struct itself.
> So structs can go ahead and point to each other as parents and children,
> because the structs don't move.
> The growing vector simply reallocates the list of pointers to those structures.
Stupid question, and appologies if this's already been asked,
but why are we storing a list of pointers?
>
> I already do this, don't I?
> t->controller is the form that owns the input tag,
> and for an option t->controller is the select that owns the option.
> Just rename controller parent and you're halfway there.
We also need to store a list of children in each tag, i.e. in the code:
The body would have a list of two pointers to the two div tags,
the first div tag would need to hold a list of two pointers to the two p tags
under it, whilst the second div tag only has one pointer to the p tag under it.
As you say though, each tag only needs a single parent link,
which simplifies things.
>
> So with this in mind
>
> static list < struct htmlTag *>htmlStack;
>
> becomes
>
> static vector < struct htmlTag *>htmlStack;
>
> Then sure it's all normal after that, and I'd just love to
> set cw->tags to htmlStack, but cw->tags
> is one of those things that is in C, not C++.
> In fact it's in eb.h, thus in every C file,
> so we'd have to use void * or some such, or convert the whole project to C++.
Or according to [1] set it to:
cw->tags = &htmlStack.front();
> But that's the idea, and we can certainly move forward there.
No need to do this rewrite at the moment,
and I think we need to get the js stuff sorted before we start contemplating
any possible benefits (I'm still not entirely convinced honestly) of doing this.
> Then there is no trouble adding new tags as we need to,
> as js creates new thingees for us.
Yeah, as long as we ensure we append the correct child list and set the parent
pointer correctly.
Cheers,
Adam.
[1] http://stackoverflow.com/questions/6485496/how-to-get-stdvector-pointer-to-the-raw-data