1
0
Fork 0
Commit Graph

429 Commits (8d81373ef8e85ef4cf1387ecb6c44890afad1185)

Author SHA1 Message Date
Mike Gerwitz 8d81373ef8 Began named trait implementation
Does not yet support staging object like classes
2014-03-15 21:16:27 -04:00
Mike Gerwitz 26bd6b88dd Named classes now support mixins 2014-03-15 21:16:27 -04:00
Mike Gerwitz 455d3a5815 Added immediate partial class invocation support after mixin 2014-03-15 21:16:27 -04:00
Mike Gerwitz 897a4afab4 Added support for mixing in traits using use method on a base class 2014-03-15 21:16:27 -04:00
Mike Gerwitz 999c10c3bf Subtype mixin support 2014-03-15 21:16:27 -04:00
Mike Gerwitz 451ec48a5c Objects are now considered types of class's mixed in traits
This is a consequence of ease.js' careful trait implementation that ensures
that any mixed in trait retains its API in the same manner that interfaces
and supertypes do.
2014-03-15 21:16:27 -04:00
Mike Gerwitz bcada87240 [bug fix] Corrected bug with implicit visibility escalation
See test case comments for details. This wasted way too much of my time.
2014-03-15 21:16:26 -04:00
Mike Gerwitz 5047d895c0 Moved closure out of getMemberVisibility
This was defining a function on every call for no particular reason other
than being lazy, it seems.

Performance poopoo.
2014-03-15 21:16:26 -04:00
Mike Gerwitz 66cab74cc1 Initial trait virtual member proxy implementation
This has some flaws that should be addressed, but those will be detailed in
later commits; this works for now.
2014-03-15 21:16:26 -04:00
Mike Gerwitz 3c7cd0e57a Added virtual members to class metadata
There does not seem to be tests for any of the metadata at present; they are
implicitly tested through various implementations that make use of them.
This will also be the case here ("will"---in coming commits), but needs to
change.

