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] Maybe do more with strings, maybe do everything with strings
Date: Sun, 05 Jan 2014 10:34:26 -0500	[thread overview]
Message-ID: <20140005103426.eklhad@comcast.net> (raw)

When I first create the js runtime context,
and when I first create a window to go with the html page,
there are quite a few variables and functions that I set up within js itself,
only because it was easier to do it that way.
Look for the word initScript in jsdom.c.
And I likely could have put more stuff in there.
This raises some questions.

Are all the variables and functions that I made in that manner
protected from gc?
Is that a method that works?

Could it be used more often, and would that be easier and safer,
mostly safer, than what we are doing now?

Example: the function establish_property_string, which puts a string beneath
an object.
This is in jsloc.c.
What if it looked like this instead.

establish_property_string(const char *this_obj, const char *name, const char *value)

this_obj is the full name of the object,
"document.forms.foo.bar"
name and value are as they are today.
The function is then a silly wrapper.

{
char delim = '"'; // string delimiter
// you may need to switch delim to '\'' if value contains quotes.
// If value contains both quotes and apostrophes I'm not sure what to do.
string smallScript =this_obj + "." + name + " = " +
delim + valu + delim;
    JS_EvaluateScript(jcx, jwin, smallScript,
       "establish_property_string", 1, &rval);
}

That last line being replaced with whatever the new call is to
run the js engine on a string.

Looks easy; easier than what we're doing -
except we would have to maintain string pointers instead of object pointers,
even outside of js*.c,
possibly changing stuff in other files.
Might be worth stepping back a bit and see if this is a better approach.
It would almost surely be safer once complete,
since everything is done in their world, playing by their rules.

Karl Dahlke

             reply	other threads:[~2014-01-05 15:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-05 15:34 Karl Dahlke [this message]
2014-01-05 17:01 ` 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=20140005103426.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).