edbrowse-dev - development list for edbrowse
 help / color / mirror / Atom feed
* [Edbrowse-dev] gc rooted
@ 2014-01-25 16:47 Karl Dahlke
  2014-01-25 17:20 ` Chris Brannon
  2014-01-26 23:41 ` Adam Thompson
  0 siblings, 2 replies; 3+ messages in thread
From: Karl Dahlke @ 2014-01-25 16:47 UTC (permalink / raw)
  To: Edbrowse-dev

I finally read the gc rooted guide, and it makes my head spin,
especially since I am still learning C++ on top of it.

I wanted to start at the heart of the matter, jwin,
which is a global pointer to a js object.
The guide talks about local variables, parameters, returns,
heap, but nothing about global or static.
So from the start I am a bit lost.
But I think I will pretend like it is a local variable,
that just never goes out of scope.
So should be declared and defined like this.

[extern] JS::RootedObject *jwin;

Ok then a context switch, moving from buffer 1 to buffer 3,
needs to swap in the new java window.
This is done by jMyContext().
 at 1109,
        jwin = cw->jsw;
This should work, even if jsw remains void * as it is today.
Should be ok.
But how is it set in the first place?

line 877
    jwin = JS_NewGlobalObject(jcx, &window_class, NULL);
I assume NewGlobalObject is part of their API?
I don't see it in my stuff.
Anyways what does it return?
If just an object pointer then it is not rooted,
and maybe should be

jwin = new JS::RootedObject(jcx, JS_NewGlobalObject(jcx, &window_class, NULL));

When we quit a buffer, or ^ to pop the stack, we would free this window,
I suppose by a delete operation,
I wonder if that would clean everything up properly?

Well this is probably the first in a long line of
thoughts, observations, etc, trying to put it all together.
The rooted guide suggests we have to change everything touching js objects.
Unless it is really just stored as void * like cw->jsw, which is probably ok.
But when we use them in any way shape or form, well you know.

Karl Dahlke

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

end of thread, other threads:[~2014-01-26 23:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-25 16:47 [Edbrowse-dev] gc rooted Karl Dahlke
2014-01-25 17:20 ` Chris Brannon
2014-01-26 23:41 ` 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).