1
0
Fork 0
Commit Graph

1113 Commits (1fe8a0e8d69a057ce8923577ae8b0e0d805fbd80)

Author SHA1 Message Date
Mike Gerwitz 1fe8a0e8d6
Remove interactive.js jQuery dependency
Importantly, this also removes loading from ajax.googleapis.com, which is a
problem, because the domain must be allowed using NoScript, and hosts many
other things.

Why this was added to begin with is beyond me.  Perhaps it demonstrates my
novice abilities back in the day.
2015-08-23 00:37:24 -04:00
Mike Gerwitz 62f7e0111a
README.md et. al. restructuring
There is now only one README* file---README.md.  Other files have been
renamed (e.g. README.hacking=>HACKING), or consolidated.
2015-08-23 00:15:48 -04:00
Mike Gerwitz 4a61781701
Browserify fix 2015-08-14 14:00:27 -04:00
Mike Gerwitz fdc2f2e3c3 __dirname removal from index.js
This satisfies Browserify, which apparently does not like __dirname
2015-08-14 13:46:20 -04:00
Mike Gerwitz 1d828b7ee2
LibreJS license header for doc/interactive.js 2015-07-06 23:42:53 -04:00
Mike Gerwitz b91d243e2b
package.json updates 2015-05-28 23:55:19 -04:00
Mike Gerwitz a1c2fbeaa4 package.json engines removed; unnecessary 2015-05-28 23:54:35 -04:00
Mike Gerwitz 32d004bee7 package.json repo URL update to HTTP
Browsable and less likely to be blocked by corporate firewalls.
2015-05-28 23:53:32 -04:00
Mike Gerwitz 6c6a3af03d package.json author e-mail update 2015-05-28 23:50:37 -04:00
Mike Gerwitz 579527d168
Class is not a needed dependency for Interface 2015-05-28 01:23:52 -04:00
Mike Gerwitz db3ade378a
[copyright] Copyright update 2015-05-28 01:01:51 -04:00
Mike Gerwitz 7ce57b7d97
Trait class extend support 2015-05-28 00:01:24 -04:00
Mike Gerwitz c27400ca83 README.traits "Trait Extending" section update to reflect class extension support 2015-05-27 23:40:30 -04:00
Mike Gerwitz f3a8dea25d Test ensuring `#use` staging object satisfies `Class.isClass` 2015-05-27 23:38:07 -04:00
Mike Gerwitz 867127ed2f Trait class extension support
"Extending" a class C simply creates a contract stating that the trait may
only be mixed into something of type C (so, C or its subtypes).
2015-05-27 23:23:47 -04:00
Mike Gerwitz 96c5a702ce Abstract mixin initial implementation 2015-05-27 23:23:47 -04:00
Mike Gerwitz 5b6a0c0bb5 "lazy" metadata support 2015-05-27 23:23:47 -04:00
Mike Gerwitz e866f53d4c Remove global _extending state
The previous implementation could not survive recursive applications, which
I did know about.  But that was before the system was brutally abused by
traits.
2015-05-27 23:23:47 -04:00
Mike Gerwitz 69e9828beb Object class masquerading 2015-05-27 23:23:47 -04:00
Mike Gerwitz 98e76be94f
Implementation note on this.__super scope with private method calls 2015-05-27 23:23:26 -04:00
Mike Gerwitz c896bdbc27
.mailmap updated with mtg@gnu.org 2015-05-11 23:11:25 -04:00
Mike Gerwitz 1ed7bd0e8b
package.json syntax correction (oops)
Was not able to rebase because I already stupidly pushed, and Savannah does
not allow --force, or deleting `master' to circumvent. ;)  Not that it would
be a good idea rergardless.
2015-05-10 01:39:12 -04:00
Mike Gerwitz d955d6e86a
package.json keyword additions and corrections 2015-05-10 01:27:27 -04:00
Mike Gerwitz a3add011fb package.json keyword additions
This list has also been sorted, so pay close attention to the diff.
2015-05-10 01:27:10 -04:00
Mike Gerwitz dcbe48d982 package.json {tags=>keywords}
Was the key "tags" in the past?  Regardless, it doesn't work [anymore], so
ease.js keywords haven't been searchable in npm for quite some time /
forever.
2015-05-10 01:24:22 -04:00
Mike Gerwitz fcdfae68b2
tools/copyright ignore `.|..' 2015-05-06 22:36:52 -04:00
Mike Gerwitz 991f4086fa
Remove Trait/ParameterTest ctor ordering comment (since resolved) 2015-05-06 22:32:55 -04:00
Mike Gerwitz 313a51d750
README TODOs using Org mode
Even if you don't use Emacs, the outline style should be intuitive.

This commit is partially for organization, partially to let people
know that this project is still on my mind and will be getting more
attention soon.
2014-12-19 22:25:18 -05:00
Mike Gerwitz ee85b058df
Various ES3-related bugfixes for bugs introduced by v0.2.3
GNU ease.js remains committed to supporting environments as far back as ES3;
unfortunately, this is important due to the popularity of older IE versions
(IE<=8). Btw, ease.js runs on IE 5.5, in case you still need that. ;)