The upcoming reflection implementation would be an excellent time to do so.
2014-03-15 21:16:26 -04:00
Mike Gerwitz a0a5c61631 Simplified ClassBuilder.buildMembers params
This cuts down on the excessive parameter length and opens up room for
additional metadata generation. Some slight foreshadowing here.
2014-03-15 21:16:26 -04:00
Mike Gerwitz b7a314753a Began implementing virtual trait methods
These require special treatment with proxying.
2014-03-15 21:16:26 -04:00
Mike Gerwitz 40e287bfc3 Warning no longer issued when overriding weak method appearing later in dfn obj 2014-03-15 21:16:26 -04:00
Mike Gerwitz 1b323ed80b Validation warnings now stored in state object
This will allow for additional processing before actually triggering the
warnings. For the sake of this commit, though, we just keep with existing
functionality.
2014-03-15 21:16:26 -04:00
Mike Gerwitz dac4b9b3a1 The `weak' keyword can now apply to overrides
Well, technically anything, but we're leaving that behavior as undefined for
now (the documentation will say the same thing).
2014-03-07 00:47:43 -05:00
Mike Gerwitz b04a8473b8 Implemented abstract traits
This is just an initial implementation, so there may be some quirks; there
are more tests to come.
2014-03-07 00:47:43 -05:00
Mike Gerwitz 987a2b88ec Classes can now access trait protected members
Slight oversight in the original commit.
2014-03-07 00:47:43 -05:00
Mike Gerwitz c10fe5e248 Proxy methods may now override abstract methods
The method for doing so is a kluge; see the test case for more info.
2014-03-07 00:47:43 -05:00
Mike Gerwitz 548c38503f Added support for weak abstract methods
This adds the `weak' keyword and permits abstract method definitions to
appear in the same definition object as the concrete implementation. This
should never be used with hand-written code---it is intended for code
generators (e.g. traits) that do not know if a concrete implementation will
be provided, and would waste cycles duplicating the property parsing that
ease.js will already be doing. It also allows for more concise code
generator code.
2014-03-07 00:47:43 -05:00
Mike Gerwitz 18ac37c871 Added support for `weak' keyword
Note that, even though it's permitted, the validator still needs to be
modified to permit useful cases. In particular, I need weak abstract and
strong concrete methods for use in traits.
2014-03-07 00:47:43 -05:00
Mike Gerwitz 00c76c69df Trait concrete class will now be lazily created on first use
This just saves some time and memory in the event that the trait is never
actually used, which may be the case in libraries or dynamically loaded
modules.
2014-03-07 00:47:43 -05:00
Mike Gerwitz e44ac3190b Protected trait methods are now mixed in 2014-03-07 00:47:43 -05:00
Mike Gerwitz 3724b1bc0d Re-implemented mixin error for member name conflicts 2014-03-07 00:47:43 -05:00
Mike Gerwitz 71358eab59 Began implementing composition-based traits
As described in <https://savannah.gnu.org/task/index.php#comment3>.

The benefit of this approach over definition object merging is primarily
simplicitly---we're re-using much of the existing system. We may provide
more tight integration eventually for performance reasons (this is a
proof-of-concept), but this is an interesting start.

This also allows us to study and reason about traits by building off of
existing knowledge of composition; the documentation will make mention of
this to explain design considerations and issues of tight coupling
introduced by mixing in of traits.
2014-03-07 00:47:42 -05:00
Mike Gerwitz dfc83032d7 Basic, incomplete, but workable traits
Note the incomplete tests. These are very important, but the current state
at least demonstrates conceptually how this will work (and is even useful in
its current state, albeit dangerous and far from ready for production).
2014-03-07 00:47:42 -05:00
Mike Gerwitz 62035a0b4c Beginning of Trait and Class.use
This is a rough concept showing how traits will be used at definition time
by classes (note that this does not yet address how they will be ``mixed
in'' at the time of instantiation).
2014-03-07 00:47:42 -05:00
Mike Gerwitz 7f8d265877
Corrected override of super-super methods
More generally, this was a problem with not recursing on *all* of the
visibility objects of the supertype's supertype; the public visibility
object was implicitly recursed upon through JavaScript's natural prototype
chain, so this only manifested itself with protected members.
2014-02-24 23:03:04 -05:00
Mike Gerwitz 89f00e0cdd [copyright] Copyright update 2014-01-20 22:55:29 -05:00
Mike Gerwitz 086ede6849 Moved test-util-define-secure-prop into suite as Util/DefineSecurePropTest 2014-01-20 22:14:42 -05:00
Mike Gerwitz 16d0641f46 prop_parse no longer scans the string twice
The performance impact is negligable in either case.
2014-01-20 22:14:42 -05:00
Mike Gerwitz 537ca0d694 Removed confusing modification warning from version.js.in
Sure, that is in the output, but it's also in the input!
2014-01-17 01:13:36 -05:00
Mike Gerwitz 97fbbd5bb9 [no-copyright] Modified headers to reduce GPL license notice width 2014-01-15 23:56:00 -05:00
Mike Gerwitz e03454b2b9 Corrected new Closure Compiler warnings 2014-01-06 22:05:05 -05:00
Mike Gerwitz 8b83add95f ease.js is now GNU ease.js.
On Sun, Dec 22, 2013 at 03:31:08AM -0500, Richard Stallman wrote:
> I hereby dub ease.js a GNU package, and you its maintainer.
>
> Please don't forget to mention prominently in the README file and
> other suitable documentation places that it is a GNU program.
2013-12-23 00:27:18 -05:00
Mike Gerwitz 26dffce00a [copyright] Copyright update after adding --follow to copyright script 2013-12-22 22:50:29 -05:00
Brandon Invergo 79109304cc Version splitting for configure.ac
Thanks again to Brandon Inverson for providing this patch. All changes are his
except for the comment in configure.ac and the version.js.tpl move/changes.

Copyright-paperwork-exempt: Yes
2013-12-22 22:50:24 -05:00
Mike Gerwitz 13ca9cd852
[copyright] Copyright update after relicensing 2013-12-20 01:11:39 -05:00
Mike Gerwitz 9050c4e4ac
Relicensed under the GPLv3+
This project was originally LGPLv+-licensed to encourage its use in a community
that is largely copyleft-phobic. After further reflection, that was a mistake,
as adoption is not the important factor here---software freedom is.

When submitting ease.js to the GNU project, it was asked if I would be willing
to relicense it under the GPLv3+; I agreed happily, because there is no reason
why we should provide proprietary software any sort of edge. Indeed, proprietary
JavaScript is a huge problem since it is automatically downloaded on the user's
PC generally without them even knowing, and is a current focus for the FSF. As
such, to remain firm in our stance against proprietary JavaScript, relicensing
made the most sense for GNU.

This is likely to upset current users of ease.js. I am not sure of their
number---I have only seen download counts periodically on npmjs.org---but I know
there are at least a small number. These users are free to continue using the
previous LGPL'd releases, but with the understanding that there will be no
further maintenance (not even bug fixes). If possible, users should use the
GPL-licensed versions and release their software as free software.

Here comes GNU ease.js.
2013-12-20 01:10:05 -05:00
Mike Gerwitz 2a76be2461
[copyright] Copyright update 2013-12-20 00:50:54 -05:00
Mike Gerwitz daae0c6843
Corrected bug whereby multiple override calls would clear __super too early
Before this change, __super was set to undefined. However, consider that we have two
method overrides---foo and bar---and the code for bar is:

  this.foo();
  this.__super();

foo() would set __super to undefined and so bar cannot invoke its super method
unless it stores a reference to __super before invoking foo(). This patch fixes
this issue.
2013-04-20 21:55:40 -04:00
Mike Gerwitz ae172a7a34
Corrected missing whitespace on interface instantiation error message 2013-04-13 12:34:52 -04:00
Mike Gerwitz b4fe08292f
'this' now properly binds to the private member object of the instance for getters/setters
Getters/setters did not get much attention during the initial development of
ease.js, simply because there was such a strong focus on pre-ES5
compatibility---ease.js was created for a project that strongly required it.
Given that, getters/setters were not used, since those are ES5 features. As
such, I find that two things have happened:

  1. There was little incentive to provide a proper implementation; even though
     I noticed the issues during the initial development, they were left
     unresolved and were then forgotten about as the project lay dormant for a
     while.
  2. The project was dormant because it was working as intended (sure, there
     are still things on the TODO-list feature-wise). Since getters/setters were
     unused in the project for which ease.js was created, the bug was never
     found and so never addressed.

That said, I now am using getters/setters in a project with ease.js and noticed
a very odd bug that could not be explained by that project's implementation.
Sure enough, it was an ease.js issue and this commit resolves it.

Now, there is more to be said about this commit. Mainly, it should be noted that
MemberBuilder.buildGetterSetter, when compared with its method counterpart
(buildMethod) is incomplete---it does not properly address overrides, the
abstract keyword, proxies or the possibility of method hiding. This is certainly
something that I will get to, but I want to get this fix out as soon as I can.
Since overriding ES5 getters/setters (rather than explicit methods) is more
likely to be a rarity, and since a partial fix is better than no fix, this will
likely be tagged immediately and a further fix will follow in the (hopefully
near) future.

(This is an interesting example of how glaring bugs manage to slip through the
cracks, even when the developer is initially aware of them.)
2013-01-19 22:38:35 -05:00
Mike Gerwitz 8b74ed9f1b
Corrected a bug whereby getters were being inadvertently invoked by util.propParse()
Nasty; hopefully this was found before it did any harm to anyone else! This bug was discovered accidentally while I was debugging a separate issue.
2013-01-19 22:38:31 -05:00
Mike Gerwitz 02e22e64b9
Corrected warning console output invocation 2013-01-19 22:38:26 -05:00
Mike Gerwitz e67c14e8c3
Added support for static proxy methods
When the static keyword is provided, the proxy will use the static accessor
method to look up the requested member.
2012-05-03 14:13:47 -04:00
Mike Gerwitz d84b86b21b
Added `proxy' keyword support
The concept of proxy methods will become an important, core concept in ease.js
that will provide strong benefits for creating decorators and proxies, removing
boilerplate code and providing useful metadata to the system. Consider the
following example:

  Class( 'Foo',
  {
      // ...

      'public performOperation': function( bar )
      {
          this._doSomethingWith( bar );
          return this;
      },
  } );

  Class( 'FooDecorator',
  {
      'private _foo': null,

      // ...

      'public performOperation': function( bar )
      {
          return this._foo.performOperation( bar );
      },
  } );

