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
_______________________________________________
Edbrowse-dev mailing list
[email protected]
http://lists.the-brannons.com/mailman/listinfo/edbrowse-dev