X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=0.6.x%2Fjs%2F01_core%2F12_XClosure.js;h=deca9981254c0027c25dc12f9ad69992bc9ebdc6;hb=b05bf97c1b3b1720e73af54017a48291a364d394;hp=82ff4a956bb4c8a92e881015b0377b722ec39fa2;hpb=475df4df9670f042764a99c80d7716e994d28033;p=pettanr%2FclientJs.git diff --git a/0.6.x/js/01_core/12_XClosure.js b/0.6.x/js/01_core/12_XClosure.js index 82ff4a9..deca998 100644 --- a/0.6.x/js/01_core/12_XClosure.js +++ b/0.6.x/js/01_core/12_XClosure.js @@ -37,7 +37,7 @@ var __CallbackHash__ = * コールバックの種類を表す数値。 this + function, this.handleEvent, function only がある。 * @type {number} */ - kind : X_CLOSURE_THIS_FUNC, + cbKind : X_CLOSURE_THIS_FUNC, /** * コールバック。 * @type {funciton|undefined} @@ -47,7 +47,7 @@ var __CallbackHash__ = * コールバック名。コールバック作成時に関数が無い、関数が入れ替わっていても動作する。 * @type {string|undefined} */ - name : undefined, + funcName : undefined, /** * コールバックの this コンテキスト。 * @type {object|undefined} @@ -73,14 +73,14 @@ function X_Closure_create( thisObject, opt_callback, opt_args /* [ listener || ( var obj = X_Closure_classifyCallbackArgs( thisObject, opt_callback, opt_args ), l, ret, _obj; - if( !obj.kind ) return obj; + if( !obj.cbKind ) return obj; if( l = X_CLOSURE_POOL_LIST.length ){ ret = X_CLOSURE_POOL_LIST[ l - 1 ]; --X_CLOSURE_POOL_LIST.length; // ret = X_CLOSURE_POOL_LIST.pop(); _obj = ret( X_Closure_COMMAND_BACK ); - _obj.kind = obj.kind; - _obj.name = obj.name; + _obj.cbKind = obj.cbKind; + _obj.funcName = obj.funcName; _obj.func = obj.func; _obj.context = obj.context; _obj.supplement = obj.supplement; @@ -98,38 +98,38 @@ function X_Closure_classifyCallbackArgs( arg1, arg2, arg3, alt_context ){ var obj; if( X_Type_isObject( arg1 ) && X_Type_isFunction( arg2 ) ){ - obj = { context : arg1, func : arg2, kind : X_CLOSURE_THIS_FUNC }; + obj = { context : arg1, func : arg2, cbKind : X_CLOSURE_THIS_FUNC }; } else if( X_Type_isObject( arg1 ) ){ if( arg2 && X_Type_isString( arg2 ) ){ - obj = { context : arg1, name : arg2, kind : X_CLOSURE_THIS_FUNCNAME }; + obj = { context : arg1, funcName : arg2, cbKind : X_CLOSURE_THIS_FUNCNAME }; } else { - obj = { context : arg1, kind : X_CLOSURE_HANDLEEVENT }; + obj = { context : arg1, cbKind : X_CLOSURE_HANDLEEVENT }; arg3 = arg2; }; } else if( X_Type_isFunction( arg1 ) ){ arg3 = arg2; if( alt_context ){ - obj = { context : alt_context, func : arg1, kind : X_CLOSURE_THIS_FUNC }; + obj = { context : alt_context, func : arg1, cbKind : X_CLOSURE_THIS_FUNC }; } else { - obj = { func : arg1, kind : X_CLOSURE_FUNC_ONLY }; + obj = { func : arg1, cbKind : X_CLOSURE_FUNC_ONLY }; }; } else if( X_Type_isFunction( arg2 ) ){ //console.log( 'X_Closure_classifyCallbackArgs : arg1 が ' + arg1 + 'です' ); ie4 で error if( alt_context ){ - obj = { context : alt_context, func : arg2, kind : X_CLOSURE_THIS_FUNC }; + obj = { context : alt_context, func : arg2, cbKind : X_CLOSURE_THIS_FUNC }; } else { - obj = { func : arg2, kind : X_CLOSURE_FUNC_ONLY }; + obj = { func : arg2, cbKind : X_CLOSURE_FUNC_ONLY }; }; } else if( alt_context && X_Type_isString( arg1 ) ){ arg3 = arg2; - obj = { context : alt_context, name : arg1, kind : X_CLOSURE_THIS_FUNCNAME }; + obj = { context : alt_context, funcName : arg1, cbKind : X_CLOSURE_THIS_FUNCNAME }; } else if( alt_context ){ - obj = { context : alt_context, kind : X_CLOSURE_HANDLEEVENT }; + obj = { context : alt_context, cbKind : X_CLOSURE_HANDLEEVENT }; arg3 = arg1; } else { console.log( '不正 ' + arg1 ); @@ -171,13 +171,13 @@ function X_Closure_proxyCallback( xfunc, _args ){ args = temp; }; - switch( xfunc.kind ){ + switch( xfunc.cbKind ){ case X_CLOSURE_THIS_FUNC : return args.length === 0 ? func.call( thisObj ) : func.apply( thisObj, args ); case X_CLOSURE_THIS_FUNCNAME : - funcName = xfunc.name; + funcName = xfunc.funcName; case X_CLOSURE_HANDLEEVENT : funcName = funcName || 'handleEvent'; temp = thisObj[ funcName ]; @@ -208,21 +208,14 @@ function X_Closure_proxyCallback( xfunc, _args ){ function X_Closure_correct( f ){ var i = X_CLOSURE_LIVE_LIST.indexOf( f ), obj; + if( i !== -1 ){ X_CLOSURE_LIVE_LIST.splice( i, 1 ); X_CLOSURE_POOL_LIST[ X_CLOSURE_POOL_LIST.length ] = f; obj = f( X_Closure_COMMAND_BACK ); - /* - delete obj.kind; - if( obj.name ) delete obj.name; - if( obj.func ) delete obj.func; - if( obj.context ) delete obj.context; - if( obj.supplement ) delete obj.supplement; - delete obj.proxy; */ X_Object_clear( obj ); return true; }; - return false; }; function X_Closure_monitor(){