src/js/oop.js
function $cpMethods(src, dest, clazz) {
    var overriddenAbstractMethods = 0;
    for(var name in src) {
        if (name   !==  CNAME        &&
            name   !== "clazz"       &&
            src.hasOwnProperty(name)   )
        {
            var method = src[name];
            if (typeof method === "function" && method !== $toString) {
                if (name === "$prototype") {
                    method.call(dest, clazz);
                } else {
                    // TODO analyze if we overwrite existent field
                    if (dest[name] !== undefined) {
                        // abstract method is overridden, let's skip abstract method
                        // stub implementation
                        if (method.$isAbstract === true) {
                            overriddenAbstractMethods++;
                            continue;
                        }

                        if (dest[name].boundTo === clazz) {
                            throw new Error("Method '" + name + "(...)'' bound to this class already exists");
                        }
                    }

                    if (method.methodBody !== undefined) {
                        dest[name] = $ProxyMethod(name, method.methodBody, clazz);
                    } else {
                        dest[name] = $ProxyMethod(name, method, clazz);
                    }

                    // save information about abstract method
                    if (method.$isAbstract === true) {
                        dest[name].$isAbstract = true;
                    }
                }
            }
        }
    }
    return overriddenAbstractMethods;
}
function $cpMethods(src, dest, clazz) {
    var overriddenAbstractMethods = 0;
    for(var name in src) {
        if (name   !==  CNAME        &&
            name   !== "clazz"       &&
            src.hasOwnProperty(name)   )
        {
            var method = src[name];
            if (typeof method === "function" && method !== $toString) {
                if (name === "$prototype") {
                    method.call(dest, clazz);
                } else {
                    // TODO analyze if we overwrite existent field
                    if (dest[name] !== undefined) {
                        // abstract method is overridden, let's skip abstract method
                        // stub implementation
                        if (method.$isAbstract === true) {
                            overriddenAbstractMethods++;
                            continue;
                        }

                        if (dest[name].boundTo === clazz) {
                            throw new Error("Method '" + name + "(...)'' bound to this class already exists");
                        }
                    }

                    if (method.methodBody !== undefined) {
                        dest[name] = $ProxyMethod(name, method.methodBody, clazz);
                    } else {
                        dest[name] = $ProxyMethod(name, method, clazz);
                    }

                    // save information about abstract method
                    if (method.$isAbstract === true) {
                        dest[name].$isAbstract = true;
                    }
                }
            }
        }
    }
    return overriddenAbstractMethods;
}
function $cpMethods ( src , dest , clazz ) { var overriddenAbstractMethods = 0 ; for ( var name in src ) { if ( name !== CNAME && name !== "clazz" && src . hasOwnProperty ( name ) ) { var method = src [ name ] ; if ( typeof method === "function" && method !== $toString ) { if ( name === "$prototype" ) { method . call ( dest , clazz ) ; } else { // TODO analyze if we overwrite existent field if ( dest [ name ] !== undefined ) { // abstract method is overridden, let's skip abstract method // stub implementation if ( method . $isAbstract === true ) { overriddenAbstractMethods ++ ; continue ; } if ( dest [ name ] . boundTo === clazz ) { throw new Error ( "Method '" + name + "(...)'' bound to this class already exists" ) ; } } if ( method . methodBody !== undefined ) { dest [ name ] = $ProxyMethod ( name , method . methodBody , clazz ) ; } else { dest [ name ] = $ProxyMethod ( name , method , clazz ) ; } // save information about abstract method if ( method . $isAbstract === true ) { dest [ name ] . $isAbstract = true ; } } } } } return overriddenAbstractMethods ; }
copy methods from source to destination
copy methods from source to destination