1
0
Fork 0
Commit Graph

1152 Commits (c662106e866515f438f49cf07c48157e9c7064f5)

Author SHA1 Message Date
Mike Gerwitz c662106e86
Copyright year update on classes.texi
* doc/classes.texi: Add 2016 to copyright
2016-07-15 23:43:21 -04:00
Mike Gerwitz ef5eade499
Add "Class Caveats" manual section
This will grow.

* doc/classes.texi (Class Caveats): Added with `this.__inst' documentation
2016-07-15 23:35:36 -04:00
Mike Gerwitz 30e7feefc9
Remove strong recommendation for `public' in manual
* doc/classes.texi (Defining Classes): Remove the recommendation for using
  the `public' keyword always (instead of omitting it), and the reference
  stating that it may be required in the future.  This is not the case.
2016-07-15 13:40:15 -04:00
Mike Gerwitz 86df50d1ca
Transparent Error Subtyping
Error subtyping (creating your own error types) in ECMAScript is notoriously
crude, and getting it to work intuitively is even harder.  ease.js will now
transparently handle all necessarily boilerplate when extending Error or its
subtypes.

Take, for example, the common boilerplate for creating your own Error type:

```javascript
    function ErrorSubtype( message )
    {
        var err = new Error();

        this.name         = 'ErrorSubtype';
        this.message      = message || 'Error';
        this.stack        = err.stack;
        this.lineNumber   = err.lineNumber;
        this.columnNumber = err.columnNumber;
        this.fileName     = err.fileName;
    }

    ErrorSubtype.prototype             = new Error();
    ErrorSubtype.prototype.constructor = ErrorSubtype;
```

There are a number of problems with this:

  - That's a lot of boilerplate for any type you wish to create;
  - Some of those features may not be supported by your environment
    (e.g. column numbers or stack traces);
  - The stack trace will include `ErrorSubtype` _itself_ (as the top frame);
    and
  - Consequently, the `{line,column}Number` and `fileName` will represent
    that top frame---the error constructor itself.

With ease.js, it's just like extending any other class/constructor:

```javascript
    Class( 'ErrorSubtype' )
        .extend( Error, {} );
```

More information can be found in the "Error Subtypes" section of the manual.

Happy Error hacking.  Maybe you'll actually want to create them now.
2016-07-15 00:21:55 -04:00
Mike Gerwitz a7e1d2ad70
Error constructor integration into ClassBuilder
This introduces the transparent subtyping.

* doc/classes.texi (Error Subtyping): Section added

* lib/ClassBuilder.js (ClassBuilder): Accepts ErrorCtor instance
  (build): Transparent Error subtyping

* lib/class.js: Provide ErrorCtor instance to ClassBuilder

* test/ClassBuilder/ErrorExtendTest.js: Add test case for transparent error
  subtyping
2016-07-15 00:21:06 -04:00
Mike Gerwitz d99ab2e5fb
Error constructor `after' support
* lib/ctor/ErrorCtor.js (createCtor): Add `after' parameter to be
  invoked by `__$$ector$$__' at end of function.

* test/ctor/ErrorCtorTest.js: Add respective tests.
2016-07-15 00:18:42 -04:00
Mike Gerwitz c69a42945c
Add error constructor generator
This produces the constructor used for Error subtypes.

* lib/ctor/ErrorCtor.js: Added
* test/ctor/ErrorCtorTest.js: Added
2016-07-15 00:18:37 -04:00
Mike Gerwitz 37a459a25a
Add autogen.sh
* autogen.sh: Added
2016-04-21 22:42:10 -04:00
Mike Gerwitz 30f769b919
package.json licence field update to GPL-3.0+
Apparently the SPDX license list used by NPM supports an "or later"
identifier; that's good, as this is an incredibly important distinction; I
was otherwise going to drop it and use my own custom identifier.

