1 Type.prototype.registerClass = function Type$registerClass(typeName, baseType, interfaceTypes) {
7 var e = Function._validateParams(arguments, [
8 {name: "typeName", type: String},
9 {name: "baseType", type: Type, mayBeNull: true, optional: true},
10 {name: "interfaceTypes", type: Type, parameterArray: true}
11 ]);
12 if (e) throw e;
13 if (!Type.__fullyQualifiedIdentifierRegExp.test(typeName)) throw Error.argument('typeName', Sys.Res.notATypeName);
14 var parsedName;
15 try {
16 parsedName = eval(typeName);
17 }
18 catch(e) {
19 throw Error.argument('typeName', Sys.Res.argumentTypeName);
20 }
21 if (parsedName !== this) throw Error.argument('typeName', Sys.Res.badTypeName);
22 if (Sys.__registeredTypes[typeName]) throw Error.invalidOperation(String.format(Sys.Res.typeRegisteredTwice, typeName));
23 if ((arguments.length > 1) && (typeof(baseType) === 'undefined')) throw Error.argumentUndefined('baseType');
24 if (baseType && !baseType.__class) throw Error.argument('baseType', Sys.Res.baseNotAClass);
25 this.prototype.constructor = this;
26 this.__typeName = typeName;
27 this.__class = true;
28 if (baseType) {
29 this.__baseType = baseType;
30 this.__basePrototypePending = true;
31 }
32 Sys.__upperCaseTypes[typeName.toUpperCase()] = this;
33 if (interfaceTypes) {
34 this.__interfaces = [];
35 this.resolveInheritance();
36 for (var i = 2, l = arguments.length; i < l; i++) {
37 var interfaceType = arguments[i];
38 if (!interfaceType.__interface) throw Error.argument('interfaceTypes[' + (i - 2) + ']', Sys.Res.notAnInterface);
39 for (var methodName in interfaceType.prototype) {
40 var method = interfaceType.prototype[methodName];
41 if (!this.prototype[methodName]) {
42 this.prototype[methodName] = method;
43 }
44 }
45 this.__interfaces.push(interfaceType);
46 }
47 }
48 Sys.__registeredTypes[typeName] = true;
49 return this;
50 }