1
0
Fork 0
Commit Graph

7 Commits (4b14813340fb602c185194cb1963642c8d4ed99d)

Author SHA1 Message Date
Mike Gerwitz 016bb1362b
Copyright year update for all files modified since 0.2.8
* lib/MemberBuilderValidator.js: Updated copyright year.
* lib/class.js: Updated copyright year.
* test/Class/ConstructorTest.js: Updated copyright year.
* test/Class/ExtendTest.js: Updated copyright year.
* test/Class/GeneralTest.js: Updated copyright year.
* test/MemberBuilderValidator/MethodTest.js: Updated copyright year.
* test/Trait/LinearizationTest.js: Updated copyright year.
* test/Trait/VirtualTest.js: Updated copyright year.
2017-11-04 15:08:02 -04: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 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 82a02c0081 [copyright] Copyright assignment to the FSF
Thanks to Donald Robertson III for his help and guidance during this
process.
2014-04-09 19:05:07 -04:00
Mike Gerwitz 89f00e0cdd [copyright] Copyright update 2014-01-20 22:55:29 -05:00
Mike Gerwitz ee886f2d37 Moved test-class-constructor into suite as Class/ConstructorTest
Also removed assertions that are performed elsewhere.

We broke onto the fifth line in the suite ;)
2014-01-20 22:14:42 -05:00