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] getters and setters in straight javascript
Date: Sat, 13 Jun 2015 04:48:49 -0400	[thread overview]
Message-ID: <20150513044849.eklhad@comcast.net> (raw)

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

             reply	other threads:[~2015-06-13  8:47 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-13  8:48 Karl Dahlke [this message]
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

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=20150513044849.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).