最近在对JScript进行面向对象的扩展,使得大家以后可以在JScript(TM)中定义类,并写出真正的面向对象的代码。
我对扩展了的JScript取了名字,叫OxScript,打算实现的features如下:
OxScript is an Object-Oriented extension for JavaScript.
The following features will be provided by OxScript:
1. class definition;
2. final class;
3. abstract class;
4. inheritance;
5. overriding;
6. abstract function;
7. polymorphism;
8. package;
9. property getter/setter;
10. reflection(readonly);
大体的Specification如下:
[Access Modifiers]
public, protected, private,
static, abstract, final, virtual
[Directives]
$include, $import,
$package, $class,
$field, $method, $property, $event
[Additional Keywords]
extend, implement,
public, protected, private, static,
get, set
[Additional Operators]
classof, raise
[Predefined Classes]
class Package extend Object {
public :
protected :
private :
}
class Class extend Object {
public :
protected :
private :
}
class Member extend Object {
public :
protected :
private :
}
class Field extend Member {
public :
protected :
private :
}
class Method extend Member {
public :
protected :
private :
}
class Property extend Member {
public :
protected :
private :
}
class Event extend Member {
public :
protected :
private :
}
[Class Hierarchy]
OxScript.Object
|--OxScript.Number
|--OxScript.String
|--OxScript.Boolean
|--OxScript.Date
|--OxScript.Array
|--OxScript.Enumerator
|--OxScript.Function
|--OxScript.RegExp
|--OxScript.VBArray
|--OxScript.Error
|--OxScript.ActiveXObject
|
|--OxScript.Reflection.Package
|--OxScript.Class
|--OxScript.Reflection.Member
|--OxScript.Reflection.Field
|--OxScript.Reflection.Method
|--OxScript.Reflection.Property
|--OxScript.Reflection.Event
下面是一段代码示例: