a
構文
class
- public,protected,privateは無し。
- 継承もなし。
- コンストラクタ,デストラクタは有り。
- operatorは可能?(未確認)
import
他のmoduleの関数(Typeは不可)を自分のmodule内で使うための機能。
なので,一工夫したほうがいいかも。
その一例。
実装クラス(L_MathVector3)はIObjectを必ず継承する。
外部に公開する関数(F_MathVector3_*)はクラス外に宣言し,引数の先頭に必ずIObjectをとる。
他のモジュールは,公開されたその関数を通してアクセスするか,そのラッパークラス(MathVector3)を使ってアクセスする。
- C++コード
1
2
3
4
5
6
7
8
|
| #spanend
#spanadd
#spanend
#spanadd
engine->RegisterInterface("IObject");
#spanend
#spanadd
|
- Vector3_Local.as
こいつは,mathモジュールでのみコンパイルされる。
クラスの内部実装を記述している。
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
|
-
|
|
|
|
|
|
|
|
|
-
|
!
|
|
|
|
-
|
!
|
!
-
|
|
|
|
!
-
|
|
|
!
-
|
|
|
!
| #spanend
#spanadd
#spanend
#spanadd
class L_MathVector3 : IObject
#spanend
#spanadd
{
#spanend
L_MathVector3(){ }
float mX;
float mY;
float mZ;
#spanadd
#spanend
float& x()
{
return mX;
}
#spanadd
#spanend
void normalize()
{
}
#spanadd
};
#spanend
#spanadd
IObject@ F_MathVector3_Constructor()
#spanend
#spanadd
{
#spanend
MathVector3 obj;
return @obj;
#spanadd
}
#spanend
#spanadd
#spanend
#spanadd
float& F_MathVector3_x( const IObject@ in obj )
#spanend
#spanadd
{
#spanend
return cast<L_Vector3>(obj).mX;
#spanadd
}
#spanend
#spanadd
void F_MathVector3_normalize( IObject@ obj )
#spanend
#spanadd
{
#spanend
cast<L_Vector3>(obj).normalize();
#spanadd
}
#spanend
#spanadd
#spanend
#spanadd
|
- Vector3.as
こいつは,他のmoduleでコンパイルされる。
クラスの内部実装は書かず,内部実装が書かれている関数を呼ぶだけに留める。
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
|
-
|
|
-
|
!
|
|
|
|
|
-
|
!
|
|
|
|
-
|
!
|
!
| #spanend
#spanadd
#spanend
#spanadd
import IObject@ F_MathVector3_Constructor() from "math";
#spanend
#spanadd
import float& F_MathVector3_x( const IObject& in ) from "math";
#spanend
#spanadd
import void F_MathVector3_normalize( const IObject& in ) from "math";
#spanend
#spanadd
class MathVector3
#spanend
#spanadd
{
#spanend
MathVector3()
{
mObj = F_MathVector3_Constructor();
}
IObject@ mObj;
#spanadd
#spanend
float& x()
{
return F_MathVector3_x( mObj );
}
#spanadd
#spanend
void normalize()
{
F_MathVector3_normalize( mObj );
}
#spanadd
};
#spanend
#spanadd
|
|