GI Summary - Jan 28, 2011: 如何在GI中定义Class.

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 = "...";
}
);
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
06-01 03:22:44.935 W/ ( 0): ==20210817==> hub_port_init 1 #2 06-01 03:22:44.935 W/ ( 0): Plug in USB Port2 06-01 03:22:44.938 W/ ( 0): [GLUE]__Glue_PM_SetupEthernetWakeup Disable WOL!! 06-01 03:22:44.938 W/ ( 0): [GLUE]__Glue_PM_SetupEthernetWakeup (EEP_WOW = 0) _gi4PDWNCWifiWowState=1 !! 06-01 03:22:44.938 W/ ( 0): [GLUE]__Glue_PM_SetupEthernetWakeup (EEP_WOL = 0) !! 06-01 03:22:44.938 W/ ( 0): [GLUE]Disable WOW 06-01 03:22:44.938 W/ ( 0): [GLUE]Enable WOBT, _u8BtGpioNum = 13 , Polarity = 1 06-01 03:22:44.938 W/ ( 0): [GLUE]Enable WOEWBS, _u8EwbsGpioNum = 255 , Polarity = 1 06-01 03:22:44.938 W/ ( 0): get env pu8Env = ENABLE_WAKEUP 06-01 03:22:44.941 W/ ( 0): Get Value 0 06-01 03:22:44.941 W/ ( 0): [GLUE]__Glue_PM_SetupVoiceWakeup[2321] _bWovEnable is 0 06-01 03:22:44.941 W/ ( 0): [GLUE]__Glue_PM_UpdateWakeupConfig(2637) Force Enable IR&SAR PM Wakeup! . 06-01 03:22:44.941 W/ ( 0): [GLUE]Disable VGA PM Wakeup 06-01 03:22:44.941 W/ ( 0): [GLUE]Enable CEC PM Wakeup 06-01 03:22:44.941 W/ ( 0): [GLUE]Disable WOL PM Wakeup 06-01 03:22:44.941 W/ ( 0): [GLUE]Disable Voice Wakeup 06-01 03:22:44.941 W/ ( 0): [GLUE]u8PmWakeWowLanGpioNumber = 255 , Polarity = 255 06-01 03:22:44.941 W/ ( 0): [GLUE]u8PmWakeBtGpioNumber = 13 , Polarity = 1 06-01 03:22:44.941 W/ ( 0): [GLUE] u8PmWakeEwbsGpioNumber = 255 , Polarity = 1 06-01 03:22:44.941 W/ ( 0): [GLUE]__Glue_PM_ResetWakeupSource[3070] done. 06-01 03:22:44.941 W/ ( 0): [GLUE] __Glue_PM_SuspendClearFlag done 06-01 03:22:44.942 W/ ( 0): __Glue_PM_EWBSWakeunlock 翻译这顿log
最新发布
06-07
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值