But please don't use a proprietary web browser. Indeed, this is why the
breaks were introduced in the first place: I neglected to run the
browser-based test suite on the proprietary Microsloth browsers until after
the v0.2.3 release, because I do not own a copy of Windows; I had to run it
at work. But, regardless---my apologies; I'll be more diligent.
2014-08-07 22:57:14 -04:00
Mike Gerwitz a5c89565fe `undefined` is no longer applied to Trait.__mixin
This is a bugfix; the bug was introduced in v0.2.3.

Notably, this caused problems in IE<=8 for non-argument traits. The problem
is that `fund.apply( x, undefined )` is not valid in ES3---we must apply an
empty array (or argument list) instead.
2014-08-07 22:53:10 -04:00
Mike Gerwitz 324ff5ddca Global no longer uses root as alt object prototype
This is a bugfix; the bug was introduced in v0.2.3.

Initially, the implementation created a new object with the root object as
its prototype, taking advantage of ECMAScript's native
overrides/fallthroughs. Unfortunately, IE<=8 had a buggy implementation,
effectively treating the prototype as an empty object. So, rather than
alt.Array === root.Array, alt.Array === undefined.

The fix is simply to reference discrete objects.
2014-08-07 22:33:04 -04:00
Mike Gerwitz d0ec7aca9b method.super references now ES3-compatible
This is a bugfix; the bug was introduced in v0.2.3.

In ECMAScript 5, reserved keywords can be used to reference the field of an
object in dot notation (e.g. method.super), but in ES3 this is prohibited;
in these cases, method['super'] must be used. To maintain ES3 compatiblity,
GNU ease.js will use the latter within its code.

Of course, if you are developing software that need not support ES3, then
you can use the dot notation yourself in your own code.

This does not sway my decision to use `super`---ES3 will soon (hopefully)
become extinct, and would be already were it not for the terrible influence
of Microsloth's outdated browsers.
2014-08-07 22:24:25 -04:00
Mike Gerwitz cef45cd097
Corrected test broken by Node.js v0.10.27
Specifically, aae51ecf, which introduces deepEqual changes for comparing
argument objects---specifically, this change:

```c
  if ((aIsArgs && !bIsArgs) || (!aIsArgs && bIsArgs))
    return false;
```

Since I was comparing an array with an arguments object, deepEqual failed.
While such an implementation may confuse users---since argument objects are
generally treated like arrays---the distinction is important and I do agree
with the change.
2014-08-07 00:01:59 -04:00
Mike Gerwitz bbfac76c34
Interface.isInstanceOf now accounts for interface interop
More information in the merged commit message.
2014-08-06 23:09:15 -04:00
Mike Gerwitz b9ba6388d2 Interface.isInstanceOf will account for interop compatibility
This is a bug fix.

If the provided object's constructor is an ease.js type, then the
conventional rules will apply (as mentioned in the test docblock and in the
manual); however, if it's just a vanilla ECMAScript object, then the interop
compatibility checks will be used instead.

The manual already states that this is the case; unfortunately, it
lies---this was apparently overlooked, and is a bug.
2014-08-06 23:07:44 -04:00
Mike Gerwitz 23557e7d5c Interface/InteropTest case assertion refactoring
This will allow multiple sub-assertions to be performed---see next commit.
2014-08-06 22:46:03 -04:00
Mike Gerwitz 78bffd9ce1
tools/mkrelease added
This is the script that is used to automate most steps of the ease.js
release process.
2014-07-28 00:50:46 -04:00
Mike Gerwitz f53c180d65
`clean` target now cleans version file 2014-07-28 00:08:06 -04:00
Mike Gerwitz 1484806456
Documentation for `super` method reference 2014-07-28 00:00:58 -04:00
Mike Gerwitz c2507356a6
.gitignore maintinance 2014-07-27 23:30:45 -04:00
Mike Gerwitz f319fed071 Missing /doc/Makefile{,.in} ignore added 2014-07-27 23:30:32 -04:00
Mike Gerwitz e0faa2ed78 Missing /version ignore added
configure-generated
2014-07-27 23:29:48 -04:00
Mike Gerwitz f1eedb81be Now using absolute (relative to repo root) paths in .gitignore 2014-07-27 23:29:16 -04:00
Mike Gerwitz 03438e0896
Parameterized traits
An in-depth description is provided by the commit message of 3fc0f90.
2014-07-27 23:27:18 -04:00
Mike Gerwitz e934338b41 Subtype ctor guarantees with parent __mixin or __construct
A solution for this problem took a disproportionally large amount of time,
attempting many different approaches, and arriving still at a kluge; this is
indicative of a larger issue---we've long since breached the comfort of the
original design, and drastic refactoring is needed.

I have ideas for this, and have already started in another branch, but I
cannot but this implementation off any longer while waiting for it.

Sorry for anyone waiting on the next release: this is what held it up, in
combination with my attention being directed elsewhere during that time (see
the sparse commit timestamps). Including this ordering guarantee is very
important for a stable, well-designed [trait] system.
2014-07-27 01:54:30 -04:00
Mike Gerwitz 90a32a104f __construct and __mixin ordering guarantees
See test cases for rationale.

