-\r
-/* X.Class.create で作られたクラスのインスタンスが共通で備えるメソッド \r
- *\r
- *\r
- */\r
-var X_Class_CommonProps = {\r
- kill : function(){\r
- var instance = this,\r
- klass = X_Class_getClass( instance ),\r
- def = X_Class_getClassDef( klass ),\r
- data, p, i;\r
- if( def.isPrivate && !X_Class_killPrivateFlag ){\r
- X.Logger.critical( 'PrivateInstance.kill() work in PrivateUser.kill().' );\r
- return;\r
- };\r
- X_Class_killPrivateFlag = false; // onKill 内で PrivateInstance.kill() を防ぐため\r
- \r
- // onKill() === false の場合、kill のキャンセル\r
- // private は false での キャンセル は無視される\r
- \r
- if( this.instanceOf( X.EventDispatcher ) ){\r
- console.log( 'this.instanceOf( X.EventDispatcher )! ' + this._dispatching );\r
- if( !def.isPrivate ){\r
- if( this._dispatching ){\r
- this.dispatch( X.Event.BEFORE_KILL_INSTANCE );\r
- this._killReserved = true;\r
- this.dispatch( X.Event.KILL_INSTANCE_CANCELED );\r
- return;\r
- } else\r
- if( this.dispatch( X.Event.BEFORE_KILL_INSTANCE ) & X.Callback.PREVENT_DEFAULT ){\r
- this.dispatch( X.Event.KILL_INSTANCE_CANCELED );\r
- return;\r
- };\r
- } else {\r
- this.dispatch( X.Event.BEFORE_KILL_INSTANCE ); \r
- };\r
- console.log('kill ' + this._dispatching);\r
- this.dispatch( X.Event.KILL_INSTANCE );\r
- this._listeners && this.unlisten();\r
- } else\r
- if( X.Type.isFunction( instance.onKill ) && instance.onKill() === false && !def.isPrivate ){\r
- return;\r
- };\r
- \r
- for( p in instance ){\r
- if( instance.hasOwnProperty && !instance.hasOwnProperty( p ) ) continue;\r
- delete instance[ p ];\r
- };\r
- if( def.pool ){\r
- def.live && def.live.splice( def.live.indexOf( instance ), 1 );\r
- def.pool[ def.pool.length ] = instance;\r
- };\r
- if( def.privateClass ){\r
- i = def.userList.indexOf( instance );\r
- if( i !== -1 ){\r
- data = X_Class_getPrivate( instance );\r
- X_Class_killPrivateFlag = true;\r
- if( data._dispatching && data.instanceOf( X.EventDispatcher ) ){\r
- data._killReserved = true;\r
- } else {\r
- data.kill();\r
- };\r
- def.dataList.splice( i, 1 );\r
- def.userList.splice( i, 1 );\r
- };\r
- };\r
- },\r
- \r
- // TODO Super\r
- // superCall\r
- \r
- instanceOf : function( klass ){\r
- var Super = this;\r
- if( this.constructor === klass ) return true;\r
- while( Super = X_Class_getClassDef( Super ).SuperClass ){\r
- if( Super === klass ) return true;\r
- };\r
- return false;\r
- }\r
-};\r