1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// #Class
(function() {
    'use strict';
    var Class = adun.Class = function(definition) {
 
        if( definition == null ) {
            throw new Error('definition is undefined (adun.Class)');
        }
        if!definition.TYPE ) {
            throw new Error('definition.TYPE is undefined (adun.Class)');
        }
 
        var name, extend = definition.extend;
        var prototype = {};
 
        if( extend && adun.isObject(extend)) {
            if( extend.constructor != adun.Class ) {
                throw new Error('extend constructor is not adun.Class (adun.Class)');
            }
 
            prototype = new extend('!ADUN.INIT');
        }
 
 
        forname in definition ) {
            if( adun.isPlainObject(definition[name]) && Object.getPrototypeOf(definition[name]) === Object.prototype ) {
                definition[name= definition[name];
                definition[name].enumerable = true;
            } else {
                definition[name= {
                    value: ( adun.isFunction(definition[name]) && adun.isFunction(prototype[name]) ) ?
                        (function(name, fn) {
                            return function() {
                                this.super = prototype[name];
                                var ret = fn.apply(this, arguments);
                                delete this.super;
                                return ret;
                            };
                        })(name, definition[name]) :
                        definition[name],
 
                    enumerable: true,
                    writable: true
                };
            }
        }
 
        var Class = function() {
            if( this.init && arguments[0!== '!ADUN.INIT' ) {
                this.init.apply(this, arguments);
            }
            if!this.objType ) {
                this.objType = function() {
                    return this.TYPE;
                }
            }
        };
        Class.prototype = Object.create(prototype, definition);
        Class.constructor = adun.Class;
 
        return Class;
    };
})();
 
 
// -----------------------------------
 
var Person = adun.Class({
    TYPE: 'Person',
 
    init: function(name, id, age) {
        this.name = name;
        this._id = id;
    },
    id: {
        set: function() {},
        get: function() {
            return this._id;
        }
    },
    talk: function() {
        alert('제 이름은 ' + this.name + "입니다.");
    }
});
 
var Student = adun.Class({
    extend: Person,
    TYPE: 'Student',
 
    init: function(name, id, age) {
        this.super(name, id);
        this.age = age;
    },
    talk: function() {
        alert('제 이름은 ' + this.name + "이고 나이는 " + this.age + "입니다.");
    }
});
 
var p = new Student('아둔''940101'23);
cs