Skip to content

Commit 9c33a67

Browse files
committed
changed dojox.math to follow the simple AMD transform pattern applied to dojo and dijit. it seems that it might be premature to try and refactor the code more than this.
effectively, this commit rolled back dojox.math to before r23089 and manually converted to AMD in a way similar to the automatic conversion done to dojo and dijit. !strict. fixes #11911
1 parent 987e64f commit 9c33a67

File tree

10 files changed

+662
-649
lines changed

10 files changed

+662
-649
lines changed

math/BigInteger-ext.js

+16-11
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1-
define("dojox/math/BigInteger-ext", ["dojo", "dojox/math/BigInteger"], function (dojo, BigInteger) {
2-
dojo.experimental("dojox.math.BigInteger-ext");
3-
4-
// Contributed under CLA by Tom Wu
5-
6-
// Extended JavaScript BN functions, required for RSA private ops.
7-
8-
var nbi = BigInteger._nbi, nbv = BigInteger._nbv,
1+
// AMD-ID "dojox/math/BigInteger-ext"
2+
define(["dojo", "dojox", "dojox/math/BigInteger"], function(dojo, dojox) {
3+
dojo.experimental("dojox.math.BigInteger-ext");
4+
5+
// Contributed under CLA by Tom Wu
6+
7+
// Extended JavaScript BN functions, required for RSA private ops.
8+
9+
(function(){
10+
var BigInteger = dojox.math.BigInteger,
11+
nbi = BigInteger._nbi, nbv = BigInteger._nbv,
912
nbits = BigInteger._nbits,
1013
Montgomery = BigInteger._Montgomery;
11-
14+
1215
// (public)
1316
function bnClone() { var r = nbi(); this._copyTo(r); return r; }
1417

@@ -650,6 +653,8 @@ define("dojox/math/BigInteger-ext", ["dojo", "dojox/math/BigInteger"], function
650653
// int hashCode()
651654
// long longValue()
652655
// static BigInteger valueOf(long val)
653-
654-
return BigInteger;
656+
657+
})();
658+
659+
return dojox.math.BigInteger;
655660
});

math/BigInteger.js

+20-17
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
define("dojox/math/BigInteger", ["dojo"], function (dojo) {
2-
// export to DojoX
3-
var dm = dojo.getObject("dojox.math", true);
4-
5-
dojo.experimental("dojox.math.BigInteger");
6-
7-
// Contributed under CLA by Tom Wu <[email protected]>
8-
// See http://www-cs-students.stanford.edu/~tjw/jsbn/ for details.
9-
10-
// Basic JavaScript BN library - subset useful for RSA encryption.
11-
// The API for dojox.math.BigInteger closely resembles that of the java.math.BigInteger class in Java.
12-
1+
// AMD-ID "dojox/math/BigInteger"
2+
define(["dojo", "dojox"], function(dojo, dojox) {
3+
dojo.getObject("math.BigInteger", true, dojox);
4+
dojo.experimental("dojox.math.BigInteger");
5+
6+
// Contributed under CLA by Tom Wu <[email protected]>
7+
// See http://www-cs-students.stanford.edu/~tjw/jsbn/ for details.
8+
9+
// Basic JavaScript BN library - subset useful for RSA encryption.
10+
// The API for dojox.math.BigInteger closely resembles that of the java.math.BigInteger class in Java.
11+
12+
(function(){
13+
1314
// Bits per digit
1415
var dbits;
1516

@@ -572,17 +573,19 @@ define("dojox/math/BigInteger", ["dojo"], function (dojo) {
572573
// "constants"
573574
ZERO: nbv(0),
574575
ONE: nbv(1),
575-
576+
576577
// internal functions
577578
_nbi: nbi,
578579
_nbv: nbv,
579580
_nbits: nbits,
580-
581+
581582
// internal classes
582583
_Montgomery: Montgomery
583584
});
584585

585-
dm.BigInteger = BigInteger;
586-
587-
return BigInteger;
586+
// export to DojoX
587+
dojox.math.BigInteger = BigInteger;
588+
})();
589+
590+
return dojox.math.BigInteger;
588591
});

math/_base.js

+12-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
define("dojox/math/_base", ["dojo"], function (dojo) {
2-
var m = dojo.getObject("dojox.math", true);
3-
4-
dojo.mixin(m, {
1+
// AMD-ID "dojox/math/_base"
2+
define(["dojo", "dojox"], function(dojo, dojox) {
3+
dojo.getObject("math", true, dojox);
4+
5+
(function(){
6+
var m = dojox.math;
7+
dojo.mixin(dojox.math, {
58
toRadians: function(/* Number */n){
69
// summary:
710
// Convert the passed number to radians.
@@ -79,7 +82,7 @@ define("dojox/math/_base", ["dojo"], function (dojo) {
7982
permutations: function(/* Number */n, /* Number */k){
8083
// summary:
8184
// TODO
82-
if(n==0 || k==0){
85+
if(n==0 || k==0){
8386
return 1; // Number
8487
}
8588
return this.factorial(n) / this.factorial(n-k);
@@ -88,7 +91,7 @@ define("dojox/math/_base", ["dojo"], function (dojo) {
8891
combinations: function(/* Number */n, /* Number */r){
8992
// summary:
9093
// TODO
91-
if(n==0 || r==0){
94+
if(n==0 || r==0){
9295
return 1; // Number
9396
}
9497
return this.factorial(n) / (this.factorial(n-r) * this.factorial(r)); // Number
@@ -155,6 +158,7 @@ define("dojox/math/_base", ["dojo"], function (dojo) {
155158
return m; // Array
156159
}
157160
});
158-
159-
return m;
161+
})();
162+
163+
return dojox.math;
160164
});

0 commit comments

Comments
 (0)