Gelmiş geçmiş en büyük porno sitemiz olan 2pe de her zaman en kaliteli pornoları sunmayı hedefledik. Diğer video sitemiz olan vuam da ise hd porno ağırlıklı çalışmalara başladık.

Hybrid View

  1. #1
    Sencha - Community Support Team hendricd's Avatar
    Join Date
    Aug 2007
    Location
    Long Island, NY USA
    Posts
    5,962
    Vote Rating
    10
    hendricd will become famous soon enough hendricd will become famous soon enough

      0  

    Default Ext.overload (javascript Function overloading)

    Ext.overload (javascript Function overloading)


    Here is an addition for the Ext framework that may be of interest.

    It permits javascript function overloading (yes, constructors too) as found in other programming languages (PHP, C++, Python, etc). For performance reasons, this implementation permits selective function invokation based on the number(only) of parameters passed as arguments.


    Syntax:

    Creates an new overloaded function:
    PHP Code:
    var ovlFN Ext.overload(fn);    
    or  
    var 
    ovlFN Ext.overload([fn1fn2]); //define multiple call signatures 
    Overloads an existing function:
    PHP Code:
    var ovlFN Ext.overload(targetFn, [fn,....] ); 
    Overload/create a new overloaded class method:
    PHP Code:
    Ext.overload(ObjectmemberName , [fn,....] );

    egExt.overload(Ext.DomHelper'markup' , [fn,....] ); 
    Samples:
    PHP Code:
    //Use it with Ext classes !
    var Person Ext.extend(Object, {

        
    constructor Ext.overload([
                             function(
    setup){ //single argument form

                                
    Ext.apply(this,
                                          
    setup||{},
                                          {
    name:'unknown'age0});

                             },
                             function(
    setupkids){  //double-argument form

                                
    this.constructor(setup); //calling the single argument form
                                //kids are people too
                                
    this.kids = (kids||[]).map(
                                     function(
    kid){return new Person({name:kid,age:3,parent:this})}
                                );
                             }]),

        
    sayName Ext.overload([
                       function(){ return 
    this.name },
                       function(
    withFn) { withFn(this.name); }
                       ])

    });


    //Overload the class's sayName method again:
    Ext.overload Person.prototype'sayName',
        function(
    kidwithFn) { withFn(this.kids[kid].name); }
        );

    //Add an overloaded getter
    Person.prototype.get Ext.overload ([
            function(
    memberencoder) {
                return 
    typeof encoder == 'function' ?
                     
    encoder.call(null,this.get(member)) :
                        
    this.get(member);

            },
            function(
    member) {  return this[member]; }
            ]);


    var 
    = new Person({name:'Dan'});
    p.sayName(console.log);

    //use the overloaded constructor for the family
    var family = new Person({name:'Dan',age:30},['Tommy''Sally']);
    console.logfamily.kids[0].sayName()) ;
    family.sayName(1console.log); //log Sally to the console

    var Dans_Age family.get('age');
    var 
    Dan_Upper family.get('name',String.toUpperCase);

    //create an overloaded debug-writer
    var debug Ext.overload([
        
    //single-argument form
        
    function(text){ console.log(text); },

        
    //double-argument form
        
    function(textobj){
            
    console.log(text);
            
    console.dir(obj);
          }
        ]);

    debug('All about Dan:'family ); 
    The Source:
    PHP Code:
     /*  Copyright 2008, Doug Hendricks, Active Group, Inc.  All rights reserved.
      *  License: LGPL 3.0
      *  @version 1.0
      */
     
    (function(){

       var 
    overload = function(pfnfn ){

           var 
    typeof pfn =='function' pfn : function(){};

           var 
    ov f._ovl//call signature hash
           
    if(!ov){
               
    ov = {base:f};
               
    ov[f.length|| 0] = f;
               
    f= function(){
                  var 
    arguments.callee._ovl;
                  var 
    fn o[arguments.length]||o.base;
                  
    //recursion safety
                  
    return fn && fn != arguments.callee fn.apply(this,arguments): undefined;
               };
           }
           var 
    fnA = [].concat(fn);
           for(var 
    i=0,l=fnA.lengthi<li++){
             
    //ensure no duplicate call signatures, but last in rules!
             
    ov[fnA[i].length] = fnA[i];
           }
           
    f._ovlov;
           return 
    f;

       };

        
    //Give Ext.overload various call signatures.
        
    Ext.overload overloadoverload,
           [
             function(
    fn){ return overload(nullfn);},
             function(
    objmnamefn){
                 return 
    obj[mname] = overload(obj[mname],fn);}
           ]);


    })(); 
    "be dom-ready..."
    Doug Hendricks

    Maintaining ux: ManagedIFrame, MIF2 (FAQ, Wiki), ux.Media/Flash, AudioEvents, ux.Chart[Fusion,OFC,amChart], ext-basex.js/$JIT, Documentation Site.


    Got Sencha licensing questions? Find out more here.


  2. #2
    Sencha User harley.333's Avatar
    Join Date
    Mar 2007
    Posts
    286
    Vote Rating
    4
    harley.333 is on a distinguished road

      0  

    Default


    Cool. I think this is a pretty good addition to the JavaScript arsenal. As long as no one gets carried away and tries to make a "type-safe" version, I think it's great!

  3. #3
    Sencha - Community Support Team SamuraiJack1's Avatar
    Join Date
    May 2008
    Posts
    550
    Vote Rating
    3
    SamuraiJack1 will become famous soon enough

      0  

    Default


    Really good idea.

    Think it should be matured to the state, when it will be possible to differentiate scalars, objects and arrays.

  4. #4
    Sencha User
    Join Date
    Apr 2013
    Posts
    2
    Vote Rating
    0
    stamat is on a distinguished road

      0  

    Default


    I tried do find an elegant way to do function overloading, and here is what I came up with:

    Code:
    var out = def({
        'int': function(a) {
            alert('Here is int '+a);
        },
    
    
        'float': function(a) {
            alert('Here is float '+a);
        },
    
    
        'string': function(a) {
            alert('Here is string '+a);
        },
    
    
        'int,string': function(a, b) {
            alert('Here is an int '+a+' and a string '+b);
        },
        'default': function(obj) {
            alert('Here is some other value '+ obj);
        }
    
    
    });
    
    
    out('ten');
    out(1);
    out(2, 'robot');
    out(2.5);
    out(true);
    The code that enables this to work:
    Code:
    var def = function(functions, parent) {
     return function() {
        var types = [];
        var args = [];
        eachArg(arguments, function(i, elem) {
            args.push(elem);
            types.push(whatis(elem));
        });
        if(functions.hasOwnProperty(types.join())) {
            return functions[types.join()].apply(parent, args);
        } else {
            if (typeof functions === 'function')
                return functions.apply(parent, args);
            if (functions.hasOwnProperty('default'))
                return functions['default'].apply(parent, args);        
        }
      };
    };
    
    
    var eachArg = function(args, fn) {
     var i = 0;
     while (args.hasOwnProperty(i)) {
        if(fn !== undefined)
            fn(i, args[i]);
        i++;
     }
     return i-1;
    };
    
    
    var whatis = function(val) {
    
    
     if(val === undefined)
        return 'undefined';
     if(val === null)
        return 'null';
    
    
     var type = typeof val;
    
    
     if(type === 'object') {
        if(val.hasOwnProperty('length') && val.hasOwnProperty('push'))
            return 'array';
        if(val.hasOwnProperty('getDate') && val.hasOwnProperty('toLocaleTimeString'))
            return 'date';
        if(val.hasOwnProperty('toExponential'))
            type = 'number';
        if(val.hasOwnProperty('substring') && val.hasOwnProperty('length'))
            retur n 'float';
        else
            return 'int';
     }
    
    
     return type;
    };
    Blog post: http://stamat.wordpress.com/2013/04/...n-overloading/
    JSFiddle: http://jsfiddle.net/stamat/Geh5r/

  5. #5
    Sencha User
    Join Date
    Dec 2013
    Posts
    84
    Vote Rating
    48
    Malte123 is infamous around these parts Malte123 is infamous around these parts

      1  

    Default JSDuck Ext.overload()

    JSDuck Ext.overload()


    If you plan to use JSDuck for documenting your Code ...

    PHP Code:
    sayName Ext.overload([
                       function(){ return 
    this.name },
                       function(
    withFn) { withFn(this.name); }
                       ]) 
    it only brings "Duplicate method name" and "Unnamed method" Warnings.

    Generated Class-Description in JSDuck is not usable.

  6. #6
    Sencha User
    Join Date
    Jan 2013
    Location
    Germany, Freiburg i. Br.
    Posts
    31
    Vote Rating
    8
    StudentDaniel will become famous soon enough

      1  

    Default


    BUG is now reported - hope next version can manage this :-)

    https://github.com/senchalabs/jsduck/issues/519