edbrowse-dev - development list for edbrowse
 help / color / mirror / Atom feed
From: Karl Dahlke <eklhad@comcast.net>
To: Edbrowse-dev@lists.the-brannons.com
Subject: [Edbrowse-dev] gc rooted
Date: Sat, 25 Jan 2014 11:47:36 -0500	[thread overview]
Message-ID: <20140025114736.eklhad@comcast.net> (raw)

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

             reply	other threads:[~2014-01-25 16:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-25 16:47 Karl Dahlke [this message]
2014-01-25 17:20 ` Chris Brannon
2014-01-26 23:41 ` Adam Thompson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140025114736.eklhad@comcast.net \
    --to=eklhad@comcast.net \
    --cc=Edbrowse-dev@lists.the-brannons.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).