I'm not satisfied with this implementation, but the current state of ease.js
makes this kind of thing awkward. Will revisit at some point.
2014-07-27 01:54:30 -04:00
Mike Gerwitz f3cb815baa Sibling traits will each have __mixin called distinctly 2014-07-27 01:54:30 -04:00
Mike Gerwitz 2204ff6d28 Parameterized traits may now be mixed in without configuration
Rationale is available in the test case.
2014-07-27 01:54:30 -04:00
Mike Gerwitz 3fc0f90e01 Initial implementation of parameterized traits
This is an important feature to permit trait reuse without excessive
subtyping---composition over inheritance. For example, consider that you
have a `HttpPlainAuth` trait that adds authentication support to some
transport layer. Without parameterized traits, you have two options:

  1. Expose setters for credentials
  2. Trait closure
  3. Extend the trait (not yet supported)

The first option seems like a simple solution:

```javascript
  Transport.use( HttpPlainAuth )()
    .setUser( 'username', 'password' )
    .send( ... );
```

But we are now in the unfortunate situation that our initialization
procedure has changed. This, for one, means that authentication logic must
be added to anything that instantiates classes that mix in `HttpPlainAuth`.
We'll explore that in more detail momentarily.

More concerning with this first method is that, not only have we prohibited
immutability, but we have also made our code reliant on *invocation order*;
`setUser` must be called before `send`. What if we have other traits mixed
in that have similar conventions? Normally, this is the type of problem that
would be solved with a builder, but would we want every configurable trait
to return a new `Transport` instance? All that on top of littering the
API---what a mess!

The second option is to store configuration data outside of the Trait acting
as a closure:

```javascript
  var _user, _pass;
  function setCredentials( user, pass ) { _user = user; _pass = pass; }
  Trait( 'HttpPlainAuth', { /* use _user and _pass */ } )
```

There are a number of problems with this; the most apparent is that, in this
case, the variables `_user` and `_pass` act in place of static fields---all
instances will share that data, and if the data is modified, it will affect
all instances; you are therefore relying on external state, and mutability
is forced upon you. You are also left with an awkward `setCredentials` call
that is disjoint from `HttpPlainAuth`.

The other notable issue arises if you did want to support instance-specific
credentials. You would have to use ease.js' internal identifiers (which is
undocumented and subject to change in future versions), and would likely
accumulate garbage data as mixin instances are deallocated, since ECMAScript
does not have destructor support.

To recover from memory leaks, you could instead create a trait generator:

```javascript
  function createHttpPlainAuth( user, pass )
  {
      return Trait( { /* ... */ } );
  }
```

This uses the same closure concept, but generates new traits at runtime.
This has various implications depending on your engine, and may thwart
future ease.js optimization attempts.

The third (which will be supported in the near future) is prohibitive: we'll
add many unnecessary traits that are a nightmare to develop and maintain.

Parameterized traits are similar in spirit to option three, but without
creating new traits each call: traits now support being passed configuration
data at the time of mixin that will be passed to every new instance:

```javascript
  Transport.use( HttpPlainAuth( user, pass ) )()
    .send( ... );
```

Notice now how the authentication configuration is isolated to the actual
mixin, *prior to* instantiation; the caller performing instantiation need
not be aware of this mixin, and so the construction logic can remain wholly
generic for all `Transport` types.

It further allows for a convenient means of providing useful, reusable
exports:

```javascript
  module.exports = {
      ServerFooAuth: HttpPlainAuth( userfoo, passfoo ),
      ServerBarAuth: HttpPlainAuth( userbar, passbar ),

      ServerFooTransport: Transport.use( module.exports.ServerFooAuth ),
      // ...
  };

  var module = require( 'foo' );

  // dynamic auth
  Transport.use( foo.ServerFooAuth )().send( ... );

  // or predefined classes
  module.ServerFooTransport().send( ... );
```

Note that, in all of the above cases, the initialization logic is
unchanged---the caller does not need to be aware of any authentication
mechanism, nor should the caller care of its existence.

So how do you create parameterized traits? You need only define a `__mixin`
method:

  Trait( 'HttpPlainAuth', { __mixin: function( user, pass ) { ... } } );

The method `__mixin` will be invoked upon instantiation of the class into
which a particular configuration of `HttpPlainAuth` is mixed into; it was
named differently from `__construct` to make clear that (a) traits cannot be
instantiated and (b) the constructor cannot be overridden by traits.

A configured parameterized trait is said to be an *argument trait*; each
argument trait's configuration is discrete, as was demonstrated by
`ServerFooAuth` and `ServerBarAuth` above. Once a parameterized trait is
configured, its arguments are stored within the argument trait and those
arguments are passed, by reference, to `__mixin`. Since any mixed in trait
can have its own `__mixin` method, this permits traits to have their own
initialization logic without the need for awkward overrides or explicit
method calls.
2014-07-27 01:54:30 -04:00
Mike Gerwitz a266cfe91b
test/runner will now pass all option args to node
Importantly, this means that --debug and --debug-brk will work ;).
2014-07-27 01:53:34 -04:00