diff --git a/src/core/Base.js b/src/core/Base.js index b250abc3..3750e44d 100644 --- a/src/core/Base.js +++ b/src/core/Base.js @@ -82,7 +82,7 @@ Base.inject(/** @lends Base# */{ // Keep track of all named classes for serialization and exporting. // Also register the Base class itself. - exports: { 'Base': Base }, + exports: new Base({ Base: Base }), extend: function extend(src) { // Override Base.extend() to register named classes in Base.exports, diff --git a/src/core/PaperScript.js b/src/core/PaperScript.js index 081c0f74..2e362cf9 100644 --- a/src/core/PaperScript.js +++ b/src/core/PaperScript.js @@ -21,7 +21,7 @@ /*#*/ include('../../lib/esprima-min.js'); /*#*/ } -var PaperScript = Base.exports.PaperScript = new function() { +var PaperScript = new function() { // Operators to overload var binaryOperators = { diff --git a/src/export.js b/src/export.js index de611e34..d18df8bc 100644 --- a/src/export.js +++ b/src/export.js @@ -10,5 +10,9 @@ * All rights reserved. */ -// Export all named classes to PaperScope and create the initial paper object. -var paper = new (PaperScope.inject(Base.exports))(); +// Add PaperScript and Numerical to exports, inject all exports into PaperScope, +// and create the initial paper object, all in one condensed statement: +var paper = new (PaperScope.inject(Base.exports.inject({ + PaperScript: PaperScript, + Numerical: Numerical +})))(); diff --git a/src/paper.js b/src/paper.js index 2b9f6c47..abceb5a1 100644 --- a/src/paper.js +++ b/src/paper.js @@ -39,17 +39,15 @@ var paper = new function() { /*#*/ include('../lib/stats.js'); /*#*/ } // options.stats +/*#*/ if (options.version == 'dev') { +/*#*/ include('constants.js'); +/*#*/ } // options.version == 'dev' + /*#*/ include('core/Base.js'); /*#*/ include('core/Callback.js'); /*#*/ include('core/PaperScope.js'); /*#*/ include('core/PaperScopeItem.js'); -/*#*/ if (options.version == 'dev') { -// We can only load constants after core, since Numerical.js is loaded and -// requires on Base.exports for exporting. -/*#*/ include('constants.js'); -/*#*/ } // options.version == 'dev' - /*#*/ include('util/Formatter.js'); /*#*/ include('util/Numerical.js'); diff --git a/src/util/Numerical.js b/src/util/Numerical.js index 4c110b35..db04302a 100644 --- a/src/util/Numerical.js +++ b/src/util/Numerical.js @@ -10,7 +10,7 @@ * All rights reserved. */ -var Numerical = Base.exports.Numerical = new function() { +var Numerical = new function() { // Lookup tables for abscissas and weights with values for n = 2 .. 16. // As values are symetric, only store half of them and addapt algorithm