六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 73|回复: 0

GI Summary

[复制链接]

升级  12.67%

15

主题

15

主题

15

主题

秀才

Rank: 2

积分
69
 楼主| 发表于 2013-1-19 04:14:09 | 显示全部楼层 |阅读模式
1. GI的JS框架中也有类似Java的Reflect的特性,比如forName()方法。
2. GI的JS中也是单根继承, 可以实现多个接口。需要定义constructor,名字必须是init(). Class/Interface中可以定义成员方法, 静态方法和抽像方法,成员变量,静态变量.
例子在下面一断代码块里, 从GI的API里拷出来的。
/*You may obtain an instance of jsx3.lang.Class in one of the following ways: */var c = jsx3.Class.forName("jsx3.Object");var c = jsx3.Object.jsxclass;/*This class is also used for defining classes. Use one of defineClass and defineInterface to define a class in the JSX class hierarchy. Note that any class defined in the package jsx3.lang is aliased into the jsx3 package. Therefore jsx3.lang.Object may also be referenced as jsx3.Object. The following are class nomenclature definitions using jsx3.lang.Object as an example:*//*jsx3.lang — the package, an instance of (JavaScript, not JSX) Object jsx3.lang.Object — the class constructor, instance of Function jsx3.lang.Object.jsxclass — the class, instance of jsx3.lang.Class jsx3.lang.Object.prototype — the class prototype, instance of Object The following is an example of how to define a new class called Example in package eg: */jsx3.lang.Class.defineClass(  "eg.Example",                   // the full name of the class to create  eg.Base,                        // the class extends eg.Base  [eg.Comparable, eg.Testable],   // the class implements interfaces eg.Comparable and eg.Testable  function(Example) {             // name the argument of this function "Example"        // every class must define an init method since it is called automatically by the constructor    Example.prototype.init = function(arg1) {      this.arg1 = arg1;    };    // define an instance method like this:    Example.prototype.instanceMethod = function() {      ...    };    // define an abstract method like this:    Example.prototype.abstractMethod = jsx3.Method.newAbstract();    // define a static method like this:    Example.staticMethod = function() {      ...    };    // define a static field like this:    Example.STATIC_FIELD = "...";    // define an instance field like this:    Example.prototype.instanceField = "...";  });
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表