1
0
Fork 0
Commit Graph

1065 Commits (c3b50bdc54f1d4243de0c7284819cf6026a70414)

Author SHA1 Message Date
Mike Gerwitz c3b50bdc54 Removed ProtoField#getDatum
This is not necessary in practice: not only does it break encapsulation, but
it muddies the point of ProtoField---to produce a class prototype.

Yes, decomposition back into a ProtoField type allows for analysis of that
datum, in principle; and that will be the case for certain data (contained
within the opaque compiled datum). But in the case of ProtoField, we do not
need to expose the original datum. Ever.
2014-07-24 02:07:14 -04:00
Mike Gerwitz bfb6e7068a Initial ProtoField implementation 2014-07-24 01:54:15 -04:00
Mike Gerwitz afb0a09784
Test case now allows for short-hand require of SUT 2014-07-24 01:11:55 -04:00
Mike Gerwitz 1458d79ee1
Began encapsulating internal metadata with symbols
This is a move to solve a couple issues:
  - We shouldn't be adding a ton of non-enumerable stuff to an object---
    defineProperty is slow; and
  - One object containing all internal data (at least in general; more on
    that later) makes ignoring it, copying it, or otherwise operating upon
    it a much easier and cleaner task.
2014-07-09 23:55:20 -04:00
Mike Gerwitz d400a4cbb1 FallbackSymbol now returns instance of self
Existing functionality is maintained using toString. This is necessary to
support type checking, and to be more consistent with the native Symbol
implementation.

