Properly export Numerical and PaperScript again.

This commit is contained in:
Jürg Lehni 2013-05-27 15:55:44 -07:00
parent e516e6f651
commit 5592bb57e0
6 changed files with 20 additions and 15 deletions

View file

@ -82,16 +82,15 @@ Base.inject(/** @lends Base# */{
// Keep track of all named classes for serialization and exporting. // Keep track of all named classes for serialization and exporting.
// Also register the Base class itself. // Also register the Base class itself.
_classes: { 'Base': Base }, exports: { 'Base': Base },
extend: function extend(src) { extend: function extend(src) {
// Override Base.extend() with a version that registers classes that // Override Base.extend() to register named classes in Base.exports,
// define #_class inside the Base._classes lookup, for // for deserialization and injection into PaperScope.
// deserialization.
var res = extend.base.apply(this, arguments), var res = extend.base.apply(this, arguments),
name = res.name; name = res.name;
if (name) if (name)
Base._classes[name] = res; Base.exports[name] = res;
return res; return res;
}, },
@ -337,7 +336,7 @@ Base.inject(/** @lends Base# */{
/** /**
* Deserializes from parsed JSON data. A simple convention is followed: * Deserializes from parsed JSON data. A simple convention is followed:
* Array values with a string at the first position are links to * Array values with a string at the first position are links to
* deserializable types through Base._classes, and the values following * deserializable types through Base.exports, and the values following
* in the array are the arguments to their initialize function. * in the array are the arguments to their initialize function.
* Any other value is passed on unmodified. * Any other value is passed on unmodified.
* The passed data is recoursively traversed and converted, leaves first * The passed data is recoursively traversed and converted, leaves first
@ -361,7 +360,7 @@ Base.inject(/** @lends Base# */{
// if so return its definition instead. // if so return its definition instead.
if (data.dictionary && obj.length == 1 && /^#/.test(type)) if (data.dictionary && obj.length == 1 && /^#/.test(type))
return data.dictionary[type]; return data.dictionary[type];
type = Base._classes[type]; type = Base.exports[type];
} }
res = []; res = [];
// Skip first type entry for arguments // Skip first type entry for arguments

View file

@ -21,7 +21,7 @@
/*#*/ include('../../lib/esprima-min.js'); /*#*/ include('../../lib/esprima-min.js');
/*#*/ } /*#*/ }
var PaperScript = new function() { var PaperScript = Base.exports.PaperScript = new function() {
// Operators to overload // Operators to overload
var binaryOperators = { var binaryOperators = {

View file

@ -11,4 +11,4 @@
*/ */
// Export all named classes to PaperScope and create the initial paper object. // Export all named classes to PaperScope and create the initial paper object.
var paper = new (PaperScope.inject(Base._classes))(); var paper = new (PaperScope.inject(Base.exports))();

View file

@ -35,10 +35,6 @@ var paper = new function() {
// Inline Bootstrap core (the Base class) inside the paper scope first: // Inline Bootstrap core (the Base class) inside the paper scope first:
/*#*/ include('../lib/straps.js'); /*#*/ include('../lib/straps.js');
/*#*/ if (options.version == 'dev') {
/*#*/ include('constants.js');
/*#*/ } // options.version == 'dev'
/*#*/ if (options.stats) { /*#*/ if (options.stats) {
/*#*/ include('../lib/stats.js'); /*#*/ include('../lib/stats.js');
/*#*/ } // options.stats /*#*/ } // options.stats
@ -48,6 +44,12 @@ var paper = new function() {
/*#*/ include('core/PaperScope.js'); /*#*/ include('core/PaperScope.js');
/*#*/ include('core/PaperScopeItem.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/Formatter.js');
/*#*/ include('util/Numerical.js'); /*#*/ include('util/Numerical.js');

View file

@ -20,6 +20,10 @@
* @extends Item * @extends Item
*/ */
var PathItem = Item.extend(/** @lends PathItem# */{ var PathItem = Item.extend(/** @lends PathItem# */{
initialize: function PathItem() {
Item.apply(this, arguments);
},
/** /**
* Returns all intersections between two {@link PathItem} items as an array * Returns all intersections between two {@link PathItem} items as an array
* of {@link CurveLocation} objects. {@link CompoundPath} items are also * of {@link CurveLocation} objects. {@link CompoundPath} items are also

View file

@ -10,7 +10,7 @@
* All rights reserved. * All rights reserved.
*/ */
var Numerical = new function() { var Numerical = Base.exports.Numerical = new function() {
// Lookup tables for abscissas and weights with values for n = 2 .. 16. // Lookup tables for abscissas and weights with values for n = 2 .. 16.
// As values are symetric, only store half of them and addapt algorithm // As values are symetric, only store half of them and addapt algorithm