77
88// Google closure compiler cannot handle Clazz.new or Clazz.super
99
10+ // BH 1/9/2018 8:40:52 AM fully running SwingJS2; adds String.isEmpty()
1011// BH 12/16/2017 5:53:47 PM refactored; removed older unused parts
1112// BH 11/16/2017 10:52:53 PM adds method name aliasing for generics; adds String.contains$CharSequence(cs)
1213// BH 10/14/2017 8:17:57 AM removing all node-based dependency class loading; fix String.initialize with four arguments (arr->byte)
@@ -48,11 +49,13 @@ window["j2s.clazzloaded"] = true;
4849/*Class = */ Clazz = {
4950 _isQuiet : false ,
5051 _debugging : false ,
52+ _loadcore : true ,
5153 _nooutput : 0
5254} ;
5355
5456; ( function ( Clazz , J2S ) {
5557
58+ Clazz . ClassFilesLoaded = [ ] ;
5659
5760Clazz . popup = Clazz . log = Clazz . error = window . alert ;
5861
@@ -247,11 +250,12 @@ Clazz.forName = function(name, initialize, loader) {
247250Clazz . getClass = function ( cl , methodList ) {
248251 // $Class$ is the java.lang.Class object wrapper
249252 // $clazz$ is the unwrapped JavaScript object
253+ cl = getClazz ( cl ) || cl ;
250254 if ( cl . $Class$ )
251255 return cl . $Class$ ;
252256 java . lang . Class || Clazz . load ( "java.lang.Class" ) ;
253257 var Class_ = cl . $Class$ = new java . lang . Class ( ) ;
254- Class_ . $clazz$ = getClazz ( cl ) || cl ; // for arrays - a bit of a hack
258+ Class_ . $clazz$ = cl ; // for arrays - a bit of a hack
255259 Class_ . $methodList$ = methodList ;
256260 return Class_ ;
257261}
@@ -365,7 +369,7 @@ Clazz.new_ = function(c, args, cl) {
365369 clInner && clInner . $init$ . apply ( f ) ;
366370 }
367371
368- _profileNew && addProfileNew ( myclass , window . performance . now ( ) - t0 ) ;
372+ _profileNew && addProfileNew ( cl , window . performance . now ( ) - t0 ) ;
369373
370374 return f ;
371375}
@@ -630,6 +634,7 @@ var arrayClass = function(baseClass, ndim) {
630634
631635try {
632636Clazz . _debugging = ( document . location . href . indexOf ( "j2sdebug" ) >= 0 ) ;
637+ Clazz . _loadcore = ( document . location . href . indexOf ( "j2snocore" ) < 0 ) ;
633638} catch ( e ) {
634639}
635640
@@ -1578,23 +1583,6 @@ Clazz._setDeclared = function(name, func) {
15781583 */
15791584
15801585
1581- /**
1582- * Class dependency tree node
1583- */
1584- /* private */
1585- var Node = function ( ) {
1586- this . parents = [ ] ;
1587- this . musts = [ ] ;
1588- this . optionals = [ ] ;
1589- this . declaration = null ;
1590- this . name = null ; // id
1591- this . path = null ;
1592- // this.requires = null;
1593- // this.requiresMap = null;
1594- this . onLoaded = null ;
1595- this . status = 0 ;
1596- this . random = 0.13412 ;
1597- } ;
15981586
15991587
16001588/**
@@ -1658,32 +1646,7 @@ _Loader.doTODO = function() {
16581646 f ( ) ;
16591647 }
16601648}
1661-
1662- _Loader . updateNodeForFunctionDecoration = function ( qName ) {
1663-
1664- var node = findNode ( qName ) ;
1665- if ( node && node . status == Node . STATUS_KNOWN ) {
1666- if ( node . musts . length == 0 && node . optionals . length == 0 ) {
1667- var f = function ( ) { updateNode ( node ) } ;
1668- _Loader . _TODO . push ( f ) ;
1669- } else {
1670- window . setTimeout ( f , 1 ) ;
1671- }
1672- }
1673- }
1674-
1675- Node . prototype . toString = function ( ) {
1676- return this . name || this . path || "ClazzNode" ;
1677- }
1678-
1679- Node . STATUS_UNKNOWN = 0 ;
1680- Node . STATUS_KNOWN = 1 ;
1681- Node . STATUS_CONTENT_LOADED = 2 ;
1682- Node . STATUS_MUSTS_LOADED = 3 ;
1683- Node . STATUS_DECLARED = 4 ;
1684- Node . STATUS_LOAD_COMPLETE = 5 ;
1685-
1686-
1649+
16871650var loaders = [ ] ;
16881651
16891652/* public */
@@ -1835,7 +1798,7 @@ Clazz.loadClass = function (name, onLoaded, async) {
18351798 */
18361799/* public */
18371800_Loader . loadClass = _Loader . prototype . loadClass = function ( name , onLoaded , forced , async , mode ) {
1838-
1801+
18391802 mode || ( mode = 0 ) ; // BH: not implemented
18401803 ( async == null ) && ( async = false ) ;
18411804
@@ -1844,7 +1807,7 @@ _Loader.loadClass = _Loader.prototype.loadClass = function (name, onLoaded, forc
18441807
18451808 //System.out.println("loadClass " + name)
18461809 var path = _Loader . getClasspathFor ( name ) ;
1847-
1810+ Clazz . ClassFilesLoaded . push ( name . replace ( / \. / g , "/" ) + ".js" ) ;
18481811 Clazz . loadScript ( path ) ; //(n, n.path, n.requiredBy, false, onLoaded ? function(_loadClass){ isLoadingEntryClass = bSave; onLoaded()}: null);
18491812}
18501813
@@ -2032,7 +1995,7 @@ Clazz._4Name = function(clazzName, applet, state, asClazz, initialize) {
20321995 var cl = evalType ( clazzName ) ;
20331996 if ( ! cl ) {
20341997 alert ( clazzName + " could not be loaded" ) ;
2035- debugger ;
1998+ doDebugger ( ) ;
20361999 }
20372000 Clazz . allClasses [ clazzName ] = cl ;
20382001 if ( initialize !== false )
@@ -3641,7 +3604,7 @@ if(cs=="utf-8"||cs=="utf8"){
36413604s = Encoding . convert2UTF8 ( this ) ;
36423605}
36433606}
3644- var arrs = Clazz . array ( Byte . TYPE , [ s . length ] ) ;
3607+ var arrs = [ ] ;
36453608for ( var i = 0 , ii = 0 ; i < s . length ; i ++ ) {
36463609var c = s . charCodeAt ( i ) ;
36473610if ( c > 255 ) {
@@ -3654,7 +3617,7 @@ arrs[ii]=c;
36543617}
36553618ii ++ ;
36563619}
3657- return arrs ;
3620+ return Clazz . array ( Byte . TYPE , - 1 , arrs ) ;
36583621} ;
36593622
36603623sp . contains$S = function ( a ) { return this . indexOf ( a ) >= 0 } // bh added
@@ -3770,6 +3733,9 @@ throw new NullPointerException();
37703733return this . $concat ( s ) ;
37713734} ;
37723735
3736+ sp . isEmpty = function ( ) {
3737+ return this . valueOf ( ) . length == 0 ;
3738+ }
37733739sp . $lastIndexOf = sp . lastIndexOf ;
37743740sp . lastIndexOf = function ( s , last ) {
37753741if ( last != null && last + this . length <= 0 ) {
@@ -4995,6 +4961,7 @@ return null;
49954961//Clazz._Loader.loadZJar(Clazz._Loader.getJ2SLibBase() + "core/coreswingjs.z.js", "swingjs.JSUtil");
49964962
49974963 //if (!J2S._isAsync) {
4964+ if ( Clazz . _loadcore )
49984965 for ( var i = 0 ; i < J2S . _coreFiles . length ; i ++ )
49994966 Clazz . loadScript ( J2S . _coreFiles [ i ] ) ;
50004967 //ClazzLoader.loadZJar(J2S._coreFiles[i], ClazzLoader.runtimeKeyClass);
0 commit comments