1
0
Fork 0
Commit Graph

1169 Commits (ab4874e2856849462f79ac61a7a1cf84b65c6b50)

Author SHA1 Message Date
Mike Gerwitz ab4874e285
Add constructor reference caveat to manual
* doc/classes.texi: Add caveat for referencing the constructor when using
  ES6-style naming.
2017-01-02 23:38:48 -05:00
Mike Gerwitz b841b9cc5e
Fix trait extending of supertype with constructor
Supertypes that extend constructors may now be extended by traits without
completely blowing up.  Good feature.

* lib/Trait.js (__tconstruct): Add function.
  (createVirtProxy): Use it.

* test/Trait/ClassExtendTest.js: Add test.
2017-01-02 23:34:29 -05:00
Mike Gerwitz 92c57c8ffe
Constructor virtual by default
* lib/ClassBuilder.js (_keywordParser): Make __construct virtual.
* test/Class/ConstructorTest.js: Add test.

* doc/classes.texi (Constructors): Update documentation.
2017-01-02 23:30:33 -05:00
Mike Gerwitz e39ff83b40
Rework constructor section in manual
My writing style has changed quite a bit since this was first written.

* doc/classes.text (Constructors):
  Reword section.
  Remove reference to static classes and singletons (we do not want to
    encourage such things).
  Add mention of good constructor practices.
2017-01-02 22:34:43 -05:00
Mike Gerwitz 35dacc00da Minor cleanup to trait naming test
test/Trait/NamedTest.js: Cleanup interface-related naming test.
2016-12-29 03:50:09 -05:00
Mike Gerwitz e93f3a70f9 Support for named trait class extending
We can call this a bugfix...it's more of a neglected feature that's
otherwise completely inconsistent with the rest of the system. :)

* lib/Trait.js (createNamedTrait): Support base.
  (_createStaging) [extend]: Support base.

* test/Trait/NamedTest.js: Add test.
2016-12-29 03:49:47 -05:00
Mike Gerwitz 017b85d75b
Copyright year updates for recent trait changes
* lib/Trait.js: Add Copyright year 2016.
* test/Trait/ContextTest.js: Add Copyright year 2016.
2016-12-29 03:11:49 -05:00
Mike Gerwitz 54b0c79fed
Rename Trait/{Scope=>Context}Test
This better reflects its focus.

* test/Trait/ScopeTest.js: Rename file (delete).
* test/Trait/ContextTest.js: Rename file (create).
2016-12-29 02:39:26 -05:00
Mike Gerwitz 04e98e682e
Correct trait->class calling context on class supertype
See test cases for more information.  This was a pretty unfortunate and
nasty bug that I discovered while working on a project that uses easejs; it
wasn't something that was found previously because this support was only
added relatively recently, and this problem does not exist if an interface
is used.

* lib/Trait.js (bindSuperCtx): Add function.
  (tctor): Use it.

* test/Trait/ScopeTest.js: Add calling context tests.
2016-12-29 02:39:16 -05:00
Mike Gerwitz 748ceaf0bf
Fix silly mix{o=e}r typo in Trait
* lib/Trait.js (_validateMixin): Change docblock and error message to
    resolve typo.
2016-12-28 03:07:29 -05:00
Mike Gerwitz 5130e41641
Add missing INSTALL
Autoconf generates INSTALL boilerplate, so I had added it to .gitignore in
the past.  Unfortunately, I do include my own INSTALL file, which is present
in the distribution, but has never been committed to the repo!

Thanks to Stefan Schweter for pointing this out to me.

* INSTALL: Added.
* .gitignore (/INSTALL): Removed.
2016-10-14 22:33:57 -04:00
Mike Gerwitz 53320e84a1
Fail mkrelease on npm publish failure
* tools/mkrelease: exit on failed `npm publish'
2016-07-21 01:24:45 -04:00
Mike Gerwitz 705f092eb0
Shorten combined min license header
* tools/license-min.tpl: Shorten software URL;
  use HTTPS; and use range for copyright years
2016-07-21 01:24:00 -04:00
Mike Gerwitz 07962af3af
Copyright year updates for combined files
* tools/*.tpl: Add 2015, 2016 to copyright years
2016-07-21 01:22:38 -04:00
Mike Gerwitz 04b620192d
Correct variable name in combined header
Clearly a bad case of search/replace.

* tools/combine.tpl: {util=>easejs}
2016-07-21 01:19:49 -04:00
Mike Gerwitz 18b2c13f7b
Update copyright years on main Texinfo manual page
* doc/easejs.texi: Add 201{5,6} to copyright years
2016-07-16 00:27:06 -04:00
Mike Gerwitz 9431efacfe
Add "Transparent error subtyping" to README
This also reorganized the list to match the website

* README.md: Added "Transparent error subtyping".
  Reordered list.
2016-07-16 00:01:09 -04:00
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