dcodeIO/ProtoBuf.js — pull request #81 by jandrieu (2013-11-28 00:16:54+00:00)
Title: test protos in /tests/proto2js/Tests/ for testing imports

These three protos will demonstrate/test imports. Note that the current imports with proto2js don't quite work. Here's what this protojs command
```
node proto2js ..\tests\proto2js\Tests\MediaDevice.proto -path=..\tests\proto2js
```

with this in MediaDevice.proto:
```
import "Tests/MediaPlayer.proto";
import "Tests/ZmqMediaPlayer.proto";
```

generates

```
{
"package": null,
"messages": [
{
"name": "MediaDevicePbm",
"fields": [
{
"rule": "optional",
"type": "bool",
"name": "auto_play",
"id": 1,
"options": {}
},
{
"rule": "optional",
"type": "MediaPlayerPbm",
"name": "media_player",
"id": 30,
"options": {}
},
{
"rule": "optional",
"type": "ZmqMediaPlayerPbm",
"name": "zmq_media_player",
"id": 31,
"options": {}
}
],
"enums": [],
"messages": [],
"options": {}
}
],
"enums": [],
"imports": [
{
"package": null,
"messages": [
{
"name": "ZmqMediaPlayerPbm",
"fields": [
{
"rule": "optional",
"type": "bool",
"name": "test",
"id": 1,
"options": {}
}
],
"enums": [],
"messages": [
{
"ref": "MediaPlayerPbm",
"fields": [
{
"rule": "optional",
"type": "ZmqMediaPlayerPbm",
"name": "zmq_media_player",
"id": 310,
"options": {}
}
]
}
],
"options": {}
}
],
"enums": [],
"imports": [
"Tests/MediaPlayer.proto"
],
"options": {},
"services": []
},
"Tests/ZmqMediaPlayer.proto"
],
"options": {},
"services": []
}
```

Unfortunately, "Tests/MediaPlayer.proto" fails to get imported TWICE. It should be in both the MediaDevice message and the ZmqMediaPlayer (unless you avoid duplication, which I think the code does try to do). Also "Tests/ZmqMediaPlayer.proto" remains listed as an import, even though it already has been turned into JSON.