edbrowse-dev - development list for edbrowse
 help / color / mirror / Atom feed
* [Edbrowse-dev] getters and setters in straight javascript
@ 2015-06-13  8:48 Karl Dahlke
  2015-06-13 10:50 ` Karl Dahlke
  2015-06-13 21:39 ` Chris Brannon
  0 siblings, 2 replies; 8+ messages in thread
From: Karl Dahlke @ 2015-06-13  8:48 UTC (permalink / raw)
  To: Edbrowse-dev

Friends, before Adam dives into javascript duktape engine, if he
could procrastinate just a couple more days, I would like to ask a question.
This is just for discussion, I don't know enough even to have an opinion.

The edbrowse-js that we have working today, based on mozilla,
is 2354 lines of c++.
Within this, the setters and getters for the URL class are 439 lines of code,
almost one fifth of the total.
If we include other setter code,
such as document.cookie = "foo=bar" folding this into the entire
document.cookie string,
we could be talking about a quarter of the code or more.
This is all C, and all tightly coupled to the getter syntaax
of whatever engine we are using, all has to be modified
whenever we upgrade or switch engines.
My question is, could some of this be done by generic javascript
in the sourcefile startwindow.js?
Does it really have to be native C?
There are already some URL.prototype definitions in there,
perhaps we could add some getters and setters easily
that would do all the stuff I do in C today.
Have a look at this web page.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Working_with_Objects
Read the section Defining getters and setters

Is this mozilla specific, or generic javascript?
Perhaps run some of the examples through d8.

The examples seem to suggest object.x can be defined as a getter or setter
but not both.
If that is the case then it won't work for us.
URL.port needs to fetch the port, 80 for example,
but url.port = 8080 needs to set the port and also change the port
in url.href.

This is an area of javascript that I didn't know existed
at all until last week, so I'm still learning.
Just raising some questions,
because the several hundred lines of C code that implement the setters
are a bit ugly, or at least awkward and engine specific.

Karl Dahlke

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

end of thread, other threads:[~2015-06-15 19:57 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-13  8:48 [Edbrowse-dev] getters and setters in straight javascript Karl Dahlke
2015-06-13 10:50 ` Karl Dahlke
2015-06-14  9:13   ` Adam Thompson
2015-06-13 21:39 ` Chris Brannon
2015-06-14  9:11   ` Karl Dahlke
2015-06-14  9:31     ` Adam Thompson
2015-06-14 15:04       ` Karl Dahlke
2015-06-15 19:59         ` 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).