Skip to content

Commit 5cbe5f6

Browse files
committed
coffee2string
1 parent 23c8d1d commit 5cbe5f6

File tree

1 file changed

+49
-7
lines changed

1 file changed

+49
-7
lines changed

coffee2string/README.md

+49-7
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,50 @@ run
108108

109109

110110
## やらなきゃいけない事
111-
1. class実装
112-
2. 循環参照問題
113-
3. coffee特有の対応
114-
115-
116-
111+
1. serializeする必要のないJS実装を除外
112+
2. class実装
113+
3. 循環参照問題
114+
4. coffee特有の対応
115+
116+
117+
### 1. serializeする必要のないJS実装を除外
118+
https://github.com/crumbjp/test/blob/master/coffee2string/coffee2string.coffee#L3
119+
- __defineGetter__
120+
- __defineSetter__
121+
- __lookupGetter__
122+
- __lookupSetter__
123+
- constructor
124+
- hasOwnProperty
125+
- isPrototypeOf
126+
- propertyIsEnumerable
127+
- toLocaleString
128+
- toString
129+
- valueOf
130+
- apply
131+
- arguments
132+
- bind
133+
- call
134+
- caller
135+
- length
136+
- name
137+
- prototype
138+
139+
### 2. class実装
140+
https://github.com/crumbjp/test/blob/master/coffee2string/coffee2string.coffee#L89
141+
`__super__` はcoffeeの独自実装で、superクラスがそのまま入っている
142+
143+
### 3. 循環参照問題
144+
https://github.com/crumbjp/test/blob/master/coffee2string/coffee2string.coffee#L44
145+
Objectをトラバースする際、Objectを発見したら全て変数に起き直す
146+
循環参照を発見したら、同じ参照を置いておけば良い。
147+
https://github.com/crumbjp/test/blob/master/coffee2string/coffee2string.coffee#L72
148+
149+
### 4. coffee特有の対応
150+
おまじないを置いておく必要がある
151+
https://github.com/crumbjp/test/blob/master/coffee2string/coffee2string.coffee#L35
152+
153+
154+
## 結果
117155
```js
118156
coffee2string = require './coffee2string'
119157
jsString = coffee2string Foo
@@ -155,4 +193,8 @@ Foo.prototype['run'] = function () {
155193
}
156194
157195
Foo::bar
158-
```
196+
```
197+
198+
## 残課題
199+
`require`問題が残っている
200+
結局、erlangの様に言語レベルでRPCが想定されていない限り、ある程度のお約束事を規定するしか無いようだ。

0 commit comments

Comments
 (0)