edbrowse-dev - development list for edbrowse
 help / color / mirror / Atom feed
* [Edbrowse-dev] compartments
@ 2014-02-04 19:17 Karl Dahlke
  2014-02-04 21:00 ` Adam Thompson
  0 siblings, 1 reply; 6+ messages in thread
From: Karl Dahlke @ 2014-02-04 19:17 UTC (permalink / raw)
  To: Edbrowse-dev

Sorry to bother you; don't know if this should move off-line.

> a runtime is created which holds everything else

Ok.

> A runtime can contain multiple contexts,

Ok.

> Each context contains multiple compartments;

Ok.

> In edbrowse each window has its own js context.

Ok.

> Each page within that window has its own global object.

But there is only one page within the window.
An edbrowse window has one html file, one context,
and One global object via JS_NewGlobalObject().
Each context has one global object, and thus one compartment.
So the context is given as the first argument to a js function,
and from there there should be just one compartment and one global object.
I don't see how js could ever get the wrong compartment,
there is only one to choose from.

> What this means when switching pages is that the context needs to be switched

Switch to another edbrowse page and you get another js context,
with its one and only one global object.

I don't doubt you at all when you say the compartment calls
are necessary, I'm just trying to figure out why they are necessary.
If they are, maybe could be confined to jSyncup(),
which starts the javascript thread, and j new context to build
the global for the first time.

Karl Dahlke

^ permalink raw reply	[flat|nested] 6+ messages in thread
* [Edbrowse-dev]  compartments
@ 2014-02-04 22:03 Karl Dahlke
  2014-02-05 10:44 ` Adam Thompson
  0 siblings, 1 reply; 6+ messages in thread
From: Karl Dahlke @ 2014-02-04 22:03 UTC (permalink / raw)
  To: Edbrowse-dev

> When I say a page within a window I'm referring
> to the ability of edbrowse to go back pages.

cw = cw->prev

That's a little over simplified, but that's the idea,
go back to the previous edbrowse window, a completely separate window.
Really not different from switching buffers.
The previous window has its own context, its own global object,
its own html page, etc.

>In theory, but the compartment field is, by default, NULL.

Ok.

I'm not going to mess with it now, I'm working on the representation of lines,
but I may want to remove all those calls and just put one in jSyncup(),
and see if that works.
That is the function that is always called when you enter the world of javascript.
Click a button, submit a form, change a field with onchange code,
any of those things, calls jSyncup().
This takes any changes you made to the form in html
and updates the corresponding js variables,
so you see it would have to be called first before running any js.
If it also set the compartment we would be good, I think.
And we don't really have to be RAII to do this,
just set the comparment to what it should be at that point,
though RAII doesn't hurt.
There might be a simpler function call.
I'll experiment when I'm not in the middle of other changes.

Karl Dahlke

^ permalink raw reply	[flat|nested] 6+ messages in thread
* [Edbrowse-dev]   compartments
@ 2014-02-05 13:55 Karl Dahlke
  2014-02-05 22:09 ` Adam Thompson
  0 siblings, 1 reply; 6+ messages in thread
From: Karl Dahlke @ 2014-02-05 13:55 UTC (permalink / raw)
  To: Edbrowse-dev

Yes everything you say makes perfect sense.

I misspoke a little bit yesterday,  or misthought.
There are two paths to javascript,
creating the global object in the first place,
and then activating js later, which always calls jSyncup
to get things ready.
But aha, raii won't work here.
jSyncup calls and sets everything up and returns.
Then all the other js functions are called.
Set the compartment via raii in jSyncup, and when it returns
your compartment is lost.
We can only simplify things if there is a straight,
old fashioned "set this compartment" call,
that does not involve scope or distructors etc.
I don't know if such a function exists.
If yes then we can clean things up a lot.
If no then we can't.

Karl Dahlke

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-02-05 22:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-04 19:17 [Edbrowse-dev] compartments Karl Dahlke
2014-02-04 21:00 ` Adam Thompson
2014-02-04 22:03 Karl Dahlke
2014-02-05 10:44 ` Adam Thompson
2014-02-05 13:55 Karl Dahlke
2014-02-05 22:09 ` Adam Thompson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).