christiank/npflua — pull request #1 by cypheratheist (2014-08-13 10:05:32+00:00)
Title: Updated for -current, and did some restructuring

Hello,

I did some updates. The problem you saw with the segfault was due to a resource being used after it had been released. Although I like abstraction layers to be thin, they can be a little _too_ thin, so I added a few structures for storing extra data if needed (and because it has a clearer separation between lua objects and npf structures).

I like to use Lua's not-really-objects-but-kinda', but I'm not sure if you want to go that way, so I made a hybrid, to illustrate:
Note that the "config" object has a metatable with methods, so an "conf" object can be called using "conf:(params)" syntax. Unfortunately the npf API isn't always trivially translated to an OO-like structure, so we would need to toss around argument order in the Lua interface. Input on whether this is a path we want to take or not is welcome. (Just to be clear: While the config objects pretty trivially support "flat functions" and an OO-like interface at once, other datatypes don't necessarily do so, so we probably need to chose one and run with that).

Also, I turned up the crankyness of clang's warning flags, and treat warnings as errors.

It may look like I removed some of your useful features, like "*" for "any interface", but what happened was that the interface to npf has changed so much that nil suddenly became available for "any interface" (like NULL in the C API).