edbrowse-dev - development list for edbrowse
 help / color / mirror / Atom feed
* [Edbrowse-dev] Maybe do more with strings, maybe do everything with strings
@ 2014-01-05 15:34 Karl Dahlke
  2014-01-05 17:01 ` Adam Thompson
  0 siblings, 1 reply; 2+ messages in thread
From: Karl Dahlke @ 2014-01-05 15:34 UTC (permalink / raw)
  To: Edbrowse-dev

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

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

end of thread, other threads:[~2014-01-05 17:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-05 15:34 [Edbrowse-dev] Maybe do more with strings, maybe do everything with strings Karl Dahlke
2014-01-05 17:01 ` 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).