* package.json: License field set to GPL-3.0{=>+}
2016-04-06 19:34:00 -04:00
Mike Gerwitz 818e4a73c8
whyfreejs link in README.md 2015-12-28 00:06:04 -05:00
Mike Gerwitz 9a19ff0218
package.json license field update
This uses the newer style.  Note that the license syntax does not support a
very important part of the license---"or later"; this is actually GPLv3+.
2015-12-24 00:08:21 -05:00
Mike Gerwitz 2f3639f776
Minor build improvements 2015-12-22 23:06:27 -05:00
Mike Gerwitz 12adc9954d {default=>all} target
Latter is recognized by Automake.
2015-12-22 23:04:31 -05:00
Mike Gerwitz 7dfb288ba7 dia check via configure 2015-12-22 22:52:04 -05:00
Mike Gerwitz d4478cdcd1
distcheck target fix
`make distcheck` now works as expected (does not fail).
2015-12-22 11:45:14 -05:00
Mike Gerwitz bb1ea6c476
Makefile.am reproducibility (test cases)
This is not strictly necessary (since order-modules does it), but let's be safe.
2015-12-22 10:41:34 -05:00
Mike Gerwitz e328445e5d
configure.ac reproducibility
Remove non-determinism from filesystem.
2015-12-22 10:23:23 -05:00
Mike Gerwitz 47e6bacd8b
Re-add README
Now that the README issue with npm is resolved, I'm re-adding this; README
is standard, and really all GNU projects should have it.
2015-12-22 10:19:30 -05:00
Mike Gerwitz 3db234f9d4
Resolve potential reproducible build issues
GNU ease.js is a pretty trivial case with respect to reproducibility---not
much goes on during the build aside from concatenation and minification.
Non-determinism is essentially confined to filesystem operations, which can
be rectified by sorting using a static locale's collation sequence (which is
done here).

This does not resolve any concerns with autoconf-installed scripts (those in
tools/), or the distribution tarball file metadata.
2015-12-21 22:34:28 -05:00
Mike Gerwitz 81bb349238
Move README.md license below title
This resolves a long-standing NPM issue whereby it was not rendering the
README (instead saying that it does not exist)
2015-12-19 01:12:20 -05:00
Mike Gerwitz febb4e3e16
Ignore known bad commits in signchk
The two commits ignored here were a mistake.  Regrettable.

This commit that introduces these ignores is signed, so these ignores can be
trusted.
2015-10-26 22:52:44 -04:00
Mike Gerwitz c0a1a9bdcc
[copyright] Copyright update for recent changes 2015 2015-10-26 22:49:28 -04:00
Mike Gerwitz 3bd52122c5
Remove misplaced function annotations for defineSecureProp
Seemed like a good idea at the time, but now Closure Compiler complains.
2015-10-26 22:46:08 -04:00
Mike Gerwitz 54412f24b6 Do not attempt copy of phony `check` during dist-hook
Whoops.
2015-10-26 22:39:52 -04:00
Mike Gerwitz 8707e537ab
Fix protected mixin override for ES3 fallbacks
It's fun when you're about to make a release and find that ES3 fallback
tests are failing.  That's also what happens when you decide not to run
the combined tests until the last minute, because they usually don't fail.
2015-10-26 22:34:48 -04:00
Mike Gerwitz 903a1a135c
Prevent mixin failure on null/undefined supertype properties 2015-10-26 22:17:28 -04:00
Mike Gerwitz 172e2e2afe
Force check target on dist
This is to ensure that final tests are run after combined files are generated.
2015-10-25 23:22:42 -04:00
Mike Gerwitz ab8cdfa173
Remove deleted README files from dist
Replace with their equivalents.
2015-10-25 22:54:45 -04:00
Mike Gerwitz bd3aa85645
Support for trait class supertype method overrides
See the specific commit for more information as part of the commit message.
2015-10-25 22:44:50 -04:00
Mike Gerwitz 47d51fd5da
Provide useful error on attempt to mix in non-trait
Before this change, mixin attempts would fail at the time of mixin when
easejs attempts to invoke the `__mixin` method on the object.  This is both
cryptic and void of any useful information on the stack.
2015-10-25 22:15:34 -04:00
Mike Gerwitz d9b86c1544
Support for trait class supertype overrides
Traits can now override methods of their class supertypes.  Previously, in
order to override a method of some class `C` by mixing in some trait `T`,
both had to implement a common interface.  This had two notable downsides:

  1. A trait that was only compatible with details of `C` could only work
     with `C#M` if it implemented an interface `I` that declared `I#M`.
     This required the author of `C` to create interfaces where they would
     otherwise not be necessary.

  2. As a corollary of #1---since methods of interfaces must be public, it
     was not possible for `T` to override any protected method of `C`; this
     meant that `C` would have to declare such methods public, which may
     break encapsulation or expose unnecessary concerns to the outside
     world.

Until documentation is available---hopefully in the near future---the test
cases provide detailed documentation of the behavior.  Stackable traits work
as you would expect:

