X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=0.6.x%2Fjs%2F01_core%2F13_XClass.js;h=2b9366907870e635dc8127c82c39cd72ffcde787;hb=66ccef8a1fdd3994dd3c75dcfede668ea55f1d2e;hp=343f862223ec2088aaea1171ad3d71c1a42a72a8;hpb=f74335422a0ae2d66e3ce9bfa03f0c77a107e8d1;p=pettanr%2FclientJs.git
diff --git a/0.6.x/js/01_core/13_XClass.js b/0.6.x/js/01_core/13_XClass.js
index 343f862..2b93669 100644
--- a/0.6.x/js/01_core/13_XClass.js
+++ b/0.6.x/js/01_core/13_XClass.js
@@ -15,7 +15,7 @@ var
* ã¯ã©ã¹å
* @type {string}
*/
- name : ''
+ NAME : ''
},
X_Class_CLASS_LIST = [],
@@ -25,7 +25,10 @@ var
X_Class_traits = null,
X_Class_useObjectCreate = false, // !!Object.create, http://jsperf.com/prototype-vs-object-create-perf
// Opera Mobile 12.10 Android11 IS01 ã§ã¯ã©ã¹ã®ã¡ã³ããæ¬ è½ããåé¡ã«ééã__proto__ ãè¾ããã¨åä½,,,
- X_Class_use_proto_ = !X_UA[ 'OperaMobile' ] && !X_UA[ 'OperaTablet' ] && !!X_emptyFunction.prototype.__proto__,
+ X_Class_use_proto_ = !X_UA[ 'OperaMobile' ] && !X_UA[ 'OperaTablet' ] &&
+ // Android ã§åå ä¸æã®ã¨ã©ã¼ã«ééãã¦ããã®ã¯ããã®è¾ºããæªãã... 2016.3.9
+ !X_UA[ 'AOSP' ] && !X_UA[ 'ChromeWV' ] &&
+ !!X_emptyFunction.prototype.__proto__,
X_Class_constructorFix = X_UA[ 'AOSP' ] < 3 || X_UA[ 'iOS' ] < 5,
X_Class_SEAL_KILLING = [],
@@ -36,14 +39,14 @@ X_Class_CommonMethods =
* å
¨ã¦ã®åçã¡ã³ããåé¤ãã¦ãã¤ã³ã¹ã¿ã³ã¹ãç ´æ£ããã
* ã¤ã³ã¹ã¿ã³ã¹ã X.EventDispatcher ã¨ãã®ãµãã¯ã©ã¹ã®å ´åã次ã®åä½ãããã
*
- * - X.Event.BEFORE_KILL_INSTANCE ãçºç«ãããæ»ãå¤ã®ããããã©ã°ã« X_Callback.PREVENT_DEFAULT ãç«ã¤å ´åãç ´æ£ããã£ã³ã»ã«ã X.Event.KILL_INSTANCE_CANCELED ãçºç«ããããã®éã« kill() ãå¼ã°ãã¦ãç¡è¦ãããã
+ *
- X.Event.BEFORE_KILL_INSTANCE ãçºç«ãããæ»ãå¤ã®ããããã©ã°ã« X.Callback.PREVENT_DEFAULT ãç«ã¤å ´åãç ´æ£ããã£ã³ã»ã«ã X.Event.KILL_INSTANCE_CANCELED ãçºç«ããããã®éã« kill() ãå¼ã°ãã¦ãç¡è¦ãããã
*
- ç ´æ£ã«é²ãå ´åã¯ãX.Event.KILL_INSTANCE ãçºç«ããã
*
- dispatch ä¸ã¯ãã¤ã³ã¹ã¿ã³ã¹ã®å
¨ã¦ã® dispatch ãçµäºããã¾ã§å®éã®ç ´æ£ãå¾
ã¤ã
*
- å®éã®ç ´æ£ã§ã¯ãã¤ã³ã¹ã¿ã³ã¹ã®ã¡ã³ãã®åé¤ã«å ãã¦å
¨ã¦ã®ã¤ãã³ããªã¹ãã解é¤ããã
*/
// TODO kill ããã¤ã³ã¹ã¿ã³ã¹ã®ã¤ãã³ããæ®ã£ã¦ããªããï¼ããã¯éçºç¨ã®ã¿
'kill' : function(){
- var listeners, flag, p, timers, def;
+ var listeners, flag, p, i, list, timers, def;
// TODO ç ´æ£æ¸ã®ã¤ã³ã¹ã¿ã³ã¹ã¸ã® kill
@@ -57,7 +60,7 @@ X_Class_CommonMethods =
// listeners ããªãå ´åãã¤ãã³ãã®ç»é²ããªããããBEFORE_KILL_INSTANCE ã¯å¼ã°ããªãã
// KILL_RESERVEDã== trueãã®å ´åãBEFORE_KILL_INSTANCE ã¯å¼ã°ããªãã
if( listeners && !listeners[ X_LISTENERS_KILL_RESERVED ] && listeners[ X_EVENT_BEFORE_KILL_INSTANCE ] ){
- X_Class_SEAL_KILLING[ X_Class_SEAL_KILLING.length ] = this;
+ X_Class_SEAL_KILLING[ i = X_Class_SEAL_KILLING.length ] = this;
if( this[ 'dispatch' ]( X_EVENT_BEFORE_KILL_INSTANCE ) & X_CALLBACK_PREVENT_DEFAULT ){
this[ 'dispatch' ]( X_EVENT_KILL_INSTANCE_CANCELED );
@@ -67,7 +70,7 @@ X_Class_CommonMethods =
X_Class_SEAL_KILLING.length === 1 ?
( X_Class_SEAL_KILLING.length = 0 ) :
- X_Class_SEAL_KILLING.splice( X_Class_SEAL_KILLING.indexOf( this ), 1 );
+ X_Class_SEAL_KILLING.splice( X_Class_SEAL_KILLING[ i ] === this ? i : X_Class_SEAL_KILLING.indexOf( this ), 1 );
if( flag ) return;
};
@@ -79,17 +82,26 @@ X_Class_CommonMethods =
};
if( listeners[ X_EVENT_KILL_INSTANCE ] ){
- X_Class_SEAL_KILLING[ X_Class_SEAL_KILLING.length ] = this;
+ X_Class_SEAL_KILLING[ i = X_Class_SEAL_KILLING.length ] = this;
listeners[ X_LISTENERS_KILL_RESERVED ] = false;
this[ 'dispatch' ]( X_EVENT_KILL_INSTANCE );
X_Class_SEAL_KILLING.length === 1 ?
( X_Class_SEAL_KILLING.length = 0 ) :
- X_Class_SEAL_KILLING.splice( X_Class_SEAL_KILLING.indexOf( this ), 1 );
+ X_Class_SEAL_KILLING.splice( X_Class_SEAL_KILLING[ i ] === this ? i : X_Class_SEAL_KILLING.indexOf( this ), 1 );
+ };
+
+ if( !( listeners = this[ '_listeners' ] ) ){
+ for( p in listeners ){
+ //if( X_EMPTY_OBJECT[ opt_type ] ) continue;
+ if( p <= X_LISTENERS_KILL_RESERVED ) continue;
+ list = listeners[ p ];
+ for( i = list.length; i; ){
+ this[ 'unlisten' ]( p, list[ --i ] );
+ };
+ };
};
-
- X_EventDispatcher_unlistenAll( this );
};
if( this[ 'instanceOf' ]( Node ) ){
@@ -159,7 +171,12 @@ X_Class_CommonMethods =
};
};
- if( X_Class_SUPER_STACKS[ i ] === stack ) console.log( 'ã¹ã¼ãã¼ã¯ã©ã¹ãã¾ãã¯ã¹ã¼ãã¼ã¯ã©ã¹ã®ã³ã³ã¹ãã©ã¯ã¿ã¯åå¨ãã¾ãã' );
+ // index ãæ¿ãã£ã¦ããå¯è½æ§ãããã®ã§åãç´ã
+ if( X_Class_SUPER_CALLER[ i ] !== me ) i = X_Class_SUPER_CALLER.indexOf( me );
+
+ if( X_Class_SUPER_STACKS[ i ] === stack ){
+ //console.log( 'ã¹ã¼ãã¼ã¯ã©ã¹ãã¾ãã¯ã¹ã¼ãã¼ã¯ã©ã¹ã®ã³ã³ã¹ãã©ã¯ã¿ã¯åå¨ãã¾ãã' );
+ };
if( stack === 0 ){
X_Class_SUPER_CALLER.splice( i, 1 );
@@ -200,7 +217,7 @@ X_Class_CommonMethods =
proto = sClass.prototype,
i = X_Class_SUPER_CALLER.indexOf( me ),
args = arguments,
- p, name, t, sFunc, ret;
+ p, name, stack, t, sFunc, ret;
if( X_Type_isFunction( myFunc ) ){
for( p in proto ){
@@ -238,21 +255,20 @@ X_Class_CommonMethods =
sFunc = sClass.prototype[ name ];
if( sFunc !== myFunc /* X_Object_own( name, sClass.prototype ) */ ){
- // this ã®é¢æ°ã¨ç°ãªããå¤ãè¨å®ããã¦ããããä»ã¯æãæã㦠undef ã?è¦ã¦ãããæ£ãã㯠hasOwnProperty
if( X_Type_isFunction( sFunc ) ){
X_Class_SUPER_STACKS[ i ] += t;
switch( args.length ){
- case 0 :
- ret = sFunc.call( me );
- break;
case 1 :
- ret = sFunc.call( me, args[ 0 ] );
+ ret = sFunc.call( me );
break;
case 2 :
- ret = sFunc.call( me, args[ 0 ], args[ 1 ] );
+ ret = sFunc.call( me, args[ 1 ] );
break;
case 3 :
- ret = sFunc.call( me, args[ 0 ], args[ 1 ], args[ 2 ] );
+ ret = sFunc.call( me, args[ 1 ], args[ 2 ] );
+ break;
+ case 4 :
+ ret = sFunc.call( me, args[ 1 ], args[ 2 ], args[ 3 ] );
break;
default :
args = X_Array_copy( args );
@@ -266,6 +282,9 @@ X_Class_CommonMethods =
};
};
+ // index ãæ¿ãã£ã¦ããå¯è½æ§ãããã®ã§åãç´ã
+ if( X_Class_SUPER_CALLER[ i ] !== me ) i = X_Class_SUPER_CALLER.indexOf( me );
+
if( stack === 0 ){
X_Class_SUPER_CALLER.splice( i, 1 );
X_Class_SUPER_STACKS.splice( i, 1 );
@@ -337,6 +356,7 @@ X[ 'Class' ] = /** @lends X.Class */ {
*/
'NONE' : X_Class.NONE,
+ // TODO ãã®æå®ããã¬ã¼ã ã¯ã¼ã¯å
ã ãï¼
/**
* ã¤ã³ã¹ã¿ã³ã¹ã¯ç ´æ£æ(this.kill())ã«ååããã次åã® new MyClass() æã«åå©ç¨ããã¾ãã
* @const
@@ -464,7 +484,7 @@ X[ 'Class' ] = /** @lends X.Class */ {
klass.prototype.constructor = klass;
};
- klass[ 'name' ] = displayName;
+ klass[ 'NAME' ] = displayName;
if( opt_abstract ){
classDef.isAbstract = true;
@@ -647,7 +667,7 @@ function X_Class_actualConstructor( f, args ){
obj = def.Constructor ?
def.Constructor.apply( instance, args ) :
- instance[ 'Super' ].apply( instance, args );
+ def.SuperClass && instance[ 'Super' ].apply( instance, args );
if( obj !== instance && ( X_Type_isObject( obj ) || X_Type_isFunction( obj ) ) ){ // Class
instance[ 'kill' ]();