In the above example, `FooDecorator` is a decorator for `Foo`. Assume that the
`getValueOf()` method is undecorated and simply needs to be proxied to its
component --- an instance of `Foo`. (It is not uncommon that a decorator, proxy,
or related class will alter certain functionality while leaving much of it
unchanged.) In order to do so, we can use this generic, boilerplate code

  return this.obj.func.apply( this.obj, arguments );

which would need to be repeated again and again for *each method that needs to
be proxied*. We also have another problem --- `Foo.getValueOf()` returns
*itself*, which `FooDecorator` *also* returns.  This breaks encapsulation, so we
instead need to return ourself:

  'public performOperation': function( bar )
  {
      this._foo.performOperation( bar );
      return this;
  },

Our boilerplate code then becomes:

  var ret = this.obj.func.apply( this.obj, arguments );
  return ( ret === this.obj )
      ? this
      : ret;

Alternatively, we could use the `proxy' keyword:

  Class( 'FooDecorator2',
  {
      'private _foo': null,

      // ...

      'public proxy performOperation': '_foo',
  } );

`FooDecorator2.getValueOf()` and `FooDecorator.getValueOf()` both perform the
exact same task --- proxy the entire call to another object and return its
result, unless the result is the component, in which case the decorator itself
is returned.

Proxies, as of this commit, accomplish the following:
  - All arguments are forwarded to the destination
  - The return value is forwarded to the caller
    - If the destination returns a reference to itself, it will be replaced with
      a reference to the caller's context (`this`).
  - If the call is expected to fail, either because the destination is not an
    object or because the requested method is not a function, a useful error
    will be immediately thrown (rather than the potentially cryptic one that
    would otherwise result, requiring analysis of the stack trace).

N.B. As of this commit, static proxies do not yet function properly.
2012-05-03 09:49:22 -04:00
Mike Gerwitz bc44bfd8e9 Set version to 0.2.0-dev 2012-03-05 22:55:14 -05:00
Mike Gerwitz fa9dbcbf2e [Fix #37] constructor property now properly set on instances 2012-01-19 23:21:04 -05:00
Mike Gerwitz 9dbd0d1fb3 Added constructor property to reserved members list 2012-01-17 23:36:01 -05:00
Mike Gerwitz 958521f673 Created version module to provide additional version information 2011-12-23 18:31:11 -05:00