```javascript
var C = Class(
{
    'virtual foo': function()
    {
        return 'C';
    },
} );

var T1 = Trait.extend( C,
{
    'virtual abstract override foo': function()
    {
        return 'T1' + this.__super();
    },
} );

var T2 = Trait.extend( C,
{
    'virtual abstract override foo': function()
    {
        return 'T2' + this.__super();
    },
} );

C.use( T1 )
    .use( T1 )
    .use( T2 )
    .use( T2 )
    .foo();
// result: "T2T2T1T1C"
```

If the `override` keyword is used without `abstract`, then the super method
is statically bound to the supertype, rather than being resolved at runtime:

```javascript
var C = Class(
{
    'virtual foo': function()
    {
        return 'C';
    },
} );

var T1 = Trait.extend( C,
{
    'virtual abstract override foo': function()
    {
        return 'T1' + this.__super();
    },
} );

var T2 = Trait.extend( C,
{
    // static override
    'virtual override foo': function()
    {
        return 'T2' + this.__super();
    },
} );

C.use( T1 )
    .use( T1 )
    .use( T2 )
    .use( T2 )
    .foo();
// result: "T2C"
```

This latter form should be discouraged in most circumstances (as it prevents
stackable traits), but the behavior is consistent with the rest of the
system.

Happy hacking.
2015-10-24 23:53:23 -04:00
Mike Gerwitz 02e8b796ee
Documentation compatibility with Texinfo 5.2
I upgraded Texinfo recently and found that ease.js' documentation would no
longer compile.  The errors make sense, but it's an unfortunate regression.
The previous version that I was using was 4.13, which is quite old.
2015-10-17 00:11:28 -04:00
Mike Gerwitz 50500ed290
ES6-style constructor documentation
Shame on me for not including this in the previous merge!
2015-09-16 00:39:26 -04:00
Mike Gerwitz 0e26f9fd0f Strip `public` keyword from __construct in docs
It must be public, so by convention, I don't include it anymore.  But this
is personal preference.
2015-09-16 00:38:04 -04:00
Mike Gerwitz 90aa74d0cb ES6-style constructor added to documentation 2015-09-16 00:37:24 -04:00
Mike Gerwitz cbf98cccf1
ES6-style constructors
Included with this change is a simple "wrapper" implementation:

```
// equivalent
easejs( Foo );
Class.extend( Foo, {} );
```
2015-09-16 00:15:50 -04:00
Mike Gerwitz d3f1f0dee2 Add test to ensure multiple constructors cannot be defined 2015-09-16 00:02:02 -04:00
Mike Gerwitz ba2605f836 Alias `constructor` member to `__construct`
This allows ease.js classes to mimic the structure of ES6 classes, which use
`constructor` to denote the constructor.  This patch simply aliases it to
`__construct`, which ease.js handles as it would normally.

To that note, since the ES6 `class` keyword is purely syntatic sugar around
the prototype model, there is not much benefit to using it over ease.js if
benefits of ease.js are still desired, since the member definition syntax is
a feature of object literals:

```
// ease.js using ES6
let Person = Class(
{
    _name: '',

    // note that __construct still works as well
    constructor( name ) {
      this._name = ''+name;
    },

    sayHi() {
      return "Hi, I'm " + this.getName();
    },

    // keywords still work as expected
    'protected getName'() {
      return this._name;
    }
} );

// ES6 using `class` keyword
class Person
{
    // note that ES6 will _not_ make this private
    _name: '',

    constructor( name ) {
      this._name = ''+name;
    },

    sayHi() {
      return "Hi, I'm " + this.getName();
    }

    // keywords unsupported (you'd have to use Symbols)
    getName() {
      return this._name;
    }
}

// ES3/5 ease.js
var Person = Class(
{
    _name: '',

    __construct: function( name ) {
      this._name = ''+name;
    },

    sayHi: function() {
      return "Hi, I'm " + this._name;
    },

    'protected getName': function() {
      return this._name;
    }
} );
```

As you can see, the only change between writing ES6-style method definitions
is the syntax; all keywords and other features continue to work as expected.
2015-09-16 00:02:00 -04:00
Mike Gerwitz a931796bdf Prototype wrapping using index function
This redefines the index as a function (rather than a vanilla object) so
that it may be invoked to yield an ease.js Class that wraps the given
prototype.
2015-09-09 23:36:14 -04:00
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