calio / lua-capnproto

Lua-capnp is a pure lua implementation of capnproto based on luajit.
BSD 2-Clause "Simplified" License
70 stars 24 forks source link

test install #10

Closed sjnam closed 8 years ago

sjnam commented 8 years ago

1. after install lua-capnproto by luarocks, the following test does not work.

$ capnp compile -olua proto/example.capnp

2. File main.lua of example directory id should be interger not string.

calio commented 8 years ago

About 1, can you provide the command you run and the error message?

About 2, id should be a string. Why do you think it should be an integer?

sjnam commented 8 years ago
  1. error message
luajit: /usr/local/share/lua/5.1/capnp/compile.lua:1184: imported file "enums.capnp" is missing, compile it together withother Cap'n Proto files
stack traceback:
    [C]: in function 'error'
    /usr/local/share/lua/5.1/capnp/compile.lua:1184: in function 'check_import'
    /usr/local/share/lua/5.1/capnp/compile.lua:1162: in function 'comp_body'
    /usr/local/share/lua/5.1/capnp/compile.lua:1294: in function 'compile'
    stdin:71: in main chunk
    [C]: at 0x01000013f0
lua: plugin failed: exit code 1

2. you defined id by UInt32.

id @0 :UInt32;

and if id is string then I got result

{"people":[{"id":0,"employment":{"school":"MIT"},"email":"alice@example.com","name":"Alice","phones":[{"number":"555-1212","type":"MOBILE"}]},{"id":0,"employment":{"unemployed":"Void"},"email":"bob@example.com","name":"Bob","phones":[{"number":"555-4567","type":"HOME"},{"number":"555-7654","type":"WORK"}]}]}

the json id is 0

calio commented 8 years ago
  1. Yes, the document is old. You do need to compile all the schema files together like this:

    $ capnp compile -olua proto/example.capnp proto/enums.capnp proto/lua.capnp proto/struct.capnp

  2. That id should be a number. I though about something else.

Nice catch, thanks.

calio commented 8 years ago

Merged, thanks!