Technically `new FallbackSymbol` is supposed to throw a TypeError, just as
`new Symbol` would, but doing so complicates the constructor unncessarily,
so I am not going to bother with that here.
2014-07-09 23:50:36 -04:00
Mike Gerwitz 07c0a974af FIXME added for possibly leaking private symbol during tctor call
This is a security-related issue: we want to ensure that the user cannot,
without debugging tools, retrieve certain internal details that may be used
to compromise an implementation.
2014-07-09 00:14:25 -04:00
Mike Gerwitz 031489a07b Private symbol key is now non-enumerable
This will, at least in ES5 environments, prevent its general discovery and
[accidental] use. Of course, any decent debugger will still be able to see
it, so unless ES6 is used, this is not truely hidden.
2014-07-09 00:14:25 -04:00
Mike Gerwitz 072fef2dc0 createMeta no longer copying to new_class.prototype
I do not wholly recall why this was done initially (nor do I care to
research it, since it's not necessary now), but from the looks of it, it was
likely a kluge to handle a poor implementation of some feature.

This will help clean up a little, since it's rude to pollute a prototype
unnecessarily.
2014-07-09 00:14:25 -04:00
Mike Gerwitz 17d11c1832 Re-encapsulated ClassBuilder private symbol
Temporary method removed and symbol now provided directly to the trait ctor;
this is needed to retrieve the protected visibility object; there is
currently no API for doing so, and there may never be (providing an API for
such a thing seems questionable).

Of course, if we eventually want to decouple the trait implementation from
ClassBuilder (which would be a good idea), we'll have to figure out
something.
2014-07-09 00:14:25 -04:00
Mike Gerwitz 13b0bd2fb3 Visibility object is now encapsulated in symbol key
Note that this patch temporarily breaks encapsulation via
ClassBuilder.___$$privsym$$ to expose necessary internal details to Trait;
this will be resolved.
2014-07-09 00:14:25 -04:00
Mike Gerwitz a35a9c6ed3 Class ___$$meta$$ moved into private symbol field 2014-07-09 00:14:25 -04:00
Mike Gerwitz e0866db313 Corrected MemberBuilderValidator warning handler in class.js 2014-07-09 00:14:25 -04:00
Mike Gerwitz 5212515d99 ClassBuilder#build now only making one getMeta call 2014-07-09 00:14:24 -04:00
Mike Gerwitz c49a6d70de util/Symbol added 2014-07-09 00:14:24 -04:00
Mike Gerwitz 2f615fbe68 FallbackSymbol added
This is the closest we will get to implementing a concept similar to symbols
in pre-ES6. The intent is that, in an ES5 environment, the caller should
ensure that the object receiving this key will mark it as non-enumerable.
Otherwise, we're out of luck.

The symbol string is pseduo-randomly generated with an attempt to reduce the
likelihood of field collisions and malicious Math.{floor,random} overwrites
(so long as they are clean at the time of loading the module).
2014-07-09 00:14:24 -04:00
Mike Gerwitz 913a497492 Combine script now handles relative includes in subdirectories
This is a bit of a kluge, specific to our scenerio, but it works.
2014-07-09 00:14:24 -04:00
Mike Gerwitz ad5291eb8d Corrected tools/combine to handle relative require paths 2014-07-07 23:50:43 -04:00
Mike Gerwitz 4e3d609b01 Extracted warning handlers into their own prototypes 2014-06-11 23:42:20 -04:00
Mike Gerwitz de33a7c964 Extracted Warning into warn/Warning
Test case moved to reflect the path change.
2014-06-11 23:08:52 -04:00
Mike Gerwitz 1bba35418a Added Global prototype
This will clean up the code for providing global check and alternatives.
2014-06-11 23:08:48 -04:00
Mike Gerwitz 9a22648fd9
Dynamically generating version string 2014-06-11 22:32:36 -04:00
Mike Gerwitz 8558d90596 Forcing version regen on combine if in git repo
This will re-run `autoconf` if it is detected that the user is within the
git repository, which will force `configure` to be regenerated; this is
necessary, since `configure.ac` contains the version macros.
2014-06-11 22:26:53 -04:00
Mike Gerwitz 013da59d7f AC_INIT e-mail changed to bug-easejs@gnu.org 2014-06-11 21:55:53 -04:00
Mike Gerwitz e3938aa814
Closure compiler --language_in=ECMASCRIPT5_STRICT
This not only resolves the error triggered by the use of `super`, but also
is more proper, since that is what ease.js is being developed for; I handle
all ES3 fallback considerations myself.

Note that the build will now produce warnings, but the lines producing them
will be removed shortly in favor of a new API.
2014-06-08 23:32:52 -04:00
Mike Gerwitz 869e0cbfc5 Makefile will now write version file on dist 2014-06-08 02:00:17 -04:00
Mike Gerwitz 0f2eb10f83 Version string now dynamically generated
This was motivated by Git itself, which uses `git describe` output to
generate the version number relative to the last tag. The format of it fits
fairly cleanly into the existing ease.js versioning scheme, but the m4
macro had to modified slightly to handle additional dashes.
2014-06-08 01:00:30 -04:00
Mike Gerwitz 2391224477
Warning tests no longer fail in pre-ES5 env emulation
Strict mode fails on `typeof` for undefined variables, which was used
outside of strict mode for exactly the purpose of checking for undefined
variables! This check will work in either case.
2014-06-03 23:47:22 -04:00
Mike Gerwitz 887d5ef0a3 GNU ease.js and test cases now compile in strict mode
During its initial development, no environments (e.g. Node.js, Chromium,
Firefox) supported strict mode; this has since changed, and node has a
--use-strict option, which is used in the test runner to ensure conformance.
2014-05-04 22:17:28 -04:00
Mike Gerwitz ff4b9c856b
Corrrected virtual non-overridden trait methods
See the introduced test cases for great detail; there was a problem with the
implementation where only the public API of the abstract trait object was
being checked, meaning that protected virtual methods were not found when
peforming the call. This was not a problem on override, because that proxies
to the protected member object (PMO), which includes protected members.
2014-05-02 21:30:27 -04:00
Mike Gerwitz 1b9317de62
Super method now provided on method override wrapper
This allows invoking any arbitrary method of a supertype. This is needed,
for example, if some method `foo` is overridden, but we wish to call the
parent `foo` in another method; this is not possible with __super:

  var C = Class(
  {
      'virtual foo': function() { return 'super'; }
  } );

  var SubC = C.extend(
  {
      'override foo': function() { return 'sub'; },

      superfoo: function() { return this.foo.super.call( this ); }
  } );

  SubC().superfoo();  // 'super'

Obviously, __super would not work here because any call to __super within
SubC#superfoo would try to invoke C@superfoo, which does not exist.
2014-05-02 21:27:03 -04:00
Mike Gerwitz 8ab183f4c8 Setting super method on override wrapper 2014-05-02 21:26:49 -04:00
Mike Gerwitz 779dbc37bc Corrected virtual non-overridden trait method invocations
What a mouthful. And nightmare, having been away from the trait
implementation for so long.
2014-05-02 21:08:41 -04:00
Mike Gerwitz 74b170d089 Moved class virtual param test into ClassVirtualTest case
VirtualTest was not the correct spot.
2014-05-02 20:13:41 -04:00
Mike Gerwitz 81ce3397ab
Corrected __length metadata on trait virtual proxies 2014-05-02 00:19:50 -04:00
Mike Gerwitz 8c95932446 Trait virtual method proxies now set __length metadata
This fixes a bug that causesd virtual definitions with parameters on classes
that a trait is mixed into to fail, and prevented proper param length
validations in the reverse case.

See test case description for a less confusing description.
2014-05-02 00:19:25 -04:00
Mike Gerwitz 21821cd9e7
Fix for subtypes of prototype subtypes
When extending a class that is a subtype of a prototype, it would clobber
___$$vis$$, yielding a useless class. See the test case for a detailed
description.
2014-04-29 10:47:24 -04:00
Mike Gerwitz 8b8a08b7dc Subtypes of prototype subtypes now work correctly 2014-04-29 10:47:12 -04:00
Mike Gerwitz ddf1d5918e
Version bump 0.2.2-dev => 0.2.2 2014-04-29 02:05:51 -04:00
Mike Gerwitz 74f53aa861
Vanilla ECMAScript interop patches
Now that ease.js is a GNU project, it has much broader reach than before.
Since its very existence is controversial, it would be wise (and polite) to
provide a means for others to integrate with libraries written using ease.js
without being forced to use ease.js themselves. Further, ease.js users
should be able to build off of the work of other libraries that do not use
ease.js.

This set of changes introduces a number of interoperability improvements,
documented in the new manual chapter ``Interoperability''. Since it is
documented in the manual, this commit message will not go into great detail;
I wish to only provide a summary.

Firstly, we now have the concept of interface compatibility; while ease.js
classes/etc must still conform to the existing interface requirements, the
rules are a bit more lax for other ECMAScript objects to permit
interoperability with type-checking ease.js code. For example:

  var I   = Interface( { foo: [ 'a' ] } ),
      obj = { foo: function( a ) {} };

  Class.isA( I, obj );  // true

This is also a powerful feature for implementing interfaces around existing
objects, as a preemptive interface check (rather than duck typing).

Prototypally extending ease.js classes is potentially problematic because
the constructor may perform argument validations (this is also an issue in
pure prototypal code). As a solution, all classes now have a static
`asPrototype` method, which defers constructor invocation, trusting that the
prototype constructor will do so itself.

Aside from a few bug fixes, there is also a more concise notation for
private members to allow prototypal developers to feel more at home when
using GNU ease.js: members prefixed with an underscore are now implicitly
private, which will satisfy the most common visibility use cases. I do
recognize that some (mostly in the Java community) use underscore *suffixes*
to denote private members, but I've noticed that this is relatively rare in
the JS community; I have therefore not included such a check, but will
consider it if many users request it.

There are many more ideas to come, but I hope that this will help to bridge
the gap between the prototypal and classical camps, allowing them to
cooperate with as little friction as possible.
2014-04-29 02:05:18 -04:00
Mike Gerwitz 2a8965f17d Added section to manual on interoperable polymorphism 2014-04-29 02:03:51 -04:00
Mike Gerwitz 8cfe231a63 Began work on interop chapter of manual 2014-04-29 02:03:51 -04:00
Mike Gerwitz fa177922b4 Class#asPrototype support
This is an interop feature: allows using ease.js classes as part of a
prototype chain.
2014-04-29 02:03:51 -04:00
Mike Gerwitz 1fe9aa2c0c Test case to protect agaist retval regressions when extending prototypes 2014-04-29 02:03:51 -04:00
Mike Gerwitz 34d84412e1 Prototype supertype property proxy fix
This was a nasty bug that I discovered when working on a project at work
probably over a year ago. I had worked around it, but ease.js was largely
stalled at the time; with it revitalized by GNU, it's finally getting fixed.

See test case comments for more information.
2014-04-29 02:03:40 -04:00
Mike Gerwitz 7f3e7fba35 Overriding vanilla prototype methods no longer errors
This is something that I've been aware of for quite some time, but never got
around to fixing; ease.js had stalled until it was revitalized by becoming a
GNU project.
2014-04-28 15:09:52 -04:00
Mike Gerwitz aa0003d239 ClassBuilder.isInstanceOf now defers to type
This allows separation of concerns and makes the type system extensible. If
the type does not implement the necessary API, it falls back to using
instanceof.
2014-04-28 15:09:52 -04:00
Mike Gerwitz 4605476b4f Added isCompatible method to interfaces
There is a great amount of rationale in the test case added in this commit.
2014-04-28 15:09:52 -04:00
Mike Gerwitz 034876ae3b
Trait API now exposed in combined source files
I missed this in the 0.2.0 release and did not notice in code I've been
writing using traits because the test cases are executed by Node. Sorry to
anyone who may have had trouble client-side.
2014-04-28 15:06:52 -04:00
Mike Gerwitz 8b50f78d55 Exposing Trait in combined source files 2014-04-28 14:32:18 -04:00
Mike Gerwitz 597ac2d7d9
Version bump 0.2.2-dev
Whoops! Meant to do this a lot sooner.
2014-04-26 00:55:18 -04:00