starwing / lua-protobuf

A Lua module to work with Google protobuf
MIT License
1.75k stars 387 forks source link

protoc.lua: some methods not accessible #36

Closed seabadger closed 6 years ago

seabadger commented 6 years ago
local protoc = require "protoc"
local p = protoc.new()
local idlfile = "google/protobuf/any.proto"
-- p.paths[#p.paths+1] = ...  -- set to wherever the .proto files live
p.include_imports = true

assert(p:parsefile( relidlfile ))
assert(p:reload())
assert(p:compilefile( relidlfile ))

In the above sequence, the call to parsefile succeds. For both of the subsequent calls, I get a message such as:

luajit: test_pb.lua:8: attempt to call method 'reload' (a nil value)

And indeed, printing the contents of the table, I see that those methods are missing:

{
  include_imports = true,
  loaded = {},
  paths = { ".",  },
  typemap = {},
  <metatable> = <1>{
    __index = <table 1>,
    __name = "Parser",
    addpath = <function 1>,
    error = <function 2>,
    loaded = {},
    new = <function 3>,
    parse = <function 4>,
    parsefile = <function 5>,
    paths = { "." },
    resolve = <function 6>,
    typemap = {}
  }
}
starwing commented 6 years ago

it might be fixed, close.